score-addon-hardware/Hardware/Widgets/StateWidget.cpp

63 lines
1.2 KiB
C++
Raw Normal View History

#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)
{
qDebug() << "is inside!";
}
2025-01-04 21:05:36 +00:00
void StateWidget::on_double_press(int x, int y)
{
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)
{
if (from_y != to_y)
model.setHeightPercentage(to_y / static_cast<double>(parent->height()));
}
const Scenario::StateModel& StateWidget::get_model() const
{
return model;
}
}