| @@ -0,0 +1,82 @@ | |||
| // Copyright Jean Pierre Cimalando 2018. | |||
| // Distributed under the Boost Software License, Version 1.0. | |||
| // (See accompanying file LICENSE or copy at | |||
| // http://www.boost.org/LICENSE_1_0.txt) | |||
| #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); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,12 @@ | |||
| // Copyright Jean Pierre Cimalando 2018. | |||
| // Distributed under the Boost Software License, Version 1.0. | |||
| // (See accompanying file LICENSE or copy at | |||
| // http://www.boost.org/LICENSE_1_0.txt) | |||
| #include "Widget.hpp" | |||
| class DemoWidgetBanner : public Widget { | |||
| public: | |||
| explicit DemoWidgetBanner(Widget *group); | |||
| void onDisplay() override; | |||
| }; | |||
| @@ -0,0 +1,74 @@ | |||
| // Copyright Jean Pierre Cimalando 2018. | |||
| // Distributed under the Boost Software License, Version 1.0. | |||
| // (See accompanying file LICENSE or copy at | |||
| // http://www.boost.org/LICENSE_1_0.txt) | |||
| #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) { | |||
| Point<int> pos = getAbsolutePos(); | |||
| Size<uint> size = getSize(); | |||
| int mx = event.pos.getX(); | |||
| int my = event.pos.getY(); | |||
| int px = pos.getX(); | |||
| int py = pos.getY(); | |||
| bool inside = mx >= 0 && my >= 0 && | |||
| mx < size.getWidth() && my < size.getHeight(); | |||
| if (inside) { | |||
| colorid_ = (colorid_ + 1) % 3; | |||
| repaint(); | |||
| } | |||
| } | |||
| return Widget::onMouse(event); | |||
| } | |||
| @@ -0,0 +1,16 @@ | |||
| // Copyright Jean Pierre Cimalando 2018. | |||
| // Distributed under the Boost Software License, Version 1.0. | |||
| // (See accompanying file LICENSE or copy at | |||
| // http://www.boost.org/LICENSE_1_0.txt) | |||
| #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; | |||
| }; | |||
| @@ -0,0 +1,118 @@ | |||
| /* | |||
| * DISTRHO Plugin Framework (DPF) | |||
| * Copyright (C) 2012-2016 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. | |||
| */ | |||
| /** | |||
| The plugin name.@n | |||
| This is used to identify your plugin before a Plugin instance can be created. | |||
| @note This macro is required. | |||
| */ | |||
| #define DISTRHO_PLUGIN_NAME "Cairo DPF example" | |||
| /** | |||
| Number of audio inputs the plugin has. | |||
| @note This macro is required. | |||
| */ | |||
| #define DISTRHO_PLUGIN_NUM_INPUTS 1 | |||
| /** | |||
| Number of audio outputs the plugin has. | |||
| @note This macro is required. | |||
| */ | |||
| #define DISTRHO_PLUGIN_NUM_OUTPUTS 1 | |||
| /** | |||
| The plugin URI when exporting in LV2 format. | |||
| @note This macro is required. | |||
| */ | |||
| #define DISTRHO_PLUGIN_URI "urn:jpcima:cairo-dpf-example" | |||
| /** | |||
| Wherever the plugin has a custom %UI. | |||
| @see DISTRHO_UI_USE_NANOVG | |||
| @see UI | |||
| */ | |||
| #define DISTRHO_PLUGIN_HAS_UI 1 | |||
| /** | |||
| Wherever the plugin processing is realtime-safe.@n | |||
| TODO - list rtsafe requirements | |||
| */ | |||
| #define DISTRHO_PLUGIN_IS_RT_SAFE 1 | |||
| /** | |||
| Wherever the plugin is a synth.@n | |||
| @ref DISTRHO_PLUGIN_WANT_MIDI_INPUT is automatically enabled when this is too. | |||
| @see DISTRHO_PLUGIN_WANT_MIDI_INPUT | |||
| */ | |||
| #define DISTRHO_PLUGIN_IS_SYNTH 0 | |||
| /** | |||
| Enable direct access between the %UI and plugin code. | |||
| @see UI::getPluginInstancePointer() | |||
| @note DO NOT USE THIS UNLESS STRICTLY NECESSARY!! | |||
| Try to avoid it at all costs! | |||
| */ | |||
| #define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 0 | |||
| /** | |||
| Wherever the plugin introduces latency during audio or midi processing. | |||
| @see Plugin::setLatency(uint32_t) | |||
| */ | |||
| #define DISTRHO_PLUGIN_WANT_LATENCY 0 | |||
| /** | |||
| Wherever the plugin wants MIDI input.@n | |||
| This is automatically enabled if @ref DISTRHO_PLUGIN_IS_SYNTH is true. | |||
| */ | |||
| #define DISTRHO_PLUGIN_WANT_MIDI_INPUT 0 | |||
| /** | |||
| Wherever the plugin wants MIDI output. | |||
| @see Plugin::writeMidiEvent(const MidiEvent&) | |||
| */ | |||
| #define DISTRHO_PLUGIN_WANT_MIDI_OUTPUT 0 | |||
| /** | |||
| Wherever the plugin provides its own internal programs. | |||
| @see Plugin::initProgramName(uint32_t, String&) | |||
| @see Plugin::loadProgram(uint32_t) | |||
| */ | |||
| #define DISTRHO_PLUGIN_WANT_PROGRAMS 0 | |||
| /** | |||
| Wherever the plugin uses internal non-parameter data. | |||
| @see Plugin::initState(uint32_t, String&, String&) | |||
| @see Plugin::setState(const char*, const char*) | |||
| */ | |||
| #define DISTRHO_PLUGIN_WANT_STATE 0 | |||
| /** | |||
| Wherever the plugin wants time position information from the host. | |||
| @see Plugin::getTimePosition() | |||
| */ | |||
| #define DISTRHO_PLUGIN_WANT_TIMEPOS 0 | |||
| /** | |||
| Wherever the %UI uses NanoVG for drawing instead of the default raw OpenGL calls.@n | |||
| When enabled your %UI instance will subclass @ref NanoWidget instead of @ref Widget. | |||
| */ | |||
| #define DISTRHO_UI_USE_NANOVG 0 | |||
| /** | |||
| The %UI URI when exporting in LV2 format.@n | |||
| By default this is set to @ref DISTRHO_PLUGIN_URI with "#UI" as suffix. | |||
| */ | |||
| #define DISTRHO_UI_URI DISTRHO_PLUGIN_URI "#UI" | |||
| @@ -0,0 +1,23 @@ | |||
| Boost Software License - Version 1.0 - August 17th, 2003 | |||
| Permission is hereby granted, free of charge, to any person or organization | |||
| obtaining a copy of the software and accompanying documentation covered by | |||
| this license (the "Software") to use, reproduce, display, distribute, | |||
| execute, and transmit the Software, and to prepare derivative works of the | |||
| Software, and to permit third-parties to whom the Software is furnished to | |||
| do so, all subject to the following: | |||
| The copyright notices in the Software and this entire statement, including | |||
| the above license grant, this restriction and the following disclaimer, | |||
| must be included in all copies of the Software, in whole or in part, and | |||
| all derivative works of the Software, unless such copies or derivative | |||
| works are solely in the form of machine-executable object code generated by | |||
| a source language processor. | |||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
| FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | |||
| SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | |||
| FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | |||
| ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |||
| DEALINGS IN THE SOFTWARE. | |||
| @@ -0,0 +1,56 @@ | |||
| #!/usr/bin/make -f | |||
| # Makefile for DISTRHO Plugins # | |||
| # ---------------------------- # | |||
| # Created by falkTX | |||
| # | |||
| # -------------------------------------------------------------- | |||
| # Project name, used for binaries | |||
| NAME = d_cairoui | |||
| # -------------------------------------------------------------- | |||
| # Files to build | |||
| FILES_DSP = \ | |||
| PluginMain.cc | |||
| FILES_UI = \ | |||
| DemoWidgetBanner.cc \ | |||
| DemoWidgetClickable.cc \ | |||
| PluginUI.cc | |||
| # -------------------------------------------------------------- | |||
| # Do some magic | |||
| UI_TYPE = cairo | |||
| include ../../Makefile.plugins.mk | |||
| # -------------------------------------------------------------- | |||
| # Enable all possible plugin types | |||
| ifeq ($(HAVE_JACK),true) | |||
| ifeq ($(HAVE_CAIRO),true) | |||
| TARGETS += jack | |||
| endif | |||
| endif | |||
| ifeq ($(LINUX),true) | |||
| ifeq ($(HAVE_CAIRO),true) | |||
| ifeq ($(HAVE_LIBLO),true) | |||
| TARGETS += dssi | |||
| endif | |||
| endif | |||
| endif | |||
| ifeq ($(HAVE_CAIRO),true) | |||
| TARGETS += lv2_sep | |||
| else | |||
| TARGETS += lv2_dsp | |||
| endif | |||
| TARGETS += vst | |||
| all: $(TARGETS) | |||
| # -------------------------------------------------------------- | |||
| @@ -0,0 +1,60 @@ | |||
| // Copyright Jean Pierre Cimalando 2018. | |||
| // Distributed under the Boost Software License, Version 1.0. | |||
| // (See accompanying file LICENSE or copy at | |||
| // http://www.boost.org/LICENSE_1_0.txt) | |||
| #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 "Boost Software License"; | |||
| } | |||
| uint32_t ExamplePlugin::getVersion() const | |||
| { | |||
| return 0; | |||
| } | |||
| int64_t ExamplePlugin::getUniqueId() const | |||
| { | |||
| return 0; | |||
| } | |||
| void ExamplePlugin::initParameter(uint32_t index, Parameter ¶meter) | |||
| { | |||
| } | |||
| float ExamplePlugin::getParameterValue(uint32_t index) const | |||
| { | |||
| return 0; | |||
| } | |||
| void ExamplePlugin::setParameterValue(uint32_t index, float value) | |||
| { | |||
| } | |||
| 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; | |||
| } | |||
| @@ -0,0 +1,20 @@ | |||
| // Copyright Jean Pierre Cimalando 2018. | |||
| // Distributed under the Boost Software License, Version 1.0. | |||
| // (See accompanying file LICENSE or copy at | |||
| // http://www.boost.org/LICENSE_1_0.txt) | |||
| #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; | |||
| }; | |||
| @@ -0,0 +1,45 @@ | |||
| // Copyright Jean Pierre Cimalando 2018. | |||
| // Distributed under the Boost Software License, Version 1.0. | |||
| // (See accompanying file LICENSE or copy at | |||
| // http://www.boost.org/LICENSE_1_0.txt) | |||
| #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 index, float value) | |||
| { | |||
| } | |||
| UI *DISTRHO::createUI() | |||
| { | |||
| return new ExampleUI; | |||
| } | |||
| @@ -0,0 +1,21 @@ | |||
| // Copyright Jean Pierre Cimalando 2018. | |||
| // Distributed under the Boost Software License, Version 1.0. | |||
| // (See accompanying file LICENSE or copy at | |||
| // http://www.boost.org/LICENSE_1_0.txt) | |||
| #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_; | |||
| }; | |||