diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp index b21e5c4c..538d347b 100644 --- a/dgl/src/Window.cpp +++ b/dgl/src/Window.cpp @@ -180,22 +180,22 @@ int Window::getOffsetX() const noexcept { DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, 0); - return puglGetFrame(pData->view).x; + return puglGetPositionHint(pData->view, PUGL_CURRENT_POSITION).x; } int Window::getOffsetY() const noexcept { DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, 0); - return puglGetFrame(pData->view).y; + return puglGetPositionHint(pData->view, PUGL_CURRENT_POSITION).y; } Point Window::getOffset() const noexcept { DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, Point()); - const PuglRect rect = puglGetFrame(pData->view); - return Point(rect.x, rect.y); + const PuglPoint point = puglGetPositionHint(pData->view, PUGL_CURRENT_POSITION); + return Point(point.x, point.y); } void Window::setOffsetX(const int x) @@ -214,7 +214,7 @@ void Window::setOffset(const int x, const int y) DISTRHO_SAFE_ASSERT_RETURN(!pData->isEmbed,); if (pData->view != nullptr) - puglSetPosition(pData->view, x, y); + puglSetPositionHint(pData->view, PUGL_CURRENT_POSITION, x, y); } void Window::setOffset(const Point& offset) @@ -226,7 +226,7 @@ uint Window::getWidth() const noexcept { DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, 0); - const double width = puglGetFrame(pData->view).width; + const double width = puglGetSizeHint(pData->view, PUGL_CURRENT_SIZE).width; DISTRHO_SAFE_ASSERT_RETURN(width > 0.0, 0); return static_cast(width + 0.5); } @@ -235,7 +235,7 @@ uint Window::getHeight() const noexcept { DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, 0); - const double height = puglGetFrame(pData->view).height; + const double height = puglGetSizeHint(pData->view, PUGL_CURRENT_SIZE).height; DISTRHO_SAFE_ASSERT_RETURN(height > 0.0, 0); return static_cast(height + 0.5); } @@ -244,11 +244,11 @@ Size Window::getSize() const noexcept { DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, Size()); - const PuglRect rect = puglGetFrame(pData->view); - DISTRHO_SAFE_ASSERT_RETURN(rect.width > 0.0, Size()); - DISTRHO_SAFE_ASSERT_RETURN(rect.height > 0.0, Size()); - return Size(static_cast(rect.width + 0.5), - static_cast(rect.height + 0.5)); + const PuglArea size = puglGetSizeHint(pData->view, PUGL_CURRENT_SIZE); + DISTRHO_SAFE_ASSERT_RETURN(size.width > 0.0, Size()); + DISTRHO_SAFE_ASSERT_RETURN(size.height > 0.0, Size()); + return Size(static_cast(size.width + 0.5), + static_cast(size.height + 0.5)); } void Window::setWidth(const uint width) @@ -429,7 +429,7 @@ void Window::repaint() noexcept if (pData->usesScheduledRepaints) pData->appData->needsRepaint = true; - puglPostRedisplay(pData->view); + puglObscureView(pData->view); } void Window::repaint(const Rectangle& rect) noexcept @@ -440,22 +440,21 @@ void Window::repaint(const Rectangle& rect) noexcept if (pData->usesScheduledRepaints) pData->appData->needsRepaint = true; - PuglRect prect = { - static_cast(rect.getX()), - static_cast(rect.getY()), - static_cast(rect.getWidth()), - static_cast(rect.getHeight()), - }; + PuglCoord x = static_cast(rect.getX()); + PuglCoord y = static_cast(rect.getY()); + PuglSpan w = static_cast(rect.getWidth()); + PuglSpan h = static_cast(rect.getHeight()); + if (pData->autoScaling) { const double autoScaleFactor = pData->autoScaleFactor; - prect.x = static_cast(prect.x * autoScaleFactor); - prect.y = static_cast(prect.y * autoScaleFactor); - prect.width = static_cast(prect.width * autoScaleFactor + 0.5); - prect.height = static_cast(prect.height * autoScaleFactor + 0.5); + x = static_cast(x * autoScaleFactor); + y = static_cast(y * autoScaleFactor); + w = static_cast(w * autoScaleFactor + 0.5); + h = static_cast(h * autoScaleFactor + 0.5); } - puglPostRedisplayRect(pData->view, prect); + puglObscureRegion(pData->view, x, y, w, h); } void Window::renderToPicture(const char* const filename) diff --git a/dgl/src/WindowPrivateData.cpp b/dgl/src/WindowPrivateData.cpp index 2d0eee67..ac82d36c 100644 --- a/dgl/src/WindowPrivateData.cpp +++ b/dgl/src/WindowPrivateData.cpp @@ -91,10 +91,10 @@ static PuglView* puglNewViewWithParentWindow(PuglWorld* const world, const uintp if (PuglView* const view = puglNewView(world)) { - puglSetParentWindow(view, parentWindowHandle); + puglSetParent(view, parentWindowHandle); if (parentWindowHandle != 0) - puglSetPosition(view, 0, 0); + puglSetPositionHint(view, PUGL_CURRENT_POSITION, 0, 0); return view; } @@ -617,7 +617,7 @@ void Window::PrivateData::onPuglConfigure(const uint width, const uint height) #endif // always repaint after a resize - puglPostRedisplay(view); + puglObscureView(view); } void Window::PrivateData::onPuglExpose() @@ -637,9 +637,9 @@ void Window::PrivateData::onPuglExpose() if (char* const filename = filenameToRenderInto) { - const PuglRect rect = puglGetFrame(view); + const PuglArea size = puglGetSizeHint(view, PUGL_CURRENT_SIZE); filenameToRenderInto = nullptr; - renderToPicture(filename, getGraphicsContext(), static_cast(rect.width), static_cast(rect.height)); + renderToPicture(filename, getGraphicsContext(), static_cast(size.width), static_cast(size.height)); std::free(filename); } #endif diff --git a/dgl/src/pugl-upstream b/dgl/src/pugl-upstream index d4d964f1..66afe808 160000 --- a/dgl/src/pugl-upstream +++ b/dgl/src/pugl-upstream @@ -1 +1 @@ -Subproject commit d4d964f129b4bf999c53ba40381bd1095fafb649 +Subproject commit 66afe808e8c17f41cf6122158df96361cb42cccb diff --git a/dgl/src/pugl.cpp b/dgl/src/pugl.cpp index e67563af..e592e1b5 100644 --- a/dgl/src/pugl.cpp +++ b/dgl/src/pugl.cpp @@ -405,7 +405,7 @@ PuglStatus puglSetSizeAndDefault(PuglView* view, uint width, uint height) // matches upstream pugl, adds flush at the end if (view->impl->win) { - if (const PuglStatus status = puglSetSize(view, width, height)) + if (const PuglStatus status = puglSetSizeHint(view, PUGL_CURRENT_SIZE, width, height)) return status; // updateSizeHints will use last known size, which is not yet updated