From e62120dbd61a435ac32bdea19e37502d94088296 Mon Sep 17 00:00:00 2001 From: George Reales Date: Fri, 24 Sep 2021 07:30:17 +0200 Subject: [PATCH] Look and feel fixes --- OB-Xd.jucer | 2 +- Source/Components/ScaleComponent.h | 145 ++--------------------------- 2 files changed, 10 insertions(+), 137 deletions(-) diff --git a/OB-Xd.jucer b/OB-Xd.jucer index 9c82b7a..bad2f72 100644 --- a/OB-Xd.jucer +++ b/OB-Xd.jucer @@ -1,6 +1,6 @@ -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& 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 getLabelBorderSize (Label& label) - { - BorderSize boder = label.getBorderSize(); - Rectangle rec = Rectangle::leftTopRightBottom(boder.getLeft(), boder.getTop(), boder.getRight(), boder.getBottom()); - Rectangle rec2 = rec.toFloat().transformedBy(AffineTransform::scale(getScaleFactor())).toNearestInt(); - - return BorderSize(rec2.getX(), rec2.getY(), rec2.getRight(), rec2.getBottom() ); - } - */ + };