2025-01-10 01:38:58 +00:00
|
|
|
#include <Scenario/Document/State/StateModel.hpp>
|
|
|
|
|
2025-01-03 23:27:19 +00:00
|
|
|
#include "StateWidget.hpp"
|
|
|
|
|
|
|
|
namespace Hardware
|
|
|
|
{
|
|
|
|
StateWidget::StateWidget(Scenario::StateModel& state,
|
2025-01-10 01:38:58 +00:00
|
|
|
bugui::container_widget* parent)
|
|
|
|
: ScenarioComponentSpec<Scenario::StateModel>{state, parent}
|
2025-01-03 23:27:19 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
int StateWidget::x() const
|
|
|
|
{
|
|
|
|
return parent->x();
|
|
|
|
}
|
|
|
|
|
|
|
|
int StateWidget::y() const
|
|
|
|
{
|
|
|
|
return model.heightPercentage() * parent->height();
|
|
|
|
}
|
|
|
|
|
|
|
|
void StateWidget::paint(bugui::painter& painter) const
|
|
|
|
{
|
2025-01-10 01:38:58 +00:00
|
|
|
const auto col = skin.StateDot().color();
|
2025-01-03 23:27:19 +00:00
|
|
|
painter.set_color(col.red(), col.green(), col.blue(), col.alpha());
|
|
|
|
|
2025-01-10 01:38:58 +00:00
|
|
|
painter.draw_cell(0, 0);
|
2025-01-03 23:27:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool StateWidget::contains(int px, int py) const
|
|
|
|
{
|
2025-01-10 01:38:58 +00:00
|
|
|
if (px == x() && py == y())
|
2025-01-03 23:27:19 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|