2025-01-03 23:27:19 +00:00
|
|
|
#include "StateWidget.hpp"
|
|
|
|
|
|
|
|
namespace Hardware
|
|
|
|
{
|
|
|
|
StateWidget::StateWidget(Scenario::StateModel& state,
|
|
|
|
container_widget* parent)
|
|
|
|
: bugui::container_widget{parent}
|
|
|
|
, model{state}
|
|
|
|
, skin{Process::Style::instance()}
|
|
|
|
{ }
|
|
|
|
|
|
|
|
int StateWidget::x() const
|
|
|
|
{
|
|
|
|
return parent->x();
|
|
|
|
}
|
|
|
|
|
|
|
|
int StateWidget::y() const
|
|
|
|
{
|
|
|
|
return model.heightPercentage() * parent->height();
|
|
|
|
}
|
|
|
|
|
|
|
|
void StateWidget::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({x(), y()}, {x() + width(), y()});
|
|
|
|
}
|
|
|
|
|
|
|
|
bool StateWidget::contains(int px, int py) const
|
|
|
|
{
|
|
|
|
if (px >= x() &&
|
|
|
|
px <= (x() + width()) &&
|
|
|
|
py == y())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2025-01-04 21:05:36 +00:00
|
|
|
void StateWidget::on_press(int x, int y, bool pressed)
|
2025-01-03 23:27:19 +00:00
|
|
|
{
|
|
|
|
qDebug() << "is inside!";
|
|
|
|
}
|
|
|
|
|
2025-01-04 21:05:36 +00:00
|
|
|
void StateWidget::on_double_press(int x, int y)
|
2025-01-03 23:27:19 +00:00
|
|
|
{
|
|
|
|
qDebug() << "double pressed !";
|
|
|
|
}
|
|
|
|
|
2025-01-04 21:05:36 +00:00
|
|
|
void StateWidget::on_drag(int from_x, int from_y, int to_x, int to_y)
|
2025-01-03 23:27:19 +00:00
|
|
|
{
|
|
|
|
if (from_y != to_y)
|
|
|
|
model.setHeightPercentage(to_y / static_cast<double>(parent->height()));
|
|
|
|
}
|
|
|
|
|
|
|
|
const Scenario::StateModel& StateWidget::get_model() const
|
|
|
|
{
|
|
|
|
return model;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|