1616
1717#pragma once
1818
19- #include " TopLevelWidget.hpp"
20- #include " Color.hpp"
19+ #include " NanoVG.hpp"
2120
2221START_NAMESPACE_DGL
2322
2423/* * Resize handle for DPF windows, will sit on bottom-right. */
25- class ResizeHandle : public TopLevelWidget
24+ class ResizeHandle : public NanoTopLevelWidget
2625{
2726public:
2827 /* * Overloaded constructor, will fetch the window from an existing top-level widget. */
2928 explicit ResizeHandle (TopLevelWidget* const tlw)
30- : TopLevelWidget (tlw->getWindow ()),
29+ : NanoTopLevelWidget (tlw->getWindow ()),
3130 handleSize(16 ),
3231 hasCursor(false ),
3332 isResizing(false )
@@ -44,22 +43,19 @@ class ResizeHandle : public TopLevelWidget
4443 }
4544
4645protected:
47- void onDisplay () override
46+ void onNanoDisplay () override
4847 {
49- const GraphicsContext& context (getGraphicsContext ());
5048 const double lineWidth = 1.0 * getScaleFactor ();
51-
52- glMatrixMode (GL_MODELVIEW);
53- glLineWidth (lineWidth);
49+ strokeWidth (lineWidth);
5450
5551 // draw white lines, 1px wide
56- glColor3f ( 1 .0f , 1 .0f , 1 .0f );
52+ strokeColor ( Color ( 1 .0f , 1 .0f , 1 .0f ) );
5753 drawLine (l1);
5854 drawLine (l2);
5955 drawLine (l3);
6056
6157 // draw black lines, offset by 1px and 1px wide
62- glColor3f ( 0 .0f , 0 .0f , 0 .0f );
58+ strokeColor ( Color ( 0 .0f , 0 .0f , 0 .0f ) );
6359 Line<double > l1b (l1), l2b (l2), l3b (l3);
6460 l1b.moveBy (lineWidth, lineWidth);
6561 l2b.moveBy (lineWidth, lineWidth);
@@ -69,6 +65,14 @@ class ResizeHandle : public TopLevelWidget
6965 drawLine (l3b);
7066 }
7167
68+ void drawLine (const Line<double >& line)
69+ {
70+ beginPath ();
71+ moveTo (line.getStartPos ().getX (), line.getStartPos ().getY ());
72+ lineTo (line.getEndPos ().getX (), line.getEndPos ().getY ());
73+ stroke ();
74+ }
75+
7276 bool onMouse (const MouseEvent& ev) override
7377 {
7478 if (ev.button != 1 )
@@ -155,7 +159,7 @@ class ResizeHandle : public TopLevelWidget
155159 void resetArea ()
156160 {
157161 const double scaleFactor = getScaleFactor ();
158- const uint margin = 0.0 * scaleFactor;
162+ const uint margin = 1.5 * scaleFactor;
159163 const uint size = handleSize * scaleFactor;
160164
161165 area = Rectangle<uint>(getWidth () - size - margin,
@@ -187,25 +191,6 @@ class ResizeHandle : public TopLevelWidget
187191 l3.setEndPos (x + offset, y + linesize + offset);
188192 }
189193
190- void drawLine (const Line<double >& line)
191- {
192- drawLine (line.getStartPos (), line.getEndPos ());
193- }
194-
195- void drawLine (const Point<double >& posStart, const Point<double >& posEnd)
196- {
197- DISTRHO_SAFE_ASSERT_RETURN (posStart != posEnd,);
198-
199- glBegin (GL_LINES);
200-
201- {
202- glVertex2d (posStart.getX (), posStart.getY ());
203- glVertex2d (posEnd.getX (), posEnd.getY ());
204- }
205-
206- glEnd ();
207- }
208-
209194 DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizeHandle)
210195};
211196
0 commit comments