mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added a LookAndFeel method to customise the options of a ComboBox's PopupMenu
This commit is contained in:
parent
fefbbc89b4
commit
64be913fa2
4 changed files with 16 additions and 6 deletions
|
|
@ -1199,6 +1199,15 @@ void LookAndFeel_V2::positionComboBoxText (ComboBox& box, Label& label)
|
|||
label.setFont (getComboBoxFont (box));
|
||||
}
|
||||
|
||||
PopupMenu::Options LookAndFeel_V2::getOptionsForComboBoxPopupMenu (ComboBox& box, Label& label)
|
||||
{
|
||||
return PopupMenu::Options().withTargetComponent (&box)
|
||||
.withItemThatMustBeVisible (box.getSelectedId())
|
||||
.withMinimumWidth (box.getWidth())
|
||||
.withMaximumNumColumns (1)
|
||||
.withStandardItemHeight (label.getHeight());
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
Font LookAndFeel_V2::getLabelFont (Label& label)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -193,6 +193,7 @@ public:
|
|||
Font getComboBoxFont (ComboBox&) override;
|
||||
Label* createComboBoxTextBox (ComboBox&) override;
|
||||
void positionComboBoxText (ComboBox&, Label&) override;
|
||||
PopupMenu::Options getOptionsForComboBoxPopupMenu (ComboBox&, Label&) override;
|
||||
|
||||
//==============================================================================
|
||||
void drawLabel (Graphics&, Label&) override;
|
||||
|
|
|
|||
|
|
@ -545,12 +545,10 @@ void ComboBox::showPopup()
|
|||
menu.addItem (1, noChoicesMessage, false, false);
|
||||
}
|
||||
|
||||
menu.setLookAndFeel (&getLookAndFeel());
|
||||
menu.showMenuAsync (PopupMenu::Options().withTargetComponent (this)
|
||||
.withItemThatMustBeVisible (getSelectedId())
|
||||
.withMinimumWidth (getWidth())
|
||||
.withMaximumNumColumns (1)
|
||||
.withStandardItemHeight (label->getHeight()),
|
||||
auto& lookAndFeel = getLookAndFeel();
|
||||
|
||||
menu.setLookAndFeel (&lookAndFeel);
|
||||
menu.showMenuAsync (lookAndFeel.getOptionsForComboBoxPopupMenu (*this, *label),
|
||||
ModalCallbackFunction::forComponent (comboBoxPopupMenuFinishedCallback, this));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -376,6 +376,8 @@ public:
|
|||
virtual Label* createComboBoxTextBox (ComboBox&) = 0;
|
||||
|
||||
virtual void positionComboBoxText (ComboBox&, Label& labelToPosition) = 0;
|
||||
|
||||
virtual PopupMenu::Options getOptionsForComboBoxPopupMenu (ComboBox&, Label&) = 0;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue