MuseScore/libmscore/stem.h

86 lines
3 KiB
C
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2010-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 __STEM_H__
#define __STEM_H__
#include "element.h"
2013-05-13 18:49:17 +02:00
namespace Ms {
class Chord;
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ Stem
/// Graphic representation of a note stem.
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class Stem final : public Element {
2016-12-28 16:23:10 +01:00
QLineF line; // p1 is attached to notehead
2016-12-23 12:05:18 +01:00
qreal _lineWidth;
2018-05-08 10:51:24 +02:00
qreal _userLen;
qreal _len { 0.0 }; // always positive
2012-05-26 14:26:10 +02:00
public:
Stem(Score* = 0);
2014-06-27 13:41:49 +02:00
Stem &operator=(const Stem&) = delete;
2012-05-26 14:26:10 +02:00
2018-05-08 10:51:24 +02:00
virtual Stem* clone() const override { return new Stem(*this); }
virtual ElementType type() const override { return ElementType::STEM; }
virtual void draw(QPainter*) const override;
virtual bool isEditable() const override { return true; }
virtual void layout() override;
virtual void spatiumChanged(qreal /*oldValue*/, qreal /*newValue*/) override;
2012-05-26 14:26:10 +02:00
2017-03-31 13:03:15 +02:00
virtual void startEdit(EditData&) override;
virtual void editDrag(EditData&) override;
virtual void write(XmlWriter& xml) const override;
virtual void read(XmlReader& e) override;
2018-05-08 10:51:24 +02:00
virtual bool readProperties(XmlReader&) override;
2017-03-31 13:03:15 +02:00
virtual void reset() override;
virtual bool acceptDrop(EditData&) const override;
2018-05-08 10:51:24 +02:00
virtual Element* drop(EditData&) override;
2012-05-26 14:26:10 +02:00
2018-05-07 19:05:34 +02:00
virtual QVariant getProperty(Pid propertyId) const override;
virtual bool setProperty(Pid propertyId, const QVariant&) override;
virtual QVariant propertyDefault(Pid id) const override;
2012-05-26 14:26:10 +02:00
2018-09-18 11:34:11 +02:00
virtual int vStaffIdx() const override;
2018-05-08 10:51:24 +02:00
Chord* chord() const { return toChord(parent()); }
2012-05-26 14:26:10 +02:00
bool up() const;
qreal userLen() const { return _userLen; }
void setUserLen(qreal l) { _userLen = l; }
2016-12-23 12:05:18 +01:00
qreal lineWidth() const { return _lineWidth; }
2018-05-07 19:05:34 +02:00
void setLineWidth(qreal w) { _lineWidth = w; }
2013-01-02 09:29:17 +01:00
2012-05-26 14:26:10 +02:00
void setLen(qreal l);
qreal len() const { return _len; }
2018-05-08 10:51:24 +02:00
QPointF hookPos() const;
2012-05-26 14:26:10 +02:00
qreal stemLen() const;
QPointF p2() const { return line.p2(); }
EditBehavior normalModeEditBehavior() const override { return EditBehavior::Edit; }
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;
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