diff --git a/dpf/dgl/src/WindowPrivateData.cpp b/dpf/dgl/src/WindowPrivateData.cpp index 2105670..089cfd8 100644 --- a/dpf/dgl/src/WindowPrivateData.cpp +++ b/dpf/dgl/src/WindowPrivateData.cpp @@ -266,17 +266,6 @@ void Window::PrivateData::initPre(const uint width, const uint height, const boo #endif puglSetViewHint(view, PUGL_STENCIL_BITS, 8); -#if defined(DGL_USE_OPENGL3) || defined(DGL_USE_GLES3) - puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_FALSE); - puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 3); -#elif defined(DGL_USE_GLES2) - puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_FALSE); - puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 2); -#else - puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_TRUE); - puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 2); -#endif - // PUGL_SAMPLES ?? puglSetEventFunc(view, puglEventCallback); diff --git a/dpf/dgl/src/nanovg/nanovg.c b/dpf/dgl/src/nanovg/nanovg.c index 988e7ca..f30f361 100644 --- a/dpf/dgl/src/nanovg/nanovg.c +++ b/dpf/dgl/src/nanovg/nanovg.c @@ -32,6 +32,37 @@ #ifndef NVG_NO_STB #define STB_IMAGE_IMPLEMENTATION +#define stbi_convert_iphone_png_to_rgb dpf_stbi_convert_iphone_png_to_rgb +#define stbi_failure_reason dpf_stbi_failure_reason +#define stbi_hdr_to_ldr_gamma dpf_stbi_hdr_to_ldr_gamma +#define stbi_hdr_to_ldr_scale dpf_stbi_hdr_to_ldr_scale +#define stbi_image_free dpf_stbi_image_free +#define stbi_info dpf_stbi_info +#define stbi_info_from_callbacks dpf_stbi_info_from_callbacks +#define stbi_info_from_file dpf_stbi_info_from_file +#define stbi_info_from_memory dpf_stbi_info_from_memory +#define stbi_is_hdr dpf_stbi_is_hdr +#define stbi_is_hdr_from_callbacks dpf_stbi_is_hdr_from_callbacks +#define stbi_is_hdr_from_file dpf_stbi_is_hdr_from_file +#define stbi_is_hdr_from_memory dpf_stbi_is_hdr_from_memory +#define stbi_ldr_to_hdr_gamma dpf_stbi_ldr_to_hdr_gamma +#define stbi_ldr_to_hdr_scale dpf_stbi_ldr_to_hdr_scale +#define stbi_load dpf_stbi_load +#define stbi_load_from_callbacks dpf_stbi_load_from_callbacks +#define stbi_load_from_file dpf_stbi_load_from_file +#define stbi_load_from_memory dpf_stbi_load_from_memory +#define stbi_loadf dpf_stbi_loadf +#define stbi_loadf_from_callbacks dpf_stbi_loadf_from_callbacks +#define stbi_loadf_from_file dpf_stbi_loadf_from_file +#define stbi_loadf_from_memory dpf_stbi_loadf_from_memory +#define stbi_set_flip_vertically_on_load dpf_stbi_set_flip_vertically_on_load +#define stbi_set_unpremultiply_on_load dpf_stbi_set_unpremultiply_on_load +#define stbi_zlib_decode_buffer dpf_stbi_zlib_decode_buffer +#define stbi_zlib_decode_malloc dpf_stbi_zlib_decode_malloc +#define stbi_zlib_decode_malloc_guesssize dpf_stbi_zlib_decode_malloc_guesssize +#define stbi_zlib_decode_malloc_guesssize_headerflag dpf_stbi_zlib_decode_malloc_guesssize_headerflag +#define stbi_zlib_decode_noheader_buffer dpf_stbi_zlib_decode_noheader_buffer +#define stbi_zlib_decode_noheader_malloc dpf_stbi_zlib_decode_noheader_malloc #include "stb_image.h" #endif diff --git a/dpf/dgl/src/pugl.cpp b/dpf/dgl/src/pugl.cpp index 001d757..b5453b1 100644 --- a/dpf/dgl/src/pugl.cpp +++ b/dpf/dgl/src/pugl.cpp @@ -44,9 +44,6 @@ # ifdef DGL_CAIRO # include # endif -# ifdef DGL_OPENGL -# include -# endif # ifdef DGL_VULKAN # import # include @@ -204,17 +201,35 @@ bool puglBackendLeave(PuglView* const view) void puglSetMatchingBackendForCurrentBuild(PuglView* const view) { -#ifdef DGL_CAIRO + #ifdef DGL_CAIRO puglSetBackend(view, puglCairoBackend()); -#endif -#ifdef DGL_OPENGL + #endif + #ifdef DGL_OPENGL puglSetBackend(view, puglGlBackend()); -#endif -#ifdef DGL_VULKAN + #endif + #ifdef DGL_VULKAN puglSetBackend(view, puglVulkanBackend()); -#endif - if (view->backend == nullptr) + #endif + + if (view->backend != nullptr) + { + #ifdef DGL_OPENGL + #if defined(DGL_USE_OPENGL3) || defined(DGL_USE_GLES3) + puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_FALSE); + puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 3); + #elif defined(DGL_USE_GLES2) + puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_FALSE); + puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 2); + #else + puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_TRUE); + puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 2); + #endif + #endif + } + else + { puglSetBackend(view, puglStubBackend()); + } } // -------------------------------------------------------------------------------------------------------------------- @@ -406,12 +421,12 @@ PuglStatus puglSetSizeAndDefault(PuglView* view, uint width, uint height) void puglOnDisplayPrepare(PuglView*) { -#ifdef DGL_OPENGL + #ifdef DGL_OPENGL glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -# ifndef DGL_USE_GLES + #ifndef DGL_USE_OPENGL3 glLoadIdentity(); -# endif -#endif + #endif + #endif } // -------------------------------------------------------------------------------------------------------------------- @@ -419,24 +434,24 @@ void puglOnDisplayPrepare(PuglView*) void puglFallbackOnResize(PuglView* const view) { -#ifdef DGL_OPENGL + #ifdef DGL_OPENGL glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -# ifndef DGL_USE_GLES + #ifdef DGL_USE_OPENGL3 + glViewport(0, 0, static_cast(view->frame.width), static_cast(view->frame.height)); + #else glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, static_cast(view->frame.width), static_cast(view->frame.height), 0.0, 0.0, 1.0); glViewport(0, 0, static_cast(view->frame.width), static_cast(view->frame.height)); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); -# else - glViewport(0, 0, static_cast(view->frame.width), static_cast(view->frame.height)); -# endif -#else + #endif + #else return; // unused (void)view; -#endif + #endif } // -------------------------------------------------------------------------------------------------------------------- diff --git a/plugins/ProM/DistrhoUIProM.cpp b/plugins/ProM/DistrhoUIProM.cpp index 44190ac..36264a4 100644 --- a/plugins/ProM/DistrhoUIProM.cpp +++ b/plugins/ProM/DistrhoUIProM.cpp @@ -297,6 +297,14 @@ bool DistrhoUIProM::onKeyboard(const KeyboardEvent& ev) return true; } +bool DistrhoUIProM::onMouse(const MouseEvent& ev) +{ + if (ev.press) + getWindow().focus(); + + return false; +} + // ----------------------------------------------------------------------- UI* createUI() diff --git a/plugins/ProM/DistrhoUIProM.hpp b/plugins/ProM/DistrhoUIProM.hpp index 42e3c45..13fb8a1 100644 --- a/plugins/ProM/DistrhoUIProM.hpp +++ b/plugins/ProM/DistrhoUIProM.hpp @@ -49,6 +49,7 @@ protected: void onDisplay() override; bool onKeyboard(const KeyboardEvent&) override; + bool onMouse(const MouseEvent& ev) override; private: ScopedPointer fPM; diff --git a/plugins/ProM/ResizeHandle.hpp b/plugins/ProM/ResizeHandle.hpp index eb804cd..a307c97 100644 --- a/plugins/ProM/ResizeHandle.hpp +++ b/plugins/ProM/ResizeHandle.hpp @@ -16,18 +16,17 @@ #pragma once -#include "TopLevelWidget.hpp" -#include "Color.hpp" +#include "NanoVG.hpp" START_NAMESPACE_DGL /** Resize handle for DPF windows, will sit on bottom-right. */ -class ResizeHandle : public TopLevelWidget +class ResizeHandle : public NanoTopLevelWidget { public: /** Overloaded constructor, will fetch the window from an existing top-level widget. */ explicit ResizeHandle(TopLevelWidget* const tlw) - : TopLevelWidget(tlw->getWindow()), + : NanoTopLevelWidget(tlw->getWindow()), handleSize(16), hasCursor(false), isResizing(false) @@ -44,22 +43,19 @@ public: } protected: - void onDisplay() override + void onNanoDisplay() override { - const GraphicsContext& context(getGraphicsContext()); const double lineWidth = 1.0 * getScaleFactor(); - - glMatrixMode(GL_MODELVIEW); - glLineWidth(lineWidth); + strokeWidth(lineWidth); // draw white lines, 1px wide - glColor3f(1.0f, 1.0f, 1.0f); + strokeColor(Color(1.0f, 1.0f, 1.0f)); drawLine(l1); drawLine(l2); drawLine(l3); // draw black lines, offset by 1px and 1px wide - glColor3f(0.0f, 0.0f, 0.0f); + strokeColor(Color(0.0f, 0.0f, 0.0f)); Line l1b(l1), l2b(l2), l3b(l3); l1b.moveBy(lineWidth, lineWidth); l2b.moveBy(lineWidth, lineWidth); @@ -69,6 +65,14 @@ protected: drawLine(l3b); } + void drawLine(const Line& line) + { + beginPath(); + moveTo(line.getStartPos().getX(), line.getStartPos().getY()); + lineTo(line.getEndPos().getX(), line.getEndPos().getY()); + stroke(); + } + bool onMouse(const MouseEvent& ev) override { if (ev.button != 1) @@ -155,7 +159,7 @@ private: void resetArea() { const double scaleFactor = getScaleFactor(); - const uint margin = 0.0 * scaleFactor; + const uint margin = 1.5 * scaleFactor; const uint size = handleSize * scaleFactor; area = Rectangle(getWidth() - size - margin, @@ -187,25 +191,6 @@ private: l3.setEndPos(x + offset, y + linesize + offset); } - void drawLine(const Line& line) - { - drawLine(line.getStartPos(), line.getEndPos()); - } - - void drawLine(const Point& posStart, const Point& posEnd) - { - DISTRHO_SAFE_ASSERT_RETURN(posStart != posEnd,); - - glBegin(GL_LINES); - - { - glVertex2d(posStart.getX(), posStart.getY()); - glVertex2d(posEnd.getX(), posEnd.getY()); - } - - glEnd(); - } - DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ResizeHandle) };