From b4f40f60bd79fd53bd12ca2a8b8bf36ed8d3ab55 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 29 Jan 2019 14:19:11 +0100 Subject: [PATCH 1/8] Add Window::isEmbed() method, for convenience Signed-off-by: falkTX --- dgl/Window.hpp | 2 ++ dgl/src/Window.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/dgl/Window.hpp b/dgl/Window.hpp index 45b88b9f..3f980939 100644 --- a/dgl/Window.hpp +++ b/dgl/Window.hpp @@ -92,6 +92,8 @@ public: bool openFileBrowser(const FileBrowserOptions& options); #endif + bool isEmbed() const noexcept; + bool isVisible() const noexcept; void setVisible(bool yesNo); diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp index 1b3955c9..8fcb954c 100644 --- a/dgl/src/Window.cpp +++ b/dgl/src/Window.cpp @@ -1281,6 +1281,11 @@ bool Window::openFileBrowser(const FileBrowserOptions& options) } #endif +bool Window::isEmbed() const noexcept +{ + return pData->fUsingEmbed; +} + bool Window::isVisible() const noexcept { return pData->fVisible; From d9f3c75d20f50b11079b1a7db88acab9089779db Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Fri, 8 Feb 2019 14:11:44 +0100 Subject: [PATCH 2/8] Fix a build failure with parallel make (#129) --- dgl/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dgl/Makefile b/dgl/Makefile index 57a4da32..9d6f31a3 100644 --- a/dgl/Makefile +++ b/dgl/Makefile @@ -89,7 +89,7 @@ all: $(TARGETS) # Compat name, to be removed soon ../build/libdgl.a: ../build/libdgl-opengl.a @echo "Symlinking libdgl.a" - @ln -s $< $@ + @ln -sf $< $@ # --------------------------------------------------------------------------------------------------------------------- From 18e4533b4772ac7ffd35e4a2ca68603bdc116803 Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Fri, 8 Feb 2019 14:12:33 +0100 Subject: [PATCH 3/8] png2rgba: Support palette-based PNG files (#128) --- utils/png2rgba.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils/png2rgba.py b/utils/png2rgba.py index 3575db7a..81354be1 100755 --- a/utils/png2rgba.py +++ b/utils/png2rgba.py @@ -52,7 +52,10 @@ def png2rgba(namespace, filenames): shortFilename = filename.rsplit(os.sep, 1)[-1].split(".", 1)[0] shortFilename = shortFilename.replace("-", "_") - png = Image.open(filename) + png = Image.open(filename) + if png.getpalette(): + png = png.convert() + pngNumpy = numpy.array(png) pngData = pngNumpy.tolist() #pngData.reverse() From 8b4a301d6088cade779c4097a5f34fe743ebaadd Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Thu, 7 Feb 2019 21:24:00 +0100 Subject: [PATCH 4/8] Provide a DISTRHO_DEPRECATED attribute --- distrho/src/DistrhoDefines.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/distrho/src/DistrhoDefines.h b/distrho/src/DistrhoDefines.h index c14cfb8a..f16e44d5 100644 --- a/distrho/src/DistrhoDefines.h +++ b/distrho/src/DistrhoDefines.h @@ -66,6 +66,15 @@ # define nullptr NULL #endif +/* Define DISTRHO_DEPRECATED */ +#if defined(__GNUC__) +# define DISTRHO_DEPRECATED __attribute__((deprecated)) +#elif defined(_MSC_VER) +# define DISTRHO_DEPRECATED __declspec(deprecated) +#else +# define DISTRHO_DEPRECATED +#endif + /* Define DISTRHO_SAFE_ASSERT* */ #define DISTRHO_SAFE_ASSERT(cond) if (! (cond)) d_safe_assert(#cond, __FILE__, __LINE__); #define DISTRHO_SAFE_ASSERT_BREAK(cond) if (! (cond)) { d_safe_assert(#cond, __FILE__, __LINE__); break; } From 409c581f29601382547a7cd3d387518b765364ef Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Thu, 7 Feb 2019 21:27:59 +0100 Subject: [PATCH 5/8] Widget drawing with cairo in local coordinates --- dgl/src/WidgetPrivateData.cpp | 15 +++++++++++++++ examples/CairoUI/DemoWidgetBanner.cpp | 8 ++------ examples/CairoUI/DemoWidgetClickable.cpp | 14 +++++--------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/dgl/src/WidgetPrivateData.cpp b/dgl/src/WidgetPrivateData.cpp index fc3da447..005e4960 100644 --- a/dgl/src/WidgetPrivateData.cpp +++ b/dgl/src/WidgetPrivateData.cpp @@ -19,6 +19,9 @@ #ifdef DGL_OPENGL # include "../OpenGL.hpp" #endif +#ifdef DGL_CAIRO +# include "../Cairo.hpp" +#endif START_NAMESPACE_DGL @@ -73,6 +76,14 @@ void Widget::PrivateData::display(const uint width, } #endif +#ifdef DGL_CAIRO + cairo_t* cr = parent.getGraphicsContext().cairo; + cairo_matrix_t matrix; + cairo_get_matrix(cr, &matrix); + cairo_translate(cr, absolutePos.getX(), absolutePos.getY()); + // TODO: scaling with cairo +#endif + // display widget self->onDisplay(); @@ -84,6 +95,10 @@ void Widget::PrivateData::display(const uint width, } #endif +#ifdef DGL_CAIRO + cairo_set_matrix(cr, &matrix); +#endif + displaySubWidgets(width, height, scaling); } diff --git a/examples/CairoUI/DemoWidgetBanner.cpp b/examples/CairoUI/DemoWidgetBanner.cpp index 56a631dd..9835e38a 100644 --- a/examples/CairoUI/DemoWidgetBanner.cpp +++ b/examples/CairoUI/DemoWidgetBanner.cpp @@ -59,11 +59,7 @@ void DemoWidgetBanner::onDisplay() { cairo_t* cr = getParentWindow().getGraphicsContext().cairo; - Point pt = getAbsolutePos(); Size sz = getSize(); - - int x = pt.getX(); - int y = pt.getY(); int w = sz.getWidth(); int h = sz.getHeight(); @@ -75,8 +71,8 @@ void DemoWidgetBanner::onDisplay() { for (int c = 0; c < columns; ++c) { - double cx = x + xoff + radius + c * diameter; - double cy = y + yoff + radius + r * diameter; + double cx = xoff + radius + c * diameter; + double cy = yoff + radius + r * diameter; char ch = banner[c + r * columns]; if (ch != ' ') diff --git a/examples/CairoUI/DemoWidgetClickable.cpp b/examples/CairoUI/DemoWidgetClickable.cpp index 98ad4d6c..67843ff5 100644 --- a/examples/CairoUI/DemoWidgetClickable.cpp +++ b/examples/CairoUI/DemoWidgetClickable.cpp @@ -28,11 +28,7 @@ void DemoWidgetClickable::onDisplay() { cairo_t* cr = getParentWindow().getGraphicsContext().cairo; - Point pt = getAbsolutePos(); Size sz = getSize(); - - int x = pt.getX(); - int y = pt.getY(); int w = sz.getWidth(); int h = sz.getHeight(); @@ -48,17 +44,17 @@ void DemoWidgetClickable::onDisplay() cairo_set_source_rgb(cr, 0.0, 0.0, 0.75); break; } - cairo_rectangle(cr, x, y, w, h); + cairo_rectangle(cr, 0, 0, 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_move_to(cr, 0.25 * w, 0.25 * h); + cairo_line_to(cr, 0.75 * w, 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_move_to(cr, 0.75 * w, 0.25 * h); + cairo_line_to(cr, 0.25 * w, 0.75 * h); cairo_stroke(cr); } From 56076b1a02ce515a0e2e7022ce5decb6c5fcf8b8 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 12 Feb 2019 10:57:30 +0100 Subject: [PATCH 6/8] Cleanup, reorder cairo stuff to be first Signed-off-by: falkTX --- dgl/src/WidgetPrivateData.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dgl/src/WidgetPrivateData.cpp b/dgl/src/WidgetPrivateData.cpp index 005e4960..cef082b1 100644 --- a/dgl/src/WidgetPrivateData.cpp +++ b/dgl/src/WidgetPrivateData.cpp @@ -16,12 +16,12 @@ #include "WidgetPrivateData.hpp" -#ifdef DGL_OPENGL -# include "../OpenGL.hpp" -#endif #ifdef DGL_CAIRO # include "../Cairo.hpp" #endif +#ifdef DGL_OPENGL +# include "../OpenGL.hpp" +#endif START_NAMESPACE_DGL @@ -81,12 +81,16 @@ void Widget::PrivateData::display(const uint width, cairo_matrix_t matrix; cairo_get_matrix(cr, &matrix); cairo_translate(cr, absolutePos.getX(), absolutePos.getY()); - // TODO: scaling with cairo + // TODO: scaling and cropping #endif // display widget self->onDisplay(); +#ifdef DGL_CAIRO + cairo_set_matrix(cr, &matrix); +#endif + #ifdef DGL_OPENGL if (needsDisableScissor) { @@ -95,10 +99,6 @@ void Widget::PrivateData::display(const uint width, } #endif -#ifdef DGL_CAIRO - cairo_set_matrix(cr, &matrix); -#endif - displaySubWidgets(width, height, scaling); } From 28a4bfa26159aafcfbb1e1750b19caa561c34746 Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Thu, 7 Feb 2019 21:34:48 +0100 Subject: [PATCH 7/8] Add png2c, embedder of images in PNG format --- utils/png2c.py | 113 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100755 utils/png2c.py diff --git a/utils/png2c.py b/utils/png2c.py new file mode 100755 index 00000000..6dc3ae62 --- /dev/null +++ b/utils/png2c.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# DISTRHO Plugin Framework (DPF) +# Copyright (C) 2012-2019 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. + +import os, sys + +# ----------------------------------------------------- + +def png2c(namespace, filenames): + + fdH = open("%s.hpp" % namespace, "w") + fdH.write("/* (Auto-generated binary data file). */\n") + fdH.write("\n") + fdH.write("#ifndef BINARY_%s_HPP\n" % namespace.upper()) + fdH.write("#define BINARY_%s_HPP\n" % namespace.upper()) + fdH.write("\n") + fdH.write("namespace %s\n" % namespace) + fdH.write("{\n") + + fdC = open("%s.cpp" % namespace, "w") + fdC.write("/* (Auto-generated binary data file). */\n") + fdC.write("\n") + fdC.write("#include \"%s.hpp\"\n" % namespace) + fdC.write("\n") + + tempIndex = 1 + + for filename in filenames: + shortFilename = filename.rsplit(os.sep, 1)[-1].split(".", 1)[0] + shortFilename = shortFilename.replace("-", "_") + + pngData = open(filename, 'rb').read() + + print("Generating data for \"%s\"" % (filename)) + + fdH.write(" extern const char* %sData;\n" % shortFilename) + fdH.write(" const unsigned int %sDataSize = %i;\n" % (shortFilename, len(pngData))) + + if tempIndex != len(filenames): + fdH.write("\n") + + fdC.write("static const unsigned char temp_%s_%i[] = {\n" % (shortFilename, tempIndex)) + + curColumn = 1 + fdC.write(" ") + + for data in pngData: + if curColumn == 0: + fdC.write(" ") + + fdC.write(" %3u," % data) + + if curColumn > 20: + fdC.write("\n ") + curColumn = 1 + else: + curColumn += 1 + + fdC.write("};\n") + fdC.write("const char* %s::%sData = (const char*)temp_%s_%i;\n" % (namespace, shortFilename, shortFilename, tempIndex)) + + if tempIndex != len(filenames): + fdC.write("\n") + + tempIndex += 1 + + fdH.write("}\n") + fdH.write("\n") + fdH.write("#endif // BINARY_%s_HPP\n" % namespace.upper()) + fdH.write("\n") + fdH.close() + + fdC.write("\n") + fdC.close() + +# ----------------------------------------------------- + +if __name__ == '__main__': + if len(sys.argv) != 3: + print("Usage: %s " % sys.argv[0]) + quit() + + namespace = sys.argv[1].replace("-","_") + artFolder = sys.argv[2] + + if not os.path.exists(artFolder): + print("Folder '%s' does not exist" % artFolder) + quit() + + # find png files + pngFiles = [] + + for root, dirs, files in os.walk(artFolder): + for name in [name for name in files if name.lower().endswith(".png")]: + pngFiles.append(os.path.join(root, name)) + + pngFiles.sort() + + # create code now + png2c(namespace, pngFiles) From 19b04b65576ac8f2a50f0487c6bc981d144db9f2 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 12 Feb 2019 10:59:25 +0100 Subject: [PATCH 8/8] Fix shebang on python scripts Signed-off-by: falkTX --- utils/png2c.py | 2 +- utils/png2rgba.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/png2c.py b/utils/png2c.py index 6dc3ae62..ab023658 100755 --- a/utils/png2c.py +++ b/utils/png2c.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # DISTRHO Plugin Framework (DPF) diff --git a/utils/png2rgba.py b/utils/png2rgba.py index 81354be1..99a50899 100755 --- a/utils/png2rgba.py +++ b/utils/png2rgba.py @@ -1,8 +1,8 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # DISTRHO Plugin Framework (DPF) -# Copyright (C) 2012-2016 Filipe Coelho +# Copyright (C) 2012-2019 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