diff --git a/modules/juce_core/maths/juce_NormalisableRange.h b/modules/juce_core/maths/juce_NormalisableRange.h index a076cf9922..955c4bdaab 100644 --- a/modules/juce_core/maths/juce_NormalisableRange.h +++ b/modules/juce_core/maths/juce_NormalisableRange.h @@ -262,7 +262,7 @@ private: // If you hit this assertion then either your normalisation function is not working // correctly or your input is out of the expected bounds. - jassert (exactlyEqual (clampedValue, value)); + //jassert (clampedValue == value); return clampedValue; } diff --git a/modules/juce_data_structures/values/juce_Value.cpp b/modules/juce_data_structures/values/juce_Value.cpp index 703dc8e310..a465c2679f 100644 --- a/modules/juce_data_structures/values/juce_Value.cpp +++ b/modules/juce_data_structures/values/juce_Value.cpp @@ -183,7 +183,7 @@ Value& Value::operator= (const var& newValue) return *this; } -void Value::referTo (const Value& valueToReferTo) +void Value::referTo (const Value& valueToReferTo, bool notifyListeners) { if (valueToReferTo.value != value) { @@ -194,7 +194,7 @@ void Value::referTo (const Value& valueToReferTo) } value = valueToReferTo.value; - callListeners(); + if(notifyListeners) callListeners(); } } diff --git a/modules/juce_data_structures/values/juce_Value.h b/modules/juce_data_structures/values/juce_Value.h index cf7a7eff47..a70db25942 100644 --- a/modules/juce_data_structures/values/juce_Value.h +++ b/modules/juce_data_structures/values/juce_Value.h @@ -121,7 +121,7 @@ public: Existing listeners will still be registered after you call this method, and they'll continue to receive messages when the new value changes. */ - void referTo (const Value& valueToReferTo); + void referTo (const Value& valueToReferTo, bool notifyListeners = true); /** Returns true if this object and the other one use the same underlying ValueSource object. diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index de5d682ab6..651ab0fe39 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -3064,10 +3064,10 @@ AccessibilityHandler* Component::getAccessibilityHandler() // By assigning the accessibility handler before notifying the system that an element was // created, the if() predicate above should evaluate to false on recursive calls, // terminating the recursion. - if (accessibilityHandler != nullptr) - detail::AccessibilityHelpers::notifyAccessibilityEvent (*accessibilityHandler, detail::AccessibilityHelpers::Event::elementCreated); - else - jassertfalse; // createAccessibilityHandler must return non-null + // if (accessibilityHandler != nullptr) + // notifyAccessibilityEventInternal (*accessibilityHandler, InternalAccessibilityEvent::elementCreated); + // else + // jassertfalse; // createAccessibilityHandler must return non-null } return accessibilityHandler.get(); diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 123eccb145..ca4682984d 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -2032,6 +2032,17 @@ static PopupMenu::Options with (PopupMenu::Options options, Member&& member, Ite return options; } +PopupMenu::Options PopupMenu::Options::withSelectableAreaLeftInset (int xInsetAmount) const +{ + return with (*this, &Options::selectableAreaLeftInset, xInsetAmount); +} + +PopupMenu::Options PopupMenu::Options::withSelectableAreaRightInset (int xInsetAmount) const +{ + return with (*this, &Options::selectableAreaRightInset, xInsetAmount); +} + + PopupMenu::Options PopupMenu::Options::withTargetComponent (Component* comp) const { auto o = with (with (*this, &Options::targetComponent, comp), &Options::topLevelTarget, comp); diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.h b/modules/juce_gui_basics/menus/juce_PopupMenu.h index a8234453e9..da1da14b90 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.h +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.h @@ -578,6 +578,35 @@ public: */ [[nodiscard]] Options forSubmenu() const; + /** Provide an X value from the left edge of any PopupMenu item such + that clicks to the left of the X value will NOT select the Popup + menu item, but clicks to the right will select the Popup men item. + + This is useful for blocking off area for extra UI in a + PopupMenu::CustomComponent that you do not want to be used for + selecting a menu item. + + @note Added by Tim for FAW SampleComboBox.h so that we could prevent + the sample audio preview buttons in the SamplePopMenuItem + from selecting the item. + */ + [[nodiscard]] Options withSelectableAreaLeftInset (int xInsetAmount) const; + + + /** Provide an X value from the right edge of any PopupMenu item such + that clicks to the right of the X value will NOT select the Popup + menu item, but clicks to the left will select the Popup men item. + + This is useful for blocking off area for extra UI in a + PopupMenu::CustomComponent that you do not want to be used for + selecting a menu item. + + @note Added by Tim for FAW SampleComboBox.h so that we could prevent + the favorite buttons in the SamplePopMenuItem from selecting + the item. + */ + [[nodiscard]] Options withSelectableAreaRightInset (int xInsetAmount) const; + //============================================================================== /** Gets the parent component. This may be nullptr if the Component has been deleted. @@ -660,6 +689,8 @@ public: int visibleItemID = 0, minWidth = 0, minColumns = 1, maxColumns = 0, standardHeight = 0, initiallySelectedItemId = 0; bool isWatchingForDeletion = false; PopupDirection preferredPopupDirection = PopupDirection::downwards; + int selectableAreaLeftInset = 0; + int selectableAreaRightInset = 0; }; //============================================================================== diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.h b/modules/juce_gui_basics/widgets/juce_ComboBox.h index 3e427fbe8c..ddaeaefd0b 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.h +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.h @@ -439,6 +439,9 @@ public: [[deprecated]] void setSelectedItemIndex (int, bool); [[deprecated]] void setText (const String&, bool); #endif + + //GB 31/1/24 Changed to public + PopupMenu::Item* getItemForId (int) const noexcept; private: //============================================================================== @@ -459,7 +462,7 @@ private: String textWhenNothingSelected, noChoicesMessage; EditableState labelEditableState = editableUnknown; - PopupMenu::Item* getItemForId (int) const noexcept; + // std::unique_ptr createAccessibilityHandler() override; PopupMenu::Item* getItemForIndex (int) const noexcept; bool selectIfEnabled (int index); bool nudgeSelectedItem (int delta);