|
@@ -18,59 +18,56 @@ |
|
|
#define DGL_STANDALONE_WINDOW_HPP_INCLUDED |
|
|
#define DGL_STANDALONE_WINDOW_HPP_INCLUDED |
|
|
|
|
|
|
|
|
#include "App.hpp" |
|
|
#include "App.hpp" |
|
|
|
|
|
#include "Widget.hpp" |
|
|
#include "Window.hpp" |
|
|
#include "Window.hpp" |
|
|
|
|
|
|
|
|
START_NAMESPACE_DGL |
|
|
START_NAMESPACE_DGL |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------- |
|
|
// ----------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
class StandaloneWindow |
|
|
|
|
|
|
|
|
class StandaloneWindow : public App, |
|
|
|
|
|
public Window |
|
|
{ |
|
|
{ |
|
|
public: |
|
|
public: |
|
|
StandaloneWindow() |
|
|
StandaloneWindow() |
|
|
: fApp(), |
|
|
|
|
|
fWindow(fApp) |
|
|
|
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
App& getApp() noexcept |
|
|
|
|
|
{ |
|
|
|
|
|
return fApp; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Window& getWindow() noexcept |
|
|
|
|
|
{ |
|
|
|
|
|
return fWindow; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
: App(), |
|
|
|
|
|
Window((App&)*this), |
|
|
|
|
|
fWidget(nullptr) {} |
|
|
|
|
|
|
|
|
void exec() |
|
|
void exec() |
|
|
{ |
|
|
{ |
|
|
fWindow.show(); |
|
|
|
|
|
fApp.exec(); |
|
|
|
|
|
|
|
|
Window::show(); |
|
|
|
|
|
App::exec(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------- |
|
|
|
|
|
// helpers |
|
|
|
|
|
|
|
|
|
|
|
void setResizable(bool yesNo) |
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
|
void onReshape(int width, int height) override |
|
|
{ |
|
|
{ |
|
|
fWindow.setResizable(yesNo); |
|
|
|
|
|
|
|
|
if (fWidget != nullptr) |
|
|
|
|
|
{ |
|
|
|
|
|
fWidget->setSize(width, height); |
|
|
|
|
|
fWidget->onReshape(width, height); |
|
|
|
|
|
} |
|
|
|
|
|
Window::onReshape(width, height); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void setSize(uint width, uint height) |
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
Widget* fWidget; |
|
|
|
|
|
|
|
|
|
|
|
void _addWidget(Widget* const widget) override |
|
|
{ |
|
|
{ |
|
|
fWindow.setSize(width, height); |
|
|
|
|
|
|
|
|
if (fWidget == nullptr) |
|
|
|
|
|
fWidget = widget; |
|
|
|
|
|
Window::_addWidget(widget); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void setTitle(const char* title) |
|
|
|
|
|
|
|
|
void _removeWidget(Widget* const widget) override |
|
|
{ |
|
|
{ |
|
|
fWindow.setTitle(title); |
|
|
|
|
|
|
|
|
if (fWidget == widget) |
|
|
|
|
|
fWidget = nullptr; |
|
|
|
|
|
Window::_removeWidget(widget); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
|
App fApp; |
|
|
|
|
|
Window fWindow; |
|
|
|
|
|
|
|
|
|
|
|
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StandaloneWindow) |
|
|
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StandaloneWindow) |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|