#include #include #include #include #include "Controller.hpp" #include namespace Hardware { Controller::Controller(const score::DocumentContext& document, Scenario::IntervalModel& interval, std::string_view device_name) : bugui::controller{device_name} , doc{document} , interval{&interval} { auto scnr = qobject_cast(&*interval.processes.begin()); if (scnr) widgets.emplace_back(std::make_unique(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().action()->trigger(); else doc.app.actions.action().action()->trigger(); } void Controller::on_stop(bool pressed) { if (m_shift) doc.app.actions.action().action()->trigger(); else doc.app.actions.action().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 W_OBJECT_IMPL(Hardware::Controller)