Browse Source

Rework StandaloneWindow class

gh-pages
falkTX 11 years ago
parent
commit
ed61894c51
2 changed files with 30 additions and 32 deletions
  1. +27
    -30
      dgl/StandaloneWindow.hpp
  2. +3
    -2
      dgl/Window.hpp

+ 27
- 30
dgl/StandaloneWindow.hpp View File

@@ -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)
};



+ 3
- 2
dgl/Window.hpp View File

@@ -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)


Loading…
Cancel
Save