DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit ed61894c516c765f17b9f746e11208f4304f51fa
parent ed0d3be276d8b0beaa28dc38eeb79a86db16e425
Author: falkTX <falktx@gmail.com>
Date:   Thu, 15 May 2014 20:49:05 +0100

Rework StandaloneWindow class

Diffstat:
Mdgl/StandaloneWindow.hpp | 57+++++++++++++++++++++++++++------------------------------
Mdgl/Window.hpp | 5+++--
2 files changed, 30 insertions(+), 32 deletions(-)

diff --git a/dgl/StandaloneWindow.hpp b/dgl/StandaloneWindow.hpp @@ -18,59 +18,56 @@ #define DGL_STANDALONE_WINDOW_HPP_INCLUDED #include "App.hpp" +#include "Widget.hpp" #include "Window.hpp" START_NAMESPACE_DGL // ----------------------------------------------------------------------- -class StandaloneWindow +class StandaloneWindow : public App, + public Window { public: StandaloneWindow() - : fApp(), - fWindow(fApp) - { - } - - App& getApp() noexcept - { - return fApp; - } - - Window& getWindow() noexcept - { - return fWindow; - } + : App(), + Window((App&)*this), + fWidget(nullptr) {} 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) }; diff --git a/dgl/Window.hpp b/dgl/Window.hpp @@ -76,9 +76,10 @@ private: PrivateData* const pData; friend class App; friend class Widget; + friend class StandaloneWindow; - void _addWidget(Widget* const widget); - void _removeWidget(Widget* const widget); + virtual void _addWidget(Widget* const widget); + virtual void _removeWidget(Widget* const widget); void _idle(); DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Window)