120 lines
2.1 KiB
C++
120 lines
2.1 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) add_widget<ScenarioWidget>(scnr);
|
|
|
|
update();
|
|
}
|
|
|
|
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 (!pressed) return;
|
|
|
|
if (m_shift)
|
|
{
|
|
vertical_scale += .2;
|
|
update();
|
|
}
|
|
else
|
|
{
|
|
if (vertical_ofset > -1) return;
|
|
|
|
vertical_ofset += 1;
|
|
update();
|
|
}
|
|
}
|
|
|
|
void Controller::on_down(bool pressed)
|
|
{
|
|
if (!pressed) return;
|
|
|
|
if (m_shift)
|
|
{
|
|
if (vertical_scale > .2)
|
|
{
|
|
vertical_scale -= .2;
|
|
update();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
vertical_ofset -= 1;
|
|
update();
|
|
}
|
|
}
|
|
|
|
void Controller::on_left(bool pressed)
|
|
{
|
|
if (!pressed) return;
|
|
|
|
if (m_shift)
|
|
{
|
|
if (horizontal_scale > .02)
|
|
{
|
|
horizontal_scale -= .02;
|
|
update();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (horizontal_ofset > -1) return;
|
|
|
|
horizontal_ofset += 1;
|
|
update();
|
|
}
|
|
}
|
|
|
|
void Controller::on_right(bool pressed)
|
|
{
|
|
if (!pressed) return;
|
|
|
|
if (m_shift)
|
|
{
|
|
horizontal_scale += .02;
|
|
update();
|
|
}
|
|
else
|
|
{
|
|
horizontal_ofset -= 1;
|
|
update();
|
|
}
|
|
}
|
|
|
|
} // namespace hardware
|