Skip to content

Commit 3ef59a7

Browse files
committed
Tests for popup windows
Signed-off-by: falkTX <[email protected]>
1 parent 4434b45 commit 3ef59a7

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

dgl/Window.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ class DISTRHO_API Window
158158
*/
159159
virtual ~Window();
160160

161+
/**
162+
TEST.
163+
*/
164+
Window* createPopup();
165+
161166
/**
162167
Whether this Window is embed into another (usually not DGL-controlled) Window.
163168
*/
@@ -574,6 +579,9 @@ class DISTRHO_API Window
574579
bool usesSizeRequest,
575580
bool doPostInit);
576581

582+
/** @internal */
583+
explicit Window(Application& app, Window& transientParentWindow, uint type);
584+
577585
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Window)
578586
};
579587

dgl/src/Window.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ Window::Window(Application& app,
111111
pData->initPost();
112112
}
113113

114+
Window::Window(Application& app, Window& transientParentWindow, const uint type)
115+
: pData(new PrivateData(app, this, transientParentWindow.pData))
116+
{
117+
if (pData->view != nullptr)
118+
puglSetViewHint(pData->view, PUGL_VIEW_TYPE, type);
119+
120+
pData->initPost();
121+
}
122+
114123
Window::Window(Application& app,
115124
const uintptr_t parentWindowHandle,
116125
const uint width,
@@ -132,6 +141,11 @@ Window::~Window()
132141
delete pData;
133142
}
134143

144+
Window* Window::createPopup()
145+
{
146+
return new Window(pData->app, *this, PUGL_VIEW_TYPE_UTILITY);
147+
}
148+
135149
bool Window::isEmbed() const noexcept
136150
{
137151
return pData->isEmbed;

examples/FileHandling/FileHandlingUI.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class FileHandlingExampleUI : public UI,
4949
static const uint kInitialWidth = 600;
5050
static const uint kInitialHeight = 350;
5151

52+
ScopedPointer<Window> win;
53+
5254
FileHandlingExampleUI()
5355
: UI(kInitialWidth, kInitialHeight),
5456
fButton1(this, this),
@@ -70,6 +72,11 @@ class FileHandlingExampleUI : public UI,
7072
#endif
7173

7274
setGeometryConstraints(kInitialWidth, kInitialHeight, false);
75+
76+
win = getWindow().createPopup();
77+
win->setTitle("test1");
78+
win->setSize(300, 300);
79+
win->runAsModal();
7380
}
7481

7582
protected:

0 commit comments

Comments
 (0)