1 /* 2 ============================================================================== 3 4 This file is part of the JUCE library. 5 Copyright (c) 2020 - Raw Material Software Limited 6 7 JUCE is an open source library subject to commercial or open-source 8 licensing. 9 10 By using JUCE, you agree to the terms of both the JUCE 6 End-User License 11 Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020). 12 13 End User License Agreement: www.juce.com/juce-6-licence 14 Privacy Policy: www.juce.com/juce-privacy-policy 15 16 Or: You may also use this code under the terms of the GPL v3 (see 17 www.gnu.org/licenses). 18 19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER 20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE 21 DISCLAIMED. 22 23 ============================================================================== 24 */ 25 26 namespace juce 27 { 28 29 //============================================================================== 30 /** 31 This LookAndFeel subclass implements the juce style from around 2008-12. 32 33 @see LookAndFeel, LookAndFeel_V1, LookAndFeel_V3 34 35 @tags{GUI} 36 */ 37 class JUCE_API LookAndFeel_V2 : public LookAndFeel 38 { 39 public: 40 LookAndFeel_V2(); 41 ~LookAndFeel_V2() override; 42 43 //============================================================================== 44 void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour, 45 bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; 46 Font getTextButtonFont (TextButton&, int buttonHeight) override; 47 48 void drawButtonText (Graphics&, TextButton&, 49 bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; 50 int getTextButtonWidthToFitText (TextButton&, int buttonHeight) override; 51 52 void drawToggleButton (Graphics&, ToggleButton&, 53 bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; 54 55 void changeToggleButtonWidthToFitText (ToggleButton&) override; 56 57 void drawTickBox (Graphics&, Component&, 58 float x, float y, float w, float h, 59 bool ticked, bool isEnabled, 60 bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; 61 62 void drawDrawableButton (Graphics&, DrawableButton&, 63 bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; 64 65 //============================================================================== 66 AlertWindow* createAlertWindow (const String& title, const String& message, 67 const String& button1, 68 const String& button2, 69 const String& button3, 70 AlertWindow::AlertIconType iconType, 71 int numButtons, Component* associatedComponent) override; 72 73 void drawAlertBox (Graphics&, AlertWindow&, const Rectangle<int>& textArea, TextLayout&) override; 74 int getAlertBoxWindowFlags() override; 75 76 Array<int> getWidthsForTextButtons (AlertWindow&, const Array<TextButton*>&) override; 77 int getAlertWindowButtonHeight() override; 78 79 /** Override this function to supply a custom font for the alert window title. 80 This default implementation will use a boldened and slightly larger version 81 of the alert window message font. 82 83 @see getAlertWindowMessageFont. 84 */ 85 Font getAlertWindowTitleFont() override; 86 87 /** Override this function to supply a custom font for the alert window message. 88 This default implementation will use the default font with height set to 15.0f. 89 90 @see getAlertWindowTitleFont 91 */ 92 Font getAlertWindowMessageFont() override; 93 94 Font getAlertWindowFont() override; 95 96 //============================================================================== 97 void drawProgressBar (Graphics&, ProgressBar&, int width, int height, double progress, const String& textToShow) override; 98 void drawSpinningWaitAnimation (Graphics&, const Colour& colour, int x, int y, int w, int h) override; 99 bool isProgressBarOpaque (ProgressBar&) override; 100 101 //============================================================================== 102 bool areScrollbarButtonsVisible() override; 103 void drawScrollbarButton (Graphics&, ScrollBar&, int width, int height, int buttonDirection, 104 bool isScrollbarVertical, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; 105 106 void drawScrollbar (Graphics&, ScrollBar&, int x, int y, int width, int height, 107 bool isScrollbarVertical, int thumbStartPosition, int thumbSize, 108 bool isMouseOver, bool isMouseDown) override; 109 110 ImageEffectFilter* getScrollbarEffect() override; 111 int getMinimumScrollbarThumbSize (ScrollBar&) override; 112 int getDefaultScrollbarWidth() override; 113 int getScrollbarButtonSize (ScrollBar&) override; 114 115 //============================================================================== 116 Path getTickShape (float height) override; 117 Path getCrossShape (float height) override; 118 119 //============================================================================== 120 void drawTreeviewPlusMinusBox (Graphics&, const Rectangle<float>& area, 121 Colour backgroundColour, bool isOpen, bool isMouseOver) override; 122 bool areLinesDrawnForTreeView (TreeView&) override; 123 int getTreeViewIndentSize (TreeView&) override; 124 125 //============================================================================== 126 void fillTextEditorBackground (Graphics&, int width, int height, TextEditor&) override; 127 void drawTextEditorOutline (Graphics&, int width, int height, TextEditor&) override; 128 CaretComponent* createCaretComponent (Component* keyFocusOwner) override; 129 130 //============================================================================== 131 const Drawable* getDefaultFolderImage() override; 132 const Drawable* getDefaultDocumentFileImage() override; 133 134 AttributedString createFileChooserHeaderText (const String& title, const String& instructions) override; 135 136 void drawFileBrowserRow (Graphics&, int width, int height, 137 const File& file, const String& filename, Image* icon, 138 const String& fileSizeDescription, const String& fileTimeDescription, 139 bool isDirectory, bool isItemSelected, int itemIndex, 140 DirectoryContentsDisplayComponent&) override; 141 142 Button* createFileBrowserGoUpButton() override; 143 144 void layoutFileBrowserComponent (FileBrowserComponent&, 145 DirectoryContentsDisplayComponent*, 146 FilePreviewComponent*, 147 ComboBox* currentPathBox, 148 TextEditor* filenameBox, 149 Button* goUpButton) override; 150 151 //============================================================================== 152 void drawBubble (Graphics&, BubbleComponent&, const Point<float>& tip, const Rectangle<float>& body) override; 153 154 void drawLasso (Graphics&, Component&) override; 155 156 //============================================================================== 157 void drawPopupMenuBackground (Graphics&, int width, int height) override; 158 159 void drawPopupMenuItem (Graphics&, const Rectangle<int>& area, 160 bool isSeparator, bool isActive, bool isHighlighted, bool isTicked, bool hasSubMenu, 161 const String& text, const String& shortcutKeyText, 162 const Drawable* icon, const Colour* textColour) override; 163 164 void drawPopupMenuSectionHeader (Graphics&, const Rectangle<int>& area, 165 const String& sectionName) override; 166 167 Font getPopupMenuFont() override; 168 169 void drawPopupMenuUpDownArrow (Graphics&, int width, int height, bool isScrollUpArrow) override; 170 171 void getIdealPopupMenuItemSize (const String& text, bool isSeparator, int standardMenuItemHeight, 172 int& idealWidth, int& idealHeight) override; 173 int getMenuWindowFlags() override; 174 void preparePopupMenuWindow (Component&) override; 175 176 void drawMenuBarBackground (Graphics&, int width, int height, bool isMouseOverBar, MenuBarComponent&) override; 177 int getMenuBarItemWidth (MenuBarComponent&, int itemIndex, const String& itemText) override; 178 Font getMenuBarFont (MenuBarComponent&, int itemIndex, const String& itemText) override; 179 int getDefaultMenuBarHeight() override; 180 181 void drawMenuBarItem (Graphics&, int width, int height, 182 int itemIndex, const String& itemText, 183 bool isMouseOverItem, bool isMenuOpen, bool isMouseOverBar, 184 MenuBarComponent&) override; 185 186 Component* getParentComponentForMenuOptions (const PopupMenu::Options& options) override; 187 188 bool shouldPopupMenuScaleWithTargetComponent (const PopupMenu::Options& options) override; 189 190 int getPopupMenuBorderSize() override; 191 192 //============================================================================== 193 void drawComboBox (Graphics&, int width, int height, bool isMouseButtonDown, 194 int buttonX, int buttonY, int buttonW, int buttonH, 195 ComboBox&) override; 196 Font getComboBoxFont (ComboBox&) override; 197 Label* createComboBoxTextBox (ComboBox&) override; 198 void positionComboBoxText (ComboBox&, Label&) override; 199 PopupMenu::Options getOptionsForComboBoxPopupMenu (ComboBox&, Label&) override; 200 void drawComboBoxTextWhenNothingSelected (Graphics&, ComboBox&, Label&) override; 201 202 //============================================================================== 203 void drawLabel (Graphics&, Label&) override; 204 Font getLabelFont (Label&) override; 205 BorderSize<int> getLabelBorderSize (Label&) override; 206 207 //============================================================================== 208 void drawLinearSlider (Graphics&, int x, int y, int width, int height, 209 float sliderPos, float minSliderPos, float maxSliderPos, 210 const Slider::SliderStyle, Slider&) override; 211 212 void drawLinearSliderBackground (Graphics&, int x, int y, int width, int height, 213 float sliderPos, float minSliderPos, float maxSliderPos, 214 const Slider::SliderStyle, Slider&) override; 215 216 void drawLinearSliderThumb (Graphics&, int x, int y, int width, int height, 217 float sliderPos, float minSliderPos, float maxSliderPos, 218 const Slider::SliderStyle, Slider&) override; 219 220 void drawRotarySlider (Graphics&, int x, int y, int width, int height, 221 float sliderPosProportional, float rotaryStartAngle, float rotaryEndAngle, 222 Slider&) override; 223 224 int getSliderThumbRadius (Slider&) override; 225 Button* createSliderButton (Slider&, bool isIncrement) override; 226 Label* createSliderTextBox (Slider&) override; 227 ImageEffectFilter* getSliderEffect (Slider&) override; 228 Font getSliderPopupFont (Slider&) override; 229 int getSliderPopupPlacement (Slider&) override; 230 Slider::SliderLayout getSliderLayout (Slider&) override; 231 232 //============================================================================== 233 Rectangle<int> getTooltipBounds (const String& tipText, Point<int> screenPos, Rectangle<int> parentArea) override; 234 void drawTooltip (Graphics&, const String& text, int width, int height) override; 235 236 //============================================================================== 237 Button* createFilenameComponentBrowseButton (const String& text) override; 238 void layoutFilenameComponent (FilenameComponent&, ComboBox* filenameBox, Button* browseButton) override; 239 240 //============================================================================== 241 void drawConcertinaPanelHeader (Graphics&, const Rectangle<int>& area, 242 bool isMouseOver, bool isMouseDown, 243 ConcertinaPanel&, Component& panel) override; 244 245 //============================================================================== 246 void drawCornerResizer (Graphics&, int w, int h, bool isMouseOver, bool isMouseDragging) override; 247 void drawResizableFrame (Graphics&, int w, int h, const BorderSize<int>&) override; 248 249 //============================================================================== 250 void fillResizableWindowBackground (Graphics&, int w, int h, const BorderSize<int>&, ResizableWindow&) override; 251 void drawResizableWindowBorder (Graphics&, int w, int h, const BorderSize<int>& border, ResizableWindow&) override; 252 253 //============================================================================== 254 void drawDocumentWindowTitleBar (DocumentWindow&, Graphics&, int w, int h, 255 int titleSpaceX, int titleSpaceW, 256 const Image* icon, bool drawTitleTextOnLeft) override; 257 258 Button* createDocumentWindowButton (int buttonType) override; 259 260 void positionDocumentWindowButtons (DocumentWindow&, 261 int titleBarX, int titleBarY, int titleBarW, int titleBarH, 262 Button* minimiseButton, 263 Button* maximiseButton, 264 Button* closeButton, 265 bool positionTitleBarButtonsOnLeft) override; 266 267 //============================================================================== 268 DropShadower* createDropShadowerForComponent (Component*) override; 269 270 //============================================================================== 271 void drawStretchableLayoutResizerBar (Graphics&, int w, int h, bool isVerticalBar, 272 bool isMouseOver, bool isMouseDragging) override; 273 274 //============================================================================== 275 void drawGroupComponentOutline (Graphics&, int w, int h, const String& text, 276 const Justification&, GroupComponent&) override; 277 278 //============================================================================== 279 int getTabButtonSpaceAroundImage() override; 280 int getTabButtonOverlap (int tabDepth) override; 281 int getTabButtonBestWidth (TabBarButton&, int tabDepth) override; 282 Rectangle<int> getTabButtonExtraComponentBounds (const TabBarButton&, Rectangle<int>& textArea, Component& extraComp) override; 283 284 void drawTabButton (TabBarButton&, Graphics&, bool isMouseOver, bool isMouseDown) override; 285 Font getTabButtonFont (TabBarButton&, float height) override; 286 void drawTabButtonText (TabBarButton&, Graphics&, bool isMouseOver, bool isMouseDown) override; 287 void drawTabbedButtonBarBackground (TabbedButtonBar&, Graphics&) override; 288 void drawTabAreaBehindFrontButton (TabbedButtonBar&, Graphics&, int w, int h) override; 289 290 void createTabButtonShape (TabBarButton&, Path&, bool isMouseOver, bool isMouseDown) override; 291 void fillTabButtonShape (TabBarButton&, Graphics&, const Path&, bool isMouseOver, bool isMouseDown) override; 292 293 Button* createTabBarExtrasButton() override; 294 295 //============================================================================== 296 void drawImageButton (Graphics&, Image*, 297 int imageX, int imageY, int imageW, int imageH, 298 const Colour& overlayColour, float imageOpacity, ImageButton&) override; 299 300 //============================================================================== 301 void drawTableHeaderBackground (Graphics&, TableHeaderComponent&) override; 302 303 void drawTableHeaderColumn (Graphics&, TableHeaderComponent&, const String& columnName, 304 int columnId, int width, int height, bool isMouseOver, 305 bool isMouseDown, int columnFlags) override; 306 307 //============================================================================== 308 void paintToolbarBackground (Graphics&, int width, int height, Toolbar&) override; 309 310 Button* createToolbarMissingItemsButton (Toolbar&) override; 311 312 void paintToolbarButtonBackground (Graphics&, int width, int height, 313 bool isMouseOver, bool isMouseDown, 314 ToolbarItemComponent&) override; 315 316 void paintToolbarButtonLabel (Graphics&, int x, int y, int width, int height, 317 const String& text, ToolbarItemComponent&) override; 318 319 //============================================================================== 320 void drawPropertyPanelSectionHeader (Graphics&, const String& name, bool isOpen, int width, int height) override; 321 void drawPropertyComponentBackground (Graphics&, int width, int height, PropertyComponent&) override; 322 void drawPropertyComponentLabel (Graphics&, int width, int height, PropertyComponent&) override; 323 Rectangle<int> getPropertyComponentContentPosition (PropertyComponent&) override; 324 int getPropertyPanelSectionHeaderHeight (const String& sectionTitle) override; 325 326 //============================================================================== 327 void drawCallOutBoxBackground (CallOutBox&, Graphics&, const Path& path, Image& cachedImage) override; 328 int getCallOutBoxBorderSize (const CallOutBox&) override; 329 float getCallOutBoxCornerSize (const CallOutBox&) override; 330 331 //============================================================================== 332 void drawLevelMeter (Graphics&, int width, int height, float level) override; 333 334 void drawKeymapChangeButton (Graphics&, int width, int height, Button&, const String& keyDescription) override; 335 336 //============================================================================== 337 Font getSidePanelTitleFont (SidePanel&) override; 338 Justification getSidePanelTitleJustification (SidePanel&) override; 339 Path getSidePanelDismissButtonShape (SidePanel&) override; 340 341 //============================================================================== 342 /** Draws a 3D raised (or indented) bevel using two colours. 343 344 The bevel is drawn inside the given rectangle, and greater bevel thicknesses 345 extend inwards. 346 347 The top-left colour is used for the top- and left-hand edges of the 348 bevel; the bottom-right colour is used for the bottom- and right-hand 349 edges. 350 351 If useGradient is true, then the bevel fades out to make it look more curved 352 and less angular. If sharpEdgeOnOutside is true, the outside of the bevel is 353 sharp, and it fades towards the centre; if sharpEdgeOnOutside is false, then 354 the centre edges are sharp and it fades towards the outside. 355 */ 356 static void drawBevel (Graphics&, 357 int x, int y, int width, int height, 358 int bevelThickness, 359 const Colour& topLeftColour = Colours::white, 360 const Colour& bottomRightColour = Colours::black, 361 bool useGradient = true, 362 bool sharpEdgeOnOutside = true); 363 364 /** Utility function to draw a shiny, glassy circle (for round LED-type buttons). */ 365 static void drawGlassSphere (Graphics&, float x, float y, float diameter, 366 const Colour&, float outlineThickness) noexcept; 367 368 static void drawGlassPointer (Graphics&, float x, float y, float diameter, 369 const Colour&, float outlineThickness, int direction) noexcept; 370 371 /** Utility function to draw a shiny, glassy oblong (for text buttons). */ 372 static void drawGlassLozenge (Graphics&, 373 float x, float y, float width, float height, 374 const Colour&, float outlineThickness, float cornerSize, 375 bool flatOnLeft, bool flatOnRight, bool flatOnTop, bool flatOnBottom) noexcept; 376 377 private: 378 //============================================================================== 379 std::unique_ptr<Drawable> folderImage, documentImage; 380 381 void drawShinyButtonShape (Graphics&, 382 float x, float y, float w, float h, float maxCornerSize, 383 const Colour&, float strokeWidth, 384 bool flatOnLeft, bool flatOnRight, bool flatOnTop, bool flatOnBottom) noexcept; 385 386 class GlassWindowButton; 387 class SliderLabelComp; 388 389 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel_V2) 390 }; 391 392 } // namespace juce 393