Loading...
Searching...
No Matches
CurvePaletteBaseTransitions.hpp
1#pragma once
2#include "CurvePaletteBaseEvents.hpp"
3#include "CurvePaletteBaseStates.hpp"
4
5#include <Curve/Point/CurvePointModel.hpp>
6#include <Curve/Point/CurvePointView.hpp>
7#include <Curve/Segment/CurveSegmentModel.hpp>
8#include <Curve/Segment/CurveSegmentView.hpp>
9
10namespace Curve
11{
12// TODO cleanup this file
13
14template <typename T>
15using GenericTransition = score::StateAwareTransition<StateBase, T>;
16
17template <typename Event>
18class MatchedCurveTransition : public GenericTransition<score::MatchedTransition<Event>>
19{
20public:
21 using GenericTransition<score::MatchedTransition<Event>>::GenericTransition;
22};
23
24template <typename Element_T, typename Modifier_T>
26 : public MatchedCurveTransition<CurveEvent<Element_T, Modifier_T>>
27{
28public:
30 CurveEvent<Element_T, Modifier_T>>::MatchedCurveTransition;
31
32protected:
33 void onTransition(QEvent* ev) override
34 {
35 auto qev = safe_cast<CurveEvent<Element_T, Modifier_T>*>(ev);
36 this->state().currentPoint = qev->point;
37
38 impl(qev);
39 }
40
41private:
44 {
45 this->state().clickedPointId = ev->pointId;
46 }
48 {
49 this->state().clickedSegmentId = ev->segmentId;
50 }
51
54 {
55 this->state().hoveredPointId = ev->pointId;
56 }
58 {
59 this->state().hoveredSegmentId = ev->segmentId;
60 }
61
64 {
65 this->state().hoveredPointId = ev->pointId;
66 }
68 {
69 this->state().hoveredSegmentId = ev->segmentId;
70 }
71};
72
79
86
93
94class ClickOnAnything_Transition final : public GenericTransition<QAbstractTransition>
95{
96public:
97 using GenericTransition<QAbstractTransition>::GenericTransition;
98
99protected:
100 bool eventTest(QEvent* e) override
101 {
102 using namespace std;
103 static const constexpr QEvent::Type types[]
104 = {QEvent::Type(QEvent::User + ClickOnNothing_Event::user_type),
105 QEvent::Type(QEvent::User + ClickOnPoint_Event::user_type),
106 QEvent::Type(QEvent::User + ClickOnSegment_Event::user_type)};
107
108 return find(begin(types), end(types), e->type()) != end(types);
109 }
110
111 void onTransition(QEvent* e) override
112 {
113 auto qev = safe_cast<score::PositionedEvent<Curve::Point>*>(e);
114
115 this->state().currentPoint = qev->point;
116 }
117};
118
119class MoveOnAnything_Transition final : public GenericTransition<QAbstractTransition>
120{
121public:
122 using GenericTransition<QAbstractTransition>::GenericTransition;
123
124protected:
125 bool eventTest(QEvent* e) override
126 {
127 using namespace std;
128 static const constexpr QEvent::Type types[]
129 = {QEvent::Type(QEvent::User + MoveOnNothing_Event::user_type),
130 QEvent::Type(QEvent::User + MoveOnPoint_Event::user_type),
131 QEvent::Type(QEvent::User + MoveOnSegment_Event::user_type)};
132
133 return find(begin(types), end(types), e->type()) != end(types);
134 }
135
136 void onTransition(QEvent* e) override
137 {
138 auto qev = safe_cast<score::PositionedEvent<Curve::Point>*>(e);
139
140 this->state().currentPoint = qev->point;
141 }
142};
143
144class ReleaseOnAnything_Transition final : public QAbstractTransition
145{
146protected:
147 bool eventTest(QEvent* e) override
148 {
149 using namespace std;
150 static const constexpr QEvent::Type types[]
151 = {QEvent::Type(QEvent::User + ReleaseOnNothing_Event::user_type),
152 QEvent::Type(QEvent::User + ReleaseOnPoint_Event::user_type),
153 QEvent::Type(QEvent::User + ReleaseOnSegment_Event::user_type)};
154
155 return find(begin(types), end(types), e->type()) != end(types);
156 }
157
158 void onTransition(QEvent* e) override { }
159};
160}
Definition CurvePaletteBaseTransitions.hpp:95
Definition CurvePaletteBaseTransitions.hpp:19
Definition CurvePaletteBaseTransitions.hpp:120
Definition CurvePaletteBaseTransitions.hpp:27
Definition CurvePaletteBaseTransitions.hpp:145
Definition StateMachineUtils.hpp:60
Definition StateMachineUtils.hpp:76
Utilities and base classes for 1D curves.
Definition FocusDispatcher.hpp:12
STL namespace.
Definition CurvePaletteBaseEvents.hpp:36