diff --git a/.gitignore b/.gitignore index 4bc9fc3..7fb69fc 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ examples/app examples/color examples/demo +examples/demo-multi examples/file-browser examples/images examples/nanovg diff --git a/dpf b/dpf index a23c1f9..28822a2 160000 --- a/dpf +++ b/dpf @@ -1 +1 @@ -Subproject commit a23c1f99fd38d394e145a01ffac051b5dad7e13c +Subproject commit 28822a20701a75444b755463daeb82e640e1ceea diff --git a/examples/Makefile b/examples/Makefile index eaec08c..65b9be9 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -16,9 +16,9 @@ WINDRES ?= windres # -------------------------------------------------------------- ifeq ($(WIN32),true) -TARGETS = app.exe color.exe demo.exe images.exe nanovg.exe rectangles.exe shapes.exe text.exe +TARGETS = app.exe color.exe demo.exe demo-multi images.exe nanovg.exe rectangles.exe shapes.exe text.exe else -TARGETS = app color demo images nanovg nanovg2 rectangles shapes text +TARGETS = app color demo demo-multi images nanovg nanovg2 rectangles shapes text endif # -------------------------------------------------------------- @@ -48,6 +48,9 @@ color: color.cpp widgets/ExampleColorWidget.hpp ../dpf/dgl/* demo: demo.cpp widgets/* ../dpf/dgl/* $(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ +demo-multi: demo-multi.cpp widgets/* ../dpf/dgl/* + $(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ + images: images.cpp widgets/ExampleImagesWidget.hpp images_res/* ../dpf/dgl/* $(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@ diff --git a/examples/demo-multi.cpp b/examples/demo-multi.cpp new file mode 100644 index 0000000..2464c38 --- /dev/null +++ b/examples/demo-multi.cpp @@ -0,0 +1,110 @@ +/* + * DISTRHO Plugin Framework (DPF) + * Copyright (C) 2012-2014 Filipe Coelho + * + * Permission to use, copy, modify, and/or distribute this software for any purpose with + * or without fee is hereby granted, provided that the above copyright notice and this + * permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +// ------------------------------------------------------ +// DGL Stuff + +#include "ImageButton.hpp" +#include "StandaloneWindow.hpp" +#include "widgets/ExampleColorWidget.hpp" +#include "widgets/ExampleImagesWidget.hpp" +#include "widgets/ExampleRectanglesWidget.hpp" +#include "widgets/ExampleShapesWidget.hpp" +#include "widgets/ExampleTextWidget.hpp" +#include "widgets/NanoPerfWidget.hpp" + +// ------------------------------------------------------ +// Images + +#include "demo_res/DemoArtwork.cpp" +#include "images_res/CatPics.cpp" + +// ------------------------------------------------------ +// use namespace + +using DGL::App; +using DGL::ImageButton; +using DGL::Line; +using DGL::Size; + +// ------------------------------------------------------ +// Single Widget Window + +static int gWindowCount = 0; + +template +class SingleWidgetWindow : public Window +{ +public: + SingleWidgetWindow(App& app) + : Window(app), + fWidget(*this), + fIsMain(true) + { + setSize(fWidget.getSize()); + setTitle("demo-multi"); + show(); + } + + SingleWidgetWindow(App& app, Window& parent) + : Window(app, parent), + fWidget(*this), + fIsMain(false) + { + setResizable(false); + setSize(fWidget.getSize()); + setTitle(d_string("transient #") + d_string(++gWindowCount)); + show(); + } + +protected: + void onReshape(uint width, uint height) override + { + fWidget.setSize(width, height); + Window::onReshape(width, height); + } + + void onClose() override + { + Window::onClose(); + + if (fIsMain) + getApp().quit(); + } + +private: + WIG fWidget; + bool fIsMain; +}; + +// ------------------------------------------------------ +// main entry point + +int main() +{ + App app; + SingleWidgetWindow wColor(app); + SingleWidgetWindow wImages(app, wColor); + SingleWidgetWindow wRects(app, wColor); + SingleWidgetWindow wShapes(app, wColor); + SingleWidgetWindow wText(app, wColor); + + app.exec(); + + return 0; +} + +// ------------------------------------------------------