| @@ -50,10 +50,10 @@ struct MidiKeyboardComponent::UpDownButton : public Button | |||
| owner.setLowestVisibleKey (note * 12); | |||
| } | |||
| void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) override | |||
| void paintButton (Graphics& g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override | |||
| { | |||
| owner.drawUpDownButton (g, getWidth(), getHeight(), | |||
| isMouseOverButton, isButtonDown, | |||
| shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown, | |||
| delta > 0); | |||
| } | |||
| @@ -36,14 +36,14 @@ ArrowButton::ArrowButton (const String& name, float arrowDirectionInRadians, Col | |||
| ArrowButton::~ArrowButton() {} | |||
| void ArrowButton::paintButton (Graphics& g, bool /*isMouseOverButton*/, bool isButtonDown) | |||
| void ArrowButton::paintButton (Graphics& g, bool /*shouldDrawButtonAsHighlighted*/, bool shouldDrawButtonAsDown) | |||
| { | |||
| Path p (path); | |||
| const float offset = isButtonDown ? 1.0f : 0.0f; | |||
| const float offset = shouldDrawButtonAsDown ? 1.0f : 0.0f; | |||
| p.applyTransform (path.getTransformToScaleToFit (offset, offset, getWidth() - 3.0f, getHeight() - 3.0f, false)); | |||
| DropShadow (Colours::black.withAlpha (0.3f), isButtonDown ? 2 : 4, Point<int>()).drawForPath (g, p); | |||
| DropShadow (Colours::black.withAlpha (0.3f), shouldDrawButtonAsDown ? 2 : 4, Point<int>()).drawForPath (g, p); | |||
| g.setColour (colour); | |||
| g.fillPath (p); | |||
| @@ -54,7 +54,7 @@ public: | |||
| ~ArrowButton(); | |||
| /** @internal */ | |||
| void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown) override; | |||
| void paintButton (Graphics&, bool, bool) override; | |||
| private: | |||
| Colour colour; | |||
| @@ -370,23 +370,27 @@ public: | |||
| virtual ~LookAndFeelMethods() {} | |||
| virtual void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour, | |||
| bool isMouseOverButton, bool isButtonDown) = 0; | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) = 0; | |||
| virtual Font getTextButtonFont (TextButton&, int buttonHeight) = 0; | |||
| virtual int getTextButtonWidthToFitText (TextButton&, int buttonHeight) = 0; | |||
| /** Draws the text for a TextButton. */ | |||
| virtual void drawButtonText (Graphics&, TextButton&, bool isMouseOverButton, bool isButtonDown) = 0; | |||
| virtual void drawButtonText (Graphics&, TextButton&, | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) = 0; | |||
| /** Draws the contents of a standard ToggleButton. */ | |||
| virtual void drawToggleButton (Graphics&, ToggleButton&, bool isMouseOverButton, bool isButtonDown) = 0; | |||
| virtual void drawToggleButton (Graphics&, ToggleButton&, | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) = 0; | |||
| virtual void changeToggleButtonWidthToFitText (ToggleButton&) = 0; | |||
| virtual void drawTickBox (Graphics&, Component&, float x, float y, float w, float h, | |||
| bool ticked, bool isEnabled, bool isMouseOverButton, bool isButtonDown) = 0; | |||
| bool ticked, bool isEnabled, | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) = 0; | |||
| virtual void drawDrawableButton (Graphics&, DrawableButton&, bool isMouseOverButton, bool isButtonDown) = 0; | |||
| virtual void drawDrawableButton (Graphics&, DrawableButton&, | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) = 0; | |||
| private: | |||
| #if JUCE_CATCH_DEPRECATED_CODE_MISUSE | |||
| @@ -424,14 +428,13 @@ protected: | |||
| It's better to use this than the paint method, because it gives you information | |||
| about the over/down state of the button. | |||
| @param g the graphics context to use | |||
| @param isMouseOverButton true if the button is either in the 'over' or | |||
| 'down' state | |||
| @param isButtonDown true if the button should be drawn in the 'down' position | |||
| @param g the graphics context to use | |||
| @param shouldDrawButtonAsHighlighted true if the button is either in the 'over' or 'down' state | |||
| @param shouldDrawButtonAsDown true if the button should be drawn in the 'down' position | |||
| */ | |||
| virtual void paintButton (Graphics& g, | |||
| bool isMouseOverButton, | |||
| bool isButtonDown) = 0; | |||
| bool shouldDrawButtonAsHighlighted, | |||
| bool shouldDrawButtonAsDown) = 0; | |||
| /** Called when the button's up/down/over state changes. | |||
| @@ -176,8 +176,8 @@ void DrawableButton::colourChanged() | |||
| } | |||
| void DrawableButton::paintButton (Graphics& g, | |||
| const bool isMouseOverButton, | |||
| const bool isButtonDown) | |||
| const bool shouldDrawButtonAsHighlighted, | |||
| const bool shouldDrawButtonAsDown) | |||
| { | |||
| auto& lf = getLookAndFeel(); | |||
| @@ -185,9 +185,9 @@ void DrawableButton::paintButton (Graphics& g, | |||
| lf.drawButtonBackground (g, *this, | |||
| findColour (getToggleState() ? TextButton::buttonOnColourId | |||
| : TextButton::buttonColourId), | |||
| isMouseOverButton, isButtonDown); | |||
| shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown); | |||
| else | |||
| lf.drawDrawableButton (g, *this, isMouseOverButton, isButtonDown); | |||
| lf.drawDrawableButton (g, *this, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown); | |||
| } | |||
| //============================================================================== | |||
| @@ -169,7 +169,7 @@ public: | |||
| //============================================================================== | |||
| /** @internal */ | |||
| void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown) override; | |||
| void paintButton (Graphics&, bool, bool) override; | |||
| /** @internal */ | |||
| void buttonStateChanged() override; | |||
| /** @internal */ | |||
| @@ -104,13 +104,13 @@ void HyperlinkButton::clicked() | |||
| } | |||
| void HyperlinkButton::paintButton (Graphics& g, | |||
| bool isMouseOverButton, | |||
| bool isButtonDown) | |||
| bool shouldDrawButtonAsHighlighted, | |||
| bool shouldDrawButtonAsDown) | |||
| { | |||
| const Colour textColour (findColour (textColourId)); | |||
| if (isEnabled()) | |||
| g.setColour ((isMouseOverButton) ? textColour.darker ((isButtonDown) ? 1.3f : 0.4f) | |||
| g.setColour ((shouldDrawButtonAsHighlighted) ? textColour.darker ((shouldDrawButtonAsDown) ? 1.3f : 0.4f) | |||
| : textColour); | |||
| else | |||
| g.setColour (textColour.withMultipliedAlpha (0.4f)); | |||
| @@ -109,7 +109,7 @@ protected: | |||
| /** @internal */ | |||
| void colourChanged() override; | |||
| /** @internal */ | |||
| void paintButton (Graphics&, bool isMouseOver, bool isButtonDown) override; | |||
| void paintButton (Graphics&, bool, bool) override; | |||
| private: | |||
| //============================================================================== | |||
| @@ -109,13 +109,13 @@ Image ImageButton::getDownImage() const | |||
| } | |||
| void ImageButton::paintButton (Graphics& g, | |||
| bool isMouseOverButton, | |||
| bool isButtonDown) | |||
| bool shouldDrawButtonAsHighlighted, | |||
| bool shouldDrawButtonAsDown) | |||
| { | |||
| if (! isEnabled()) | |||
| { | |||
| isMouseOverButton = false; | |||
| isButtonDown = false; | |||
| shouldDrawButtonAsHighlighted = false; | |||
| shouldDrawButtonAsDown = false; | |||
| } | |||
| Image im (getCurrentImage()); | |||
| @@ -168,14 +168,14 @@ void ImageButton::paintButton (Graphics& g, | |||
| imageBounds.setBounds (x, y, w, h); | |||
| const bool useDownImage = isButtonDown || getToggleState(); | |||
| const bool useDownImage = shouldDrawButtonAsDown || getToggleState(); | |||
| getLookAndFeel().drawImageButton (g, &im, x, y, w, h, | |||
| useDownImage ? downOverlay | |||
| : (isMouseOverButton ? overOverlay | |||
| : (shouldDrawButtonAsHighlighted ? overOverlay | |||
| : normalOverlay), | |||
| useDownImage ? downOpacity | |||
| : (isMouseOverButton ? overOpacity | |||
| : (shouldDrawButtonAsHighlighted ? overOpacity | |||
| : normalOpacity), | |||
| *this); | |||
| } | |||
| @@ -143,7 +143,7 @@ protected: | |||
| /** @internal */ | |||
| bool hitTest (int x, int y) override; | |||
| /** @internal */ | |||
| void paintButton (Graphics&, bool isMouseOver, bool isButtonDown) override; | |||
| void paintButton (Graphics&, bool, bool) override; | |||
| private: | |||
| //============================================================================== | |||
| @@ -97,12 +97,12 @@ void ShapeButton::setShape (const Path& newShape, | |||
| repaint(); | |||
| } | |||
| void ShapeButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) | |||
| void ShapeButton::paintButton (Graphics& g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) | |||
| { | |||
| if (! isEnabled()) | |||
| { | |||
| isMouseOverButton = false; | |||
| isButtonDown = false; | |||
| shouldDrawButtonAsHighlighted = false; | |||
| shouldDrawButtonAsDown = false; | |||
| } | |||
| auto r = border.subtractedFrom (getLocalBounds()) | |||
| @@ -112,7 +112,7 @@ void ShapeButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButto | |||
| if (getComponentEffect() != nullptr) | |||
| r = r.reduced (2.0f); | |||
| if (isButtonDown) | |||
| if (shouldDrawButtonAsDown) | |||
| { | |||
| const float sizeReductionWhenPressed = 0.04f; | |||
| @@ -122,9 +122,9 @@ void ShapeButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButto | |||
| auto trans = shape.getTransformToScaleToFit (r, maintainShapeProportions); | |||
| if (isButtonDown) g.setColour (getToggleState() && useOnColours ? downColourOn : downColour); | |||
| else if (isMouseOverButton) g.setColour (getToggleState() && useOnColours ? overColourOn : overColour); | |||
| else g.setColour (getToggleState() && useOnColours ? normalColourOn : normalColour); | |||
| if (shouldDrawButtonAsDown) g.setColour (getToggleState() && useOnColours ? downColourOn : downColour); | |||
| else if (shouldDrawButtonAsHighlighted) g.setColour (getToggleState() && useOnColours ? overColourOn : overColour); | |||
| else g.setColour (getToggleState() && useOnColours ? normalColourOn : normalColour); | |||
| g.fillPath (shape, trans); | |||
| @@ -108,7 +108,7 @@ public: | |||
| void setBorderSize (BorderSize<int> border); | |||
| /** @internal */ | |||
| void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown) override; | |||
| void paintButton (Graphics&, bool, bool) override; | |||
| private: | |||
| //============================================================================== | |||
| @@ -44,15 +44,15 @@ TextButton::~TextButton() | |||
| { | |||
| } | |||
| void TextButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) | |||
| void TextButton::paintButton (Graphics& g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) | |||
| { | |||
| auto& lf = getLookAndFeel(); | |||
| lf.drawButtonBackground (g, *this, | |||
| findColour (getToggleState() ? buttonOnColourId : buttonColourId), | |||
| isMouseOverButton, isButtonDown); | |||
| shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown); | |||
| lf.drawButtonText (g, *this, isMouseOverButton, isButtonDown); | |||
| lf.drawButtonText (g, *this, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown); | |||
| } | |||
| void TextButton::colourChanged() | |||
| @@ -99,7 +99,7 @@ public: | |||
| //============================================================================== | |||
| /** @internal */ | |||
| void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown) override; | |||
| void paintButton (Graphics&, bool, bool) override; | |||
| /** @internal */ | |||
| void colourChanged() override; | |||
| @@ -43,9 +43,9 @@ ToggleButton::~ToggleButton() | |||
| { | |||
| } | |||
| void ToggleButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) | |||
| void ToggleButton::paintButton (Graphics& g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) | |||
| { | |||
| getLookAndFeel().drawToggleButton (g, *this, isMouseOverButton, isButtonDown); | |||
| getLookAndFeel().drawToggleButton (g, *this, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown); | |||
| } | |||
| void ToggleButton::changeWidthToFitText() | |||
| @@ -80,7 +80,7 @@ public: | |||
| protected: | |||
| //============================================================================== | |||
| /** @internal */ | |||
| void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown) override; | |||
| void paintButton (Graphics&, bool, bool) override; | |||
| /** @internal */ | |||
| void colourChanged() override; | |||
| @@ -39,9 +39,9 @@ int TabBarButton::getIndex() const { return owner.indexOfTa | |||
| Colour TabBarButton::getTabBackgroundColour() const { return owner.getTabBackgroundColour (getIndex()); } | |||
| bool TabBarButton::isFrontTab() const { return getToggleState(); } | |||
| void TabBarButton::paintButton (Graphics& g, const bool isMouseOverButton, const bool isButtonDown) | |||
| void TabBarButton::paintButton (Graphics& g, const bool shouldDrawButtonAsHighlighted, const bool shouldDrawButtonAsDown) | |||
| { | |||
| getLookAndFeel().drawTabButton (*this, g, isMouseOverButton, isButtonDown); | |||
| getLookAndFeel().drawTabButton (*this, g, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown); | |||
| } | |||
| void TabBarButton::clicked (const ModifierKeys& mods) | |||
| @@ -109,7 +109,7 @@ public: | |||
| //============================================================================== | |||
| /** @internal */ | |||
| void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown) override; | |||
| void paintButton (Graphics&, bool, bool) override; | |||
| /** @internal */ | |||
| void clicked (const ModifierKeys&) override; | |||
| /** @internal */ | |||
| @@ -52,7 +52,7 @@ LookAndFeel_V1::~LookAndFeel_V1() | |||
| //============================================================================== | |||
| void LookAndFeel_V1::drawButtonBackground (Graphics& g, Button& button, const Colour& backgroundColour, | |||
| bool isMouseOverButton, bool isButtonDown) | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) | |||
| { | |||
| const int width = button.getWidth(); | |||
| const int height = button.getHeight(); | |||
| @@ -69,9 +69,9 @@ void LookAndFeel_V1::drawButtonBackground (Graphics& g, Button& button, const Co | |||
| Colour bc (backgroundColour.withMultipliedSaturation (0.3f)); | |||
| if (isMouseOverButton) | |||
| if (shouldDrawButtonAsHighlighted) | |||
| { | |||
| if (isButtonDown) | |||
| if (shouldDrawButtonAsDown) | |||
| bc = bc.brighter(); | |||
| else if (bc.getBrightness() > 0.5f) | |||
| bc = bc.darker (0.1f); | |||
| @@ -82,21 +82,21 @@ void LookAndFeel_V1::drawButtonBackground (Graphics& g, Button& button, const Co | |||
| g.setColour (bc); | |||
| g.fillPath (p); | |||
| g.setColour (bc.contrasting().withAlpha ((isMouseOverButton) ? 0.6f : 0.4f)); | |||
| g.strokePath (p, PathStrokeType ((isMouseOverButton) ? 2.0f : 1.4f)); | |||
| g.setColour (bc.contrasting().withAlpha ((shouldDrawButtonAsHighlighted) ? 0.6f : 0.4f)); | |||
| g.strokePath (p, PathStrokeType ((shouldDrawButtonAsHighlighted) ? 2.0f : 1.4f)); | |||
| } | |||
| void LookAndFeel_V1::drawTickBox (Graphics& g, Component& /*component*/, | |||
| float x, float y, float w, float h, | |||
| const bool ticked, | |||
| const bool isEnabled, | |||
| const bool /*isMouseOverButton*/, | |||
| const bool isButtonDown) | |||
| const bool /*shouldDrawButtonAsHighlighted*/, | |||
| const bool shouldDrawButtonAsDown) | |||
| { | |||
| Path box; | |||
| box.addRoundedRectangle (0.0f, 2.0f, 6.0f, 6.0f, 1.0f); | |||
| g.setColour (isEnabled ? Colours::blue.withAlpha (isButtonDown ? 0.3f : 0.1f) | |||
| g.setColour (isEnabled ? Colours::blue.withAlpha (shouldDrawButtonAsDown ? 0.3f : 0.1f) | |||
| : Colours::lightgrey.withAlpha (0.1f)); | |||
| AffineTransform trans (AffineTransform::scale (w / 9.0f, h / 9.0f).translated (x, y)); | |||
| @@ -118,7 +118,7 @@ void LookAndFeel_V1::drawTickBox (Graphics& g, Component& /*component*/, | |||
| } | |||
| } | |||
| void LookAndFeel_V1::drawToggleButton (Graphics& g, ToggleButton& button, bool isMouseOverButton, bool isButtonDown) | |||
| void LookAndFeel_V1::drawToggleButton (Graphics& g, ToggleButton& button, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) | |||
| { | |||
| if (button.hasKeyboardFocus (true)) | |||
| { | |||
| @@ -132,8 +132,8 @@ void LookAndFeel_V1::drawToggleButton (Graphics& g, ToggleButton& button, bool i | |||
| (float) tickWidth, (float) tickWidth, | |||
| button.getToggleState(), | |||
| button.isEnabled(), | |||
| isMouseOverButton, | |||
| isButtonDown); | |||
| shouldDrawButtonAsHighlighted, | |||
| shouldDrawButtonAsDown); | |||
| g.setColour (button.findColour (ToggleButton::textColourId)); | |||
| g.setFont (jmin (15.0f, button.getHeight() * 0.6f)); | |||
| @@ -182,8 +182,8 @@ void LookAndFeel_V1::drawProgressBar (Graphics& g, ProgressBar& progressBar, | |||
| void LookAndFeel_V1::drawScrollbarButton (Graphics& g, ScrollBar& bar, | |||
| int width, int height, int buttonDirection, | |||
| bool isScrollbarVertical, | |||
| bool isMouseOverButton, | |||
| bool isButtonDown) | |||
| bool shouldDrawButtonAsHighlighted, | |||
| bool shouldDrawButtonAsDown) | |||
| { | |||
| if (isScrollbarVertical) | |||
| width -= 2; | |||
| @@ -209,9 +209,9 @@ void LookAndFeel_V1::drawScrollbarButton (Graphics& g, ScrollBar& bar, | |||
| width * 0.7f, height * 0.1f, | |||
| width * 0.7f, height * 0.9f); | |||
| if (isButtonDown) | |||
| if (shouldDrawButtonAsDown) | |||
| g.setColour (Colours::white); | |||
| else if (isMouseOverButton) | |||
| else if (shouldDrawButtonAsHighlighted) | |||
| g.setColour (Colours::white.withAlpha (0.7f)); | |||
| else | |||
| g.setColour (bar.findColour (ScrollBar::thumbColourId).withAlpha (0.5f)); | |||
| @@ -42,12 +42,14 @@ public: | |||
| //============================================================================== | |||
| void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour, | |||
| bool isMouseOverButton, bool isButtonDown) override; | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; | |||
| void drawToggleButton (Graphics&, ToggleButton&, bool isMouseOverButton, bool isButtonDown) override; | |||
| void drawToggleButton (Graphics&, ToggleButton&, | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; | |||
| void drawTickBox (Graphics&, Component&, float x, float y, float w, float h, | |||
| bool ticked, bool isEnabled, bool isMouseOverButton, bool isButtonDown) override; | |||
| bool ticked, bool isEnabled, | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; | |||
| void drawProgressBar (Graphics&, ProgressBar&, int width, int height, | |||
| double progress, const String& textToShow) override; | |||
| @@ -55,7 +57,7 @@ public: | |||
| //============================================================================== | |||
| void drawScrollbarButton (Graphics&, ScrollBar&, int width, int height, | |||
| int buttonDirection, bool isScrollbarVertical, | |||
| bool isMouseOverButton, bool isButtonDown) override; | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; | |||
| void drawScrollbar (Graphics&, ScrollBar&, int x, int y, int width, int height, | |||
| bool isScrollbarVertical, int thumbStartPosition, int thumbSize, | |||
| @@ -31,14 +31,14 @@ namespace LookAndFeelHelpers | |||
| { | |||
| static Colour createBaseColour (Colour buttonColour, | |||
| bool hasKeyboardFocus, | |||
| bool isMouseOverButton, | |||
| bool isButtonDown) noexcept | |||
| bool shouldDrawButtonAsHighlighted, | |||
| bool shouldDrawButtonAsDown) noexcept | |||
| { | |||
| const float sat = hasKeyboardFocus ? 1.3f : 0.9f; | |||
| const Colour baseColour (buttonColour.withMultipliedSaturation (sat)); | |||
| if (isButtonDown) return baseColour.contrasting (0.2f); | |||
| if (isMouseOverButton) return baseColour.contrasting (0.1f); | |||
| if (shouldDrawButtonAsDown) return baseColour.contrasting (0.2f); | |||
| if (shouldDrawButtonAsHighlighted) return baseColour.contrasting (0.1f); | |||
| return baseColour; | |||
| } | |||
| @@ -239,13 +239,13 @@ LookAndFeel_V2::~LookAndFeel_V2() {} | |||
| void LookAndFeel_V2::drawButtonBackground (Graphics& g, | |||
| Button& button, | |||
| const Colour& backgroundColour, | |||
| bool isMouseOverButton, | |||
| bool isButtonDown) | |||
| bool shouldDrawButtonAsHighlighted, | |||
| bool shouldDrawButtonAsDown) | |||
| { | |||
| const int width = button.getWidth(); | |||
| const int height = button.getHeight(); | |||
| const float outlineThickness = button.isEnabled() ? ((isButtonDown || isMouseOverButton) ? 1.2f : 0.7f) : 0.4f; | |||
| const float outlineThickness = button.isEnabled() ? ((shouldDrawButtonAsDown || shouldDrawButtonAsHighlighted) ? 1.2f : 0.7f) : 0.4f; | |||
| const float halfThickness = outlineThickness * 0.5f; | |||
| const float indentL = button.isConnectedOnLeft() ? 0.1f : halfThickness; | |||
| @@ -255,7 +255,8 @@ void LookAndFeel_V2::drawButtonBackground (Graphics& g, | |||
| const Colour baseColour (LookAndFeelHelpers::createBaseColour (backgroundColour, | |||
| button.hasKeyboardFocus (true), | |||
| isMouseOverButton, isButtonDown) | |||
| shouldDrawButtonAsHighlighted, | |||
| shouldDrawButtonAsDown) | |||
| .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f)); | |||
| drawGlassLozenge (g, | |||
| @@ -280,7 +281,8 @@ int LookAndFeel_V2::getTextButtonWidthToFitText (TextButton& b, int buttonHeight | |||
| return getTextButtonFont (b, buttonHeight).getStringWidth (b.getButtonText()) + buttonHeight; | |||
| } | |||
| void LookAndFeel_V2::drawButtonText (Graphics& g, TextButton& button, bool /*isMouseOverButton*/, bool /*isButtonDown*/) | |||
| void LookAndFeel_V2::drawButtonText (Graphics& g, TextButton& button, | |||
| bool /*shouldDrawButtonAsHighlighted*/, bool /*shouldDrawButtonAsDown*/) | |||
| { | |||
| Font font (getTextButtonFont (button, button.getHeight())); | |||
| g.setFont (font); | |||
| @@ -306,16 +308,16 @@ void LookAndFeel_V2::drawTickBox (Graphics& g, Component& component, | |||
| float x, float y, float w, float h, | |||
| const bool ticked, | |||
| const bool isEnabled, | |||
| const bool isMouseOverButton, | |||
| const bool isButtonDown) | |||
| const bool shouldDrawButtonAsHighlighted, | |||
| const bool shouldDrawButtonAsDown) | |||
| { | |||
| const float boxSize = w * 0.7f; | |||
| drawGlassSphere (g, x, y + (h - boxSize) * 0.5f, boxSize, | |||
| LookAndFeelHelpers::createBaseColour (component.findColour (TextButton::buttonColourId) | |||
| .withMultipliedAlpha (isEnabled ? 1.0f : 0.5f), | |||
| true, isMouseOverButton, isButtonDown), | |||
| isEnabled ? ((isButtonDown || isMouseOverButton) ? 1.1f : 0.5f) : 0.3f); | |||
| true, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown), | |||
| isEnabled ? ((shouldDrawButtonAsDown || shouldDrawButtonAsHighlighted) ? 1.1f : 0.5f) : 0.3f); | |||
| if (ticked) | |||
| { | |||
| @@ -335,7 +337,7 @@ void LookAndFeel_V2::drawTickBox (Graphics& g, Component& component, | |||
| } | |||
| void LookAndFeel_V2::drawToggleButton (Graphics& g, ToggleButton& button, | |||
| bool isMouseOverButton, bool isButtonDown) | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) | |||
| { | |||
| if (button.hasKeyboardFocus (true)) | |||
| { | |||
| @@ -350,8 +352,8 @@ void LookAndFeel_V2::drawToggleButton (Graphics& g, ToggleButton& button, | |||
| tickWidth, tickWidth, | |||
| button.getToggleState(), | |||
| button.isEnabled(), | |||
| isMouseOverButton, | |||
| isButtonDown); | |||
| shouldDrawButtonAsHighlighted, | |||
| shouldDrawButtonAsDown); | |||
| g.setColour (button.findColour (ToggleButton::textColourId)); | |||
| g.setFont (fontSize); | |||
| @@ -377,7 +379,7 @@ void LookAndFeel_V2::changeToggleButtonWidthToFitText (ToggleButton& button) | |||
| } | |||
| void LookAndFeel_V2::drawDrawableButton (Graphics& g, DrawableButton& button, | |||
| bool /*isMouseOverButton*/, bool /*isButtonDown*/) | |||
| bool /*shouldDrawButtonAsHighlighted*/, bool /*shouldDrawButtonAsDown*/) | |||
| { | |||
| bool toggleState = button.getToggleState(); | |||
| @@ -644,8 +646,8 @@ bool LookAndFeel_V2::areScrollbarButtonsVisible() | |||
| void LookAndFeel_V2::drawScrollbarButton (Graphics& g, ScrollBar& scrollbar, | |||
| int width, int height, int buttonDirection, | |||
| bool /*isScrollbarVertical*/, | |||
| bool /*isMouseOverButton*/, | |||
| bool isButtonDown) | |||
| bool /*shouldDrawButtonAsHighlighted*/, | |||
| bool shouldDrawButtonAsDown) | |||
| { | |||
| Path p; | |||
| @@ -666,7 +668,7 @@ void LookAndFeel_V2::drawScrollbarButton (Graphics& g, ScrollBar& scrollbar, | |||
| width * 0.7f, height * 0.1f, | |||
| width * 0.7f, height * 0.9f); | |||
| if (isButtonDown) | |||
| if (shouldDrawButtonAsDown) | |||
| g.setColour (scrollbar.findColour (ScrollBar::thumbColourId).contrasting (0.2f)); | |||
| else | |||
| g.setColour (scrollbar.findColour (ScrollBar::thumbColourId)); | |||
| @@ -1132,7 +1134,7 @@ CaretComponent* LookAndFeel_V2::createCaretComponent (Component* keyFocusOwner) | |||
| } | |||
| //============================================================================== | |||
| void LookAndFeel_V2::drawComboBox (Graphics& g, int width, int height, const bool isButtonDown, | |||
| void LookAndFeel_V2::drawComboBox (Graphics& g, int width, int height, const bool isMouseButtonDown, | |||
| int buttonX, int buttonY, int buttonW, int buttonH, ComboBox& box) | |||
| { | |||
| g.fillAll (box.findColour (ComboBox::backgroundColourId)); | |||
| @@ -1148,11 +1150,11 @@ void LookAndFeel_V2::drawComboBox (Graphics& g, int width, int height, const boo | |||
| g.drawRect (0, 0, width, height); | |||
| } | |||
| auto outlineThickness = box.isEnabled() ? (isButtonDown ? 1.2f : 0.5f) : 0.3f; | |||
| auto outlineThickness = box.isEnabled() ? (isMouseButtonDown ? 1.2f : 0.5f) : 0.3f; | |||
| auto baseColour = LookAndFeelHelpers::createBaseColour (box.findColour (ComboBox::buttonColourId), | |||
| box.hasKeyboardFocus (true), | |||
| false, isButtonDown) | |||
| false, isMouseButtonDown) | |||
| .withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.5f); | |||
| drawGlassLozenge (g, | |||
| @@ -1803,9 +1805,9 @@ public: | |||
| } | |||
| //============================================================================== | |||
| void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) override | |||
| void paintButton (Graphics& g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override | |||
| { | |||
| float alpha = isMouseOverButton ? (isButtonDown ? 1.0f : 0.8f) : 0.55f; | |||
| float alpha = shouldDrawButtonAsHighlighted ? (shouldDrawButtonAsDown ? 1.0f : 0.8f) : 0.55f; | |||
| if (! isEnabled()) | |||
| alpha *= 0.5f; | |||
| @@ -43,21 +43,25 @@ public: | |||
| //============================================================================== | |||
| void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour, | |||
| bool isMouseOverButton, bool isButtonDown) override; | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; | |||
| Font getTextButtonFont (TextButton&, int buttonHeight) override; | |||
| void drawButtonText (Graphics&, TextButton&, bool isMouseOverButton, bool isButtonDown) override; | |||
| void drawButtonText (Graphics&, TextButton&, | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; | |||
| int getTextButtonWidthToFitText (TextButton&, int buttonHeight) override; | |||
| void drawToggleButton (Graphics&, ToggleButton&, bool isMouseOverButton, bool isButtonDown) override; | |||
| void drawToggleButton (Graphics&, ToggleButton&, | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; | |||
| void changeToggleButtonWidthToFitText (ToggleButton&) override; | |||
| void drawTickBox (Graphics&, Component&, | |||
| float x, float y, float w, float h, | |||
| bool ticked, bool isEnabled, bool isMouseOverButton, bool isButtonDown) override; | |||
| bool ticked, bool isEnabled, | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; | |||
| void drawDrawableButton (Graphics&, DrawableButton&, bool isMouseOverButton, bool isButtonDown) override; | |||
| void drawDrawableButton (Graphics&, DrawableButton&, | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; | |||
| //============================================================================== | |||
| AlertWindow* createAlertWindow (const String& title, const String& message, | |||
| @@ -98,7 +102,7 @@ public: | |||
| //============================================================================== | |||
| bool areScrollbarButtonsVisible() override; | |||
| void drawScrollbarButton (Graphics&, ScrollBar&, int width, int height, int buttonDirection, | |||
| bool isScrollbarVertical, bool isMouseOverButton, bool isButtonDown) override; | |||
| bool isScrollbarVertical, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; | |||
| void drawScrollbar (Graphics&, ScrollBar&, int x, int y, int width, int height, | |||
| bool isScrollbarVertical, int thumbStartPosition, int thumbSize, | |||
| @@ -187,7 +191,7 @@ public: | |||
| int getPopupMenuBorderSize() override; | |||
| //============================================================================== | |||
| void drawComboBox (Graphics&, int width, int height, bool isButtonDown, | |||
| void drawComboBox (Graphics&, int width, int height, bool isMouseButtonDown, | |||
| int buttonX, int buttonY, int buttonW, int buttonH, | |||
| ComboBox&) override; | |||
| Font getComboBoxFont (ComboBox&) override; | |||
| @@ -125,13 +125,13 @@ static void drawButtonShape (Graphics& g, const Path& outline, Colour baseColour | |||
| } | |||
| void LookAndFeel_V3::drawButtonBackground (Graphics& g, Button& button, const Colour& backgroundColour, | |||
| bool isMouseOverButton, bool isButtonDown) | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) | |||
| { | |||
| Colour baseColour (backgroundColour.withMultipliedSaturation (button.hasKeyboardFocus (true) ? 1.3f : 0.9f) | |||
| .withMultipliedAlpha (button.isEnabled() ? 0.9f : 0.5f)); | |||
| if (isButtonDown || isMouseOverButton) | |||
| baseColour = baseColour.contrasting (isButtonDown ? 0.2f : 0.1f); | |||
| if (shouldDrawButtonAsDown || shouldDrawButtonAsHighlighted) | |||
| baseColour = baseColour.contrasting (shouldDrawButtonAsDown ? 0.2f : 0.1f); | |||
| const bool flatOnLeft = button.isConnectedOnLeft(); | |||
| const bool flatOnRight = button.isConnectedOnRight(); | |||
| @@ -353,7 +353,7 @@ int LookAndFeel_V3::getTreeViewIndentSize (TreeView&) | |||
| return 20; | |||
| } | |||
| void LookAndFeel_V3::drawComboBox (Graphics& g, int width, int height, const bool /*isButtonDown*/, | |||
| void LookAndFeel_V3::drawComboBox (Graphics& g, int width, int height, const bool /*isMouseButtonDown*/, | |||
| int buttonX, int buttonY, int buttonW, int buttonH, ComboBox& box) | |||
| { | |||
| g.fillAll (box.findColour (ComboBox::backgroundColourId)); | |||
| @@ -536,7 +536,7 @@ public: | |||
| { | |||
| } | |||
| void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) override | |||
| void paintButton (Graphics& g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override | |||
| { | |||
| Colour background (Colours::grey); | |||
| @@ -544,7 +544,7 @@ public: | |||
| background = rw->getBackgroundColour(); | |||
| const float cx = getWidth() * 0.5f, cy = getHeight() * 0.5f; | |||
| const float diam = jmin (cx, cy) * (isButtonDown ? 0.60f : 0.65f); | |||
| const float diam = jmin (cx, cy) * (shouldDrawButtonAsDown ? 0.60f : 0.65f); | |||
| g.setColour (background); | |||
| g.fillEllipse (cx - diam, cy - diam, diam * 2.0f, diam * 2.0f); | |||
| @@ -553,7 +553,7 @@ public: | |||
| if (! isEnabled()) | |||
| c = c.withAlpha (0.6f); | |||
| else if (isMouseOverButton) | |||
| else if (shouldDrawButtonAsHighlighted) | |||
| c = c.brighter(); | |||
| g.setColour (c); | |||
| @@ -42,7 +42,7 @@ public: | |||
| //============================================================================== | |||
| void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour, | |||
| bool isMouseOverButton, bool isButtonDown) override; | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; | |||
| void drawTableHeaderBackground (Graphics&, TableHeaderComponent&) override; | |||
| @@ -115,7 +115,7 @@ public: | |||
| { | |||
| } | |||
| void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) override | |||
| void paintButton (Graphics& g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override | |||
| { | |||
| auto background = Colours::grey; | |||
| @@ -125,10 +125,10 @@ public: | |||
| g.fillAll (background); | |||
| g.setColour ((! isEnabled() || isButtonDown) ? colour.withAlpha (0.6f) | |||
| g.setColour ((! isEnabled() || shouldDrawButtonAsDown) ? colour.withAlpha (0.6f) | |||
| : colour); | |||
| if (isMouseOverButton) | |||
| if (shouldDrawButtonAsHighlighted) | |||
| { | |||
| g.fillAll(); | |||
| g.setColour (background); | |||
| @@ -284,8 +284,8 @@ Font LookAndFeel_V4::getTextButtonFont (TextButton&, int buttonHeight) | |||
| void LookAndFeel_V4::drawButtonBackground (Graphics& g, | |||
| Button& button, | |||
| const Colour& backgroundColour, | |||
| bool isMouseOverButton, | |||
| bool isButtonDown) | |||
| bool shouldDrawButtonAsHighlighted, | |||
| bool shouldDrawButtonAsDown) | |||
| { | |||
| auto cornerSize = 6.0f; | |||
| auto bounds = button.getLocalBounds().toFloat().reduced (0.5f, 0.5f); | |||
| @@ -293,8 +293,8 @@ void LookAndFeel_V4::drawButtonBackground (Graphics& g, | |||
| auto baseColour = backgroundColour.withMultipliedSaturation (button.hasKeyboardFocus (true) ? 1.3f : 0.9f) | |||
| .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f); | |||
| if (isButtonDown || isMouseOverButton) | |||
| baseColour = baseColour.contrasting (isButtonDown ? 0.2f : 0.05f); | |||
| if (shouldDrawButtonAsDown || shouldDrawButtonAsHighlighted) | |||
| baseColour = baseColour.contrasting (shouldDrawButtonAsDown ? 0.2f : 0.05f); | |||
| g.setColour (baseColour); | |||
| @@ -324,7 +324,7 @@ void LookAndFeel_V4::drawButtonBackground (Graphics& g, | |||
| } | |||
| void LookAndFeel_V4::drawToggleButton (Graphics& g, ToggleButton& button, | |||
| bool isMouseOverButton, bool isButtonDown) | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) | |||
| { | |||
| auto fontSize = jmin (15.0f, button.getHeight() * 0.75f); | |||
| auto tickWidth = fontSize * 1.1f; | |||
| @@ -333,8 +333,8 @@ void LookAndFeel_V4::drawToggleButton (Graphics& g, ToggleButton& button, | |||
| tickWidth, tickWidth, | |||
| button.getToggleState(), | |||
| button.isEnabled(), | |||
| isMouseOverButton, | |||
| isButtonDown); | |||
| shouldDrawButtonAsHighlighted, | |||
| shouldDrawButtonAsDown); | |||
| g.setColour (button.findColour (ToggleButton::textColourId)); | |||
| g.setFont (fontSize); | |||
| @@ -352,10 +352,10 @@ void LookAndFeel_V4::drawTickBox (Graphics& g, Component& component, | |||
| float x, float y, float w, float h, | |||
| const bool ticked, | |||
| const bool isEnabled, | |||
| const bool isMouseOverButton, | |||
| const bool isButtonDown) | |||
| const bool shouldDrawButtonAsHighlighted, | |||
| const bool shouldDrawButtonAsDown) | |||
| { | |||
| ignoreUnused (isEnabled, isMouseOverButton, isButtonDown); | |||
| ignoreUnused (isEnabled, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown); | |||
| Rectangle<float> tickBounds (x, y, w, h); | |||
| @@ -115,12 +115,14 @@ public: | |||
| Font getTextButtonFont (TextButton&, int buttonHeight) override; | |||
| void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour, | |||
| bool isMouseOverButton, bool isButtonDown) override; | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; | |||
| void drawToggleButton (Graphics&, ToggleButton&, bool isMouseOverButton, bool isButtonDown) override; | |||
| void drawToggleButton (Graphics&, ToggleButton&, | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; | |||
| void drawTickBox (Graphics&, Component&, | |||
| float x, float y, float w, float h, | |||
| bool ticked, bool isEnabled, bool isMouseOverButton, bool isButtonDown) override; | |||
| bool ticked, bool isEnabled, | |||
| bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; | |||
| void changeToggleButtonWidthToFitText (ToggleButton&) override; | |||