MuseScore  3.4
Music composition and notation
input.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2002-2011 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __INPUT_H__
14 #define __INPUT_H__
15 
16 #include "mscore.h"
17 #include "durationtype.h"
18 #include "beam.h"
19 
20 namespace Ms {
21 
22 class Element;
23 class Slur;
24 class ChordRest;
25 class Drumset;
26 class Segment;
27 class Score;
28 class Selection;
29 
30 //---------------------------------------------------------
31 // NoteEntryMethod
32 //---------------------------------------------------------
33 
34 enum class NoteEntryMethod : char {
36  };
37 
38 //---------------------------------------------------------
39 // InputState
40 //---------------------------------------------------------
41 
42 class InputState {
43  TDuration _duration { TDuration::DurationType::V_INVALID }; // currently duration
44  int _drumNote { -1 };
45  int _track { 0 };
46  int _prevTrack { 0 }; // used for navigation
47  Segment* _lastSegment { 0 };
48  Segment* _segment { 0 }; // current segment
49  int _string { VISUAL_STRING_NONE }; // visual string selected for input (TAB staves only)
50  bool _rest { false }; // rest mode
51  NoteType _noteType { NoteType::NORMAL };
53  bool _noteEntryMode { false };
55  AccidentalType _accidentalType { AccidentalType::NONE };
56  Slur* _slur { 0 };
57  bool _insertMode { false };
58 
59  Segment* nextInputPos() const;
60 
61  public:
62  ChordRest* cr() const;
63 
64  Fraction tick() const;
65 
66  void setDuration(const TDuration& d) { _duration = d; }
67  TDuration duration() const { return _duration; }
68  void setDots(int n);
69  Fraction ticks() const { return _duration.ticks(); }
70 
71  Segment* segment() const { return _segment; }
72  void setSegment(Segment* s);
73 
74  Segment* lastSegment() const { return _lastSegment; }
75  void setLastSegment(Segment* s) { _lastSegment = s; }
76 
77  const Drumset* drumset() const;
78 
79  int drumNote() const { return _drumNote; }
80  void setDrumNote(int v) { _drumNote = v; }
81 
82  int voice() const { return _track == -1 ? 0 : (_track % VOICES); }
83  int track() const { return _track; }
84  void setTrack(int v) { _prevTrack = _track; _track = v; }
85  int prevTrack() const { return _prevTrack; }
86 
87  int string() const { return _string; }
88  void setString(int val) { _string = val; }
89 
90  StaffGroup staffGroup() const;
91 
92  bool rest() const { return _rest; }
93  void setRest(bool v) { _rest = v; }
94 
95  NoteType noteType() const { return _noteType; }
96  void setNoteType(NoteType t) { _noteType = t; }
97 
98  Beam::Mode beamMode() const { return _beamMode; }
99  void setBeamMode(Beam::Mode m) { _beamMode = m; }
100 
101  bool noteEntryMode() const { return _noteEntryMode; }
102  void setNoteEntryMode(bool v) { _noteEntryMode = v; }
103 
104  NoteEntryMethod noteEntryMethod() const { return _noteEntryMethod; }
105  void setNoteEntryMethod(NoteEntryMethod m) { _noteEntryMethod = m; }
106  bool usingNoteEntryMethod(NoteEntryMethod m) const { return m == noteEntryMethod(); }
107 
108  AccidentalType accidentalType() const { return _accidentalType; }
109  void setAccidentalType(AccidentalType val) { _accidentalType = val; }
110 
111  Slur* slur() const { return _slur; }
112  void setSlur(Slur* s) { _slur = s; }
113 
114  bool insertMode() const { return _insertMode; }
115  void setInsertMode(bool val) { _insertMode = val; }
116 
117  void update(Selection& selection);
118  void moveInputPos(Element* e);
119  void moveToNextInputPos();
120  bool endOfScore() const;
121 
122  // TODO: unify with Selection::cr()?
123  static Note* note(Element*);
124  static ChordRest* chordRest(Element*);
125  };
126 
127 
128 } // namespace Ms
129 #endif
130 
Segment * lastSegment() const
Definition: input.h:74
Definition: select.h:136
Definition: durationtype.h:28
void setLastSegment(Segment *s)
Definition: input.h:75
void setTrack(int v)
Definition: input.h:84
bool insertMode() const
Definition: input.h:114
Fraction ticks() const
Definition: input.h:69
void setInsertMode(bool val)
Definition: input.h:115
void setDuration(const TDuration &d)
Definition: input.h:66
AccidentalType accidentalType() const
Definition: input.h:108
NoteEntryMethod
Definition: input.h:34
Definition: slur.h:55
AccidentalType
Definition: types.h:152
Base class of score layout elements.
Definition: element.h:158
TDuration duration() const
Definition: input.h:67
StaffGroup
Definition: mscore.h:177
int string() const
Definition: input.h:87
void setAccidentalType(AccidentalType val)
Definition: input.h:109
void setString(int val)
Definition: input.h:88
void setBeamMode(Beam::Mode m)
Definition: input.h:99
bool rest() const
Definition: input.h:92
Slur * slur() const
Definition: input.h:111
NoteEntryMethod noteEntryMethod() const
Definition: input.h:104
Definition: drumset.h:68
#define VOICES
Definition: mscore.h:72
Definition: input.h:42
int prevTrack() const
Definition: input.h:85
void setDrumNote(int v)
Definition: input.h:80
Segment * segment() const
Definition: input.h:71
Definition: segment.h:50
Mode
Definition: beam.h:73
Definition: aeolus.cpp:26
void setNoteEntryMode(bool v)
Definition: input.h:102
NoteType
Definition: types.h:255
int voice() const
Definition: input.h:82
void setSlur(Slur *s)
Definition: input.h:112
void setRest(bool v)
Definition: input.h:93
int ticks() const
Definition: fraction.h:228
bool noteEntryMode() const
Definition: input.h:101
Definition: chordrest.h:48
bool usingNoteEntryMethod(NoteEntryMethod m) const
Definition: input.h:106
NoteType noteType() const
Definition: input.h:95
void setNoteEntryMethod(NoteEntryMethod m)
Definition: input.h:105
int drumNote() const
Definition: input.h:79
Beam::Mode beamMode() const
Definition: input.h:98
Graphic representation of a note.
Definition: note.h:212
Definition: fraction.h:46
int track() const
Definition: input.h:83
void setNoteType(NoteType t)
Definition: input.h:96