Skip to content

Commit

Permalink
Adding in PopMenu left and right insert
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinFAW committed Dec 6, 2023
1 parent 69795dc commit bb9b531
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/juce_gui_basics/menus/juce_PopupMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2357,6 +2357,16 @@ bool PopupMenu::MenuItemIterator::next()
return true;
}

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::Item& PopupMenu::MenuItemIterator::getItem() const
{
jassert (currentItem != nullptr);
Expand Down
31 changes: 31 additions & 0 deletions modules/juce_gui_basics/menus/juce_PopupMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,37 @@ class JUCE_API PopupMenu

/** Sets the direction of the popup menu relative to the target screen area. */
[[nodiscard]] Options withPreferredPopupDirection (PopupDirection direction) 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;


/** Sets an item to select in the menu.
Expand Down

0 comments on commit bb9b531

Please sign in to comment.