1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

changed the look and feel classes, to make "shiny" the new default look, and moved the old look into an OldSchoolLookAndFeel class.

This commit is contained in:
jules 2007-06-20 13:14:27 +00:00
parent 1bb0bf0b36
commit 205304c3a9
23 changed files with 1689 additions and 1666 deletions

View file

@ -299,8 +299,8 @@
84A48AAD08A22E4B00752A2B /* juce_Viewport.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A488C408A22E4900752A2B /* juce_Viewport.h */; };
84A48AAE08A22E4B00752A2B /* juce_LookAndFeel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84A488C608A22E4900752A2B /* juce_LookAndFeel.cpp */; };
84A48AAF08A22E4B00752A2B /* juce_LookAndFeel.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A488C708A22E4900752A2B /* juce_LookAndFeel.h */; };
84A48AB008A22E4B00752A2B /* juce_ShinyLookAndFeel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84A488C808A22E4900752A2B /* juce_ShinyLookAndFeel.cpp */; };
84A48AB108A22E4B00752A2B /* juce_ShinyLookAndFeel.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A488C908A22E4900752A2B /* juce_ShinyLookAndFeel.h */; };
84A48AB008A22E4B00752A2B /* juce_OldSchoolLookAndFeel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84A488C808A22E4900752A2B /* juce_OldSchoolLookAndFeel.cpp */; };
84A48AB108A22E4B00752A2B /* juce_OldSchoolLookAndFeel.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A488C908A22E4900752A2B /* juce_OldSchoolLookAndFeel.h */; };
84A48AB208A22E4B00752A2B /* juce_MenuBarComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84A488CB08A22E4900752A2B /* juce_MenuBarComponent.cpp */; };
84A48AB308A22E4B00752A2B /* juce_MenuBarComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A488CC08A22E4900752A2B /* juce_MenuBarComponent.h */; };
84A48AB408A22E4B00752A2B /* juce_MenuBarModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A488CD08A22E4900752A2B /* juce_MenuBarModel.h */; };
@ -943,8 +943,8 @@
84A488C408A22E4900752A2B /* juce_Viewport.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = juce_Viewport.h; path = ../../src/juce_appframework/gui/components/layout/juce_Viewport.h; sourceTree = SOURCE_ROOT; };
84A488C608A22E4900752A2B /* juce_LookAndFeel.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = juce_LookAndFeel.cpp; path = ../../src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp; sourceTree = SOURCE_ROOT; };
84A488C708A22E4900752A2B /* juce_LookAndFeel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = juce_LookAndFeel.h; path = ../../src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h; sourceTree = SOURCE_ROOT; };
84A488C808A22E4900752A2B /* juce_ShinyLookAndFeel.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ShinyLookAndFeel.cpp; path = ../../src/juce_appframework/gui/components/lookandfeel/juce_ShinyLookAndFeel.cpp; sourceTree = SOURCE_ROOT; };
84A488C908A22E4900752A2B /* juce_ShinyLookAndFeel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = juce_ShinyLookAndFeel.h; path = ../../src/juce_appframework/gui/components/lookandfeel/juce_ShinyLookAndFeel.h; sourceTree = SOURCE_ROOT; };
84A488C808A22E4900752A2B /* juce_OldSchoolLookAndFeel.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = juce_OldSchoolLookAndFeel.cpp; path = ../../src/juce_appframework/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.cpp; sourceTree = SOURCE_ROOT; };
84A488C908A22E4900752A2B /* juce_OldSchoolLookAndFeel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = juce_OldSchoolLookAndFeel.h; path = ../../src/juce_appframework/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.h; sourceTree = SOURCE_ROOT; };
84A488CB08A22E4900752A2B /* juce_MenuBarComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = juce_MenuBarComponent.cpp; path = ../../src/juce_appframework/gui/components/menus/juce_MenuBarComponent.cpp; sourceTree = SOURCE_ROOT; };
84A488CC08A22E4900752A2B /* juce_MenuBarComponent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = juce_MenuBarComponent.h; path = ../../src/juce_appframework/gui/components/menus/juce_MenuBarComponent.h; sourceTree = SOURCE_ROOT; };
84A488CD08A22E4900752A2B /* juce_MenuBarModel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = juce_MenuBarModel.h; path = ../../src/juce_appframework/gui/components/menus/juce_MenuBarModel.h; sourceTree = SOURCE_ROOT; };
@ -1731,8 +1731,8 @@
children = (
84A488C608A22E4900752A2B /* juce_LookAndFeel.cpp */,
84A488C708A22E4900752A2B /* juce_LookAndFeel.h */,
84A488C808A22E4900752A2B /* juce_ShinyLookAndFeel.cpp */,
84A488C908A22E4900752A2B /* juce_ShinyLookAndFeel.h */,
84A488C808A22E4900752A2B /* juce_OldSchoolLookAndFeel.cpp */,
84A488C908A22E4900752A2B /* juce_OldSchoolLookAndFeel.h */,
);
name = lookandfeel;
path = ../../src/juce_appframework/gui/components/lookandfeel;
@ -2496,7 +2496,7 @@
84A48AAB08A22E4B00752A2B /* juce_TabbedComponent.h in Headers */,
84A48AAD08A22E4B00752A2B /* juce_Viewport.h in Headers */,
84A48AAF08A22E4B00752A2B /* juce_LookAndFeel.h in Headers */,
84A48AB108A22E4B00752A2B /* juce_ShinyLookAndFeel.h in Headers */,
84A48AB108A22E4B00752A2B /* juce_OldSchoolLookAndFeel.h in Headers */,
84A48AB308A22E4B00752A2B /* juce_MenuBarComponent.h in Headers */,
84A48AB408A22E4B00752A2B /* juce_MenuBarModel.h in Headers */,
84A48AB608A22E4B00752A2B /* juce_PopupMenu.h in Headers */,
@ -2827,7 +2827,7 @@
84A48AAA08A22E4B00752A2B /* juce_TabbedComponent.cpp in Sources */,
84A48AAC08A22E4B00752A2B /* juce_Viewport.cpp in Sources */,
84A48AAE08A22E4B00752A2B /* juce_LookAndFeel.cpp in Sources */,
84A48AB008A22E4B00752A2B /* juce_ShinyLookAndFeel.cpp in Sources */,
84A48AB008A22E4B00752A2B /* juce_OldSchoolLookAndFeel.cpp in Sources */,
84A48AB208A22E4B00752A2B /* juce_MenuBarComponent.cpp in Sources */,
84A48AB508A22E4B00752A2B /* juce_PopupMenu.cpp in Sources */,
84A48AB808A22E4B00752A2B /* juce_ComponentDragger.cpp in Sources */,

View file

@ -3789,11 +3789,11 @@
>
</File>
<File
RelativePath="..\..\..\src\juce_appframework\gui\components\lookandfeel\juce_ShinyLookAndFeel.cpp"
RelativePath="..\..\..\src\juce_appframework\gui\components\lookandfeel\juce_OldSchoolLookAndFeel.cpp"
>
</File>
<File
RelativePath="..\..\..\src\juce_appframework\gui\components\lookandfeel\juce_ShinyLookAndFeel.h"
RelativePath="..\..\..\src\juce_appframework\gui\components\lookandfeel\juce_OldSchoolLookAndFeel.h"
>
</File>
</Filter>

View file

@ -6,6 +6,7 @@
==============================================================================
Changelist for version 1.44
- swapped the look and feel classes around, so that the basic LookAndFeel class is now what used to be the "shiny" one. The ShinyLookAndFeel class has been removed, and for that old fashioned look, I've added an OldSchoolLookAndFeel that you can use if you need the original L+F. This means that any custom looks that you were using may need to change their base class.
- changed the MouseEvent structure so that it now contains a pointer to the event component and also the original component.
- added a PopupMenu::dismissAllActiveMenus() method.
- added the JUCE_LOG_ASSERTIONS flag, which can automatically log assertion failures, even in release builds.

View file

@ -68,27 +68,11 @@ static const String ppqToBarsBeatsString (const double ppq,
return s;
}
//==============================================================================
// just a quick way of using a single static look and feel object without
// it getting leaked when the plugin is deleted..
class AutoDeletedLookAndFeel : public ShinyLookAndFeel,
public DeletedAtShutdown
{
public:
AutoDeletedLookAndFeel() {}
};
//==============================================================================
DemoEditorComponent::DemoEditorComponent (DemoJuceFilter* const ownerFilter)
: AudioFilterEditor (ownerFilter)
{
static ShinyLookAndFeel* shinyLook = 0;
if (shinyLook == 0)
shinyLook = new AutoDeletedLookAndFeel();
LookAndFeel::setDefaultLookAndFeel (shinyLook);
// create our gain slider..
addAndMakeVisible (gainSlider = new Slider (T("gain")));
gainSlider->addListener (this);

View file

@ -86,7 +86,6 @@ class JUCEHelloWorldApplication : public JUCEApplication
initialised, so any embedded objects would also get constructed too soon.
*/
HelloWorldWindow* helloWorldWindow;
ShinyLookAndFeel shinyLookAndFeel;
public:
//==============================================================================
@ -109,8 +108,6 @@ public:
//==============================================================================
void initialise (const String& commandLine)
{
LookAndFeel::setDefaultLookAndFeel (&shinyLookAndFeel);
// just create the main window...
helloWorldWindow = new HelloWorldWindow();
@ -129,8 +126,6 @@ public:
if (helloWorldWindow != 0)
delete helloWorldWindow;
LookAndFeel::setDefaultLookAndFeel (0);
}
//==============================================================================

View file

@ -7865,4 +7865,3 @@ static const unsigned char temp17[] = {47,42,13,10,32,32,61,61,61,61,61,61,61,61
100,77,97,110,97,103,101,114,42,32,99,111,109,109,97,110,100,77,97,110,97,103,101,114,41,13,10,123,13,10,32,32,32,32,114,101,116,117,114,110,
32,110,101,119,32,87,105,100,103,101,116,115,68,101,109,111,32,40,99,111,109,109,97,110,100,77,97,110,97,103,101,114,41,59,13,10,125,13,10,0,0};
const char* BinaryData::widgetsdemo_cpp = (const char*) temp17;

View file

@ -92,7 +92,7 @@ class ContentComp : public Component,
//==============================================================================
MainDemoWindow* mainWindow;
ShinyLookAndFeel shinyLookAndFeel;
OldSchoolLookAndFeel oldLookAndFeel;
Component* currentDemo;
int currentDemoId;
@ -119,7 +119,7 @@ class ContentComp : public Component,
showSourceCode = 0x200a,
setDefaultLookAndFeel = 0x200b,
setShinyLookAndFeel = 0x200c,
setOldSchoolLookAndFeel = 0x200c,
useNativeTitleBar = 0x200d,
useNativeMenus = 0x200e
};
@ -132,15 +132,13 @@ public:
currentDemoId (0),
demoSourceCodeText (0)
{
LookAndFeel::setDefaultLookAndFeel (&shinyLookAndFeel);
invokeDirectly (showWidgets, true);
}
~ContentComp()
{
// (need to do this because the default look-and-feel object is one of our members,
// so will be deleted with us, and would leave a dangling pointer)
// (need to do this because the old school look-and-feel object is one of our members,
// so will be deleted with us, and would leave a dangling pointer if it's selected)
LookAndFeel::setDefaultLookAndFeel (0);
deleteAllChildren();
@ -218,7 +216,7 @@ public:
else if (menuIndex == 2)
{
menu.addCommandItem (commandManager, setDefaultLookAndFeel);
menu.addCommandItem (commandManager, setShinyLookAndFeel);
menu.addCommandItem (commandManager, setOldSchoolLookAndFeel);
menu.addSeparator();
menu.addCommandItem (commandManager, useNativeTitleBar);
@ -265,7 +263,7 @@ public:
showInterprocessComms,
showSourceCode,
setDefaultLookAndFeel,
setShinyLookAndFeel,
setOldSchoolLookAndFeel,
useNativeTitleBar
#if JUCE_MAC
, useNativeMenus
@ -366,9 +364,9 @@ public:
result.setTicked ((typeid (LookAndFeel) == typeid (getLookAndFeel())) != 0);
break;
case setShinyLookAndFeel:
result.setInfo (T("Use shiny look-and-feel"), String::empty, generalCategory, 0);
result.setTicked ((typeid (ShinyLookAndFeel) == typeid (getLookAndFeel())) != 0);
case setOldSchoolLookAndFeel:
result.setInfo (T("Use the old, original juce look-and-feel"), String::empty, generalCategory, 0);
result.setTicked ((typeid (OldSchoolLookAndFeel) == typeid (getLookAndFeel())) != 0);
break;
case useNativeTitleBar:
@ -460,8 +458,8 @@ public:
LookAndFeel::setDefaultLookAndFeel (0);
break;
case setShinyLookAndFeel:
LookAndFeel::setDefaultLookAndFeel (&shinyLookAndFeel);
case setOldSchoolLookAndFeel:
LookAndFeel::setDefaultLookAndFeel (&oldLookAndFeel);
break;
case useNativeTitleBar:

View file

@ -911,4 +911,3 @@ static const unsigned char temp4[] = {137,80,78,71,13,10,26,10,0,0,0,13,73,72,68
0,98,28,9,155,95,0,2,104,68,236,11,1,8,160,17,225,73,128,0,3,0,120,52,172,151,198,78,252,63,0,0,0,0,73,69,78,68,174,66,
96,130,0,0};
const char* BinaryData::prefs_misc_png = (const char*) temp4;

View file

@ -39,7 +39,7 @@
#include "../properties/jucer_FontPropertyComponent.h"
static ShinyLookAndFeel* shinyLook = 0;
static OldSchoolLookAndFeel* oldLook = 0;
static const int snapSizes[] = { 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32 };
//==============================================================================
@ -71,10 +71,8 @@ MainWindow::MainWindow()
Colours::azure,
DocumentWindow::allButtons)
{
if (shinyLook == 0)
shinyLook = new ShinyLookAndFeel();
LookAndFeel::setDefaultLookAndFeel (shinyLook);
if (oldLook == 0)
oldLook = new OldSchoolLookAndFeel();
setContentComponent (multiDocHolder = new MultiDocHolder());
@ -142,7 +140,7 @@ MainWindow::~MainWindow()
setContentComponent (0);
LookAndFeel::setDefaultLookAndFeel (0);
deleteAndZero (shinyLook);
deleteAndZero (oldLook);
}
void MainWindow::closeButtonPressed()
@ -309,8 +307,8 @@ const PopupMenu MainWindow::getMenuForIndex (int topLevelMenuIndex,
menu.addCommandItem (commandManager, CommandIDs::test);
PopupMenu lookAndFeels;
lookAndFeels.addItem (200, T("Shiny"), true, (typeid (ShinyLookAndFeel) == typeid (LookAndFeel::getDefaultLookAndFeel())) != 0);
lookAndFeels.addItem (201, T("Default"), true, (typeid (LookAndFeel) == typeid (LookAndFeel::getDefaultLookAndFeel())) != 0);
lookAndFeels.addItem (200, T("Old School"), true, (typeid (OldSchoolLookAndFeel) == typeid (LookAndFeel::getDefaultLookAndFeel())) != 0);
menu.addSeparator();
menu.addSubMenu (T("Look and Feel"), lookAndFeels);
@ -365,7 +363,7 @@ void MainWindow::menuItemSelected (int menuItemID,
}
else if (menuItemID == 200)
{
LookAndFeel::setDefaultLookAndFeel (shinyLook);
LookAndFeel::setDefaultLookAndFeel (oldLook);
}
else if (menuItemID == 201)
{

View file

@ -644,8 +644,8 @@
#ifndef __JUCE_LOOKANDFEEL_JUCEHEADER__
#include "juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h"
#endif
#ifndef __JUCE_SHINYLOOKANDFEEL_JUCEHEADER__
#include "juce_appframework/gui/components/lookandfeel/juce_ShinyLookAndFeel.h"
#ifndef __JUCE_OLDSCHOOLLOOKANDFEEL_JUCEHEADER__
#include "juce_appframework/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.h"
#endif
#ifndef __JUCE_FILEBASEDDOCUMENT_JUCEHEADER__
#include "juce_appframework/documents/juce_FileBasedDocument.h"

View file

@ -497,6 +497,21 @@ public:
virtual const Rectangle getPropertyComponentContentPosition (PropertyComponent& component);
//==============================================================================
/** Utility function to draw a shiny, glassy circle (for round LED-type buttons). */
static void drawGlassSphere (Graphics& g, float x, float y, float diameter,
const Colour& colour, const float outlineThickness) throw();
static void drawGlassPointer (Graphics& g, float x, float y, float diameter,
const Colour& colour, const float outlineThickness,
const int direction) throw();
/** Utility function to draw a shiny, glassy oblong (for text buttons). */
static void drawGlassLozenge (Graphics& g, float x, float y, float width, float height,
const Colour& colour, const float outlineThickness, const float cornerSize,
const bool flatOnLeft, const bool flatOnRight, const bool flatOnTop, const bool flatOnBottom) throw();
//==============================================================================
juce_UseDebuggingNewOperator
@ -513,13 +528,20 @@ protected:
virtual void getTabButtonBestWidth (int, const String&, int) {}
private:
DropShadowEffect scrollbarShadow;
friend void JUCE_PUBLIC_FUNCTION shutdownJuce_GUI();
static void clearDefaultLookAndFeel(); // called at shutdown
Array <int> colourIds;
Array <Colour> colours;
void drawShinyButtonShape (Graphics& g,
float x, float y, float w, float h, float maxCornerSize,
const Colour& baseColour,
const float strokeWidth,
const bool flatOnLeft,
const bool flatOnRight,
const bool flatOnTop,
const bool flatOnBottom) throw();
};

View file

@ -0,0 +1,611 @@
/*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-7 by Raw Material Software ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the
GNU General Public License, as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.
JUCE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with JUCE; if not, visit www.gnu.org/licenses or write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
------------------------------------------------------------------------------
If you'd like to release a closed-source product which uses JUCE, commercial
licenses are also available: visit www.rawmaterialsoftware.com/juce for
more information.
==============================================================================
*/
#include "../../../../juce_core/basics/juce_StandardHeader.h"
BEGIN_JUCE_NAMESPACE
#include "juce_OldSchoolLookAndFeel.h"
#include "../buttons/juce_TextButton.h"
#include "../buttons/juce_ToggleButton.h"
#include "../buttons/juce_ShapeButton.h"
#include "../buttons/juce_ArrowButton.h"
#include "../windows/juce_AlertWindow.h"
#include "../buttons/juce_DrawableButton.h"
#include "../windows/juce_DocumentWindow.h"
#include "../layout/juce_ScrollBar.h"
#include "../controls/juce_Slider.h"
#include "../controls/juce_ProgressBar.h"
#include "../controls/juce_ListBox.h"
#include "../filebrowser/juce_FilenameComponent.h"
#include "../juce_Desktop.h"
#include "../../graphics/brushes/juce_GradientBrush.h"
#include "../../graphics/drawables/juce_DrawableComposite.h"
#include "../../graphics/drawables/juce_DrawablePath.h"
//==============================================================================
OldSchoolLookAndFeel::OldSchoolLookAndFeel()
{
setColour (TextButton::buttonColourId, Colour (0xffbbbbff));
setColour (ListBox::outlineColourId, findColour (ComboBox::outlineColourId));
setColour (ScrollBar::thumbColourId, Colour (0xffbbbbdd));
setColour (ScrollBar::backgroundColourId, Colours::transparentBlack);
setColour (Slider::thumbColourId, Colours::white);
setColour (Slider::trackColourId, Colour (0x7f000000));
setColour (Slider::textBoxOutlineColourId, Colours::grey);
setColour (ProgressBar::backgroundColourId, Colours::white.withAlpha (0.6f));
setColour (ProgressBar::foregroundColourId, Colours::green.withAlpha (0.7f));
setColour (PopupMenu::backgroundColourId, Colour (0xffeef5f8));
setColour (PopupMenu::highlightedBackgroundColourId, Colour (0xbfa4c2ce));
setColour (PopupMenu::highlightedTextColourId, Colours::black);
setColour (TextEditor::focusedOutlineColourId, findColour (TextButton::buttonColourId));
scrollbarShadow.setShadowProperties (2.2f, 0.5f, 0, 0);
}
OldSchoolLookAndFeel::~OldSchoolLookAndFeel()
{
}
//==============================================================================
void OldSchoolLookAndFeel::drawButtonBackground (Graphics& g,
Button& button,
const Colour& backgroundColour,
bool isMouseOverButton,
bool isButtonDown)
{
const int width = button.getWidth();
const int height = button.getHeight();
const float indent = 2.0f;
const int cornerSize = jmin (roundFloatToInt (width * 0.4f),
roundFloatToInt (height * 0.4f));
Path p;
p.addRoundedRectangle (indent, indent,
width - indent * 2.0f,
height - indent * 2.0f,
(float) cornerSize);
Colour bc (backgroundColour.withMultipliedSaturation (0.3f));
if (isMouseOverButton)
{
if (isButtonDown)
bc = bc.brighter();
else if (bc.getBrightness() > 0.5f)
bc = bc.darker (0.1f);
else
bc = bc.brighter (0.1f);
}
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));
}
void OldSchoolLookAndFeel::drawTickBox (Graphics& g,
Component& /*component*/,
int x, int y, int w, int h,
const bool ticked,
const bool isEnabled,
const bool /*isMouseOverButton*/,
const bool isButtonDown)
{
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)
: Colours::lightgrey.withAlpha (0.1f));
AffineTransform trans (AffineTransform::scale (w / 9.0f, h / 9.0f)
.translated ((float) x, (float) y));
g.fillPath (box, trans);
g.setColour (Colours::black.withAlpha (0.6f));
g.strokePath (box, PathStrokeType (0.9f), trans);
if (ticked)
{
Path tick;
tick.startNewSubPath (1.5f, 3.0f);
tick.lineTo (3.0f, 6.0f);
tick.lineTo (6.0f, 0.0f);
g.setColour (isEnabled ? Colours::black : Colours::grey);
g.strokePath (tick, PathStrokeType (2.5f), trans);
}
}
void OldSchoolLookAndFeel::drawToggleButton (Graphics& g,
ToggleButton& button,
bool isMouseOverButton,
bool isButtonDown)
{
if (button.hasKeyboardFocus (true))
{
g.setColour (button.findColour (TextEditor::focusedOutlineColourId));
g.drawRect (0, 0, button.getWidth(), button.getHeight());
}
const int tickWidth = jmin (20, button.getHeight() - 4);
drawTickBox (g, button, 4, (button.getHeight() - tickWidth) / 2,
tickWidth, tickWidth,
button.getToggleState(),
button.isEnabled(),
isMouseOverButton,
isButtonDown);
g.setColour (button.findColour (ToggleButton::textColourId));
g.setFont (jmin (15.0f, button.getHeight() * 0.6f));
if (! button.isEnabled())
g.setOpacity (0.5f);
const int textX = tickWidth + 5;
g.drawFittedText (button.getButtonText(),
textX, 4,
button.getWidth() - textX - 2, button.getHeight() - 8,
Justification::centredLeft, 10);
}
void OldSchoolLookAndFeel::drawProgressBar (Graphics& g, ProgressBar& progressBar,
int x, int y, int w, int h,
float progress)
{
g.fillAll (progressBar.findColour (ProgressBar::backgroundColourId));
g.setColour (progressBar.findColour (ProgressBar::foregroundColourId));
g.fillRect (x + 1,
y + 1,
jlimit (0, w - 2, roundFloatToInt (progress * (w - 2))),
h - 2);
}
void OldSchoolLookAndFeel::drawScrollbarButton (Graphics& g,
ScrollBar& bar,
int width, int height,
int buttonDirection,
bool isScrollbarVertical,
bool isMouseOverButton,
bool isButtonDown)
{
if (isScrollbarVertical)
width -= 2;
else
height -= 2;
Path p;
if (buttonDirection == 0)
p.addTriangle (width * 0.5f, height * 0.2f,
width * 0.1f, height * 0.7f,
width * 0.9f, height * 0.7f);
else if (buttonDirection == 1)
p.addTriangle (width * 0.8f, height * 0.5f,
width * 0.3f, height * 0.1f,
width * 0.3f, height * 0.9f);
else if (buttonDirection == 2)
p.addTriangle (width * 0.5f, height * 0.8f,
width * 0.1f, height * 0.3f,
width * 0.9f, height * 0.3f);
else if (buttonDirection == 3)
p.addTriangle (width * 0.2f, height * 0.5f,
width * 0.7f, height * 0.1f,
width * 0.7f, height * 0.9f);
if (isButtonDown)
g.setColour (Colours::white);
else if (isMouseOverButton)
g.setColour (Colours::white.withAlpha (0.7f));
else
g.setColour (bar.findColour (ScrollBar::thumbColourId).withAlpha (0.5f));
g.fillPath (p);
g.setColour (Colours::black.withAlpha (0.5f));
g.strokePath (p, PathStrokeType (0.5f));
}
void OldSchoolLookAndFeel::drawScrollbar (Graphics& g,
ScrollBar& bar,
int x, int y,
int width, int height,
bool isScrollbarVertical,
int thumbStartPosition,
int thumbSize,
bool isMouseOver,
bool isMouseDown)
{
g.fillAll (bar.findColour (ScrollBar::backgroundColourId));
g.setColour (bar.findColour (ScrollBar::thumbColourId)
.withAlpha ((isMouseOver || isMouseDown) ? 0.4f : 0.15f));
if (thumbSize > 0.0f)
{
Rectangle thumb;
if (isScrollbarVertical)
{
width -= 2;
g.fillRect (x + roundFloatToInt (width * 0.35f), y,
roundFloatToInt (width * 0.3f), height);
thumb.setBounds (x + 1, thumbStartPosition,
width - 2, thumbSize);
}
else
{
height -= 2;
g.fillRect (x, y + roundFloatToInt (height * 0.35f),
width, roundFloatToInt (height * 0.3f));
thumb.setBounds (thumbStartPosition, y + 1,
thumbSize, height - 2);
}
g.setColour (bar.findColour (ScrollBar::thumbColourId)
.withAlpha ((isMouseOver || isMouseDown) ? 0.95f : 0.7f));
g.fillRect (thumb);
g.setColour (Colours::black.withAlpha ((isMouseOver || isMouseDown) ? 0.4f : 0.25f));
g.drawRect (thumb.getX(), thumb.getY(), thumb.getWidth(), thumb.getHeight());
if (thumbSize > 16)
{
for (int i = 3; --i >= 0;)
{
const float linePos = thumbStartPosition + thumbSize / 2 + (i - 1) * 4.0f;
g.setColour (Colours::black.withAlpha (0.15f));
if (isScrollbarVertical)
{
g.drawLine (x + width * 0.2f, linePos, width * 0.8f, linePos);
g.setColour (Colours::white.withAlpha (0.15f));
g.drawLine (width * 0.2f, linePos - 1, width * 0.8f, linePos - 1);
}
else
{
g.drawLine (linePos, height * 0.2f, linePos, height * 0.8f);
g.setColour (Colours::white.withAlpha (0.15f));
g.drawLine (linePos - 1, height * 0.2f, linePos - 1, height * 0.8f);
}
}
}
}
}
ImageEffectFilter* OldSchoolLookAndFeel::getScrollbarEffect()
{
return &scrollbarShadow;
}
//==============================================================================
void OldSchoolLookAndFeel::drawPopupMenuBackground (Graphics& g, int width, int height)
{
g.fillAll (findColour (PopupMenu::backgroundColourId));
g.setColour (Colours::black.withAlpha (0.6f));
g.drawRect (0, 0, width, height);
}
void OldSchoolLookAndFeel::drawMenuBarBackground (Graphics& g, int /*width*/, int /*height*/,
bool, MenuBarComponent& menuBar)
{
g.fillAll (menuBar.findColour (PopupMenu::backgroundColourId));
}
//==============================================================================
void OldSchoolLookAndFeel::drawTextEditorOutline (Graphics& g, int width, int height, TextEditor& textEditor)
{
if (textEditor.isEnabled())
{
g.setColour (textEditor.findColour (TextEditor::outlineColourId));
g.drawRect (0, 0, width, height);
}
}
//==============================================================================
void OldSchoolLookAndFeel::drawComboBox (Graphics& g, int width, int height,
const bool isButtonDown,
int buttonX, int buttonY,
int buttonW, int buttonH,
ComboBox& box)
{
g.fillAll (box.findColour (ComboBox::backgroundColourId));
g.setColour (box.findColour ((isButtonDown) ? ComboBox::buttonColourId
: ComboBox::backgroundColourId));
g.fillRect (buttonX, buttonY, buttonW, buttonH);
g.setColour (box.findColour (ComboBox::outlineColourId));
g.drawRect (0, 0, width, height);
const float arrowX = 0.2f;
const float arrowH = 0.3f;
if (box.isEnabled())
{
Path p;
p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.45f - arrowH),
buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.45f,
buttonX + buttonW * arrowX, buttonY + buttonH * 0.45f);
p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.55f + arrowH),
buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.55f,
buttonX + buttonW * arrowX, buttonY + buttonH * 0.55f);
g.setColour (box.findColour ((isButtonDown) ? ComboBox::backgroundColourId
: ComboBox::buttonColourId));
g.fillPath (p);
}
}
const Font OldSchoolLookAndFeel::getComboBoxFont (ComboBox& box)
{
Font f (jmin (15.0f, box.getHeight() * 0.85f));
f.setHorizontalScale (0.9f);
return f;
}
//==============================================================================
static void drawTriangle (Graphics& g, float x1, float y1, float x2, float y2, float x3, float y3, const Colour& fill, const Colour& outline) throw()
{
Path p;
p.addTriangle (x1, y1, x2, y2, x3, y3);
g.setColour (fill);
g.fillPath (p);
g.setColour (outline);
g.strokePath (p, PathStrokeType (0.3f));
}
void OldSchoolLookAndFeel::drawLinearSlider (Graphics& g,
int x, int y,
int w, int h,
float sliderPos,
float minSliderPos,
float maxSliderPos,
const Slider::SliderStyle style,
Slider& slider)
{
g.fillAll (slider.findColour (Slider::backgroundColourId));
if (style == Slider::LinearBar)
{
g.setColour (slider.findColour (Slider::thumbColourId));
g.fillRect (x, y, (int) sliderPos - x, h);
g.setColour (slider.findColour (Slider::textBoxTextColourId).withMultipliedAlpha (0.5f));
g.drawRect (x, y, (int) sliderPos - x, h);
}
else
{
g.setColour (slider.findColour (Slider::trackColourId)
.withMultipliedAlpha (slider.isEnabled() ? 1.0f : 0.3f));
if (slider.isHorizontal())
{
g.fillRect (x, y + roundFloatToInt (h * 0.6f),
w, roundFloatToInt (h * 0.2f));
}
else
{
g.fillRect (x + roundFloatToInt (w * 0.5f - jmin (3.0f, w * 0.1f)), y,
jmin (4, roundFloatToInt (w * 0.2f)), h);
}
float alpha = 0.35f;
if (slider.isEnabled())
alpha = slider.isMouseOverOrDragging() ? 1.0f : 0.7f;
const Colour fill (slider.findColour (Slider::thumbColourId).withAlpha (alpha));
const Colour outline (Colours::black.withAlpha (slider.isEnabled() ? 0.7f : 0.35f));
if (style == Slider::TwoValueVertical || style == Slider::ThreeValueVertical)
{
drawTriangle (g, x + w * 0.5f + jmin (4.0f, w * 0.3f), minSliderPos,
x + w * 0.5f - jmin (8.0f, w * 0.4f), minSliderPos - 7.0f,
x + w * 0.5f - jmin (8.0f, w * 0.4f), minSliderPos,
fill, outline);
drawTriangle (g, x + w * 0.5f + jmin (4.0f, w * 0.3f), maxSliderPos,
x + w * 0.5f - jmin (8.0f, w * 0.4f), maxSliderPos,
x + w * 0.5f - jmin (8.0f, w * 0.4f), maxSliderPos + 7.0f,
fill, outline);
}
else if (style == Slider::TwoValueHorizontal || style == Slider::ThreeValueHorizontal)
{
drawTriangle (g, minSliderPos, y + h * 0.6f - jmin (4.0f, h * 0.3f),
minSliderPos - 7.0f, y + h * 0.9f ,
minSliderPos, y + h * 0.9f,
fill, outline);
drawTriangle (g, maxSliderPos, y + h * 0.6f - jmin (4.0f, h * 0.3f),
maxSliderPos, y + h * 0.9f,
maxSliderPos + 7.0f, y + h * 0.9f,
fill, outline);
}
if (style == Slider::LinearHorizontal || style == Slider::ThreeValueHorizontal)
{
drawTriangle (g, sliderPos, y + h * 0.9f,
sliderPos - 7.0f, y + h * 0.2f,
sliderPos + 7.0f, y + h * 0.2f,
fill, outline);
}
else if (style == Slider::LinearVertical || style == Slider::ThreeValueVertical)
{
drawTriangle (g, x + w * 0.5f - jmin (4.0f, w * 0.3f), sliderPos,
x + w * 0.5f + jmin (8.0f, w * 0.4f), sliderPos - 7.0f,
x + w * 0.5f + jmin (8.0f, w * 0.4f), sliderPos + 7.0f,
fill, outline);
}
}
}
Button* OldSchoolLookAndFeel::createSliderButton (const bool isIncrement)
{
if (isIncrement)
return new ArrowButton ("u", 0.75f, Colours::white.withAlpha (0.8f));
else
return new ArrowButton ("d", 0.25f, Colours::white.withAlpha (0.8f));
}
ImageEffectFilter* OldSchoolLookAndFeel::getSliderEffect()
{
return &scrollbarShadow;
}
int OldSchoolLookAndFeel::getSliderThumbRadius (Slider&)
{
return 8;
}
//==============================================================================
void OldSchoolLookAndFeel::drawCornerResizer (Graphics& g,
int w, int h,
bool isMouseOver,
bool isMouseDragging)
{
g.setColour ((isMouseOver || isMouseDragging) ? Colours::lightgrey
: Colours::darkgrey);
const float lineThickness = jmin (w, h) * 0.1f;
for (float i = 0.0f; i < 1.0f; i += 0.3f)
{
g.drawLine (w * i,
h + 1.0f,
w + 1.0f,
h * i,
lineThickness);
}
}
//==============================================================================
Button* OldSchoolLookAndFeel::createDocumentWindowButton (int buttonType)
{
Path shape;
if (buttonType == DocumentWindow::closeButton)
{
shape.addLineSegment (0.0f, 0.0f, 1.0f, 1.0f, 0.35f);
shape.addLineSegment (1.0f, 0.0f, 0.0f, 1.0f, 0.35f);
ShapeButton* const b = new ShapeButton ("close",
Colour (0x7fff3333),
Colour (0xd7ff3333),
Colour (0xf7ff3333));
b->setShape (shape, true, true, true);
return b;
}
else if (buttonType == DocumentWindow::minimiseButton)
{
shape.addLineSegment (0.0f, 0.5f, 1.0f, 0.5f, 0.25f);
DrawableButton* b = new DrawableButton ("minimise", DrawableButton::ImageFitted);
DrawablePath dp;
dp.setPath (shape);
dp.setSolidFill (Colours::black.withAlpha (0.3f));
b->setImages (&dp);
return b;
}
else if (buttonType == DocumentWindow::maximiseButton)
{
shape.addLineSegment (0.5f, 0.0f, 0.5f, 1.0f, 0.25f);
shape.addLineSegment (0.0f, 0.5f, 1.0f, 0.5f, 0.25f);
DrawableButton* b = new DrawableButton ("maximise", DrawableButton::ImageFitted);
DrawablePath dp;
dp.setPath (shape);
dp.setSolidFill (Colours::black.withAlpha (0.3f));
b->setImages (&dp);
return b;
}
jassertfalse
return 0;
}
void OldSchoolLookAndFeel::positionDocumentWindowButtons (DocumentWindow&,
int titleBarX,
int titleBarY,
int titleBarW,
int titleBarH,
Button* minimiseButton,
Button* maximiseButton,
Button* closeButton,
bool positionTitleBarButtonsOnLeft)
{
titleBarY += titleBarH / 8;
titleBarH -= titleBarH / 4;
const int buttonW = titleBarH;
int x = positionTitleBarButtonsOnLeft ? titleBarX + 4
: titleBarX + titleBarW - buttonW - 4;
if (closeButton != 0)
{
closeButton->setBounds (x, titleBarY, buttonW, titleBarH);
x += positionTitleBarButtonsOnLeft ? buttonW + buttonW / 5
: -(buttonW + buttonW / 5);
}
if (positionTitleBarButtonsOnLeft)
swapVariables (minimiseButton, maximiseButton);
if (maximiseButton != 0)
{
maximiseButton->setBounds (x, titleBarY - 2, buttonW, titleBarH);
x += positionTitleBarButtonsOnLeft ? buttonW : -buttonW;
}
if (minimiseButton != 0)
minimiseButton->setBounds (x, titleBarY - 2, buttonW, titleBarH);
}
END_JUCE_NAMESPACE

View file

@ -0,0 +1,168 @@
/*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-7 by Raw Material Software ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the
GNU General Public License, as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.
JUCE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with JUCE; if not, visit www.gnu.org/licenses or write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
------------------------------------------------------------------------------
If you'd like to release a closed-source product which uses JUCE, commercial
licenses are also available: visit www.rawmaterialsoftware.com/juce for
more information.
==============================================================================
*/
#ifndef __JUCE_OLDSCHOOLLOOKANDFEEL_JUCEHEADER__
#define __JUCE_OLDSCHOOLLOOKANDFEEL_JUCEHEADER__
#include "juce_LookAndFeel.h"
//==============================================================================
/**
The original Juce look-and-feel.
*/
class JUCE_API OldSchoolLookAndFeel : public LookAndFeel
{
public:
//==============================================================================
/** Creates the default JUCE look and feel. */
OldSchoolLookAndFeel();
/** Destructor. */
virtual ~OldSchoolLookAndFeel();
//==============================================================================
/** Draws the lozenge-shaped background for a standard button. */
virtual void drawButtonBackground (Graphics& g,
Button& button,
const Colour& backgroundColour,
bool isMouseOverButton,
bool isButtonDown);
/** Draws the contents of a standard ToggleButton. */
virtual void drawToggleButton (Graphics& g,
ToggleButton& button,
bool isMouseOverButton,
bool isButtonDown);
virtual void drawTickBox (Graphics& g,
Component& component,
int x, int y, int w, int h,
const bool ticked,
const bool isEnabled,
const bool isMouseOverButton,
const bool isButtonDown);
//==============================================================================
virtual void drawProgressBar (Graphics& g, ProgressBar& progressBar,
int x, int y, int w, int h,
float progress);
//==============================================================================
virtual void drawScrollbarButton (Graphics& g,
ScrollBar& scrollbar,
int width, int height,
int buttonDirection,
bool isScrollbarVertical,
bool isMouseOverButton,
bool isButtonDown);
virtual void drawScrollbar (Graphics& g,
ScrollBar& scrollbar,
int x, int y,
int width, int height,
bool isScrollbarVertical,
int thumbStartPosition,
int thumbSize,
bool isMouseOver,
bool isMouseDown);
virtual ImageEffectFilter* getScrollbarEffect();
//==============================================================================
virtual void drawTextEditorOutline (Graphics& g,
int width, int height,
TextEditor& textEditor);
//==============================================================================
/** Fills the background of a popup menu component. */
virtual void drawPopupMenuBackground (Graphics& g, int width, int height);
virtual void drawMenuBarBackground (Graphics& g, int width, int height,
bool isMouseOverBar,
MenuBarComponent& menuBar);
//==============================================================================
virtual void drawComboBox (Graphics& g, int width, int height,
const bool isButtonDown,
int buttonX, int buttonY,
int buttonW, int buttonH,
ComboBox& box);
virtual const Font getComboBoxFont (ComboBox& box);
//==============================================================================
virtual void drawLinearSlider (Graphics& g,
int x, int y,
int width, int height,
float sliderPos,
float minSliderPos,
float maxSliderPos,
const Slider::SliderStyle style,
Slider& slider);
virtual int getSliderThumbRadius (Slider& slider);
virtual Button* createSliderButton (const bool isIncrement);
virtual ImageEffectFilter* getSliderEffect();
//==============================================================================
virtual void drawCornerResizer (Graphics& g,
int w, int h,
bool isMouseOver,
bool isMouseDragging);
virtual Button* createDocumentWindowButton (int buttonType);
virtual void positionDocumentWindowButtons (DocumentWindow& window,
int titleBarX, int titleBarY,
int titleBarW, int titleBarH,
Button* minimiseButton,
Button* maximiseButton,
Button* closeButton,
bool positionTitleBarButtonsOnLeft);
//==============================================================================
juce_UseDebuggingNewOperator
private:
DropShadowEffect scrollbarShadow;
OldSchoolLookAndFeel (const OldSchoolLookAndFeel&);
const OldSchoolLookAndFeel& operator= (const OldSchoolLookAndFeel&);
};
#endif // __JUCE_OLDSCHOOLLOOKANDFEEL_JUCEHEADER__

View file

@ -1,187 +0,0 @@
/*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-7 by Raw Material Software ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the
GNU General Public License, as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.
JUCE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with JUCE; if not, visit www.gnu.org/licenses or write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
------------------------------------------------------------------------------
If you'd like to release a closed-source product which uses JUCE, commercial
licenses are also available: visit www.rawmaterialsoftware.com/juce for
more information.
==============================================================================
*/
#ifndef __JUCE_SHINYLOOKANDFEEL_JUCEHEADER__
#define __JUCE_SHINYLOOKANDFEEL_JUCEHEADER__
#include "juce_LookAndFeel.h"
//==============================================================================
/**
A new, slightly plasticky looking look-and-feel.
To make this the default look for your app, just set it as the default in
your initialisation code.
e.g. @code
void initialise (const String& commandLine)
{
static ShinyLookAndFeel shinyLook;
LookAndFeel::setDefaultLookAndFeel (&shinyLook);
}
@endcode
*/
class JUCE_API ShinyLookAndFeel : public LookAndFeel
{
public:
//==============================================================================
/** Creates a ShinyLookAndFeel look and feel object. */
ShinyLookAndFeel();
/** Destructor. */
virtual ~ShinyLookAndFeel();
//==============================================================================
void drawTextEditorOutline (Graphics& g,
int width, int height,
TextEditor& textEditor);
//==============================================================================
void drawComboBox (Graphics& g, int width, int height,
const bool isButtonDown,
int buttonX, int buttonY,
int buttonW, int buttonH,
ComboBox& box);
const Font getComboBoxFont (ComboBox& box);
//==============================================================================
void drawScrollbarButton (Graphics& g,
ScrollBar& scrollbar,
int width, int height,
int buttonDirection,
bool isScrollbarVertical,
bool isMouseOverButton,
bool isButtonDown);
void drawScrollbar (Graphics& g,
ScrollBar& scrollbar,
int x, int y,
int width, int height,
bool isScrollbarVertical,
int thumbStartPosition,
int thumbSize,
bool isMouseOver,
bool isMouseDown);
ImageEffectFilter* getScrollbarEffect();
//==============================================================================
void drawButtonBackground (Graphics& g,
Button& button,
const Colour& backgroundColour,
bool isMouseOverButton,
bool isButtonDown);
void drawTickBox (Graphics& g,
Component& component,
int x, int y, int w, int h,
const bool ticked,
const bool isEnabled,
const bool isMouseOverButton,
const bool isButtonDown);
//==============================================================================
void drawLinearSlider (Graphics& g,
int x, int y,
int width, int height,
float sliderPos,
float minSliderPos,
float maxSliderPos,
const Slider::SliderStyle style,
Slider& slider);
int getSliderThumbRadius (Slider& slider);
Button* createSliderButton (const bool isIncrement);
ImageEffectFilter* getSliderEffect();
//==============================================================================
void drawPopupMenuBackground (Graphics& g, int width, int height);
void drawMenuBarBackground (Graphics& g, int width, int height,
bool isMouseOverBar, MenuBarComponent& menuBar);
//==============================================================================
void positionDocumentWindowButtons (DocumentWindow& window,
int titleBarX, int titleBarY,
int titleBarW, int titleBarH,
Button* minimiseButton,
Button* maximiseButton,
Button* closeButton,
bool positionTitleBarButtonsOnLeft);
Button* createDocumentWindowButton (int buttonType);
//==============================================================================
void drawCornerResizer (Graphics& g,
int w, int h,
bool isMouseOver,
bool isMouseDragging);
//==============================================================================
void drawProgressBar (Graphics& g,
ProgressBar& progressBar,
int x, int y, int w, int h,
float progress);
//==============================================================================
/** Utility function to draw a shiny, glassy circle (for round LED-type buttons). */
static void drawGlassSphere (Graphics& g, float x, float y, float diameter,
const Colour& colour, const float outlineThickness);
static void drawGlassPointer (Graphics& g, float x, float y, float diameter,
const Colour& colour, const float outlineThickness,
const int direction);
/** Utility function to draw a shiny, glassy oblong (for text buttons). */
static void drawGlassLozenge (Graphics& g, float x, float y, float width, float height,
const Colour& colour, const float outlineThickness, const float cornerSize,
const bool flatOnLeft, const bool flatOnRight, const bool flatOnTop, const bool flatOnBottom);
//==============================================================================
juce_UseDebuggingNewOperator
private:
void drawShinyButtonShape (Graphics& g,
float x, float y, float w, float h, float maxCornerSize,
const Colour& baseColour,
const float strokeWidth,
const bool flatOnLeft,
const bool flatOnRight,
const bool flatOnTop,
const bool flatOnBottom);
};
#endif // __JUCE_SHINYLOOKANDFEEL_JUCEHEADER__

View file

@ -220,17 +220,27 @@ bool Colour::isOpaque() const throw()
const Colour Colour::withAlpha (const uint8 newAlpha) const throw()
{
return Colour (getRed(), getGreen(), getBlue(), newAlpha);
PixelARGB newCol (argb);
newCol.setAlpha (newAlpha);
return Colour (newCol.getARGB());
}
const Colour Colour::withAlpha (const float newAlpha) const throw()
{
return withAlpha (floatAlphaToInt (newAlpha));
jassert (newAlpha >= 0 && newAlpha <= 1.0f);
PixelARGB newCol (argb);
newCol.setAlpha (floatAlphaToInt (newAlpha));
return Colour (newCol.getARGB());
}
const Colour Colour::withMultipliedAlpha (const float alphaMultiplier) const throw()
{
return withAlpha ((uint8) jlimit (0, 0xff, roundFloatToInt (alphaMultiplier * getAlpha())));
jassert (alphaMultiplier >= 0);
PixelARGB newCol (argb);
newCol.setAlpha ((uint8) jmin (0xff, roundFloatToInt (alphaMultiplier * newCol.getAlpha())));
return Colour (newCol.getARGB());
}
//==============================================================================