MuseScore/libmscore/stem.h

77 lines
2.5 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
qreal _userLen { 0.0 };
qreal _len { 0.0 }; // always positive
2016-12-23 12:05:18 +01:00
qreal _lineWidth;
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
virtual Stem* clone() const { return new Stem(*this); }
virtual ElementType type() const { return ElementType::STEM; }
2012-05-26 14:26:10 +02:00
virtual void draw(QPainter*) const;
virtual bool isEditable() const { return true; }
2012-05-26 14:26:10 +02:00
virtual void layout();
virtual void spatiumChanged(qreal /*oldValue*/, qreal /*newValue*/);
2017-03-31 13:03:15 +02:00
virtual void startEdit(EditData&) override;
virtual void editDrag(EditData&) override;
virtual void updateGrips(EditData&) const override;
virtual void write(XmlWriter& xml) const override;
virtual void read(XmlReader& e) override;
virtual void reset() override;
virtual bool acceptDrop(EditData&) const override;
virtual Element* drop(EditData&);
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
Chord* chord() const { return (Chord*)parent(); }
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
2013-03-13 15:24:03 +01:00
QPointF hookPos() const;
2012-05-26 14:26:10 +02:00
void setLen(qreal l);
qreal len() const { return _len; }
qreal stemLen() const;
QPointF p2() const { return line.p2(); }
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