Skip to content

Commit

Permalink
Update DPF
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Jan 9, 2022
1 parent 8616f96 commit c4d4c60
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 21 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update -qq
sudo apt-get install -yqq --allow-downgrades libpcre2-8-0/focal
sudo apt-get install -yqq --allow-downgrades libpcre2-8-0/focal libpcre2-16-0/focal libpcre2-32-0/focal libpcre2-posix2/focal
- name: Set up dependencies
run: |
sudo dpkg --add-architecture arm64
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update -qq
sudo apt-get install -yqq --allow-downgrades libpcre2-8-0/focal
sudo apt-get install -yqq --allow-downgrades libpcre2-8-0/focal libpcre2-16-0/focal libpcre2-32-0/focal libpcre2-posix2/focal
- name: Set up dependencies
run: |
sudo dpkg --add-architecture armhf
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update -qq
sudo apt-get install -yqq --allow-downgrades libpcre2-8-0/focal
sudo apt-get install -yqq --allow-downgrades libpcre2-8-0/focal libpcre2-16-0/focal libpcre2-32-0/focal libpcre2-posix2/focal
- name: Set up dependencies
run: |
sudo dpkg --add-architecture i386
Expand Down Expand Up @@ -193,7 +193,7 @@ jobs:
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update -qq
sudo apt-get install -yqq --allow-downgrades libpcre2-8-0/focal
sudo apt-get install -yqq --allow-downgrades libpcre2-8-0/focal libpcre2-16-0/focal libpcre2-32-0/focal libpcre2-posix2/focal
- name: Set up dependencies
run: |
sudo dpkg --add-architecture i386
Expand Down Expand Up @@ -327,14 +327,14 @@ jobs:
done
- name: Test VST2 plugins
run: |
for p in $(ls bin/ | grep vst.so); do \
for p in $(find bin/ | grep -e vst.so -e '.*\.vst/.*\.so'); do \
env CARLA_BRIDGE_DUMMY=1 CARLA_BRIDGE_TESTING=native \
valgrind \
--error-exitcode=255 \
--leak-check=full \
--track-origins=yes \
--suppressions=./dpf/utils/valgrind-dpf.supp \
/usr/lib/carla/carla-bridge-native vst2 ./bin/${p} "" 1>/dev/null; \
/usr/lib/carla/carla-bridge-native vst2 ./${p} "" 1>/dev/null; \
done
- name: Test VST3 plugins
run: |
Expand Down
2 changes: 1 addition & 1 deletion dpf
51 changes: 37 additions & 14 deletions plugins/glBars/ResizeHandle.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Resize handle for DPF
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
*
* 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
Expand Down Expand Up @@ -29,7 +29,8 @@ class ResizeHandle : public TopLevelWidget
explicit ResizeHandle(Window& window)
: TopLevelWidget(window),
handleSize(16),
resizing(false)
hasCursor(false),
isResizing(false)
{
resetArea();
}
Expand All @@ -38,12 +39,14 @@ class ResizeHandle : public TopLevelWidget
explicit ResizeHandle(TopLevelWidget* const tlw)
: TopLevelWidget(tlw->getWindow()),
handleSize(16),
resizing(false)
hasCursor(false),
isResizing(false)
{
resetArea();
}

/** Set the handle size, minimum 16. */
/** Set the handle size, minimum 16.
* Scale factor is automatically applied on top of this size as needed */
void setHandleSize(const uint size)
{
handleSize = std::max(16u, size);
Expand All @@ -53,12 +56,14 @@ 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();

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

// draw white lines, 1px wide
Color(1.0f, 1.0f, 1.0f).setFor(context);
Expand All @@ -75,6 +80,7 @@ class ResizeHandle : public TopLevelWidget
l1b.draw(context, lineWidth);
l2b.draw(context, lineWidth);
l3b.draw(context, lineWidth);
#endif
}

bool onMouse(const MouseEvent& ev) override
Expand All @@ -84,15 +90,16 @@ class ResizeHandle : public TopLevelWidget

if (ev.press && area.contains(ev.pos))
{
resizing = true;
isResizing = true;
resizingSize = Size<double>(getWidth(), getHeight());
lastResizePoint = ev.pos;
return true;
}

if (resizing && ! ev.press)
if (isResizing && ! ev.press)
{
resizing = false;
isResizing = false;
recheckCursor(ev.pos);
return true;
}

Expand All @@ -101,18 +108,23 @@ class ResizeHandle : public TopLevelWidget

bool onMotion(const MotionEvent& ev) override
{
if (! resizing)
if (! isResizing)
{
recheckCursor(ev.pos);
return false;
}

const Size<double> offset(ev.pos.getX() - lastResizePoint.getX(),
ev.pos.getY() - lastResizePoint.getY());

resizingSize += offset;
lastResizePoint = ev.pos;

// TODO min width, min height
const uint minWidth = 16;
const uint minHeight = 16;
// TODO keepAspectRatio
bool keepAspectRatio;
const Size<uint> minSize(getWindow().getGeometryConstraints(keepAspectRatio));
const uint minWidth = minSize.getWidth();
const uint minHeight = minSize.getHeight();

if (resizingSize.getWidth() < minWidth)
resizingSize.setWidth(minWidth);
Expand All @@ -139,10 +151,21 @@ class ResizeHandle : public TopLevelWidget
uint handleSize;

// event handling state
bool resizing;
bool hasCursor, isResizing;
Point<double> lastResizePoint;
Size<double> resizingSize;

void recheckCursor(const Point<double>& pos)
{
const bool shouldHaveCursor = area.contains(pos);

if (shouldHaveCursor == hasCursor)
return;

hasCursor = shouldHaveCursor;
setCursor(shouldHaveCursor ? kMouseCursorDiagonal : kMouseCursorArrow);
}

void resetArea()
{
const double scaleFactor = getScaleFactor();
Expand Down

0 comments on commit c4d4c60

Please sign in to comment.