2024-12-02 01:05:53 +00:00
|
|
|
#include <score/application/GUIApplicationContext.hpp>
|
2024-10-06 15:16:11 +01:00
|
|
|
#include <score/actions/ActionManager.hpp>
|
|
|
|
#include <Scenario/Application/ScenarioActions.hpp>
|
2024-10-15 21:00:53 +01:00
|
|
|
#include <Process/Style/ScenarioStyle.hpp>
|
2024-10-06 15:16:11 +01:00
|
|
|
|
2024-10-03 23:50:15 +01:00
|
|
|
#include "Controller.hpp"
|
2024-12-28 17:53:59 +00:00
|
|
|
#include <Hardware/Widgets/ScenarioWidget.hpp>
|
2024-10-03 23:50:15 +01:00
|
|
|
|
2024-10-06 15:16:11 +01:00
|
|
|
namespace Hardware
|
|
|
|
{
|
2024-12-09 13:33:58 +00:00
|
|
|
Controller::Controller(const score::DocumentContext& document,
|
2024-12-13 00:10:19 +00:00
|
|
|
Scenario::IntervalModel& interval,
|
|
|
|
std::string_view device_name)
|
|
|
|
: bugui::controller<Controller>{device_name}
|
2024-12-03 23:42:27 +00:00
|
|
|
, doc{document}
|
2024-12-13 00:10:19 +00:00
|
|
|
, interval{&interval}
|
2024-10-06 15:16:11 +01:00
|
|
|
{
|
2024-12-13 00:10:19 +00:00
|
|
|
auto scnr = qobject_cast<Scenario::ProcessModel*>(&*interval.processes.begin());
|
2024-12-09 13:33:58 +00:00
|
|
|
|
2024-12-28 17:53:59 +00:00
|
|
|
if (scnr) widgets.emplace_back(std::make_unique<ScenarioWidget>(this, scnr));
|
2024-10-06 15:16:11 +01:00
|
|
|
|
2024-12-27 11:04:40 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2024-12-29 23:23:03 +00:00
|
|
|
bool Controller::on_press(int x, int y, bool pressed)
|
2024-12-26 12:00:43 +00:00
|
|
|
{
|
2024-12-29 23:23:03 +00:00
|
|
|
for (auto& w : widgets)
|
|
|
|
if (w->on_press(x, y, pressed))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Controller::on_double_press(int x, int y)
|
|
|
|
{
|
|
|
|
for (auto& w : widgets)
|
|
|
|
if (w->on_double_press(x, y))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
2024-12-26 12:00:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Controller::on_play(bool pressed)
|
2024-12-03 23:42:27 +00:00
|
|
|
{
|
|
|
|
if (m_shift)
|
|
|
|
doc.app.actions.action<Actions::PlayGlobal>().action()->trigger();
|
|
|
|
else
|
|
|
|
doc.app.actions.action<Actions::Play>().action()->trigger();
|
|
|
|
}
|
|
|
|
|
2024-12-26 12:00:43 +00:00
|
|
|
void Controller::on_stop(bool pressed)
|
2024-12-03 23:42:27 +00:00
|
|
|
{
|
|
|
|
if (m_shift)
|
|
|
|
doc.app.actions.action<Actions::Reinitialize>().action()->trigger();
|
|
|
|
else
|
|
|
|
doc.app.actions.action<Actions::Stop>().action()->trigger();
|
|
|
|
}
|
|
|
|
|
2024-12-26 12:00:43 +00:00
|
|
|
void Controller::on_shift(bool pressed)
|
2024-12-03 23:42:27 +00:00
|
|
|
{
|
|
|
|
m_shift = pressed;
|
|
|
|
}
|
|
|
|
|
2024-12-26 12:00:43 +00:00
|
|
|
void Controller::on_up(bool pressed)
|
2024-12-03 23:42:27 +00:00
|
|
|
{
|
|
|
|
if (m_shift)
|
|
|
|
{
|
2024-12-26 12:00:43 +00:00
|
|
|
v_scale += .2;
|
2024-12-03 23:42:27 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
v_ofset += .02;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-26 12:00:43 +00:00
|
|
|
void Controller::on_down(bool pressed)
|
2024-12-03 23:42:27 +00:00
|
|
|
{
|
|
|
|
if (m_shift)
|
|
|
|
{
|
2024-12-26 12:00:43 +00:00
|
|
|
if (v_scale > .2)
|
2024-12-03 23:42:27 +00:00
|
|
|
{
|
2024-12-26 12:00:43 +00:00
|
|
|
v_scale -= .2;
|
2024-12-03 23:42:27 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
v_ofset -= .02;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-26 12:00:43 +00:00
|
|
|
void Controller::on_left(bool pressed)
|
2024-12-03 23:42:27 +00:00
|
|
|
{
|
|
|
|
if (m_shift)
|
|
|
|
{
|
2024-12-26 12:00:43 +00:00
|
|
|
if (h_scale > .02)
|
2024-12-03 23:42:27 +00:00
|
|
|
{
|
2024-12-26 12:00:43 +00:00
|
|
|
h_scale -= .02;
|
2024-12-03 23:42:27 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (h_ofset > 0)
|
|
|
|
{
|
|
|
|
h_ofset -= .02;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-26 12:00:43 +00:00
|
|
|
void Controller::on_right(bool pressed)
|
2024-12-03 23:42:27 +00:00
|
|
|
{
|
|
|
|
if (m_shift)
|
|
|
|
{
|
2024-12-26 12:00:43 +00:00
|
|
|
h_scale += .02;
|
2024-12-03 23:42:27 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
h_ofset += .02;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-26 12:00:43 +00:00
|
|
|
} // namespace hardware
|
2024-10-06 15:16:11 +01:00
|
|
|
|
2024-10-08 16:12:35 +01:00
|
|
|
#include <wobjectimpl.h>
|
2024-10-06 15:16:11 +01:00
|
|
|
W_OBJECT_IMPL(Hardware::Controller)
|