MuseScore/src/engraving/libmscore/arpeggio.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

118 lines
3.8 KiB
C
Raw Normal View History

/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore BVBA and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2012-05-26 14:26:10 +02:00
#ifndef __ARPEGGIO_H__
#define __ARPEGGIO_H__
2020-12-05 16:59:48 +01:00
#include <QApplication>
2012-05-26 14:26:10 +02:00
#include "element.h"
2013-05-13 18:49:17 +02:00
namespace Ms {
class Chord;
enum class ArpeggioType : char {
2013-02-27 11:23:30 +01:00
NORMAL, UP, DOWN, BRACKET, UP_STRAIGHT, DOWN_STRAIGHT
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ Arpeggio
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class Arpeggio final : public Element
{
ArpeggioType _arpeggioType;
qreal _userLen1;
qreal _userLen2;
2012-05-26 14:26:10 +02:00
qreal _height;
int _span; // spanning staves
2016-01-04 14:48:58 +01:00
std::vector<SymId> symbols;
2015-07-06 18:16:52 +02:00
bool _playArpeggio;
2020-05-26 15:54:26 +02:00
qreal _stretch;
2020-05-26 15:54:26 +02:00
bool _hidden = false; // set in layout, will skip draw if true
2020-05-26 15:54:26 +02:00
2013-11-19 12:12:07 +01:00
void symbolLine(SymId start, SymId fill);
void symbolLine2(SymId end, SymId fill);
2020-05-26 15:54:26 +02:00
2020-03-24 14:49:16 +01:00
void spatiumChanged(qreal /*oldValue*/, qreal /*newValue*/) override;
2021-06-07 19:25:41 +02:00
QVector<mu::LineF> dragAnchorLines() const override;
QVector<mu::LineF> gripAnchorLines(Grip) const override;
2020-03-24 14:49:16 +01:00
void startEdit(EditData&) override;
2020-05-26 15:54:26 +02:00
2020-04-21 15:47:00 +02:00
static const std::array<const char*, 6> arpeggioTypeNames;
2020-05-26 15:54:26 +02:00
2012-05-26 14:26:10 +02:00
public:
Arpeggio(Score* s);
2020-05-26 15:54:26 +02:00
2020-03-24 14:49:16 +01:00
Arpeggio* clone() const override { return new Arpeggio(*this); }
ElementType type() const override { return ElementType::ARPEGGIO; }
2020-05-26 15:54:26 +02:00
ArpeggioType arpeggioType() const { return _arpeggioType; }
void setArpeggioType(ArpeggioType v) { _arpeggioType = v; }
2020-04-21 15:47:00 +02:00
QString arpeggioTypeName() { return qApp->translate("Palette", arpeggioTypeNames[int(_arpeggioType)]); }
2020-05-26 15:54:26 +02:00
Chord* chord() const { return (Chord*)parent(); }
2020-05-26 15:54:26 +02:00
2020-03-24 14:49:16 +01:00
bool acceptDrop(EditData&) const override;
Element* drop(EditData&) override;
void layout() override;
2021-03-09 13:27:51 +01:00
void draw(mu::draw::Painter* painter) const override;
2020-03-24 14:49:16 +01:00
bool isEditable() const override { return true; }
void editDrag(EditData&) override;
bool edit(EditData&) override;
2020-05-26 15:54:26 +02:00
2020-03-24 14:49:16 +01:00
void read(XmlReader& e) override;
void write(XmlWriter& xml) const override;
void reset() override;
2020-05-26 15:54:26 +02:00
2012-05-26 14:26:10 +02:00
int span() const { return _span; }
void setSpan(int val) { _span = val; }
void setHeight(qreal) override;
2020-05-26 15:54:26 +02:00
qreal userLen1() const { return _userLen1; }
qreal userLen2() const { return _userLen2; }
void setUserLen1(qreal v) { _userLen1 = v; }
void setUserLen2(qreal v) { _userLen2 = v; }
2020-05-26 15:54:26 +02:00
2015-07-06 18:16:52 +02:00
bool playArpeggio() { return _playArpeggio; }
void setPlayArpeggio(bool p) { _playArpeggio = p; }
2020-05-26 15:54:26 +02:00
qreal Stretch() const { return _stretch; }
void setStretch(qreal val) { _stretch = val; }
2020-05-26 15:54:26 +02:00
2020-03-24 14:49:16 +01:00
QVariant getProperty(Pid propertyId) const override;
bool setProperty(Pid propertyId, const QVariant&) override;
QVariant propertyDefault(Pid propertyId) const override;
Pid propertyId(const QStringRef& xmlName) const override;
2020-05-26 15:54:26 +02:00
// TODO: add a grip for moving the entire arpeggio
EditBehavior normalModeEditBehavior() const override { return EditBehavior::Edit; }
int gripsCount() const override { return 2; }
Grip initialEditModeGrip() const override { return Grip::END; }
Grip defaultGrip() const override { return Grip::START; }
2021-06-07 19:25:41 +02:00
std::vector<mu::PointF> gripsPositions(const EditData& = EditData()) const override;
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