MuseScore/libmscore/input.h

125 lines
4.5 KiB
C
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// 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"
2012-05-26 14:26:10 +02:00
2013-05-13 18:49:17 +02:00
namespace Ms {
2013-10-24 12:09:00 +02:00
class Element;
2012-05-26 14:26:10 +02:00
class Slur;
class ChordRest;
class Drumset;
class Segment;
2013-10-24 12:09:00 +02:00
class Score;
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// NoteEntryMethod
//---------------------------------------------------------
enum class NoteEntryMethod : char {
STEPTIME, REPITCH, RHYTHM, REALTIME_AUTO, REALTIME_MANUAL
};
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// InputState
//---------------------------------------------------------
class InputState {
2013-10-24 12:09:00 +02:00
Score* _score;
2014-06-19 11:34:15 +02:00
TDuration _duration { TDuration::DurationType::V_INVALID }; // currently duration
int _drumNote { -1 };
int _track { 0 };
int _prevTrack { 0 }; // used for navigation
2014-06-19 11:34:15 +02:00
Segment* _lastSegment { 0 };
Segment* _segment { 0 }; // current segment
int _string { VISUAL_STRING_NONE }; // visual string selected for input (TAB staves only)
bool _rest { false }; // rest mode
NoteType _noteType { NoteType::NORMAL };
Beam::Mode _beamMode { Beam::Mode::AUTO };
2014-06-19 11:34:15 +02:00
bool _noteEntryMode { false };
NoteEntryMethod _noteEntryMethod { NoteEntryMethod::STEPTIME };
2014-06-19 11:34:15 +02:00
Slur* _slur { 0 };
bool _insertMode { false };
2013-10-24 12:09:00 +02:00
Segment* nextInputPos() const;
2012-05-26 14:26:10 +02:00
public:
2013-10-24 12:09:00 +02:00
InputState(Score* s) : _score(s) {}
2012-05-26 14:26:10 +02:00
ChordRest* cr() const;
int tick() const;
2013-10-24 12:09:00 +02:00
2012-05-26 14:26:10 +02:00
void setDuration(const TDuration& d) { _duration = d; }
TDuration duration() const { return _duration; }
void setDots(int n) { _duration.setDots(n); }
2013-10-24 12:09:00 +02:00
int ticks() const { return _duration.ticks(); }
2012-05-26 14:26:10 +02:00
Segment* segment() const { return _segment; }
2013-10-31 08:12:53 +01:00
void setSegment(Segment* s);
2012-05-26 14:26:10 +02:00
2013-10-24 12:09:00 +02:00
Segment* lastSegment() const { return _lastSegment; }
void setLastSegment(Segment* s) { _lastSegment = s; }
const Drumset* drumset() const;
2012-05-26 14:26:10 +02:00
int drumNote() const { return _drumNote; }
void setDrumNote(int v) { _drumNote = v; }
2014-08-11 15:25:55 +02:00
int voice() const { return _track == -1 ? 0 : (_track % VOICES); }
2012-05-26 14:26:10 +02:00
int track() const { return _track; }
void setTrack(int v) { _prevTrack = _track; _track = v; }
int prevTrack() const { return _prevTrack; }
2012-05-26 14:26:10 +02:00
int string() const { return _string; }
void setString(int val) { _string = val; }
StaffGroup staffGroup() const;
2013-10-24 12:09:00 +02:00
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; }
2013-10-24 12:09:00 +02:00
bool noteEntryMode() const { return _noteEntryMode; }
void setNoteEntryMode(bool v) { _noteEntryMode = v; }
NoteEntryMethod noteEntryMethod() const { return _noteEntryMethod; }
void setNoteEntryMethod(NoteEntryMethod m) { _noteEntryMethod = m; }
bool usingNoteEntryMethod(NoteEntryMethod m) const { return m == noteEntryMethod(); }
2013-10-24 12:09:00 +02:00
Slur* slur() const { return _slur; }
void setSlur(Slur* s) { _slur = s; }
bool insertMode() const { return _insertMode; }
void setInsertMode(bool val) { _insertMode = val; }
2013-10-24 12:09:00 +02:00
void update(Element* e);
void moveInputPos(Element* e);
void moveToNextInputPos();
bool endOfScore() const;
2012-05-26 14:26:10 +02:00
};
2013-05-13 18:49:17 +02:00
} // namespace Ms
2012-05-26 14:26:10 +02:00
#endif