From 7bc8bf8bf9bbfc33660cf2ce45208c2b692f20b2 Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 9 Jan 2009 20:04:52 +0000 Subject: [PATCH] Added some colour IDs for various properties of the ResizableWindow, DocumentWindow, TabbedButtonBar, TabbedComponent. --- .../How to use this framework.txt | 10 +- .../src/ui/jucer_JucerDocumentHolder.cpp | 2 +- juce_amalgamated.cpp | 81 +++++++++++++--- juce_amalgamated.h | 95 +++++++++++++++++-- .../components/layout/juce_TabbedButtonBar.h | 19 ++++ .../layout/juce_TabbedComponent.cpp | 8 +- .../components/layout/juce_TabbedComponent.h | 28 ++++-- .../lookandfeel/juce_LookAndFeel.cpp | 33 ++++++- .../components/lookandfeel/juce_LookAndFeel.h | 5 + .../components/windows/juce_DocumentWindow.h | 13 +++ .../windows/juce_ResizableWindow.cpp | 40 ++++++-- .../components/windows/juce_ResizableWindow.h | 33 ++++++- 12 files changed, 315 insertions(+), 52 deletions(-) diff --git a/extras/audio plugins/How to use this framework.txt b/extras/audio plugins/How to use this framework.txt index bcf1c4c5ba..3f9c0340db 100644 --- a/extras/audio plugins/How to use this framework.txt +++ b/extras/audio plugins/How to use this framework.txt @@ -124,8 +124,8 @@ Each plugin project needs to contain a JucePluginCharacteristics.h file, which h plugin-specific build details. In here, there are three macros that you can set to enable each of the available formats: -#define JucePlugin_Build_VST 1 -#define JucePlugin_Build_RTAS 1 +#define JucePlugin_Build_VST 1 +#define JucePlugin_Build_RTAS 1 #define JucePlugin_Build_AU 1 You can set these to 0 to disable the formats that you don't want to build, and this will avoid @@ -197,7 +197,7 @@ any compilation problems if, for example, you don't have the appropriate SDK for ========================================== -- For an AU, make sure that the JucePlugin_Build_AU is enabled in your JucePluginCharacteristics.h +- For an AU, make sure that the JucePlugin_Build_AU is enabled in your JucePluginCharacteristics.h - In XCode, create a new project based on the "Audio Unit Effect" template - XCode will create a bunch of template source files for you - you can remove all of these from the project and delete them @@ -216,7 +216,7 @@ any compilation problems if, for example, you don't have the appropriate SDK for You should now be able to build a functional AU! If you want VST support as well, then read on... -- Make sure that the JucePlugin_Build_VST is enabled in your JucePluginCharacteristics.h +- Make sure that the JucePlugin_Build_VST is enabled in your JucePluginCharacteristics.h - For VST support, add all the juce_VST_* files from /wrapper/VST - In your target info settings, add the vstsdk2_4 folder to your "Header Search Paths" list - Make sure that in your Info.plist, the "Bundle Name" value is correctly set to the name of your plugin. @@ -227,7 +227,7 @@ changing the suffix to ".vst", and put it in your VST folder. If you also want to build an RTAS, then carry on reading... -- Make sure that the JucePlugin_Build_RTAS is enabled in your JucePluginCharacteristics.h +- Make sure that the JucePlugin_Build_RTAS is enabled in your JucePluginCharacteristics.h - After installing the Digidesign SDK, make sure you've run the config_SDK_for_Mac command in its root directory. This sets up some of the tools that it needs. - Add the files from /wrapper/RTAS to your project. Obviously a couple of these are for Windows, so diff --git a/extras/the jucer/src/ui/jucer_JucerDocumentHolder.cpp b/extras/the jucer/src/ui/jucer_JucerDocumentHolder.cpp index 71d983bcb7..51c0a56c16 100644 --- a/extras/the jucer/src/ui/jucer_JucerDocumentHolder.cpp +++ b/extras/the jucer/src/ui/jucer_JucerDocumentHolder.cpp @@ -385,7 +385,7 @@ JucerDocumentHolder::JucerDocumentHolder (JucerDocument* const document_) document->getInitialHeight()); addAndMakeVisible (tabbedComponent = new TabbedComponent (TabbedButtonBar::TabsAtRight)); - tabbedComponent->setOutline (Colours::black, 0); + tabbedComponent->setOutline (0); tabbedComponent->addTab (T("Class"), tabColour, new ClassPropertiesPanel (*document), true); diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index d4e6f090e3..550373175b 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -58874,7 +58874,6 @@ private: TabbedComponent::TabbedComponent (const TabbedButtonBar::Orientation orientation) : panelComponent (0), tabDepth (30), - outlineColour (Colours::grey), outlineThickness (1), edgeIndent (0) { @@ -59017,9 +59016,8 @@ const String& TabbedComponent::getCurrentTabName() const return tabs->getCurrentTabName(); } -void TabbedComponent::setOutline (const Colour& colour, int thickness) +void TabbedComponent::setOutline (int thickness) { - outlineColour = colour; outlineThickness = thickness; repaint(); } @@ -59031,6 +59029,8 @@ void TabbedComponent::setIndent (const int indentThickness) void TabbedComponent::paint (Graphics& g) { + g.fillAll (findColour (backgroundColourId)); + const TabbedButtonBar::Orientation o = getOrientation(); int x = 0; @@ -59061,7 +59061,7 @@ void TabbedComponent::paint (Graphics& g) else if (o == TabbedButtonBar::TabsAtRight) ++r; - g.setColour (outlineColour); + g.setColour (findColour (outlineColourId)); g.drawRect (x, y, r - x, b - y, outlineThickness); } } @@ -59529,6 +59529,9 @@ LookAndFeel::LookAndFeel() Slider::textBoxHighlightColourId, textHighlightColour, Slider::textBoxOutlineColourId, standardOutlineColour, + ResizableWindow::backgroundColourId, 0xff777777, + //DocumentWindow::textColourId, 0xff000000, // (this is deliberately not set) + AlertWindow::backgroundColourId, 0xffededed, AlertWindow::textColourId, 0xff000000, AlertWindow::outlineColourId, 0xff666666, @@ -59540,6 +59543,11 @@ LookAndFeel::LookAndFeel() TooltipWindow::textColourId, 0xff000000, TooltipWindow::outlineColourId, 0x4c000000, + TabbedComponent::backgroundColourId, 0x00000000, + TabbedComponent::outlineColourId, 0xff777777, + TabbedButtonBar::tabOutlineColourId, 0x80000000, + TabbedButtonBar::frontOutlineColourId, 0x90000000, + Toolbar::backgroundColourId, 0xfff6f8f9, Toolbar::separatorColourId, 0x4c000000, Toolbar::buttonMouseOverBackgroundColourId, 0x4c0000ff, @@ -59603,6 +59611,11 @@ void LookAndFeel::setColour (const int colourId, const Colour& colour) throw() colours.add (colour); } +bool LookAndFeel::isColourSpecified (const int colourId) const throw() +{ + return colourIds.contains (colourId); +} + static LookAndFeel* defaultLF = 0; static LookAndFeel* currentDefaultLF = 0; @@ -61010,7 +61023,11 @@ void LookAndFeel::drawDocumentWindowTitleBar (DocumentWindow& window, textW -= iconW; } - g.setColour (window.getBackgroundColour().contrasting (isActive ? 0.7f : 0.4f)); + if (window.isColourSpecified (DocumentWindow::textColourId) || isColourSpecified (DocumentWindow::textColourId)) + g.setColour (findColour (DocumentWindow::textColourId)); + else + g.setColour (window.getBackgroundColour().contrasting (isActive ? 0.7f : 0.4f)); + g.drawText (window.getName(), textX, 0, textW, h, Justification::centredLeft, true); } @@ -61349,7 +61366,10 @@ void LookAndFeel::fillTabButtonShape (Graphics& g, g.fillPath (path); - g.setColour (Colours::black.withAlpha (button.isEnabled() ? 0.5f : 0.25f)); + g.setColour (button.findColour (isFrontTab ? TabbedButtonBar::frontOutlineColourId + : TabbedButtonBar::tabOutlineColourId, false) + .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f)); + g.strokePath (path, PathStrokeType (isFrontTab ? 1.0f : 0.5f)); } @@ -61362,7 +61382,7 @@ void LookAndFeel::drawTabButtonText (Graphics& g, TabbedButtonBar::Orientation orientation, const bool isMouseOver, const bool isMouseDown, - const bool /*isFrontTab*/) + const bool isFrontTab) { int length = w; int depth = h; @@ -61399,7 +61419,12 @@ void LookAndFeel::drawTabButtonText (Graphics& g, transform = transform.translated ((float) x, (float) y); } - g.setColour (preferredBackgroundColour.contrasting()); + if (isFrontTab && (button.isColourSpecified (TabbedButtonBar::frontTextColourId) || isColourSpecified (TabbedButtonBar::frontTextColourId))) + g.setColour (findColour (TabbedButtonBar::frontTextColourId)); + else if (button.isColourSpecified (TabbedButtonBar::tabTextColourId) || isColourSpecified (TabbedButtonBar::tabTextColourId)) + g.setColour (findColour (TabbedButtonBar::tabTextColourId)); + else + g.setColour (preferredBackgroundColour.contrasting()); if (! (isMouseOver || isMouseDown)) g.setOpacity (0.8f); @@ -72489,6 +72514,28 @@ END_JUCE_NAMESPACE BEGIN_JUCE_NAMESPACE +ResizableWindow::ResizableWindow (const String& name, + const bool addToDesktop_) + : TopLevelWindow (name, addToDesktop_), + resizableCorner (0), + resizableBorder (0), + contentComponent (0), + resizeToFitContent (false), + fullscreen (false), + lastNonFullScreenPos (50, 50, 256, 256), + constrainer (0) +#ifdef JUCE_DEBUG + , hasBeenResized (false) +#endif +{ + defaultConstrainer.setMinimumOnscreenAmounts (0x10000, 16, 24, 16); + + lastNonFullScreenPos.setBounds (50, 50, 256, 256); + + if (addToDesktop_) + Component::addToDesktop (getDesktopWindowStyleFlags()); +} + ResizableWindow::ResizableWindow (const String& name, const Colour& backgroundColour_, const bool addToDesktop_) @@ -72498,6 +72545,7 @@ ResizableWindow::ResizableWindow (const String& name, contentComponent (0), resizeToFitContent (false), fullscreen (false), + lastNonFullScreenPos (50, 50, 256, 256), constrainer (0) #ifdef JUCE_DEBUG , hasBeenResized (false) @@ -72507,8 +72555,6 @@ ResizableWindow::ResizableWindow (const String& name, defaultConstrainer.setMinimumOnscreenAmounts (0x10000, 16, 24, 16); - lastNonFullScreenPos.setBounds (50, 50, 256, 256); - if (addToDesktop_) Component::addToDesktop (getDesktopWindowStyleFlags()); } @@ -72735,7 +72781,7 @@ void ResizableWindow::setBoundsConstrained (int x, int y, int w, int h) void ResizableWindow::paint (Graphics& g) { - g.fillAll (backgroundColour); + g.fillAll (getBackgroundColour()); if (! isFullScreen()) { @@ -72773,13 +72819,20 @@ void ResizableWindow::lookAndFeelChanged() } } +const Colour ResizableWindow::getBackgroundColour() const throw() +{ + return findColour (backgroundColourId, false); +} + void ResizableWindow::setBackgroundColour (const Colour& newColour) { - if (Desktop::canUseSemiTransparentWindows()) - backgroundColour = newColour; - else + Colour backgroundColour (newColour); + + if (! Desktop::canUseSemiTransparentWindows()) backgroundColour = newColour.withAlpha (1.0f); + setColour (backgroundColourId, backgroundColour); + setOpaque (backgroundColour.isOpaque()); repaint(); } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 9bc9aed632..88b9d0c2c3 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -46959,6 +46959,24 @@ public: */ void setTabBackgroundColour (const int tabIndex, const Colour& newColour); + /** A set of colour IDs to use to change the colour of various aspects of the component. + + These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() + methods. + + @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour + */ + enum ColourIds + { + tabOutlineColourId = 0x1005812, /**< The colour to use to draw an outline around the tabs. */ + tabTextColourId = 0x1005813, /**< The colour to use to draw the tab names. If this isn't specified, + the look and feel will choose an appropriate colour. */ + frontOutlineColourId = 0x1005814, /**< The colour to use to draw an outline around the currently-selected tab. */ + frontTextColourId = 0x1005815, /**< The colour to use to draw the currently-selected tab name. If + this isn't specified, the look and feel will choose an appropriate + colour. */ + }; + /** @internal */ void resized(); /** @internal */ @@ -47047,14 +47065,14 @@ public: */ int getTabBarDepth() const throw() { return tabDepth; } - /** Specifies an outline that should be drawn around the entire content component. + /** Specifies the thickness of an outline that should be drawn around the content component. + + If this thickness is > 0, a line will be drawn around the three sides of the content + component which don't touch the tab-bar, and the content component will be inset by this amount. - If this thickness is > 0, a line of the specified colour will be drawn around - the three sides of the content component which don't touch the tab-bar, and - the content component will be inset by this amount. + To set the colour of the line, use setColour (outlineColourId, ...). */ - void setOutline (const Colour& newOutlineColour, - const int newThickness); + void setOutline (const int newThickness); /** Specifies a gap to leave around the edge of the content component. @@ -47152,6 +47170,20 @@ public: */ TabbedButtonBar& getTabbedButtonBar() const throw() { return *tabs; } + /** A set of colour IDs to use to change the colour of various aspects of the component. + + These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() + methods. + + @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour + */ + enum ColourIds + { + backgroundColourId = 0x1005800, /**< The colour to fill the background behind the tabs. */ + outlineColourId = 0x1005801, /**< The colour to use to draw an outline around the content. + (See setOutline) */ + }; + /** @internal */ void paint (Graphics& g); /** @internal */ @@ -47178,7 +47210,6 @@ private: Array contentComponents; Component* panelComponent; int tabDepth; - Colour outlineColour; int outlineThickness, edgeIndent; friend class TabCompButtonBar; @@ -47596,6 +47627,18 @@ class JUCE_API ResizableWindow : public TopLevelWindow { public: + /** Creates a ResizableWindow. + + This constructor doesn't specify a background colour, so the LookAndFeel's default + background colour will be used. + + @param name the name to give the component + @param addToDesktop if true, the window will be automatically added to the + desktop; if false, you can use it as a child component + */ + ResizableWindow (const String& name, + const bool addToDesktop); + /** Creates a ResizableWindow. @param name the name to give the component @@ -47619,9 +47662,11 @@ public: As a convenience the window will fill itself with this colour, but you can override the paint() method if you need more customised behaviour. + This method is the same as retrieving the colour for ResizableWindow::backgroundColourId. + @see setBackgroundColour */ - const Colour& getBackgroundColour() const throw() { return backgroundColour; } + const Colour getBackgroundColour() const throw(); /** Changes the colour currently being used for the window's background. @@ -47633,6 +47678,9 @@ public: semi-transparent windows this might cause problems, (though it's unlikely you'll be using this class as a base for a semi-transparent component anyway). + You can also use the ResizableWindow::backgroundColourId colour id to set + this colour. + @see getBackgroundColour */ void setBackgroundColour (const Colour& newColour); @@ -47784,6 +47832,18 @@ public: */ void setContentComponentSize (int width, int height); + /** A set of colour IDs to use to change the colour of various aspects of the window. + + These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() + methods. + + @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour + */ + enum ColourIds + { + backgroundColourId = 0x1005700, /**< A colour to use to fill the window's background. */ + }; + juce_UseDebuggingNewOperator protected: @@ -47846,7 +47906,6 @@ protected: private: Component* contentComponent; bool resizeToFitContent, fullscreen; - Colour backgroundColour; ComponentDragger dragger; Rectangle lastNonFullScreenPos; ComponentBoundsConstrainer defaultConstrainer; @@ -48038,6 +48097,19 @@ public: /** Returns the maximise button, (or 0 if there isn't one). */ Button* getMaximiseButton() const throw(); + /** A set of colour IDs to use to change the colour of various aspects of the window. + + These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() + methods. + + @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour + */ + enum ColourIds + { + textColourId = 0x1005701, /**< The colour to draw any text with. It's up to the look + and feel class how this is used. */ + }; + /** @internal */ void paint (Graphics& g); /** @internal */ @@ -52799,6 +52871,11 @@ public: */ void setColour (const int colourId, const Colour& colour) throw(); + /** Returns true if the specified colour ID has been explicitly set using the + setColour() method. + */ + bool isColourSpecified (const int colourId) const throw(); + /** Draws the lozenge-shaped background for a standard button. */ virtual void drawButtonBackground (Graphics& g, Button& button, diff --git a/src/juce_appframework/gui/components/layout/juce_TabbedButtonBar.h b/src/juce_appframework/gui/components/layout/juce_TabbedButtonBar.h index 5d04ea5bed..bd4f10d843 100644 --- a/src/juce_appframework/gui/components/layout/juce_TabbedButtonBar.h +++ b/src/juce_appframework/gui/components/layout/juce_TabbedButtonBar.h @@ -238,6 +238,25 @@ public: */ void setTabBackgroundColour (const int tabIndex, const Colour& newColour); + //============================================================================== + /** A set of colour IDs to use to change the colour of various aspects of the component. + + These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() + methods. + + @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour + */ + enum ColourIds + { + tabOutlineColourId = 0x1005812, /**< The colour to use to draw an outline around the tabs. */ + tabTextColourId = 0x1005813, /**< The colour to use to draw the tab names. If this isn't specified, + the look and feel will choose an appropriate colour. */ + frontOutlineColourId = 0x1005814, /**< The colour to use to draw an outline around the currently-selected tab. */ + frontTextColourId = 0x1005815, /**< The colour to use to draw the currently-selected tab name. If + this isn't specified, the look and feel will choose an appropriate + colour. */ + }; + //============================================================================== /** @internal */ void resized(); diff --git a/src/juce_appframework/gui/components/layout/juce_TabbedComponent.cpp b/src/juce_appframework/gui/components/layout/juce_TabbedComponent.cpp index bd7e7e6cef..add69b4de9 100644 --- a/src/juce_appframework/gui/components/layout/juce_TabbedComponent.cpp +++ b/src/juce_appframework/gui/components/layout/juce_TabbedComponent.cpp @@ -87,7 +87,6 @@ private: TabbedComponent::TabbedComponent (const TabbedButtonBar::Orientation orientation) : panelComponent (0), tabDepth (30), - outlineColour (Colours::grey), outlineThickness (1), edgeIndent (0) { @@ -232,9 +231,8 @@ const String& TabbedComponent::getCurrentTabName() const return tabs->getCurrentTabName(); } -void TabbedComponent::setOutline (const Colour& colour, int thickness) +void TabbedComponent::setOutline (int thickness) { - outlineColour = colour; outlineThickness = thickness; repaint(); } @@ -246,6 +244,8 @@ void TabbedComponent::setIndent (const int indentThickness) void TabbedComponent::paint (Graphics& g) { + g.fillAll (findColour (backgroundColourId)); + const TabbedButtonBar::Orientation o = getOrientation(); int x = 0; @@ -276,7 +276,7 @@ void TabbedComponent::paint (Graphics& g) else if (o == TabbedButtonBar::TabsAtRight) ++r; - g.setColour (outlineColour); + g.setColour (findColour (outlineColourId)); g.drawRect (x, y, r - x, b - y, outlineThickness); } } diff --git a/src/juce_appframework/gui/components/layout/juce_TabbedComponent.h b/src/juce_appframework/gui/components/layout/juce_TabbedComponent.h index 9b392ca451..e9e5bf99e5 100644 --- a/src/juce_appframework/gui/components/layout/juce_TabbedComponent.h +++ b/src/juce_appframework/gui/components/layout/juce_TabbedComponent.h @@ -88,14 +88,14 @@ public: */ int getTabBarDepth() const throw() { return tabDepth; } - /** Specifies an outline that should be drawn around the entire content component. + /** Specifies the thickness of an outline that should be drawn around the content component. - If this thickness is > 0, a line of the specified colour will be drawn around - the three sides of the content component which don't touch the tab-bar, and - the content component will be inset by this amount. + If this thickness is > 0, a line will be drawn around the three sides of the content + component which don't touch the tab-bar, and the content component will be inset by this amount. + + To set the colour of the line, use setColour (outlineColourId, ...). */ - void setOutline (const Colour& newOutlineColour, - const int newThickness); + void setOutline (const int newThickness); /** Specifies a gap to leave around the edge of the content component. @@ -196,6 +196,21 @@ public: */ TabbedButtonBar& getTabbedButtonBar() const throw() { return *tabs; } + //============================================================================== + /** A set of colour IDs to use to change the colour of various aspects of the component. + + These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() + methods. + + @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour + */ + enum ColourIds + { + backgroundColourId = 0x1005800, /**< The colour to fill the background behind the tabs. */ + outlineColourId = 0x1005801, /**< The colour to use to draw an outline around the content. + (See setOutline) */ + }; + //============================================================================== /** @internal */ void paint (Graphics& g); @@ -224,7 +239,6 @@ private: Array contentComponents; Component* panelComponent; int tabDepth; - Colour outlineColour; int outlineThickness, edgeIndent; friend class TabCompButtonBar; diff --git a/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp b/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp index 30f0968fd2..61074c0070 100644 --- a/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp +++ b/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp @@ -160,6 +160,9 @@ LookAndFeel::LookAndFeel() Slider::textBoxHighlightColourId, textHighlightColour, Slider::textBoxOutlineColourId, standardOutlineColour, + ResizableWindow::backgroundColourId, 0xff777777, + //DocumentWindow::textColourId, 0xff000000, // (this is deliberately not set) + AlertWindow::backgroundColourId, 0xffededed, AlertWindow::textColourId, 0xff000000, AlertWindow::outlineColourId, 0xff666666, @@ -171,6 +174,11 @@ LookAndFeel::LookAndFeel() TooltipWindow::textColourId, 0xff000000, TooltipWindow::outlineColourId, 0x4c000000, + TabbedComponent::backgroundColourId, 0x00000000, + TabbedComponent::outlineColourId, 0xff777777, + TabbedButtonBar::tabOutlineColourId, 0x80000000, + TabbedButtonBar::frontOutlineColourId, 0x90000000, + Toolbar::backgroundColourId, 0xfff6f8f9, Toolbar::separatorColourId, 0x4c000000, Toolbar::buttonMouseOverBackgroundColourId, 0x4c0000ff, @@ -235,6 +243,11 @@ void LookAndFeel::setColour (const int colourId, const Colour& colour) throw() colours.add (colour); } +bool LookAndFeel::isColourSpecified (const int colourId) const throw() +{ + return colourIds.contains (colourId); +} + //============================================================================== static LookAndFeel* defaultLF = 0; static LookAndFeel* currentDefaultLF = 0; @@ -1658,7 +1671,11 @@ void LookAndFeel::drawDocumentWindowTitleBar (DocumentWindow& window, textW -= iconW; } - g.setColour (window.getBackgroundColour().contrasting (isActive ? 0.7f : 0.4f)); + if (window.isColourSpecified (DocumentWindow::textColourId) || isColourSpecified (DocumentWindow::textColourId)) + g.setColour (findColour (DocumentWindow::textColourId)); + else + g.setColour (window.getBackgroundColour().contrasting (isActive ? 0.7f : 0.4f)); + g.drawText (window.getName(), textX, 0, textW, h, Justification::centredLeft, true); } @@ -2005,7 +2022,10 @@ void LookAndFeel::fillTabButtonShape (Graphics& g, g.fillPath (path); - g.setColour (Colours::black.withAlpha (button.isEnabled() ? 0.5f : 0.25f)); + g.setColour (button.findColour (isFrontTab ? TabbedButtonBar::frontOutlineColourId + : TabbedButtonBar::tabOutlineColourId, false) + .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f)); + g.strokePath (path, PathStrokeType (isFrontTab ? 1.0f : 0.5f)); } @@ -2018,7 +2038,7 @@ void LookAndFeel::drawTabButtonText (Graphics& g, TabbedButtonBar::Orientation orientation, const bool isMouseOver, const bool isMouseDown, - const bool /*isFrontTab*/) + const bool isFrontTab) { int length = w; int depth = h; @@ -2055,7 +2075,12 @@ void LookAndFeel::drawTabButtonText (Graphics& g, transform = transform.translated ((float) x, (float) y); } - g.setColour (preferredBackgroundColour.contrasting()); + if (isFrontTab && (button.isColourSpecified (TabbedButtonBar::frontTextColourId) || isColourSpecified (TabbedButtonBar::frontTextColourId))) + g.setColour (findColour (TabbedButtonBar::frontTextColourId)); + else if (button.isColourSpecified (TabbedButtonBar::tabTextColourId) || isColourSpecified (TabbedButtonBar::tabTextColourId)) + g.setColour (findColour (TabbedButtonBar::tabTextColourId)); + else + g.setColour (preferredBackgroundColour.contrasting()); if (! (isMouseOver || isMouseDown)) g.setOpacity (0.8f); diff --git a/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h b/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h index c4b0755c50..3e9262d794 100644 --- a/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h +++ b/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h @@ -126,6 +126,11 @@ public: */ void setColour (const int colourId, const Colour& colour) throw(); + /** Returns true if the specified colour ID has been explicitly set using the + setColour() method. + */ + bool isColourSpecified (const int colourId) const throw(); + //============================================================================== /** Draws the lozenge-shaped background for a standard button. */ virtual void drawButtonBackground (Graphics& g, diff --git a/src/juce_appframework/gui/components/windows/juce_DocumentWindow.h b/src/juce_appframework/gui/components/windows/juce_DocumentWindow.h index 1973c1e308..710fcb09a9 100644 --- a/src/juce_appframework/gui/components/windows/juce_DocumentWindow.h +++ b/src/juce_appframework/gui/components/windows/juce_DocumentWindow.h @@ -210,6 +210,19 @@ public: /** Returns the maximise button, (or 0 if there isn't one). */ Button* getMaximiseButton() const throw(); + //============================================================================== + /** A set of colour IDs to use to change the colour of various aspects of the window. + + These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() + methods. + + @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour + */ + enum ColourIds + { + textColourId = 0x1005701, /**< The colour to draw any text with. It's up to the look + and feel class how this is used. */ + }; //============================================================================== /** @internal */ diff --git a/src/juce_appframework/gui/components/windows/juce_ResizableWindow.cpp b/src/juce_appframework/gui/components/windows/juce_ResizableWindow.cpp index a33adc39f6..e06b3a6dd4 100644 --- a/src/juce_appframework/gui/components/windows/juce_ResizableWindow.cpp +++ b/src/juce_appframework/gui/components/windows/juce_ResizableWindow.cpp @@ -41,6 +41,28 @@ BEGIN_JUCE_NAMESPACE //============================================================================== +ResizableWindow::ResizableWindow (const String& name, + const bool addToDesktop_) + : TopLevelWindow (name, addToDesktop_), + resizableCorner (0), + resizableBorder (0), + contentComponent (0), + resizeToFitContent (false), + fullscreen (false), + lastNonFullScreenPos (50, 50, 256, 256), + constrainer (0) +#ifdef JUCE_DEBUG + , hasBeenResized (false) +#endif +{ + defaultConstrainer.setMinimumOnscreenAmounts (0x10000, 16, 24, 16); + + lastNonFullScreenPos.setBounds (50, 50, 256, 256); + + if (addToDesktop_) + Component::addToDesktop (getDesktopWindowStyleFlags()); +} + ResizableWindow::ResizableWindow (const String& name, const Colour& backgroundColour_, const bool addToDesktop_) @@ -50,6 +72,7 @@ ResizableWindow::ResizableWindow (const String& name, contentComponent (0), resizeToFitContent (false), fullscreen (false), + lastNonFullScreenPos (50, 50, 256, 256), constrainer (0) #ifdef JUCE_DEBUG , hasBeenResized (false) @@ -59,8 +82,6 @@ ResizableWindow::ResizableWindow (const String& name, defaultConstrainer.setMinimumOnscreenAmounts (0x10000, 16, 24, 16); - lastNonFullScreenPos.setBounds (50, 50, 256, 256); - if (addToDesktop_) Component::addToDesktop (getDesktopWindowStyleFlags()); } @@ -292,7 +313,7 @@ void ResizableWindow::setBoundsConstrained (int x, int y, int w, int h) //============================================================================== void ResizableWindow::paint (Graphics& g) { - g.fillAll (backgroundColour); + g.fillAll (getBackgroundColour()); if (! isFullScreen()) { @@ -330,13 +351,20 @@ void ResizableWindow::lookAndFeelChanged() } } +const Colour ResizableWindow::getBackgroundColour() const throw() +{ + return findColour (backgroundColourId, false); +} + void ResizableWindow::setBackgroundColour (const Colour& newColour) { - if (Desktop::canUseSemiTransparentWindows()) - backgroundColour = newColour; - else + Colour backgroundColour (newColour); + + if (! Desktop::canUseSemiTransparentWindows()) backgroundColour = newColour.withAlpha (1.0f); + setColour (backgroundColourId, backgroundColour); + setOpaque (backgroundColour.isOpaque()); repaint(); } diff --git a/src/juce_appframework/gui/components/windows/juce_ResizableWindow.h b/src/juce_appframework/gui/components/windows/juce_ResizableWindow.h index 7b96db50ef..13696b38b1 100644 --- a/src/juce_appframework/gui/components/windows/juce_ResizableWindow.h +++ b/src/juce_appframework/gui/components/windows/juce_ResizableWindow.h @@ -62,6 +62,18 @@ class JUCE_API ResizableWindow : public TopLevelWindow { public: //============================================================================== + /** Creates a ResizableWindow. + + This constructor doesn't specify a background colour, so the LookAndFeel's default + background colour will be used. + + @param name the name to give the component + @param addToDesktop if true, the window will be automatically added to the + desktop; if false, you can use it as a child component + */ + ResizableWindow (const String& name, + const bool addToDesktop); + /** Creates a ResizableWindow. @param name the name to give the component @@ -86,9 +98,11 @@ public: As a convenience the window will fill itself with this colour, but you can override the paint() method if you need more customised behaviour. + This method is the same as retrieving the colour for ResizableWindow::backgroundColourId. + @see setBackgroundColour */ - const Colour& getBackgroundColour() const throw() { return backgroundColour; } + const Colour getBackgroundColour() const throw(); /** Changes the colour currently being used for the window's background. @@ -100,6 +114,9 @@ public: semi-transparent windows this might cause problems, (though it's unlikely you'll be using this class as a base for a semi-transparent component anyway). + You can also use the ResizableWindow::backgroundColourId colour id to set + this colour. + @see getBackgroundColour */ void setBackgroundColour (const Colour& newColour); @@ -257,6 +274,19 @@ public: */ void setContentComponentSize (int width, int height); + //============================================================================== + /** A set of colour IDs to use to change the colour of various aspects of the window. + + These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() + methods. + + @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour + */ + enum ColourIds + { + backgroundColourId = 0x1005700, /**< A colour to use to fill the window's background. */ + }; + //============================================================================== juce_UseDebuggingNewOperator @@ -320,7 +350,6 @@ protected: private: Component* contentComponent; bool resizeToFitContent, fullscreen; - Colour backgroundColour; ComponentDragger dragger; Rectangle lastNonFullScreenPos; ComponentBoundsConstrainer defaultConstrainer;