141 lines
2.4 KiB
C++
141 lines
2.4 KiB
C++
#include <score/application/GUIApplicationContext.hpp>
|
|
#include <score/actions/ActionManager.hpp>
|
|
#include <Scenario/Application/ScenarioActions.hpp>
|
|
#include <Process/Style/ScenarioStyle.hpp>
|
|
|
|
#include "Controller.hpp"
|
|
#include <Hardware/Widgets/ScenarioWidget.hpp>
|
|
|
|
namespace Hardware
|
|
{
|
|
Controller::Controller(const score::DocumentContext& document,
|
|
Scenario::IntervalModel& interval,
|
|
std::string_view device_name)
|
|
: bugui::controller<Controller>{device_name}
|
|
, doc{document}
|
|
, interval{&interval}
|
|
{
|
|
auto scnr = qobject_cast<Scenario::ProcessModel*>(&*interval.processes.begin());
|
|
|
|
if (scnr) widgets.emplace_back(std::make_unique<ScenarioWidget>(this, scnr));
|
|
|
|
update();
|
|
}
|
|
|
|
bool Controller::on_press(int x, int y, bool pressed)
|
|
{
|
|
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;
|
|
}
|
|
|
|
bool Controller::on_drag(int from_x, int from_y, int to_x, int to_y)
|
|
{
|
|
for (auto& w : widgets)
|
|
if (w->on_drag(from_x, from_y, to_x, to_y))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
void Controller::on_play(bool pressed)
|
|
{
|
|
if (m_shift)
|
|
doc.app.actions.action<Actions::PlayGlobal>().action()->trigger();
|
|
else
|
|
doc.app.actions.action<Actions::Play>().action()->trigger();
|
|
}
|
|
|
|
void Controller::on_stop(bool pressed)
|
|
{
|
|
if (m_shift)
|
|
doc.app.actions.action<Actions::Reinitialize>().action()->trigger();
|
|
else
|
|
doc.app.actions.action<Actions::Stop>().action()->trigger();
|
|
}
|
|
|
|
void Controller::on_shift(bool pressed)
|
|
{
|
|
m_shift = pressed;
|
|
}
|
|
|
|
void Controller::on_up(bool pressed)
|
|
{
|
|
if (m_shift)
|
|
{
|
|
v_scale += .2;
|
|
update();
|
|
}
|
|
else
|
|
{
|
|
v_ofset += .02;
|
|
update();
|
|
}
|
|
}
|
|
|
|
void Controller::on_down(bool pressed)
|
|
{
|
|
if (m_shift)
|
|
{
|
|
if (v_scale > .2)
|
|
{
|
|
v_scale -= .2;
|
|
update();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
v_ofset -= .02;
|
|
update();
|
|
}
|
|
}
|
|
|
|
void Controller::on_left(bool pressed)
|
|
{
|
|
if (m_shift)
|
|
{
|
|
if (h_scale > .02)
|
|
{
|
|
h_scale -= .02;
|
|
update();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (h_ofset > 0)
|
|
{
|
|
h_ofset -= .02;
|
|
update();
|
|
}
|
|
}
|
|
}
|
|
|
|
void Controller::on_right(bool pressed)
|
|
{
|
|
if (m_shift)
|
|
{
|
|
h_scale += .02;
|
|
update();
|
|
}
|
|
else
|
|
{
|
|
h_ofset += .02;
|
|
update();
|
|
}
|
|
}
|
|
|
|
} // namespace hardware
|
|
|
|
#include <wobjectimpl.h>
|
|
W_OBJECT_IMPL(Hardware::Controller)
|