Skip to content

Commit

Permalink
Merge: origin/develop -> improve/state-allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi committed Feb 5, 2025
2 parents e2b900e + 34435e0 commit 116dd85
Show file tree
Hide file tree
Showing 23 changed files with 437 additions and 140 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ jobs:
strategy:
matrix:
os:
# wrong use of AU MIDIPacket
# - macos-12
# - macos-13
# - macos-14
- macos-13
- macos-14
- macos-15
# webgui failure
# - ubuntu-20.04
- ubuntu-22.04
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,49 +42,49 @@ jobs:
suffix: _24_04
target: ${{ matrix.target }}

macos-12:
macos-13:
strategy:
matrix:
target: [macos-intel, macos-universal, macos-10.15]
runs-on: macos-12
runs-on: macos-13
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: distrho/dpf-cmake-action@v1
with:
dpf_path: .
suffix: _12
suffix: _13
target: ${{ matrix.target }}

macos-13:
macos-14:
strategy:
matrix:
target: [macos-intel, macos-universal, macos-10.15]
runs-on: macos-13
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: distrho/dpf-cmake-action@v1
with:
dpf_path: .
suffix: _13
suffix: _14
target: ${{ matrix.target }}

macos-14:
macos-15:
strategy:
matrix:
target: [macos-intel, macos-universal, macos-10.15]
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: distrho/dpf-cmake-action@v1
with:
dpf_path: .
suffix: _14
suffix: _15
target: ${{ matrix.target }}

cmake_win32:
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/example-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,47 +39,47 @@ jobs:
suffix: _24_04
target: ${{ matrix.target }}

macos-12:
macos-13:
strategy:
matrix:
target: [macos-intel, macos-universal, macos-10.15]
runs-on: macos-12
runs-on: macos-13
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: distrho/dpf-makefile-action@v1
with:
dpf_path: .
suffix: _12
suffix: _13
target: ${{ matrix.target }}

macos-13:
macos-14:
strategy:
matrix:
target: [macos-intel, macos-universal, macos-10.15]
runs-on: macos-13
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: distrho/dpf-makefile-action@v1
with:
dpf_path: .
suffix: _13
suffix: _14
target: ${{ matrix.target }}

macos-14:
macos-15:
strategy:
matrix:
target: [macos-intel, macos-universal, macos-10.15]
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: distrho/dpf-makefile-action@v1
with:
dpf_path: .
suffix: _14
suffix: _15
target: ${{ matrix.target }}
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ CMakeFiles
CMakeSettings.json
cmake_install.cmake

bin/
build/
docs/
utils/lv2_ttl_generator
utils/lv2_ttl_generator.dSYM/
/bin/
/build/
/docs/
/khronos/
/utils/lv2_ttl_generator
/utils/lv2_ttl_generator.dSYM/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Bug reports happen on the [DPF github project](https://github.com/DISTRHO/DPF/is

Online documentation is available at [https://distrho.github.io/DPF/](https://distrho.github.io/DPF/).

Online help and discussion about DPF happens in the [kx.studio chat, DPF room](https://chat.kx.studio/channel/dpf).
Online help and discussion about DPF happens in the [DPF github discussions](https://github.com/DISTRHO/DPF/discussions).


## List of plugins made with DPF:
Expand Down
8 changes: 7 additions & 1 deletion dgl/EventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2025 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 @@ -63,6 +63,9 @@ class ButtonEventHandler
bool isCheckable() const noexcept;
void setCheckable(bool checkable) noexcept;

bool isEnabled() const noexcept;
void setEnabled(bool enabled, bool appliesToEventInput = true) noexcept;

Point<double> getLastClickPosition() const noexcept;
Point<double> getLastMotionPosition() const noexcept;

Expand Down Expand Up @@ -121,6 +124,9 @@ class KnobEventHandler
KnobEventHandler& operator=(const KnobEventHandler& other);
virtual ~KnobEventHandler();

bool isEnabled() const noexcept;
void setEnabled(bool enabled, bool appliesToEventInput = true) noexcept;

// if setStep(1) has been called before, this returns true
bool isInteger() const noexcept;

Expand Down
92 changes: 91 additions & 1 deletion dgl/src/EventHandlers.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2025 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 @@ -31,6 +31,8 @@ struct ButtonEventHandler::PrivateData {
int state;
bool checkable;
bool checked;
bool enabled;
bool enabledInput;

Point<double> lastClickPos;
Point<double> lastMotionPos;
Expand All @@ -44,11 +46,16 @@ struct ButtonEventHandler::PrivateData {
state(kButtonStateDefault),
checkable(false),
checked(false),
enabled(true),
enabledInput(true),
lastClickPos(0, 0),
lastMotionPos(0, 0) {}

bool mouseEvent(const Widget::MouseEvent& ev)
{
if (! enabledInput)
return false;

lastClickPos = ev.pos;

// button was released, handle it now
Expand Down Expand Up @@ -98,6 +105,9 @@ struct ButtonEventHandler::PrivateData {

bool motionEvent(const Widget::MotionEvent& ev)
{
if (! enabledInput)
return false;

// keep pressed
if (button != -1)
{
Expand Down Expand Up @@ -171,6 +181,27 @@ struct ButtonEventHandler::PrivateData {
}
}

void setEnabled(const bool enabled2, const bool appliesToEventInput) noexcept
{
if (appliesToEventInput)
enabledInput = enabled2;

if (enabled == enabled2)
return;

// reset temp vars if disabling
if (! enabled2)
{
button = -1;
state = kButtonStateDefault;
lastClickPos = Point<double>();
lastMotionPos = Point<double>();
}

enabled = enabled2;
widget->repaint();
}

DISTRHO_DECLARE_NON_COPYABLE(PrivateData)
};

Expand Down Expand Up @@ -217,6 +248,16 @@ void ButtonEventHandler::setCheckable(const bool checkable) noexcept
pData->checkable = checkable;
}

bool ButtonEventHandler::isEnabled() const noexcept
{
return pData->enabled;
}

void ButtonEventHandler::setEnabled(const bool enabled, const bool appliesToEventInput) noexcept
{
pData->setEnabled(enabled, appliesToEventInput);
}

Point<double> ButtonEventHandler::getLastClickPosition() const noexcept
{
return pData->lastClickPos;
Expand Down Expand Up @@ -281,6 +322,8 @@ struct KnobEventHandler::PrivateData {
float value;
float valueDef;
float valueTmp;
bool enabled;
bool enabledInput;
bool usingDefault;
bool usingLog;
Orientation orientation;
Expand All @@ -301,6 +344,8 @@ struct KnobEventHandler::PrivateData {
value(0.5f),
valueDef(value),
valueTmp(value),
enabled(true),
enabledInput(true),
usingDefault(false),
usingLog(false),
orientation(Vertical),
Expand All @@ -320,6 +365,8 @@ struct KnobEventHandler::PrivateData {
value(other->value),
valueDef(other->valueDef),
valueTmp(value),
enabled(other->enabled),
enabledInput(other->enabledInput),
usingDefault(other->usingDefault),
usingLog(other->usingLog),
orientation(other->orientation),
Expand All @@ -338,6 +385,8 @@ struct KnobEventHandler::PrivateData {
value = other->value;
valueDef = other->valueDef;
valueTmp = value;
enabled = other->enabled;
enabledInput = other->enabledInput;
usingDefault = other->usingDefault;
usingLog = other->usingLog;
orientation = other->orientation;
Expand All @@ -363,6 +412,9 @@ struct KnobEventHandler::PrivateData {

bool mouseEvent(const Widget::MouseEvent& ev, const double scaleFactor)
{
if (! enabledInput)
return false;

if (ev.button != 1)
return false;

Expand Down Expand Up @@ -416,6 +468,9 @@ struct KnobEventHandler::PrivateData {

bool motionEvent(const Widget::MotionEvent& ev, const double scaleFactor)
{
if (! enabledInput)
return false;

if ((state & kKnobStateDragging) == 0x0)
return false;

Expand Down Expand Up @@ -501,6 +556,9 @@ struct KnobEventHandler::PrivateData {

bool scrollEvent(const Widget::ScrollEvent& ev)
{
if (! enabledInput)
return false;

if (! widget->contains(ev.pos))
return false;

Expand Down Expand Up @@ -541,6 +599,28 @@ struct KnobEventHandler::PrivateData {
return ((usingLog ? invlogscale(value) : value) - minimum) / diff;
}

void setEnabled(const bool enabled2, const bool appliesToEventInput) noexcept
{
if (appliesToEventInput)
enabledInput = enabled2;

if (enabled == enabled2)
return;

// reset temp vars if disabling
if (! enabled2)
{
state = kKnobStateDefault;
lastX = 0.0;
lastY = 0.0;
lastClickTime = 0;
valueTmp = value;
}

enabled = enabled2;
widget->repaint();
}

void setRange(const float min, const float max) noexcept
{
DISTRHO_SAFE_ASSERT_RETURN(max > min,);
Expand Down Expand Up @@ -598,6 +678,16 @@ KnobEventHandler::~KnobEventHandler()
delete pData;
}

bool KnobEventHandler::isEnabled() const noexcept
{
return pData->enabled;
}

void KnobEventHandler::setEnabled(const bool enabled, const bool appliesToEventInput) noexcept
{
pData->setEnabled(enabled, appliesToEventInput);
}

bool KnobEventHandler::isInteger() const noexcept
{
return d_isEqual(pData->step, 1.f);
Expand Down
Loading

0 comments on commit 116dd85

Please sign in to comment.