From 8a9abd5ee9ef6384eedfab62218fb2e342b22108 Mon Sep 17 00:00:00 2001 From: thibaudk Date: Sat, 4 Jan 2025 21:05:36 +0000 Subject: [PATCH] [widgets] still flawed coordonates --- Hardware/3rdparty/bugui | 2 +- Hardware/Widgets/IntervalWidget.cpp | 24 +++++++----------------- Hardware/Widgets/IntervalWidget.hpp | 12 ++++++------ Hardware/Widgets/StateWidget.cpp | 18 +++--------------- Hardware/Widgets/StateWidget.hpp | 6 +++--- 5 files changed, 20 insertions(+), 42 deletions(-) diff --git a/Hardware/3rdparty/bugui b/Hardware/3rdparty/bugui index 586572a..7461767 160000 --- a/Hardware/3rdparty/bugui +++ b/Hardware/3rdparty/bugui @@ -1 +1 @@ -Subproject commit 586572a187266d3752e735774a6de62e1463af27 +Subproject commit 74617670a95ac6cf8bc59c999db89eddc5caed4c diff --git a/Hardware/Widgets/IntervalWidget.cpp b/Hardware/Widgets/IntervalWidget.cpp index ac72046..5940fbf 100644 --- a/Hardware/Widgets/IntervalWidget.cpp +++ b/Hardware/Widgets/IntervalWidget.cpp @@ -1,10 +1,12 @@ +#include + #include "IntervalWidget.hpp" namespace Hardware { IntervalWidget::IntervalWidget(Scenario::IntervalModel& interval, - container_widget* parent) - : bugui::container_widget{parent} + bugui::container_widget* parent) + : bugui::base_widget{parent} , model{interval} , skin{Process::Style::instance()} { } @@ -43,32 +45,20 @@ bool IntervalWidget::contains(int px, int py) const return false; } -bool IntervalWidget::on_press(int x, int y, bool pressed) +void IntervalWidget::on_press(int x, int y, bool pressed) { - if (!contains(x, y)) return false; - qDebug() << "is inside!"; - - return true; } -bool IntervalWidget::on_double_press(int x, int y) +void IntervalWidget::on_double_press(int x, int y) { - if (!contains(x, y)) return false; - qDebug() << "double pressed !"; - - return true; } -bool IntervalWidget::on_drag(int from_x, int from_y, int to_x, int to_y) +void IntervalWidget::on_drag(int from_x, int from_y, int to_x, int to_y) { - if (!contains(from_x, from_y)) return false; - if (from_y != to_y) model.requestHeightChange(to_y / static_cast(parent->height())); - - return true; } const Scenario::IntervalModel& IntervalWidget::get_model() const diff --git a/Hardware/Widgets/IntervalWidget.hpp b/Hardware/Widgets/IntervalWidget.hpp index 57dd3df..13a8cb0 100644 --- a/Hardware/Widgets/IntervalWidget.hpp +++ b/Hardware/Widgets/IntervalWidget.hpp @@ -2,19 +2,19 @@ #include #include -#include +#include namespace Hardware { -struct IntervalWidget final : bugui::container_widget +struct IntervalWidget final : bugui::base_widget { explicit IntervalWidget(Scenario::IntervalModel& interval, - container_widget* parent); + bugui::container_widget* parent); void paint(bugui::painter& painter) const override; - bool on_press(int x, int y, bool pressed) override; - bool on_double_press(int x, int y) override; - bool on_drag(int from_x, int from_y, int to_x, int to_y) override; + void on_press(int x, int y, bool pressed) override; + void on_double_press(int x, int y) override; + void on_drag(int from_x, int from_y, int to_x, int to_y) override; int x() const override; int y() const override; diff --git a/Hardware/Widgets/StateWidget.cpp b/Hardware/Widgets/StateWidget.cpp index 914b7ca..e5a8cb4 100644 --- a/Hardware/Widgets/StateWidget.cpp +++ b/Hardware/Widgets/StateWidget.cpp @@ -38,32 +38,20 @@ bool StateWidget::contains(int px, int py) const return false; } -bool StateWidget::on_press(int x, int y, bool pressed) +void StateWidget::on_press(int x, int y, bool pressed) { - if (!contains(x, y)) return false; - qDebug() << "is inside!"; - - return true; } -bool StateWidget::on_double_press(int x, int y) +void StateWidget::on_double_press(int x, int y) { - if (!contains(x, y)) return false; - qDebug() << "double pressed !"; - - return true; } -bool StateWidget::on_drag(int from_x, int from_y, int to_x, int to_y) +void StateWidget::on_drag(int from_x, int from_y, int to_x, int to_y) { - if (!contains(from_x, from_y)) return false; - if (from_y != to_y) model.setHeightPercentage(to_y / static_cast(parent->height())); - - return true; } const Scenario::StateModel& StateWidget::get_model() const diff --git a/Hardware/Widgets/StateWidget.hpp b/Hardware/Widgets/StateWidget.hpp index b7a9b94..8f38aea 100644 --- a/Hardware/Widgets/StateWidget.hpp +++ b/Hardware/Widgets/StateWidget.hpp @@ -12,9 +12,9 @@ struct StateWidget final : bugui::container_widget container_widget* parent); void paint(bugui::painter& painter) const override; - bool on_press(int x, int y, bool pressed) override; - bool on_double_press(int x, int y) override; - bool on_drag(int from_x, int from_y, int to_x, int to_y) override; + void on_press(int x, int y, bool pressed) override; + void on_double_press(int x, int y) override; + void on_drag(int from_x, int from_y, int to_x, int to_y) override; int x() const override; int y() const override;