File: input.h

package info (click to toggle)
musescore 2.0.3%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 202,532 kB
  • ctags: 58,769
  • sloc: cpp: 257,595; xml: 172,226; ansic: 139,931; python: 6,565; sh: 6,383; perl: 423; makefile: 290; awk: 142; pascal: 67; sed: 3
file content (111 lines) | stat: -rw-r--r-- 3,977 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//=============================================================================
//  MuseScore
//  Music Composition & Notation
//
//  Copyright (C) 2002-2011 Werner Schweer
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License version 2
//  as published by the Free Software Foundation and appearing in
//  the file LICENCE.GPL
//=============================================================================

#ifndef __INPUT_H__
#define __INPUT_H__

#include "mscore.h"
#include "durationtype.h"
#include "beam.h"

namespace Ms {

class Element;
class Slur;
class ChordRest;
class Drumset;
class Segment;
class Score;

//---------------------------------------------------------
//   InputState
//---------------------------------------------------------

class InputState {
      Score*      _score;
      TDuration   _duration    { TDuration::DurationType::V_INVALID };  // currently duration
      int         _drumNote    { -1 };
      int         _track       { 0 };
      int         _prevTrack   { 0 };                       // used for navigation
      Segment*    _lastSegment { 0 };
      Segment*    _segment     { 0 };                       // current segment
      int         _string      { VISUAL_STRING_NONE };      // visual string selected for input (TAB staves only)
      bool        _repitchMode { false };
      bool _rest               { false };              // rest mode
      NoteType _noteType       { NoteType::NORMAL };
      Beam::Mode _beamMode       { Beam::Mode::AUTO };
      bool _noteEntryMode      { false };
      Slur* _slur              { 0     };

      Segment* nextInputPos() const;

   public:
      InputState(Score* s) : _score(s) {}

      ChordRest* cr() const;

      int tick() const;

      void setDuration(const TDuration& d) { _duration = d;          }
      TDuration duration() const           { return _duration;       }
      void setDots(int n)                  { _duration.setDots(n);   }
      int ticks() const                    { return _duration.ticks(); }

      Segment* segment() const            { return _segment;        }
      void setSegment(Segment* s);

      Segment* lastSegment() const        { return _lastSegment;        }
      void setLastSegment(Segment* s)     { _lastSegment = s;           }

      const Drumset* drumset() const;

      int drumNote() const                { return _drumNote;       }
      void setDrumNote(int v)             { _drumNote = v;          }

      int voice() const                   { return _track == -1 ? 0 : (_track % VOICES); }
      int track() const                   { return _track;          }
      void setTrack(int v)                { _prevTrack = _track; _track = v; }
      int prevTrack() const               { return _prevTrack;      }

      int string() const                  { return _string;             }
      void setString(int val)             { _string = val;              }

      bool repitchMode() const            { return _repitchMode;    }
      void setRepitchMode(bool val)       { _repitchMode = val;     }

      StaffGroup staffGroup() const;

      bool rest() const                   { return _rest; }
      void setRest(bool v)                { _rest = v; }

      NoteType noteType() const           { return _noteType; }
      void setNoteType(NoteType t)        { _noteType = t; }

      Beam::Mode beamMode() const           { return _beamMode; }
      void setBeamMode(Beam::Mode m)        { _beamMode = m; }

      bool noteEntryMode() const          { return _noteEntryMode; }
      void setNoteEntryMode(bool v)       { _noteEntryMode = v; }

      Slur* slur() const                  { return _slur; }
      void setSlur(Slur* s)               { _slur = s; }

      void update(Element* e);
      void moveInputPos(Element* e);
      void moveToNextInputPos();
      bool endOfScore() const;
      };


}     // namespace Ms
#endif