diff --git a/dpf b/dpf index ec28625..b52112b 160000 --- a/dpf +++ b/dpf @@ -1 +1 @@ -Subproject commit ec2862546a3613190e5dadf939efb6e4deff41fe +Subproject commit b52112bf23ef7eb91883828b27f12bb15cb671ac diff --git a/plugins/ProM/ResizeHandle.hpp b/plugins/ProM/ResizeHandle.hpp index eb804cd..4543663 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 = 2.0 * 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) };