commit accb8c96daf69708bd81f93b7c057637be49aec9
parent ab2e7e732f4da89a97f46a6ae1b88567f66aaf3b
Author: falkTX <falktx@falktx.com>
Date: Sat, 26 Jun 2021 22:37:17 +0100
Add ButtonEventHandler::getLastMotionPosition(), fix whitespace
Diffstat:
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/dgl/EventHandlers.hpp b/dgl/EventHandlers.hpp
@@ -52,16 +52,18 @@ public:
bool isCheckable() const noexcept;
void setCheckable(bool checkable) noexcept;
+ Point<double> getLastMotionPosition() const noexcept;
+
void setCallback(Callback* callback) noexcept;
bool mouseEvent(const Widget::MouseEvent& ev);
bool motionEvent(const Widget::MotionEvent& ev);
protected:
- State getState() const noexcept;
- void clearState() noexcept;
+ State getState() const noexcept;
+ void clearState() noexcept;
- virtual void stateChanged(State state, State oldState);
+ virtual void stateChanged(State state, State oldState);
void setInternalCallback(Callback* callback) noexcept;
void triggerUserCallback(SubWidget* widget, int button);
diff --git a/dgl/src/EventHandlers.cpp b/dgl/src/EventHandlers.cpp
@@ -59,18 +59,14 @@ struct ButtonEventHandler::PrivateData {
const int state2 = state;
state &= ~kButtonStateActive;
+ self->stateChanged(static_cast<State>(state), static_cast<State>(state2));
+ widget->repaint();
+
// cursor was moved outside the button bounds, ignore click
if (! widget->contains(ev.pos))
- {
- self->stateChanged(static_cast<State>(state), static_cast<State>(state2));
- widget->repaint();
return true;
- }
// still on bounds, register click
- self->stateChanged(static_cast<State>(state), static_cast<State>(state2));
- widget->repaint();
-
if (checkable)
checked = !checked;
@@ -217,6 +213,11 @@ void ButtonEventHandler::setCheckable(const bool checkable) noexcept
pData->checkable = checkable;
}
+Point<double> ButtonEventHandler::getLastMotionPosition() const noexcept
+{
+ return pData->oldMotionPos;
+}
+
void ButtonEventHandler::setCallback(Callback* const callback) noexcept
{
pData->userCallback = callback;