Loading...
Searching...
No Matches
WidgetInletFactory.hpp
1#pragma once
2#include <Process/Dataflow/PortListWidget.hpp>
3
4#include <Dataflow/ControlInletItem.hpp>
5#include <Dataflow/ControlOutletItem.hpp>
6#include <Dataflow/PortItem.hpp>
7
8namespace Dataflow
9{
10SCORE_PLUGIN_DATAFLOW_EXPORT
11QWidget* makeGraphicsViewForInspectorItem(QGraphicsItem* item, QWidget* parent);
12
13template <typename T, typename Widget>
15{
16 using Model_T = T;
17 UuidKey<Process::Port> concreteKey() const noexcept override
18 {
19 return Model_T::static_concreteKey();
20 }
21
22 Model_T* load(const VisitorVariant& vis, QObject* parent) override
23 {
24 return score::deserialize_dyn(vis, [&](auto&& deserializer) {
25 return new Model_T{deserializer, parent};
26 });
27 }
28
29 void setupInletInspector(
30 const Process::Inlet& port, const score::DocumentContext& ctx, QWidget* parent,
31 Inspector::Layout& lay, QObject* context) override
32 {
33 auto& ctrl = const_cast<Model_T&>(static_cast<const Model_T&>(port));
34 auto widg = Widget::make_widget(ctrl, ctx, parent, parent);
35 if(widg)
36 {
37 Process::PortWidgetSetup::setupControl(ctrl, widg, ctx, lay, parent);
38 }
39 else
40 {
41 auto item = makeControlItem(ctrl, ctx, nullptr, context);
42 auto widg = makeGraphicsViewForInspectorItem(item, parent);
43 Process::PortWidgetSetup::setupControl(ctrl, widg, ctx, lay, parent);
44 }
45 }
46
47 QGraphicsItem* makeControlItem(
49 QGraphicsItem* parent, QObject* context) override
50 {
51 auto& ctrl = static_cast<Model_T&>(port);
52 return Widget::make_item(ctrl, ctrl, ctx, nullptr, context);
53 }
54
55 Process::PortItemLayout defaultLayout() const noexcept override
56 {
57 return Widget::layout();
58 }
59};
60
61template <typename T, typename Widget>
63{
64 using Model_T = T;
65 UuidKey<Process::Port> concreteKey() const noexcept override
66 {
68 }
69
70 Model_T* load(const VisitorVariant& vis, QObject* parent) override
71 {
72 return score::deserialize_dyn(vis, [&](auto&& deserializer) {
73 return new Model_T{deserializer, parent};
74 });
75 }
76
77 void setupOutletInspector(
78 const Process::Outlet& port, const score::DocumentContext& ctx, QWidget* parent,
79 Inspector::Layout& lay, QObject* context) override
80 {
81 auto& ctrl = static_cast<const Model_T&>(port);
82 auto widg = Widget::make_widget(ctrl, ctx, parent, parent);
83 Process::PortWidgetSetup::setupControl(ctrl, widg, ctx, lay, parent);
84 }
85
86 QGraphicsItem* makeControlItem(
88 QGraphicsItem* parent, QObject* context) override
89 {
90 auto& ctrl = static_cast<Model_T&>(port);
91 return Widget::make_item(ctrl, ctrl, ctx, nullptr, context);
92 }
93
94 Process::PortItemLayout defaultLayout() const noexcept override
95 {
96 return Widget::layout();
97 }
98};
99}
Definition lib/score/widgets/Layout.hpp:29
Definition Port.hpp:203
Definition Port.hpp:425
Definition Port.hpp:177
Definition Port.hpp:273
Definition UuidKey.hpp:343
Definition ControlInletItem.hpp:7
Definition ControlOutletItem.hpp:7
Definition WidgetInletFactory.hpp:15
Definition WidgetInletFactory.hpp:63
Static metadata implementation.
Definition lib/score/tools/Metadata.hpp:36
Definition Port.hpp:90
The VisitorVariant struct.
Definition VisitorInterface.hpp:26
Definition DocumentContext.hpp:18