LayerPresenter.hpp
1 #pragma once
2 #include <Process/ProcessContext.hpp>
3 #include <Process/ZoomHelper.hpp>
4 
5 #include <score/model/Identifier.hpp>
6 
7 #include <QGraphicsItem>
8 
9 #include <score_lib_process_export.h>
10 
11 #include <verdigris>
12 class QMenu;
13 class QPoint;
14 class QPointF;
15 class QMimeData;
16 namespace Process
17 {
18 class ProcessModel;
19 class LayerContextMenuManager;
20 class SCORE_LIB_PROCESS_EXPORT GraphicsShapeItem : public QGraphicsItem
21 {
22 public:
23  using QGraphicsItem::QGraphicsItem;
24  ~GraphicsShapeItem() override;
25  virtual void setSize(QSizeF sz);
26  virtual void on_zoomRatioChanged(ZoomRatio) = 0;
27 
28  QRectF boundingRect() const final override;
29 
30 private:
31  QSizeF m_sz{};
32 };
33 class SCORE_LIB_PROCESS_EXPORT LayerPresenter : public QObject
34 {
35  W_OBJECT(LayerPresenter)
36 
37 public:
39  const ProcessModel& model, const LayerView* view, const Context& ctx,
40  QObject* parent);
41  ~LayerPresenter() override;
42 
43  const Process::LayerContext& context() const { return m_context; }
44 
45  bool focused() const;
46  void setFocus(bool focus);
47  virtual void on_focusChanged();
48 
49  virtual void setFullView();
50 
51  virtual void setWidth(qreal width, qreal defaultWidth) = 0;
52  virtual void setHeight(qreal height) = 0;
53 
54  virtual void putToFront() = 0;
55  virtual void putBehind() = 0;
56 
57  virtual void on_zoomRatioChanged(ZoomRatio) = 0;
58  virtual void parentGeometryChanged() = 0;
59 
60  const ProcessModel& model() const noexcept;
61 
62  virtual void
63  fillContextMenu(QMenu&, QPoint pos, QPointF scenepos, const LayerContextMenuManager&);
64 
65  virtual GraphicsShapeItem* makeSlotHeaderDelegate();
66 
67  static constexpr bool recommendedHeight = false;
68 
69 public:
70  void contextMenuRequested(const QPoint& arg_1, const QPointF& arg_2)
71  E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, contextMenuRequested, arg_1, arg_2)
72 
73 protected:
74  void handlePresetDrop(const QPointF& pt, const QMimeData& mime);
75  void requestFocus();
76 
77  Process::LayerContext m_context;
78  const Process::ProcessModel& m_process;
79 
80 private:
81  bool m_focus{false};
82 };
83 }
84 
85 W_REGISTER_ARGTYPE(Process::LayerPresenter*)
Definition: LayerPresenter.hpp:21
Definition: LayerContextMenu.hpp:38
Definition: LayerPresenter.hpp:34
Definition: LayerView.hpp:21
The Process class.
Definition: score-lib-process/Process/Process.hpp:61
Base classes and tools to implement processes and layers.
Definition: JSONVisitor.hpp:1324
Definition: ProcessContext.hpp:12
Definition: ProcessContext.hpp:21