DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 6f218732774b8b49708d4b07137471d14d38614c
parent a895877f5ee3722a840b973b76bec7022cc93f86
Author: falkTX <falktx@falktx.com>
Date:   Tue, 18 May 2021 09:57:02 +0100

Build CairoUI by default now that DPF cairo APIs are going stable

Diffstat:
MMakefile | 8+++-----
Mdistrho/DistrhoUI.hpp | 3+++
Mexamples/CairoUI/CairoExampleUI.cpp | 8++++----
Mexamples/CairoUI/DemoWidgetBanner.cpp | 18++++++++----------
Mexamples/CairoUI/DemoWidgetBanner.hpp | 14+++++++++-----
Mexamples/CairoUI/DemoWidgetClickable.cpp | 18++++++++----------
Mexamples/CairoUI/DemoWidgetClickable.hpp | 14+++++++++-----
Mexamples/CairoUI/DistrhoPluginInfo.h | 4+++-
Mexamples/Parameters/Makefile | 1-
9 files changed, 47 insertions(+), 41 deletions(-)

diff --git a/Makefile b/Makefile @@ -26,11 +26,9 @@ examples: dgl $(MAKE) all -C examples/MidiThrough $(MAKE) all -C examples/Parameters $(MAKE) all -C examples/States - -# ifeq ($(HAVE_CAIRO),true) -# $(MAKE) all -C examples/CairoUI -# endif - +ifeq ($(HAVE_CAIRO),true) + $(MAKE) all -C examples/CairoUI +endif ifneq ($(MACOS_OR_WINDOWS),true) # ExternalUI is WIP $(MAKE) all -C examples/ExternalUI diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp @@ -27,6 +27,9 @@ typedef DISTRHO_NAMESPACE::ExternalWindow UIWidget; #elif DISTRHO_UI_USE_CUSTOM # include DISTRHO_UI_CUSTOM_INCLUDE_PATH typedef DISTRHO_UI_CUSTOM_WIDGET_TYPE UIWidget; +#elif DISTRHO_UI_USE_CAIRO +# include "../dgl/Cairo.hpp" +typedef DGL_NAMESPACE::CairoTopLevelWidget UIWidget; #elif DISTRHO_UI_USE_NANOVG # include "../dgl/NanoVG.hpp" typedef DGL_NAMESPACE::NanoTopLevelWidget UIWidget; diff --git a/examples/CairoUI/CairoExampleUI.cpp b/examples/CairoUI/CairoExampleUI.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com> + * Copyright (C) 2012-2021 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 @@ -17,7 +17,6 @@ #include "DistrhoUI.hpp" #include "DemoWidgetBanner.hpp" #include "DemoWidgetClickable.hpp" -#include "Window.hpp" START_NAMESPACE_DISTRHO @@ -42,9 +41,10 @@ public: { } - void onDisplay() +protected: + void onCairoDisplay(const CairoGraphicsContext& context) { - cairo_t* cr = getParentWindow().getGraphicsContext().cairo; + cairo_t* cr = context.handle; cairo_set_source_rgb(cr, 1.0, 0.8, 0.5); cairo_paint(cr); diff --git a/examples/CairoUI/DemoWidgetBanner.cpp b/examples/CairoUI/DemoWidgetBanner.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com> + * Copyright (C) 2012-2021 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 @@ -16,9 +16,6 @@ #include "DemoWidgetBanner.hpp" -#include "Cairo.hpp" -#include "Window.hpp" - START_NAMESPACE_DGL // ----------------------------------------------------------------------- @@ -54,14 +51,15 @@ enum columns = 72, }; -DemoWidgetBanner::DemoWidgetBanner(Widget* group) - : Widget(group) -{ -} +DemoWidgetBanner::DemoWidgetBanner(SubWidget* parent) + : CairoSubWidget(parent) {} + +DemoWidgetBanner::DemoWidgetBanner(TopLevelWidget* parent) + : CairoSubWidget(parent) {} -void DemoWidgetBanner::onDisplay() +void DemoWidgetBanner::onCairoDisplay(const CairoGraphicsContext& context) { - cairo_t* cr = getParentWindow().getGraphicsContext().cairo; + cairo_t* cr = context.handle; Size<uint> sz = getSize(); int w = sz.getWidth(); diff --git a/examples/CairoUI/DemoWidgetBanner.hpp b/examples/CairoUI/DemoWidgetBanner.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com> + * Copyright (C) 2012-2021 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 @@ -14,17 +14,21 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "Widget.hpp" +#pragma once + +#include "Cairo.hpp" START_NAMESPACE_DGL // ----------------------------------------------------------------------- -class DemoWidgetBanner : public Widget +class DemoWidgetBanner : public CairoSubWidget { public: - explicit DemoWidgetBanner(Widget* group); - void onDisplay() override; + explicit DemoWidgetBanner(SubWidget* parent); + explicit DemoWidgetBanner(TopLevelWidget* parent); +protected: + void onCairoDisplay(const CairoGraphicsContext& context) override; }; // ----------------------------------------------------------------------- diff --git a/examples/CairoUI/DemoWidgetClickable.cpp b/examples/CairoUI/DemoWidgetClickable.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com> + * Copyright (C) 2012-2021 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 @@ -16,21 +16,19 @@ #include "DemoWidgetClickable.hpp" -#include "Cairo.hpp" -#include "Window.hpp" - START_NAMESPACE_DGL // ----------------------------------------------------------------------- -DemoWidgetClickable::DemoWidgetClickable(Widget* group) - : Widget(group) -{ -} +DemoWidgetClickable::DemoWidgetClickable(SubWidget* parent) + : CairoSubWidget(parent) {} + +DemoWidgetClickable::DemoWidgetClickable(TopLevelWidget* parent) + : CairoSubWidget(parent) {} -void DemoWidgetClickable::onDisplay() +void DemoWidgetClickable::onCairoDisplay(const CairoGraphicsContext& context) { - cairo_t* cr = getParentWindow().getGraphicsContext().cairo; + cairo_t* cr = context.handle; Size<uint> sz = getSize(); int w = sz.getWidth(); diff --git a/examples/CairoUI/DemoWidgetClickable.hpp b/examples/CairoUI/DemoWidgetClickable.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com> + * Copyright (C) 2012-2021 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 @@ -14,17 +14,21 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "Widget.hpp" +#pragma once + +#include "Cairo.hpp" START_NAMESPACE_DGL // ----------------------------------------------------------------------- -class DemoWidgetClickable : public Widget +class DemoWidgetClickable : public CairoSubWidget { public: - explicit DemoWidgetClickable(Widget* group); - void onDisplay() override; + explicit DemoWidgetClickable(SubWidget* group); + explicit DemoWidgetClickable(TopLevelWidget* parent); +protected: + void onCairoDisplay(const CairoGraphicsContext& context) override; bool onMouse(const MouseEvent& event) override; private: diff --git a/examples/CairoUI/DistrhoPluginInfo.h b/examples/CairoUI/DistrhoPluginInfo.h @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com> + * Copyright (C) 2012-2021 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 @@ -116,3 +116,5 @@ By default this is set to @ref DISTRHO_PLUGIN_URI with "#UI" as suffix. */ #define DISTRHO_UI_URI DISTRHO_PLUGIN_URI "#UI" + +#define DISTRHO_UI_USE_CAIRO 1 diff --git a/examples/Parameters/Makefile b/examples/Parameters/Makefile @@ -21,7 +21,6 @@ FILES_UI = \ # -------------------------------------------------------------- # Do some magic -UI_TYPE = cairo include ../../Makefile.plugins.mk # --------------------------------------------------------------