51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
#include <Scenario/Document/State/StateModel.hpp>
|
|
|
|
#include "StateWidget.hpp"
|
|
#include "Hardware/Widgets/ScenarioWidget.hpp"
|
|
|
|
namespace Hardware
|
|
{
|
|
StateWidget::StateWidget(Scenario::StateModel& state,
|
|
ScenarioWidget* scenario,
|
|
bugui::container_widget* parent)
|
|
: ScenarioComponentSpec<Scenario::StateModel>{state, scenario, parent}
|
|
{ }
|
|
|
|
int StateWidget::y() const
|
|
{
|
|
return model.heightPercentage() * scenario->height();
|
|
}
|
|
|
|
void StateWidget::paint(bugui::painter& painter) const
|
|
{
|
|
const auto col = skin.StateDot().color();
|
|
painter.set_color(col.red(), col.green(), col.blue(), col.alpha());
|
|
|
|
painter.draw_cell(0, 0);
|
|
}
|
|
|
|
bool StateWidget::contains(int px, int py) const
|
|
{
|
|
if (px == x() && py == y())
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
void StateWidget::on_press(int x, int y, bool pressed)
|
|
{
|
|
qDebug() << "is inside!";
|
|
}
|
|
|
|
void StateWidget::on_double_press(int x, int y)
|
|
{
|
|
qDebug() << "double pressed !";
|
|
}
|
|
|
|
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()));
|
|
}
|
|
|
|
}
|