diff --git a/build/linux/platform_specific_code/juce_linux_SystemStats.cpp b/build/linux/platform_specific_code/juce_linux_SystemStats.cpp index 3303cb9f0a..71609f519a 100644 --- a/build/linux/platform_specific_code/juce_linux_SystemStats.cpp +++ b/build/linux/platform_specific_code/juce_linux_SystemStats.cpp @@ -65,7 +65,7 @@ static juce_noinline unsigned int getCPUIDWord (int* familyModel, int* extFeatur unsigned int dummy = 0; #if JUCE_64BIT - __asm__ ("cpuid" + __asm__ ("cpuid" : "=a" (family), "=b" (ext), "=c" (dummy), "=d" (cpu) : "a" (1)); #else diff --git a/build/macosx/Juce.xcodeproj/project.pbxproj b/build/macosx/Juce.xcodeproj/project.pbxproj index 1cd4e3a353..8999b07627 100644 --- a/build/macosx/Juce.xcodeproj/project.pbxproj +++ b/build/macosx/Juce.xcodeproj/project.pbxproj @@ -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 */, diff --git a/build/win32/vc8/JUCE.vcproj b/build/win32/vc8/JUCE.vcproj index 1680dfb935..61041a1118 100644 --- a/build/win32/vc8/JUCE.vcproj +++ b/build/win32/vc8/JUCE.vcproj @@ -3789,11 +3789,11 @@ > diff --git a/docs/JUCE changelist.txt b/docs/JUCE changelist.txt index 11159ab87a..5863b137ac 100644 --- a/docs/JUCE changelist.txt +++ b/docs/JUCE changelist.txt @@ -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. diff --git a/extras/audio plugins/demo/src/DemoEditorComponent.cpp b/extras/audio plugins/demo/src/DemoEditorComponent.cpp index 3dcd9fd0b4..0334a2035e 100644 --- a/extras/audio plugins/demo/src/DemoEditorComponent.cpp +++ b/extras/audio plugins/demo/src/DemoEditorComponent.cpp @@ -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); diff --git a/extras/example projects/common/Main.cpp b/extras/example projects/common/Main.cpp index 8faae6d3b0..34bd5e43f0 100644 --- a/extras/example projects/common/Main.cpp +++ b/extras/example projects/common/Main.cpp @@ -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); } //============================================================================== diff --git a/extras/juce demo/src/BinaryData.cpp b/extras/juce demo/src/BinaryData.cpp index 34a5efd981..e3213ef384 100644 --- a/extras/juce demo/src/BinaryData.cpp +++ b/extras/juce demo/src/BinaryData.cpp @@ -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; - diff --git a/extras/juce demo/src/MainDemoWindow.cpp b/extras/juce demo/src/MainDemoWindow.cpp index 52add2aa1c..a48e5d0619 100644 --- a/extras/juce demo/src/MainDemoWindow.cpp +++ b/extras/juce demo/src/MainDemoWindow.cpp @@ -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: diff --git a/extras/the jucer/src/BinaryData.cpp b/extras/the jucer/src/BinaryData.cpp index c08fddd03e..1279f531a8 100644 --- a/extras/the jucer/src/BinaryData.cpp +++ b/extras/the jucer/src/BinaryData.cpp @@ -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; - diff --git a/extras/the jucer/src/model/components/jucer_TabbedComponentHandler.h b/extras/the jucer/src/model/components/jucer_TabbedComponentHandler.h index afb057428f..6ab2c32252 100644 --- a/extras/the jucer/src/model/components/jucer_TabbedComponentHandler.h +++ b/extras/the jucer/src/model/components/jucer_TabbedComponentHandler.h @@ -1167,7 +1167,7 @@ private: class TabMoveProperty : public ButtonPropertyComponent { public: - TabMoveProperty (TabbedComponent* comp, JucerDocument& document_, + TabMoveProperty (TabbedComponent* comp, JucerDocument& document_, const int tabIndex_, const int totalNumTabs_) : ButtonPropertyComponent (T("add tab"), false), component (comp), @@ -1206,10 +1206,10 @@ private: class MoveTabAction : public ComponentUndoableAction { public: - MoveTabAction (TabbedComponent* const comp, ComponentLayout& layout, + MoveTabAction (TabbedComponent* const comp, ComponentLayout& layout, const int oldIndex_, const int newIndex_) : ComponentUndoableAction (comp, layout), - oldIndex (oldIndex_), + oldIndex (oldIndex_), newIndex (newIndex_) { } diff --git a/extras/the jucer/src/ui/jucer_MainWindow.cpp b/extras/the jucer/src/ui/jucer_MainWindow.cpp index ac789385f7..4e83580fbb 100644 --- a/extras/the jucer/src/ui/jucer_MainWindow.cpp +++ b/extras/the jucer/src/ui/jucer_MainWindow.cpp @@ -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) { diff --git a/src/juce_app_includes.h b/src/juce_app_includes.h index 6f29457438..5a663010a4 100644 --- a/src/juce_app_includes.h +++ b/src/juce_app_includes.h @@ -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" diff --git a/src/juce_appframework/audio/devices/juce_AudioIODevice.h b/src/juce_appframework/audio/devices/juce_AudioIODevice.h index 0fe3d1a5e6..2111bcc2c1 100644 --- a/src/juce_appframework/audio/devices/juce_AudioIODevice.h +++ b/src/juce_appframework/audio/devices/juce_AudioIODevice.h @@ -42,8 +42,8 @@ One of these is passed to an AudioIODevice object to stream the audio data in and out. - The AudioIODevice will repeatedly call this class's audioDeviceIOCallback() - method on its own high-priority audio thread, when it needs to send or receive + The AudioIODevice will repeatedly call this class's audioDeviceIOCallback() + method on its own high-priority audio thread, when it needs to send or receive the next block of data. @see AudioIODevice, AudioDeviceManager diff --git a/src/juce_appframework/gui/components/controls/juce_TreeView.h b/src/juce_appframework/gui/components/controls/juce_TreeView.h index 56825ade08..e08579f21f 100644 --- a/src/juce_appframework/gui/components/controls/juce_TreeView.h +++ b/src/juce_appframework/gui/components/controls/juce_TreeView.h @@ -397,8 +397,8 @@ public: You can pass in 0 to this method to clear the tree and remove its current root item. The object passed in will not be deleted by the treeview, it's up to the caller - to delete it when no longer needed. BUT make absolutely sure that you don't delete - this item until you've removed it from the tree, either by calling setRootItem (0), + to delete it when no longer needed. BUT make absolutely sure that you don't delete + this item until you've removed it from the tree, either by calling setRootItem (0), or by deleting the tree first. */ void setRootItem (TreeViewItem* const newRootItem); diff --git a/src/juce_appframework/gui/components/filebrowser/juce_FileTreeComponent.cpp b/src/juce_appframework/gui/components/filebrowser/juce_FileTreeComponent.cpp index 6404828548..06ff784456 100644 --- a/src/juce_appframework/gui/components/filebrowser/juce_FileTreeComponent.cpp +++ b/src/juce_appframework/gui/components/filebrowser/juce_FileTreeComponent.cpp @@ -235,7 +235,7 @@ FileTreeComponent::FileTreeComponent (DirectoryContentsList& listToShow) : DirectoryContentsDisplayComponent (listToShow) { FileListTreeItem* const root - = new FileListTreeItem (*this, 0, 0, listToShow.getDirectory(), + = new FileListTreeItem (*this, 0, 0, listToShow.getDirectory(), listToShow.getTimeSliceThread()); root->setSubContentsList (&listToShow); diff --git a/src/juce_appframework/gui/components/juce_Component.h b/src/juce_appframework/gui/components/juce_Component.h index 14677bab2c..0d93d3ea4c 100644 --- a/src/juce_appframework/gui/components/juce_Component.h +++ b/src/juce_appframework/gui/components/juce_Component.h @@ -202,7 +202,7 @@ public: getPeer, ComponentPeer::setMinimised, ComponentPeer::StyleFlags, ComponentPeer::getStyleFlags, ComponentPeer::setFullScreen */ - virtual void addToDesktop (int windowStyleFlags, + virtual void addToDesktop (int windowStyleFlags, void* nativeWindowToAttachTo = 0); /** If the component is currently showing on the desktop, this will hide it. diff --git a/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp b/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp index b8474683f5..c16208f45e 100644 --- a/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp +++ b/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp @@ -67,6 +67,22 @@ BEGIN_JUCE_NAMESPACE #include "../../../../juce_core/text/juce_LocalisedStrings.h" #include "../special/juce_MidiKeyboardComponent.h" +//============================================================================== +static const Colour createBaseColour (const Colour& buttonColour, + const bool hasKeyboardFocus, + const bool isMouseOverButton, + const bool isButtonDown) throw() +{ + const float sat = hasKeyboardFocus ? 1.3f : 0.9f; + const Colour baseColour (buttonColour.withMultipliedSaturation (sat)); + + if (isButtonDown) + return baseColour.contrasting (0.2f); + else if (isMouseOverButton) + return baseColour.contrasting (0.1f); + + return baseColour; +} //============================================================================== LookAndFeel::LookAndFeel() @@ -78,95 +94,103 @@ LookAndFeel::LookAndFeel() */ jassert (Colours::white == Colour (0xffffffff)); - // Set up the standard colours.. - setColour (TextButton::buttonColourId, Colour (0xffbbbbff)); - setColour (TextButton::buttonOnColourId, Colour (0xff4444ff)); - setColour (TextButton::textColourId, Colours::black); + // set up the standard set of colours.. + #define textButtonColour 0xffbbbbff + #define textHighlightColour 0x401111ee + #define standardOutlineColour 0xb2808080 - setColour (ToggleButton::textColourId, Colours::black); + static const int standardColours[] = { + TextButton::buttonColourId, textButtonColour, + TextButton::buttonOnColourId, 0xff4444ff, + TextButton::textColourId, 0xff000000, - setColour (TextEditor::backgroundColourId, Colours::white); - setColour (TextEditor::textColourId, Colours::black); - setColour (TextEditor::highlightColourId, Colour (0x401111ee)); - setColour (TextEditor::highlightedTextColourId, Colours::black); - setColour (TextEditor::caretColourId, Colours::black); - setColour (TextEditor::outlineColourId, Colours::transparentBlack); - setColour (TextEditor::focusedOutlineColourId, findColour (TextButton::buttonColourId)); - setColour (TextEditor::shadowColourId, Colours::black.withAlpha (0.22f)); + ComboBox::buttonColourId, 0xffbbbbff, + ComboBox::outlineColourId, standardOutlineColour, - setColour (Label::backgroundColourId, Colours::transparentBlack); - setColour (Label::textColourId, Colours::black); - setColour (Label::outlineColourId, Colours::transparentBlack); + ToggleButton::textColourId, 0xff000000, - setColour (ScrollBar::thumbColourId, Colour (0xffbbbbdd)); - setColour (ScrollBar::backgroundColourId, Colours::transparentBlack); + TextEditor::backgroundColourId, 0xffffffff, + TextEditor::textColourId, 0xff000000, + TextEditor::highlightColourId, textHighlightColour, + TextEditor::highlightedTextColourId, 0xff000000, + TextEditor::caretColourId, 0xff000000, + TextEditor::outlineColourId, 0x00000000, + TextEditor::focusedOutlineColourId, textButtonColour, + TextEditor::shadowColourId, 0x38000000, - setColour (TreeView::linesColourId, Colours::black.withAlpha (0.3f)); - setColour (TreeView::backgroundColourId, Colours::transparentBlack); + Label::backgroundColourId, 0x00000000, + Label::textColourId, 0xff000000, + Label::outlineColourId, 0x00000000, - setColour (PopupMenu::backgroundColourId, Colour (0xffeef5f8)); - setColour (PopupMenu::textColourId, Colours::black); - setColour (PopupMenu::headerTextColourId, Colours::black); - setColour (PopupMenu::highlightedBackgroundColourId, Colour (0xbfa4c2ce)); - setColour (PopupMenu::highlightedTextColourId, Colours::black); + ScrollBar::backgroundColourId, 0x00000000, + ScrollBar::thumbColourId, 0xffffffff, - setColour (ComboBox::textColourId, Colours::black); - setColour (ComboBox::backgroundColourId, Colours::white); - setColour (ComboBox::outlineColourId, Colours::grey); - setColour (ComboBox::buttonColourId, Colours::lightgrey); + TreeView::linesColourId, 0x4c000000, + TreeView::backgroundColourId, 0x00000000, - setColour (ListBox::backgroundColourId, Colours::white); - setColour (ListBox::outlineColourId, findColour (ComboBox::outlineColourId)); + PopupMenu::backgroundColourId, 0xffffffff, + PopupMenu::textColourId, 0xff000000, + PopupMenu::headerTextColourId, 0xff000000, + PopupMenu::highlightedTextColourId, 0xffffffff, + PopupMenu::highlightedBackgroundColourId, 0x991111aa, - setColour (Slider::backgroundColourId, Colours::transparentBlack); - setColour (Slider::thumbColourId, Colours::white); - setColour (Slider::trackColourId, Colour (0x7f000000)); - setColour (Slider::rotarySliderFillColourId, Colour (0x7f0000ff)); - setColour (Slider::rotarySliderOutlineColourId, Colour (0x66000000)); - setColour (Slider::textBoxTextColourId, Colours::black); - setColour (Slider::textBoxBackgroundColourId, Colours::white); - setColour (Slider::textBoxHighlightColourId, findColour (TextEditor::highlightColourId)); - setColour (Slider::textBoxOutlineColourId, Colours::grey); + ComboBox::textColourId, 0xff000000, + ComboBox::backgroundColourId, 0xffffffff, - setColour (AlertWindow::backgroundColourId, Colour::greyLevel (0.93f)); - setColour (AlertWindow::textColourId, Colours::black); - setColour (AlertWindow::outlineColourId, Colour::greyLevel (0.4f)); + ListBox::backgroundColourId, 0xffffffff, + ListBox::outlineColourId, standardOutlineColour, - setColour (ProgressBar::backgroundColourId, Colours::white.withAlpha (0.6f)); - setColour (ProgressBar::foregroundColourId, Colours::green.withAlpha (0.7f)); + Slider::backgroundColourId, 0x00000000, + Slider::thumbColourId, textButtonColour, + Slider::trackColourId, 0x7fffffff, + Slider::rotarySliderFillColourId, 0x7f0000ff, + Slider::rotarySliderOutlineColourId, 0x66000000, + Slider::textBoxTextColourId, 0xff000000, + Slider::textBoxBackgroundColourId, 0xffffffff, + Slider::textBoxHighlightColourId, textHighlightColour, + Slider::textBoxOutlineColourId, standardOutlineColour, - setColour (TooltipWindow::backgroundColourId, Colour (0xffeeeebb)); - setColour (TooltipWindow::textColourId, Colours::black); - setColour (TooltipWindow::outlineColourId, Colours::black.withAlpha (0.3f)); + AlertWindow::backgroundColourId, 0xffededed, + AlertWindow::textColourId, 0xff000000, + AlertWindow::outlineColourId, 0xff666666, - setColour (Toolbar::backgroundColourId, Colour (Colour (0xfff6f8f9))); - setColour (Toolbar::separatorColourId, Colours::black.withAlpha (0.3f)); - setColour (Toolbar::buttonMouseOverBackgroundColourId, Colours::blue.withAlpha (0.3f)); - setColour (Toolbar::buttonMouseDownBackgroundColourId, Colours::blue.withAlpha (0.5f)); - setColour (Toolbar::labelTextColourId, Colours::black); - setColour (Toolbar::editingModeOutlineColourId, Colours::red); + ProgressBar::backgroundColourId, 0xffffffff, + ProgressBar::foregroundColourId, 0xffaaaaee, - setColour (HyperlinkButton::textColourId, Colour (0xcc1111ee)); + TooltipWindow::backgroundColourId, 0xffeeeebb, + TooltipWindow::textColourId, 0xff000000, + TooltipWindow::outlineColourId, 0x4c000000, - setColour (GroupComponent::outlineColourId, Colours::black.withAlpha (0.4f)); - setColour (GroupComponent::textColourId, Colours::black); + Toolbar::backgroundColourId, 0xfff6f8f9, + Toolbar::separatorColourId, 0x4c000000, + Toolbar::buttonMouseOverBackgroundColourId, 0x4c0000ff, + Toolbar::buttonMouseDownBackgroundColourId, 0x800000ff, + Toolbar::labelTextColourId, 0xff000000, + Toolbar::editingModeOutlineColourId, 0xffff0000, - setColour (DirectoryContentsDisplayComponent::highlightColourId, findColour (TextEditor::highlightColourId)); - setColour (DirectoryContentsDisplayComponent::textColourId, Colours::black); + HyperlinkButton::textColourId, 0xcc1111ee, - setColour (0x1000440, /*LassoComponent::lassoFillColourId*/ Colour (0x66dddddd)); - setColour (0x1000441, /*LassoComponent::lassoOutlineColourId*/ Colour (0x99111111)); + GroupComponent::outlineColourId, 0x66000000, + GroupComponent::textColourId, 0xff000000, - setColour (MidiKeyboardComponent::whiteNoteColourId, Colours::white); - setColour (MidiKeyboardComponent::blackNoteColourId, Colours::black); - setColour (MidiKeyboardComponent::keySeparatorLineColourId, Colours::black.withAlpha (0.4f)); - setColour (MidiKeyboardComponent::mouseOverKeyOverlayColourId, Colours::yellow.withAlpha (0.5f)); - setColour (MidiKeyboardComponent::keyDownOverlayColourId, Colours::yellow.darker()); - setColour (MidiKeyboardComponent::textLabelColourId, Colours::black); - setColour (MidiKeyboardComponent::upDownButtonBackgroundColourId, Colours::lightgrey); - setColour (MidiKeyboardComponent::upDownButtonArrowColourId, Colours::black); + DirectoryContentsDisplayComponent::highlightColourId, textHighlightColour, + DirectoryContentsDisplayComponent::textColourId, 0xff000000, - scrollbarShadow.setShadowProperties (2.2f, 0.5f, 0, 0); + 0x1000440, /*LassoComponent::lassoFillColourId*/ 0x66dddddd, + 0x1000441, /*LassoComponent::lassoOutlineColourId*/ 0x99111111, + + MidiKeyboardComponent::whiteNoteColourId, 0xffffffff, + MidiKeyboardComponent::blackNoteColourId, 0xff000000, + MidiKeyboardComponent::keySeparatorLineColourId, 0x66000000, + MidiKeyboardComponent::mouseOverKeyOverlayColourId, 0x80ffff00, + MidiKeyboardComponent::keyDownOverlayColourId, 0xffb6b600, + MidiKeyboardComponent::textLabelColourId, 0xff000000, + MidiKeyboardComponent::upDownButtonBackgroundColourId, 0xffd3d3d3, + MidiKeyboardComponent::upDownButtonArrowColourId, 0xff000000 + }; + + for (int i = 0; i < numElementsInArray (standardColours); i += 2) + setColour (standardColours [i], Colour (standardColours [i + 1])); } LookAndFeel::~LookAndFeel() @@ -249,56 +273,47 @@ void LookAndFeel::drawButtonBackground (Graphics& g, 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)); + const float outlineThickness = button.isEnabled() ? ((isButtonDown || isMouseOverButton) ? 1.2f : 0.7f) : 0.4f; - Path p; - p.addRoundedRectangle (indent, indent, - width - indent * 2.0f, - height - indent * 2.0f, - (float) cornerSize); + const float indentL = button.isConnectedOnLeft() ? 0.1f : outlineThickness * 0.5f; + const float indentR = button.isConnectedOnRight() ? 0.1f : outlineThickness * 0.5f; + const float indentT = button.isConnectedOnTop() ? 0.1f : outlineThickness * 0.5f; + const float indentB = button.isConnectedOnBottom() ? 0.1f : outlineThickness * 0.5f; - Colour bc (backgroundColour.withMultipliedSaturation (0.3f)); + const Colour baseColour (createBaseColour (backgroundColour, + button.hasKeyboardFocus (true), + isMouseOverButton, isButtonDown) + .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f)); - 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)); + drawGlassLozenge (g, + indentL, + indentT, + width - indentL - indentR, + height - indentT - indentB, + baseColour, outlineThickness, -1.0f, + button.isConnectedOnLeft(), + button.isConnectedOnRight(), + button.isConnectedOnTop(), + button.isConnectedOnBottom()); } void LookAndFeel::drawTickBox (Graphics& g, - Component& /*component*/, + Component& component, int x, int y, int w, int h, const bool ticked, const bool isEnabled, - const bool /*isMouseOverButton*/, + const bool isMouseOverButton, const bool isButtonDown) { - Path box; - box.addRoundedRectangle (0.0f, 2.0f, 6.0f, 6.0f, 1.0f); + const float boxSize = w * 0.7f; - 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); + drawGlassSphere (g, (float) x, y + (h - boxSize) * 0.5f, boxSize, + createBaseColour (component.findColour (TextButton::buttonColourId) + .withMultipliedAlpha (isEnabled ? 1.0f : 0.5f), + true, + isMouseOverButton, + isButtonDown), + isEnabled ? ((isButtonDown || isMouseOverButton) ? 1.1f : 0.5f) : 0.3f); if (ticked) { @@ -308,6 +323,10 @@ void LookAndFeel::drawTickBox (Graphics& g, tick.lineTo (6.0f, 0.0f); g.setColour (isEnabled ? Colours::black : Colours::grey); + + AffineTransform trans (AffineTransform::scale (w / 9.0f, h / 9.0f) + .translated ((float) x, (float) y)); + g.strokePath (tick, PathStrokeType (2.5f), trans); } } @@ -395,8 +414,8 @@ void LookAndFeel::drawAlertBox (Graphics& g, g.setColour (background); g.setFont (iconRect.getHeight() * 0.9f, Font::bold); - g.drawText ((alert.getAlertType() == AlertWindow::InfoIcon) ? T("i") - : T("?"), + g.drawText ((alert.getAlertType() == AlertWindow::InfoIcon) ? "i" + : "?", iconRect.getX(), iconRect.getY(), iconRect.getWidth(), @@ -456,29 +475,31 @@ void LookAndFeel::drawProgressBar (Graphics& g, ProgressBar& progressBar, int x, int y, int w, int h, float progress) { - g.fillAll (progressBar.findColour (ProgressBar::backgroundColourId)); + const Colour background (progressBar.findColour (ProgressBar::backgroundColourId)); + g.fillAll (background); - g.setColour (progressBar.findColour (ProgressBar::foregroundColourId)); + g.setColour (background.contrasting (0.2f)); + g.drawRect (x, y, w, h); - g.fillRect (x + 1, - y + 1, - jlimit (0, w - 2, roundFloatToInt (progress * (w - 2))), - h - 2); + drawGlassLozenge (g, + (float) (x + 1), + (float) (y + 1), + jlimit (0.0f, w - 2.0f, progress * (w - 2.0f)), + (float) (h - 2), + progressBar.findColour (ProgressBar::foregroundColourId), + 0.5f, + 0.0f, + true, true, true, true); } void LookAndFeel::drawScrollbarButton (Graphics& g, - ScrollBar& bar, + ScrollBar& scrollbar, int width, int height, int buttonDirection, - bool isScrollbarVertical, - bool isMouseOverButton, + bool /*isScrollbarVertical*/, + bool /*isMouseOverButton*/, bool isButtonDown) { - if (isScrollbarVertical) - width -= 2; - else - height -= 2; - Path p; if (buttonDirection == 0) @@ -499,11 +520,9 @@ void LookAndFeel::drawScrollbarButton (Graphics& g, width * 0.7f, height * 0.9f); if (isButtonDown) - g.setColour (Colours::white); - else if (isMouseOverButton) - g.setColour (Colours::white.withAlpha (0.7f)); + g.setColour (scrollbar.findColour (ScrollBar::thumbColourId).contrasting (0.2f)); else - g.setColour (bar.findColour (ScrollBar::thumbColourId).withAlpha (0.5f)); + g.setColour (scrollbar.findColour (ScrollBar::thumbColourId)); g.fillPath (p); @@ -512,78 +531,114 @@ void LookAndFeel::drawScrollbarButton (Graphics& g, } void LookAndFeel::drawScrollbar (Graphics& g, - ScrollBar& bar, + ScrollBar& scrollbar, int x, int y, int width, int height, bool isScrollbarVertical, int thumbStartPosition, int thumbSize, - bool isMouseOver, - bool isMouseDown) + bool /*isMouseOver*/, + bool /*isMouseDown*/) { - g.fillAll (bar.findColour (ScrollBar::backgroundColourId)); + g.fillAll (scrollbar.findColour (ScrollBar::backgroundColourId)); - g.setColour (bar.findColour (ScrollBar::thumbColourId) - .withAlpha ((isMouseOver || isMouseDown) ? 0.4f : 0.15f)); + Path slotPath, thumbPath; - if (thumbSize > 0.0f) + const float slotIndent = jmin (width, height) > 15 ? 1.0f : 0.0f; + const float thumbIndent = slotIndent + 1.0f; + + float gx1 = 0.0f, gy1 = 0.0f, gx2 = 0.0f, gy2 = 0.0f; + + if (isScrollbarVertical) { - Rectangle thumb; + slotPath.addRoundedRectangle (x + slotIndent, + y + slotIndent, + width - slotIndent * 2.0f, + height - slotIndent * 2.0f, + (width - slotIndent * 2.0f) * 0.5f); - 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); - } - } - } + if (thumbSize > 0) + thumbPath.addRoundedRectangle (x + thumbIndent, + thumbStartPosition + thumbIndent, + width - thumbIndent * 2.0f, + thumbSize - thumbIndent * 2.0f, + (width - thumbIndent * 2.0f) * 0.5f); + gx1 = (float) x; + gx2 = x + width * 0.7f; } + else + { + slotPath.addRoundedRectangle (x + slotIndent, + y + slotIndent, + width - slotIndent * 2.0f, + height - slotIndent * 2.0f, + (height - slotIndent * 2.0f) * 0.5f); + + if (thumbSize > 0) + thumbPath.addRoundedRectangle (thumbStartPosition + thumbIndent, + y + thumbIndent, + thumbSize - thumbIndent * 2.0f, + height - thumbIndent * 2.0f, + (height - thumbIndent * 2.0f) * 0.5f); + gy1 = (float) y; + gy2 = y + height * 0.7f; + } + + const Colour thumbColour (scrollbar.findColour (ScrollBar::thumbColourId)); + + GradientBrush gb (thumbColour.overlaidWith (Colours::black.withAlpha (0.27f)), + gx1, gy1, + thumbColour.overlaidWith (Colours::black.withAlpha (0.1f)), + gx2, gy2, false); + + g.setBrush (&gb); + g.fillPath (slotPath); + + if (isScrollbarVertical) + { + gx1 = x + width * 0.6f; + gx2 = (float) x + width; + } + else + { + gy1 = y + height * 0.6f; + gy2 = (float) y + height; + } + + GradientBrush gb2 (Colours::black.withAlpha (0.0f), + gx1, gy1, + Colours::black.withAlpha (0.1f), + gx2, gy2, false); + + g.setBrush (&gb2); + g.fillPath (slotPath); + + g.setColour (thumbColour); + g.fillPath (thumbPath); + + GradientBrush gb3 (Colours::black.withAlpha (0.05f), + gx1, gy1, + Colours::black.withAlpha (0.0f), + gx2, gy2, false); + + g.saveState(); + g.setBrush (&gb3); + + if (isScrollbarVertical) + g.reduceClipRegion (x + width / 2, y, width, height); + else + g.reduceClipRegion (x, y + height / 2, width, height); + + g.fillPath (thumbPath); + g.restoreState(); + + g.setColour (Colours::black.withAlpha (0.3f)); + g.strokePath (thumbPath, PathStrokeType (0.4f)); } ImageEffectFilter* LookAndFeel::getScrollbarEffect() { - return &scrollbarShadow; + return 0; } int LookAndFeel::getMinimumScrollbarThumbSize (ScrollBar& scrollbar) @@ -729,9 +784,15 @@ void LookAndFeel::getIdealPopupMenuItemSize (const String& text, void LookAndFeel::drawPopupMenuBackground (Graphics& g, int width, int height) { - g.fillAll (findColour (PopupMenu::backgroundColourId)); + const Colour background (findColour (PopupMenu::backgroundColourId)); - g.setColour (Colours::black.withAlpha (0.6f)); + g.fillAll (background); + g.setColour (background.overlaidWith (Colours::lightblue.withAlpha (0.17f))); + + for (int i = 0; i < height; i += 3) + g.fillRect (0, i, width, 1); + + g.setColour (findColour (PopupMenu::textColourId).withAlpha (0.6f)); g.drawRect (0, 0, width, height); } @@ -880,10 +941,25 @@ int LookAndFeel::getMenuWindowFlags() return ComponentPeer::windowHasDropShadow; } -void LookAndFeel::drawMenuBarBackground (Graphics& g, int /*width*/, int /*height*/, +void LookAndFeel::drawMenuBarBackground (Graphics& g, int width, int height, bool, MenuBarComponent& menuBar) { - g.fillAll (menuBar.findColour (PopupMenu::backgroundColourId)); + const Colour baseColour (createBaseColour (menuBar.findColour (PopupMenu::backgroundColourId), false, false, false)); + + if (menuBar.isEnabled()) + { + drawShinyButtonShape (g, + -4.0f, 0.0f, + width + 8.0f, (float) height, + 0.0f, + baseColour, + 0.4f, + true, true, true, true); + } + else + { + g.fillAll (baseColour); + } } const Font LookAndFeel::getMenuBarFont (MenuBarComponent& menuBar, int /*itemIndex*/, const String& /*itemText*/) @@ -930,8 +1006,26 @@ void LookAndFeel::drawTextEditorOutline (Graphics& g, int width, int height, Tex { if (textEditor.isEnabled()) { - g.setColour (textEditor.findColour (TextEditor::outlineColourId)); - g.drawRect (0, 0, width, height); + if (textEditor.hasKeyboardFocus (true) && ! textEditor.isReadOnly()) + { + const int border = 2; + + g.setColour (textEditor.findColour (TextEditor::focusedOutlineColourId)); + g.drawRect (0, 0, width, height, border); + + g.setOpacity (1.0f); + const Colour shadowColour (textEditor.findColour (TextEditor::shadowColourId).withMultipliedAlpha (0.75f)); + g.drawBevel (0, 0, width, height + 2, border + 2, shadowColour, shadowColour); + } + else + { + g.setColour (textEditor.findColour (TextEditor::outlineColourId)); + g.drawRect (0, 0, width, height); + + g.setOpacity (1.0f); + const Colour shadowColour (textEditor.findColour (TextEditor::shadowColourId)); + g.drawBevel (0, 0, width, height + 2, 3, shadowColour, shadowColour); + } } } @@ -944,18 +1038,35 @@ void LookAndFeel::drawComboBox (Graphics& g, int width, int height, { g.fillAll (box.findColour (ComboBox::backgroundColourId)); - g.setColour (box.findColour ((isButtonDown) ? ComboBox::buttonColourId - : ComboBox::backgroundColourId)); - g.fillRect (buttonX, buttonY, buttonW, buttonH); + if (box.isEnabled() && box.hasKeyboardFocus (false)) + { + g.setColour (box.findColour (TextButton::buttonColourId)); + g.drawRect (0, 0, width, height, 2); + } + else + { + g.setColour (box.findColour (ComboBox::outlineColourId)); + g.drawRect (0, 0, width, height); + } - g.setColour (box.findColour (ComboBox::outlineColourId)); - g.drawRect (0, 0, width, height); + const float outlineThickness = box.isEnabled() ? (isButtonDown ? 1.2f : 0.5f) : 0.3f; - const float arrowX = 0.2f; - const float arrowH = 0.3f; + const Colour baseColour (createBaseColour (box.findColour (ComboBox::buttonColourId), + box.hasKeyboardFocus (true), + false, isButtonDown) + .withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.5f)); + + drawGlassLozenge (g, + buttonX + outlineThickness, buttonY + outlineThickness, + buttonW - outlineThickness * 2.0f, buttonH - outlineThickness * 2.0f, + baseColour, outlineThickness, -1.0f, + true, true, true, true); if (box.isEnabled()) { + const float arrowX = 0.3f; + const float arrowH = 0.2f; + Path p; p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.45f - arrowH), buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.45f, @@ -965,8 +1076,7 @@ void LookAndFeel::drawComboBox (Graphics& g, int width, int height, 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.setColour (Colours::black.withAlpha (0.6f)); g.fillPath (p); } } @@ -974,25 +1084,13 @@ void LookAndFeel::drawComboBox (Graphics& g, int width, int height, const Font LookAndFeel::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) -{ - 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 LookAndFeel::drawLinearSlider (Graphics& g, int x, int y, - int w, int h, + int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, @@ -1001,83 +1099,139 @@ void LookAndFeel::drawLinearSlider (Graphics& g, { g.fillAll (slider.findColour (Slider::backgroundColourId)); + const bool isMouseOver = slider.isMouseOverOrDragging() && slider.isEnabled(); + if (style == Slider::LinearBar) { - g.setColour (slider.findColour (Slider::thumbColourId)); - g.fillRect (x, y, (int) sliderPos - x, h); + Colour baseColour (createBaseColour (slider.findColour (Slider::thumbColourId) + .withMultipliedSaturation (slider.isEnabled() ? 1.0f : 0.5f), + false, + isMouseOver, isMouseOver || slider.isMouseButtonDown())); - g.setColour (slider.findColour (Slider::textBoxTextColourId).withMultipliedAlpha (0.5f)); - g.drawRect (x, y, (int) sliderPos - x, h); + drawShinyButtonShape (g, + (float) x, (float) y, sliderPos - (float) x, (float) height, 0.0f, + baseColour, + slider.isEnabled() ? 0.9f : 0.3f, + true, true, true, true); } else { - g.setColour (slider.findColour (Slider::trackColourId) - .withMultipliedAlpha (slider.isEnabled() ? 1.0f : 0.3f)); + const float sliderRadius = (float) getSliderThumbRadius (slider); + + const Colour trackColour (slider.findColour (Slider::trackColourId)); + const Colour gradCol1 (trackColour.overlaidWith (Colours::black.withAlpha (slider.isEnabled() ? 0.25f : 0.13f))); + const Colour gradCol2 (trackColour.overlaidWith (Colours::black.withAlpha (0.08f))); + Path indent; if (slider.isHorizontal()) { - g.fillRect (x, y + roundFloatToInt (h * 0.6f), - w, roundFloatToInt (h * 0.2f)); + const float iy = y + height * 0.5f - sliderRadius * 0.5f; + const float ih = sliderRadius; + + GradientBrush gb (gradCol1, 0.0f, iy, + gradCol2, 0.0f, iy + ih, false); + g.setBrush (&gb); + + indent.addRoundedRectangle (x - sliderRadius * 0.5f, iy, + width + sliderRadius, ih, + 5.0f); + g.fillPath (indent); } else { - g.fillRect (x + roundFloatToInt (w * 0.5f - jmin (3.0f, w * 0.1f)), y, - jmin (4, roundFloatToInt (w * 0.2f)), h); + const float ix = x + width * 0.5f - sliderRadius * 0.5f; + const float iw = sliderRadius; + + GradientBrush gb (gradCol1, ix, 0.0f, + gradCol2, ix + iw, 0.0f, false); + g.setBrush (&gb); + + indent.addRoundedRectangle (ix, y - sliderRadius * 0.5f, + iw, height + sliderRadius, + 5.0f); + g.fillPath (indent); } - float alpha = 0.35f; + g.setColour (Colours::black.withAlpha (0.3f)); + g.strokePath (indent, PathStrokeType (0.5f)); - if (slider.isEnabled()) - alpha = slider.isMouseOverOrDragging() ? 1.0f : 0.7f; + Colour knobColour (createBaseColour (slider.findColour (Slider::thumbColourId), + slider.hasKeyboardFocus (false) && slider.isEnabled(), + isMouseOver, + slider.isMouseButtonDown() && slider.isEnabled())); - const Colour fill (slider.findColour (Slider::thumbColourId).withAlpha (alpha)); - const Colour outline (Colours::black.withAlpha (slider.isEnabled() ? 0.7f : 0.35f)); + const float outlineThickness = slider.isEnabled() ? 0.8f : 0.3f; - if (style == Slider::TwoValueVertical || style == Slider::ThreeValueVertical) + if (style == Slider::LinearHorizontal || style == Slider::LinearVertical) { - 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); + float kx, ky; - 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); + if (style == Slider::LinearVertical) + { + kx = x + width * 0.5f; + ky = sliderPos; + } + else + { + kx = sliderPos; + ky = y + height * 0.5f; + } + + drawGlassSphere (g, + kx - sliderRadius, + ky - sliderRadius, + sliderRadius * 2.0f, + knobColour, outlineThickness); } - else if (style == Slider::TwoValueHorizontal || style == Slider::ThreeValueHorizontal) + else { - 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); + if (style == Slider::ThreeValueVertical) + { + drawGlassSphere (g, x + width * 0.5f - sliderRadius, + sliderPos - sliderRadius, + sliderRadius * 2.0f, + knobColour, outlineThickness); + } + else if (style == Slider::ThreeValueHorizontal) + { + drawGlassSphere (g,sliderPos - sliderRadius, + y + height * 0.5f - sliderRadius, + sliderRadius * 2.0f, + knobColour, outlineThickness); + } - 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::TwoValueVertical || style == Slider::ThreeValueVertical) + { + const float sr = jmin (sliderRadius, width * 0.4f); - 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); + drawGlassPointer (g, jmax (0.0f, x + width * 0.5f - sliderRadius * 2.0f), + minSliderPos - sliderRadius, + sliderRadius * 2.0f, knobColour, outlineThickness, 1); + + drawGlassPointer (g, jmin (x + width - sliderRadius * 2.0f, x + width * 0.5f), maxSliderPos - sr, + sliderRadius * 2.0f, knobColour, outlineThickness, 3); + } + else if (style == Slider::TwoValueHorizontal || style == Slider::ThreeValueHorizontal) + { + const float sr = jmin (sliderRadius, height * 0.4f); + + drawGlassPointer (g, minSliderPos - sr, + jmax (0.0f, y + height * 0.5f - sliderRadius * 2.0f), + sliderRadius * 2.0f, knobColour, outlineThickness, 2); + + drawGlassPointer (g, maxSliderPos - sliderRadius, + jmin (y + height - sliderRadius * 2.0f, y + height * 0.5f), + sliderRadius * 2.0f, knobColour, outlineThickness, 4); + } } } } -int LookAndFeel::getSliderThumbRadius (Slider&) +int LookAndFeel::getSliderThumbRadius (Slider& slider) { - return 8; + return jmin (7, + slider.getHeight() / 2, + slider.getWidth() / 2); } void LookAndFeel::drawRotarySlider (Graphics& g, @@ -1106,21 +1260,23 @@ void LookAndFeel::drawRotarySlider (Graphics& g, const float thickness = 0.7f; - Path filledArc; - filledArc.addPieSegment (rx, ry, rw, rw, - rotaryStartAngle, - angle, - thickness); + { + Path filledArc; + filledArc.addPieSegment (rx, ry, rw, rw, + rotaryStartAngle, + angle, + thickness); - g.fillPath (filledArc); + g.fillPath (filledArc); + } if (thickness > 0) { const float innerRadius = radius * 0.2f; Path p; p.addTriangle (-innerRadius, 0.0f, - 0.0f, -radius * thickness * 1.1f, - innerRadius, 0.0f); + 0.0f, -radius * thickness * 1.1f, + innerRadius, 0.0f); p.addEllipse (-innerRadius, -innerRadius, innerRadius * 2.0f, innerRadius * 2.0f); @@ -1139,27 +1295,24 @@ void LookAndFeel::drawRotarySlider (Graphics& g, } else { + if (slider.isEnabled()) + g.setColour (slider.findColour (Slider::rotarySliderFillColourId).withAlpha (isMouseOver ? 1.0f : 0.7f)); + else + g.setColour (Colours::grey.withAlpha (0.5f)); + Path p; p.addEllipse (-0.4f * rw, -0.4f * rw, rw * 0.8f, rw * 0.8f); PathStrokeType (rw * 0.1f).createStrokedPath (p, p); p.addLineSegment (0.0f, 0.0f, 0.0f, -radius, rw * 0.2f); - if (slider.isEnabled()) - g.setColour (slider.findColour (Slider::rotarySliderFillColourId).withAlpha (isMouseOver ? 1.0f : 0.7f)); - else - g.setColour (Colours::grey.withAlpha (0.5f)); - g.fillPath (p, AffineTransform::rotation (angle).translated (centreX, centreY)); } } Button* LookAndFeel::createSliderButton (const bool isIncrement) { - if (isIncrement) - return new ArrowButton (T("u"), 0.75f, Colours::white.withAlpha (0.8f)); - else - return new ArrowButton (T("d"), 0.25f, Colours::white.withAlpha (0.8f)); + return new TextButton (isIncrement ? "+" : "-", String::empty); } Label* LookAndFeel::createSliderTextBox (Slider& slider) @@ -1188,16 +1341,16 @@ Label* LookAndFeel::createSliderTextBox (Slider& slider) ImageEffectFilter* LookAndFeel::getSliderEffect() { - return &scrollbarShadow; + return 0; } //============================================================================== -static const TextLayout layoutTooltipText (const String& text) +static const TextLayout layoutTooltipText (const String& text) throw() { const float tooltipFontSize = 15.0f; const int maxToolTipWidth = 400; - Font f (tooltipFontSize, Font::bold); + const Font f (tooltipFontSize, Font::bold); TextLayout tl (text, f); tl.layout (maxToolTipWidth, Justification::left, true); @@ -1252,21 +1405,28 @@ void LookAndFeel::layoutFilenameComponent (FilenameComponent& filenameComp, //============================================================================== void LookAndFeel::drawCornerResizer (Graphics& g, int w, int h, - bool isMouseOver, - bool isMouseDragging) + bool /*isMouseOver*/, + bool /*isMouseDragging*/) { - g.setColour ((isMouseOver || isMouseDragging) ? Colours::lightgrey - : Colours::darkgrey); - - const float lineThickness = jmin (w, h) * 0.1f; + const float lineThickness = jmin (w, h) * 0.075f; for (float i = 0.0f; i < 1.0f; i += 0.3f) { + g.setColour (Colours::lightgrey); + g.drawLine (w * i, h + 1.0f, w + 1.0f, h * i, lineThickness); + + g.setColour (Colours::darkgrey); + + g.drawLine (w * i + lineThickness, + h + 1.0f, + w + 1.0f, + h * i + lineThickness, + lineThickness); } } @@ -1336,46 +1496,115 @@ void LookAndFeel::drawDocumentWindowTitleBar (DocumentWindow& window, g.drawText (window.getName(), textX, 0, textW, h, Justification::centredLeft, true); } +//============================================================================== +class GlassWindowButton : public Button +{ +public: + //============================================================================== + GlassWindowButton (const String& name, const Colour& col, + const Path& normalShape_, + const Path& toggledShape_) + : Button (name), + colour (col), + normalShape (normalShape_), + toggledShape (toggledShape_) + { + } + + ~GlassWindowButton() + { + } + + //============================================================================== + void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) + { + float alpha = isMouseOverButton ? (isButtonDown ? 1.0f : 0.8f) : 0.55f; + + if (! isEnabled()) + alpha *= 0.5f; + + float x = 0, y = 0, diam; + + if (getWidth() < getHeight()) + { + diam = (float) getWidth(); + y = (getHeight() - getWidth()) * 0.5f; + } + else + { + diam = (float) getHeight(); + y = (getWidth() - getHeight()) * 0.5f; + } + + x += diam * 0.05f; + y += diam * 0.05f; + diam *= 0.9f; + + GradientBrush gb1 (Colour::greyLevel (0.9f).withAlpha (alpha), 0, y + diam, + Colour::greyLevel (0.6f).withAlpha (alpha), 0, y, false); + + g.setBrush (&gb1); + g.fillEllipse (x, y, diam, diam); + + x += 2.0f; + y += 2.0f; + diam -= 4.0f; + + LookAndFeel::drawGlassSphere (g, x, y, diam, colour.withAlpha (alpha), 1.0f); + + Path& p = getToggleState() ? toggledShape : normalShape; + + const AffineTransform t (p.getTransformToScaleToFit (x + diam * 0.3f, y + diam * 0.3f, + diam * 0.4f, diam * 0.4f, true)); + + g.setColour (Colours::black.withAlpha (alpha * 0.6f)); + g.fillPath (p, t); + } + + //============================================================================== + juce_UseDebuggingNewOperator + +private: + Colour colour; + Path normalShape, toggledShape; + + GlassWindowButton (const GlassWindowButton&); + const GlassWindowButton& operator= (const GlassWindowButton&); +}; Button* LookAndFeel::createDocumentWindowButton (int buttonType) { Path shape; + const float crossThickness = 0.25f; 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); + shape.addLineSegment (0.0f, 0.0f, 1.0f, 1.0f, crossThickness * 1.4f); + shape.addLineSegment (1.0f, 0.0f, 0.0f, 1.0f, crossThickness * 1.4f); - ShapeButton* const b = new ShapeButton ("close", - Colour (0x7fff3333), - Colour (0xd7ff3333), - Colour (0xf7ff3333)); - - b->setShape (shape, true, true, true); - return b; + return new GlassWindowButton ("close", Colour (0xffdd1100), shape, shape); } else if (buttonType == DocumentWindow::minimiseButton) { - shape.addLineSegment (0.0f, 0.5f, 1.0f, 0.5f, 0.25f); + shape.addLineSegment (0.0f, 0.5f, 1.0f, 0.5f, crossThickness); - DrawableButton* b = new DrawableButton ("minimise", DrawableButton::ImageFitted); - DrawablePath dp; - dp.setPath (shape); - dp.setSolidFill (Colours::black.withAlpha (0.3f)); - b->setImages (&dp); - return b; + return new GlassWindowButton ("minimise", Colour (0xffaa8811), shape, shape); } 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); + shape.addLineSegment (0.5f, 0.0f, 0.5f, 1.0f, crossThickness); + shape.addLineSegment (0.0f, 0.5f, 1.0f, 0.5f, crossThickness); - DrawableButton* b = new DrawableButton ("maximise", DrawableButton::ImageFitted); - DrawablePath dp; - dp.setPath (shape); - dp.setSolidFill (Colours::black.withAlpha (0.3f)); - b->setImages (&dp); - return b; + Path fullscreenShape; + fullscreenShape.startNewSubPath (45.0f, 100.0f); + fullscreenShape.lineTo (0.0f, 100.0f); + fullscreenShape.lineTo (0.0f, 0.0f); + fullscreenShape.lineTo (100.0f, 0.0f); + fullscreenShape.lineTo (100.0f, 45.0f); + fullscreenShape.addRectangle (45.0f, 45.0f, 100.0f, 100.0f); + PathStrokeType (30.0f).createStrokedPath (fullscreenShape, fullscreenShape); + + return new GlassWindowButton ("maximise", Colour (0xff119911), shape, fullscreenShape); } jassertfalse @@ -1392,19 +1621,15 @@ void LookAndFeel::positionDocumentWindowButtons (DocumentWindow&, Button* closeButton, bool positionTitleBarButtonsOnLeft) { - titleBarY += titleBarH / 8; - titleBarH -= titleBarH / 4; - - const int buttonW = titleBarH; + const int buttonW = titleBarH - titleBarH / 8; int x = positionTitleBarButtonsOnLeft ? titleBarX + 4 - : titleBarX + titleBarW - buttonW - 4; + : titleBarX + titleBarW - buttonW - buttonW / 4; if (closeButton != 0) { closeButton->setBounds (x, titleBarY, buttonW, titleBarH); - x += positionTitleBarButtonsOnLeft ? buttonW + buttonW / 5 - : -(buttonW + buttonW / 5); + x += positionTitleBarButtonsOnLeft ? buttonW : -(buttonW + buttonW / 4); } if (positionTitleBarButtonsOnLeft) @@ -1412,12 +1637,12 @@ void LookAndFeel::positionDocumentWindowButtons (DocumentWindow&, if (maximiseButton != 0) { - maximiseButton->setBounds (x, titleBarY - 2, buttonW, titleBarH); + maximiseButton->setBounds (x, titleBarY, buttonW, titleBarH); x += positionTitleBarButtonsOnLeft ? buttonW : -buttonW; } if (minimiseButton != 0) - minimiseButton->setBounds (x, titleBarY - 2, buttonW, titleBarH); + minimiseButton->setBounds (x, titleBarY, buttonW, titleBarH); } int LookAndFeel::getDefaultMenuBarHeight() @@ -2165,5 +2390,290 @@ Image* LookAndFeel::getDefaultDocumentFileImage() return ImageCache::getFromMemory (fileicon_png, sizeof (fileicon_png)); } +//============================================================================== +static void createRoundedPath (Path& p, + const float x, const float y, + const float w, const float h, + const float cs, + const bool curveTopLeft, const bool curveTopRight, + const bool curveBottomLeft, const bool curveBottomRight) throw() +{ + const float cs2 = 2.0f * cs; + + if (curveTopLeft) + { + p.startNewSubPath (x, y + cs); + p.addArc (x, y, cs2, cs2, float_Pi * 1.5f, float_Pi * 2.0f); + } + else + { + p.startNewSubPath (x, y); + } + + if (curveTopRight) + { + p.lineTo (x + w - cs, y); + p.addArc (x + w - cs2, y, cs2, cs2, 0.0f, float_Pi * 0.5f); + } + else + { + p.lineTo (x + w, y); + } + + if (curveBottomRight) + { + p.lineTo (x + w, y + h - cs); + p.addArc (x + w - cs2, y + h - cs2, cs2, cs2, float_Pi * 0.5f, float_Pi); + } + else + { + p.lineTo (x + w, y + h); + } + + if (curveBottomLeft) + { + p.lineTo (x + cs, y + h); + p.addArc (x, y + h - cs2, cs2, cs2, float_Pi, float_Pi * 1.5f); + } + else + { + p.lineTo (x, y + h); + } + + p.closeSubPath(); +} + +//============================================================================== +void LookAndFeel::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() +{ + if (w <= strokeWidth * 1.1f || h <= strokeWidth * 1.1f) + return; + + const float cs = jmin (maxCornerSize, w * 0.5f, h * 0.5f); + + Path outline; + createRoundedPath (outline, x, y, w, h, cs, + ! (flatOnLeft || flatOnTop), + ! (flatOnRight || flatOnTop), + ! (flatOnLeft || flatOnBottom), + ! (flatOnRight || flatOnBottom)); + + ColourGradient cg (baseColour, 0.0f, y, + baseColour.overlaidWith (Colours::blue.withAlpha (0.03f)), 0.0f, y + h, + false); + + cg.addColour (0.5, baseColour.overlaidWith (Colours::white.withAlpha (0.2f))); + cg.addColour (0.51, baseColour.overlaidWith (Colours::blue.withAlpha (0.07f))); + + GradientBrush gb (cg); + g.setBrush (&gb); + g.fillPath (outline); + + g.setColour (Colours::black.withAlpha (0.5f)); + g.strokePath (outline, PathStrokeType (strokeWidth)); +} + +//============================================================================== +void LookAndFeel::drawGlassSphere (Graphics& g, + float x, float y, float diameter, + const Colour& colour, + const float outlineThickness) throw() +{ + if (diameter <= outlineThickness) + return; + + Path p; + p.addEllipse (x, y, diameter, diameter); + + { + ColourGradient cg (Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y, + Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y + diameter, false); + + cg.addColour (0.4, Colours::white.overlaidWith (colour)); + + GradientBrush gb (cg); + g.setBrush (&gb); + g.fillPath (p); + } + + { + GradientBrush gb (Colours::white, 0, y + diameter * 0.06f, + Colours::transparentWhite, 0, y + diameter * 0.3f, false); + + g.setBrush (&gb); + g.fillEllipse (x + diameter * 0.2f, y + diameter * 0.05f, diameter * 0.6f, diameter * 0.4f); + } + + { + ColourGradient cg (Colours::transparentBlack, + x + diameter * 0.5f, y + diameter * 0.5f, + Colours::black.withAlpha (0.5f * outlineThickness * colour.getFloatAlpha()), + x, y + diameter * 0.5f, true); + + cg.addColour (0.7, Colours::transparentBlack); + cg.addColour (0.8, Colours::black.withAlpha (0.1f * outlineThickness)); + + GradientBrush gb (cg); + g.setBrush (&gb); + g.fillPath (p); + } + + g.setColour (Colours::black.withAlpha (0.5f * colour.getFloatAlpha())); + g.drawEllipse (x, y, diameter, diameter, outlineThickness); +} + +//============================================================================== +void LookAndFeel::drawGlassPointer (Graphics& g, float x, float y, float diameter, + const Colour& colour, const float outlineThickness, + const int direction) throw() +{ + if (diameter <= outlineThickness) + return; + + Path p; + p.startNewSubPath (x + diameter * 0.5f, y); + p.lineTo (x + diameter, y + diameter * 0.6f); + p.lineTo (x + diameter, y + diameter); + p.lineTo (x, y + diameter); + p.lineTo (x, y + diameter * 0.6f); + p.closeSubPath(); + + p.applyTransform (AffineTransform::rotation (direction * (float_Pi * 0.5f), x + diameter * 0.5f, y + diameter * 0.5f)); + + { + ColourGradient cg (Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y, + Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y + diameter, false); + + cg.addColour (0.4, Colours::white.overlaidWith (colour)); + + GradientBrush gb (cg); + g.setBrush (&gb); + g.fillPath (p); + } + + { + ColourGradient cg (Colours::transparentBlack, + x + diameter * 0.5f, y + diameter * 0.5f, + Colours::black.withAlpha (0.5f * outlineThickness * colour.getFloatAlpha()), + x - diameter * 0.2f, y + diameter * 0.5f, true); + + cg.addColour (0.5, Colours::transparentBlack); + cg.addColour (0.7, Colours::black.withAlpha (0.07f * outlineThickness)); + + GradientBrush gb (cg); + g.setBrush (&gb); + g.fillPath (p); + } + + g.setColour (Colours::black.withAlpha (0.5f * colour.getFloatAlpha())); + g.strokePath (p, PathStrokeType (outlineThickness)); +} + +//============================================================================== +void LookAndFeel::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() +{ + if (width <= outlineThickness || height <= outlineThickness) + return; + + const int intX = (int) x; + const int intY = (int) y; + const int intW = (int) width; + const int intH = (int) height; + + const float cs = cornerSize < 0 ? jmin (width * 0.5f, height * 0.5f) : cornerSize; + const float edgeBlurRadius = height * 0.75f + (height - cs * 2.0f); + const int intEdge = (int) edgeBlurRadius; + + Path outline; + createRoundedPath (outline, x, y, width, height, cs, + ! (flatOnLeft || flatOnTop), + ! (flatOnRight || flatOnTop), + ! (flatOnLeft || flatOnBottom), + ! (flatOnRight || flatOnBottom)); + + { + ColourGradient cg (colour.darker (0.2f), 0, y, + colour.darker (0.2f), 0, y + height, false); + + cg.addColour (0.03, colour.withMultipliedAlpha (0.3f)); + cg.addColour (0.4, colour); + cg.addColour (0.97, colour.withMultipliedAlpha (0.3f)); + + GradientBrush gb (cg); + g.setBrush (&gb); + g.fillPath (outline); + } + + ColourGradient cg (Colours::transparentBlack, x + edgeBlurRadius, y + height * 0.5f, + colour.darker (0.2f), x, y + height * 0.5f, true); + + cg.addColour (jlimit (0.0, 1.0, 1.0 - (cs * 0.5f) / edgeBlurRadius), Colours::transparentBlack); + cg.addColour (jlimit (0.0, 1.0, 1.0 - (cs * 0.25f) / edgeBlurRadius), colour.darker (0.2f).withMultipliedAlpha (0.3f)); + + if (! (flatOnLeft || flatOnTop || flatOnBottom)) + { + GradientBrush gb (cg); + + g.saveState(); + g.setBrush (&gb); + g.reduceClipRegion (intX, intY, intEdge, intH); + g.fillPath (outline); + g.restoreState(); + } + + if (! (flatOnRight || flatOnTop || flatOnBottom)) + { + cg.x1 = x + width - edgeBlurRadius; + cg.x2 = x + width; + GradientBrush gb (cg); + + g.saveState(); + g.setBrush (&gb); + g.reduceClipRegion (intX + intW - intEdge, intY, 2 + intEdge, intH); + g.fillPath (outline); + g.restoreState(); + } + + { + const float leftIndent = flatOnLeft ? 0.0f : cs * 0.4f; + const float rightIndent = flatOnRight ? 0.0f : cs * 0.4f; + + Path highlight; + createRoundedPath (highlight, + x + leftIndent, + y + cs * 0.1f, + width - (leftIndent + rightIndent), + height * 0.4f, cs * 0.4f, + ! (flatOnLeft || flatOnTop), + ! (flatOnRight || flatOnTop), + ! (flatOnLeft || flatOnBottom), + ! (flatOnRight || flatOnBottom)); + + GradientBrush gb (colour.brighter (10.0f), 0, y + height * 0.06f, + Colours::transparentWhite, 0, y + height * 0.4f, false); + + g.setBrush (&gb); + g.fillPath (highlight); + } + + g.setColour (colour.darker().withMultipliedAlpha (1.5f)); + g.strokePath (outline, PathStrokeType (outlineThickness)); +} END_JUCE_NAMESPACE diff --git a/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h b/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h index 8f529a1802..cfa39a8544 100644 --- a/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h +++ b/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h @@ -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 colourIds; Array 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(); }; diff --git a/src/juce_appframework/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.cpp b/src/juce_appframework/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.cpp new file mode 100644 index 0000000000..234d7a3c99 --- /dev/null +++ b/src/juce_appframework/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.cpp @@ -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 diff --git a/src/juce_appframework/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.h b/src/juce_appframework/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.h new file mode 100644 index 0000000000..469933ae7b --- /dev/null +++ b/src/juce_appframework/gui/components/lookandfeel/juce_OldSchoolLookAndFeel.h @@ -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__ diff --git a/src/juce_appframework/gui/components/lookandfeel/juce_ShinyLookAndFeel.cpp b/src/juce_appframework/gui/components/lookandfeel/juce_ShinyLookAndFeel.cpp deleted file mode 100644 index df700c10f7..0000000000 --- a/src/juce_appframework/gui/components/lookandfeel/juce_ShinyLookAndFeel.cpp +++ /dev/null @@ -1,1085 +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. - - ============================================================================== -*/ - -#include "../../../../juce_core/basics/juce_StandardHeader.h" - -BEGIN_JUCE_NAMESPACE - -#include "juce_ShinyLookAndFeel.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 "../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 "../../../../juce_core/text/juce_LocalisedStrings.h" - - -//============================================================================== -static const Colour createBaseColour (const Colour& buttonColour, - const bool hasKeyboardFocus, - const bool isMouseOverButton, - const bool isButtonDown) -{ - float sat = hasKeyboardFocus ? 1.3f : 0.9f; - - Colour baseColour (buttonColour.withMultipliedSaturation (sat)); - - if (isButtonDown) - return baseColour.contrasting (0.2f); - else if (isMouseOverButton) - return baseColour.contrasting (0.1f); - - return baseColour; -} - - -//============================================================================== -ShinyLookAndFeel::ShinyLookAndFeel() -{ - setColour (ComboBox::buttonColourId, Colour (0xffbbbbff)); - setColour (ComboBox::outlineColourId, Colours::grey.withAlpha (0.7f)); - - setColour (ListBox::outlineColourId, findColour (ComboBox::outlineColourId)); - - setColour (ScrollBar::backgroundColourId, Colours::transparentBlack); - setColour (ScrollBar::thumbColourId, Colours::white); - - setColour (Slider::thumbColourId, findColour (TextButton::buttonColourId)); - setColour (Slider::trackColourId, Colour (0x7fffffff)); - setColour (Slider::textBoxOutlineColourId, findColour (ComboBox::outlineColourId)); - - setColour (ProgressBar::backgroundColourId, Colours::white); - setColour (ProgressBar::foregroundColourId, Colour (0xffaaaaee)); - - setColour (PopupMenu::backgroundColourId, Colours::white); - setColour (PopupMenu::highlightedTextColourId, Colours::white); - setColour (PopupMenu::highlightedBackgroundColourId, Colour (0x991111aa)); - - setColour (TextEditor::focusedOutlineColourId, findColour (TextButton::buttonColourId)); -} - -ShinyLookAndFeel::~ShinyLookAndFeel() -{ -} - -//============================================================================== -void ShinyLookAndFeel::drawTextEditorOutline (Graphics& g, int width, int height, TextEditor& textEditor) -{ - if (textEditor.isEnabled()) - { - if (textEditor.hasKeyboardFocus (true) && ! textEditor.isReadOnly()) - { - const int border = 2; - - g.setColour (textEditor.findColour (TextEditor::focusedOutlineColourId)); - g.drawRect (0, 0, width, height, border); - - g.setOpacity (1.0f); - const Colour shadowColour (textEditor.findColour (TextEditor::shadowColourId).withMultipliedAlpha (0.75f)); - g.drawBevel (0, 0, width, height + 2, border + 2, shadowColour, shadowColour); - } - else - { - g.setColour (textEditor.findColour (TextEditor::outlineColourId)); - g.drawRect (0, 0, width, height); - - g.setOpacity (1.0f); - const Colour shadowColour (textEditor.findColour (TextEditor::shadowColourId)); - g.drawBevel (0, 0, width, height + 2, 3, shadowColour, shadowColour); - } - } -} - -//============================================================================== -void ShinyLookAndFeel::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)); - - if (box.isEnabled() && box.hasKeyboardFocus (false)) - { - g.setColour (box.findColour (TextButton::buttonColourId)); - g.drawRect (0, 0, width, height, 2); - } - else - { - g.setColour (box.findColour (ComboBox::outlineColourId)); - g.drawRect (0, 0, width, height); - } - - const float outlineThickness = box.isEnabled() ? (isButtonDown ? 1.2f : 0.5f) : 0.3f; - - const Colour baseColour (createBaseColour (box.findColour (ComboBox::buttonColourId), - box.hasKeyboardFocus (true), - false, isButtonDown) - .withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.5f)); - - drawGlassLozenge (g, - buttonX + outlineThickness, buttonY + outlineThickness, - buttonW - outlineThickness * 2.0f, buttonH - outlineThickness * 2.0f, - baseColour, outlineThickness, -1.0f, - true, true, true, true); - - if (box.isEnabled()) - { - const float arrowX = 0.3f; - const float arrowH = 0.2f; - - 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 (Colours::black.withAlpha (0.6f)); - g.fillPath (p); - } -} - -const Font ShinyLookAndFeel::getComboBoxFont (ComboBox& box) -{ - Font f (jmin (15.0f, box.getHeight() * 0.85f)); - return f; -} - - -//============================================================================== -void ShinyLookAndFeel::drawScrollbarButton (Graphics& g, - ScrollBar& scrollbar, - int width, int height, - int buttonDirection, - bool /*isScrollbarVertical*/, - bool /*isMouseOverButton*/, - bool isButtonDown) -{ - 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 (scrollbar.findColour (ScrollBar::thumbColourId).contrasting (0.2f)); - else - g.setColour (scrollbar.findColour (ScrollBar::thumbColourId)); - - g.fillPath (p); - - g.setColour (Colours::black.withAlpha (0.5f)); - g.strokePath (p, PathStrokeType (0.5f)); -} - -void ShinyLookAndFeel::drawScrollbar (Graphics& g, - ScrollBar& scrollbar, - int x, int y, - int width, int height, - bool isScrollbarVertical, - int thumbStartPosition, - int thumbSize, - bool /*isMouseOver*/, - bool /*isMouseDown*/) -{ - g.fillAll (scrollbar.findColour (ScrollBar::backgroundColourId)); - - Path slotPath, thumbPath; - - const float slotIndent = jmin (width, height) > 15 ? 1.0f : 0.0f; - const float thumbIndent = slotIndent + 1.0f; - - float gx1 = 0.0f, gy1 = 0.0f, gx2 = 0.0f, gy2 = 0.0f; - - if (isScrollbarVertical) - { - slotPath.addRoundedRectangle (x + slotIndent, - y + slotIndent, - width - slotIndent * 2.0f, - height - slotIndent * 2.0f, - (width - slotIndent * 2.0f) * 0.5f); - - if (thumbSize > 0) - thumbPath.addRoundedRectangle (x + thumbIndent, - thumbStartPosition + thumbIndent, - width - thumbIndent * 2.0f, - thumbSize - thumbIndent * 2.0f, - (width - thumbIndent * 2.0f) * 0.5f); - gx1 = (float) x; - gx2 = x + width * 0.7f; - } - else - { - slotPath.addRoundedRectangle (x + slotIndent, - y + slotIndent, - width - slotIndent * 2.0f, - height - slotIndent * 2.0f, - (height - slotIndent * 2.0f) * 0.5f); - - if (thumbSize > 0) - thumbPath.addRoundedRectangle (thumbStartPosition + thumbIndent, - y + thumbIndent, - thumbSize - thumbIndent * 2.0f, - height - thumbIndent * 2.0f, - (height - thumbIndent * 2.0f) * 0.5f); - gy1 = (float) y; - gy2 = y + height * 0.7f; - } - - const Colour thumbColour (scrollbar.findColour (ScrollBar::thumbColourId)); - - GradientBrush gb (thumbColour.overlaidWith (Colours::black.withAlpha (0.27f)), - gx1, gy1, - thumbColour.overlaidWith (Colours::black.withAlpha (0.1f)), - gx2, gy2, false); - - g.setBrush (&gb); - g.fillPath (slotPath); - - if (isScrollbarVertical) - { - gx1 = x + width * 0.6f; - gx2 = (float) x + width; - } - else - { - gy1 = y + height * 0.6f; - gy2 = (float) y + height; - } - - GradientBrush gb2 (Colours::black.withAlpha (0.0f), - gx1, gy1, - Colours::black.withAlpha (0.1f), - gx2, gy2, false); - - g.setBrush (&gb2); - g.fillPath (slotPath); - - g.setColour (thumbColour); - g.fillPath (thumbPath); - - GradientBrush gb3 (Colours::black.withAlpha (0.05f), - gx1, gy1, - Colours::black.withAlpha (0.0f), - gx2, gy2, false); - - g.saveState(); - g.setBrush (&gb3); - - if (isScrollbarVertical) - g.reduceClipRegion (x + width / 2, y, width, height); - else - g.reduceClipRegion (x, y + height / 2, width, height); - - g.fillPath (thumbPath); - g.restoreState(); - - g.setColour (Colours::black.withAlpha (0.3f)); - g.strokePath (thumbPath, PathStrokeType (0.4f)); -} - -ImageEffectFilter* ShinyLookAndFeel::getScrollbarEffect() -{ - return 0; -} - -//============================================================================== -void ShinyLookAndFeel::drawButtonBackground (Graphics& g, - Button& button, - const Colour& backgroundColour, - bool isMouseOverButton, - bool isButtonDown) -{ - 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 indentL = button.isConnectedOnLeft() ? 0.1f : outlineThickness * 0.5f; - const float indentR = button.isConnectedOnRight() ? 0.1f : outlineThickness * 0.5f; - const float indentT = button.isConnectedOnTop() ? 0.1f : outlineThickness * 0.5f; - const float indentB = button.isConnectedOnBottom() ? 0.1f : outlineThickness * 0.5f; - - const Colour baseColour (createBaseColour (backgroundColour, - button.hasKeyboardFocus (true), - isMouseOverButton, isButtonDown) - .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f)); - - drawGlassLozenge (g, - indentL, - indentT, - width - indentL - indentR, - height - indentT - indentB, - baseColour, outlineThickness, -1.0f, - button.isConnectedOnLeft(), - button.isConnectedOnRight(), - button.isConnectedOnTop(), - button.isConnectedOnBottom()); -} - -//============================================================================== -void ShinyLookAndFeel::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) -{ - const float boxSize = w * 0.7f; - - drawGlassSphere (g, (float) x, y + (h - boxSize) * 0.5f, boxSize, - createBaseColour (component.findColour (TextButton::buttonColourId) - .withMultipliedAlpha (isEnabled ? 1.0f : 0.5f), - true, - isMouseOverButton, - isButtonDown), - isEnabled ? ((isButtonDown || isMouseOverButton) ? 1.1f : 0.5f) : 0.3f); - - 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); - - AffineTransform trans (AffineTransform::scale (w / 9.0f, h / 9.0f) - .translated ((float) x, (float) y)); - - g.strokePath (tick, PathStrokeType (2.5f), trans); - } -} - -//============================================================================== -int ShinyLookAndFeel::getSliderThumbRadius (Slider& slider) -{ - return jmin (7, - slider.getHeight() / 2, - slider.getWidth() / 2); -} - -void ShinyLookAndFeel::drawLinearSlider (Graphics& g, - int x, int y, - int width, int height, - float sliderPos, - float minSliderPos, - float maxSliderPos, - const Slider::SliderStyle style, - Slider& slider) -{ - g.fillAll (slider.findColour (Slider::backgroundColourId)); - - const bool isMouseOver = slider.isMouseOverOrDragging() && slider.isEnabled(); - - if (style == Slider::LinearBar) - { - Colour baseColour (createBaseColour (slider.findColour (Slider::thumbColourId) - .withMultipliedSaturation (slider.isEnabled() ? 1.0f : 0.5f), - false, - isMouseOver, isMouseOver || slider.isMouseButtonDown())); - - drawShinyButtonShape (g, - (float) x, (float) y, sliderPos - (float) x, (float) height, 0.0f, - baseColour, - slider.isEnabled() ? 0.9f : 0.3f, - true, true, true, true); - } - else - { - const float sliderRadius = (float) getSliderThumbRadius (slider); - - const Colour trackColour (slider.findColour (Slider::trackColourId)); - const Colour gradCol1 (trackColour.overlaidWith (Colours::black.withAlpha (slider.isEnabled() ? 0.25f : 0.13f))); - const Colour gradCol2 (trackColour.overlaidWith (Colours::black.withAlpha (0.08f))); - Path indent; - - if (slider.isHorizontal()) - { - const float iy = y + height * 0.5f - sliderRadius * 0.5f; - const float ih = sliderRadius; - - GradientBrush gb (gradCol1, 0.0f, iy, - gradCol2, 0.0f, iy + ih, false); - g.setBrush (&gb); - - indent.addRoundedRectangle (x - sliderRadius * 0.5f, iy, - width + sliderRadius, ih, - 5.0f); - g.fillPath (indent); - } - else - { - const float ix = x + width * 0.5f - sliderRadius * 0.5f; - const float iw = sliderRadius; - - GradientBrush gb (gradCol1, ix, 0.0f, - gradCol2, ix + iw, 0.0f, false); - g.setBrush (&gb); - - indent.addRoundedRectangle (ix, y - sliderRadius * 0.5f, - iw, height + sliderRadius, - 5.0f); - g.fillPath (indent); - } - - g.setColour (Colours::black.withAlpha (0.3f)); - g.strokePath (indent, PathStrokeType (0.5f)); - - Colour knobColour (createBaseColour (slider.findColour (Slider::thumbColourId), - slider.hasKeyboardFocus (false) && slider.isEnabled(), - isMouseOver, - slider.isMouseButtonDown() && slider.isEnabled())); - - const float outlineThickness = slider.isEnabled() ? 0.8f : 0.3f; - - if (style == Slider::LinearHorizontal || style == Slider::LinearVertical) - { - float kx, ky; - - if (style == Slider::LinearVertical) - { - kx = x + width * 0.5f; - ky = sliderPos; - } - else - { - kx = sliderPos; - ky = y + height * 0.5f; - } - - drawGlassSphere (g, - kx - sliderRadius, - ky - sliderRadius, - sliderRadius * 2.0f, - knobColour, outlineThickness); - } - else - { - if (style == Slider::ThreeValueVertical) - { - drawGlassSphere (g, x + width * 0.5f - sliderRadius, - sliderPos - sliderRadius, - sliderRadius * 2.0f, - knobColour, outlineThickness); - } - else if (style == Slider::ThreeValueHorizontal) - { - drawGlassSphere (g,sliderPos - sliderRadius, - y + height * 0.5f - sliderRadius, - sliderRadius * 2.0f, - knobColour, outlineThickness); - } - - if (style == Slider::TwoValueVertical || style == Slider::ThreeValueVertical) - { - const float sr = jmin (sliderRadius, width * 0.4f); - - drawGlassPointer (g, jmax (0.0f, x + width * 0.5f - sliderRadius * 2.0f), - minSliderPos - sliderRadius, - sliderRadius * 2.0f, knobColour, outlineThickness, 1); - - drawGlassPointer (g, jmin (x + width - sliderRadius * 2.0f, x + width * 0.5f), maxSliderPos - sr, - sliderRadius * 2.0f, knobColour, outlineThickness, 3); - } - else if (style == Slider::TwoValueHorizontal || style == Slider::ThreeValueHorizontal) - { - const float sr = jmin (sliderRadius, height * 0.4f); - - drawGlassPointer (g, minSliderPos - sr, - jmax (0.0f, y + height * 0.5f - sliderRadius * 2.0f), - sliderRadius * 2.0f, knobColour, outlineThickness, 2); - - drawGlassPointer (g, maxSliderPos - sliderRadius, - jmin (y + height - sliderRadius * 2.0f, y + height * 0.5f), - sliderRadius * 2.0f, knobColour, outlineThickness, 4); - } - } - } -} - -Button* ShinyLookAndFeel::createSliderButton (const bool isIncrement) -{ - return new TextButton (isIncrement ? "+" : "-", String::empty); -} - -ImageEffectFilter* ShinyLookAndFeel::getSliderEffect() -{ - return 0; -} - -//============================================================================== -void ShinyLookAndFeel::drawPopupMenuBackground (Graphics& g, int width, int height) -{ - const Colour background (findColour (PopupMenu::backgroundColourId)); - - g.fillAll (background); - g.setColour (background.overlaidWith (Colours::lightblue.withAlpha (0.17f))); - - for (int i = 0; i < height; i += 3) - g.fillRect (0, i, width, 1); - - g.setColour (findColour (PopupMenu::textColourId).withAlpha (0.6f)); - g.drawRect (0, 0, width, height); -} - -void ShinyLookAndFeel::drawMenuBarBackground (Graphics& g, int width, int height, - bool /*isMouseOverBar*/, - MenuBarComponent& menuBar) -{ - const Colour baseColour (createBaseColour (menuBar.findColour (PopupMenu::backgroundColourId), false, false, false)); - - if (menuBar.isEnabled()) - { - drawShinyButtonShape (g, - -4.0f, 0.0f, - width + 8.0f, (float) height, - 0.0f, - baseColour, - 0.4f, - true, true, true, true); - } - else - { - g.fillAll (baseColour); - } -} - -//============================================================================== -void ShinyLookAndFeel::drawCornerResizer (Graphics& g, - int w, int h, - bool /*isMouseOver*/, - bool /*isMouseDragging*/) -{ - const float lineThickness = jmin (w, h) * 0.075f; - - for (float i = 0.0f; i < 1.0f; i += 0.3f) - { - g.setColour (Colours::lightgrey); - - g.drawLine (w * i, - h + 1.0f, - w + 1.0f, - h * i, - lineThickness); - - g.setColour (Colours::darkgrey); - - g.drawLine (w * i + lineThickness, - h + 1.0f, - w + 1.0f, - h * i + lineThickness, - lineThickness); - } -} - -//============================================================================== -void ShinyLookAndFeel::drawProgressBar (Graphics& g, ProgressBar& progressBar, - int x, int y, int w, int h, - float progress) -{ - const Colour background (progressBar.findColour (ProgressBar::backgroundColourId)); - g.fillAll (background); - - g.setColour (background.contrasting (0.2f)); - g.drawRect (x, y, w, h); - - drawGlassLozenge (g, - (float) (x + 1), - (float) (y + 1), - jlimit (0.0f, w - 2.0f, progress * (w - 2.0f)), - (float) (h - 2), - progressBar.findColour (ProgressBar::foregroundColourId), - 0.5f, - 0.0f, - true, true, true, true); -} - -//============================================================================== -class GlassWindowButton : public Button -{ -public: - //============================================================================== - GlassWindowButton (const String& name, const Colour& col, - const Path& normalShape_, - const Path& toggledShape_) - : Button (name), - colour (col), - normalShape (normalShape_), - toggledShape (toggledShape_) - { - } - - ~GlassWindowButton() - { - } - - //============================================================================== - void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) - { - float alpha = isMouseOverButton ? (isButtonDown ? 1.0f : 0.8f) : 0.55f; - - if (! isEnabled()) - alpha *= 0.5f; - - float x = 0, y = 0, diam; - - if (getWidth() < getHeight()) - { - diam = (float) getWidth(); - y = (getHeight() - getWidth()) * 0.5f; - } - else - { - diam = (float) getHeight(); - y = (getWidth() - getHeight()) * 0.5f; - } - - x += diam * 0.05f; - y += diam * 0.05f; - diam *= 0.9f; - - GradientBrush gb1 (Colour::greyLevel (0.9f).withAlpha (alpha), 0, y + diam, - Colour::greyLevel (0.6f).withAlpha (alpha), 0, y, false); - - g.setBrush (&gb1); - g.fillEllipse (x, y, diam, diam); - - x += 2.0f; - y += 2.0f; - diam -= 4.0f; - - ShinyLookAndFeel::drawGlassSphere (g, x, y, diam, colour.withAlpha (alpha), 1.0f); - - Path& p = getToggleState() ? toggledShape : normalShape; - - const AffineTransform t (p.getTransformToScaleToFit (x + diam * 0.3f, y + diam * 0.3f, - diam * 0.4f, diam * 0.4f, true)); - - g.setColour (Colours::black.withAlpha (alpha * 0.6f)); - g.fillPath (p, t); - } - - //============================================================================== - juce_UseDebuggingNewOperator - -private: - Colour colour; - Path normalShape, toggledShape; - - GlassWindowButton (const GlassWindowButton&); - const GlassWindowButton& operator= (const GlassWindowButton&); -}; - - -Button* ShinyLookAndFeel::createDocumentWindowButton (int buttonType) -{ - Path shape; - const float crossThickness = 0.25f; - - if (buttonType == DocumentWindow::closeButton) - { - shape.addLineSegment (0.0f, 0.0f, 1.0f, 1.0f, crossThickness * 1.4f); - shape.addLineSegment (1.0f, 0.0f, 0.0f, 1.0f, crossThickness * 1.4f); - - return new GlassWindowButton ("close", Colour (0xffdd1100), shape, shape); - } - else if (buttonType == DocumentWindow::minimiseButton) - { - shape.addLineSegment (0.0f, 0.5f, 1.0f, 0.5f, crossThickness); - - return new GlassWindowButton ("minimise", Colour (0xffaa8811), shape, shape); - } - else if (buttonType == DocumentWindow::maximiseButton) - { - shape.addLineSegment (0.5f, 0.0f, 0.5f, 1.0f, crossThickness); - shape.addLineSegment (0.0f, 0.5f, 1.0f, 0.5f, crossThickness); - - Path fullscreenShape; - fullscreenShape.startNewSubPath (45.0f, 100.0f); - fullscreenShape.lineTo (0.0f, 100.0f); - fullscreenShape.lineTo (0.0f, 0.0f); - fullscreenShape.lineTo (100.0f, 0.0f); - fullscreenShape.lineTo (100.0f, 45.0f); - fullscreenShape.addRectangle (45.0f, 45.0f, 100.0f, 100.0f); - PathStrokeType (30.0f).createStrokedPath (fullscreenShape, fullscreenShape); - - return new GlassWindowButton ("maximise", Colour (0xff119911), shape, fullscreenShape); - } - - jassertfalse - return 0; -} - -void ShinyLookAndFeel::positionDocumentWindowButtons (DocumentWindow&, - int titleBarX, int titleBarY, - int titleBarW, int titleBarH, - Button* minimiseButton, - Button* maximiseButton, - Button* closeButton, - bool positionTitleBarButtonsOnLeft) -{ - const int buttonW = titleBarH - titleBarH / 8; - - int x = positionTitleBarButtonsOnLeft ? titleBarX + 4 - : titleBarX + titleBarW - buttonW - buttonW / 4; - - if (closeButton != 0) - { - closeButton->setBounds (x, titleBarY, buttonW, titleBarH); - x += positionTitleBarButtonsOnLeft ? buttonW : -(buttonW + buttonW / 4); - } - - if (positionTitleBarButtonsOnLeft) - swapVariables (minimiseButton, maximiseButton); - - if (maximiseButton != 0) - { - maximiseButton->setBounds (x, titleBarY, buttonW, titleBarH); - x += positionTitleBarButtonsOnLeft ? buttonW : -buttonW; - } - - if (minimiseButton != 0) - minimiseButton->setBounds (x, titleBarY, buttonW, titleBarH); -} - - -//============================================================================== -static void createRoundedPath (Path& p, - const float x, const float y, - const float w, const float h, - const float cs, - const bool curveTopLeft, const bool curveTopRight, - const bool curveBottomLeft, const bool curveBottomRight) -{ - const float cs2 = 2.0f * cs; - - if (curveTopLeft) - { - p.startNewSubPath (x, y + cs); - p.addArc (x, y, cs2, cs2, float_Pi * 1.5f, float_Pi * 2.0f); - } - else - { - p.startNewSubPath (x, y); - } - - if (curveTopRight) - { - p.lineTo (x + w - cs, y); - p.addArc (x + w - cs2, y, cs2, cs2, 0.0f, float_Pi * 0.5f); - } - else - { - p.lineTo (x + w, y); - } - - if (curveBottomRight) - { - p.lineTo (x + w, y + h - cs); - p.addArc (x + w - cs2, y + h - cs2, cs2, cs2, float_Pi * 0.5f, float_Pi); - } - else - { - p.lineTo (x + w, y + h); - } - - if (curveBottomLeft) - { - p.lineTo (x + cs, y + h); - p.addArc (x, y + h - cs2, cs2, cs2, float_Pi, float_Pi * 1.5f); - } - else - { - p.lineTo (x, y + h); - } - - p.closeSubPath(); -} - -void ShinyLookAndFeel::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) -{ - if (w <= strokeWidth * 1.1f || h <= strokeWidth * 1.1f) - return; - - const float cs = jmin (maxCornerSize, w * 0.5f, h * 0.5f); - - Path outline; - createRoundedPath (outline, x, y, w, h, cs, - ! (flatOnLeft || flatOnTop), - ! (flatOnRight || flatOnTop), - ! (flatOnLeft || flatOnBottom), - ! (flatOnRight || flatOnBottom)); - - ColourGradient cg (baseColour.overlaidWith (Colours::white.withAlpha (0.0f)), 0.0f, y, - baseColour.overlaidWith (Colours::blue.withAlpha (0.03f)), 0.0f, y + h, - false); - - cg.addColour (0.5, baseColour.overlaidWith (Colours::white.withAlpha (0.2f))); - cg.addColour (0.51, baseColour.overlaidWith (Colours::blue.withAlpha (0.07f))); - - GradientBrush gb (cg); - g.setBrush (&gb); - g.fillPath (outline); - - g.setColour (Colours::black.withAlpha (0.5f)); - g.strokePath (outline, PathStrokeType (strokeWidth)); -} - -//============================================================================== -void ShinyLookAndFeel::drawGlassSphere (Graphics& g, - float x, float y, float diameter, - const Colour& colour, - const float outlineThickness) -{ - if (diameter <= outlineThickness) - return; - - Path p; - p.addEllipse (x, y, diameter, diameter); - - { - ColourGradient cg (Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y, - Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y + diameter, false); - - cg.addColour (0.4, Colours::white.overlaidWith (colour)); - - GradientBrush gb (cg); - g.setBrush (&gb); - g.fillPath (p); - } - - { - GradientBrush gb (Colours::white, 0, y + diameter * 0.06f, - Colours::transparentWhite, 0, y + diameter * 0.3f, false); - - g.setBrush (&gb); - g.fillEllipse (x + diameter * 0.2f, y + diameter * 0.05f, diameter * 0.6f, diameter * 0.4f); - } - - { - ColourGradient cg (Colours::transparentBlack, - x + diameter * 0.5f, y + diameter * 0.5f, - Colours::black.withAlpha (0.5f * outlineThickness * colour.getFloatAlpha()), - x, y + diameter * 0.5f, true); - - cg.addColour (0.7, Colours::transparentBlack); - cg.addColour (0.8, Colours::black.withAlpha (0.1f * outlineThickness)); - - GradientBrush gb (cg); - g.setBrush (&gb); - g.fillPath (p); - } - - g.setColour (Colours::black.withAlpha (0.5f * colour.getFloatAlpha())); - g.drawEllipse (x, y, diameter, diameter, outlineThickness); -} - -void ShinyLookAndFeel::drawGlassPointer (Graphics& g, float x, float y, float diameter, - const Colour& colour, const float outlineThickness, - const int direction) -{ - if (diameter <= outlineThickness) - return; - - Path p; - p.startNewSubPath (x + diameter * 0.5f, y); - p.lineTo (x + diameter, y + diameter * 0.6f); - p.lineTo (x + diameter, y + diameter); - p.lineTo (x, y + diameter); - p.lineTo (x, y + diameter * 0.6f); - p.closeSubPath(); - - p.applyTransform (AffineTransform::rotation (direction * (float_Pi * 0.5f), x + diameter * 0.5f, y + diameter * 0.5f)); - - { - ColourGradient cg (Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y, - Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y + diameter, false); - - cg.addColour (0.4, Colours::white.overlaidWith (colour)); - - GradientBrush gb (cg); - g.setBrush (&gb); - g.fillPath (p); - } - - { - ColourGradient cg (Colours::transparentBlack, - x + diameter * 0.5f, y + diameter * 0.5f, - Colours::black.withAlpha (0.5f * outlineThickness * colour.getFloatAlpha()), - x - diameter * 0.2f, y + diameter * 0.5f, true); - - cg.addColour (0.5, Colours::transparentBlack); - cg.addColour (0.7, Colours::black.withAlpha (0.07f * outlineThickness)); - - GradientBrush gb (cg); - g.setBrush (&gb); - g.fillPath (p); - } - - g.setColour (Colours::black.withAlpha (0.5f * colour.getFloatAlpha())); - g.strokePath (p, PathStrokeType (outlineThickness)); -} - -//============================================================================== -void ShinyLookAndFeel::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) -{ - if (width <= outlineThickness || height <= outlineThickness) - return; - - const int intX = (int) x; - const int intY = (int) y; - const int intW = (int) width; - const int intH = (int) height; - - const float cs = cornerSize < 0 ? jmin (width * 0.5f, height * 0.5f) : cornerSize; - const float edgeBlurRadius = height * 0.75f + (height - cs * 2.0f); - const int intEdge = (int) edgeBlurRadius; - - Path outline; - createRoundedPath (outline, x, y, width, height, cs, - ! (flatOnLeft || flatOnTop), - ! (flatOnRight || flatOnTop), - ! (flatOnLeft || flatOnBottom), - ! (flatOnRight || flatOnBottom)); - - { - ColourGradient cg (colour.darker (0.2f), 0, y, - colour.darker (0.2f), 0, y + height, false); - - cg.addColour (0.03, colour.withMultipliedAlpha (0.3f)); - cg.addColour (0.4, colour); - cg.addColour (0.97, colour.withMultipliedAlpha (0.3f)); - - GradientBrush gb (cg); - g.setBrush (&gb); - g.fillPath (outline); - } - - ColourGradient cg (Colours::transparentBlack, x + edgeBlurRadius, y + height * 0.5f, - colour.darker (0.2f), x, y + height * 0.5f, true); - - cg.addColour (jlimit (0.0, 1.0, 1.0 - (cs * 0.5f) / edgeBlurRadius), Colours::transparentBlack); - cg.addColour (jlimit (0.0, 1.0, 1.0 - (cs * 0.25f) / edgeBlurRadius), colour.darker (0.2f).withMultipliedAlpha (0.3f)); - - if (! (flatOnLeft || flatOnTop || flatOnBottom)) - { - GradientBrush gb (cg); - - g.saveState(); - g.setBrush (&gb); - g.reduceClipRegion (intX, intY, intEdge, intH); - g.fillPath (outline); - g.restoreState(); - } - - if (! (flatOnRight || flatOnTop || flatOnBottom)) - { - cg.x1 = x + width - edgeBlurRadius; - cg.x2 = x + width; - GradientBrush gb (cg); - - g.saveState(); - g.setBrush (&gb); - g.reduceClipRegion (intX + intW - intEdge, intY, 2 + intEdge, intH); - g.fillPath (outline); - g.restoreState(); - } - - { - const float leftIndent = flatOnLeft ? 0.0f : cs * 0.4f; - const float rightIndent = flatOnRight ? 0.0f : cs * 0.4f; - - Path highlight; - createRoundedPath (highlight, - x + leftIndent, - y + cs * 0.1f, - width - (leftIndent + rightIndent), - height * 0.4f, cs * 0.4f, - ! (flatOnLeft || flatOnTop), - ! (flatOnRight || flatOnTop), - ! (flatOnLeft || flatOnBottom), - ! (flatOnRight || flatOnBottom)); - - GradientBrush gb (colour.brighter (10.0f), 0, y + height * 0.06f, - Colours::transparentWhite, 0, y + height * 0.4f, false); - - g.setBrush (&gb); - g.fillPath (highlight); - } - - g.setColour (colour.darker().withMultipliedAlpha (1.5f)); - g.strokePath (outline, PathStrokeType (outlineThickness)); -} - - -END_JUCE_NAMESPACE diff --git a/src/juce_appframework/gui/components/lookandfeel/juce_ShinyLookAndFeel.h b/src/juce_appframework/gui/components/lookandfeel/juce_ShinyLookAndFeel.h deleted file mode 100644 index afe2a056c4..0000000000 --- a/src/juce_appframework/gui/components/lookandfeel/juce_ShinyLookAndFeel.h +++ /dev/null @@ -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__ diff --git a/src/juce_appframework/gui/graphics/colour/juce_Colour.cpp b/src/juce_appframework/gui/graphics/colour/juce_Colour.cpp index ece5d0de63..0b1bfd33cf 100644 --- a/src/juce_appframework/gui/graphics/colour/juce_Colour.cpp +++ b/src/juce_appframework/gui/graphics/colour/juce_Colour.cpp @@ -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()); } //============================================================================== @@ -247,9 +257,9 @@ const Colour Colour::overlaidWith (const Colour& src) const throw() { const int da = (invA * destAlpha) / resA; - return Colour ((uint8) (src.getRed() + ((((int) getRed() - src.getRed()) * da) >> 8)), + return Colour ((uint8) (src.getRed() + ((((int) getRed() - src.getRed()) * da) >> 8)), (uint8) (src.getGreen() + ((((int) getGreen() - src.getGreen()) * da) >> 8)), - (uint8) (src.getBlue() + ((((int) getBlue() - src.getBlue()) * da) >> 8)), + (uint8) (src.getBlue() + ((((int) getBlue() - src.getBlue()) * da) >> 8)), (uint8) resA); }