-
-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathLookAndFeel.h
More file actions
255 lines (194 loc) · 11.7 KB
/
LookAndFeel.h
File metadata and controls
255 lines (194 loc) · 11.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
/*
// Copyright (c) 2021-2025 Timothy Schoen
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "LICENSE.txt," in this distribution.
*/
#pragma once
#include <bit>
#include <nanovg.h>
#include "Utility/Config.h"
#include "Utility/Fonts.h"
#include "Utility/SettingsFile.h"
#include "Constants.h"
struct PlugDataColours {
static inline Colour toolbarBackgroundColour;
static inline Colour toolbarTextColour;
static inline Colour toolbarActiveColour;
static inline Colour toolbarHoverColour;
static inline Colour toolbarOutlineColour;
static inline Colour activeTabBackgroundColour;
static inline Colour canvasBackgroundColour;
static inline Colour canvasTextColour;
static inline Colour canvasDotsColour;
static inline Colour presentationBackgroundColour;
static inline Colour guiObjectBackgroundColour;
static inline Colour guiObjectInternalOutlineColour;
static inline Colour textObjectBackgroundColour;
static inline Colour objectOutlineColour;
static inline Colour objectSelectedOutlineColour;
static inline Colour commentTextColour;
static inline Colour outlineColour;
static inline Colour ioletAreaColour;
static inline Colour ioletOutlineColour;
static inline Colour dataColour;
static inline Colour connectionColour;
static inline Colour signalColour;
static inline Colour gemColour;
static inline Colour dialogBackgroundColour;
static inline Colour sidebarBackgroundColour;
static inline Colour sidebarTextColour;
static inline Colour sidebarActiveBackgroundColour;
static inline Colour levelMeterActiveColour;
static inline Colour levelMeterBackgroundColour;
static inline Colour levelMeterThumbColour;
static inline Colour panelBackgroundColour;
static inline Colour panelForegroundColour;
static inline Colour panelTextColour;
static inline Colour panelActiveBackgroundColour;
static inline Colour popupMenuBackgroundColour;
static inline Colour popupMenuActiveBackgroundColour;
static inline Colour popupMenuTextColour;
static inline Colour scrollbarThumbColour;
static inline Colour graphAreaColour;
static inline Colour gridLineColour;
static inline Colour caretColour;
};
static inline NVGcolor nvgColour(Colour const& c)
{
return std::bit_cast<NVGcolor>(c); // Both store as BGRA internally
}
inline UnorderedMap<PlugDataColour, std::tuple<String, String, String>> const PlugDataColourNames = {
{ toolbarBackgroundColourId, { "Toolbar background", "toolbar_background", "Toolbar" } },
{ toolbarTextColourId, { "Toolbar text", "toolbar_text", "Toolbar" } },
{ toolbarHoverColourId, { "Toolbar hover", "toolbar_hover", "Toolbar" } },
{ toolbarActiveColourId, { "Toolbar active text", "toolbar_active", "Toolbar" } },
{ activeTabBackgroundColourId, { "Selected tab background", "selected_tab_background", "Toolbar" } },
{ canvasBackgroundColourId, { "Canvas background", "canvas_background", "Canvas" } },
{ canvasTextColourId, { "Canvas text", "canvas_text", "Canvas" } },
{ canvasDotsColourId, { "Canvas dots colour", "canvas_dots", "Canvas" } },
{ presentationBackgroundColourId, { "Presentation background", "presentation_background", "Canvas" } },
{ dataColourId, { "Data colour", "data_colour", "Canvas" } },
{ connectionColourId, { "Connection", "connection_colour", "Canvas" } },
{ signalColourId, { "Signal", "signal_colour", "Canvas" } },
{ gemColourId, { "Gem", "gem_colour", "Canvas" } },
{ graphAreaColourId, { "Graph resizer", "graph_area", "Canvas" } },
{ gridLineColourId, { "Grid line", "grid_colour", "Canvas" } },
{ guiObjectBackgroundColourId, { "GUI object background", "default_object_background", "Object" } },
{ guiObjectInternalOutlineColourId, { "GUI object internal outline colour", "gui_internal_outline_colour", "Object" } },
{ textObjectBackgroundColourId, { "Object background", "text_object_background", "Object" } },
{ commentTextColourId, { "Comment text", "comment_text_colour", "Object" } },
{ objectOutlineColourId, { "Object outline", "object_outline_colour", "Object" } },
{ objectSelectedOutlineColourId, { "Selected object outline", "selected_object_outline_colour", "Object" } },
{ ioletAreaColourId, { "Inlet/Outlet area", "iolet_area_colour", "Object" } },
{ ioletOutlineColourId, { "Inlet/Outlet outline", "iolet_outline_colour", "Object" } },
{ popupMenuBackgroundColourId, { "Popup menu background", "popup_background", "Popup Menu" } },
{ popupMenuActiveBackgroundColourId, { "Popup menu background active", "popup_background_active", "Popup Menu" } },
{ popupMenuTextColourId, { "Popup menu text", "popup_text", "Popup Menu" } },
{ outlineColourId, { "Popup menu outline", "outline_colour", "Popup Menu" } },
{ dialogBackgroundColourId, { "Dialog background", "dialog_background", "Other" } },
{ caretColourId, { "Text editor caret", "caret_colour", "Other" } },
{ toolbarOutlineColourId, { "Outline", "toolbar_outline_colour", "Other" } },
{ scrollbarThumbColourId, { "Scrollbar thumb", "scrollbar_thumb", "Other" } },
{ levelMeterActiveColourId, { "Level meter active", "levelmeter_active", "Level Meter" } },
{ levelMeterBackgroundColourId, { "Level meter track", "levelmeter_background", "Level Meter" } },
{ levelMeterThumbColourId, { "Level meter thumb", "levelmeter_thumb", "Level Meter" } },
{ panelBackgroundColourId, { "Panel background", "panel_background", "Properties Panel" } },
{ panelForegroundColourId, { "Panel foreground", "panel_foreground", "Properties Panel" } },
{ panelTextColourId, { "Panel text", "panel_text", "Properties Panel" } },
{ panelActiveBackgroundColourId, { "Panel background active", "panel_background_active", "Properties Panel" } },
{ sidebarBackgroundColourId, { "Sidebar background", "sidebar_colour", "Sidebar" } },
{ sidebarTextColourId, { "Sidebar text", "sidebar_text", "Sidebar" } },
{ sidebarActiveBackgroundColourId, { "Sidebar background active", "sidebar_background_active", "Sidebar" } },
};
struct PlugDataLook final : public LookAndFeel_V4
, public SettingsFileListener {
// Makes sure fonts get initialised
SharedResourcePointer<Fonts> fonts;
PlugDataLook();
void settingsChanged(String const& name, var const& value) override;
void fillResizableWindowBackground(Graphics& g, int w, int h, BorderSize<int> const& border, ResizableWindow& window) override;
void drawResizableWindowBorder(Graphics&, int w, int h, BorderSize<int> const& border, ResizableWindow&) override { }
void drawCallOutBoxBackground(CallOutBox& box, Graphics& g, Path const& path, Image& cachedImage) override;
int getCallOutBoxBorderSize(CallOutBox const& c) override;
void drawButtonText(Graphics& g, TextButton& button, bool isMouseOverButton, bool isButtonDown) override;
Font getTextButtonFont(TextButton& but, int buttonHeight) override;
Button* createDocumentWindowButton(int buttonType) override;
void positionDocumentWindowButtons(DocumentWindow& window,
int titleBarX, int titleBarY, int titleBarW, int titleBarH,
Button* minimiseButton,
Button* maximiseButton,
Button* closeButton,
bool positionTitleBarButtonsOnLeft) override;
Font getTabButtonFont(TabBarButton&, float height) override;
void drawScrollbar(Graphics& g, ScrollBar& scrollbar, int x, int y, int width, int height,
bool isScrollbarVertical, int thumbStartPosition, int thumbSize, bool isMouseOver, [[maybe_unused]] bool isMouseDown) override;
void getIdealPopupMenuItemSize(String const& text, bool isSeparator, int standardMenuItemHeight, int& idealWidth, int& idealHeight) override;
void drawPopupMenuBackgroundWithOptions(Graphics& g, int width, int height, PopupMenu::Options const& options) override;
Path getTickShape(float height) override;
void drawPopupMenuItem(Graphics& g, Rectangle<int> const& area,
bool isSeparator, bool isActive,
bool isHighlighted, bool isTicked,
bool hasSubMenu, String const& text,
String const& shortcutKeyText,
Drawable const* icon, Colour const* textColourToUse) override;
int getMenuWindowFlags() override;
int getPopupMenuBorderSize() override;
void drawTreeviewPlusMinusBox(Graphics& g, Rectangle<float> const& area, Colour, bool isOpen, bool isMouseOver) override;
void drawComboBox(Graphics& g, int width, int height, bool, int, int, int, int, ComboBox& object) override;
Font getComboBoxFont(ComboBox&) override;
PopupMenu::Options getOptionsForComboBoxPopupMenu(ComboBox& box, Label& label) override;
void drawResizableFrame(Graphics& g, int w, int h, BorderSize<int> const& border) override { }
void fillTextEditorBackground(Graphics& g, int width, int height, TextEditor& textEditor) override;
void drawTextEditorOutline(Graphics& g, int width, int height, TextEditor& textEditor) override;
void drawSpinningWaitAnimation(Graphics& g, Colour const& colour, int x, int y, int w, int h) override;
void drawCornerResizer(Graphics& g, int w, int h, bool isMouseOver, bool isMouseDragging) override;
void drawLasso(Graphics& g, Component& lassoComp) override;
void drawAlertBox(Graphics& g, AlertWindow& alert,
Rectangle<int> const& textArea, TextLayout& textLayout) override;
void drawTooltip(Graphics& g, String const& text, int width, int height) override;
void drawLabel(Graphics& g, Label& label) override;
void drawPropertyComponentLabel(Graphics& g, int width, int height, PropertyComponent& component) override;
void drawPropertyPanelSectionHeader(Graphics& g, String const& name, bool isOpen, int width, int height) override;
void drawTableHeaderBackground(Graphics&, TableHeaderComponent&) override;
void drawTableHeaderColumn(Graphics&, TableHeaderComponent&,
String const& columnName, int columnId,
int width, int height,
bool isMouseOver, bool isMouseDown, int columnFlags) override;
Rectangle<int> getTooltipBounds(String const& tipText, Point<int> screenPos, Rectangle<int> parentArea) override;
int getTreeViewIndentSize(TreeView&) override;
void setColours(UnorderedMap<PlugDataColour, Colour>& colours);
void setTheme(DynamicObject::Ptr themeTree);
enum ConnectionStyle {
ConnectionStyleDefault = 1,
ConnectionStyleVanilla,
ConnectionStyleThin
};
static inline ConnectionStyle useConnectionStyle = ConnectionStyleDefault;
static inline bool useFlagOutline = false;
static inline bool useSyntaxHighlighting = false;
static inline bool useSquareIolets = false;
static inline bool useIoletSpacingEdge = false;
static inline bool useGradientConnectionLook = false;
static inline bool useStraightConnections = false;
static inline bool useTouchMode = false;
static inline String currentTheme = "light";
static inline StringArray selectedThemes = { "light", "dark" };
static StringArray getAllThemes();
static ConnectionStyle getConnectionStyle();
static void setDefaultFont(String const& fontName);
static void resetColours();
static Colour getThemeColour(DynamicObject::Ptr themeTree, PlugDataColour colourId);
static bool getUseStraightConnections();
static bool getUseFlagOutline();
static bool getUseSyntaxHighlighting();
static bool getUseIoletSpacingEdge();
static bool getUseSquareIolets();
static bool getUseGradientConnectionLook();
static bool isFixedIoletPosition();
static int getIoletSize();
#if JUCE_IOS
void setMainComponent(Component* c) { mainComponent = c; }
Component::SafePointer<Component> mainComponent;
#endif
static String const defaultThemesJSON;
};