Cleanup
[carla.git] / source / frontend / patchcanvas / theme.py
blobfe9b2c4cb2baaae57c351babaf5f5a1186c8d12b
1 #!/usr/bin/env python3
2 # SPDX-FileCopyrightText: 2011-2024 Filipe Coelho <falktx@falktx.com>
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # ------------------------------------------------------------------------------------------------------------
6 # Imports (Global)
8 from qt_compat import qt_config
10 if qt_config == 5:
11 from PyQt5.QtCore import Qt
12 from PyQt5.QtGui import QColor, QFont, QPen, QPixmap
13 elif qt_config == 6:
14 from PyQt6.QtCore import Qt
15 from PyQt6.QtGui import QColor, QFont, QPen, QPixmap
17 # ------------------------------------------------------------------------------------------------------------
19 class Theme(object):
20 # enum PortType
21 THEME_PORT_SQUARE = 0
22 THEME_PORT_POLYGON = 1
24 # enum List
25 THEME_MODERN_DARK = 0
26 THEME_MODERN_DARK_TINY = 1
27 THEME_MODERN_LIGHT = 2
28 THEME_CLASSIC_DARK = 3
29 THEME_OOSTUDIO = 4
30 THEME_MAX = 5
32 # enum BackgroundType
33 THEME_BG_SOLID = 0
34 THEME_BG_GRADIENT = 1
36 def __init__(self, idx):
37 object.__init__(self)
39 self.idx = idx
41 if idx == self.THEME_MODERN_DARK:
42 # Canvas
43 self.canvas_bg = QColor(0, 0, 0)
45 # Boxes
46 self.box_pen = QPen(QColor(76, 77, 78), 1, Qt.SolidLine)
47 self.box_pen_sel = QPen(QColor(206, 207, 208), 1, Qt.DashLine)
48 self.box_bg_1 = QColor(32, 34, 35)
49 self.box_bg_2 = QColor(43, 47, 48)
50 self.box_shadow = QColor(89, 89, 89, 180)
51 self.box_header_pixmap = None
52 self.box_header_height = 24
53 self.box_header_spacing = 0
55 self.box_text = QPen(QColor(240, 240, 240), 0)
56 self.box_text_sel = self.box_text
57 self.box_text_ypos = 16
58 self.box_font_name = "Deja Vu Sans"
59 self.box_font_size = 11
60 self.box_font_state = QFont.Bold
62 self.box_bg_type = self.THEME_BG_GRADIENT
63 self.box_use_icon = True
65 # Ports
66 self.port_text = QPen(QColor(250, 250, 250), 0)
67 self.port_text_ypos = 12
68 self.port_bg_pixmap = None
69 self.port_font_name = "Deja Vu Sans"
70 self.port_font_size = 11
71 self.port_font_state = QFont.Normal
72 self.port_mode = self.THEME_PORT_POLYGON
74 self.port_audio_jack_pen = QPen(QColor(63, 90, 126), 1)
75 self.port_audio_jack_pen_sel = QPen(QColor(63 + 30, 90 + 30, 126 + 30), 1)
76 self.port_midi_jack_pen = QPen(QColor(159, 44, 42), 1)
77 self.port_midi_jack_pen_sel = QPen(QColor(159 + 30, 44 + 30, 42 + 30), 1)
78 self.port_midi_alsa_pen = QPen(QColor(93, 141, 46), 1)
79 self.port_midi_alsa_pen_sel = QPen(QColor(93 + 30, 141 + 30, 46 + 30), 1)
80 self.port_parameter_pen = QPen(QColor(137, 76, 43), 1)
81 self.port_parameter_pen_sel = QPen(QColor(137 + 30, 76 + 30, 43 + 30), 1)
83 self.port_audio_jack_bg = QColor(35, 61, 99)
84 self.port_audio_jack_bg_sel = QColor(35 + 50, 61 + 50, 99 + 50)
85 self.port_midi_jack_bg = QColor(120, 15, 16)
86 self.port_midi_jack_bg_sel = QColor(120 + 50, 15 + 50, 16 + 50)
87 self.port_midi_alsa_bg = QColor(64, 112, 18)
88 self.port_midi_alsa_bg_sel = QColor(64 + 50, 112 + 50, 18 + 50)
89 self.port_parameter_bg = QColor(101, 47, 16)
90 self.port_parameter_bg_sel = QColor(101 + 50, 47 + 50, 16 + 50)
92 self.port_audio_jack_text = self.port_text
93 self.port_audio_jack_text_sel = self.port_text
94 self.port_midi_jack_text = self.port_text
95 self.port_midi_jack_text_sel = self.port_text
96 self.port_midi_alsa_text = self.port_text
97 self.port_midi_alsa_text_sel = self.port_text
98 self.port_parameter_text = self.port_text
99 self.port_parameter_text_sel = self.port_text
101 self.port_height = 16
102 self.port_offset = 0
103 self.port_spacing = 2
104 self.port_spacingT = 2
106 # Lines
107 self.line_audio_jack = QColor(63, 90, 126)
108 self.line_audio_jack_sel = QColor(63 + 90, 90 + 90, 126 + 90)
109 self.line_audio_jack_glow = QColor(100, 100, 200)
110 self.line_midi_jack = QColor(159, 44, 42)
111 self.line_midi_jack_sel = QColor(159 + 90, 44 + 90, 42 + 90)
112 self.line_midi_jack_glow = QColor(200, 100, 100)
113 self.line_midi_alsa = QColor(93, 141, 46)
114 self.line_midi_alsa_sel = QColor(93 + 90, 141 + 90, 46 + 90)
115 self.line_midi_alsa_glow = QColor(100, 200, 100)
116 self.line_parameter = QColor(137, 76, 43)
117 self.line_parameter_sel = QColor(137 + 90, 76 + 90, 43 + 90)
118 self.line_parameter_glow = QColor(166, 133, 133)
120 self.rubberband_pen = QPen(QColor(206, 207, 208), 1, Qt.SolidLine)
121 self.rubberband_brush = QColor(76, 77, 78, 100)
123 elif idx == self.THEME_MODERN_DARK_TINY:
124 # Canvas
125 self.canvas_bg = QColor(0, 0, 0)
127 # Boxes
128 self.box_pen = QPen(QColor(76, 77, 78), 1, Qt.SolidLine)
129 self.box_pen_sel = QPen(QColor(206, 207, 208), 1, Qt.DashLine)
130 self.box_bg_1 = QColor(32, 34, 35)
131 self.box_bg_2 = QColor(43, 47, 48)
132 self.box_shadow = QColor(89, 89, 89, 180)
133 self.box_header_pixmap = None
134 self.box_header_height = 14
135 self.box_header_spacing = 0
137 self.box_text = QPen(QColor(240, 240, 240), 0)
138 self.box_text_sel = self.box_text
139 self.box_text_ypos = 10
140 self.box_font_name = "Deja Vu Sans"
141 self.box_font_size = 10
142 self.box_font_state = QFont.Bold
144 self.box_bg_type = self.THEME_BG_GRADIENT
145 self.box_use_icon = False
147 # Ports
148 self.port_text = QPen(QColor(250, 250, 250), 0)
149 self.port_text_ypos = 9
150 self.port_bg_pixmap = None
151 self.port_font_name = "Deja Vu Sans"
152 self.port_font_size = 9
153 self.port_font_state = QFont.Normal
154 self.port_mode = self.THEME_PORT_POLYGON
156 self.port_audio_jack_pen = QPen(QColor(63, 90, 126), 1)
157 self.port_audio_jack_pen_sel = QPen(QColor(63 + 30, 90 + 30, 126 + 30), 1)
158 self.port_midi_jack_pen = QPen(QColor(159, 44, 42), 1)
159 self.port_midi_jack_pen_sel = QPen(QColor(159 + 30, 44 + 30, 42 + 30), 1)
160 self.port_midi_alsa_pen = QPen(QColor(93, 141, 46), 1)
161 self.port_midi_alsa_pen_sel = QPen(QColor(93 + 30, 141 + 30, 46 + 30), 1)
162 self.port_parameter_pen = QPen(QColor(137, 76, 43), 1)
163 self.port_parameter_pen_sel = QPen(QColor(137 + 30, 76 + 30, 43 + 30), 1)
165 self.port_audio_jack_bg = QColor(35, 61, 99)
166 self.port_audio_jack_bg_sel = QColor(35 + 50, 61 + 50, 99 + 50)
167 self.port_midi_jack_bg = QColor(120, 15, 16)
168 self.port_midi_jack_bg_sel = QColor(120 + 50, 15 + 50, 16 + 50)
169 self.port_midi_alsa_bg = QColor(64, 112, 18)
170 self.port_midi_alsa_bg_sel = QColor(64 + 50, 112 + 50, 18 + 50)
171 self.port_parameter_bg = QColor(101, 47, 16)
172 self.port_parameter_bg_sel = QColor(101 + 50, 47 + 50, 16 + 50)
174 self.port_audio_jack_text = self.port_text
175 self.port_audio_jack_text_sel = self.port_text
176 self.port_midi_jack_text = self.port_text
177 self.port_midi_jack_text_sel = self.port_text
178 self.port_midi_alsa_text = self.port_text
179 self.port_midi_alsa_text_sel = self.port_text
180 self.port_parameter_text = self.port_text
181 self.port_parameter_text_sel = self.port_text
183 self.port_height = 12
184 self.port_offset = 0
185 self.port_spacing = 1
186 self.port_spacingT = 1
188 # Lines
189 self.line_audio_jack = QColor(63, 90, 126)
190 self.line_audio_jack_sel = QColor(63 + 90, 90 + 90, 126 + 90)
191 self.line_audio_jack_glow = QColor(100, 100, 200)
192 self.line_midi_jack = QColor(159, 44, 42)
193 self.line_midi_jack_sel = QColor(159 + 90, 44 + 90, 42 + 90)
194 self.line_midi_jack_glow = QColor(200, 100, 100)
195 self.line_midi_alsa = QColor(93, 141, 46)
196 self.line_midi_alsa_sel = QColor(93 + 90, 141 + 90, 46 + 90)
197 self.line_midi_alsa_glow = QColor(100, 200, 100)
198 self.line_parameter = QColor(137, 76, 43)
199 self.line_parameter_sel = QColor(137 + 90, 76 + 90, 43 + 90)
200 self.line_parameter_glow = QColor(166, 133, 133)
202 self.rubberband_pen = QPen(QColor(206, 207, 208), 1, Qt.SolidLine)
203 self.rubberband_brush = QColor(76, 77, 78, 100)
205 elif idx == self.THEME_MODERN_LIGHT:
206 # Canvas
207 self.canvas_bg = QColor(248, 249, 250)
209 # Boxes
210 self.box_pen = QPen(QColor(176, 177, 178), 1, Qt.SolidLine)
211 self.box_pen_sel = QPen(QColor(1, 2, 3), 2, Qt.DashLine)
212 self.box_bg_1 = QColor(250, 250, 250)
213 self.box_bg_2 = QColor(200, 200, 200)
214 self.box_shadow = QColor(1, 1, 1, 100)
215 self.box_header_pixmap = None
216 self.box_header_height = 24
217 self.box_header_spacing = 0
219 self.box_text = QPen(QColor(1, 1, 1), 0)
220 self.box_text_sel = self.box_text
221 self.box_text_ypos = 16
222 self.box_font_name = "Ubuntu"
223 self.box_font_size = 11
224 self.box_font_state = QFont.Bold
226 self.box_bg_type = self.THEME_BG_GRADIENT
227 self.box_use_icon = True
229 # Ports
230 self.port_text = QPen(QColor(255, 255, 255), 1)
231 self.port_text_ypos = 12
232 self.port_bg_pixmap = None
233 self.port_font_name = "Ubuntu"
234 self.port_font_size = 11
235 self.port_font_state = QFont.Bold
236 self.port_mode = self.THEME_PORT_POLYGON
238 self.port_audio_jack_pen = QPen(QColor(103, 130, 166), 2)
239 self.port_audio_jack_pen_sel = QPen(QColor(103 + 136, 190 + 130, 226 + 130), 1)
240 self.port_midi_jack_pen = QPen(QColor(159, 44, 42), 1)
241 self.port_midi_jack_pen_sel = QPen(QColor(90 + 30, 44 + 30, 42 + 30), 1)
242 self.port_midi_alsa_pen = QPen(QColor(93, 141, 46), 1)
243 self.port_midi_alsa_pen_sel = QPen(QColor(93 + 30, 141 + 30, 46 + 30), 1)
244 self.port_parameter_pen = QPen(QColor(137, 76, 43), 1)
245 self.port_parameter_pen_sel = QPen(QColor(137 + 30, 76 + 30, 43 + 30), 1)
247 self.port_audio_jack_bg = QColor(0, 0, 180)
248 self.port_audio_jack_bg_sel = QColor(135 + 150, 161 + 150, 199 + 150)
249 self.port_midi_jack_bg = QColor(130, 15, 16)
250 self.port_midi_jack_bg_sel = QColor(90 + 30, 15 + 50, 16 + 50)
251 self.port_midi_alsa_bg = QColor(64, 112, 18)
252 self.port_midi_alsa_bg_sel = QColor(64 + 50, 112 + 50, 18 + 50)
253 self.port_parameter_bg = QColor(101, 47, 16)
254 self.port_parameter_bg_sel = QColor(101 + 50, 47 + 50, 16 + 50)
256 self.port_audio_jack_text = self.port_text
257 self.port_audio_jack_text_sel = self.port_text
258 self.port_midi_jack_text = self.port_text
259 self.port_midi_jack_text_sel = self.port_text
260 self.port_midi_alsa_text = self.port_text
261 self.port_midi_alsa_text_sel = self.port_text
262 self.port_parameter_text = self.port_text
263 self.port_parameter_text_sel = self.port_text
265 self.port_height = 16
266 self.port_offset = 0
267 self.port_spacing = 2
268 self.port_spacingT = 2
270 # Lines
271 self.line_audio_jack = QColor(63, 90, 126)
272 self.line_audio_jack_sel = QColor(63 + 63, 90 + 90, 126 + 90)
273 self.line_audio_jack_glow = QColor(100, 100, 200)
274 self.line_midi_jack = QColor(159, 44, 42)
275 self.line_midi_jack_sel = QColor(159 + 44, 44 + 90, 42 + 90)
276 self.line_midi_jack_glow = QColor(200, 100, 100)
277 self.line_midi_alsa = QColor(93, 141, 46)
278 self.line_midi_alsa_sel = QColor(93 + 90, 141 + 90, 46 + 90)
279 self.line_midi_alsa_glow = QColor(100, 200, 100)
280 self.line_parameter = QColor(137, 43, 43)
281 self.line_parameter_sel = QColor(137 + 90, 76 + 90, 43 + 90)
282 self.line_parameter_glow = QColor(166, 133, 133)
284 self.rubberband_pen = QPen(QColor(206, 207, 208), 1, Qt.SolidLine)
285 self.rubberband_brush = QColor(76, 77, 78, 100)
287 elif idx == self.THEME_CLASSIC_DARK:
288 # Canvas
289 self.canvas_bg = QColor(0, 0, 0)
291 # Boxes
292 self.box_pen = QPen(QColor(147 - 70, 151 - 70, 143 - 70), 2, Qt.SolidLine)
293 self.box_pen_sel = QPen(QColor(147, 151, 143), 2, Qt.DashLine)
294 self.box_bg_1 = QColor(30, 34, 36)
295 self.box_bg_2 = QColor(30, 34, 36)
296 self.box_shadow = QColor(89, 89, 89, 180)
297 self.box_header_pixmap = None
298 self.box_header_height = 19
299 self.box_header_spacing = 0
301 self.box_text = QPen(QColor(255, 255, 255), 0)
302 self.box_text_sel = self.box_text
303 self.box_text_ypos = 12
304 self.box_font_name = "Sans"
305 self.box_font_size = 12
306 self.box_font_state = QFont.Normal
308 self.box_bg_type = self.THEME_BG_GRADIENT
309 self.box_use_icon = False
311 # Ports
312 self.port_text = QPen(QColor(250, 250, 250), 0)
313 self.port_text_ypos = 11
314 self.port_bg_pixmap = None
315 self.port_font_name = "Sans"
316 self.port_font_size = 11
317 self.port_font_state = QFont.Normal
318 self.port_mode = self.THEME_PORT_SQUARE
320 self.port_audio_jack_pen = QPen(QColor(35, 61, 99), Qt.NoPen, 0)
321 self.port_audio_jack_pen_sel = QPen(QColor(255, 0, 0), Qt.NoPen, 0)
322 self.port_midi_jack_pen = QPen(QColor(120, 15, 16), Qt.NoPen, 0)
323 self.port_midi_jack_pen_sel = QPen(QColor(255, 0, 0), Qt.NoPen, 0)
324 self.port_midi_alsa_pen = QPen(QColor(63, 112, 19), Qt.NoPen, 0)
325 self.port_midi_alsa_pen_sel = QPen(QColor(255, 0, 0), Qt.NoPen, 0)
326 self.port_parameter_pen = QPen(QColor(101, 47, 17), Qt.NoPen, 0)
327 self.port_parameter_pen_sel = QPen(QColor(255, 0, 0), Qt.NoPen, 0)
329 self.port_audio_jack_bg = QColor(35, 61, 99)
330 self.port_audio_jack_bg_sel = QColor(255, 0, 0)
331 self.port_midi_jack_bg = QColor(120, 15, 16)
332 self.port_midi_jack_bg_sel = QColor(255, 0, 0)
333 self.port_midi_alsa_bg = QColor(63, 112, 19)
334 self.port_midi_alsa_bg_sel = QColor(255, 0, 0)
335 self.port_parameter_bg = QColor(101, 47, 17)
336 self.port_parameter_bg_sel = QColor(255, 0, 0)
338 self.port_audio_jack_text = self.port_text
339 self.port_audio_jack_text_sel = self.port_text
340 self.port_midi_jack_text = self.port_text
341 self.port_midi_jack_text_sel = self.port_text
342 self.port_midi_alsa_text = self.port_text
343 self.port_midi_alsa_text_sel = self.port_text
344 self.port_parameter_text = self.port_text
345 self.port_parameter_text_sel = self.port_text
347 self.port_height = 14
348 self.port_offset = 0
349 self.port_spacing = 1
350 self.port_spacingT = 0
352 # Lines
353 self.line_audio_jack = QColor(53, 78, 116)
354 self.line_audio_jack_sel = QColor(255, 0, 0)
355 self.line_audio_jack_glow = QColor(255, 0, 0)
356 self.line_midi_jack = QColor(139, 32, 32)
357 self.line_midi_jack_sel = QColor(255, 0, 0)
358 self.line_midi_jack_glow = QColor(255, 0, 0)
359 self.line_midi_alsa = QColor(81, 130, 36)
360 self.line_midi_alsa_sel = QColor(255, 0, 0)
361 self.line_midi_alsa_glow = QColor(255, 0, 0)
362 self.line_parameter = QColor(120, 65, 33)
363 self.line_parameter_sel = QColor(255, 0, 0)
364 self.line_parameter_glow = QColor(255, 0, 0)
366 self.rubberband_pen = QPen(QColor(147, 151, 143), 2, Qt.SolidLine)
367 self.rubberband_brush = QColor(35, 61, 99, 100)
369 elif idx == self.THEME_OOSTUDIO:
370 # Canvas
371 self.canvas_bg = QColor(11, 11, 11)
373 # Boxes
374 self.box_pen = QPen(QColor(76, 77, 78), 1, Qt.SolidLine)
375 self.box_pen_sel = QPen(QColor(189, 122, 214), 1, Qt.DashLine)
376 self.box_bg_1 = QColor(46, 46, 46)
377 self.box_bg_2 = QColor(23, 23, 23)
378 self.box_shadow = QColor(89, 89, 89, 180)
379 self.box_header_pixmap = QPixmap(":/bitmaps/canvas/frame_node_header.png")
380 self.box_header_height = 22
381 self.box_header_spacing = 6
383 self.box_text = QPen(QColor(144, 144, 144), 0)
384 self.box_text_sel = QPen(QColor(189, 122, 214), 0)
385 self.box_text_ypos = 16
386 self.box_font_name = "Deja Vu Sans"
387 self.box_font_size = 11
388 self.box_font_state = QFont.Bold
390 self.box_bg_type = self.THEME_BG_SOLID
391 self.box_use_icon = False
393 # Ports
394 normalPortBG = QColor(46, 46, 46)
395 selPortBG = QColor(23, 23, 23)
397 self.port_text = QPen(QColor(155, 155, 155), 0)
398 self.port_text_ypos = 14
399 self.port_bg_pixmap = QPixmap(":/bitmaps/canvas/frame_port_bg.png")
400 self.port_font_name = "Deja Vu Sans"
401 self.port_font_size = 11
402 self.port_font_state = QFont.Normal
403 self.port_mode = self.THEME_PORT_SQUARE
405 self.port_audio_jack_pen = QPen(selPortBG, 2)
406 self.port_audio_jack_pen_sel = QPen(QColor(1, 230, 238), 1)
407 self.port_midi_jack_pen = QPen(selPortBG, 2)
408 self.port_midi_jack_pen_sel = QPen(QColor(252, 118, 118), 1)
409 self.port_midi_alsa_pen = QPen(selPortBG, 2)
410 self.port_midi_alsa_pen_sel = QPen(QColor(129, 244, 118), 0)
411 self.port_parameter_pen = QPen(selPortBG, 2)
412 self.port_parameter_pen_sel = QPen(QColor(137, 76, 43), 1)
414 self.port_audio_jack_bg = normalPortBG
415 self.port_audio_jack_bg_sel = selPortBG
416 self.port_midi_jack_bg = normalPortBG
417 self.port_midi_jack_bg_sel = selPortBG
418 self.port_midi_alsa_bg = normalPortBG
419 self.port_midi_alsa_bg_sel = selPortBG
420 self.port_parameter_bg = normalPortBG
421 self.port_parameter_bg_sel = selPortBG
423 self.port_audio_jack_text = self.port_text
424 self.port_audio_jack_text_sel = self.port_audio_jack_pen_sel
425 self.port_midi_jack_text = self.port_text
426 self.port_midi_jack_text_sel = self.port_midi_jack_pen_sel
427 self.port_midi_alsa_text = self.port_text
428 self.port_midi_alsa_text_sel = self.port_midi_alsa_pen_sel
429 self.port_parameter_text = self.port_text
430 self.port_parameter_text_sel = self.port_parameter_pen_sel
432 # missing, ports 2
433 self.port_height = 21
434 self.port_offset = 1
435 self.port_spacing = 3
436 self.port_spacingT = 0
438 # Lines
439 self.line_audio_jack = QColor(64, 64, 64)
440 self.line_audio_jack_sel = QColor(1, 230, 238)
441 self.line_audio_jack_glow = QColor(100, 200, 100)
442 self.line_midi_jack = QColor(64, 64, 64)
443 self.line_midi_jack_sel = QColor(252, 118, 118)
444 self.line_midi_jack_glow = QColor(200, 100, 100)
445 self.line_midi_alsa = QColor(64, 64, 64)
446 self.line_midi_alsa_sel = QColor(129, 244, 118)
447 self.line_midi_alsa_glow = QColor(100, 200, 100)
448 self.line_parameter = QColor(64, 64, 64)
449 self.line_parameter_sel = QColor(137+90, 76+90, 43+90)
450 self.line_parameter_glow = QColor(166, 133, 133)
452 self.rubberband_pen = QPen(QColor(1, 230, 238), 2, Qt.SolidLine)
453 self.rubberband_brush = QColor(90, 90, 90, 100)
455 # ------------------------------------------------------------------------------------------------------------
457 def getDefaultTheme():
458 return Theme.THEME_MODERN_DARK
460 def getThemeName(idx):
461 if idx == Theme.THEME_MODERN_DARK:
462 return "Modern Dark"
463 if idx == Theme.THEME_MODERN_DARK_TINY:
464 return "Modern Dark (Tiny)"
465 if idx == Theme.THEME_MODERN_LIGHT:
466 return "Modern Light"
467 if idx == Theme.THEME_CLASSIC_DARK:
468 return "Classic Dark"
469 if idx == Theme.THEME_OOSTUDIO:
470 return "OpenOctave Studio"
471 return ""
473 def getDefaultThemeName():
474 return "Modern Dark"
476 # ------------------------------------------------------------------------------------------------------------