Fixed font issues
This commit is contained in:
parent
d6b67f6786
commit
b28f8ea99a
3 changed files with 182 additions and 9 deletions
|
@ -37,7 +37,19 @@ PresetBar::PresetBar (ObxdAudioProcessorEditor &gui)
|
||||||
presetNameLb.reset (new CustomLabel ("new label",
|
presetNameLb.reset (new CustomLabel ("new label",
|
||||||
TRANS("---\n")));
|
TRANS("---\n")));
|
||||||
addAndMakeVisible (presetNameLb.get());
|
addAndMakeVisible (presetNameLb.get());
|
||||||
presetNameLb->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
|
|
||||||
|
#ifdef JUCE_MAC
|
||||||
|
presetNameLb->setFont (juce::Font ("Helvetica Neue", 16.00f, juce::Font::plain).withTypefaceStyle ("Bold"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JUCE_WINDOWS
|
||||||
|
presetNameLb->setFont (juce::Font ("Arial", 16.00f, juce::Font::plain).withTypefaceStyle ("Bold"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JUCE_LINUX
|
||||||
|
presetNameLb->setFont (juce::Font ("DejaVu Sans", 16.00f, juce::Font::plain).withTypefaceStyle ("Bold"));
|
||||||
|
#endif
|
||||||
|
|
||||||
presetNameLb->setJustificationType (juce::Justification::centred);
|
presetNameLb->setJustificationType (juce::Justification::centred);
|
||||||
presetNameLb->setEditable (false, false, false);
|
presetNameLb->setEditable (false, false, false);
|
||||||
presetNameLb->setColour (juce::TextEditor::textColourId, juce::Colours::black);
|
presetNameLb->setColour (juce::TextEditor::textColourId, juce::Colours::black);
|
||||||
|
|
|
@ -52,11 +52,162 @@ public:
|
||||||
this->setColour(PopupMenu::backgroundColourId, Colour(20, 20, 20));
|
this->setColour(PopupMenu::backgroundColourId, Colour(20, 20, 20));
|
||||||
this->setColour(PopupMenu::textColourId, Colour(245, 245, 245));
|
this->setColour(PopupMenu::textColourId, Colour(245, 245, 245));
|
||||||
this->setColour(PopupMenu::highlightedBackgroundColourId, Colour(60, 60, 60));
|
this->setColour(PopupMenu::highlightedBackgroundColourId, Colour(60, 60, 60));
|
||||||
|
this->setColour(Label::textColourId, Colour(245, 245, 245));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PopupMenu::Options getOptionsForComboBoxPopupMenu (ComboBox& box, Label& label) override
|
PopupMenu::Options getOptionsForComboBoxPopupMenu (ComboBox& box, Label& label) override
|
||||||
{
|
{
|
||||||
PopupMenu::Options option = LookAndFeel_V3::getOptionsForComboBoxPopupMenu(box, label);
|
PopupMenu::Options option = LookAndFeel_V3::getOptionsForComboBoxPopupMenu(box, label);
|
||||||
return option.withStandardItemHeight (label.getHeight()/ getScaleFactor());
|
return option.withStandardItemHeight (label.getHeight()/ getScaleFactor());
|
||||||
};
|
};
|
||||||
|
Font getPopupMenuFont () override
|
||||||
|
{
|
||||||
|
|
||||||
|
float scaleFactor = getScaleFactor();
|
||||||
|
DBG("getPopupMenuFont::scaleFactor " << scaleFactor);
|
||||||
|
if (scaleFactor > 1.0) scaleFactor *= 0.75;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef JUCE_MAC
|
||||||
|
return Font("Helvetica Neue", 16.0 * scaleFactor, Font::plain);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JUCE_WINDOWS
|
||||||
|
return Font("Arial", 16.0 * scaleFactor, Font::plain);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JUCE_LINUX
|
||||||
|
return Font("DejaVu Sans", 16.0 * scaleFactor, Font::plain);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
void drawPopupMenuItem (Graphics& g, const Rectangle<int>& area,
|
||||||
|
const bool isSeparator, const bool isActive,
|
||||||
|
const bool isHighlighted, const bool isTicked,
|
||||||
|
const bool hasSubMenu, const String& text,
|
||||||
|
const String& shortcutKeyText,
|
||||||
|
const Drawable* icon, const Colour* const textColourToUse)
|
||||||
|
{
|
||||||
|
if (isSeparator)
|
||||||
|
{
|
||||||
|
auto r = area.reduced (5, 0);
|
||||||
|
r.removeFromTop (r.getHeight() / 2 - 1);
|
||||||
|
|
||||||
|
g.setColour (Colour (0x33000000));
|
||||||
|
g.fillRect (r.removeFromTop (1));
|
||||||
|
|
||||||
|
g.setColour (Colour (0x66ffffff));
|
||||||
|
g.fillRect (r.removeFromTop (1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto textColour = findColour (PopupMenu::textColourId);
|
||||||
|
|
||||||
|
if (textColourToUse != nullptr)
|
||||||
|
textColour = *textColourToUse;
|
||||||
|
|
||||||
|
auto r = area.reduced (1);
|
||||||
|
|
||||||
|
if (isHighlighted)
|
||||||
|
{
|
||||||
|
g.setColour (findColour (PopupMenu::highlightedBackgroundColourId));
|
||||||
|
g.fillRect (r);
|
||||||
|
|
||||||
|
g.setColour (findColour (PopupMenu::highlightedTextColourId));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g.setColour (textColour);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! isActive)
|
||||||
|
g.setOpacity (0.3f);
|
||||||
|
|
||||||
|
Font font (getPopupMenuFont());
|
||||||
|
|
||||||
|
auto maxFontHeight = (float) area.getHeight() / 1.3f;
|
||||||
|
|
||||||
|
if (font.getHeight() > maxFontHeight)
|
||||||
|
font.setHeight (maxFontHeight);
|
||||||
|
|
||||||
|
g.setFont (font);
|
||||||
|
|
||||||
|
auto iconArea = r.removeFromLeft ((r.getHeight() * 5) / 4).reduced (3).toFloat();
|
||||||
|
|
||||||
|
if (icon != nullptr)
|
||||||
|
{
|
||||||
|
icon->drawWithin (g, iconArea, RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f);
|
||||||
|
}
|
||||||
|
else if (isTicked)
|
||||||
|
{
|
||||||
|
auto tick = getTickShape (1.0f);
|
||||||
|
g.fillPath (tick, tick.getTransformToScaleToFit (iconArea, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasSubMenu)
|
||||||
|
{
|
||||||
|
auto arrowH = 0.6f * getPopupMenuFont().getAscent();
|
||||||
|
|
||||||
|
auto x = (float) r.removeFromRight ((int) arrowH).getX();
|
||||||
|
auto halfH = (float) r.getCentreY();
|
||||||
|
|
||||||
|
Path p;
|
||||||
|
p.addTriangle (x, halfH - arrowH * 0.5f,
|
||||||
|
x, halfH + arrowH * 0.5f,
|
||||||
|
x + arrowH * 0.6f, halfH);
|
||||||
|
|
||||||
|
g.fillPath (p);
|
||||||
|
}
|
||||||
|
|
||||||
|
r.removeFromRight (3);
|
||||||
|
g.drawFittedText (text, r, Justification::centredLeft, 1);
|
||||||
|
|
||||||
|
if (shortcutKeyText.isNotEmpty())
|
||||||
|
{
|
||||||
|
Font f2 (font);
|
||||||
|
f2.setHeight (f2.getHeight() * 0.75f);
|
||||||
|
f2.setHorizontalScale (0.95f);
|
||||||
|
g.setFont (f2);
|
||||||
|
|
||||||
|
g.drawText (shortcutKeyText, r, Justification::centredRight, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void drawLabel (Graphics& g, Label& label) override
|
||||||
|
{
|
||||||
|
g.fillAll (label.findColour (Label::backgroundColourId));
|
||||||
|
|
||||||
|
if (! label.isBeingEdited())
|
||||||
|
{
|
||||||
|
auto alpha = label.isEnabled() ? 1.0f : 0.5f;
|
||||||
|
const Font font (getLabelFont (label));
|
||||||
|
|
||||||
|
g.setColour (label.findColour (Label::textColourId).withMultipliedAlpha (alpha));
|
||||||
|
g.setFont (font);
|
||||||
|
|
||||||
|
auto textArea = getLabelBorderSize (label).subtractedFrom (label.getLocalBounds());
|
||||||
|
textArea = textArea.toFloat().transformedBy(AffineTransform::scale(getScaleFactor())).toNearestInt();
|
||||||
|
g.drawFittedText (label.getText(), textArea, label.getJustificationType(),
|
||||||
|
jmax (1, (int) ((float) textArea.getHeight() / font.getHeight())),
|
||||||
|
label.getMinimumHorizontalScale());
|
||||||
|
|
||||||
|
g.setColour (label.findColour (Label::outlineColourId).withMultipliedAlpha (alpha));
|
||||||
|
}
|
||||||
|
else if (label.isEnabled())
|
||||||
|
{
|
||||||
|
g.setColour (label.findColour (Label::outlineColourId));
|
||||||
|
}
|
||||||
|
|
||||||
|
g.drawRect (label.getLocalBounds());
|
||||||
|
}
|
||||||
|
BorderSize<int> getLabelBorderSize (Label& label)
|
||||||
|
{
|
||||||
|
BorderSize<int> boder = label.getBorderSize();
|
||||||
|
Rectangle<int> rec = Rectangle<int>::leftTopRightBottom(boder.getLeft(), boder.getTop(), boder.getRight(), boder.getBottom());
|
||||||
|
Rectangle<int> rec2 = rec.toFloat().transformedBy(AffineTransform::scale(getScaleFactor())).toNearestInt();
|
||||||
|
|
||||||
|
return BorderSize<int>(rec2.getX(), rec2.getY(), rec2.getRight(), rec2.getBottom() );
|
||||||
|
}
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,11 +25,13 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil
|
||||||
skins (processor.getSkinFiles()),
|
skins (processor.getSkinFiles()),
|
||||||
banks (processor.getBankFiles())
|
banks (processor.getBankFiles())
|
||||||
{
|
{
|
||||||
LookAndFeel& lf = getLookAndFeel();
|
setLookAndFeel(new CustomLookAndFeel(&this->processor));
|
||||||
|
|
||||||
|
//LookAndFeel& lf = getLookAndFeel();
|
||||||
// Popup Menu Look and Feel
|
// Popup Menu Look and Feel
|
||||||
lf.setColour(PopupMenu::backgroundColourId, Colour(20, 20, 20));
|
//lf.setColour(PopupMenu::backgroundColourId, Colour(20, 20, 20));
|
||||||
lf.setColour(PopupMenu::textColourId, Colour(245, 245, 245));
|
//lf.setColour(PopupMenu::textColourId, Colour(245, 245, 245));
|
||||||
lf.setColour(PopupMenu::highlightedBackgroundColourId, Colour(60, 60, 60));
|
//lf.setColour(PopupMenu::highlightedBackgroundColourId, Colour(60, 60, 60));
|
||||||
|
|
||||||
//skinFolder = ownerFilter.getCurrentSkinFolder(); // initialized above
|
//skinFolder = ownerFilter.getCurrentSkinFolder(); // initialized above
|
||||||
commandManager.registerAllCommandsForTarget(this);
|
commandManager.registerAllCommandsForTarget(this);
|
||||||
|
@ -478,16 +480,15 @@ 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(&this->getLookAndFeel());
|
||||||
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);
|
legatoSwitch->setLookAndFeel(&this->getLookAndFeel());
|
||||||
mappingComps["legatoSwitch"] = legatoSwitch;
|
mappingComps["legatoSwitch"] = legatoSwitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,6 +524,7 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
|
||||||
presetBar->setVisible(processor.getShowPresetBar());
|
presetBar->setVisible(processor.getShowPresetBar());
|
||||||
presetBar->leftClicked = [this](juce::Point<int> &pos){
|
presetBar->leftClicked = [this](juce::Point<int> &pos){
|
||||||
PopupMenu menu;
|
PopupMenu menu;
|
||||||
|
menu.setLookAndFeel(&this->getLookAndFeel());
|
||||||
for (int i = 0; i < processor.getNumPrograms(); ++i)
|
for (int i = 0; i < processor.getNumPrograms(); ++i)
|
||||||
{
|
{
|
||||||
menu.addItem (i + progStart + 1,
|
menu.addItem (i + progStart + 1,
|
||||||
|
@ -774,12 +776,19 @@ void ObxdAudioProcessorEditor::createMenu ()
|
||||||
{
|
{
|
||||||
popupMenus.clear();
|
popupMenus.clear();
|
||||||
PopupMenu* menu = new PopupMenu();
|
PopupMenu* menu = new PopupMenu();
|
||||||
|
//menu->setLookAndFeel(new CustomLookAndFeel(&this->processor));
|
||||||
PopupMenu progMenu;
|
PopupMenu progMenu;
|
||||||
PopupMenu bankMenu;
|
PopupMenu bankMenu;
|
||||||
PopupMenu skinMenu;
|
PopupMenu skinMenu;
|
||||||
PopupMenu fileMenu;
|
PopupMenu fileMenu;
|
||||||
//PopupMenu viewMenu;
|
//PopupMenu viewMenu;
|
||||||
PopupMenu midiMenu;
|
PopupMenu midiMenu;
|
||||||
|
menu->setLookAndFeel(&this->getLookAndFeel());
|
||||||
|
progMenu.setLookAndFeel(&this->getLookAndFeel());
|
||||||
|
bankMenu.setLookAndFeel(&this->getLookAndFeel());
|
||||||
|
skinMenu.setLookAndFeel(&this->getLookAndFeel());
|
||||||
|
fileMenu.setLookAndFeel(&this->getLookAndFeel());
|
||||||
|
midiMenu.setLookAndFeel(&this->getLookAndFeel());
|
||||||
skins = processor.getSkinFiles();
|
skins = processor.getSkinFiles();
|
||||||
banks = processor.getBankFiles();
|
banks = processor.getBankFiles();
|
||||||
{
|
{
|
||||||
|
@ -900,6 +909,7 @@ void ObxdAudioProcessorEditor::createMenu ()
|
||||||
|
|
||||||
#if defined(JUCE_MAC) || defined(WIN32)
|
#if defined(JUCE_MAC) || defined(WIN32)
|
||||||
PopupMenu helpMenu;
|
PopupMenu helpMenu;
|
||||||
|
helpMenu.setLookAndFeel(&this->getLookAndFeel());
|
||||||
String version = String("Release ") + String(JucePlugin_VersionString).dropLastCharacters(2);
|
String version = String("Release ") + String(JucePlugin_VersionString).dropLastCharacters(2);
|
||||||
helpMenu.addItem(menuScaleNum+4, "Manual", true);
|
helpMenu.addItem(menuScaleNum+4, "Manual", true);
|
||||||
helpMenu.addItem(menuScaleNum+3, version, false);
|
helpMenu.addItem(menuScaleNum+3, version, false);
|
||||||
|
|
Loading…
Reference in a new issue