Skip to content

Commit 8262811

Browse files
committed
Cleanup UI size code details
Signed-off-by: falkTX <[email protected]>
1 parent 826bd85 commit 8262811

File tree

4 files changed

+9
-43
lines changed

4 files changed

+9
-43
lines changed

dpf-widgets

plugins/ImGuiDemo/PluginUI.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,10 @@ class ImGuiDemoUI : public UI
1818
The UI should be initialized to a default state that matches the plugin side.
1919
*/
2020
ImGuiDemoUI()
21-
: UI(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT)
21+
: UI()
2222
{
2323
const double scaleFactor = getScaleFactor();
24-
25-
if (d_isEqual(scaleFactor, 1.0))
26-
{
27-
setGeometryConstraints(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT);
28-
}
29-
else
30-
{
31-
const uint width = DISTRHO_UI_DEFAULT_WIDTH * scaleFactor;
32-
const uint height = DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor;
33-
setGeometryConstraints(width, height);
34-
setSize(width, height);
35-
}
24+
setGeometryConstraints(DISTRHO_UI_DEFAULT_WIDTH * scaleFactor, DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor);
3625
}
3726

3827
protected:

plugins/TextEditor/PluginUI.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,10 @@ class TextEditorUI : public UI
2222
The UI should be initialized to a default state that matches the plugin side.
2323
*/
2424
TextEditorUI()
25-
: UI(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT)
25+
: UI()
2626
{
2727
const double scaleFactor = getScaleFactor();
28-
29-
if (d_isEqual(scaleFactor, 1.0))
30-
{
31-
setGeometryConstraints(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT);
32-
}
33-
else
34-
{
35-
const uint width = DISTRHO_UI_DEFAULT_WIDTH * scaleFactor;
36-
const uint height = DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor;
37-
setGeometryConstraints(width, height);
38-
setSize(width, height);
39-
}
28+
setGeometryConstraints(DISTRHO_UI_DEFAULT_WIDTH * scaleFactor, DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor);
4029

4130
showMenu();
4231
}
@@ -76,10 +65,10 @@ class TextEditorUI : public UI
7665
if (hasTextChangedSinceLastTime())
7766
{
7867
textChanged = true;
68+
// wait for first idle with no more text changes
7969
return;
8070
}
8171

82-
// wait for first idle with no more text changes
8372
if (textChanged)
8473
{
8574
textChanged = false;

plugins/WebBrowser/PluginUI.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,10 @@ class WebBrowserUI : public UI
3232
: UI(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT)
3333
{
3434
const double scaleFactor = getScaleFactor();
35-
36-
if (d_isEqual(scaleFactor, 1.0))
37-
{
38-
urlLabelHeight = 36;
39-
setGeometryConstraints(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT);
40-
}
41-
else
42-
{
43-
const uint width = DISTRHO_UI_DEFAULT_WIDTH * scaleFactor;
44-
const uint height = DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor;
45-
urlLabelHeight = 36 * scaleFactor;
46-
setGeometryConstraints(width, height);
47-
setSize(width, height);
48-
}
49-
35+
setGeometryConstraints(DISTRHO_UI_DEFAULT_WIDTH * scaleFactor, DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor);
5036
setFontSize(16);
37+
38+
urlLabelHeight = d_roundToUnsignedInt(36 * scaleFactor);
5139
}
5240

5341
protected:

0 commit comments

Comments
 (0)