[Widgets] press tests
This commit is contained in:
parent
9887ab6f8d
commit
94135cbb43
8 changed files with 21 additions and 51 deletions
2
Hardware/3rdparty/bugui
vendored
2
Hardware/3rdparty/bugui
vendored
|
@ -1 +1 @@
|
|||
Subproject commit a35f73f5e0600726458454c23ffcf1e1ceb98d8e
|
||||
Subproject commit 0a04a681f6f1baf201c48ce2c27ff848b2101ed2
|
|
@ -100,7 +100,12 @@ void EventWidget::on_state_removed(const Scenario::StateModel& state)
|
|||
|
||||
void EventWidget::on_press(int x, int y, bool pressed)
|
||||
{
|
||||
qDebug() << "is inside!";
|
||||
qDebug() << "event pressed";
|
||||
}
|
||||
|
||||
void EventWidget::on_double_press(int x, int y, bool pressed)
|
||||
{
|
||||
qDebug() << "event double pressed";
|
||||
}
|
||||
|
||||
} // namespace Hardware
|
||||
|
|
|
@ -25,6 +25,8 @@ private:
|
|||
void paint(bugui::painter& painter) const override;
|
||||
|
||||
void on_press(int x, int y, bool pressed) override;
|
||||
void on_double_press(int x, int y, bool pressed);
|
||||
|
||||
void on_state_added(Scenario::StateModel& state);
|
||||
void on_state_removed(const Scenario::StateModel& state);
|
||||
|
||||
|
|
|
@ -9,28 +9,7 @@ IntervalWidget::IntervalWidget(Scenario::IntervalModel& interval,
|
|||
ScenarioWidget* scenario,
|
||||
bugui::container_widget* parent)
|
||||
: ScenarioComponentSpec<Scenario::IntervalModel>{interval, scenario, parent}
|
||||
{
|
||||
connect(&model,
|
||||
&Scenario::IntervalModel::heightPercentageChanged,
|
||||
this,
|
||||
[scenario] (double) { scenario->update(); });
|
||||
|
||||
connect(&model,
|
||||
&Scenario::IntervalModel::dateChanged,
|
||||
this,
|
||||
[scenario] (const TimeVal&) { scenario->update(); });
|
||||
}
|
||||
|
||||
IntervalWidget::~IntervalWidget()
|
||||
{
|
||||
disconnect(&model,
|
||||
&Scenario::IntervalModel::heightPercentageChanged,
|
||||
this, 0);
|
||||
|
||||
disconnect(&model,
|
||||
&Scenario::IntervalModel::dateChanged,
|
||||
this, 0);
|
||||
}
|
||||
{ }
|
||||
|
||||
int IntervalWidget::x() const
|
||||
{
|
||||
|
@ -47,19 +26,12 @@ int IntervalWidget::width() const
|
|||
return model.duration.defaultDuration().sec();
|
||||
}
|
||||
|
||||
void IntervalWidget::paint(bugui::painter& painter) const
|
||||
{
|
||||
// Copied from MiniscenarioView
|
||||
// const auto col = skin.IntervalBase().color();
|
||||
// painter.set_color(col.red(), col.green(), col.blue(), col.alpha());
|
||||
|
||||
// painter.draw_line(0, 0, width(), 0);
|
||||
}
|
||||
|
||||
bool IntervalWidget::contains(int px, int py) const
|
||||
{
|
||||
if (px >= 0 &&
|
||||
px <= width() &&
|
||||
// ignore first and last cell
|
||||
// so that timesyncs are pressed
|
||||
// at the extremeties
|
||||
if (px > 0 && px < width() &&
|
||||
py == 0)
|
||||
return true;
|
||||
|
||||
|
@ -68,12 +40,12 @@ bool IntervalWidget::contains(int px, int py) const
|
|||
|
||||
void IntervalWidget::on_press(int x, int y, bool pressed)
|
||||
{
|
||||
qDebug() << "is inside!";
|
||||
qDebug() << "interval pressed";
|
||||
}
|
||||
|
||||
void IntervalWidget::on_double_press(int x, int y)
|
||||
{
|
||||
qDebug() << "double pressed !";
|
||||
qDebug() << "interval double pressed";
|
||||
}
|
||||
|
||||
void IntervalWidget::on_drag(int from_x, int from_y, int to_x, int to_y)
|
||||
|
@ -83,6 +55,3 @@ void IntervalWidget::on_drag(int from_x, int from_y, int to_x, int to_y)
|
|||
}
|
||||
|
||||
} // namespace hardware
|
||||
|
||||
#include <wobjectimpl.h>
|
||||
W_OBJECT_IMPL(Hardware::IntervalWidget);
|
||||
|
|
|
@ -8,23 +8,16 @@
|
|||
namespace Hardware
|
||||
{
|
||||
struct IntervalWidget final : ScenarioComponentSpec<Scenario::IntervalModel>
|
||||
, QObject
|
||||
{
|
||||
explicit IntervalWidget(Scenario::IntervalModel& interval,
|
||||
ScenarioWidget* scenario,
|
||||
bugui::container_widget* parent);
|
||||
|
||||
~IntervalWidget() override;
|
||||
|
||||
int x() const override;
|
||||
int y() const override;
|
||||
int width() const override;
|
||||
|
||||
private:
|
||||
W_OBJECT(IntervalWidget)
|
||||
|
||||
void paint(bugui::painter& painter) const override;
|
||||
|
||||
bool contains(int px, int py) const override;
|
||||
|
||||
void on_press(int x, int y, bool pressed) override;
|
||||
|
|
|
@ -41,7 +41,7 @@ int ScenarioWidget::width() const
|
|||
|
||||
int ScenarioWidget::height() const
|
||||
{
|
||||
return bugui::base_widget::parent->height();
|
||||
return 15;
|
||||
}
|
||||
|
||||
Scenario::ProcessModel *ScenarioWidget::get_model() const
|
||||
|
|
|
@ -25,6 +25,7 @@ StateWidget::StateWidget(Scenario::StateModel& state,
|
|||
|
||||
StateWidget::~StateWidget()
|
||||
{
|
||||
// FIXME : this disconnect seem to cause crashes
|
||||
// disconnect(&model,
|
||||
// &Scenario::StateModel::heightPercentageChanged,
|
||||
// this, 0);
|
||||
|
@ -53,12 +54,12 @@ bool StateWidget::contains(int px, int py) const
|
|||
|
||||
void StateWidget::on_press(int x, int y, bool pressed)
|
||||
{
|
||||
qDebug() << "is inside!";
|
||||
qDebug() << "state pressed";
|
||||
}
|
||||
|
||||
void StateWidget::on_double_press(int x, int y)
|
||||
{
|
||||
qDebug() << "double pressed !";
|
||||
qDebug() << "state double pressed";
|
||||
}
|
||||
|
||||
void StateWidget::on_drag(int from_x, int from_y, int to_x, int to_y)
|
||||
|
|
|
@ -114,7 +114,7 @@ bool TimeSyncWidget::contains(int px, int py) const
|
|||
|
||||
void TimeSyncWidget::on_press(int x, int y, bool pressed)
|
||||
{
|
||||
qDebug() << "is inside!";
|
||||
qDebug() << "timeSync pressed";
|
||||
}
|
||||
|
||||
} // namespace Hardware
|
||||
|
|
Loading…
Add table
Reference in a new issue