Browse Source

Tweak demo-multi, only close app when all windows close

pull/1/head
falkTX 6 years ago
parent
commit
421d7ab716
1 changed files with 8 additions and 19 deletions
  1. +8
    -19
      examples/demo-multi.cpp

+ 8
- 19
examples/demo-multi.cpp View File

@@ -42,22 +42,12 @@ class SingleWidgetWindow : public Window
public:
SingleWidgetWindow(Application& app)
: Window(app),
fWidget(*this),
fIsMain(true)
fWidget(*this)
{
setSize(fWidget.getSize());
setTitle("demo-multi");
show();
}
const String title = "demo-multi-" + String(++gWindowCount);

SingleWidgetWindow(Application& app, Window& parent)
: Window(app, parent),
fWidget(*this),
fIsMain(false)
{
setResizable(false);
setSize(fWidget.getSize());
setTitle(String("transient #") + String(++gWindowCount));
setTitle(title);
show();
}

@@ -72,13 +62,12 @@ protected:
{
Window::onClose();

if (fIsMain)
if (--gWindowCount == 0)
getApp().quit();
}

private:
WIG fWidget;
bool fIsMain;
};

// ------------------------------------------------------
@@ -88,10 +77,10 @@ int main()
{
Application app;
SingleWidgetWindow<ExampleColorWidget> wColor(app);
SingleWidgetWindow<ExampleImagesWidget> wImages(app, wColor);
SingleWidgetWindow<ExampleRectanglesWidget> wRects(app, wColor);
SingleWidgetWindow<ExampleShapesWidget> wShapes(app, wColor);
SingleWidgetWindow<ExampleTextWidget> wText(app, wColor);
SingleWidgetWindow<ExampleImagesWidget> wImages(app);
SingleWidgetWindow<ExampleRectanglesWidget> wRects(app);
SingleWidgetWindow<ExampleShapesWidget> wShapes(app);
SingleWidgetWindow<ExampleTextWidget> wText(app);

app.exec();



Loading…
Cancel
Save