2 #include <Process/Style/ScenarioStyle.hpp>
4 #include <Scenario/Document/State/StateModel.hpp>
5 #include <Scenario/Document/State/StatePresenter.hpp>
6 #include <Scenario/Document/State/StateView.hpp>
8 #include <QGraphicsItem>
9 #include <QGraphicsSceneMouseEvent>
19 : QGraphicsItem{parent}
21 this->setFlag(ItemStacksBehindParent,
true);
22 this->setAcceptHoverEvents(
true);
23 auto& skin = score::Skin::instance();
24 this->setCursor(skin.CursorPointingHand);
27 static const constexpr
int Type = ItemType::StateOverlay;
28 int type()
const final override {
return Type; }
30 QRectF boundingRect()
const override {
return {-1, -1, 16, 16}; }
34 void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option, QWidget* widget)
37 painter->setRenderHint(QPainter::Antialiasing,
true);
39 const auto& pending_brush = brush();
40 painter->setBrush(pending_brush);
41 const auto bright = pending_brush.color();
42 QPen p{bright.darker(300)};
47 const auto small_rad = m_big ? 4. : 2.;
51 ? QLineF{QPointF{15 - small_rad, 0}, QPointF{15 - small_rad, 2 * small_rad}}
53 : QLineF{QPointF{15 - small_rad, 0}, QPointF{15 - small_rad, 2 * small_rad}}
56 = m_big ? QLineF{QPointF{15 - 2 * small_rad, small_rad}, QPointF{15, small_rad}}
58 : QLineF{QPointF{15 - 2 * small_rad, small_rad}, QPointF{15, small_rad}}
61 painter->drawLine(l1.translated(1, 1));
62 painter->drawLine(l2.translated(1, 1));
65 painter->drawLine(l1);
66 painter->drawLine(l2);
68 painter->setRenderHint(QPainter::Antialiasing,
false);
71 void hoverEnterEvent(QGraphicsSceneHoverEvent* event)
override
73 auto p =
event->pos();
74 m_big = p.x() > 4 && p.y() < 10;
78 void hoverMoveEvent(QGraphicsSceneHoverEvent* event)
override
80 auto p =
event->pos();
81 m_big = p.x() > 4 && p.y() < 10;
85 void hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
override
91 void mouseMoveEvent(QGraphicsSceneMouseEvent* event)
override
93 auto st =
static_cast<StateView*
>(parentItem());
94 st->presenter().moved(event->scenePos());
98 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
override
100 auto st =
static_cast<StateView*
>(parentItem());
101 st->presenter().released(event->scenePos());
115 QObject::tr(
"Create an interval.\nDrag the plus to create an interval"));
121 auto& skin = Process::Style::instance();
122 return skin.EventPending();
125 void mousePressEvent(QGraphicsSceneMouseEvent* event)
override
127 if(event->button() == Qt::MouseButton::LeftButton)
129 auto st =
static_cast<StateView*
>(parentItem());
130 st->presenter().select();
131 if(
auto p = event->pos(); p.x() > 4 && p.y() < 10)
133 st->startCreateMode();
136 st->presenter().pressed(event->scenePos());
149 QObject::tr(
"Create a graph link.\nDrag the plus to create a graph link"));
155 auto& skin = Process::Style::instance();
156 return skin.EventDisposed();
159 void mousePressEvent(QGraphicsSceneMouseEvent* event)
override
161 if(event->button() == Qt::MouseButton::LeftButton)
163 auto st =
static_cast<StateView*
>(parentItem());
164 st->presenter().select();
165 if(
auto p = event->pos(); p.x() > 4 && p.y() < 10)
167 st->startCreateGraphalMode();
170 st->presenter().pressed(event->scenePos());
183 QObject::tr(
"Create a sequence.\nDrag the plus to create a sequence."));
189 auto& skin = Process::Style::instance();
190 return skin.IntervalBase();
193 void mousePressEvent(QGraphicsSceneMouseEvent* event)
override
195 if(event->button() == Qt::MouseButton::LeftButton)
197 auto st =
static_cast<StateView*
>(parentItem());
198 st->presenter().select();
199 if(
auto p = event->pos(); p.x() > 4 && p.y() < 10)
201 st->startCreateSequence();
204 st->presenter().pressed(event->scenePos());
215 , m_sequenceOverlay{v}
217 m_overlay.setZValue(1);
218 m_sequenceOverlay.setZValue(2);
219 m_graphOverlay.setZValue(3);
221 m_overlay.setPos(1, -14);
222 m_graphOverlay.setPos(1, 6);
223 if(v->presenter().model().nextInterval())
225 m_sequenceOverlay.setVisible(
false);
226 m_sequenceOverlay.setEnabled(
false);
230 m_sequenceOverlay.setPos(7, -4);
Definition: StateMenuOverlay.hpp:16
Definition: StateMenuOverlay.hpp:143
Definition: StateMenuOverlay.hpp:109
Definition: StateMenuOverlay.hpp:177
Definition: StateView.hpp:29
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Definition: StateMenuOverlay.hpp:211