Skip to content

Commit

Permalink
Update to latest DPF, force GL1 drawing on resize handle
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Oct 30, 2022
1 parent 8686010 commit 6c954be
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
51 changes: 28 additions & 23 deletions plugins/ProM/ResizeHandle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ START_NAMESPACE_DGL
class ResizeHandle : public TopLevelWidget
{
public:
/** Constructor for placing this handle on top of a window. */
explicit ResizeHandle(Window& window)
: TopLevelWidget(window),
handleSize(16),
hasCursor(false),
isResizing(false)
{
resetArea();
}

/** Overloaded constructor, will fetch the window from an existing top-level widget. */
explicit ResizeHandle(TopLevelWidget* const tlw)
: TopLevelWidget(tlw->getWindow()),
Expand All @@ -56,31 +46,27 @@ class ResizeHandle : public TopLevelWidget
protected:
void onDisplay() override
{
// TODO implement gl3 stuff in DPF
#ifndef DGL_USE_OPENGL3
const GraphicsContext& context(getGraphicsContext());
const double lineWidth = 1.0 * getScaleFactor();

#if defined(DGL_OPENGL) && !defined(DGL_USE_OPENGL3)
glMatrixMode(GL_MODELVIEW);
#endif
glLineWidth(lineWidth);

// draw white lines, 1px wide
Color(1.0f, 1.0f, 1.0f).setFor(context);
l1.draw(context, lineWidth);
l2.draw(context, lineWidth);
l3.draw(context, lineWidth);
glColor3f(1.0f, 1.0f, 1.0f);
drawLine(l1);
drawLine(l2);
drawLine(l3);

// draw black lines, offset by 1px and 1px wide
Color(0.0f, 0.0f, 0.0f).setFor(context);
glColor3f(0.0f, 0.0f, 0.0f);
Line<double> l1b(l1), l2b(l2), l3b(l3);
l1b.moveBy(lineWidth, lineWidth);
l2b.moveBy(lineWidth, lineWidth);
l3b.moveBy(lineWidth, lineWidth);
l1b.draw(context, lineWidth);
l2b.draw(context, lineWidth);
l3b.draw(context, lineWidth);
#endif
drawLine(l1b);
drawLine(l2b);
drawLine(l3b);
}

bool onMouse(const MouseEvent& ev) override
Expand Down Expand Up @@ -201,6 +187,25 @@ class ResizeHandle : public TopLevelWidget
l3.setEndPos(x + offset, y + linesize + offset);
}

void drawLine(const Line<double>& line)
{
drawLine(line.getStartPos(), line.getEndPos());
}

void drawLine(const Point<double>& posStart, const Point<double>& 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)
};

Expand Down

0 comments on commit 6c954be

Please sign in to comment.