[ScenarioComponent] fixed inheritance, maybe a little convoluted
This commit is contained in:
parent
92583043f0
commit
8c9eef1959
4 changed files with 14 additions and 11 deletions
|
@ -6,7 +6,10 @@
|
|||
|
||||
namespace Hardware
|
||||
{
|
||||
struct ScenarioComponent : bugui::base_widget
|
||||
template <typename T = bugui::base_widget>
|
||||
requires (std::same_as<T, bugui::base_widget> ||
|
||||
std::derived_from<T, bugui::base_widget>)
|
||||
struct ScenarioComponent : T
|
||||
{
|
||||
virtual bool this_model(const Scenario::IntervalModel&) const { return false; };
|
||||
virtual bool this_model(const Scenario::TimeSyncModel&) const { return false; };
|
||||
|
@ -15,23 +18,23 @@ struct ScenarioComponent : bugui::base_widget
|
|||
|
||||
protected:
|
||||
explicit ScenarioComponent(bugui::container_widget* parent)
|
||||
: bugui::base_widget{parent}
|
||||
: T{parent}
|
||||
{ }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
template <typename T, typename Base = bugui::base_widget>
|
||||
requires (std::same_as<T, Scenario::IntervalModel> ||
|
||||
std::same_as<T, Scenario::TimeSyncModel> ||
|
||||
std::same_as<T, Scenario::EventModel> ||
|
||||
std::same_as<T, Scenario::StateModel>)
|
||||
struct ScenarioComponentSpec : ScenarioComponent
|
||||
struct ScenarioComponentSpec : ScenarioComponent<Base>
|
||||
{
|
||||
bool this_model(const T& m) const override { return m.id() == model.id(); };
|
||||
|
||||
protected:
|
||||
explicit ScenarioComponentSpec(T& m,
|
||||
bugui::container_widget* parent)
|
||||
: ScenarioComponent{parent}
|
||||
: ScenarioComponent<Base>{parent}
|
||||
, model{m}
|
||||
, skin{Process::Style::instance()}
|
||||
{ }
|
||||
|
|
|
@ -57,7 +57,7 @@ void ScenarioWidget::on_interval_removed(const Scenario::IntervalModel& interval
|
|||
{
|
||||
remove_widget([&interval]
|
||||
(const auto& w)
|
||||
{ return static_cast<ScenarioComponent*>(w.get())->this_model(interval); });
|
||||
{ return static_cast<ScenarioComponent<>*>(w.get())->this_model(interval); });
|
||||
|
||||
update();
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ void ScenarioWidget::on_time_sync_removed(const Scenario::TimeSyncModel& timeSyn
|
|||
{
|
||||
remove_widget([&timeSync]
|
||||
(const auto& w)
|
||||
{ return static_cast<ScenarioComponent*>(w.get())->this_model(timeSync); });
|
||||
{ return static_cast<ScenarioComponent<>*>(w.get())->this_model(timeSync); });
|
||||
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ namespace Hardware
|
|||
{
|
||||
TimeSyncWidget::TimeSyncWidget(Scenario::TimeSyncModel& timeSync,
|
||||
bugui::container_widget* parent)
|
||||
: ScenarioComponentSpec<Scenario::TimeSyncModel>{timeSync, parent}
|
||||
// , bugui::container_widget{parent}
|
||||
: ScenarioComponentSpec<Scenario::TimeSyncModel,
|
||||
bugui::container_widget>{timeSync, parent}
|
||||
{ }
|
||||
|
||||
int TimeSyncWidget::x() const
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
namespace Hardware
|
||||
{
|
||||
struct TimeSyncWidget final : ScenarioComponentSpec<Scenario::TimeSyncModel>
|
||||
// , virtual bugui::container_widget
|
||||
struct TimeSyncWidget final : ScenarioComponentSpec<Scenario::TimeSyncModel,
|
||||
bugui::container_widget>
|
||||
{
|
||||
explicit TimeSyncWidget(Scenario::TimeSyncModel& timeSync,
|
||||
bugui::container_widget* parent);
|
||||
|
|
Loading…
Add table
Reference in a new issue