Loading...
Searching...
No Matches
PatternController.hpp
1#pragma once
2#include <QObject>
3
4#include <Patternist/PatternEdit.hpp>
5
6#include <functional>
7#include <random>
8
9class QMenu;
10namespace score
11{
12struct DocumentContext;
13}
14namespace Patternist
15{
16class View;
17
20class SCORE_PLUGIN_MIDI_EXPORT Controller final : public QObject
21{
22public:
24 const ProcessModel& model, const score::DocumentContext& ctx, QObject* parent);
25
27 void attach(View& view);
28
30 void fillMenu(QMenu& menu, int lane);
31
33 std::function<void(const QString&)> status;
34
35 void copy() const;
36 void paste();
38 void copySteps(const StepSelection& s) const;
41 bool pasteSteps(int lane, const std::vector<int>& starts);
42 void clearSteps(const StepSelection& s);
43 void clear();
44 void rotate(int steps);
46 void transpose(int semitones);
48 void randomize(int lane = -1);
49
50 void toggleMute(int lane);
51 void toggleSolo(int lane);
52 void copyLanes(const std::vector<int>& lanes) const;
53 bool pasteLanes(const std::vector<int>& targets);
54 void clearLanes(const std::vector<int>& lanes);
55 void addLane();
56 void addControlLane(uint8_t note);
57 void removeLane(int lane);
58 void setLength(int length);
59 void setDivision(int division);
60
62 template <typename F>
63 void editLane(int lane, F&& f)
64 {
65 if(!hasPattern())
66 return;
67 auto p = current();
68 if(lane < 0 || lane >= int(p.lanes.size()))
69 return;
70 f(p.lanes[lane]);
71 submit(p);
72 }
74 void euclidean(int lane, int hits, int rotation, Combine c);
76 void randomizeField(StepField f, int lane);
77 void resetField(StepField f, int lane);
78 void setCondition(int lane, int step, Condition c, int a, int b);
79
80 void selectPattern(int index);
81 void duplicatePattern();
82 void removePattern();
83
84private:
85 bool hasPattern() const noexcept;
86 Pattern current() const;
87 void submit(const Pattern& p);
88
89 const ProcessModel& m_model;
90 const score::DocumentContext& m_ctx;
91 std::mt19937 m_rng{std::random_device{}()};
92};
93}
Definition PatternController.hpp:21
std::function< void(const QString &)> status
What the last action did, for the editor to show.
Definition PatternController.hpp:33
void editLane(int lane, F &&f)
One-shot edits of a lane, as one undo step.
Definition PatternController.hpp:63
Definition PatternModel.hpp:247
Definition PatternView.hpp:20
Base toolkit upon which the software is built.
Definition Application.cpp:83
STL namespace.
Definition PatternModel.hpp:139
Definition PatternEdit.hpp:67
Definition DocumentContext.hpp:18