From b8f557b2012c1d89d0a47e45eb59d2bacc036785 Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 12 Jul 2012 11:06:12 +0100 Subject: [PATCH] Tab button fix and minor clean-ups. --- .../effects/juce_DropShadowEffect.cpp | 7 +++---- modules/juce_gui_basics/buttons/juce_ArrowButton.h | 2 -- .../juce_gui_basics/buttons/juce_ShapeButton.cpp | 6 +++--- modules/juce_gui_basics/buttons/juce_ShapeButton.h | 5 +---- .../layout/juce_TabbedButtonBar.cpp | 4 +++- .../juce_gui_basics/misc/juce_BubbleComponent.cpp | 14 ++++++-------- 6 files changed, 16 insertions(+), 22 deletions(-) diff --git a/modules/juce_graphics/effects/juce_DropShadowEffect.cpp b/modules/juce_graphics/effects/juce_DropShadowEffect.cpp index dfe64b54e9..eb5639af8f 100644 --- a/modules/juce_graphics/effects/juce_DropShadowEffect.cpp +++ b/modules/juce_graphics/effects/juce_DropShadowEffect.cpp @@ -124,10 +124,9 @@ void DropShadow::drawForPath (Graphics& g, const Path& path) const { jassert (radius > 0); - const Rectangle area (path.getBounds().translated ((float) offset.x, (float) offset.y) - .getSmallestIntegerContainer() - .getIntersection (g.getClipBounds()) - .expanded (radius + 1, radius + 1)); + const Rectangle area ((path.getBounds().getSmallestIntegerContainer() + offset) + .getIntersection (g.getClipBounds()) + .expanded (radius + 1, radius + 1)); if (area.getWidth() > 2 && area.getHeight() > 2) { diff --git a/modules/juce_gui_basics/buttons/juce_ArrowButton.h b/modules/juce_gui_basics/buttons/juce_ArrowButton.h index f08391b06f..d09b9ee078 100644 --- a/modules/juce_gui_basics/buttons/juce_ArrowButton.h +++ b/modules/juce_gui_basics/buttons/juce_ArrowButton.h @@ -53,8 +53,6 @@ public: /** Destructor. */ ~ArrowButton(); - -protected: /** @internal */ void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown); diff --git a/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp b/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp index e36d7b3071..f3ee2e15cd 100644 --- a/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp +++ b/modules/juce_gui_basics/buttons/juce_ShapeButton.cpp @@ -89,9 +89,9 @@ void ShapeButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButto isButtonDown = false; } - g.setColour ((isButtonDown) ? downColour - : (isMouseOverButton) ? overColour - : normalColour); + g.setColour (isButtonDown ? downColour + : isMouseOverButton ? overColour + : normalColour); int w = getWidth(); int h = getHeight(); diff --git a/modules/juce_gui_basics/buttons/juce_ShapeButton.h b/modules/juce_gui_basics/buttons/juce_ShapeButton.h index 24674b13a2..92b10b021d 100644 --- a/modules/juce_gui_basics/buttons/juce_ShapeButton.h +++ b/modules/juce_gui_basics/buttons/juce_ShapeButton.h @@ -87,11 +87,8 @@ public: float outlineStrokeWidth); -protected: /** @internal */ - void paintButton (Graphics& g, - bool isMouseOverButton, - bool isButtonDown); + void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown); private: //============================================================================== diff --git a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp index 77039a4862..db96707407 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp +++ b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp @@ -152,7 +152,10 @@ void TabBarButton::setExtraComponent (Component* comp, ExtraComponentPlacement p void TabBarButton::childBoundsChanged (Component* c) { if (c == extraComponent) + { + owner.resized(); resized(); + } } void TabBarButton::resized() @@ -434,7 +437,6 @@ void TabbedButtonBar::resized() for (int i = 0; i < tabs.size(); ++i) { TabBarButton* const tb = tabs.getUnchecked(i)->button; - const int newLength = totalLength + tb->getBestTabLength (depth); if (i > 0 && newLength * minimumScale > tabsButtonPos) diff --git a/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp b/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp index 31c132a7df..94f585c889 100644 --- a/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp +++ b/modules/juce_gui_basics/misc/juce_BubbleComponent.cpp @@ -32,9 +32,7 @@ BubbleComponent::BubbleComponent() setComponentEffect (&shadow); } -BubbleComponent::~BubbleComponent() -{ -} +BubbleComponent::~BubbleComponent() {} //============================================================================== void BubbleComponent::paint (Graphics& g) @@ -43,13 +41,12 @@ void BubbleComponent::paint (Graphics& g) (float) content.getX(), (float) content.getY(), (float) content.getWidth(), (float) content.getHeight()); + g.reduceClipRegion (content); g.setOrigin (content.getX(), content.getY()); - g.reduceClipRegion (0, 0, content.getWidth(), content.getHeight()); paintContent (g, content.getWidth(), content.getHeight()); } -//============================================================================== void BubbleComponent::setAllowedPlacement (const int newPlacement) { allowablePlacements = newPlacement; @@ -82,9 +79,8 @@ void BubbleComponent::setPosition (const Rectangle& rectangleToPointTo) content.setBounds (edgeSpace, edgeSpace, contentW, contentH); } - int totalW = content.getWidth() + edgeSpace * 2; - int totalH = content.getHeight() + edgeSpace * 2; - int targetX, targetY; + const int totalW = content.getWidth() + edgeSpace * 2; + const int totalH = content.getHeight() + edgeSpace * 2; const Rectangle availableSpace (getParentComponent() != nullptr ? getParentComponent()->getLocalBounds() : getParentMonitorArea()); @@ -106,6 +102,8 @@ void BubbleComponent::setPosition (const Rectangle& rectangleToPointTo) spaceAbove = spaceBelow = 0; } + int targetX, targetY; + if (jmax (spaceAbove, spaceBelow) >= jmax (spaceLeft, spaceRight)) { targetX = rectangleToPointTo.getCentre().x;