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: public:
SingleWidgetWindow(Application& app) SingleWidgetWindow(Application& app)
: Window(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()); setSize(fWidget.getSize());
setTitle(String("transient #") + String(++gWindowCount));
setTitle(title);
show(); show();
} }


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


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


private: private:
WIG fWidget; WIG fWidget;
bool fIsMain;
}; };


// ------------------------------------------------------ // ------------------------------------------------------
@@ -88,10 +77,10 @@ int main()
{ {
Application app; Application app;
SingleWidgetWindow<ExampleColorWidget> wColor(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(); app.exec();




Loading…
Cancel
Save