[architecture] use bugui paint function
This commit is contained in:
parent
39f11ea247
commit
deaaed30fe
3 changed files with 20 additions and 22 deletions
2
Hardware/3rdparty/bugui
vendored
2
Hardware/3rdparty/bugui
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 6e18b2d897e89ced5eb420aafe7c50f29026bfb6
|
Subproject commit ceddf2006062b5bcc83f8c3043a9bac79e485b81
|
|
@ -8,7 +8,7 @@
|
||||||
namespace Hardware
|
namespace Hardware
|
||||||
{
|
{
|
||||||
Controller::Controller(const score::DocumentContext& doc)
|
Controller::Controller(const score::DocumentContext& doc)
|
||||||
: bugui::painter{[&doc, this]
|
: bugui::controller{[&doc, this]
|
||||||
(bugui::commands com, const bool& shift)
|
(bugui::commands com, const bool& shift)
|
||||||
{
|
{
|
||||||
switch (com)
|
switch (com)
|
||||||
|
@ -29,12 +29,12 @@ Controller::Controller(const score::DocumentContext& doc)
|
||||||
if (shift)
|
if (shift)
|
||||||
{
|
{
|
||||||
v_zoom += .2;
|
v_zoom += .2;
|
||||||
draw_intervals();
|
update();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
v_ofset += .02;
|
v_ofset += .02;
|
||||||
draw_intervals();
|
update();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case bugui::Down:
|
case bugui::Down:
|
||||||
|
@ -43,13 +43,13 @@ Controller::Controller(const score::DocumentContext& doc)
|
||||||
if (v_zoom > .2)
|
if (v_zoom > .2)
|
||||||
{
|
{
|
||||||
v_zoom -= .2;
|
v_zoom -= .2;
|
||||||
draw_intervals();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
v_ofset -= .02;
|
v_ofset -= .02;
|
||||||
draw_intervals();
|
update();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case bugui::Left:
|
case bugui::Left:
|
||||||
|
@ -58,7 +58,7 @@ Controller::Controller(const score::DocumentContext& doc)
|
||||||
if (h_zoom > .02)
|
if (h_zoom > .02)
|
||||||
{
|
{
|
||||||
h_zoom -= .02;
|
h_zoom -= .02;
|
||||||
draw_intervals();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -66,7 +66,7 @@ Controller::Controller(const score::DocumentContext& doc)
|
||||||
if (h_ofset > 0)
|
if (h_ofset > 0)
|
||||||
{
|
{
|
||||||
h_ofset -= .02;
|
h_ofset -= .02;
|
||||||
draw_intervals();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -74,12 +74,12 @@ Controller::Controller(const score::DocumentContext& doc)
|
||||||
if (shift)
|
if (shift)
|
||||||
{
|
{
|
||||||
h_zoom += .02;
|
h_zoom += .02;
|
||||||
draw_intervals();
|
update();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
h_ofset += .02;
|
h_ofset += .02;
|
||||||
draw_intervals();
|
update();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -106,32 +106,30 @@ void Controller::setup_scenario(Scenario::ProcessModel* s)
|
||||||
|
|
||||||
connect(scenar,
|
connect(scenar,
|
||||||
&Scenario::ProcessModel::intervalMoved,
|
&Scenario::ProcessModel::intervalMoved,
|
||||||
[this] { draw_intervals(); });
|
[this] { update(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::on_interval_changed(const Scenario::IntervalModel &)
|
void Controller::on_interval_changed(const Scenario::IntervalModel &)
|
||||||
{
|
{
|
||||||
draw_intervals();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::draw_intervals()
|
void Controller::paint(bugui::painter &painter)
|
||||||
{
|
{
|
||||||
if (!ctl || !scenar) return;
|
if (!scenar) return;
|
||||||
|
|
||||||
// Copied from MiniscenarioView
|
// Copied from MiniscenarioView
|
||||||
auto& skin = Process::Style::instance();
|
auto& skin = Process::Style::instance();
|
||||||
const auto col = skin.IntervalBase().color();
|
const auto col = skin.IntervalBase().color();
|
||||||
set_color(col.redF(), col.greenF(), col.blackF(), col.alphaF());
|
painter.set_color(col.redF(), col.greenF(), col.blackF(), col.alphaF());
|
||||||
|
|
||||||
for(const Scenario::IntervalModel& c : scenar->intervals)
|
for(const Scenario::IntervalModel& c : scenar->intervals)
|
||||||
{
|
{
|
||||||
auto def = c.duration.defaultDuration().sec() * h_zoom;
|
auto def = c.duration.defaultDuration().sec() * h_zoom;
|
||||||
auto st = (c.date().sec() * h_zoom) - h_ofset;
|
auto st = (c.date().sec() * h_zoom) - h_ofset;
|
||||||
auto y = (c.heightPercentage() * v_zoom) + v_ofset;
|
auto y = (c.heightPercentage() * v_zoom) + v_ofset;
|
||||||
draw_line({st, y}, {st + def, y});
|
painter.draw_line({st, y}, {st + def, y});
|
||||||
}
|
}
|
||||||
|
|
||||||
update_grid();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
#include <Scenario/Document/Interval/IntervalModel.hpp>
|
#include <Scenario/Document/Interval/IntervalModel.hpp>
|
||||||
#include <Scenario/Process/ScenarioModel.hpp>
|
#include <Scenario/Process/ScenarioModel.hpp>
|
||||||
|
|
||||||
#include <painter.hpp>
|
#include <controller.hpp>
|
||||||
|
|
||||||
namespace Hardware
|
namespace Hardware
|
||||||
{
|
{
|
||||||
class SCORE_ADDON_HARDWARE_EXPORT Controller
|
class SCORE_ADDON_HARDWARE_EXPORT Controller
|
||||||
: public bugui::painter
|
: public bugui::controller
|
||||||
, public QObject
|
, public QObject
|
||||||
{
|
{
|
||||||
W_OBJECT(Controller)
|
W_OBJECT(Controller)
|
||||||
|
@ -19,7 +19,7 @@ public:
|
||||||
explicit Controller(const score::DocumentContext& doc);
|
explicit Controller(const score::DocumentContext& doc);
|
||||||
|
|
||||||
void setup_scenario(Scenario::ProcessModel* s);
|
void setup_scenario(Scenario::ProcessModel* s);
|
||||||
void draw_intervals();
|
void paint(bugui::painter& painter) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Scenario::ProcessModel* scenar;
|
Scenario::ProcessModel* scenar;
|
||||||
|
|
Loading…
Add table
Reference in a new issue