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 
10 namespace Process
11 {
12 template <typename Model_T>
14 {
15 public:
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 
33  ProcessFlags flags() const noexcept override
34  {
36  }
37 
38  QString customConstructionData() const noexcept override;
39 
40  Model_T* make(
41  const TimeVal& duration, const QString& data, const Id<Process::ProcessModel>& id,
42  const score::DocumentContext& ctx, QObject* parent) override
43  {
44  return new Model_T{duration, data, id, parent};
45  }
46 
47  Model_T* load(
48  const VisitorVariant& vis, const score::DocumentContext& ctx,
49  QObject* parent) final override
50  {
51  return score::deserialize_dyn(vis, [&](auto&& deserializer) {
52  return new Model_T{deserializer, parent};
53  });
54  }
55 };
56 
57 template <typename Model_T>
59 {
60  static_assert(std::is_same<Model_T, void>::value, "can't be used like this");
61  return {};
62 }
63 
64 template <typename Model_T, typename Item_T, typename ExtView_T = void>
66 {
67 public:
68  virtual ~EffectLayerFactory_T() = default;
69 
70 private:
71  UuidKey<Process::ProcessModel> concreteKey() const noexcept override
72  {
74  }
75 
76  LayerView* makeLayerView(
77  const Process::ProcessModel&, const Process::Context& context,
78  QGraphicsItem* parent) const final override
79  {
80  return new EffectLayerView{parent};
81  }
82 
83  LayerPresenter* makeLayerPresenter(
85  const Process::Context& context, QObject* parent) const final override
86  {
87  auto pres = new EffectLayerPresenter{
88  safe_cast<const Model_T&>(lm), safe_cast<EffectLayerView*>(v), context, parent};
89 
90  auto rect = new score::EmptyRectItem{v};
91  auto item = makeItem(lm, context, rect);
92  item->setParentItem(rect);
93  return pres;
94  }
95 
96  score::ResizeableItem* makeItem(
97  const Process::ProcessModel& proc, const Process::Context& ctx,
98  QGraphicsItem* parent) const override
99  {
100  return new Item_T{safe_cast<const Model_T&>(proc), ctx, parent};
101  }
102 
103  bool hasExternalUI(
104  const Process::ProcessModel& proc,
105  const score::DocumentContext& ctx) const noexcept override
106  {
107  return ((Model_T&)proc).hasExternalUI();
108  }
109 
110  QWidget* makeExternalUI(
111  const Process::ProcessModel& proc, const score::DocumentContext& ctx,
112  QWidget* parent) const final override
113  {
114  (void)parent;
115  try
116  {
117  if constexpr(!std::is_same_v<ExtView_T, void>)
118  return new ExtView_T{safe_cast<const Model_T&>(proc), ctx, parent};
119  }
120  catch(...)
121  {
122  }
123  return nullptr;
124  }
125 
126  bool matches(const UuidKey<Process::ProcessModel>& p) const override
127  {
129  }
130 };
131 }
Definition: EffectFactory.hpp:66
Definition: EffectLayer.hpp:27
Definition: EffectLayer.hpp:16
Definition: EffectFactory.hpp:14
Definition: score-lib-process/Process/ProcessFactory.hpp:58
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
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