2
0
Fork 0

Look and feel fixes

This commit is contained in:
George Reales 2021-09-24 07:30:17 +02:00
parent e0bbc3c4e2
commit e62120dbd6
2 changed files with 10 additions and 137 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<JUCERPROJECT id="mxW328" name="OB-Xd" projectType="audioplug" version="2.5.0"
<JUCERPROJECT id="mxW328" name="OB-Xd" projectType="audioplug" version="2.5.1"
bundleIdentifier="com.discoDSP.Obxd" includeBinaryInAppConfig="1"
pluginName="OB-Xd" pluginDesc="Emulation of famous OB-X, OB-Xa and OB-8 synths"
pluginManufacturer="discoDSP" pluginManufacturerCode="DDSP" pluginCode="Obxd"

View file

@ -44,21 +44,22 @@ private:
//==============================================================================
class CustomLookAndFeel : public LookAndFeel_V3,
class CustomLookAndFeel : public LookAndFeel_V4,
public ScalableComponent
{
public:
CustomLookAndFeel(ObxdAudioProcessor* owner_):LookAndFeel_V3(), ScalableComponent(owner_) {
CustomLookAndFeel(ObxdAudioProcessor* owner_):LookAndFeel_V4(), 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));
this->setColour(Label::textColourId, Colour(245, 245, 245));
};
PopupMenu::Options getOptionsForComboBoxPopupMenu (ComboBox& box, Label& label) override
{
PopupMenu::Options option = LookAndFeel_V3::getOptionsForComboBoxPopupMenu(box, label);
PopupMenu::Options option = LookAndFeel_V4::getOptionsForComboBoxPopupMenu(box, label);
return option.withStandardItemHeight (label.getHeight()/ getScaleFactor());
};
Font getPopupMenuFont () override
@ -66,148 +67,20 @@ public:
float scaleFactor = getScaleFactor();
DBG("getPopupMenuFont::scaleFactor " << scaleFactor);
if (scaleFactor > 1.0) scaleFactor *= 0.75;
if (scaleFactor > 1.0) scaleFactor *= 0.85;
#ifdef JUCE_MAC
return Font("Helvetica Neue", 16.0 * scaleFactor, Font::plain);
return Font("Helvetica Neue", 18.0 * scaleFactor, Font::plain);
#endif
#ifdef JUCE_WINDOWS
return Font("Arial", 16.0 * scaleFactor, Font::plain);
return Font("Arial", 18.0 * scaleFactor, Font::plain);
#endif
#ifdef JUCE_LINUX
return Font("DejaVu Sans", 16.0 * scaleFactor, Font::plain);
return Font("DejaVu Sans", 18.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() );
}
*/
};