2
0
Fork 0

Legato voices popup menu scaling fix

This commit is contained in:
George Reales 2021-09-09 17:30:38 +02:00
parent f9a575d03b
commit 3593583161
2 changed files with 36 additions and 3 deletions

View file

@ -15,6 +15,8 @@
class ObxdAudioProcessor; class ObxdAudioProcessor;
//============================================================================== //==============================================================================
class ScalableComponent class ScalableComponent
{ {
@ -39,3 +41,22 @@ private:
bool isHighResolutionDisplay; bool isHighResolutionDisplay;
}; };
//==============================================================================
class CustomLookAndFeel : public LookAndFeel_V3,
public ScalableComponent
{
public:
CustomLookAndFeel(ObxdAudioProcessor* owner_):LookAndFeel_V3(), ScalableComponent(owner_) {
this->setColour(PopupMenu::backgroundColourId, Colour(20, 20, 20));
this->setColour(PopupMenu::textColourId, Colour(245, 245, 245));
this->setColour(PopupMenu::highlightedBackgroundColourId, Colour(60, 60, 60));
};
PopupMenu::Options getOptionsForComboBoxPopupMenu (ComboBox& box, Label& label) override
{
PopupMenu::Options option = LookAndFeel_V3::getOptionsForComboBoxPopupMenu(box, label);
return option.withStandardItemHeight (label.getHeight()/ getScaleFactor());
};
};

View file

@ -122,6 +122,7 @@ void ObxdAudioProcessorEditor::resized() {
} }
else if (dynamic_cast<ButtonList*>(mappingComps[name])){ else if (dynamic_cast<ButtonList*>(mappingComps[name])){
mappingComps[name]->setBounds(transformBounds(x, y, w, h)); mappingComps[name]->setBounds(transformBounds(x, y, w, h));
//((ButtonList *)mappingComps[name])->getRootMenu()->setLookAndFeel(& getLookAndFeel());
} }
else if (dynamic_cast<TooglableButton*>(mappingComps[name])){ else if (dynamic_cast<TooglableButton*>(mappingComps[name])){
@ -477,12 +478,16 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
if (name == "voiceSwitch"){ if (name == "voiceSwitch"){
voiceSwitch = addList (x, y, w, h, ownerFilter, VOICE_COUNT, "VoiceCount", "voices"); voiceSwitch = addList (x, y, w, h, ownerFilter, VOICE_COUNT, "VoiceCount", "voices");
CustomLookAndFeel *lf = new CustomLookAndFeel(&this->processor);
voiceSwitch->setLookAndFeel(lf);
mappingComps["voiceSwitch"] = voiceSwitch; mappingComps["voiceSwitch"] = voiceSwitch;
} }
if (name == "legatoSwitch"){ if (name == "legatoSwitch"){
legatoSwitch = addList (x, y, w, h, ownerFilter, LEGATOMODE, "Legato", "legato"); legatoSwitch = addList (x, y, w, h, ownerFilter, LEGATOMODE, "Legato", "legato");
CustomLookAndFeel *lf = new CustomLookAndFeel(&this->processor);
legatoSwitch->setLookAndFeel(lf);
mappingComps["legatoSwitch"] = legatoSwitch; mappingComps["legatoSwitch"] = legatoSwitch;
} }
@ -587,9 +592,16 @@ void ObxdAudioProcessorEditor::scaleFactorChanged()
{ {
object->setScaleFactor(scaleFactor, highResolutionDisplay); object->setScaleFactor(scaleFactor, highResolutionDisplay);
} }
}
// update look and feel // update look and feel
CustomLookAndFeel* laf =
dynamic_cast<CustomLookAndFeel*>(&getChildComponent(i)->getLookAndFeel());
if (laf != nullptr)
{
laf->setScaleFactor(scaleFactor, highResolutionDisplay);
}
}
// redraw everything // redraw everything
backgroundImage = getScaledImageFromCache("main", scaleFactor, highResolutionDisplay); backgroundImage = getScaledImageFromCache("main", scaleFactor, highResolutionDisplay);