| @@ -369,7 +369,7 @@ public: | |||||
| bool operator==(const Line<T>& line) const noexcept; | bool operator==(const Line<T>& line) const noexcept; | ||||
| bool operator!=(const Line<T>& line) const noexcept; | bool operator!=(const Line<T>& line) const noexcept; | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| /** | /** | ||||
| Draw this line using the current OpenGL state.@n | Draw this line using the current OpenGL state.@n | ||||
| DEPRECATED Please use draw(const GraphicsContext&) instead. | DEPRECATED Please use draw(const GraphicsContext&) instead. | ||||
| @@ -487,7 +487,7 @@ public: | |||||
| bool operator==(const Circle<T>& cir) const noexcept; | bool operator==(const Circle<T>& cir) const noexcept; | ||||
| bool operator!=(const Circle<T>& cir) const noexcept; | bool operator!=(const Circle<T>& cir) const noexcept; | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| /** | /** | ||||
| Draw this circle using the current OpenGL state.@n | Draw this circle using the current OpenGL state.@n | ||||
| DEPRECATED Please use draw(const GraphicsContext&) instead. | DEPRECATED Please use draw(const GraphicsContext&) instead. | ||||
| @@ -580,7 +580,7 @@ public: | |||||
| bool operator==(const Triangle<T>& tri) const noexcept; | bool operator==(const Triangle<T>& tri) const noexcept; | ||||
| bool operator!=(const Triangle<T>& tri) const noexcept; | bool operator!=(const Triangle<T>& tri) const noexcept; | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| /** | /** | ||||
| Draw this triangle using the current OpenGL state.@n | Draw this triangle using the current OpenGL state.@n | ||||
| DEPRECATED Please use draw(const GraphicsContext&) instead. | DEPRECATED Please use draw(const GraphicsContext&) instead. | ||||
| @@ -811,7 +811,7 @@ public: | |||||
| bool operator==(const Rectangle<T>& size) const noexcept; | bool operator==(const Rectangle<T>& size) const noexcept; | ||||
| bool operator!=(const Rectangle<T>& size) const noexcept; | bool operator!=(const Rectangle<T>& size) const noexcept; | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| /** | /** | ||||
| Draw this rectangle using the current OpenGL state.@n | Draw this rectangle using the current OpenGL state.@n | ||||
| DEPRECATED Please use draw(const GraphicsContext&) instead. | DEPRECATED Please use draw(const GraphicsContext&) instead. | ||||
| @@ -274,7 +274,7 @@ public: | |||||
| inline void drawAt(const GraphicsContext& context, int x, int y) | inline void drawAt(const GraphicsContext& context, int x, int y) | ||||
| { drawAt(context, Point<int>(x, y)); } | { drawAt(context, Point<int>(x, y)); } | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| /** | /** | ||||
| Constructor using raw image data, specifying an OpenGL image format. | Constructor using raw image data, specifying an OpenGL image format. | ||||
| @note @a rawData must remain valid for the lifetime of this Image. | @note @a rawData must remain valid for the lifetime of this Image. | ||||
| @@ -479,6 +479,7 @@ public: | |||||
| */ | */ | ||||
| void setTransientParent(uintptr_t transientParentWindowHandle); | void setTransientParent(uintptr_t transientParentWindowHandle); | ||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| /** DEPRECATED Use isIgnoringKeyRepeat(). */ | /** DEPRECATED Use isIgnoringKeyRepeat(). */ | ||||
| DISTRHO_DEPRECATED_BY("isIgnoringKeyRepeat()") | DISTRHO_DEPRECATED_BY("isIgnoringKeyRepeat()") | ||||
| inline bool getIgnoringKeyRepeat() const noexcept { return isIgnoringKeyRepeat(); } | inline bool getIgnoringKeyRepeat() const noexcept { return isIgnoringKeyRepeat(); } | ||||
| @@ -490,6 +491,7 @@ public: | |||||
| /** DEPRECATED Use runAsModal(bool). */ | /** DEPRECATED Use runAsModal(bool). */ | ||||
| DISTRHO_DEPRECATED_BY("runAsModal(bool)") | DISTRHO_DEPRECATED_BY("runAsModal(bool)") | ||||
| inline void exec(bool blockWait = false) { runAsModal(blockWait); } | inline void exec(bool blockWait = false) { runAsModal(blockWait); } | ||||
| #endif | |||||
| protected: | protected: | ||||
| /** | /** | ||||
| @@ -528,12 +530,11 @@ protected: | |||||
| */ | */ | ||||
| virtual void onFocus(bool focus, CrossingMode mode); | virtual void onFocus(bool focus, CrossingMode mode); | ||||
| /** | |||||
| A function called when the window is resized. | |||||
| If there is a top-level widget associated with this window, its size will be set right after this function. | |||||
| The default implementation sets up drawing context where necessary. | |||||
| */ | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| /** DEPRECATED DO NOT USE */ | |||||
| DISTRHO_DEPRECATED | |||||
| virtual void onReshape(uint width, uint height); | virtual void onReshape(uint width, uint height); | ||||
| #endif | |||||
| /** | /** | ||||
| A function called when scale factor requested for this window changes. | A function called when scale factor requested for this window changes. | ||||
| @@ -542,7 +543,7 @@ protected: | |||||
| */ | */ | ||||
| virtual void onScaleFactorChanged(double scaleFactor); | virtual void onScaleFactorChanged(double scaleFactor); | ||||
| #ifdef DGL_USE_FILE_BROWSER | |||||
| #ifdef DGL_USE_FILE_BROWSER | |||||
| /** | /** | ||||
| A function called when a path is selected by the user, as triggered by openFileBrowser(). | A function called when a path is selected by the user, as triggered by openFileBrowser(). | ||||
| This action happens after the user confirms the action, so the file browser dialog will be closed at this point. | This action happens after the user confirms the action, so the file browser dialog will be closed at this point. | ||||
| @@ -550,10 +551,12 @@ protected: | |||||
| */ | */ | ||||
| virtual void onFileSelected(const char* filename); | virtual void onFileSelected(const char* filename); | ||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| /** DEPRECATED Use onFileSelected(). */ | /** DEPRECATED Use onFileSelected(). */ | ||||
| DISTRHO_DEPRECATED_BY("onFileSelected(const char*)") | DISTRHO_DEPRECATED_BY("onFileSelected(const char*)") | ||||
| inline virtual void fileBrowserSelected(const char* filename) { return onFileSelected(filename); } | inline virtual void fileBrowserSelected(const char* filename) { return onFileSelected(filename); } | ||||
| #endif | #endif | ||||
| #endif | |||||
| private: | private: | ||||
| PrivateData* const pData; | PrivateData* const pData; | ||||
| @@ -165,13 +165,11 @@ void Application::PrivateData::quit() | |||||
| isQuitting = true; | isQuitting = true; | ||||
| #ifndef DPF_TEST_APPLICATION_CPP | |||||
| for (WindowListReverseIterator rit = windows.rbegin(), rite = windows.rend(); rit != rite; ++rit) | for (WindowListReverseIterator rit = windows.rbegin(), rite = windows.rend(); rit != rite; ++rit) | ||||
| { | { | ||||
| DGL_NAMESPACE::Window* const window(*rit); | DGL_NAMESPACE::Window* const window(*rit); | ||||
| window->close(); | window->close(); | ||||
| } | } | ||||
| #endif | |||||
| } | } | ||||
| double Application::PrivateData::getTime() const | double Application::PrivateData::getTime() const | ||||
| @@ -23,6 +23,8 @@ | |||||
| #include "../Geometry.hpp" | #include "../Geometry.hpp" | ||||
| #define DGL_GEOMETRY_CPP_INCLUDED | |||||
| #include <cmath> | #include <cmath> | ||||
| START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
| @@ -1,6 +1,6 @@ | |||||
| /* | /* | ||||
| * DISTRHO Plugin Framework (DPF) | * DISTRHO Plugin Framework (DPF) | ||||
| * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com> | |||||
| * Copyright (C) 2012-2025 Filipe Coelho <falktx@falktx.com> | |||||
| * | * | ||||
| * Permission to use, copy, modify, and/or distribute this software for any purpose with | * 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 | * or without fee is hereby granted, provided that the above copyright notice and this | ||||
| @@ -1144,6 +1144,9 @@ inline void NanoBaseWidget<SubWidget>::onDisplay() | |||||
| onNanoDisplay(); | onNanoDisplay(); | ||||
| displayChildren(); | displayChildren(); | ||||
| NanoVG::endFrame(); | NanoVG::endFrame(); | ||||
| #ifdef DGL_USE_OPENGL3 | |||||
| glUseProgram(reinterpret_cast<const OpenGL3GraphicsContext&>(getGraphicsContext()).program); | |||||
| #endif | |||||
| } | } | ||||
| } | } | ||||
| @@ -125,7 +125,7 @@ OpenGLImage& OpenGLImage::operator=(const OpenGLImage& image) noexcept | |||||
| return *this; | return *this; | ||||
| } | } | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| OpenGLImage::OpenGLImage(const char* const rdata, const uint w, const uint h, const GLenum fmt) | OpenGLImage::OpenGLImage(const char* const rdata, const uint w, const uint h, const GLenum fmt) | ||||
| : ImageBase(rdata, w, h, asDISTRHOImageFormat(fmt)), | : ImageBase(rdata, w, h, asDISTRHOImageFormat(fmt)), | ||||
| setupCalled(false), | setupCalled(false), | ||||
| @@ -93,7 +93,7 @@ void Line<T>::draw(const GraphicsContext&, const T width) | |||||
| drawLine<T>(posStart, posEnd); | drawLine<T>(posStart, posEnd); | ||||
| } | } | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| template<typename T> | template<typename T> | ||||
| void Line<T>::draw() | void Line<T>::draw() | ||||
| { | { | ||||
| @@ -101,13 +101,6 @@ void Line<T>::draw() | |||||
| } | } | ||||
| #endif | #endif | ||||
| template class Line<double>; | |||||
| template class Line<float>; | |||||
| template class Line<int>; | |||||
| template class Line<uint>; | |||||
| template class Line<short>; | |||||
| template class Line<ushort>; | |||||
| // -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
| // Circle | // Circle | ||||
| @@ -168,7 +161,7 @@ void Circle<T>::drawOutline(const GraphicsContext& context, const T lineWidth) | |||||
| drawCircle<T>(context, fPos, fNumSegments, fSize, fSin, fCos, true); | drawCircle<T>(context, fPos, fNumSegments, fSize, fSin, fCos, true); | ||||
| } | } | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| template<typename T> | template<typename T> | ||||
| void Circle<T>::draw() | void Circle<T>::draw() | ||||
| { | { | ||||
| @@ -182,13 +175,6 @@ void Circle<T>::drawOutline() | |||||
| } | } | ||||
| #endif | #endif | ||||
| template class Circle<double>; | |||||
| template class Circle<float>; | |||||
| template class Circle<int>; | |||||
| template class Circle<uint>; | |||||
| template class Circle<short>; | |||||
| template class Circle<ushort>; | |||||
| // -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
| // Triangle | // Triangle | ||||
| @@ -236,7 +222,7 @@ void Triangle<T>::drawOutline(const GraphicsContext&, const T lineWidth) | |||||
| drawTriangle<T>(pos1, pos2, pos3, true); | drawTriangle<T>(pos1, pos2, pos3, true); | ||||
| } | } | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| template<typename T> | template<typename T> | ||||
| void Triangle<T>::draw() | void Triangle<T>::draw() | ||||
| { | { | ||||
| @@ -250,13 +236,6 @@ void Triangle<T>::drawOutline() | |||||
| } | } | ||||
| #endif | #endif | ||||
| template class Triangle<double>; | |||||
| template class Triangle<float>; | |||||
| template class Triangle<int>; | |||||
| template class Triangle<uint>; | |||||
| template class Triangle<short>; | |||||
| template class Triangle<ushort>; | |||||
| // -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
| // Rectangle | // Rectangle | ||||
| @@ -290,13 +269,13 @@ static void drawRectangle(const Rectangle<T>& rect, const bool outline) | |||||
| } | } | ||||
| template<typename T> | template<typename T> | ||||
| void Rectangle<T>::draw(const GraphicsContext& context) | |||||
| void Rectangle<T>::draw(const GraphicsContext&) | |||||
| { | { | ||||
| drawRectangle<T>(*this, false); | drawRectangle<T>(*this, false); | ||||
| } | } | ||||
| template<typename T> | template<typename T> | ||||
| void Rectangle<T>::drawOutline(const GraphicsContext& context, const T lineWidth) | |||||
| void Rectangle<T>::drawOutline(const GraphicsContext&, const T lineWidth) | |||||
| { | { | ||||
| DISTRHO_SAFE_ASSERT_RETURN(lineWidth != 0,); | DISTRHO_SAFE_ASSERT_RETURN(lineWidth != 0,); | ||||
| @@ -304,7 +283,7 @@ void Rectangle<T>::drawOutline(const GraphicsContext& context, const T lineWidth | |||||
| drawRectangle<T>(*this, true); | drawRectangle<T>(*this, true); | ||||
| } | } | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| template<typename T> | template<typename T> | ||||
| void Rectangle<T>::draw() | void Rectangle<T>::draw() | ||||
| { | { | ||||
| @@ -318,13 +297,6 @@ void Rectangle<T>::drawOutline() | |||||
| } | } | ||||
| #endif | #endif | ||||
| template class Rectangle<double>; | |||||
| template class Rectangle<float>; | |||||
| template class Rectangle<int>; | |||||
| template class Rectangle<uint>; | |||||
| template class Rectangle<short>; | |||||
| template class Rectangle<ushort>; | |||||
| // -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
| // OpenGLImage | // OpenGLImage | ||||
| @@ -408,7 +380,7 @@ void OpenGLImage::drawAt(const GraphicsContext&, const Point<int>& pos) | |||||
| drawOpenGLImage(*this, pos, textureId, setupCalled); | drawOpenGLImage(*this, pos, textureId, setupCalled); | ||||
| } | } | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| void OpenGLImage::draw() | void OpenGLImage::draw() | ||||
| { | { | ||||
| drawOpenGLImage(*this, Point<int>(0, 0), textureId, setupCalled); | drawOpenGLImage(*this, Point<int>(0, 0), textureId, setupCalled); | ||||
| @@ -559,6 +531,17 @@ void Window::PrivateData::destroyContext() | |||||
| void Window::PrivateData::startContext() | void Window::PrivateData::startContext() | ||||
| { | { | ||||
| const PuglArea size = puglGetSizeHint(view, PUGL_CURRENT_SIZE); | |||||
| glEnable(GL_BLEND); | |||||
| glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |||||
| glViewport(0, 0, static_cast<GLsizei>(size.width), static_cast<GLsizei>(size.height)); | |||||
| glMatrixMode(GL_PROJECTION); | |||||
| glLoadIdentity(); | |||||
| glOrtho(0.0, static_cast<GLdouble>(size.width), static_cast<GLdouble>(size.height), 0.0, 0.0, 1.0); | |||||
| glViewport(0, 0, static_cast<GLsizei>(size.width), static_cast<GLsizei>(size.height)); | |||||
| glMatrixMode(GL_MODELVIEW); | |||||
| glLoadIdentity(); | |||||
| } | } | ||||
| void Window::PrivateData::endContext() | void Window::PrivateData::endContext() | ||||
| @@ -567,4 +550,36 @@ void Window::PrivateData::endContext() | |||||
| // -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
| #ifndef DGL_GEOMETRY_CPP_INCLUDED | |||||
| template class Line<double>; | |||||
| template class Line<float>; | |||||
| template class Line<int>; | |||||
| template class Line<uint>; | |||||
| template class Line<short>; | |||||
| template class Line<ushort>; | |||||
| template class Circle<double>; | |||||
| template class Circle<float>; | |||||
| template class Circle<int>; | |||||
| template class Circle<uint>; | |||||
| template class Circle<short>; | |||||
| template class Circle<ushort>; | |||||
| template class Triangle<double>; | |||||
| template class Triangle<float>; | |||||
| template class Triangle<int>; | |||||
| template class Triangle<uint>; | |||||
| template class Triangle<short>; | |||||
| template class Triangle<ushort>; | |||||
| template class Rectangle<double>; | |||||
| template class Rectangle<float>; | |||||
| template class Rectangle<int>; | |||||
| template class Rectangle<uint>; | |||||
| template class Rectangle<short>; | |||||
| template class Rectangle<ushort>; | |||||
| #endif | |||||
| // -------------------------------------------------------------------------------------------------------------------- | |||||
| END_NAMESPACE_DGL | END_NAMESPACE_DGL | ||||
| @@ -93,10 +93,12 @@ DGL_EXT(PFNGLVERTEXATTRIBPOINTERPROC, glVertexAttribPointer) | |||||
| // -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| static void notImplemented(const char* const name) | static void notImplemented(const char* const name) | ||||
| { | { | ||||
| d_stderr2("OpenGL3 function not implemented: %s", name); | d_stderr2("OpenGL3 function not implemented: %s", name); | ||||
| } | } | ||||
| #endif | |||||
| // -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
| // Color | // Color | ||||
| @@ -149,7 +151,7 @@ void Line<T>::draw(const GraphicsContext& context, const T width) | |||||
| glBindBuffer(GL_ARRAY_BUFFER, 0); | glBindBuffer(GL_ARRAY_BUFFER, 0); | ||||
| } | } | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| template<typename T> | template<typename T> | ||||
| void Line<T>::draw() | void Line<T>::draw() | ||||
| { | { | ||||
| @@ -157,13 +159,6 @@ void Line<T>::draw() | |||||
| } | } | ||||
| #endif | #endif | ||||
| template class Line<double>; | |||||
| template class Line<float>; | |||||
| template class Line<int>; | |||||
| template class Line<uint>; | |||||
| template class Line<short>; | |||||
| template class Line<ushort>; | |||||
| // -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
| // Circle | // Circle | ||||
| @@ -260,7 +255,7 @@ void Circle<T>::drawOutline(const GraphicsContext& context, const T lineWidth) | |||||
| drawCircle<T>(context, fPos, fNumSegments, fSize, fSin, fCos, true); | drawCircle<T>(context, fPos, fNumSegments, fSize, fSin, fCos, true); | ||||
| } | } | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| template<typename T> | template<typename T> | ||||
| void Circle<T>::draw() | void Circle<T>::draw() | ||||
| { | { | ||||
| @@ -274,13 +269,6 @@ void Circle<T>::drawOutline() | |||||
| } | } | ||||
| #endif | #endif | ||||
| template class Circle<double>; | |||||
| template class Circle<float>; | |||||
| template class Circle<int>; | |||||
| template class Circle<uint>; | |||||
| template class Circle<short>; | |||||
| template class Circle<ushort>; | |||||
| // -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
| // Triangle | // Triangle | ||||
| @@ -344,7 +332,7 @@ void Triangle<T>::drawOutline(const GraphicsContext& context, const T lineWidth) | |||||
| drawTriangle<T>(context, pos1, pos2, pos3, true); | drawTriangle<T>(context, pos1, pos2, pos3, true); | ||||
| } | } | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| template<typename T> | template<typename T> | ||||
| void Triangle<T>::draw() | void Triangle<T>::draw() | ||||
| { | { | ||||
| @@ -358,13 +346,6 @@ void Triangle<T>::drawOutline() | |||||
| } | } | ||||
| #endif | #endif | ||||
| template class Triangle<double>; | |||||
| template class Triangle<float>; | |||||
| template class Triangle<int>; | |||||
| template class Triangle<uint>; | |||||
| template class Triangle<short>; | |||||
| template class Triangle<ushort>; | |||||
| // -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
| // Rectangle | // Rectangle | ||||
| @@ -424,7 +405,7 @@ void Rectangle<T>::drawOutline(const GraphicsContext& context, const T lineWidth | |||||
| drawRectangle<T>(context, *this, true); | drawRectangle<T>(context, *this, true); | ||||
| } | } | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| template<typename T> | template<typename T> | ||||
| void Rectangle<T>::draw() | void Rectangle<T>::draw() | ||||
| { | { | ||||
| @@ -438,13 +419,6 @@ void Rectangle<T>::drawOutline() | |||||
| } | } | ||||
| #endif | #endif | ||||
| template class Rectangle<double>; | |||||
| template class Rectangle<float>; | |||||
| template class Rectangle<int>; | |||||
| template class Rectangle<uint>; | |||||
| template class Rectangle<short>; | |||||
| template class Rectangle<ushort>; | |||||
| // -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
| // OpenGLImage | // OpenGLImage | ||||
| @@ -626,18 +600,18 @@ const char* OpenGLImage::getRawData() const noexcept | |||||
| } | } | ||||
| #endif | #endif | ||||
| #ifdef DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| void OpenGLImage::draw() | void OpenGLImage::draw() | ||||
| { | { | ||||
| notImplemented("OpenGLImage::draw"); | notImplemented("OpenGLImage::draw"); | ||||
| } | } | ||||
| void OpenGLImage::drawAt(const int x, const int y) | |||||
| void OpenGLImage::drawAt(int, int) | |||||
| { | { | ||||
| notImplemented("OpenGLImage::drawAt"); | notImplemented("OpenGLImage::drawAt"); | ||||
| } | } | ||||
| void OpenGLImage::drawAt(const Point<int>& pos) | |||||
| void OpenGLImage::drawAt(const Point<int>&) | |||||
| { | { | ||||
| notImplemented("OpenGLImage::drawAt"); | notImplemented("OpenGLImage::drawAt"); | ||||
| } | } | ||||
| @@ -1013,6 +987,8 @@ void Window::PrivateData::startContext() | |||||
| gl3context.width = size.width; | gl3context.width = size.width; | ||||
| gl3context.height = size.height; | gl3context.height = size.height; | ||||
| glUseProgram(gl3context.program); | glUseProgram(gl3context.program); | ||||
| glViewport(0, 0, static_cast<GLsizei>(size.width), static_cast<GLsizei>(size.height)); | |||||
| } | } | ||||
| void Window::PrivateData::endContext() | void Window::PrivateData::endContext() | ||||
| @@ -1022,4 +998,36 @@ void Window::PrivateData::endContext() | |||||
| // -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
| #ifndef DGL_GEOMETRY_CPP_INCLUDED | |||||
| template class Line<double>; | |||||
| template class Line<float>; | |||||
| template class Line<int>; | |||||
| template class Line<uint>; | |||||
| template class Line<short>; | |||||
| template class Line<ushort>; | |||||
| template class Circle<double>; | |||||
| template class Circle<float>; | |||||
| template class Circle<int>; | |||||
| template class Circle<uint>; | |||||
| template class Circle<short>; | |||||
| template class Circle<ushort>; | |||||
| template class Triangle<double>; | |||||
| template class Triangle<float>; | |||||
| template class Triangle<int>; | |||||
| template class Triangle<uint>; | |||||
| template class Triangle<short>; | |||||
| template class Triangle<ushort>; | |||||
| template class Rectangle<double>; | |||||
| template class Rectangle<float>; | |||||
| template class Rectangle<int>; | |||||
| template class Rectangle<uint>; | |||||
| template class Rectangle<short>; | |||||
| template class Rectangle<ushort>; | |||||
| #endif | |||||
| // -------------------------------------------------------------------------------------------------------------------- | |||||
| END_NAMESPACE_DGL | END_NAMESPACE_DGL | ||||
| @@ -135,11 +135,6 @@ bool TopLevelWidget::PrivateData::scrollEvent(const ScrollEvent& ev) | |||||
| return selfw->pData->giveScrollEventForSubWidgets(rev); | return selfw->pData->giveScrollEventForSubWidgets(rev); | ||||
| } | } | ||||
| void TopLevelWidget::PrivateData::fallbackOnResize(const uint width, const uint height) | |||||
| { | |||||
| puglFallbackOnResize(window.pData->view, width, height); | |||||
| } | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| END_NAMESPACE_DGL | END_NAMESPACE_DGL | ||||
| @@ -38,7 +38,6 @@ struct TopLevelWidget::PrivateData { | |||||
| bool mouseEvent(const MouseEvent& ev); | bool mouseEvent(const MouseEvent& ev); | ||||
| bool motionEvent(const MotionEvent& ev); | bool motionEvent(const MotionEvent& ev); | ||||
| bool scrollEvent(const ScrollEvent& ev); | bool scrollEvent(const ScrollEvent& ev); | ||||
| void fallbackOnResize(uint width, uint height); | |||||
| DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PrivateData) | DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PrivateData) | ||||
| }; | }; | ||||
| @@ -397,12 +397,10 @@ Application& Window::getApp() const noexcept | |||||
| return pData->app; | return pData->app; | ||||
| } | } | ||||
| #ifndef DPF_TEST_WINDOW_CPP | |||||
| const GraphicsContext& Window::getGraphicsContext() const noexcept | const GraphicsContext& Window::getGraphicsContext() const noexcept | ||||
| { | { | ||||
| return pData->getGraphicsContext(); | return pData->getGraphicsContext(); | ||||
| } | } | ||||
| #endif | |||||
| uintptr_t Window::getNativeWindowHandle() const noexcept | uintptr_t Window::getNativeWindowHandle() const noexcept | ||||
| { | { | ||||
| @@ -583,11 +581,11 @@ void Window::onFocus(bool, CrossingMode) | |||||
| { | { | ||||
| } | } | ||||
| void Window::onReshape(const uint width, const uint height) | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| void Window::onReshape(uint, uint) | |||||
| { | { | ||||
| if (pData->view != nullptr) | |||||
| puglFallbackOnResize(pData->view, width, height); | |||||
| } | } | ||||
| #endif | |||||
| void Window::onScaleFactorChanged(double) | void Window::onScaleFactorChanged(double) | ||||
| { | { | ||||
| @@ -268,9 +268,7 @@ Window::PrivateData::~PrivateData() | |||||
| isVisible = false; | isVisible = false; | ||||
| } | } | ||||
| #ifndef DPF_TEST_WINDOW_CPP | |||||
| destroyContext(); | destroyContext(); | ||||
| #endif | |||||
| puglFreeView(view); | puglFreeView(view); | ||||
| } | } | ||||
| @@ -646,9 +644,7 @@ void Window::PrivateData::onPuglConfigure(const uint width, const uint height) | |||||
| DGL_DBGp("PUGL: onReshape : %d %d\n", width, height); | DGL_DBGp("PUGL: onReshape : %d %d\n", width, height); | ||||
| #ifndef DPF_TEST_WINDOW_CPP | |||||
| createContextIfNeeded(); | createContextIfNeeded(); | ||||
| #endif | |||||
| if (autoScaling) | if (autoScaling) | ||||
| { | { | ||||
| @@ -672,9 +668,27 @@ void Window::PrivateData::onPuglConfigure(const uint width, const uint height) | |||||
| autoScaling ? autoScaleFactor : scaleFactor); | autoScaling ? autoScaleFactor : scaleFactor); | ||||
| #endif | #endif | ||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if defined(_MSC_VER) | |||||
| #pragma warning(push) | |||||
| #pragma warning(disable:4996) | |||||
| #elif defined(__clang__) | |||||
| #pragma clang diagnostic push | |||||
| #pragma clang diagnostic ignored "-Wdeprecated-declarations" | |||||
| #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 460 | |||||
| #pragma GCC diagnostic push | |||||
| #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |||||
| #endif | |||||
| self->onReshape(uwidth, uheight); | self->onReshape(uwidth, uheight); | ||||
| #if defined(_MSC_VER) | |||||
| #pragma warning(pop) | |||||
| #elif defined(__clang__) | |||||
| #pragma clang diagnostic pop | |||||
| #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 460 | |||||
| #pragma GCC diagnostic pop | |||||
| #endif | |||||
| #endif | |||||
| #ifndef DPF_TEST_WINDOW_CPP | |||||
| FOR_EACH_TOP_LEVEL_WIDGET(it) | FOR_EACH_TOP_LEVEL_WIDGET(it) | ||||
| { | { | ||||
| TopLevelWidget* const widget = *it; | TopLevelWidget* const widget = *it; | ||||
| @@ -689,7 +703,6 @@ void Window::PrivateData::onPuglConfigure(const uint width, const uint height) | |||||
| */ | */ | ||||
| ((Widget*)widget)->setSize(uwidth, uheight); | ((Widget*)widget)->setSize(uwidth, uheight); | ||||
| } | } | ||||
| #endif | |||||
| // always repaint after a resize | // always repaint after a resize | ||||
| puglObscureView(view); | puglObscureView(view); | ||||
| @@ -701,7 +714,6 @@ void Window::PrivateData::onPuglExpose() | |||||
| puglOnDisplayPrepare(view); | puglOnDisplayPrepare(view); | ||||
| #ifndef DPF_TEST_WINDOW_CPP | |||||
| startContext(); | startContext(); | ||||
| FOR_EACH_TOP_LEVEL_WIDGET(it) | FOR_EACH_TOP_LEVEL_WIDGET(it) | ||||
| @@ -721,7 +733,6 @@ void Window::PrivateData::onPuglExpose() | |||||
| } | } | ||||
| endContext(); | endContext(); | ||||
| #endif | |||||
| } | } | ||||
| void Window::PrivateData::onPuglClose() | void Window::PrivateData::onPuglClose() | ||||
| @@ -774,7 +785,6 @@ void Window::PrivateData::onPuglKey(const Widget::KeyboardEvent& ev) | |||||
| if (modal.child != nullptr) | if (modal.child != nullptr) | ||||
| return modal.child->focus(); | return modal.child->focus(); | ||||
| #ifndef DPF_TEST_WINDOW_CPP | |||||
| FOR_EACH_TOP_LEVEL_WIDGET_INV(rit) | FOR_EACH_TOP_LEVEL_WIDGET_INV(rit) | ||||
| { | { | ||||
| TopLevelWidget* const widget(*rit); | TopLevelWidget* const widget(*rit); | ||||
| @@ -782,7 +792,6 @@ void Window::PrivateData::onPuglKey(const Widget::KeyboardEvent& ev) | |||||
| if (widget->isVisible() && widget->onKeyboard(ev)) | if (widget->isVisible() && widget->onKeyboard(ev)) | ||||
| break; | break; | ||||
| } | } | ||||
| #endif | |||||
| } | } | ||||
| void Window::PrivateData::onPuglText(const Widget::CharacterInputEvent& ev) | void Window::PrivateData::onPuglText(const Widget::CharacterInputEvent& ev) | ||||
| @@ -792,7 +801,6 @@ void Window::PrivateData::onPuglText(const Widget::CharacterInputEvent& ev) | |||||
| if (modal.child != nullptr) | if (modal.child != nullptr) | ||||
| return modal.child->focus(); | return modal.child->focus(); | ||||
| #ifndef DPF_TEST_WINDOW_CPP | |||||
| FOR_EACH_TOP_LEVEL_WIDGET_INV(rit) | FOR_EACH_TOP_LEVEL_WIDGET_INV(rit) | ||||
| { | { | ||||
| TopLevelWidget* const widget(*rit); | TopLevelWidget* const widget(*rit); | ||||
| @@ -800,7 +808,6 @@ void Window::PrivateData::onPuglText(const Widget::CharacterInputEvent& ev) | |||||
| if (widget->isVisible() && widget->onCharacterInput(ev)) | if (widget->isVisible() && widget->onCharacterInput(ev)) | ||||
| break; | break; | ||||
| } | } | ||||
| #endif | |||||
| } | } | ||||
| void Window::PrivateData::onPuglMouse(const Widget::MouseEvent& ev) | void Window::PrivateData::onPuglMouse(const Widget::MouseEvent& ev) | ||||
| @@ -810,7 +817,6 @@ void Window::PrivateData::onPuglMouse(const Widget::MouseEvent& ev) | |||||
| if (modal.child != nullptr) | if (modal.child != nullptr) | ||||
| return modal.child->focus(); | return modal.child->focus(); | ||||
| #ifndef DPF_TEST_WINDOW_CPP | |||||
| FOR_EACH_TOP_LEVEL_WIDGET_INV(rit) | FOR_EACH_TOP_LEVEL_WIDGET_INV(rit) | ||||
| { | { | ||||
| TopLevelWidget* const widget(*rit); | TopLevelWidget* const widget(*rit); | ||||
| @@ -818,7 +824,6 @@ void Window::PrivateData::onPuglMouse(const Widget::MouseEvent& ev) | |||||
| if (widget->isVisible() && widget->onMouse(ev)) | if (widget->isVisible() && widget->onMouse(ev)) | ||||
| break; | break; | ||||
| } | } | ||||
| #endif | |||||
| } | } | ||||
| void Window::PrivateData::onPuglMotion(const Widget::MotionEvent& ev) | void Window::PrivateData::onPuglMotion(const Widget::MotionEvent& ev) | ||||
| @@ -828,7 +833,6 @@ void Window::PrivateData::onPuglMotion(const Widget::MotionEvent& ev) | |||||
| if (modal.child != nullptr) | if (modal.child != nullptr) | ||||
| return modal.child->focus(); | return modal.child->focus(); | ||||
| #ifndef DPF_TEST_WINDOW_CPP | |||||
| FOR_EACH_TOP_LEVEL_WIDGET_INV(rit) | FOR_EACH_TOP_LEVEL_WIDGET_INV(rit) | ||||
| { | { | ||||
| TopLevelWidget* const widget(*rit); | TopLevelWidget* const widget(*rit); | ||||
| @@ -836,7 +840,6 @@ void Window::PrivateData::onPuglMotion(const Widget::MotionEvent& ev) | |||||
| if (widget->isVisible() && widget->onMotion(ev)) | if (widget->isVisible() && widget->onMotion(ev)) | ||||
| break; | break; | ||||
| } | } | ||||
| #endif | |||||
| } | } | ||||
| void Window::PrivateData::onPuglScroll(const Widget::ScrollEvent& ev) | void Window::PrivateData::onPuglScroll(const Widget::ScrollEvent& ev) | ||||
| @@ -846,7 +849,6 @@ void Window::PrivateData::onPuglScroll(const Widget::ScrollEvent& ev) | |||||
| if (modal.child != nullptr) | if (modal.child != nullptr) | ||||
| return modal.child->focus(); | return modal.child->focus(); | ||||
| #ifndef DPF_TEST_WINDOW_CPP | |||||
| FOR_EACH_TOP_LEVEL_WIDGET_INV(rit) | FOR_EACH_TOP_LEVEL_WIDGET_INV(rit) | ||||
| { | { | ||||
| TopLevelWidget* const widget(*rit); | TopLevelWidget* const widget(*rit); | ||||
| @@ -854,7 +856,6 @@ void Window::PrivateData::onPuglScroll(const Widget::ScrollEvent& ev) | |||||
| if (widget->isVisible() && widget->onScroll(ev)) | if (widget->isVisible() && widget->onScroll(ev)) | ||||
| break; | break; | ||||
| } | } | ||||
| #endif | |||||
| } | } | ||||
| const void* Window::PrivateData::getClipboard(size_t& dataSize) | const void* Window::PrivateData::getClipboard(size_t& dataSize) | ||||
| @@ -680,9 +680,8 @@ typedef struct { | |||||
| to the appropriate type, or the union members used. | to the appropriate type, or the union members used. | ||||
| The graphics system may only be accessed when handling certain events. The | The graphics system may only be accessed when handling certain events. The | ||||
| graphics context is active for #PUGL_REALIZE, #PUGL_UNREALIZE, | |||||
| #PUGL_CONFIGURE, and #PUGL_EXPOSE, but only enabled for drawing for | |||||
| #PUGL_EXPOSE. | |||||
| graphics context is active for #PUGL_REALIZE, #PUGL_UNREALIZE, and | |||||
| #PUGL_EXPOSE, but only enabled for drawing for #PUGL_EXPOSE. | |||||
| */ | */ | ||||
| typedef union { | typedef union { | ||||
| PuglAnyEvent any; ///< Valid for all event types | PuglAnyEvent any; ///< Valid for all event types | ||||
| @@ -1367,7 +1366,7 @@ typedef enum { | |||||
| do so automatically. If the view is currently hidden, it will be shown and | do so automatically. If the view is currently hidden, it will be shown and | ||||
| possibly raised to the top depending on the platform. | possibly raised to the top depending on the platform. | ||||
| @return #PUGL_SUCCESS, an error from puglRealize(), or #PUGL_FAILURE if the | |||||
| @return #PUGL_SUCCESS, an error from realization, or #PUGL_FAILURE if the | |||||
| window was shown but not raised. | window was shown but not raised. | ||||
| */ | */ | ||||
| PUGL_API PuglStatus | PUGL_API PuglStatus | ||||
| @@ -1395,12 +1394,7 @@ puglHide(PuglView* view); | |||||
| PUGL_API PuglStatus | PUGL_API PuglStatus | ||||
| puglSetViewStyle(PuglView* view, PuglViewStyleFlags flags); | puglSetViewStyle(PuglView* view, PuglViewStyleFlags flags); | ||||
| /** | |||||
| Return true if the view currently has a style flag set. | |||||
| The result is determined based on the state announced in the last configure | |||||
| event. | |||||
| */ | |||||
| /// Return the style flags currently set for a view | |||||
| PUGL_API PuglViewStyleFlags | PUGL_API PuglViewStyleFlags | ||||
| puglGetViewStyle(const PuglView* view); | puglGetViewStyle(const PuglView* view); | ||||
| @@ -1410,7 +1404,7 @@ puglGetVisible(const PuglView* view); | |||||
| /// Return the native window handle | /// Return the native window handle | ||||
| PUGL_API PuglNativeView | PUGL_API PuglNativeView | ||||
| puglGetNativeView(PuglView* view); | |||||
| puglGetNativeView(const PuglView* view); | |||||
| /** | /** | ||||
| @} | @} | ||||
| @@ -1,4 +1,4 @@ | |||||
| // Copyright 2012-2023 David Robillard <d@drobilla.net> | |||||
| // Copyright 2012-2025 David Robillard <d@drobilla.net> | |||||
| // SPDX-License-Identifier: ISC | // SPDX-License-Identifier: ISC | ||||
| #include "internal.h" | #include "internal.h" | ||||
| @@ -258,26 +258,6 @@ puglDispatchSimpleEvent(PuglView* view, const PuglEventType type) | |||||
| return puglDispatchEvent(view, &event); | return puglDispatchEvent(view, &event); | ||||
| } | } | ||||
| static inline bool | |||||
| puglMustConfigure(PuglView* view, const PuglConfigureEvent* configure) | |||||
| { | |||||
| return !!memcmp(configure, &view->lastConfigure, sizeof(PuglConfigureEvent)); | |||||
| } | |||||
| PuglStatus | |||||
| puglConfigure(PuglView* view, const PuglEvent* event) | |||||
| { | |||||
| PuglStatus st = PUGL_SUCCESS; | |||||
| assert(event->type == PUGL_CONFIGURE); | |||||
| if (puglMustConfigure(view, &event->configure)) { | |||||
| st = view->eventFunc(view, event); | |||||
| view->lastConfigure = event->configure; | |||||
| } | |||||
| return st; | |||||
| } | |||||
| PuglStatus | PuglStatus | ||||
| puglDispatchEvent(PuglView* view, const PuglEvent* event) | puglDispatchEvent(PuglView* view, const PuglEvent* event) | ||||
| { | { | ||||
| @@ -307,12 +287,8 @@ puglDispatchEvent(PuglView* view, const PuglEvent* event) | |||||
| break; | break; | ||||
| case PUGL_CONFIGURE: | case PUGL_CONFIGURE: | ||||
| if (puglMustConfigure(view, &event->configure)) { | |||||
| if (!(st0 = view->backend->enter(view, NULL))) { | |||||
| st0 = puglConfigure(view, event); | |||||
| st1 = view->backend->leave(view, NULL); | |||||
| } | |||||
| } | |||||
| st0 = view->eventFunc(view, event); | |||||
| view->lastConfigure = event->configure; | |||||
| if (view->stage == PUGL_VIEW_STAGE_REALIZED) { | if (view->stage == PUGL_VIEW_STAGE_REALIZED) { | ||||
| view->stage = PUGL_VIEW_STAGE_CONFIGURED; | view->stage = PUGL_VIEW_STAGE_CONFIGURED; | ||||
| } | } | ||||
| @@ -6,7 +6,6 @@ | |||||
| #ifndef PUGL_INTERNAL_H | #ifndef PUGL_INTERNAL_H | ||||
| #define PUGL_INTERNAL_H | #define PUGL_INTERNAL_H | ||||
| #include "attributes.h" | |||||
| #include "types.h" | #include "types.h" | ||||
| #include <pugl/attributes.h> | #include <pugl/attributes.h> | ||||
| @@ -81,10 +80,6 @@ puglPreRealize(PuglView* view); | |||||
| PuglStatus | PuglStatus | ||||
| puglDispatchSimpleEvent(PuglView* view, PuglEventType type); | puglDispatchSimpleEvent(PuglView* view, PuglEventType type); | ||||
| /// Process configure event while already in the graphics context | |||||
| PUGL_WARN_UNUSED_RESULT PuglStatus | |||||
| puglConfigure(PuglView* view, const PuglEvent* event); | |||||
| /// Dispatch `event` to `view`, entering graphics context if necessary | /// Dispatch `event` to `view`, entering graphics context if necessary | ||||
| PuglStatus | PuglStatus | ||||
| puglDispatchEvent(PuglView* view, const PuglEvent* event); | puglDispatchEvent(PuglView* view, const PuglEvent* event); | ||||
| @@ -1689,7 +1689,7 @@ puglObscureRegion(PuglView* view, | |||||
| } | } | ||||
| PuglNativeView | PuglNativeView | ||||
| puglGetNativeView(PuglView* view) | |||||
| puglGetNativeView(const PuglView* view) | |||||
| { | { | ||||
| return (PuglNativeView)view->impl->wrapperView; | return (PuglNativeView)view->impl->wrapperView; | ||||
| } | } | ||||
| @@ -1230,7 +1230,7 @@ puglObscureRegion(PuglView* const view, | |||||
| } | } | ||||
| PuglNativeView | PuglNativeView | ||||
| puglGetNativeView(PuglView* view) | |||||
| puglGetNativeView(const PuglView* view) | |||||
| { | { | ||||
| return (PuglNativeView)view->impl->hwnd; | return (PuglNativeView)view->impl->hwnd; | ||||
| } | } | ||||
| @@ -1635,9 +1635,11 @@ puglWinConfigure(PuglView* view) | |||||
| PuglStatus | PuglStatus | ||||
| puglWinEnter(PuglView* view, const PuglExposeEvent* expose) | puglWinEnter(PuglView* view, const PuglExposeEvent* expose) | ||||
| { | { | ||||
| return expose | |||||
| ? puglWinStatus(!!BeginPaint(view->impl->hwnd, &view->impl->paint)) | |||||
| : PUGL_SUCCESS; | |||||
| if (expose) { | |||||
| return puglWinStatus(!!BeginPaint(view->impl->hwnd, &view->impl->paint)); | |||||
| } | |||||
| return PUGL_SUCCESS; | |||||
| } | } | ||||
| PuglStatus | PuglStatus | ||||
| @@ -27,7 +27,7 @@ puglWinCairoCreateDrawContext(PuglView* view) | |||||
| surface->drawDc = CreateCompatibleDC(impl->hdc); | surface->drawDc = CreateCompatibleDC(impl->hdc); | ||||
| surface->drawBitmap = CreateCompatibleBitmap( | surface->drawBitmap = CreateCompatibleBitmap( | ||||
| impl->hdc, (int)view->lastConfigure.width, (int)view->lastConfigure.height); | |||||
| impl->hdc, view->lastConfigure.width, view->lastConfigure.height); | |||||
| DeleteObject(SelectObject(surface->drawDc, surface->drawBitmap)); | DeleteObject(SelectObject(surface->drawDc, surface->drawBitmap)); | ||||
| @@ -106,12 +106,11 @@ puglWinCairoEnter(PuglView* view, const PuglExposeEvent* expose) | |||||
| { | { | ||||
| PuglStatus st = PUGL_SUCCESS; | PuglStatus st = PUGL_SUCCESS; | ||||
| if (expose && !(st = puglWinCairoCreateDrawContext(view)) && | |||||
| !(st = puglWinCairoOpen(view))) { | |||||
| st = puglWinEnter(view, expose); | |||||
| if (expose && !(st = puglWinCairoCreateDrawContext(view))) { | |||||
| st = puglWinCairoOpen(view); | |||||
| } | } | ||||
| return st; | |||||
| return st ? st : puglWinEnter(view, expose); | |||||
| } | } | ||||
| static PuglStatus | static PuglStatus | ||||
| @@ -125,8 +124,8 @@ puglWinCairoLeave(PuglView* view, const PuglExposeEvent* expose) | |||||
| BitBlt(impl->hdc, | BitBlt(impl->hdc, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| (int)view->lastConfigure.width, | |||||
| (int)view->lastConfigure.height, | |||||
| view->lastConfigure.width, | |||||
| view->lastConfigure.height, | |||||
| surface->drawDc, | surface->drawDc, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| @@ -418,12 +418,12 @@ puglUpdateSizeHints(PuglView* const view) | |||||
| } | } | ||||
| sizeHints.flags = PBaseSize | PMinSize | PMaxSize; | sizeHints.flags = PBaseSize | PMinSize | PMaxSize; | ||||
| sizeHints.base_width = (int)size.width; | |||||
| sizeHints.base_height = (int)size.height; | |||||
| sizeHints.min_width = (int)size.width; | |||||
| sizeHints.min_height = (int)size.height; | |||||
| sizeHints.max_width = (int)size.width; | |||||
| sizeHints.max_height = (int)size.height; | |||||
| sizeHints.base_width = size.width; | |||||
| sizeHints.base_height = size.height; | |||||
| sizeHints.min_width = size.width; | |||||
| sizeHints.min_height = size.height; | |||||
| sizeHints.max_width = size.width; | |||||
| sizeHints.max_height = size.height; | |||||
| } else { | } else { | ||||
| // Avoid setting PBaseSize for top level views to avoid window manager bugs | // Avoid setting PBaseSize for top level views to avoid window manager bugs | ||||
| const PuglArea defaultSize = view->sizeHints[PUGL_DEFAULT_SIZE]; | const PuglArea defaultSize = view->sizeHints[PUGL_DEFAULT_SIZE]; | ||||
| @@ -729,13 +729,7 @@ puglUnrealize(PuglView* const view) | |||||
| impl->vi = NULL; | impl->vi = NULL; | ||||
| memset(&view->lastConfigure, 0, sizeof(PuglConfigureEvent)); | memset(&view->lastConfigure, 0, sizeof(PuglConfigureEvent)); | ||||
| memset(&view->impl->pendingConfigure, 0, sizeof(PuglEvent)); | |||||
| memset(&view->impl->pendingExpose, 0, sizeof(PuglEvent)); | memset(&view->impl->pendingExpose, 0, sizeof(PuglEvent)); | ||||
| if (impl->mapped) { | |||||
| view->impl->pendingConfigure.configure.style |= PUGL_VIEW_STYLE_MAPPED; | |||||
| } | |||||
| return PUGL_SUCCESS; | return PUGL_SUCCESS; | ||||
| } | } | ||||
| @@ -1072,6 +1066,7 @@ getCurrentViewStyleFlags(PuglView* const view) | |||||
| state |= PUGL_VIEW_STYLE_DEMANDING; | state |= PUGL_VIEW_STYLE_DEMANDING; | ||||
| } | } | ||||
| } | } | ||||
| XFree(hints); | |||||
| } | } | ||||
| if (view->impl->mapped) { | if (view->impl->mapped) { | ||||
| @@ -1110,22 +1105,6 @@ getCurrentConfiguration(PuglView* const view) | |||||
| return configureEvent; | return configureEvent; | ||||
| } | } | ||||
| static PuglEvent | |||||
| makeConfigureEvent(PuglView* const view) | |||||
| { | |||||
| PuglEvent event = view->impl->pendingConfigure; | |||||
| if (event.type != PUGL_CONFIGURE) { | |||||
| event = getCurrentConfiguration(view); | |||||
| } else if (view->impl->mapped) { | |||||
| event.configure.style |= PUGL_VIEW_STYLE_MAPPED; | |||||
| } else { | |||||
| event.configure.style &= ~(PuglViewStyleFlags)PUGL_VIEW_STYLE_MAPPED; | |||||
| } | |||||
| return event; | |||||
| } | |||||
| static PuglEvent | static PuglEvent | ||||
| translatePropertyNotify(PuglView* const view, XPropertyEvent message) | translatePropertyNotify(PuglView* const view, XPropertyEvent message) | ||||
| { | { | ||||
| @@ -1142,8 +1121,7 @@ translatePropertyNotify(PuglView* const view, XPropertyEvent message) | |||||
| } | } | ||||
| // Make a configure event based on the current configuration to update | // Make a configure event based on the current configuration to update | ||||
| event = makeConfigureEvent(view); | |||||
| event.configure.style = getCurrentViewStyleFlags(view); // FIXME: necessary? | |||||
| event = getCurrentConfiguration(view); | |||||
| XFree(hints); | XFree(hints); | ||||
| } else if (message.atom == atoms->NET_FRAME_EXTENTS) { | } else if (message.atom == atoms->NET_FRAME_EXTENTS) { | ||||
| @@ -1192,21 +1170,21 @@ translateEvent(PuglView* const view, XEvent xevent) | |||||
| event = translatePropertyNotify(view, xevent.xproperty); | event = translatePropertyNotify(view, xevent.xproperty); | ||||
| break; | break; | ||||
| case VisibilityNotify: | case VisibilityNotify: | ||||
| event = makeConfigureEvent(view); | |||||
| event = getCurrentConfiguration(view); | |||||
| break; | break; | ||||
| case MapNotify: | case MapNotify: | ||||
| view->impl->mapped = true; | view->impl->mapped = true; | ||||
| event = makeConfigureEvent(view); | |||||
| event = getCurrentConfiguration(view); | |||||
| break; | break; | ||||
| case UnmapNotify: | case UnmapNotify: | ||||
| view->impl->mapped = false; | view->impl->mapped = false; | ||||
| event = makeConfigureEvent(view); | |||||
| event = getCurrentConfiguration(view); | |||||
| break; | break; | ||||
| case DestroyNotify: | case DestroyNotify: | ||||
| view->impl->win = None; | view->impl->win = None; | ||||
| break; | break; | ||||
| case ConfigureNotify: | case ConfigureNotify: | ||||
| event = makeConfigureEvent(view); | |||||
| event = getCurrentConfiguration(view); | |||||
| event.configure.width = (PuglSpan)xevent.xconfigure.width; | event.configure.width = (PuglSpan)xevent.xconfigure.width; | ||||
| event.configure.height = (PuglSpan)xevent.xconfigure.height; | event.configure.height = (PuglSpan)xevent.xconfigure.height; | ||||
| if (view->parent) { | if (view->parent) { | ||||
| @@ -1688,7 +1666,6 @@ flushExposures(PuglWorld* const world) | |||||
| { | { | ||||
| PuglStatus st0 = PUGL_SUCCESS; | PuglStatus st0 = PUGL_SUCCESS; | ||||
| PuglStatus st1 = PUGL_SUCCESS; | PuglStatus st1 = PUGL_SUCCESS; | ||||
| PuglStatus st2 = PUGL_SUCCESS; | |||||
| // Send update events so the application can trigger redraws | // Send update events so the application can trigger redraws | ||||
| for (size_t i = 0; i < world->numViews; ++i) { | for (size_t i = 0; i < world->numViews; ++i) { | ||||
| @@ -1702,32 +1679,17 @@ flushExposures(PuglWorld* const world) | |||||
| for (size_t i = 0; i < world->numViews; ++i) { | for (size_t i = 0; i < world->numViews; ++i) { | ||||
| PuglView* const view = world->views[i]; | PuglView* const view = world->views[i]; | ||||
| // Copy and reset pending events (in case their handlers write new ones) | |||||
| const PuglEvent configure = view->impl->pendingConfigure; | |||||
| const PuglEvent expose = view->impl->pendingExpose; | |||||
| view->impl->pendingConfigure.type = PUGL_NOTHING; | |||||
| view->impl->pendingExpose.type = PUGL_NOTHING; | |||||
| if (expose.type || configure.type) { | |||||
| const PuglExposeEvent* const exposeEvent = | |||||
| expose.type ? &expose.expose : NULL; | |||||
| if (!(st0 = view->backend->enter(view, exposeEvent))) { | |||||
| if (configure.type) { | |||||
| st0 = puglConfigure(view, &configure); | |||||
| } | |||||
| if (expose.type) { | |||||
| st1 = view->eventFunc(view, &expose); | |||||
| } | |||||
| if (puglGetVisible(view)) { | |||||
| const PuglEvent expose = view->impl->pendingExpose; | |||||
| if (expose.type && !(st0 = view->backend->enter(view, &expose.expose))) { | |||||
| st0 = view->eventFunc(view, &expose); | |||||
| st1 = view->backend->leave(view, &expose.expose); | |||||
| view->impl->pendingExpose.type = PUGL_NOTHING; | |||||
| } | } | ||||
| st2 = view->backend->leave(view, exposeEvent); | |||||
| } | } | ||||
| } | } | ||||
| return st0 ? st0 : st1 ? st1 : st2; | |||||
| return st0 ? st0 : st1; | |||||
| } | } | ||||
| static bool | static bool | ||||
| @@ -1808,10 +1770,6 @@ dispatchX11Events(PuglWorld* const world) | |||||
| const PuglEvent event = translateEvent(view, xevent); | const PuglEvent event = translateEvent(view, xevent); | ||||
| switch (event.type) { | switch (event.type) { | ||||
| case PUGL_CONFIGURE: | |||||
| // Update configure event to be dispatched after loop | |||||
| view->impl->pendingConfigure = event; | |||||
| break; | |||||
| case PUGL_EXPOSE: | case PUGL_EXPOSE: | ||||
| // Expand expose event to be dispatched after loop | // Expand expose event to be dispatched after loop | ||||
| mergeExposeEvents(&view->impl->pendingExpose.expose, &event.expose); | mergeExposeEvents(&view->impl->pendingExpose.expose, &event.expose); | ||||
| @@ -1928,7 +1886,7 @@ puglObscureRegion(PuglView* const view, | |||||
| } | } | ||||
| PuglNativeView | PuglNativeView | ||||
| puglGetNativeView(PuglView* const view) | |||||
| puglGetNativeView(const PuglView* const view) | |||||
| { | { | ||||
| return (PuglNativeView)view->impl->win; | return (PuglNativeView)view->impl->win; | ||||
| } | } | ||||
| @@ -82,7 +82,6 @@ struct PuglInternalsImpl { | |||||
| Window win; | Window win; | ||||
| XIC xic; | XIC xic; | ||||
| PuglSurface* surface; | PuglSurface* surface; | ||||
| PuglEvent pendingConfigure; | |||||
| PuglEvent pendingExpose; | PuglEvent pendingExpose; | ||||
| PuglX11Clipboard clipboard; | PuglX11Clipboard clipboard; | ||||
| long frameExtentLeft; | long frameExtentLeft; | ||||
| @@ -14,7 +14,6 @@ | |||||
| #include <X11/Xlib.h> | #include <X11/Xlib.h> | ||||
| #include <stdint.h> | #include <stdint.h> | ||||
| #include <stdio.h> | |||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| @@ -435,33 +435,6 @@ void puglOnDisplayPrepare(PuglView*) | |||||
| #endif | #endif | ||||
| } | } | ||||
| // -------------------------------------------------------------------------------------------------------------------- | |||||
| // DGL specific, build-specific fallback resize | |||||
| void puglFallbackOnResize(PuglView* const view, const uint width, const uint height) | |||||
| { | |||||
| #ifdef DGL_OPENGL | |||||
| #if defined(DGL_USE_OPENGL3) | |||||
| glViewport(0, 0, static_cast<GLsizei>(width), static_cast<GLsizei>(height)); | |||||
| #else | |||||
| glEnable(GL_BLEND); | |||||
| glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |||||
| glViewport(0, 0, static_cast<GLsizei>(width), static_cast<GLsizei>(height)); | |||||
| glMatrixMode(GL_PROJECTION); | |||||
| glLoadIdentity(); | |||||
| glOrtho(0.0, static_cast<GLdouble>(width), static_cast<GLdouble>(height), 0.0, 0.0, 1.0); | |||||
| glViewport(0, 0, static_cast<GLsizei>(width), static_cast<GLsizei>(height)); | |||||
| glMatrixMode(GL_MODELVIEW); | |||||
| glLoadIdentity(); | |||||
| #endif | |||||
| #else | |||||
| // unused | |||||
| (void)view; | |||||
| (void)width; | |||||
| (void)height; | |||||
| #endif | |||||
| } | |||||
| // -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
| #if defined(DISTRHO_OS_HAIKU) | #if defined(DISTRHO_OS_HAIKU) | ||||
| @@ -84,9 +84,6 @@ PuglStatus puglSetSizeAndDefault(PuglView* view, uint width, uint height); | |||||
| // DGL specific, build-specific drawing prepare | // DGL specific, build-specific drawing prepare | ||||
| void puglOnDisplayPrepare(PuglView* view); | void puglOnDisplayPrepare(PuglView* view); | ||||
| // DGL specific, build-specific fallback resize | |||||
| void puglFallbackOnResize(PuglView* view, uint width, uint height); | |||||
| #if defined(DISTRHO_OS_HAIKU) | #if defined(DISTRHO_OS_HAIKU) | ||||
| // nothing here yet | // nothing here yet | ||||
| @@ -1,6 +1,6 @@ | |||||
| /* | /* | ||||
| * DISTRHO Plugin Framework (DPF) | * DISTRHO Plugin Framework (DPF) | ||||
| * Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com> | |||||
| * Copyright (C) 2012-2025 Filipe Coelho <falktx@falktx.com> | |||||
| * | * | ||||
| * Permission to use, copy, modify, and/or distribute this software for any purpose with | * 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 | * or without fee is hereby granted, provided that the above copyright notice and this | ||||
| @@ -291,19 +291,13 @@ protected: | |||||
| */ | */ | ||||
| virtual void uiFocus(bool focus, DGL_NAMESPACE::CrossingMode mode); | virtual void uiFocus(bool focus, DGL_NAMESPACE::CrossingMode mode); | ||||
| /** | |||||
| Window reshape function, called when the window is resized. | |||||
| This function is for plugin UIs to be able to override Window::onReshape(uint, uint). | |||||
| The plugin UI size will be set right after this function. | |||||
| The default implementation sets up the drawing context where necessary. | |||||
| You should almost never need to override this function. | |||||
| The most common exception is custom OpenGL setup, but only really needed for custom OpenGL drawing code. | |||||
| */ | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| /** DEPRECATED DO NOT USE */ | |||||
| DISTRHO_DEPRECATED | |||||
| virtual void uiReshape(uint width, uint height); | virtual void uiReshape(uint width, uint height); | ||||
| #endif | |||||
| #if DISTRHO_UI_FILE_BROWSER | |||||
| #if DISTRHO_UI_FILE_BROWSER | |||||
| /** | /** | ||||
| Window file selected function, called when a path is selected by the user, as triggered by openFileBrowser(). | Window file selected function, called when a path is selected by the user, as triggered by openFileBrowser(). | ||||
| This function is for plugin UIs to be able to override Window::onFileSelected(const char*). | This function is for plugin UIs to be able to override Window::onFileSelected(const char*). | ||||
| @@ -314,7 +308,7 @@ protected: | |||||
| If you need to use files as plugin state, please setup and use states with kStateIsFilenamePath instead. | If you need to use files as plugin state, please setup and use states with kStateIsFilenamePath instead. | ||||
| */ | */ | ||||
| virtual void uiFileBrowserSelected(const char* filename); | virtual void uiFileBrowserSelected(const char* filename); | ||||
| #endif | |||||
| #endif | |||||
| /* -------------------------------------------------------------------------------------------------------- | /* -------------------------------------------------------------------------------------------------------- | ||||
| * UI Resize Handling, internal */ | * UI Resize Handling, internal */ | ||||
| @@ -77,6 +77,11 @@ int main(int argc, char* argv[]) | |||||
| { | { | ||||
| return DISTRHO_NAMESPACE::dpf_webview_start(argc, argv); | return DISTRHO_NAMESPACE::dpf_webview_start(argc, argv); | ||||
| } | } | ||||
| #elif defined(DISTRHO_OS_LINUX) && defined(DGL_USE_WEB_VIEW) && !DISTRHO_IS_STANDALONE | |||||
| int main() | |||||
| { | |||||
| return 0; | |||||
| } | |||||
| #endif | #endif | ||||
| #endif | #endif | ||||
| @@ -695,11 +695,11 @@ public: | |||||
| "abcdefghijklmnopqrstuvwxyz" | "abcdefghijklmnopqrstuvwxyz" | ||||
| "0123456789+/"; | "0123456789+/"; | ||||
| const size_t strBufSize = std::min(d_nextPowerOf2(static_cast<uint32_t>(dataSize/3)), 65536U); | |||||
| const size_t strBufSize = std::min(d_nextPowerOf2(static_cast<uint32_t>(dataSize / 3) + 1), 65536U); | |||||
| char* strBuf = static_cast<char*>(std::malloc(strBufSize)); | char* strBuf = static_cast<char*>(std::malloc(strBufSize)); | ||||
| DISTRHO_SAFE_ASSERT_RETURN(strBuf != nullptr, String()); | DISTRHO_SAFE_ASSERT_RETURN(strBuf != nullptr, String()); | ||||
| strBuf[strBufSize] = '\0'; | |||||
| strBuf[strBufSize - 1] = '\0'; | |||||
| size_t strBufIndex = 0; | size_t strBufIndex = 0; | ||||
| const uchar* bytesToEncode = static_cast<const uchar*>(data); | const uchar* bytesToEncode = static_cast<const uchar*>(data); | ||||
| @@ -560,11 +560,11 @@ void UI::uiFocus(bool, DGL_NAMESPACE::CrossingMode) | |||||
| { | { | ||||
| } | } | ||||
| void UI::uiReshape(const uint width, const uint height) | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| void UI::uiReshape(uint, uint) | |||||
| { | { | ||||
| // NOTE this must be the same as Window::onReshape | |||||
| pData->fallbackOnResize(width, height); | |||||
| } | } | ||||
| #endif | |||||
| #if DISTRHO_UI_FILE_BROWSER | #if DISTRHO_UI_FILE_BROWSER | ||||
| void UI::uiFileBrowserSelected(const char*) | void UI::uiFileBrowserSelected(const char*) | ||||
| @@ -115,7 +115,9 @@ class PluginWindow : public DGL_NAMESPACE::Window | |||||
| { | { | ||||
| UI* const ui; | UI* const ui; | ||||
| bool initializing; | bool initializing; | ||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| bool receivedReshapeDuringInit; | bool receivedReshapeDuringInit; | ||||
| #endif | |||||
| public: | public: | ||||
| explicit PluginWindow(UI* const uiPtr, | explicit PluginWindow(UI* const uiPtr, | ||||
| @@ -130,8 +132,10 @@ public: | |||||
| DISTRHO_UI_USES_SIZE_REQUEST, | DISTRHO_UI_USES_SIZE_REQUEST, | ||||
| false), | false), | ||||
| ui(uiPtr), | ui(uiPtr), | ||||
| initializing(true), | |||||
| receivedReshapeDuringInit(false) | |||||
| initializing(true) | |||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| , receivedReshapeDuringInit(false) | |||||
| #endif | |||||
| { | { | ||||
| if (pData->view == nullptr) | if (pData->view == nullptr) | ||||
| return; | return; | ||||
| @@ -159,12 +163,31 @@ public: | |||||
| initializing = false; | initializing = false; | ||||
| puglBackendLeave(pData->view); | puglBackendLeave(pData->view); | ||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| if (receivedReshapeDuringInit) | if (receivedReshapeDuringInit) | ||||
| { | { | ||||
| puglBackendEnter(pData->view); | puglBackendEnter(pData->view); | ||||
| #if defined(_MSC_VER) | |||||
| #pragma warning(push) | |||||
| #pragma warning(disable:4996) | |||||
| #elif defined(__clang__) | |||||
| #pragma clang diagnostic push | |||||
| #pragma clang diagnostic ignored "-Wdeprecated-declarations" | |||||
| #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 460 | |||||
| #pragma GCC diagnostic push | |||||
| #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |||||
| #endif | |||||
| ui->uiReshape(getWidth(), getHeight()); | ui->uiReshape(getWidth(), getHeight()); | ||||
| #if defined(_MSC_VER) | |||||
| #pragma warning(pop) | |||||
| #elif defined(__clang__) | |||||
| #pragma clang diagnostic pop | |||||
| #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 460 | |||||
| #pragma GCC diagnostic pop | |||||
| #endif | |||||
| puglBackendLeave(pData->view); | puglBackendLeave(pData->view); | ||||
| } | } | ||||
| #endif | |||||
| } | } | ||||
| // used for temporary windows (VST/CLAP get size without active/visible view) | // used for temporary windows (VST/CLAP get size without active/visible view) | ||||
| @@ -213,6 +236,17 @@ protected: | |||||
| ui->uiFocus(focus, mode); | ui->uiFocus(focus, mode); | ||||
| } | } | ||||
| #if DGL_ALLOW_DEPRECATED_METHODS | |||||
| #if defined(_MSC_VER) | |||||
| #pragma warning(push) | |||||
| #pragma warning(disable:4996) | |||||
| #elif defined(__clang__) | |||||
| #pragma clang diagnostic push | |||||
| #pragma clang diagnostic ignored "-Wdeprecated-declarations" | |||||
| #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 460 | |||||
| #pragma GCC diagnostic push | |||||
| #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |||||
| #endif | |||||
| void onReshape(const uint width, const uint height) override | void onReshape(const uint width, const uint height) override | ||||
| { | { | ||||
| DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,); | DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,); | ||||
| @@ -225,6 +259,14 @@ protected: | |||||
| ui->uiReshape(width, height); | ui->uiReshape(width, height); | ||||
| } | } | ||||
| #if defined(_MSC_VER) | |||||
| #pragma warning(pop) | |||||
| #elif defined(__clang__) | |||||
| #pragma clang diagnostic pop | |||||
| #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 460 | |||||
| #pragma GCC diagnostic pop | |||||
| #endif | |||||
| #endif | |||||
| void onScaleFactorChanged(const double scaleFactor) override | void onScaleFactorChanged(const double scaleFactor) override | ||||
| { | { | ||||