StoneyVCV v2
StoneyDSP Modules for VCV Rack 2.
Loading...
Searching...
No Matches
PanelWidget.hpp
Go to the documentation of this file.
1
31#pragma once
32
33#define STONEYVCV_COMPONENTLIBRARY_PANELWIDGET_HPP_INCLUDED 1
34
35#if defined (STONEYVCV_BUILD_COMPONENTLIBRARY)
36
37//==============================================================================
38
39#include <StoneyVCV.hpp>
45
46//==============================================================================
47
48#include <rack.hpp>
49#include <StoneyDSP/Core.hpp>
50
51//==============================================================================
52
53#include <string>
54#include <array>
55
56//==============================================================================
57
58namespace StoneyDSP
59{
64//==============================================================================
65
66namespace StoneyVCV
67{
72//==============================================================================
73
74namespace ComponentLibrary {
75struct ThemedPanelWidget; // forward-declaration
76}
77
87template <class TPanelWidget>
88inline TPanelWidget *createPanelWidget(::rack::math::Rect box);
89
90//==============================================================================
91
92namespace ComponentLibrary
93{
98//==============================================================================
99
107{
108
109 //==========================================================================
110
111public:
112
114
115 //==========================================================================
116
122
128 PanelBorderWidget(::rack::math::Rect newBox);
129
135
136 //==========================================================================
137
144 virtual void draw(const ::StoneyDSP::StoneyVCV::ComponentLibrary::PanelBorderWidget::DrawArgs &args) override;
145
146 //==========================================================================
147
149
150 //==========================================================================
151
152private:
153
154 //==========================================================================
155
156 const ::NVGcolor &borderColor = ::StoneyDSP::StoneyVCV::Panels::borderColor;
157
158 //==========================================================================
159
162};
163
164//==============================================================================
165
173{
174
175 //==========================================================================
176
177public:
178
180
181 //==========================================================================
182
188
194 PanelLinesWidget(::rack::math::Rect newBox);
195
201
202 //==========================================================================
203
210 virtual void draw(const ::StoneyDSP::StoneyVCV::ComponentLibrary::PanelLinesWidget::DrawArgs &args) override;
211
212 //==========================================================================
213
215
216 //==========================================================================
217
218private:
219
220 //==========================================================================
221
222 const ::NVGcolor &borderColor = ::StoneyDSP::StoneyVCV::Panels::borderColor;
223
224 //==========================================================================
225
228};
229
230//==============================================================================
231
236struct ThemedPanelWidget : virtual ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedWidget
237{
238
239 //==========================================================================
240
241public:
242
244
245 //==========================================================================
246
252 ThemedPanelWidget(::rack::math::Rect newBox);
253
259
260 //==========================================================================
261
268
275 virtual void draw(const ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget::DrawArgs &args) override;
276
277 //==========================================================================
278
285 virtual void onPrefersDarkPanelsChange(const PrefersDarkPanelsChangeEvent& e) override;
286
287 //==========================================================================
288
289 const ::std::size_t &getNumScrews() const noexcept;
290
291 void setNumScrews(const ::std::size_t &newNumScrews);
292
293 //==========================================================================
294
295 const ::std::size_t &getNumPorts() const noexcept;
296
297 void setNumPorts(const ::std::size_t &newNumPorts);
298
299 //==========================================================================
300
301 const ::std::size_t &getNumParams() const noexcept;
302
303 void setNumParams(const ::std::size_t &newNumParams);
304
305 //==========================================================================
306
307 const ::std::size_t &getNumLights() const noexcept;
308
309 void setNumLights(const ::std::size_t &newNumLights);
310
311 //==========================================================================
312
313 ::StoneyDSP::StoneyVCV::ComponentLibrary::FramebufferWidget &getFrameBufferWidget() noexcept;
314
315 //==========================================================================
316
317 ::std::vector<::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget *> &getPortPanelWidgets() noexcept;
318
319 ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget &getPortPanelWidget(const ::std::size_t &i) noexcept(false);
320
321 //==========================================================================
322
323 ::std::vector<::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedParamPanelWidget *> &getParamPanelWidgets() noexcept;
324
325 ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedParamPanelWidget &getParamPanelWidget(const ::std::size_t &i) noexcept(false);
326
327 //==========================================================================
328
331
332 //==========================================================================
333
335
336 //==========================================================================
337
339 inline void addParamPanelWidget(::rack::math::Vec pos);
340
342 inline void addParamPanelWidgetCentered(::rack::math::Vec pos);
343
345 inline void addParamPanelWidgetSized(::rack::math::Vec pos, ::rack::math::Vec size);
346
348 inline void addParamPanelWidgetCenteredSized(::rack::math::Vec pos, ::rack::math::Vec size);
349
351 inline void addPortPanelWidget(::rack::math::Vec pos);
352
354 inline void addPortPanelWidgetCentered(::rack::math::Vec pos);
355
357 inline void addPortPanelWidgetSized(::rack::math::Vec pos, ::rack::math::Vec size);
358
360 inline void addPortPanelWidgetCenteredSized(::rack::math::Vec pos, ::rack::math::Vec size);
361
362 //==========================================================================
363
364 ::std::vector<::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedParamPanelWidget *> paramPanelWidgets = { NULL };
365
366
367 ::std::vector<::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget *> portPanelWidgets = { NULL };
368
369 //==========================================================================
370
371 ::std::size_t numScrews = 0U;
372
373 ::std::size_t numParams = 0U;
374
375 ::std::size_t numPorts = 0U;
376
377 ::std::size_t numLights = 0U;
378
379 //==========================================================================
380
395
396 //==========================================================================
397
403
409
410 //==========================================================================
411
416 ::std::array<::rack::math::Vec, 4> screwsPositions = { ::rack::math::Vec() };
417
422 ::std::array<::rack::componentlibrary::ThemedScrew *, 4> screws = { NULL };
423
424 //==========================================================================
425
426private:
427
428 //==========================================================================
429
433};
434
435//==============================================================================
436
438} // namespace ComponentLibrary
439
440//==============================================================================
441
443} // namespace StoneyVCV
444
445//==============================================================================
446
448} // namespace StoneyDSP
449
450//==============================================================================
451
452template <class TPanelWidget = ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget>
454{
455 static_assert(::std::is_base_of<::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget, TPanelWidget>::value, "TPanelWidget must be derived from StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget");
456
458 return o;
459}
460
461// Explicit instantiation to ensure the definition is visible to the linker
462template ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget *::StoneyDSP::StoneyVCV::createPanelWidget<::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget>(::rack::math::Rect box);
463
464//==============================================================================
465
478template <typename TParamPanelWidget = ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedParamPanelWidget>
479inline void ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget::addParamPanelWidget(::rack::math::Vec pos)
480{
481 this->paramPanelWidgets.emplace_back<TParamPanelWidget *>(
482 dynamic_cast<TParamPanelWidget *>(
484 )
485 );
486}
487
500template <typename TParamPanelWidget = ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedParamPanelWidget>
501inline void ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget::addParamPanelWidgetCentered(::rack::math::Vec pos)
502{
503 this->paramPanelWidgets.emplace_back<TParamPanelWidget *>(
504 dynamic_cast<TParamPanelWidget *>(
506 )
507 );
508}
509
523template <typename TParamPanelWidget = ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedParamPanelWidget>
524inline void ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget::addParamPanelWidgetSized(::rack::math::Vec pos, ::rack::math::Vec size)
525{
526 this->paramPanelWidgets.emplace_back<TParamPanelWidget *>(
527 dynamic_cast<TParamPanelWidget *>(
529 )
530 );
531}
532
546template <typename TParamPanelWidget = ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedParamPanelWidget>
547inline void ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget::addParamPanelWidgetCenteredSized(::rack::math::Vec pos, ::rack::math::Vec size)
548{
549 this->paramPanelWidgets.emplace_back<TParamPanelWidget *>(
550 dynamic_cast<TParamPanelWidget *>(
552 )
553 );
554}
555
568template <typename TPortPanelWidget = ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget>
569inline void ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget::addPortPanelWidget(::rack::math::Vec pos)
570{
571 this->portPanelWidgets.emplace_back<TPortPanelWidget *>(
572 dynamic_cast<TPortPanelWidget *>(
574 )
575 );
576}
577
590template <typename TPortPanelWidget = ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget>
591inline void ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget::addPortPanelWidgetCentered(::rack::math::Vec pos)
592{
593 this->portPanelWidgets.emplace_back<TPortPanelWidget *>(
594 dynamic_cast<TPortPanelWidget *>(
596 )
597 );
598}
599
613template <typename TPortPanelWidget = ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget>
614inline void ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget::addPortPanelWidgetSized(::rack::math::Vec pos, ::rack::math::Vec size)
615{
616 this->portPanelWidgets.emplace_back<TPortPanelWidget *>(
617 dynamic_cast<TPortPanelWidget *>(
619 )
620 );
621}
622
636template <typename TPortPanelWidget = ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortPanelWidget>
637inline void ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget::addPortPanelWidgetCenteredSized(::rack::math::Vec pos, ::rack::math::Vec size)
638{
639 this->portPanelWidgets.emplace_back<TPortPanelWidget *>(
640 dynamic_cast<TPortPanelWidget *>(
642 )
643 );
644}
645
646//==============================================================================
647
648#endif // STONEYVCV_BUILD_COMPONENTLIBRARY
649
650//==============================================================================
StoneyDSP Modules for VCV Rack 2.
StoneyDSP Modules for VCV Rack 2.
StoneyDSP Modules for VCV Rack 2.
StoneyDSP Modules for VCV Rack 2.
TPanelWidget * createPanelWidget(::rack::math::Rect box)
Definition PanelWidget.hpp:453
The StoneyDSP namespace.
Definition StoneyVCV.hpp:78
The PaneBorderWidget struct.
Definition PanelWidget.hpp:107
PanelBorderWidget()
Constructs a new PanelBorderWidget object.
const ::NVGcolor & borderColor
Definition PanelWidget.hpp:156
virtual void draw(const ::StoneyDSP::StoneyVCV::ComponentLibrary::PanelBorderWidget::DrawArgs &args) override
Draws a set of lines for spacing to the widget's NanoVG context.
::StoneyDSP::StoneyVCV::ComponentLibrary::TransparentWidget::DrawArgs DrawArgs
Definition PanelWidget.hpp:113
const ::NVGcolor & getBorderColor() const noexcept
virtual ~PanelBorderWidget() noexcept
Destroys the PanelBorderWidget object.
PanelBorderWidget(::rack::math::Rect newBox)
Construct a new PanelBorderWidget object with its' position and size set using a rack::math::Rect.
The PanelLinesWidget struct.
Definition PanelWidget.hpp:173
PanelLinesWidget(::rack::math::Rect newBox)
Construct a new PanelLinesWidget object with its' position and size set using a rack::math::Rect.
virtual ~PanelLinesWidget() noexcept
Destroys the PanelLinesWidget object.
PanelLinesWidget()
Constructs a new PanelLinesWidget object.
::StoneyDSP::StoneyVCV::ComponentLibrary::TransparentWidget::DrawArgs DrawArgs
Definition PanelWidget.hpp:179
The ThemedPanelWidget struct.
Definition PanelWidget.hpp:237
ThemedPanelWidget(::rack::math::Rect newBox)
Construct a new ThemedPanelWidget object with its' position and size set using a rack::math::Rect.
virtual ~ThemedPanelWidget() noexcept
Destroys the ThemedPanelWidget object.
::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedWidget::DrawArgs DrawArgs
Definition PanelWidget.hpp:243
The ThemedParamPanelWidget struct.
Definition ParamWidget.hpp:85
The ThemedPortPanelWidget struct.
Definition PortWidget.hpp:85
Occurs after the prefersDarkPanels setting is changed.
Definition Widget.hpp:294
The ThemedWidget struct.
Definition Widget.hpp:238
::StoneyDSP::StoneyVCV::ComponentLibrary::Widget::DrawArgs DrawArgs
Definition Widget.hpp:244
::StoneyDSP::StoneyVCV::ComponentLibrary::Widget::DrawArgs DrawArgs
Definition Widget.hpp:394
::rack::math::Rect box
Position relative to parent and size of Widget.
Definition Widget.hpp:182
virtual void step() override
Advances the Widget by one frame.
Definition StoneyVCV.hpp:125