diff --git a/extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp b/extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp index 83cf37bf4e..c6029f81f4 100644 --- a/extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp +++ b/extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp @@ -187,6 +187,9 @@ void AppearanceSettings::applyToLookAndFeel (LookAndFeel& lf) const lf.setColour (AppearanceColours::colours[i].colourID, col); } } + + lf.setColour (ScrollBar::thumbColourId, + getScrollbarColourForBackground (lf.findColour (mainBackgroundColourId))); } void AppearanceSettings::applyToCodeEditor (CodeEditorComponent& editor) const @@ -201,6 +204,9 @@ void AppearanceSettings::applyToCodeEditor (CodeEditorComponent& editor) const editor.setColourScheme (cs); editor.setFont (getCodeFont()); + + editor.setColour (ScrollBar::thumbColourId, + getScrollbarColourForBackground (editor.findColour (CodeEditorComponent::backgroundColourId))); } Font AppearanceSettings::getCodeFont() const @@ -255,6 +261,11 @@ bool AppearanceSettings::getColour (const String& name, Colour& result) const return false; } +Colour AppearanceSettings::getScrollbarColourForBackground (const Colour& background) +{ + return background.contrasting().withAlpha (0.13f); +} + //============================================================================== struct AppearanceEditor { @@ -469,3 +480,97 @@ Rectangle IntrojucerLookAndFeel::getPropertyComponentContentPosition (Prope return LookAndFeel::getPropertyComponentContentPosition (component); } + +int IntrojucerLookAndFeel::getTabButtonOverlap (int tabDepth) { return -1; } +int IntrojucerLookAndFeel::getTabButtonSpaceAroundImage() { return 1; } +int IntrojucerLookAndFeel::getTabButtonBestWidth (TabBarButton& button, int tabDepth) { return 120; } + +void IntrojucerLookAndFeel::createTabTextLayout (const TabBarButton& button, const Rectangle& textArea, GlyphArrangement& textLayout) +{ + Font font (textArea.getHeight() * 0.5f); + font.setUnderline (button.hasKeyboardFocus (false)); + + textLayout.addFittedText (font, button.getButtonText().trim(), + (float) textArea.getX(), (float) textArea.getY(), (float) textArea.getWidth(), (float) textArea.getHeight(), + Justification::centred, 1); +} + +Colour IntrojucerLookAndFeel::getTabBackgroundColour (TabBarButton& button) +{ + Colour normalBkg (button.getTabBackgroundColour()); + Colour bkg (normalBkg.contrasting (0.15f)); + if (button.isFrontTab()) + bkg = bkg.overlaidWith (Colours::yellow.withAlpha (0.5f)); + + return bkg; +} + +void IntrojucerLookAndFeel::drawTabButton (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown) +{ + const Rectangle activeArea (button.getActiveArea()); + + Colour bkg (getTabBackgroundColour (button)); + + g.setGradientFill (ColourGradient (bkg.brighter (0.1f), 0, (float) activeArea.getY(), + bkg.darker (0.1f), 0, (float) activeArea.getBottom(), false)); + g.fillRect (activeArea); + + g.setColour (button.getTabBackgroundColour().darker (0.3f)); + g.drawRect (activeArea); + + GlyphArrangement textLayout; + createTabTextLayout (button, button.getTextArea(), textLayout); + + const float alpha = button.isEnabled() ? ((isMouseOver || isMouseDown) ? 1.0f : 0.8f) : 0.3f; + g.setColour (bkg.contrasting().withMultipliedAlpha (alpha)); + textLayout.draw (g); +} + +Rectangle IntrojucerLookAndFeel::getTabButtonExtraComponentBounds (const TabBarButton& button, Rectangle& textArea, Component& comp) +{ + GlyphArrangement textLayout; + createTabTextLayout (button, textArea, textLayout); + const int textWidth = (int) textLayout.getBoundingBox (0, -1, false).getWidth(); + const int extraSpace = jmax (0, textArea.getWidth() - (textWidth + comp.getWidth())) / 2; + + textArea.removeFromRight (extraSpace); + textArea.removeFromLeft (extraSpace); + return textArea.removeFromRight (comp.getWidth()); +} + +void IntrojucerLookAndFeel::drawStretchableLayoutResizerBar (Graphics& g, int /*w*/, int /*h*/, bool /*isVerticalBar*/, bool isMouseOver, bool isMouseDragging) +{ + if (isMouseOver || isMouseDragging) + g.fillAll (Colours::yellow.withAlpha (0.4f)); +} + +void IntrojucerLookAndFeel::drawScrollbar (Graphics& g, ScrollBar& scrollbar, int x, int y, int width, int height, + bool isScrollbarVertical, int thumbStartPosition, int thumbSize, + bool isMouseOver, bool isMouseDown) +{ + Path thumbPath; + + if (thumbSize > 0) + { + const float thumbIndent = jmin (width, height) * 0.25f; + const float thumbIndentx2 = thumbIndent * 2.0f; + + if (isScrollbarVertical) + thumbPath.addRoundedRectangle (x + thumbIndent, thumbStartPosition + thumbIndent, + width - thumbIndentx2, thumbSize - thumbIndentx2, (width - thumbIndentx2) * 0.5f); + else + thumbPath.addRoundedRectangle (thumbStartPosition + thumbIndent, y + thumbIndent, + thumbSize - thumbIndentx2, height - thumbIndentx2, (height - thumbIndentx2) * 0.5f); + } + + Colour thumbCol (scrollbar.findColour (ScrollBar::thumbColourId, true)); + + if (isMouseOver || isMouseDown) + thumbCol = thumbCol.withMultipliedAlpha (2.0f); + + g.setColour (thumbCol); + g.fillPath (thumbPath); + + g.setColour (thumbCol.contrasting ((isMouseOver || isMouseDown) ? 0.2f : 0.1f)); + g.strokePath (thumbPath, PathStrokeType (1.0f)); +} diff --git a/extras/Introjucer/Source/Application/jucer_AppearanceSettings.h b/extras/Introjucer/Source/Application/jucer_AppearanceSettings.h index 10af23c61a..62f23a9585 100644 --- a/extras/Introjucer/Source/Application/jucer_AppearanceSettings.h +++ b/extras/Introjucer/Source/Application/jucer_AppearanceSettings.h @@ -36,6 +36,7 @@ public: bool readFromXML (const XmlElement&); bool writeToFile (const File& file) const; + void updateColourScheme(); void applyToCodeEditor (CodeEditorComponent& editor) const; StringArray getColourNames() const; @@ -52,6 +53,8 @@ public: void refreshPresetSchemeList(); void selectPresetScheme (int index); + static Colour getScrollbarColourForBackground (const Colour& background); + static Component* createEditorWindow(); private: @@ -60,7 +63,6 @@ private: Array presetSchemeFiles; void applyToLookAndFeel (LookAndFeel&) const; - void updateColourScheme(); void valueTreePropertyChanged (ValueTree&, const Identifier&) { updateColourScheme(); } void valueTreeChildAdded (ValueTree&, ValueTree&) { updateColourScheme(); } @@ -78,74 +80,24 @@ class IntrojucerLookAndFeel : public LookAndFeel public: IntrojucerLookAndFeel(); - int getTabButtonOverlap (int tabDepth) { return -1; } - int getTabButtonSpaceAroundImage() { return 1; } - int getTabButtonBestWidth (TabBarButton& button, int tabDepth) { return 120; } + int getTabButtonOverlap (int tabDepth); + int getTabButtonSpaceAroundImage(); + int getTabButtonBestWidth (TabBarButton& button, int tabDepth); - void createTabTextLayout (const TabBarButton& button, const Rectangle& textArea, GlyphArrangement& textLayout) - { - Font font (textArea.getHeight() * 0.5f); - font.setUnderline (button.hasKeyboardFocus (false)); - - textLayout.addFittedText (font, button.getButtonText().trim(), - (float) textArea.getX(), (float) textArea.getY(), (float) textArea.getWidth(), (float) textArea.getHeight(), - Justification::centred, 1); - } - - static Colour getTabBackgroundColour (TabBarButton& button) - { - Colour normalBkg (button.getTabBackgroundColour()); - Colour bkg (normalBkg.contrasting (0.15f)); - if (button.isFrontTab()) - bkg = bkg.overlaidWith (Colours::yellow.withAlpha (0.5f)); - - return bkg; - } - - void drawTabButton (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown) - { - const Rectangle activeArea (button.getActiveArea()); - - Colour bkg (getTabBackgroundColour (button)); - - g.setGradientFill (ColourGradient (bkg.brighter (0.1f), 0, (float) activeArea.getY(), - bkg.darker (0.1f), 0, (float) activeArea.getBottom(), false)); - g.fillRect (activeArea); - - g.setColour (button.getTabBackgroundColour().darker (0.3f)); - g.drawRect (activeArea); - - GlyphArrangement textLayout; - createTabTextLayout (button, button.getTextArea(), textLayout); - - const float alpha = button.isEnabled() ? ((isMouseOver || isMouseDown) ? 1.0f : 0.8f) : 0.3f; - g.setColour (bkg.contrasting().withMultipliedAlpha (alpha)); - textLayout.draw (g); - } - - Rectangle getTabButtonExtraComponentBounds (const TabBarButton& button, Rectangle& textArea, Component& comp) - { - GlyphArrangement textLayout; - createTabTextLayout (button, textArea, textLayout); - const int textWidth = (int) textLayout.getBoundingBox (0, -1, false).getWidth(); - const int extraSpace = jmax (0, textArea.getWidth() - (textWidth + comp.getWidth())) / 2; - - textArea.removeFromRight (extraSpace); - textArea.removeFromLeft (extraSpace); - return textArea.removeFromRight (comp.getWidth()); - } + static Colour getTabBackgroundColour (TabBarButton& button); + void createTabTextLayout (const TabBarButton& button, const Rectangle& textArea, GlyphArrangement& textLayout); + void drawTabButton (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown); + Rectangle getTabButtonExtraComponentBounds (const TabBarButton& button, Rectangle& textArea, Component& comp); void drawTabAreaBehindFrontButton (TabbedButtonBar&, Graphics&, int, int) {} - void drawStretchableLayoutResizerBar (Graphics& g, int /*w*/, int /*h*/, bool /*isVerticalBar*/, bool isMouseOver, bool isMouseDragging) - { - if (isMouseOver || isMouseDragging) - g.fillAll (Colours::yellow.withAlpha (0.4f)); - } - + void drawStretchableLayoutResizerBar (Graphics& g, int /*w*/, int /*h*/, bool /*isVerticalBar*/, bool isMouseOver, bool isMouseDragging); Rectangle getPropertyComponentContentPosition (PropertyComponent&); bool areScrollbarButtonsVisible() { return false; } + + void drawScrollbar (Graphics& g, ScrollBar& scrollbar, int x, int y, int width, int height, bool isScrollbarVertical, + int thumbStartPosition, int thumbSize, bool /*isMouseOver*/, bool /*isMouseDown*/); }; diff --git a/extras/Introjucer/Source/Utility/jucer_StoredSettings.cpp b/extras/Introjucer/Source/Utility/jucer_StoredSettings.cpp index 7995c8ffe2..01c840cd1a 100644 --- a/extras/Introjucer/Source/Utility/jucer_StoredSettings.cpp +++ b/extras/Introjucer/Source/Utility/jucer_StoredSettings.cpp @@ -122,6 +122,7 @@ void StoredSettings::reload() if (xml != nullptr) appearance.readFromXML (*xml); + appearance.updateColourScheme(); loadSwatchColours(); }