[Controller] add recuring template argument
This commit is contained in:
parent
01f6edc127
commit
c52e1599eb
5 changed files with 18 additions and 16 deletions
2
Hardware/3rdparty/bugui
vendored
2
Hardware/3rdparty/bugui
vendored
|
@ -1 +1 @@
|
|||
Subproject commit c71a9c1e02e3364a16edf3664ca6ef40898b9635
|
||||
Subproject commit 2a725a7eb0ec3262059d7f724d2725e33b03c55f
|
|
@ -1,4 +1,4 @@
|
|||
#include <score/application/ApplicationContext.hpp>
|
||||
#include <score/application/GUIApplicationContext.hpp>
|
||||
#include <score/actions/ActionManager.hpp>
|
||||
#include <Scenario/Application/ScenarioActions.hpp>
|
||||
#include <Process/Style/ScenarioStyle.hpp>
|
||||
|
@ -8,7 +8,7 @@
|
|||
namespace Hardware
|
||||
{
|
||||
Controller::Controller(const score::DocumentContext& doc)
|
||||
: bugui::controller{[&doc, this]
|
||||
: bugui::controller<Controller>{[&doc, this]
|
||||
(bugui::commands com, bool shift)
|
||||
{
|
||||
switch (com)
|
||||
|
@ -121,7 +121,7 @@ void Controller::paint(bugui::painter& painter)
|
|||
// Copied from MiniscenarioView
|
||||
auto& skin = Process::Style::instance();
|
||||
const auto col = skin.IntervalBase().color();
|
||||
painter.set_color(col.red(), col.green(), col.black(), col.alpha());
|
||||
painter.set_color(col.red(), col.green(), col.blue(), col.alpha());
|
||||
|
||||
for(const Scenario::IntervalModel& c : scenar->intervals)
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
namespace Hardware
|
||||
{
|
||||
class SCORE_ADDON_HARDWARE_EXPORT Controller
|
||||
: public bugui::controller
|
||||
: public bugui::controller<Controller>
|
||||
, public QObject
|
||||
{
|
||||
W_OBJECT(Controller)
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Hardware
|
|||
using namespace std::literals;
|
||||
DocumentPlugin::DocumentPlugin(const score::DocumentContext& doc, QObject* parent)
|
||||
: score::DocumentPlugin{doc, "Hardware::DocumentPlugin", parent}
|
||||
, hardware{doc}
|
||||
, ctrlr{doc}
|
||||
{
|
||||
auto& set = m_context.app.settings<Settings::Model>();
|
||||
if(set.getEnabled())
|
||||
|
@ -34,7 +34,8 @@ DocumentPlugin::DocumentPlugin(const score::DocumentContext& doc, QObject* paren
|
|||
|
||||
con(
|
||||
set, &Settings::Model::EnabledChanged, this,
|
||||
[this](bool b) {
|
||||
[this](bool b)
|
||||
{
|
||||
if (b)
|
||||
create();
|
||||
else
|
||||
|
@ -52,25 +53,26 @@ void DocumentPlugin::on_documentClosing()
|
|||
|
||||
void DocumentPlugin::create()
|
||||
{
|
||||
if(cstr)
|
||||
cleanup();
|
||||
if (cstr) cleanup();
|
||||
|
||||
auto& doc = m_context.document.model().modelDelegate();
|
||||
auto scenar = safe_cast<Scenario::ScenarioDocumentModel*>(&doc);
|
||||
cstr = &scenar->baseScenario().interval();
|
||||
|
||||
hardware.setup();
|
||||
ctrlr.setup();
|
||||
|
||||
// Get Scenario::processModel
|
||||
// adapted from
|
||||
// src/plugins/score-plugin-scenario/Scenario/Document/ScenarioDocument/ScenarioDocumentModel.cpp#67
|
||||
hardware.setup_scenario(qobject_cast<Scenario::ProcessModel*>(&*cstr->processes.begin()));
|
||||
ctrlr.setup_scenario(
|
||||
qobject_cast<Scenario::ProcessModel*>(
|
||||
&*cstr->processes.begin())
|
||||
);
|
||||
}
|
||||
|
||||
void DocumentPlugin::cleanup()
|
||||
{
|
||||
if(!cstr)
|
||||
return;
|
||||
if (!cstr) return;
|
||||
|
||||
cstr = nullptr;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
|
||||
void on_documentClosing() override;
|
||||
|
||||
Controller hardware;
|
||||
Controller ctrlr;
|
||||
|
||||
private:
|
||||
void create();
|
||||
|
|
Loading…
Add table
Reference in a new issue