Browse Source

Add demo-multi example, to test window transients

pull/1/head
falkTX 10 years ago
parent
commit
7df65aaf9f
4 changed files with 117 additions and 3 deletions
  1. +1
    -0
      .gitignore
  2. +1
    -1
      dpf
  3. +5
    -2
      examples/Makefile
  4. +110
    -0
      examples/demo-multi.cpp

+ 1
- 0
.gitignore View File

@@ -12,6 +12,7 @@
examples/app
examples/color
examples/demo
examples/demo-multi
examples/file-browser
examples/images
examples/nanovg


+ 1
- 1
dpf

@@ -1 +1 @@
Subproject commit a23c1f99fd38d394e145a01ffac051b5dad7e13c
Subproject commit 28822a20701a75444b755463daeb82e640e1ceea

+ 5
- 2
examples/Makefile View File

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



+ 110
- 0
examples/demo-multi.cpp View File

@@ -0,0 +1,110 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2014 Filipe Coelho <falktx@falktx.com>
*
* 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 WIG>
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<ExampleColorWidget> wColor(app);
SingleWidgetWindow<ExampleImagesWidget> wImages(app, wColor);
SingleWidgetWindow<ExampleRectanglesWidget> wRects(app, wColor);
SingleWidgetWindow<ExampleShapesWidget> wShapes(app, wColor);
SingleWidgetWindow<ExampleTextWidget> wText(app, wColor);

app.exec();

return 0;
}

// ------------------------------------------------------

Loading…
Cancel
Save