MuseScore/libmscore/bracket.h
J. Edward Sanchez f363220a1b Fix #297426: The playback cursor is not repositioned when selecting items other than notes, rests or measures
Improved the functionality of the playhead (a.k.a. the playback cursor) so that whenever the user selects an element, the playhead is automatically repositioned to the element's time position. Previously, this worked only for noteheads and rests, but it now works for note stems, beams, augmentation dots, accidentals, ties, slurs, articulations, time signatures, key signatures, clefs, tempo changes, dynamics, lines, barlines, breaks, spacers, measure numbers, text, and so on.

Special cases handled:

* Barlines. The playhead is moved to the start of the measure to the right of the barline, unless it's the last barline in either the entire score or the system, in which case the playhead is moved to the start of the measure to the left of the barline.

* Brackets always have a time position of zero, so the playhead is moved to the start of the first measure in the system that the bracket belongs to.

* Instrument names always have a time position of zero, so the playhead is moved to the start of the first measure in the system that the instrument name belongs to.
2020-04-14 05:15:05 -07:00

114 lines
3.7 KiB
C++

//=============================================================================
// 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 __BRACKET_H__
#define __BRACKET_H__
#include "element.h"
#include "bracketItem.h"
namespace Ms {
class MuseScoreView;
class System;
enum class BracketType : signed char;
//---------------------------------------------------------
// @@ Bracket
//---------------------------------------------------------
class Bracket final : public Element {
BracketItem* _bi;
qreal ay1;
qreal h2;
int _firstStaff;
int _lastStaff;
QPainterPath path;
SymId _braceSymbol;
Shape _shape;
// horizontal scaling factor for brace symbol. Cannot be equal to magY or depend on h
// because layout needs width of brace before knowing height of system...
qreal _magx;
Measure* _measure = nullptr;
public:
Bracket(Score*);
~Bracket();
Bracket* clone() const override { return new Bracket(*this); }
ElementType type() const override { return ElementType::BRACKET; }
void setBracketItem(BracketItem* i) { _bi = i; }
BracketItem* bracketItem() const { return _bi; }
BracketType bracketType() const { return _bi->bracketType(); }
static const char* bracketTypeName(BracketType type);
int firstStaff() const { return _firstStaff; }
int lastStaff() const { return _lastStaff; }
void setStaffSpan(int a, int b);
SymId braceSymbol() const { return _braceSymbol; }
int column() const { return _bi->column(); }
int span() const { return _bi->bracketSpan(); }
qreal magx() const { return _magx; }
System* system() const { return (System*)parent(); }
Measure* measure() const { return _measure; }
void setMeasure(Measure* measure) { _measure = measure; }
Fraction playTick() const override;
void setHeight(qreal) override;
qreal width() const override;
Shape shape() const override { return _shape; }
void draw(QPainter*) const override;
void layout() override;
void write(XmlWriter& xml) const override;
void read(XmlReader&) override;
bool isEditable() const override { return true; }
void startEdit(EditData&) override;
bool edit(EditData&) override;
void endEdit(EditData&) override;
void editDrag(EditData&) override;
void endEditDrag(EditData&) override;
bool acceptDrop(EditData&) const override;
Element* drop(EditData&) override;
QVariant getProperty(Pid propertyId) const override;
bool setProperty(Pid propertyId, const QVariant&) override;
QVariant propertyDefault(Pid) const override;
void undoChangeProperty(Pid id, const QVariant& v, PropertyFlags ps) override;
using ScoreElement::undoChangeProperty;
int gripsCount() const override { return 1; }
Grip initialEditModeGrip() const override { return Grip::START; }
Grip defaultGrip() const override { return Grip::START; }
std::vector<QPointF> gripsPositions(const EditData&) const override;
void setSelected(bool f) override;
};
} // namespace Ms
#endif