Loading...
Searching...
No Matches
EffectFactory.hpp
1#pragma once
2#include <Process/LayerView.hpp>
3#include <Process/Process.hpp>
4#include <Process/ProcessFactory.hpp>
5
6#include <Effect/EffectLayer.hpp>
7
8#include <score/graphics/RectItem.hpp>
9
10namespace Process
11{
12template <typename Model_T>
14{
15public:
16 virtual ~EffectProcessFactory_T() = default;
17
18 UuidKey<Process::ProcessModel> concreteKey() const noexcept override
19 {
21 }
22 QString prettyName() const noexcept override
23 {
25 }
26 QString category() const noexcept override
27 {
29 }
30
31 Descriptor descriptor(QString) const noexcept override;
32 Descriptor descriptor(const Process::ProcessModel&) const noexcept override;
33
34 ProcessFlags flags() const noexcept override
35 {
37 }
38
39 QString customConstructionData() const noexcept override;
40
41 Model_T* make(
42 const TimeVal& duration, const QString& data, const Id<Process::ProcessModel>& id,
43 const score::DocumentContext& ctx, QObject* parent) override
44 {
45 return new Model_T{duration, data, id, parent};
46 }
47
48 Model_T* load(
49 const VisitorVariant& vis, const score::DocumentContext& ctx,
50 QObject* parent) final override
51 {
52 return score::deserialize_dyn(vis, [&](auto&& deserializer) {
53 return new Model_T{deserializer, parent};
54 });
55 }
56};
57
58template <typename Model_T>
60{
61 static_assert(std::is_same<Model_T, void>::value, "can't be used like this");
62 return {};
63}
64
65template <typename Model_T, typename Item_T, typename ExtView_T = void>
67{
68public:
69 virtual ~EffectLayerFactory_T() = default;
70
71private:
72 UuidKey<Process::ProcessModel> concreteKey() const noexcept override
73 {
75 }
76
77 LayerView* makeLayerView(
78 const Process::ProcessModel&, const Process::Context& context,
79 QGraphicsItem* parent) const final override
80 {
81 return new EffectLayerView{parent};
82 }
83
84 LayerPresenter* makeLayerPresenter(
86 const Process::Context& context, QObject* parent) const final override
87 {
88 auto pres = new EffectLayerPresenter{
89 safe_cast<const Model_T&>(lm), safe_cast<EffectLayerView*>(v), context, parent};
90
91 auto rect = new score::EmptyRectItem{v};
92 auto item = makeItem(lm, context, rect);
93 item->setParentItem(rect);
94 return pres;
95 }
96
97 score::ResizeableItem* makeItem(
98 const Process::ProcessModel& proc, const Process::Context& ctx,
99 QGraphicsItem* parent) const override
100 {
101 return new Item_T{safe_cast<const Model_T&>(proc), ctx, parent};
102 }
103
104 bool hasExternalUI(
105 const Process::ProcessModel& proc,
106 const score::DocumentContext& ctx) const noexcept override
107 {
108 return ((Model_T&)proc).hasExternalUI();
109 }
110
111 QWidget* makeExternalUI(
112 const Process::ProcessModel& proc, const score::DocumentContext& ctx,
113 QWidget* parent) const final override
114 {
115 (void)parent;
116 try
117 {
118 if constexpr(!std::is_same_v<ExtView_T, void>)
119 return new ExtView_T{safe_cast<const Model_T&>(proc), ctx, parent};
120 }
121 catch(...)
122 {
123 }
124 return nullptr;
125 }
126
127 bool matches(const UuidKey<Process::ProcessModel>& p) const override
128 {
130 }
131};
132}
Definition EffectFactory.hpp:67
Definition EffectLayer.hpp:32
Definition EffectLayer.hpp:16
Definition EffectFactory.hpp:14
Definition score-lib-process/Process/ProcessFactory.hpp:59
Definition LayerPresenter.hpp:34
Definition LayerView.hpp:21
The ProcessFactory class.
Definition score-lib-process/Process/ProcessFactory.hpp:35
The Process class.
Definition score-lib-process/Process/Process.hpp:61
Definition UuidKey.hpp:343
The id_base_t class.
Definition Identifier.hpp:57
Definition RectItem.hpp:64
Definition RectItem.hpp:12
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1324
ProcessFlags
Various settings for processes.
Definition ProcessFlags.hpp:17
Static metadata implementation.
Definition lib/score/tools/Metadata.hpp:36
Definition ProcessContext.hpp:12
Definition score-lib-process/Process/ProcessMetadata.hpp:37
Definition TimeValue.hpp:21
The VisitorVariant struct.
Definition VisitorInterface.hpp:26
Definition ObjectMatches.hpp:6
Definition DocumentContext.hpp:18