Skip to content

Commit 2a1b539

Browse files
committed
Add GUI scaling option
1 parent e0c1984 commit 2a1b539

174 files changed

Lines changed: 4638 additions & 3478 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AccumulativeRingMod/source/editor.cpp

Lines changed: 41 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@
88
#include <algorithm>
99
#include <random>
1010

11-
constexpr float uiTextSize = 12.0f;
12-
constexpr float pluginNameTextSize = 14.0f;
13-
constexpr float margin = 5.0f;
14-
constexpr float uiMargin = 20.0f;
15-
constexpr float labelWidth = 80.0f;
16-
constexpr float labelHeight = 20.0f;
17-
constexpr float labelY = labelHeight + 2 * margin;
18-
constexpr float halfLabelWidth = int(labelWidth / 2);
19-
20-
constexpr int_least32_t defaultWidth
21-
= int_least32_t(2 * uiMargin + 6 * labelWidth + 14 * margin);
22-
constexpr int_least32_t defaultHeight
23-
= int_least32_t(2 * uiMargin + 9 * labelY + 2 * labelWidth + 2 * margin);
24-
2511
namespace Steinberg {
2612
namespace Vst {
2713

@@ -30,9 +16,6 @@ using namespace VSTGUI;
3016
Editor::Editor(void *controller) : PlugEditor(controller)
3117
{
3218
param = std::make_unique<Synth::GlobalParameter>();
33-
34-
viewRect = ViewRect{0, 0, int32(defaultWidth), int32(defaultHeight)};
35-
setRect(viewRect);
3619
}
3720

3821
void Editor::syncUI(ParamID id, float normalized)
@@ -60,24 +43,24 @@ bool Editor::prepareUI()
6043
using Scales = Synth::Scales;
6144
using Style = Uhhyou::Style;
6245

63-
constexpr auto top0 = uiMargin;
64-
constexpr auto left0 = uiMargin;
46+
const auto top0 = uiMargin;
47+
const auto left0 = uiMargin;
6548

6649
// Misc.
67-
constexpr auto miscTop0 = top0;
68-
constexpr auto miscTop1 = miscTop0 + labelY;
69-
constexpr auto miscTop2 = miscTop1 + labelWidth;
70-
constexpr auto miscTop3 = miscTop2 + labelY;
71-
constexpr auto miscTop4 = miscTop3 + labelY;
72-
constexpr auto miscTop5 = miscTop4 + labelY;
73-
constexpr auto miscTop6 = miscTop5 + labelY;
74-
constexpr auto miscTop7 = miscTop6 + labelY;
75-
constexpr auto miscTop8 = miscTop7 + labelY;
76-
constexpr auto miscTop9 = miscTop8 + labelY;
77-
constexpr auto miscTop10 = miscTop9 + labelY;
78-
constexpr auto miscTop11 = miscTop10 + labelY;
79-
constexpr auto miscLeft0 = left0;
80-
constexpr auto miscLeft1 = miscLeft0 + labelWidth + 2 * margin;
50+
const auto miscTop0 = top0;
51+
const auto miscTop1 = miscTop0 + labelY;
52+
const auto miscTop2 = miscTop1 + labelWidth;
53+
const auto miscTop3 = miscTop2 + labelY;
54+
const auto miscTop4 = miscTop3 + labelY;
55+
const auto miscTop5 = miscTop4 + labelY;
56+
const auto miscTop6 = miscTop5 + labelY;
57+
const auto miscTop7 = miscTop6 + labelY;
58+
const auto miscTop8 = miscTop7 + labelY;
59+
const auto miscTop9 = miscTop8 + labelY;
60+
const auto miscTop10 = miscTop9 + labelY;
61+
const auto miscTop11 = miscTop10 + labelY;
62+
const auto miscLeft0 = left0;
63+
const auto miscLeft1 = miscLeft0 + labelWidth + 2 * margin;
8164

8265
addGroupLabel(
8366
miscLeft0, miscTop0, 2 * (labelWidth + margin), labelHeight, uiTextSize, "Gain");
@@ -119,16 +102,16 @@ bool Editor::prepareUI()
119102
oversamplingItems);
120103

121104
// Input Modulation.
122-
constexpr auto inTop0 = top0;
123-
constexpr auto inTop1 = inTop0 + labelY;
124-
constexpr auto inTop2 = inTop1 + labelY;
125-
constexpr auto inTop3 = inTop2 + labelY;
126-
constexpr auto inTop4 = inTop3 + labelY;
127-
constexpr auto inTop5 = inTop4 + labelY;
128-
constexpr auto inTop6 = inTop5 + labelY;
129-
constexpr auto inTop7 = inTop6 + labelY;
130-
constexpr auto inLeft0 = miscLeft0 + 2 * labelWidth + 6 * margin;
131-
constexpr auto inLeft1 = inLeft0 + labelWidth + 2 * margin;
105+
const auto inTop0 = top0;
106+
const auto inTop1 = inTop0 + labelY;
107+
const auto inTop2 = inTop1 + labelY;
108+
const auto inTop3 = inTop2 + labelY;
109+
const auto inTop4 = inTop3 + labelY;
110+
const auto inTop5 = inTop4 + labelY;
111+
const auto inTop6 = inTop5 + labelY;
112+
const auto inTop7 = inTop6 + labelY;
113+
const auto inLeft0 = miscLeft0 + 2 * labelWidth + 6 * margin;
114+
const auto inLeft1 = inLeft0 + labelWidth + 2 * margin;
132115

133116
addGroupLabel(inLeft0, inTop0, 2 * labelWidth, labelHeight, uiTextSize, "Main Input");
134117

@@ -163,16 +146,16 @@ bool Editor::prepareUI()
163146
ID::inputPostAsymmetryHarsh, Scales::defaultScale);
164147

165148
// Side chain Modulation.
166-
constexpr auto sideTop0 = top0;
167-
constexpr auto sideTop1 = sideTop0 + labelY;
168-
constexpr auto sideTop2 = sideTop1 + labelY;
169-
constexpr auto sideTop3 = sideTop2 + labelY;
170-
constexpr auto sideTop4 = sideTop3 + labelY;
171-
constexpr auto sideTop5 = sideTop4 + labelY;
172-
constexpr auto sideTop6 = sideTop5 + labelY;
173-
constexpr auto sideTop7 = sideTop6 + labelY;
174-
constexpr auto sideLeft0 = inLeft0 + 2 * labelWidth + 6 * margin;
175-
constexpr auto sideLeft1 = sideLeft0 + labelWidth + 2 * margin;
149+
const auto sideTop0 = top0;
150+
const auto sideTop1 = sideTop0 + labelY;
151+
const auto sideTop2 = sideTop1 + labelY;
152+
const auto sideTop3 = sideTop2 + labelY;
153+
const auto sideTop4 = sideTop3 + labelY;
154+
const auto sideTop5 = sideTop4 + labelY;
155+
const auto sideTop6 = sideTop5 + labelY;
156+
const auto sideTop7 = sideTop6 + labelY;
157+
const auto sideLeft0 = inLeft0 + 2 * labelWidth + 6 * margin;
158+
const auto sideLeft1 = sideLeft0 + labelWidth + 2 * margin;
176159

177160
addGroupLabel(
178161
sideLeft0, sideTop0, 2 * (labelWidth + margin), labelHeight, uiTextSize,
@@ -210,11 +193,11 @@ bool Editor::prepareUI()
210193
Scales::defaultScale);
211194

212195
// Plugin name.
213-
constexpr auto splashMargin = uiMargin;
214-
constexpr auto splashWidth = int(2 * labelWidth + 2 * margin);
215-
constexpr auto splashHeight = labelHeight + margin;
216-
constexpr auto splashTop = defaultHeight - uiMargin - splashHeight;
217-
constexpr auto splashLeft = left0;
196+
const auto splashMargin = uiMargin;
197+
const auto splashWidth = int(2 * labelWidth + 2 * margin);
198+
const auto splashHeight = labelHeight + margin;
199+
const auto splashTop = defaultHeight - uiMargin - splashHeight;
200+
const auto splashLeft = left0;
218201
addSplashScreen(
219202
splashLeft, splashTop, splashWidth, splashHeight, splashMargin, splashMargin,
220203
defaultWidth - 2 * splashMargin, defaultHeight - 2 * splashMargin, pluginNameTextSize,

AccumulativeRingMod/source/editor.hpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,39 @@ class Editor : public PlugEditor {
2121
DELEGATE_REFCOUNT(VSTGUIEditor);
2222

2323
private:
24+
float uiTextSize = 12.0f;
25+
float pluginNameTextSize = 14.0f;
26+
float margin = 5.0f;
27+
float uiMargin = 20.0f;
28+
float labelWidth = 80.0f;
29+
float labelHeight = 20.0f;
30+
float labelY = labelHeight + 2 * margin;
31+
float halfLabelWidth = int(labelWidth / 2);
32+
33+
int32_t defaultWidth = int32_t(2 * uiMargin + 6 * labelWidth + 14 * margin);
34+
int32_t defaultHeight
35+
= int32_t(2 * uiMargin + 9 * labelY + 2 * labelWidth + 2 * margin);
36+
37+
void setDimensions() override
38+
{
39+
const float sc = palette.guiScale();
40+
41+
uiTextSize = int(sc * 12);
42+
pluginNameTextSize = int(sc * 14);
43+
margin = int(sc * 5);
44+
uiMargin = int(sc * 20);
45+
labelWidth = int(sc * 80);
46+
labelHeight = int(sc * 20);
47+
labelY = labelHeight + 2 * margin;
48+
halfLabelWidth = int(labelWidth / 2);
49+
50+
defaultWidth = int32_t(2 * uiMargin + 6 * labelWidth + 14 * margin);
51+
defaultHeight = int32_t(2 * uiMargin + 9 * labelY + 2 * labelWidth + 2 * margin);
52+
53+
viewRect = ViewRect{0, 0, int32(defaultWidth), int32(defaultHeight)};
54+
setRect(viewRect);
55+
}
56+
2457
struct XYPadAxis {
2558
size_t index = 0;
2659
SharedPointer<XYPad> xypad;

AccumulativeRingMod/source/gui/splashdraw.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ void CreditView::draw(CDrawContext *pContext)
1717

1818
const auto width = getWidth();
1919
const auto height = getHeight();
20-
const double borderWidth = 2.0;
21-
const double halfBorderWidth = borderWidth / 2.0;
20+
const auto sc = pal.guiScale();
21+
const double borderWidth = int(sc * 2);
22+
const double halfBorderWidth = int(borderWidth / 2);
2223

2324
// Background.
2425
pContext->setLineWidth(borderWidth);
@@ -36,11 +37,13 @@ void CreditView::draw(CDrawContext *pContext)
3637
// Text.
3738
pContext->setFont(fontIdTitle);
3839
pContext->setFontColor(pal.foreground());
39-
pContext->drawString("AccumulativeRingMod " VERSION_STR, CPoint(20.0, 40.0));
40+
pContext->drawString(
41+
"AccumulativeRingMod " VERSION_STR, CPoint(int(sc * 20), int(sc * 40)));
4042

4143
pContext->setFont(fontIdText);
4244
pContext->setFontColor(pal.foreground());
43-
pContext->drawString("© 2023 Takamitsu Endo (ryukau@gmail.com)", CPoint(20.0f, 60.0f));
45+
pContext->drawString(
46+
"© 2023 Takamitsu Endo (ryukau@gmail.com)", CPoint(int(sc * 20), int(sc * 60)));
4447

4548
std::string leftText = R"(- Number & Knob -
4649
Shift + Left Drag|Fine Adjustment
@@ -67,12 +70,12 @@ CPU load rises when Phase Warp is not 0.
6770
6871
Have a nice day!)";
6972

70-
constexpr float top0 = 100.0f;
71-
constexpr float lineHeight = 20.0f;
72-
constexpr float blockWidth = 120.0f;
73-
drawTextBlock(pContext, 20.0f, top0, lineHeight, blockWidth, leftText);
73+
const float top0 = int(sc * 100);
74+
const float lineHeight = int(sc * 20);
75+
const float blockWidth = int(sc * 120);
76+
drawTextBlock(pContext, int(sc * 20), top0, lineHeight, blockWidth, leftText);
7477
drawTextBlock(
75-
pContext, int(width / 2) + 20.0f, top0, lineHeight, blockWidth, rightText);
78+
pContext, int(width / 2) + int(sc * 20), top0, lineHeight, blockWidth, rightText);
7679

7780
setDirty(false);
7881
}

BasicLimiter/source/editor.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,6 @@
99
#include <sstream>
1010
#include <string>
1111

12-
constexpr float uiTextSize = 12.0f;
13-
constexpr float midTextSize = 12.0f;
14-
constexpr float pluginNameTextSize = 14.0f;
15-
constexpr float margin = 5.0f;
16-
constexpr float uiMargin = 20.0f;
17-
constexpr float labelHeight = 20.0f;
18-
constexpr float labelY = 30.0f;
19-
constexpr float splashHeight = 30.0f;
20-
21-
constexpr float limiterLabelWidth = 100.0f;
22-
constexpr float checkboxWidth = 2.0f * limiterLabelWidth;
23-
24-
constexpr uint32_t defaultWidth = uint32_t(2 * uiMargin + 2 * limiterLabelWidth);
25-
constexpr uint32_t defaultHeight = uint32_t(2 * uiMargin + 8 * labelY + splashHeight);
26-
2712
namespace Steinberg {
2813
namespace Vst {
2914

@@ -32,9 +17,6 @@ using namespace VSTGUI;
3217
Editor::Editor(void *controller) : PlugEditor(controller)
3318
{
3419
param = std::make_unique<Synth::GlobalParameter>();
35-
36-
viewRect = ViewRect{0, 0, int32(defaultWidth), int32(defaultHeight)};
37-
setRect(viewRect);
3820
}
3921

4022
Editor::~Editor()

BasicLimiter/source/editor.hpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,44 @@ class Editor : public PlugEditor {
2222
DELEGATE_REFCOUNT(VSTGUIEditor);
2323

2424
protected:
25+
float uiTextSize = 12.0f;
26+
float midTextSize = 12.0f;
27+
float pluginNameTextSize = 14.0f;
28+
float margin = 5.0f;
29+
float uiMargin = 20.0f;
30+
float labelHeight = 20.0f;
31+
float labelY = 30.0f;
32+
float splashHeight = 30.0f;
33+
34+
float limiterLabelWidth = 100.0f;
35+
float checkboxWidth = 2.0f * limiterLabelWidth;
36+
37+
uint32_t defaultWidth = uint32_t(2 * uiMargin + 2 * limiterLabelWidth);
38+
uint32_t defaultHeight = uint32_t(2 * uiMargin + 8 * labelY + splashHeight);
39+
40+
void setDimensions() override
41+
{
42+
const float sc = palette.guiScale();
43+
44+
uiTextSize = sc * 12;
45+
midTextSize = sc * 12;
46+
pluginNameTextSize = sc * 14;
47+
margin = sc * 5;
48+
uiMargin = sc * 20;
49+
labelHeight = sc * 20;
50+
labelY = sc * 30;
51+
splashHeight = sc * 30;
52+
53+
limiterLabelWidth = sc * 100;
54+
checkboxWidth = 2 * limiterLabelWidth;
55+
56+
defaultWidth = uint32_t(2 * uiMargin + 2 * limiterLabelWidth);
57+
defaultHeight = uint32_t(2 * uiMargin + 8 * labelY + splashHeight);
58+
59+
viewRect = ViewRect{0, 0, int32(defaultWidth), int32(defaultHeight)};
60+
setRect(viewRect);
61+
}
62+
2563
TextTableView *infoTextView = nullptr;
2664
ParamValue getPlainValue(ParamID id);
2765
bool prepareUI() override;

BasicLimiter/source/gui/splashdraw.cpp

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ void CreditView::draw(CDrawContext *pContext)
1717

1818
const auto width = getWidth();
1919
const auto height = getHeight();
20-
const double borderWidth = 2.0;
21-
const double halfBorderWidth = borderWidth / 2.0;
20+
const auto sc = pal.guiScale();
21+
const double borderWidth = int(sc * 2);
22+
const double halfBorderWidth = int(borderWidth / 2);
2223

2324
// Background.
2425
pContext->setLineWidth(borderWidth);
@@ -27,23 +28,30 @@ void CreditView::draw(CDrawContext *pContext)
2728

2829
pContext->setFont(fontIdTitle);
2930
pContext->setFontColor(pal.foreground());
30-
pContext->drawString("BasicLimiter " VERSION_STR, CPoint(20.0, 30.0));
31+
pContext->drawString("BasicLimiter " VERSION_STR, CPoint(int(sc * 20), int(sc * 30)));
3132

3233
pContext->setFont(fontIdText);
3334
pContext->setFontColor(pal.foreground());
34-
pContext->drawString("© 2021 Takamitsu Endo", CPoint(20.0, 50.0));
35-
pContext->drawString(" (ryukau@gmail.com)", CPoint(20.0, 70.0));
35+
pContext->drawString("© 2021 Takamitsu Endo", CPoint(int(sc * 20), int(sc * 50)));
36+
pContext->drawString(" (ryukau@gmail.com)", CPoint(int(sc * 20), int(sc * 70)));
3637

37-
pContext->drawString("- Shift + Left Drag: Fine Adjustment", CPoint(20.0f, 100.0f));
38-
pContext->drawString("- Ctrl + Left Click: Reset to Default", CPoint(20.0f, 120.0f));
39-
pContext->drawString("- Middle Click: Toggle Min/Mid/Max", CPoint(20.0f, 140.0f));
40-
pContext->drawString("- Shift + Middle Click: Take Floor", CPoint(20.0f, 160.0f));
38+
pContext->drawString(
39+
"- Shift + Left Drag: Fine Adjustment", CPoint(int(sc * 20), int(sc * 100)));
40+
pContext->drawString(
41+
"- Ctrl + Left Click: Reset to Default", CPoint(int(sc * 20), int(sc * 120)));
42+
pContext->drawString(
43+
"- Middle Click: Toggle Min/Mid/Max", CPoint(int(sc * 20), int(sc * 140)));
44+
pContext->drawString(
45+
"- Shift + Middle Click: Take Floor", CPoint(int(sc * 20), int(sc * 160)));
4146

42-
pContext->drawString("If Overshoot is greater than 0 dB,", CPoint(20.0f, 190.0f));
43-
pContext->drawString("lower Threshold to avoid clipping.", CPoint(20.0f, 210.0f));
44-
pContext->drawString("It shows max sample peak over 0 dB.", CPoint(20.0f, 230.0f));
47+
pContext->drawString(
48+
"If Overshoot is greater than 0 dB,", CPoint(int(sc * 20), int(sc * 190)));
49+
pContext->drawString(
50+
"lower Threshold to avoid clipping.", CPoint(int(sc * 20), int(sc * 210)));
51+
pContext->drawString(
52+
"It shows max sample peak over 0 dB.", CPoint(int(sc * 20), int(sc * 230)));
4553

46-
pContext->drawString("Have a nice day!", CPoint(20.0f, 260.0f));
54+
pContext->drawString("Have a nice day!", CPoint(int(sc * 20), int(sc * 260)));
4755

4856
// Border.
4957
pContext->setFrameColor(isMouseEntered ? pal.highlightMain() : pal.border());

BasicLimiterAutoMake/source/editor.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,6 @@
99
#include <sstream>
1010
#include <string>
1111

12-
constexpr float uiTextSize = 12.0f;
13-
constexpr float midTextSize = 12.0f;
14-
constexpr float pluginNameTextSize = 14.0f;
15-
constexpr float margin = 5.0f;
16-
constexpr float uiMargin = 20.0f;
17-
constexpr float labelHeight = 20.0f;
18-
constexpr float labelY = 30.0f;
19-
constexpr float splashHeight = 30.0f;
20-
21-
constexpr float limiterLabelWidth = 100.0f;
22-
constexpr float checkboxWidth = 2.0f * limiterLabelWidth;
23-
24-
constexpr uint32_t defaultWidth = uint32_t(2 * uiMargin + 2 * limiterLabelWidth);
25-
constexpr uint32_t defaultHeight = uint32_t(2 * uiMargin + 10 * labelY + splashHeight);
26-
2712
namespace Steinberg {
2813
namespace Vst {
2914

@@ -32,9 +17,6 @@ using namespace VSTGUI;
3217
Editor::Editor(void *controller) : PlugEditor(controller)
3318
{
3419
param = std::make_unique<Synth::GlobalParameter>();
35-
36-
viewRect = ViewRect{0, 0, int32(defaultWidth), int32(defaultHeight)};
37-
setRect(viewRect);
3820
}
3921

4022
Editor::~Editor()

0 commit comments

Comments
 (0)