commit 943d9cdc1f8fba284b8063bb17e28440929590e2
parent 1f1302c319c8a0543e48b84da3918b605712730c
Author: JP Cimalando <jp-dev@inbox.ru>
Date: Sat, 12 Jan 2019 23:36:23 +0100
Cairo example (#108)
* Rewrite the Cairo example in matching code style
* Use of ScopedPointer in the Cairo example
Diffstat:
15 files changed, 394 insertions(+), 417 deletions(-)
diff --git a/examples/CairoUI/CairoExamplePlugin.cpp b/examples/CairoUI/CairoExamplePlugin.cpp
@@ -0,0 +1,89 @@
+/*
+ * DISTRHO Plugin Framework (DPF)
+ * Copyright (C) 2012-2019 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.
+ */
+
+#include "DistrhoPlugin.hpp"
+
+#include <string.h>
+
+START_NAMESPACE_DISTRHO
+
+class CairoExamplePlugin : public Plugin
+{
+public:
+ CairoExamplePlugin()
+ : Plugin(0, 0, 0)
+ {
+ }
+
+ const char* getLabel() const
+ {
+ return "Cairo DPF Example";
+ }
+
+ const char* getMaker() const
+ {
+ return "Jean Pierre Cimalando";
+ }
+
+ const char* getLicense() const
+ {
+ return "ISC";
+ }
+
+ uint32_t getVersion() const
+ {
+ return 0;
+ }
+
+ int64_t getUniqueId() const
+ {
+ return 0;
+ }
+
+ void initParameter(uint32_t index, Parameter& parameter)
+ {
+ // unused
+ (void)index;
+ (void)parameter;
+ }
+
+ float getParameterValue(uint32_t index) const
+ {
+ return 0;
+
+ // unused
+ (void)index;
+ }
+
+ void setParameterValue(uint32_t index, float value)
+ {
+ // unused
+ (void)index;
+ (void)value;
+ }
+
+ void run(const float** inputs, float** outputs, uint32_t frames)
+ {
+ memcpy(outputs[0], inputs[0], frames * sizeof(float));
+ }
+};
+
+Plugin* createPlugin()
+{
+ return new CairoExamplePlugin;
+}
+
+END_NAMESPACE_DISTRHO
diff --git a/examples/CairoUI/CairoExampleUI.cpp b/examples/CairoUI/CairoExampleUI.cpp
@@ -0,0 +1,70 @@
+/*
+ * DISTRHO Plugin Framework (DPF)
+ * Copyright (C) 2012-2019 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.
+ */
+
+#include "DistrhoUI.hpp"
+#include "DemoWidgetBanner.hpp"
+#include "DemoWidgetClickable.hpp"
+#include "Window.hpp"
+
+START_NAMESPACE_DISTRHO
+
+class CairoExampleUI : public UI
+{
+public:
+ CairoExampleUI()
+ : UI(200, 200)
+ {
+ DemoWidgetClickable* widgetClickable = new DemoWidgetClickable(this);
+ fWidgetClickable = widgetClickable;
+ widgetClickable->setSize(50, 50);
+ widgetClickable->setAbsolutePos(100, 100);
+
+ DemoWidgetBanner* widgetBanner = new DemoWidgetBanner(this);
+ fWidgetBanner = widgetBanner;
+ widgetBanner->setSize(180, 80);
+ widgetBanner->setAbsolutePos(10, 10);
+ }
+
+ ~CairoExampleUI()
+ {
+ }
+
+ void onDisplay()
+ {
+ cairo_t* cr = getParentWindow().getGraphicsContext().cairo;
+
+ cairo_set_source_rgb(cr, 1.0, 0.8, 0.5);
+ cairo_paint(cr);
+ }
+
+ void parameterChanged(uint32_t index, float value)
+ {
+ // unused
+ (void)index;
+ (void)value;
+ }
+
+private:
+ ScopedPointer<DemoWidgetClickable> fWidgetClickable;
+ ScopedPointer<DemoWidgetBanner> fWidgetBanner;
+};
+
+UI* createUI()
+{
+ return new CairoExampleUI;
+}
+
+END_NAMESPACE_DISTRHO
diff --git a/examples/CairoUI/DemoWidgetBanner.cc b/examples/CairoUI/DemoWidgetBanner.cc
@@ -1,93 +0,0 @@
-/*
- * DISTRHO Plugin Framework (DPF)
- * Copyright (C) 2012-2019 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.
- */
-
-#include "DemoWidgetBanner.h"
-
-#include "Cairo.hpp"
-#include "Window.hpp"
-
-static const char *banner =
-" "
-" * * * * * "
-" ** ** * * * * "
-" * * * * * * * "
-" * * * **** *** * **** * * ** **** * *** "
-" * * * * ** * * * * * * ** * "
-" * * ***** * * ****** * * * * * * * "
-" * * * * * * * * * * * * * * "
-" * * * ** * ** * * * * * * * * * * "
-" * * *** * *** * **** ** ** ***** ** * * "
-" "
-" "
-" "
-" ***** **** ***** "
-" * * * * * "
-" * * * * * "
-" * * * * * "
-" * * **** **** "
-" * * * * "
-" * * * * "
-" * * * * "
-" ***** * * "
-" ";
-
-enum {
- rows = 23,
- columns = 72,
-};
-
-DemoWidgetBanner::DemoWidgetBanner(Widget *group)
- : Widget(group)
-{
-}
-
-void DemoWidgetBanner::onDisplay()
-{
- cairo_t *cr = getParentWindow().getGraphicsContext().cairo;
-
- Point<int> pt = getAbsolutePos();
- Size<uint> sz = getSize();
-
- int x = pt.getX();
- int y = pt.getY();
- int w = sz.getWidth();
- int h = sz.getHeight();
-
- double diameter = (double)w / columns;
- double radius = 0.5 * diameter;
- double xoff = 0;
- double yoff = 0.5 * (h - rows * diameter);
- for (int r = 0; r < rows; ++r) {
- for (int c = 0; c < columns; ++c) {
- double cx = x + xoff + radius + c * diameter;
- double cy = y + yoff + radius + r * diameter;
-
- char ch = banner[c + r * columns];
- if (ch != ' ')
- cairo_set_source_rgb(cr, 0.5, 0.9, 0.2);
- else
- cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
-
- cairo_save(cr);
- cairo_translate(cr, cx, cy);
- cairo_scale(cr, radius, radius);
- cairo_arc(cr, 0.0, 0.0, 1.0, 0.0, 2 * M_PI);
- cairo_restore(cr);
-
- cairo_fill(cr);
- }
- }
-}
diff --git a/examples/CairoUI/DemoWidgetBanner.cpp b/examples/CairoUI/DemoWidgetBanner.cpp
@@ -0,0 +1,96 @@
+/*
+ * DISTRHO Plugin Framework (DPF)
+ * Copyright (C) 2012-2019 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.
+ */
+
+#include "DemoWidgetBanner.hpp"
+
+#include "Cairo.hpp"
+#include "Window.hpp"
+
+static const char* banner =
+" "
+" * * * * * "
+" ** ** * * * * "
+" * * * * * * * "
+" * * * **** *** * **** * * ** **** * *** "
+" * * * * ** * * * * * * ** * "
+" * * ***** * * ****** * * * * * * * "
+" * * * * * * * * * * * * * * "
+" * * * ** * ** * * * * * * * * * * "
+" * * *** * *** * **** ** ** ***** ** * * "
+" "
+" "
+" "
+" ***** **** ***** "
+" * * * * * "
+" * * * * * "
+" * * * * * "
+" * * **** **** "
+" * * * * "
+" * * * * "
+" * * * * "
+" ***** * * "
+" ";
+
+enum
+{
+ rows = 23,
+ columns = 72,
+};
+
+DemoWidgetBanner::DemoWidgetBanner(Widget* group)
+ : Widget(group)
+{
+}
+
+void DemoWidgetBanner::onDisplay()
+{
+ cairo_t* cr = getParentWindow().getGraphicsContext().cairo;
+
+ Point<int> pt = getAbsolutePos();
+ Size<uint> sz = getSize();
+
+ int x = pt.getX();
+ int y = pt.getY();
+ int w = sz.getWidth();
+ int h = sz.getHeight();
+
+ double diameter = (double)w / columns;
+ double radius = 0.5 * diameter;
+ double xoff = 0;
+ double yoff = 0.5 * (h - rows * diameter);
+ for (int r = 0; r < rows; ++r)
+ {
+ for (int c = 0; c < columns; ++c)
+ {
+ double cx = x + xoff + radius + c * diameter;
+ double cy = y + yoff + radius + r * diameter;
+
+ char ch = banner[c + r * columns];
+ if (ch != ' ')
+ cairo_set_source_rgb(cr, 0.5, 0.9, 0.2);
+ else
+ cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
+
+ cairo_save(cr);
+ cairo_translate(cr, cx, cy);
+ cairo_scale(cr, radius, radius);
+ cairo_arc(cr, 0.0, 0.0, 1.0, 0.0, 2 * M_PI);
+ cairo_restore(cr);
+
+ cairo_fill(cr);
+ }
+ }
+}
diff --git a/examples/CairoUI/DemoWidgetBanner.h b/examples/CairoUI/DemoWidgetBanner.h
@@ -1,23 +0,0 @@
-/*
- * DISTRHO Plugin Framework (DPF)
- * Copyright (C) 2012-2019 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.
- */
-
-#include "Widget.hpp"
-
-class DemoWidgetBanner : public Widget {
-public:
- explicit DemoWidgetBanner(Widget *group);
- void onDisplay() override;
-};
diff --git a/examples/CairoUI/DemoWidgetBanner.hpp b/examples/CairoUI/DemoWidgetBanner.hpp
@@ -0,0 +1,24 @@
+/*
+ * DISTRHO Plugin Framework (DPF)
+ * Copyright (C) 2012-2019 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.
+ */
+
+#include "Widget.hpp"
+
+class DemoWidgetBanner : public Widget
+{
+public:
+ explicit DemoWidgetBanner(Widget* group);
+ void onDisplay() override;
+};
diff --git a/examples/CairoUI/DemoWidgetClickable.cc b/examples/CairoUI/DemoWidgetClickable.cc
@@ -1,80 +0,0 @@
-/*
- * DISTRHO Plugin Framework (DPF)
- * Copyright (C) 2012-2019 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.
- */
-
-#include "DemoWidgetClickable.h"
-
-#include "Cairo.hpp"
-#include "Window.hpp"
-
-DemoWidgetClickable::DemoWidgetClickable(Widget *group)
- : Widget(group)
-{
-}
-
-void DemoWidgetClickable::onDisplay()
-{
- cairo_t *cr = getParentWindow().getGraphicsContext().cairo;
-
- Point<int> pt = getAbsolutePos();
- Size<uint> sz = getSize();
-
- int x = pt.getX();
- int y = pt.getY();
- int w = sz.getWidth();
- int h = sz.getHeight();
-
- switch (colorid_) {
- case 0:
- cairo_set_source_rgb(cr, 0.75, 0.0, 0.0);
- break;
- case 1:
- cairo_set_source_rgb(cr, 0.0, 0.75, 0.0);
- break;
- case 2:
- cairo_set_source_rgb(cr, 0.0, 0.0, 0.75);
- break;
- }
- cairo_rectangle(cr, x, y, w, h);
- cairo_fill(cr);
-
- cairo_set_source_rgb(cr, 0.9, 0.9, 0.9);
- cairo_new_path(cr);
- cairo_move_to(cr, x + 0.25 * w, y + 0.25 * h);
- cairo_line_to(cr, x + 0.75 * w, y + 0.75 * h);
- cairo_stroke(cr);
- cairo_new_path(cr);
- cairo_move_to(cr, x + 0.75 * w, y + 0.25 * h);
- cairo_line_to(cr, x + 0.25 * w, y + 0.75 * h);
- cairo_stroke(cr);
-}
-
-bool DemoWidgetClickable::onMouse(const MouseEvent &event)
-{
- if (event.press) {
- int w = getWidth();
- int h = getHeight();
- int mx = event.pos.getX();
- int my = event.pos.getY();
-
- bool inside = mx >= 0 && my >= 0 && mx < w && my < h;
- if (inside) {
- colorid_ = (colorid_ + 1) % 3;
- repaint();
- }
- }
-
- return Widget::onMouse(event);
-}
diff --git a/examples/CairoUI/DemoWidgetClickable.cpp b/examples/CairoUI/DemoWidgetClickable.cpp
@@ -0,0 +1,83 @@
+/*
+ * DISTRHO Plugin Framework (DPF)
+ * Copyright (C) 2012-2019 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.
+ */
+
+#include "DemoWidgetClickable.hpp"
+
+#include "Cairo.hpp"
+#include "Window.hpp"
+
+DemoWidgetClickable::DemoWidgetClickable(Widget* group)
+ : Widget(group)
+{
+}
+
+void DemoWidgetClickable::onDisplay()
+{
+ cairo_t* cr = getParentWindow().getGraphicsContext().cairo;
+
+ Point<int> pt = getAbsolutePos();
+ Size<uint> sz = getSize();
+
+ int x = pt.getX();
+ int y = pt.getY();
+ int w = sz.getWidth();
+ int h = sz.getHeight();
+
+ switch (fColorId)
+ {
+ case 0:
+ cairo_set_source_rgb(cr, 0.75, 0.0, 0.0);
+ break;
+ case 1:
+ cairo_set_source_rgb(cr, 0.0, 0.75, 0.0);
+ break;
+ case 2:
+ cairo_set_source_rgb(cr, 0.0, 0.0, 0.75);
+ break;
+ }
+ cairo_rectangle(cr, x, y, w, h);
+ cairo_fill(cr);
+
+ cairo_set_source_rgb(cr, 0.9, 0.9, 0.9);
+ cairo_new_path(cr);
+ cairo_move_to(cr, x + 0.25 * w, y + 0.25 * h);
+ cairo_line_to(cr, x + 0.75 * w, y + 0.75 * h);
+ cairo_stroke(cr);
+ cairo_new_path(cr);
+ cairo_move_to(cr, x + 0.75 * w, y + 0.25 * h);
+ cairo_line_to(cr, x + 0.25 * w, y + 0.75 * h);
+ cairo_stroke(cr);
+}
+
+bool DemoWidgetClickable::onMouse(const MouseEvent& event)
+{
+ if (event.press)
+ {
+ int w = getWidth();
+ int h = getHeight();
+ int mx = event.pos.getX();
+ int my = event.pos.getY();
+
+ bool inside = mx >= 0 && my >= 0 && mx < w && my < h;
+ if (inside)
+ {
+ fColorId = (fColorId + 1) % 3;
+ repaint();
+ }
+ }
+
+ return Widget::onMouse(event);
+}
diff --git a/examples/CairoUI/DemoWidgetClickable.h b/examples/CairoUI/DemoWidgetClickable.h
@@ -1,27 +0,0 @@
-/*
- * DISTRHO Plugin Framework (DPF)
- * Copyright (C) 2012-2019 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.
- */
-
-#include "Widget.hpp"
-
-class DemoWidgetClickable : public Widget {
-public:
- explicit DemoWidgetClickable(Widget *group);
- void onDisplay() override;
- bool onMouse(const MouseEvent &event) override;
-
-private:
- unsigned colorid_ = 0;
-};
diff --git a/examples/CairoUI/DemoWidgetClickable.hpp b/examples/CairoUI/DemoWidgetClickable.hpp
@@ -0,0 +1,28 @@
+/*
+ * DISTRHO Plugin Framework (DPF)
+ * Copyright (C) 2012-2019 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.
+ */
+
+#include "Widget.hpp"
+
+class DemoWidgetClickable : public Widget
+{
+public:
+ explicit DemoWidgetClickable(Widget* group);
+ void onDisplay() override;
+ bool onMouse(const MouseEvent& event) override;
+
+private:
+ unsigned fColorId = 0;
+};
diff --git a/examples/CairoUI/Makefile b/examples/CairoUI/Makefile
@@ -13,12 +13,12 @@ NAME = d_cairoui
# Files to build
FILES_DSP = \
- PluginMain.cc
+ CairoExamplePlugin.cpp
FILES_UI = \
- DemoWidgetBanner.cc \
- DemoWidgetClickable.cc \
- PluginUI.cc
+ DemoWidgetBanner.cpp \
+ DemoWidgetClickable.cpp \
+ CairoExampleUI.cpp
# --------------------------------------------------------------
# Do some magic
diff --git a/examples/CairoUI/PluginMain.cc b/examples/CairoUI/PluginMain.cc
@@ -1,71 +0,0 @@
-/*
- * DISTRHO Plugin Framework (DPF)
- * Copyright (C) 2012-2019 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.
- */
-
-#include "PluginMain.h"
-#include <string.h>
-
-ExamplePlugin::ExamplePlugin()
- : Plugin(0, 0, 0)
-{
-}
-
-const char *ExamplePlugin::getLabel() const
-{
- return "Cairo DPF Example";
-}
-
-const char *ExamplePlugin::getMaker() const
-{
- return "Jean Pierre Cimalando";
-}
-
-const char *ExamplePlugin::getLicense() const
-{
- return "ISC";
-}
-
-uint32_t ExamplePlugin::getVersion() const
-{
- return 0;
-}
-
-int64_t ExamplePlugin::getUniqueId() const
-{
- return 0;
-}
-
-void ExamplePlugin::initParameter(uint32_t, Parameter &)
-{
-}
-
-float ExamplePlugin::getParameterValue(uint32_t) const
-{
- return 0;
-}
-
-void ExamplePlugin::setParameterValue(uint32_t, float)
-{
-}
-
-void ExamplePlugin::run(const float **inputs, float **outputs, uint32_t frames)
-{
- memcpy(outputs[0], inputs[0], frames * sizeof(float));
-}
-
-Plugin *DISTRHO::createPlugin()
-{
- return new ExamplePlugin;
-}
diff --git a/examples/CairoUI/PluginMain.h b/examples/CairoUI/PluginMain.h
@@ -1,31 +0,0 @@
-/*
- * DISTRHO Plugin Framework (DPF)
- * Copyright (C) 2012-2019 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.
- */
-
-#include "DistrhoPlugin.hpp"
-
-class ExamplePlugin : public Plugin {
-public:
- ExamplePlugin();
- const char *getLabel() const override;
- const char *getMaker() const override;
- const char *getLicense() const override;
- uint32_t getVersion() const override;
- int64_t getUniqueId() const override;
- void initParameter(uint32_t index, Parameter ¶meter) override;
- float getParameterValue(uint32_t index) const override;
- void setParameterValue(uint32_t index, float value) override;
- void run(const float **inputs, float **outputs, uint32_t frames) override;
-};
diff --git a/examples/CairoUI/PluginUI.cc b/examples/CairoUI/PluginUI.cc
@@ -1,56 +0,0 @@
-/*
- * DISTRHO Plugin Framework (DPF)
- * Copyright (C) 2012-2019 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.
- */
-
-#include "PluginUI.h"
-#include "DemoWidgetClickable.h"
-#include "DemoWidgetBanner.h"
-
-#include "Window.hpp"
-
-ExampleUI::ExampleUI()
- : UI(200, 200)
-{
- DemoWidgetClickable *widget_clickable = new DemoWidgetClickable(this);
- widget_clickable_.reset(widget_clickable);
- widget_clickable->setSize(50, 50);
- widget_clickable->setAbsolutePos(100, 100);
-
- DemoWidgetBanner *widget_banner = new DemoWidgetBanner(this);
- widget_banner_.reset(widget_banner);
- widget_banner->setSize(180, 80);
- widget_banner->setAbsolutePos(10, 10);
-}
-
-ExampleUI::~ExampleUI()
-{
-}
-
-void ExampleUI::onDisplay()
-{
- cairo_t *cr = getParentWindow().getGraphicsContext().cairo;
-
- cairo_set_source_rgb(cr, 1.0, 0.8, 0.5);
- cairo_paint(cr);
-}
-
-void ExampleUI::parameterChanged(uint32_t, float)
-{
-}
-
-UI *DISTRHO::createUI()
-{
- return new ExampleUI;
-}
diff --git a/examples/CairoUI/PluginUI.h b/examples/CairoUI/PluginUI.h
@@ -1,32 +0,0 @@
-/*
- * DISTRHO Plugin Framework (DPF)
- * Copyright (C) 2012-2019 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.
- */
-
-#include "DistrhoUI.hpp"
-#include <memory>
-class DemoWidgetClickable;
-class DemoWidgetBanner;
-
-class ExampleUI : public UI {
-public:
- ExampleUI();
- ~ExampleUI();
- void onDisplay() override;
- void parameterChanged(uint32_t index, float value) override;
-
-private:
- std::unique_ptr<DemoWidgetClickable> widget_clickable_;
- std::unique_ptr<DemoWidgetBanner> widget_banner_;
- };