IntervalPresenter.hpp
1 #pragma once
2 #include <Process/TimeValue.hpp>
3 #include <Process/ZoomHelper.hpp>
4 
5 #include <Scenario/Document/Interval/SlotPresenter.hpp>
6 
7 #include <score/model/Identifier.hpp>
8 
9 #include <QPoint>
10 
11 #include <nano_signal_slot.hpp>
12 #include <score_plugin_scenario_export.h>
13 
14 #include <verdigris>
15 
16 namespace Process
17 {
18 struct Context;
19 }
20 
21 namespace Scenario
22 {
23 class IntervalHeader;
24 class IntervalModel;
25 class IntervalView;
26 
27 class SCORE_PLUGIN_SCENARIO_EXPORT IntervalPresenter
28  : public QObject
29  , public Nano::Observer
30 {
31  W_OBJECT(IntervalPresenter)
32 
33 public:
35  ZoomRatio zoom, const IntervalModel& model, IntervalView* view,
36  IntervalHeader* header, const Process::Context& ctx, QObject* parent);
37  virtual ~IntervalPresenter();
38  virtual void updateScaling();
39 
40  bool isSelected() const;
41 
42  const IntervalModel& model() const;
43 
44  IntervalView* view() const;
45  IntervalHeader* header() const { return m_header; }
46 
47  virtual void on_zoomRatioChanged(ZoomRatio val);
48  ZoomRatio zoomRatio() const { return m_zoomRatio; }
49 
50  const std::vector<SlotPresenter>& getSlots() const { return m_slots; }
51 
52  const Id<IntervalModel>& id() const;
53 
54  const Process::Context& context() const { return m_context; }
55 
56  void on_minDurationChanged(const TimeVal&);
57  void on_maxDurationChanged(const TimeVal&);
58 
59  double on_playPercentageChanged(double t);
60 
61  virtual void startSlotDrag(int slot, QPointF) const = 0;
62  virtual void stopSlotDrag() const = 0;
63 
64  virtual void selectedSlot(int) const = 0;
65  virtual void requestSlotMenu(int slot, QPoint pos, QPointF sp) const = 0;
66 
67  void updateAllSlots() const;
68 
69 public:
70  void pressed(QPointF arg_1) const
71  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, pressed, arg_1)
72  void moved(QPointF arg_1) const E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, moved, arg_1)
73  void released(QPointF arg_1) const
74  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, released, arg_1)
75 
76  void askUpdate() E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, askUpdate)
77  void heightChanged() E_SIGNAL(
78  SCORE_PLUGIN_SCENARIO_EXPORT,
79  heightChanged) // The vertical size
80  void heightPercentageChanged() E_SIGNAL(
81  SCORE_PLUGIN_SCENARIO_EXPORT,
82  heightPercentageChanged) // The vertical position
83 
84 protected:
85  void updateChildren();
86  void updateBraces();
87 
88  // Process presenters are in the slot presenters.
89  const IntervalModel& m_model;
90 
91  ZoomRatio m_zoomRatio{};
92  IntervalView* m_view{};
93  IntervalHeader* m_header{};
94  const Process::Context& m_context;
95 
96  std::vector<SlotPresenter> m_slots;
97 };
98 
99 template <typename T>
100 const typename T::view_type* view(const T* obj)
101 {
102  return static_cast<const typename T::view_type*>(obj->view());
103 }
104 
105 template <typename T>
106 typename T::view_type* view(T* obj)
107 {
108  return static_cast<typename T::view_type*>(obj->view());
109 }
110 
111 template <typename T>
112 typename T::view_type& view(const T& obj)
113 {
114  return static_cast<typename T::view_type&>(*obj.view());
115 }
116 
117 template <typename T>
118 typename T::view_type& view(T& obj)
119 {
120  return static_cast<typename T::view_type&>(*obj.view());
121 }
122 }
Definition: IntervalHeader.hpp:14
Definition: IntervalModel.hpp:50
Definition: IntervalPresenter.hpp:30
Definition: IntervalView.hpp:34
The id_base_t class.
Definition: Identifier.hpp:57
Base classes and tools to implement processes and layers.
Definition: JSONVisitor.hpp:1324
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Definition: ProcessContext.hpp:12
Definition: TimeValue.hpp:21