diff --git a/Hardware/3rdparty/bugui b/Hardware/3rdparty/bugui index 2a725a7..34ec648 160000 --- a/Hardware/3rdparty/bugui +++ b/Hardware/3rdparty/bugui @@ -1 +1 @@ -Subproject commit 2a725a7eb0ec3262059d7f724d2725e33b03c55f +Subproject commit 34ec6482874d49de63a353160d78af786a7258e6 diff --git a/Hardware/Controller.cpp b/Hardware/Controller.cpp index 97667f4..2b62b15 100644 --- a/Hardware/Controller.cpp +++ b/Hardware/Controller.cpp @@ -7,91 +7,13 @@ namespace Hardware { -Controller::Controller(const score::DocumentContext& doc) - : bugui::controller{[&doc, this] - (bugui::commands com, bool shift) - { - switch (com) - { - case bugui::Play: - if (shift) - doc.app.actions.action().action()->trigger(); - else - doc.app.actions.action().action()->trigger(); - break; - case bugui::Stop: - if (shift) - doc.app.actions.action().action()->trigger(); - else - doc.app.actions.action().action()->trigger(); - break; - case bugui::Up: - if (shift) - { - v_zoom += .2; - update(); - } - else - { - v_ofset += .02; - update(); - } - break; - case bugui::Down: - if (shift) - { - if (v_zoom > .2) - { - v_zoom -= .2; - update(); - } - } - else - { - v_ofset -= .02; - update(); - } - break; - case bugui::Left: - if (shift) - { - if (h_zoom > .02) - { - h_zoom -= .02; - update(); - } - } - else - { - if (h_ofset > 0) - { - h_ofset -= .02; - update(); - } - } - break; - case bugui::Right: - if (shift) - { - h_zoom += .02; - update(); - } - else - { - h_ofset += .02; - update(); - } - break; - default: - break; - } - - // qDebug() << "v_ofset: " << v_ofset; - // qDebug() << "v_zoom: " << v_zoom; - // qDebug() << "h_ofset: " << h_ofset; - // qDebug() << "h_zoom: " << h_ofset; - } -} +Controller::Controller(const score::DocumentContext& document) + : bugui::controller{} + , doc{document} + , h_ofset{0.} // initial horizontal ofset + , v_ofset{0.} // initial verticalal ofset + , h_zoom{.125} // initial horizontal zoom + , v_zoom{1.1} // initial verticalal zoom {} void Controller::setup_scenario(Scenario::ProcessModel* s) @@ -114,7 +36,7 @@ void Controller::on_interval_changed(const Scenario::IntervalModel&) update(); } -void Controller::paint(bugui::painter& painter) +void Controller::paint(bugui::painter& painter) const { if (!scenar) return; @@ -132,6 +54,92 @@ void Controller::paint(bugui::painter& painter) } } +void Controller::play(bool pressed) +{ + if (m_shift) + doc.app.actions.action().action()->trigger(); + else + doc.app.actions.action().action()->trigger(); +} + +void Controller::stop(bool pressed) +{ + if (m_shift) + doc.app.actions.action().action()->trigger(); + else + doc.app.actions.action().action()->trigger(); +} + +void Controller::shift(bool pressed) +{ + m_shift = pressed; +} + +void Controller::up(bool pressed) +{ + if (m_shift) + { + v_zoom += .2; + update(); + } + else + { + v_ofset += .02; + update(); + } +} + +void Controller::down(bool pressed) +{ + if (m_shift) + { + if (v_zoom > .2) + { + v_zoom -= .2; + update(); + } + } + else + { + v_ofset -= .02; + update(); + } +} + +void Controller::left(bool pressed) +{ + if (m_shift) + { + if (h_zoom > .02) + { + h_zoom -= .02; + update(); + } + } + else + { + if (h_ofset > 0) + { + h_ofset -= .02; + update(); + } + } +} + +void Controller::right(bool pressed) +{ + if (m_shift) + { + h_zoom += .02; + update(); + } + else + { + h_ofset += .02; + update(); + } +} + } #include diff --git a/Hardware/Controller.hpp b/Hardware/Controller.hpp index 578e33d..1f7b3fe 100644 --- a/Hardware/Controller.hpp +++ b/Hardware/Controller.hpp @@ -2,6 +2,7 @@ #include +#include #include #include @@ -16,15 +17,31 @@ class SCORE_ADDON_HARDWARE_EXPORT Controller W_OBJECT(Controller) public: - explicit Controller(const score::DocumentContext& doc); + explicit Controller(const score::DocumentContext& document); void setup_scenario(Scenario::ProcessModel* s); - void paint(bugui::painter& painter) override; + void paint(bugui::painter& painter) const override; + + void play(bool pressed); + void stop(bool pressed); + void shift(bool pressed); + void up(bool pressed); + void down(bool pressed); + void left(bool pressed); + void right(bool pressed); private: - Scenario::ProcessModel* scenar; - void on_interval_changed(const Scenario::IntervalModel&); + + Scenario::ProcessModel* scenar; + const score::DocumentContext& doc; + + bool m_shift{false}; + + float h_ofset; + float v_ofset; + float h_zoom; + float v_zoom; }; }