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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
//=============================================================================
// 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 __SELECT_H__
#define __SELECT_H__
namespace Ms {
class Score;
class Page;
class System;
class ChordRest;
class Element;
class Segment;
class Note;
class Measure;
class Chord;
//---------------------------------------------------------
// ElementPattern
//---------------------------------------------------------
struct ElementPattern {
QList<Element*> el;
int type;
int subtype;
int staffStart;
int staffEnd; // exclusive
int voice;
const System* system;
bool subtypeValid;
};
//---------------------------------------------------------
// SelState
//---------------------------------------------------------
enum class SelState : char {
NONE, // nothing is selected
LIST, // disjoint selection
RANGE, // adjacent selection, a range in one or more staves
// is selected
};
enum class SelectionFilterType {
NONE = 0,
FIRST_VOICE = 1 << 0,
SECOND_VOICE = 1 << 1,
THIRD_VOICE = 1 << 2,
FOURTH_VOICE = 1 << 3,
DYNAMIC = 1 << 4,
FINGERING = 1 << 5,
LYRICS = 1 << 6,
CHORD_SYMBOL = 1 << 7,
OTHER_TEXT = 1 << 8,
ARTICULATION = 1 << 9,
SLUR = 1 << 10,
FIGURED_BASS = 1 << 11,
OTTAVA = 1 << 12,
PEDAL_LINE = 1 << 13,
OTHER_LINE = 1 << 14,
ARPEGGIO = 1 << 15,
GLISSANDO = 1 << 16,
FRET_DIAGRAM = 1 << 17,
BREATH = 1 << 18,
TREMOLO = 1 << 19,
GRACE_NOTE = 1 << 20,
ALL = -1
};
class SelectionFilter {
Score* _score;
int _filtered;
public:
SelectionFilter() { _score = 0; _filtered = (int)SelectionFilterType::ALL;}
SelectionFilter(Score* score) { _score = score; _filtered = (int)SelectionFilterType::ALL;}
int& filtered() { return _filtered; }
void setFiltered(SelectionFilterType type, bool set);
bool isFiltered(SelectionFilterType type) const { return _filtered & (int)type; }
bool canSelect(const Element*) const;
bool canSelectVoice(int track) const;
};
//-------------------------------------------------------------------
// Selection
// For SelState::LIST state only visible elements can be selected
// (no Chord element etc.).
//-------------------------------------------------------------------
class Selection {
Score* _score;
SelState _state;
QList<Element*> _el; // valid in mode SelState::LIST
int _staffStart; // valid if selState is SelState::RANGE
int _staffEnd;
Segment* _startSegment;
Segment* _endSegment; // next segment after selection
Segment* _activeSegment;
int _activeTrack;
QByteArray staffMimeData() const;
QByteArray symbolListMimeData() const;
SelectionFilter selectionFilter() const;
bool canSelect(Element* e) const { return selectionFilter().canSelect(e); }
bool canSelectVoice(int track) const { return selectionFilter().canSelectVoice(track); }
void appendFiltered(Element* e);
void appendChord(Chord* chord);
public:
Selection() { _score = 0; _state = SelState::NONE; }
Selection(Score*);
Score* score() const { return _score; }
SelState state() const { return _state; }
bool isNone() const { return _state == SelState::NONE; }
bool isRange() const { return _state == SelState::RANGE; }
bool isList() const { return _state == SelState::LIST; }
void setState(SelState s);
const QList<Element*>& elements() const { return _el; }
QList<Note*> noteList(int track = -1) const;
const QList<Element*> uniqueElements() const;
QList<Note*> uniqueNotes(int track = -1) const;
bool isSingle() const { return (_state == SelState::LIST) && (_el.size() == 1); }
void add(Element*);
void deselectAll();
void remove(Element*);
void clear();
Element* element() const;
ChordRest* cr() const;
Segment* firstChordRestSegment() const;
ChordRest* firstChordRest(int track = -1) const;
ChordRest* lastChordRest(int track = -1) const;
Measure* findMeasure() const;
void update();
void updateState();
void dump();
QString mimeType() const;
QByteArray mimeData() const;
Segment* startSegment() const { return _startSegment; }
Segment* endSegment() const { return _endSegment; }
void setStartSegment(Segment* s) { _startSegment = s; }
void setEndSegment(Segment* s) { _endSegment = s; }
void setRange(Segment* startSegment, Segment* endSegment, int staffStart, int staffEnd);
Segment* activeSegment() const { return _activeSegment; }
void setActiveSegment(Segment* s) { _activeSegment = s; }
ChordRest* activeCR() const;
bool isStartActive() const;
bool isEndActive() const;
int tickStart() const;
int tickEnd() const;
int staffStart() const { return _staffStart; }
int staffEnd() const { return _staffEnd; }
int activeTrack() const { return _activeTrack; }
void setStaffStart(int v) { _staffStart = v; }
void setStaffEnd(int v) { _staffEnd = v; }
void setActiveTrack(int v) { _activeTrack = v; }
bool canCopy() const;
void updateSelectedElements();
bool measureRange(Measure** m1, Measure** m2) const;
void extendRangeSelection(ChordRest* cr);
void extendRangeSelection(Segment* seg, Segment* segAfter, int staffIdx, int tick, int etick);
};
} // namespace Ms
#endif
|