Loading...
Searching...
No Matches
score-plugin-media/Media/Step/View.hpp
1#pragma once
2#include <Process/LayerView.hpp>
3
4#include <Media/Step/Commands.hpp>
5
6#include <score/command/Dispatchers/SingleOngoingCommandDispatcher.hpp>
7#include <score/graphics/RectItem.hpp>
8#include <score/tools/BarsDrag.hpp>
9
10#include <QGraphicsSceneMouseEvent>
11#include <QPainter>
12
13#include <optional>
14
15#include <verdigris>
16
17namespace Process
18{
19struct Context;
20}
21class QMenu;
22namespace score
23{
24class CommandStackFacade;
25}
26namespace Media::Step
27{
28class Model;
29
40{
41public:
44 std::optional<ossia::float_vector> press(
45 const Model& m, int step, QPointF pos, Qt::KeyboardModifiers mods, double height);
46 std::optional<ossia::float_vector>
47 move(const Model& m, int step, QPointF pos, double height);
48 void release() noexcept;
49
50private:
51 score::BarsDrag m_drag;
52 bool m_setting{};
53};
54
56void randomizeSteps(const Model& m, const score::CommandStackFacade& stack);
58void fillStepsMenu(QMenu& menu, const Model& m, const score::CommandStackFacade& stack);
59
60class View final : public Process::LayerView
61{
62 W_OBJECT(View)
63public:
64 explicit View(const Model&, QGraphicsItem* parent);
65 ~View();
66
67 void setBarWidth(double v);
68
69public:
72 void stepsEdited(const ossia::float_vector& steps) W_SIGNAL(stepsEdited, steps);
73
74private:
75 void paint_impl(QPainter* p) const override;
76
78 int stepAt(double x) const noexcept;
79 void mousePressEvent(QGraphicsSceneMouseEvent* ev) override;
80 void mouseMoveEvent(QGraphicsSceneMouseEvent* ev) override;
81 void mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) override;
82 void contextMenuEvent(QGraphicsSceneContextMenuEvent* ev) override;
83 bool sceneEvent(QEvent* ev) override;
84 void endGesture();
85
86private:
87 const Model& m_model;
88 StepsGesture m_gesture;
89 bool m_editing{};
90 double m_barWidth{};
92 int m_playing{-1};
93};
94
95class Item final : public score::EmptyRectItem
96{
97 W_OBJECT(Item)
98public:
99 explicit Item(const Model&, const Process::Context& ctx, QGraphicsItem* parent);
100 ~Item();
101
102private:
103 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
104 final override;
105
106 void mousePressEvent(QGraphicsSceneMouseEvent* ev) override;
107 void mouseMoveEvent(QGraphicsSceneMouseEvent* ev) override;
108 void mouseReleaseEvent(QGraphicsSceneMouseEvent* ev) override;
109 void contextMenuEvent(QGraphicsSceneContextMenuEvent* ev) override;
110 bool sceneEvent(QEvent* ev) override;
111 int stepAt(double x) const noexcept;
112 void endGesture();
113
114private:
115 const Model& m_model;
117 StepsGesture m_gesture;
118 int m_playing{-1};
119};
120
121}
Definition score-plugin-media/Media/Step/View.hpp:96
A step sequencer with several sequences.
Definition score-plugin-media/Media/Step/Model.hpp:37
The mouse on the bars of the sequence shown, in the layer and in the node.
Definition score-plugin-media/Media/Step/View.hpp:40
std::optional< ossia::float_vector > press(const Model &m, int step, QPointF pos, Qt::KeyboardModifiers mods, double height)
Definition score-plugin-media/Media/Step/View.cpp:257
Definition score-plugin-media/Media/Step/View.hpp:61
void stepsEdited(const ossia::float_vector &steps)
Definition LayerView.hpp:21
The SingleOngoingCommandDispatcher class.
Definition SingleOngoingCommandDispatcher.hpp:18
A small abstraction layer over the score::CommandStack.
Definition CommandStackFacade.hpp:21
Definition RectItem.hpp:78
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1115
Base toolkit upon which the software is built.
Definition Application.cpp:83
Definition ProcessContext.hpp:12
A modifier drag over a row of bars, each the value of a step.
Definition BarsDrag.hpp:22