2012-05-26 14:26:10 +02:00
|
|
|
//=============================================================================
|
|
|
|
// MuseScore
|
|
|
|
// Music Composition & Notation
|
|
|
|
//
|
2013-08-01 22:24:36 +02:00
|
|
|
// Copyright (C) 2002-2013 Werner Schweer
|
2012-05-26 14:26:10 +02:00
|
|
|
//
|
|
|
|
// 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 __ELEMENT_H__
|
|
|
|
#define __ELEMENT_H__
|
|
|
|
|
|
|
|
#include "mscore.h"
|
2013-05-13 18:49:17 +02:00
|
|
|
#include "spatium.h"
|
2014-04-09 16:09:21 +02:00
|
|
|
#include "fraction.h"
|
2015-02-04 22:12:13 +01:00
|
|
|
#include "scoreElement.h"
|
2016-01-04 14:48:58 +01:00
|
|
|
#include "shape.h"
|
2013-05-13 18:49:17 +02:00
|
|
|
|
|
|
|
class QPainter;
|
|
|
|
|
|
|
|
namespace Ms {
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
\file
|
|
|
|
Definition of classes Element, ElementList, StaffLines.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
class Xml;
|
|
|
|
class Measure;
|
|
|
|
class Staff;
|
2015-03-05 16:46:37 +01:00
|
|
|
class Part;
|
2012-05-26 14:26:10 +02:00
|
|
|
class Score;
|
|
|
|
class Sym;
|
|
|
|
class MuseScoreView;
|
|
|
|
class Segment;
|
|
|
|
class TextStyle;
|
|
|
|
class Element;
|
2016-02-04 11:27:47 +01:00
|
|
|
class BarLine;
|
|
|
|
class Articulation;
|
2016-02-04 17:06:32 +01:00
|
|
|
class Marker;
|
|
|
|
class Clef;
|
|
|
|
class KeySig;
|
|
|
|
class TimeSig;
|
2016-02-06 11:41:16 +01:00
|
|
|
class TempoText;
|
|
|
|
class Breath;
|
|
|
|
class Box;
|
|
|
|
class HBox;
|
|
|
|
class VBox;
|
|
|
|
class TBox;
|
|
|
|
class FBox;
|
|
|
|
class ChordRest;
|
|
|
|
class Slur;
|
|
|
|
class Tie;
|
|
|
|
class Glissando;
|
|
|
|
class SystemDivider;
|
|
|
|
class RehearsalMark;
|
|
|
|
class Harmony;
|
|
|
|
class Volta;
|
|
|
|
class Jump;
|
|
|
|
class StaffText;
|
|
|
|
class Ottava;
|
2016-02-06 22:03:43 +01:00
|
|
|
class Note;
|
2016-02-09 13:51:19 +01:00
|
|
|
class Chord;
|
|
|
|
class Rest;
|
2016-02-09 09:20:54 +01:00
|
|
|
class LayoutBreak;
|
2016-02-16 21:21:28 +01:00
|
|
|
class Tremolo;
|
|
|
|
class System;
|
2016-03-02 13:20:19 +01:00
|
|
|
class Lyrics;
|
2016-03-19 08:18:54 +01:00
|
|
|
class Stem;
|
2016-04-20 10:45:51 +02:00
|
|
|
class SlurSegment;
|
|
|
|
class Beam;
|
2016-04-27 16:33:30 +02:00
|
|
|
class Hook;
|
|
|
|
class StemSlash;
|
2016-05-02 13:41:41 +02:00
|
|
|
class Spacer;
|
2016-02-04 11:27:47 +01:00
|
|
|
|
2014-06-24 17:16:22 +02:00
|
|
|
enum class SymId;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2015-01-19 12:37:17 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// Grip
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2015-07-08 14:52:30 +02:00
|
|
|
enum class Grip : signed char {
|
2015-01-19 12:37:17 +01:00
|
|
|
NO_GRIP = -1,
|
|
|
|
START = 0, END = 1, // arpeggio etc.
|
|
|
|
MIDDLE = 2, APERTURE = 3, // Line
|
|
|
|
/*START, END , */
|
|
|
|
BEZIER1 = 2, SHOULDER = 3, BEZIER2 = 4, DRAG = 5, // Slur
|
|
|
|
GRIPS = 6 // number of grips for slur
|
|
|
|
};
|
2014-07-10 14:13:37 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// ElementFlag
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2014-06-02 13:08:33 +02:00
|
|
|
enum class ElementFlag : char {
|
2014-05-22 10:10:58 +02:00
|
|
|
DROP_TARGET = 0x2,
|
|
|
|
SELECTABLE = 0x4,
|
|
|
|
MOVABLE = 0x8,
|
|
|
|
SEGMENT = 0x10,
|
|
|
|
HAS_TAG = 0x20,
|
|
|
|
ON_STAFF = 0x40 // parent is Segment() type
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef QFlags<ElementFlag> ElementFlags;
|
2014-05-16 13:48:03 +02:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(ElementFlags);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// DropData
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
struct DropData {
|
|
|
|
MuseScoreView* view;
|
|
|
|
QPointF pos;
|
|
|
|
QPointF dragOffset;
|
|
|
|
Element* element;
|
|
|
|
Qt::KeyboardModifiers modifiers;
|
|
|
|
Fraction duration;
|
|
|
|
|
2016-02-04 11:27:47 +01:00
|
|
|
bool control() const { return modifiers & Qt::ControlModifier; }
|
2012-05-26 14:26:10 +02:00
|
|
|
DropData();
|
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// EditData
|
|
|
|
// used in editDrag
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
struct EditData {
|
|
|
|
MuseScoreView* view;
|
2015-01-19 12:37:17 +01:00
|
|
|
Grip curGrip;
|
2013-10-22 12:05:31 +02:00
|
|
|
QPointF startMove;
|
2012-05-26 14:26:10 +02:00
|
|
|
QPointF pos;
|
2014-05-05 12:25:17 +02:00
|
|
|
QPointF lastPos;
|
|
|
|
QPointF delta;
|
2012-05-26 14:26:10 +02:00
|
|
|
bool hRaster;
|
|
|
|
bool vRaster;
|
|
|
|
};
|
|
|
|
|
2015-01-19 12:37:17 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// ElementName
|
|
|
|
//---------------------------------------------------------
|
2013-11-03 18:38:53 +01:00
|
|
|
|
|
|
|
struct ElementName {
|
|
|
|
const char* name;
|
|
|
|
const char* userName;
|
|
|
|
ElementName(const char* _name, const char* _userName) : name(_name), userName(_userName) {}
|
2014-06-04 08:30:59 +02:00
|
|
|
};
|
|
|
|
|
2012-07-11 21:29:42 +02:00
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @@ Element
|
2014-05-16 13:44:32 +02:00
|
|
|
/// \brief Base class of score layout elements
|
2012-07-16 19:59:32 +02:00
|
|
|
///
|
2014-05-16 13:44:32 +02:00
|
|
|
/// The Element class is the virtual base class of all
|
|
|
|
/// score layout elements.
|
2012-07-16 19:59:32 +02:00
|
|
|
//
|
2015-04-24 00:55:46 +02:00
|
|
|
// @P bbox rect bounding box relative to pos and userOff (read only)
|
|
|
|
// @P color color element drawing color
|
|
|
|
// @P generated bool true if the element has been generated by layout
|
|
|
|
// @P pagePos point position in page coordinated (read only)
|
|
|
|
// @P parent Element the parent element in drawing hierarchy
|
|
|
|
// @P placement enum (Element.ABOVE, Element.BELOW)
|
|
|
|
// @P pos point position relative to parent
|
|
|
|
// @P selected bool true if the element is currently selected
|
|
|
|
// @P track int the track the elment belongs to
|
|
|
|
// @P type enum (Element.ACCIDENTAL, .ACCIDENTAL, .AMBITUS, .ARPEGGIO, .BAGPIPE_EMBELLISHMENT, .BAR_LINE, .BEAM, .BEND, .BRACKET, .BREATH, .CHORD, .CHORDLINE, .CLEF, .COMPOUND, .DYNAMIC, .ELEMENT, .ELEMENT_LIST, .FBOX, .FIGURED_BASS, .FINGERING, .FRET_DIAGRAM, .FSYMBOL, .GLISSANDO, .GLISSANDO_SEGMENT, .HAIRPIN, .HAIRPIN_SEGMENT, .HARMONY, .HBOX, .HOOK, .ICON, .IMAGE, .INSTRUMENT_CHANGE, .INSTRUMENT_NAME, .JUMP, .KEYSIG, .LASSO, .LAYOUT_BREAK, .LEDGER_LINE, .LINE, .LYRICS, .LYRICSLINE, .LYRICSLINE_SEGMENT, .MARKER, .MEASURE, .MEASURE_LIST, .NOTE, .NOTEDOT, .NOTEHEAD, .NOTELINE, .OSSIA, .OTTAVA, .OTTAVA_SEGMENT, .PAGE, .PEDAL, .PEDAL_SEGMENT, .REHEARSAL_MARK, .REPEAT_MEASURE, .REST, .SEGMENT, .SELECTION, .SHADOW_NOTE, .SLUR, .SLUR_SEGMENT, .SPACER, .STAFF_LINES, .STAFF_LIST, .STAFF_STATE, .STAFF_TEXT, .STEM, .STEM_SLASH, .SYMBOL, .SYSTEM, .TAB_DURATION_SYMBOL, .TBOX, .TEMPO_TEXT, .TEXT, .TEXTLINE, .TEXTLINE_SEGMENT, .TIE, .TIMESIG, .TREMOLO, .TREMOLOBAR, .TRILL, .TRILL_SEGMENT, .TUPLET, .VBOX, .VOLTA, .VOLTA_SEGMENT) (read only)
|
|
|
|
// @P userOff point manual offset to position determined by layout
|
2014-05-16 13:44:32 +02:00
|
|
|
// @P visible bool
|
2012-07-11 21:29:42 +02:00
|
|
|
//-------------------------------------------------------------------
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2015-02-04 22:12:13 +01:00
|
|
|
class Element : public QObject, public ScoreElement {
|
2012-05-28 11:29:21 +02:00
|
|
|
Q_OBJECT
|
2014-06-24 18:36:02 +02:00
|
|
|
Q_ENUMS(Type)
|
2012-10-30 09:06:24 +01:00
|
|
|
Q_ENUMS(Placement)
|
2012-09-13 18:01:34 +02:00
|
|
|
|
2014-11-02 22:44:35 +01:00
|
|
|
Q_PROPERTY(QRectF bbox READ scriptBbox )
|
|
|
|
Q_PROPERTY(QColor color READ color WRITE undoSetColor)
|
|
|
|
Q_PROPERTY(bool generated READ generated WRITE setGenerated)
|
|
|
|
Q_PROPERTY(QPointF pagePos READ scriptPagePos)
|
|
|
|
Q_PROPERTY(Ms::Element* parent READ parent WRITE setParent)
|
|
|
|
Q_PROPERTY(Ms::Element::Placement placement READ placement WRITE undoSetPlacement)
|
|
|
|
Q_PROPERTY(QPointF pos READ scriptPos WRITE scriptSetPos)
|
|
|
|
Q_PROPERTY(bool selected READ selected WRITE setSelected)
|
|
|
|
Q_PROPERTY(qreal spatium READ spatium)
|
|
|
|
Q_PROPERTY(int track READ track WRITE setTrack)
|
|
|
|
Q_PROPERTY(Ms::Element::Type type READ type)
|
|
|
|
Q_PROPERTY(QPointF userOff READ scriptUserOff WRITE scriptSetUserOff)
|
2015-05-01 15:54:56 +02:00
|
|
|
Q_PROPERTY(bool visible READ visible WRITE undoSetVisible)
|
2012-05-28 11:29:21 +02:00
|
|
|
|
2015-03-31 17:34:54 +02:00
|
|
|
Element* _parent { 0 };
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
bool _generated; ///< automatically generated Element
|
2014-06-18 20:57:45 +02:00
|
|
|
|
2014-05-07 18:09:01 +02:00
|
|
|
protected:
|
|
|
|
bool _selected; ///< set if element is selected
|
|
|
|
bool _visible; ///< visibility attribute
|
2014-10-01 15:15:08 +02:00
|
|
|
QColor _color; ///< element color attribute
|
2014-05-07 18:09:01 +02:00
|
|
|
|
2014-06-24 17:27:58 +02:00
|
|
|
public:
|
2014-06-24 18:36:02 +02:00
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// The value of this enum determines the "stacking order"
|
|
|
|
// of elements on the canvas.
|
|
|
|
// Note: keep in sync with array elementNames[] in element.cpp
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
enum class Type : char {
|
|
|
|
INVALID = 0,
|
|
|
|
SYMBOL,
|
|
|
|
TEXT,
|
|
|
|
INSTRUMENT_NAME,
|
|
|
|
SLUR_SEGMENT,
|
|
|
|
STAFF_LINES,
|
|
|
|
BAR_LINE,
|
2015-07-25 08:43:02 +02:00
|
|
|
SYSTEM_DIVIDER,
|
2014-06-24 18:36:02 +02:00
|
|
|
STEM_SLASH,
|
|
|
|
LINE,
|
|
|
|
|
|
|
|
ARPEGGIO,
|
|
|
|
ACCIDENTAL,
|
|
|
|
STEM, // list STEM before NOTE: notes in TAB might 'break' stems
|
|
|
|
NOTE, // and this requires stems to be drawn before notes
|
|
|
|
CLEF, // elements from CLEF to TIMESIG need to be in the order
|
|
|
|
KEYSIG, // in which they appear in a measure
|
|
|
|
AMBITUS,
|
|
|
|
TIMESIG,
|
|
|
|
REST,
|
|
|
|
BREATH,
|
|
|
|
|
|
|
|
REPEAT_MEASURE,
|
|
|
|
IMAGE,
|
|
|
|
TIE,
|
|
|
|
ARTICULATION,
|
|
|
|
CHORDLINE,
|
|
|
|
DYNAMIC,
|
|
|
|
BEAM,
|
|
|
|
HOOK,
|
|
|
|
LYRICS,
|
|
|
|
FIGURED_BASS,
|
|
|
|
|
|
|
|
MARKER,
|
|
|
|
JUMP,
|
|
|
|
FINGERING,
|
|
|
|
TUPLET,
|
|
|
|
TEMPO_TEXT,
|
|
|
|
STAFF_TEXT,
|
|
|
|
REHEARSAL_MARK,
|
|
|
|
INSTRUMENT_CHANGE,
|
|
|
|
HARMONY,
|
|
|
|
FRET_DIAGRAM,
|
|
|
|
BEND,
|
|
|
|
TREMOLOBAR,
|
|
|
|
VOLTA,
|
|
|
|
HAIRPIN_SEGMENT,
|
|
|
|
OTTAVA_SEGMENT,
|
|
|
|
TRILL_SEGMENT,
|
|
|
|
TEXTLINE_SEGMENT,
|
|
|
|
VOLTA_SEGMENT,
|
|
|
|
PEDAL_SEGMENT,
|
Lyrics multi-system melisma and dashes
Implements melisma and dash lines for lyrics spanning several systems.
The melisma and dash line is based on the `SLine` class and its segments on the `LineSegment` class. Both the whole line and its segments are not selectable, marked as generated and not saved in the score file, which is not changed in any way.
For very wide dash segments, several dashes are drawn; the distance between the dashes is not configurable.
Lyrics layout code in `Measure` class and in `layout.cpp` file has been commented out as the lyrics line layout is all contained in the lyrics.cpp file
The line is registered with the `Score` (to have its layout delayed until all elements are positioned) with a mechanism similar to other `Spanner`'s, but in a different container (`_unmanagedSpanner`), as the owning `Lyrics` should decide when create, register, unregister and delete its line.
The line segments are registered with the `System` they belong to (to have them drawn), in the same way as other `Spanner`'s.
There is code for using the dash metrics of the lyrics font, but it is turned off via a conditional directive, as there does not seem to be a reliable way to determine the dash metrics; conventional values (determined by trials and errors and based on my taste!) are used when the conditional directive is off.
2015-01-11 10:11:44 +01:00
|
|
|
LYRICSLINE_SEGMENT,
|
2014-12-13 17:40:39 +01:00
|
|
|
GLISSANDO_SEGMENT,
|
2014-06-24 18:36:02 +02:00
|
|
|
LAYOUT_BREAK,
|
|
|
|
SPACER,
|
|
|
|
STAFF_STATE,
|
|
|
|
LEDGER_LINE,
|
|
|
|
NOTEHEAD,
|
|
|
|
NOTEDOT,
|
|
|
|
TREMOLO,
|
|
|
|
MEASURE,
|
|
|
|
SELECTION,
|
|
|
|
LASSO,
|
|
|
|
SHADOW_NOTE,
|
|
|
|
TAB_DURATION_SYMBOL,
|
|
|
|
FSYMBOL,
|
|
|
|
PAGE,
|
|
|
|
HAIRPIN,
|
|
|
|
OTTAVA,
|
|
|
|
PEDAL,
|
|
|
|
TRILL,
|
|
|
|
TEXTLINE,
|
|
|
|
NOTELINE,
|
Lyrics multi-system melisma and dashes
Implements melisma and dash lines for lyrics spanning several systems.
The melisma and dash line is based on the `SLine` class and its segments on the `LineSegment` class. Both the whole line and its segments are not selectable, marked as generated and not saved in the score file, which is not changed in any way.
For very wide dash segments, several dashes are drawn; the distance between the dashes is not configurable.
Lyrics layout code in `Measure` class and in `layout.cpp` file has been commented out as the lyrics line layout is all contained in the lyrics.cpp file
The line is registered with the `Score` (to have its layout delayed until all elements are positioned) with a mechanism similar to other `Spanner`'s, but in a different container (`_unmanagedSpanner`), as the owning `Lyrics` should decide when create, register, unregister and delete its line.
The line segments are registered with the `System` they belong to (to have them drawn), in the same way as other `Spanner`'s.
There is code for using the dash metrics of the lyrics font, but it is turned off via a conditional directive, as there does not seem to be a reliable way to determine the dash metrics; conventional values (determined by trials and errors and based on my taste!) are used when the conditional directive is off.
2015-01-11 10:11:44 +01:00
|
|
|
LYRICSLINE,
|
2015-02-28 12:15:56 +01:00
|
|
|
GLISSANDO,
|
2015-06-01 13:33:44 +02:00
|
|
|
BRACKET,
|
|
|
|
|
2014-06-24 18:36:02 +02:00
|
|
|
SEGMENT,
|
|
|
|
SYSTEM,
|
|
|
|
COMPOUND,
|
|
|
|
CHORD,
|
|
|
|
SLUR,
|
|
|
|
ELEMENT,
|
|
|
|
ELEMENT_LIST,
|
|
|
|
STAFF_LIST,
|
|
|
|
MEASURE_LIST,
|
|
|
|
HBOX,
|
|
|
|
VBOX,
|
|
|
|
TBOX,
|
|
|
|
FBOX,
|
|
|
|
ICON,
|
|
|
|
OSSIA,
|
|
|
|
BAGPIPE_EMBELLISHMENT,
|
|
|
|
|
|
|
|
MAXTYPE
|
|
|
|
};
|
|
|
|
|
2014-06-24 17:27:58 +02:00
|
|
|
enum class Placement : char {
|
|
|
|
ABOVE, BELOW
|
|
|
|
};
|
|
|
|
|
2014-05-07 18:09:01 +02:00
|
|
|
private:
|
2012-10-31 14:21:13 +01:00
|
|
|
Placement _placement;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
mutable ElementFlags _flags;
|
|
|
|
|
|
|
|
int _track; ///< staffIdx * VOICES + voice
|
|
|
|
qreal _mag; ///< standard magnification (derived value)
|
|
|
|
|
|
|
|
QPointF _pos; ///< Reference position, relative to _parent.
|
|
|
|
QPointF _userOff; ///< offset from normal layout position:
|
|
|
|
///< user dragged object this amount.
|
|
|
|
QPointF _readPos;
|
|
|
|
|
|
|
|
mutable QRectF _bbox; ///< Bounding box relative to _pos + _userOff
|
|
|
|
///< valid after call to layout()
|
|
|
|
uint _tag; ///< tag bitmask
|
2016-02-06 22:03:43 +01:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
protected:
|
|
|
|
QPointF _startDragPosition; ///< used during drag
|
2015-02-04 22:12:13 +01:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
public:
|
|
|
|
Element(Score* s = 0);
|
|
|
|
Element(const Element&);
|
2016-03-30 22:33:04 +02:00
|
|
|
virtual ~Element() {}
|
|
|
|
|
2014-06-27 13:41:49 +02:00
|
|
|
Element &operator=(const Element&) = delete;
|
2015-04-24 00:55:46 +02:00
|
|
|
//@ create a copy of the element
|
2013-07-13 18:41:16 +02:00
|
|
|
Q_INVOKABLE virtual Ms::Element* clone() const = 0;
|
2012-05-26 14:26:10 +02:00
|
|
|
virtual Element* linkedClone();
|
2015-02-12 11:41:39 +01:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
Element* parent() const { return _parent; }
|
|
|
|
void setParent(Element* e) { _parent = e; }
|
2013-04-13 23:53:44 +02:00
|
|
|
Element* findMeasure();
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
qreal spatium() const;
|
|
|
|
|
|
|
|
bool selected() const { return _selected; }
|
|
|
|
virtual void setSelected(bool f) { _selected = f; }
|
|
|
|
|
|
|
|
bool visible() const { return _visible; }
|
|
|
|
virtual void setVisible(bool f) { _visible = f; }
|
2012-10-31 14:21:13 +01:00
|
|
|
|
|
|
|
Placement placement() const { return _placement; }
|
|
|
|
void setPlacement(Placement val) { _placement = val; }
|
|
|
|
void undoSetPlacement(Placement val);
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
bool generated() const { return _generated; }
|
|
|
|
void setGenerated(bool val) { _generated = val; }
|
|
|
|
|
|
|
|
const QPointF& ipos() const { return _pos; }
|
2012-10-04 17:07:38 +02:00
|
|
|
virtual const QPointF pos() const { return _pos + _userOff; }
|
2012-05-26 14:26:10 +02:00
|
|
|
virtual qreal x() const { return _pos.x() + _userOff.x(); }
|
|
|
|
virtual qreal y() const { return _pos.y() + _userOff.y(); }
|
|
|
|
void setPos(qreal x, qreal y) { _pos.rx() = x, _pos.ry() = y; }
|
|
|
|
void setPos(const QPointF& p) { _pos = p; }
|
|
|
|
qreal& rxpos() { return _pos.rx(); }
|
|
|
|
qreal& rypos() { return _pos.ry(); }
|
|
|
|
virtual void move(const QPointF& s) { _pos += s; }
|
|
|
|
|
|
|
|
virtual QPointF pagePos() const; ///< position in page coordinates
|
|
|
|
virtual QPointF canvasPos() const; ///< position in canvas coordinates
|
|
|
|
qreal pageX() const;
|
|
|
|
qreal canvasX() const;
|
|
|
|
|
|
|
|
const QPointF& userOff() const { return _userOff; }
|
2014-03-15 12:32:58 +01:00
|
|
|
virtual void setUserOff(const QPointF& o) { _userOff = o; }
|
2012-05-26 14:26:10 +02:00
|
|
|
void setUserXoffset(qreal v) { _userOff.setX(v); }
|
|
|
|
void setUserYoffset(qreal v) { _userOff.setY(v); }
|
2012-10-27 14:46:35 +02:00
|
|
|
|
|
|
|
qreal& rUserXoffset() { return _userOff.rx(); }
|
|
|
|
qreal& rUserYoffset() { return _userOff.ry(); }
|
|
|
|
|
2012-09-30 18:54:34 +02:00
|
|
|
// function versions for scripts: use coords in spatium units rather than raster
|
|
|
|
// and route pos changes to userOff
|
2014-10-29 13:29:29 +01:00
|
|
|
QRectF scriptBbox() const;
|
2014-11-02 22:44:35 +01:00
|
|
|
virtual QPointF scriptPagePos() const;
|
2012-09-30 18:54:34 +02:00
|
|
|
virtual QPointF scriptPos() const;
|
|
|
|
void scriptSetPos(const QPointF& p);
|
|
|
|
QPointF scriptUserOff() const;
|
|
|
|
void scriptSetUserOff(const QPointF& o);
|
|
|
|
|
2012-06-09 10:50:51 +02:00
|
|
|
bool isNudged() const { return !(_readPos.isNull() && _userOff.isNull()); }
|
2012-05-26 14:26:10 +02:00
|
|
|
const QPointF& readPos() const { return _readPos; }
|
|
|
|
void setReadPos(const QPointF& p) { _readPos = p; }
|
2012-10-02 17:07:28 +02:00
|
|
|
virtual void adjustReadPos();
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2012-07-24 14:20:43 +02:00
|
|
|
virtual const QRectF& bbox() const { return _bbox; }
|
2013-01-02 09:29:17 +01:00
|
|
|
virtual QRectF& bbox() { return _bbox; }
|
2012-05-26 14:26:10 +02:00
|
|
|
virtual qreal height() const { return bbox().height(); }
|
|
|
|
virtual void setHeight(qreal v) { _bbox.setHeight(v); }
|
|
|
|
virtual qreal width() const { return bbox().width(); }
|
|
|
|
virtual void setWidth(qreal v) { _bbox.setWidth(v); }
|
|
|
|
QRectF abbox() const { return bbox().translated(pagePos()); }
|
|
|
|
QRectF pageBoundingRect() const { return bbox().translated(pagePos()); }
|
|
|
|
QRectF canvasBoundingRect() const { return bbox().translated(canvasPos()); }
|
|
|
|
virtual void setbbox(const QRectF& r) const { _bbox = r; }
|
|
|
|
virtual void addbbox(const QRectF& r) const { _bbox |= r; }
|
|
|
|
virtual bool contains(const QPointF& p) const;
|
|
|
|
bool intersects(const QRectF& r) const;
|
2016-01-04 14:48:58 +01:00
|
|
|
virtual QPainterPath outline() const;
|
|
|
|
virtual Shape shape() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
virtual qreal baseLine() const { return -height(); }
|
|
|
|
|
2014-06-24 18:36:02 +02:00
|
|
|
virtual Element::Type type() const = 0;
|
2014-07-16 19:40:15 +02:00
|
|
|
virtual int subtype() const { return -1; } // for select gui
|
2015-02-23 10:10:18 +01:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
virtual void draw(QPainter*) const {}
|
|
|
|
|
2013-07-31 11:05:48 +02:00
|
|
|
virtual void writeProperties(Xml& xml) const;
|
|
|
|
virtual bool readProperties(XmlReader&);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
virtual void write(Xml&) const;
|
2013-01-11 18:10:18 +01:00
|
|
|
virtual void read(XmlReader&);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-10-22 12:05:31 +02:00
|
|
|
virtual QRectF drag(EditData*);
|
2012-05-26 14:26:10 +02:00
|
|
|
virtual void endDrag() {}
|
|
|
|
virtual QLineF dragAnchor() const { return QLineF(); }
|
|
|
|
|
|
|
|
virtual bool isEditable() const { return !_generated; }
|
2013-02-26 15:50:36 +01:00
|
|
|
virtual void startEdit(MuseScoreView*, const QPointF&);
|
2015-01-19 12:37:17 +01:00
|
|
|
virtual bool edit(MuseScoreView*, Grip, int key, Qt::KeyboardModifiers, const QString& s);
|
2012-05-26 14:26:10 +02:00
|
|
|
virtual void editDrag(const EditData&);
|
|
|
|
virtual void endEditDrag() {}
|
|
|
|
virtual void endEdit() {}
|
2015-01-19 12:37:17 +01:00
|
|
|
virtual void updateGrips(Grip*, QVector<QRectF>&) const { }
|
|
|
|
virtual bool nextGrip(Grip*) const;
|
|
|
|
virtual int grips() const { return 0; }
|
|
|
|
virtual bool prevGrip(Grip*) const;
|
|
|
|
virtual QPointF gripAnchor(Grip) const { return QPointF(); }
|
|
|
|
virtual void setGrip(Grip, const QPointF&);
|
|
|
|
virtual QPointF getGrip(Grip) const;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
int track() const { return _track; }
|
|
|
|
virtual void setTrack(int val) { _track = val; }
|
|
|
|
|
2014-05-22 19:49:51 +02:00
|
|
|
virtual int z() const { return int(type()) * 100; } // stacking order
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-01-02 20:13:58 +01:00
|
|
|
int staffIdx() const { return _track >> 2; }
|
2016-03-18 14:35:15 +01:00
|
|
|
virtual int vStaffIdx() const { return staffIdx(); }
|
2013-01-02 20:13:58 +01:00
|
|
|
int voice() const { return _track & 3; }
|
2015-04-25 11:43:09 +02:00
|
|
|
void setVoice(int v) { _track = (_track / VOICES) * VOICES + v; }
|
2012-05-26 14:26:10 +02:00
|
|
|
Staff* staff() const;
|
2015-03-05 16:46:37 +01:00
|
|
|
Part* part() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
virtual void add(Element*);
|
|
|
|
virtual void remove(Element*);
|
|
|
|
virtual void change(Element* o, Element* n);
|
|
|
|
|
|
|
|
virtual void layout() {}
|
|
|
|
virtual void spatiumChanged(qreal /*oldValue*/, qreal /*newValue*/);
|
2015-02-20 11:56:13 +01:00
|
|
|
virtual void localSpatiumChanged(qreal /*oldValue*/, qreal /*newValue*/);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
// debug functions
|
|
|
|
virtual void dump() const;
|
2016-03-18 09:29:16 +01:00
|
|
|
virtual const char* name() const override;
|
2015-04-03 18:23:51 +02:00
|
|
|
virtual Q_INVOKABLE QString subtypeName() const;
|
2015-04-24 00:55:46 +02:00
|
|
|
//@ Returns the human-readable name of the element type
|
2015-04-03 18:23:51 +02:00
|
|
|
virtual Q_INVOKABLE QString userName() const;
|
2015-04-24 00:55:46 +02:00
|
|
|
//@ Returns the name of the element type
|
2015-04-03 18:23:51 +02:00
|
|
|
virtual Q_INVOKABLE QString _name() const { return QString(name()); }
|
2012-05-26 14:26:10 +02:00
|
|
|
void dumpQPointF(const char*) const;
|
|
|
|
|
2015-03-20 09:58:41 +01:00
|
|
|
virtual QColor color() const { return _color; }
|
2012-05-26 14:26:10 +02:00
|
|
|
QColor curColor() const;
|
2013-11-21 12:37:19 +01:00
|
|
|
QColor curColor(const Element* proxy) const;
|
2014-10-01 15:15:08 +02:00
|
|
|
virtual void setColor(const QColor& c) { _color = c; }
|
2012-06-08 19:06:52 +02:00
|
|
|
void undoSetColor(const QColor& c);
|
2015-05-01 15:54:56 +02:00
|
|
|
void undoSetVisible(bool v);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-06-24 18:36:02 +02:00
|
|
|
static Element::Type readType(XmlReader& node, QPointF*, Fraction*);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
QByteArray mimeData(const QPointF&) const;
|
|
|
|
/**
|
|
|
|
Return true if this element accepts a drop at canvas relative \a pos
|
|
|
|
of given element \a type and \a subtype.
|
|
|
|
|
|
|
|
Reimplemented by elements that accept drops. Used to change cursor shape while
|
|
|
|
dragging to indicate drop targets.
|
|
|
|
*/
|
2014-08-13 21:01:21 +02:00
|
|
|
virtual bool acceptDrop(const DropData&) const { return false; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Handle a dropped element at canvas relative \a pos of given element
|
|
|
|
\a type and \a subtype. Returns dropped element if any.
|
|
|
|
The ownership of element in DropData is transfered to the called
|
|
|
|
element (if not used, element has to be deleted).
|
|
|
|
The returned element will be selected if not in note edit mode.
|
|
|
|
|
|
|
|
Reimplemented by elements that accept drops.
|
|
|
|
*/
|
|
|
|
virtual Element* drop(const DropData&) { return 0;}
|
|
|
|
|
|
|
|
/**
|
|
|
|
delivers mouseEvent to element in edit mode
|
|
|
|
returns true if mouse event is accepted by element
|
|
|
|
*/
|
|
|
|
virtual bool mousePress(const QPointF&, QMouseEvent*) { return false; }
|
|
|
|
|
2014-01-03 12:09:23 +01:00
|
|
|
mutable bool itemDiscovered; ///< helper flag for bsp
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true);
|
|
|
|
|
2016-02-09 13:51:19 +01:00
|
|
|
virtual void reset(); // reset all properties & position to default
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-08-14 16:52:58 +02:00
|
|
|
virtual qreal mag() const { return _mag; }
|
2013-08-30 16:03:46 +02:00
|
|
|
void setMag(qreal val) { _mag = val; }
|
2014-08-14 16:52:58 +02:00
|
|
|
qreal magS() const;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2012-05-29 22:55:30 +02:00
|
|
|
bool isText() const;
|
2014-12-07 17:46:57 +01:00
|
|
|
bool isPrintable() const;
|
2014-07-10 14:13:37 +02:00
|
|
|
virtual bool isSpanner() const { return false; }
|
|
|
|
virtual bool isSpannerSegment() const { return false; }
|
2012-05-29 22:55:30 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
qreal point(const Spatium sp) const { return sp.val() * spatium(); }
|
|
|
|
|
2016-03-08 09:46:33 +01:00
|
|
|
virtual int tick() const; // utility, searches for segment / segment parent
|
|
|
|
virtual int rtick() const; // utility, searches for segment / segment parent
|
2016-02-09 13:51:19 +01:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//
|
|
|
|
// check element for consistency; return false if element
|
|
|
|
// is not valid
|
|
|
|
//
|
|
|
|
virtual bool check() const { return true; }
|
|
|
|
|
|
|
|
QPointF startDragPosition() const { return _startDragPosition; }
|
|
|
|
void setStartDragPosition(const QPointF& v) { _startDragPosition = v; }
|
|
|
|
|
2014-06-24 18:36:02 +02:00
|
|
|
static const char* name(Element::Type type);
|
2016-01-13 00:47:01 +01:00
|
|
|
static Ms::Element* create(Ms::Element::Type type, Score*);
|
2014-06-24 18:36:02 +02:00
|
|
|
static Element::Type name2type(const QStringRef&);
|
2013-01-18 10:55:52 +01:00
|
|
|
static Element* name2Element(const QStringRef&, Score*);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
void setFlag(ElementFlag f, bool v) {
|
|
|
|
if (v)
|
|
|
|
_flags |= f;
|
|
|
|
else
|
2014-06-02 13:08:33 +02:00
|
|
|
_flags &= ~ElementFlags(f);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
bool flag(ElementFlag f) const { return _flags & f; }
|
|
|
|
void setFlags(ElementFlags f) { _flags = f; }
|
|
|
|
ElementFlags flags() const { return _flags; }
|
|
|
|
virtual bool systemFlag() const { return false; }
|
2014-05-22 10:10:58 +02:00
|
|
|
bool selectable() const { return flag(ElementFlag::SELECTABLE); }
|
|
|
|
void setSelectable(bool val) { setFlag(ElementFlag::SELECTABLE, val); }
|
|
|
|
bool dropTarget() const { return flag(ElementFlag::DROP_TARGET); }
|
2012-05-26 14:26:10 +02:00
|
|
|
void setDropTarget(bool v) const {
|
|
|
|
if (v)
|
2014-05-22 10:10:58 +02:00
|
|
|
_flags |= ElementFlag::DROP_TARGET;
|
2012-05-26 14:26:10 +02:00
|
|
|
else
|
2014-06-02 13:08:33 +02:00
|
|
|
_flags &= ~ElementFlags(ElementFlag::DROP_TARGET);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
2014-05-22 10:10:58 +02:00
|
|
|
virtual bool isMovable() const { return flag(ElementFlag::MOVABLE); }
|
2016-02-10 18:35:35 +01:00
|
|
|
bool isSegmentFlag() const { return flag(ElementFlag::SEGMENT); }
|
2012-05-26 14:26:10 +02:00
|
|
|
uint tag() const { return _tag; }
|
|
|
|
void setTag(uint val) { _tag = val; }
|
|
|
|
|
2015-02-04 22:12:13 +01:00
|
|
|
virtual QVariant getProperty(P_ID) const override;
|
|
|
|
virtual bool setProperty(P_ID, const QVariant&) override;
|
|
|
|
virtual QVariant propertyDefault(P_ID) const override;
|
2016-02-04 11:27:47 +01:00
|
|
|
void undoChangeProperty(P_ID, const QVariant&);
|
2016-02-09 13:51:19 +01:00
|
|
|
void resetProperty(P_ID);
|
2016-02-04 11:27:47 +01:00
|
|
|
void undoResetProperty(P_ID);
|
2016-02-09 13:51:19 +01:00
|
|
|
bool custom(P_ID) const;
|
2016-03-02 13:20:19 +01:00
|
|
|
void readProperty(XmlReader&, P_ID);
|
2016-02-09 13:51:19 +01:00
|
|
|
virtual bool isUserModified() const;
|
2013-08-06 19:28:04 +02:00
|
|
|
|
|
|
|
virtual void styleChanged() {}
|
2013-11-06 15:58:05 +01:00
|
|
|
|
|
|
|
void drawSymbol(SymId id, QPainter* p, const QPointF& o = QPointF()) const;
|
|
|
|
void drawSymbol(SymId id, QPainter* p, const QPointF& o, int n) const;
|
2016-01-04 14:48:58 +01:00
|
|
|
void drawSymbols(const std::vector<SymId>&, QPainter* p, const QPointF& o = QPointF()) const;
|
2013-11-11 15:11:28 +01:00
|
|
|
qreal symHeight(SymId id) const;
|
|
|
|
qreal symWidth(SymId id) const;
|
2016-01-04 14:48:58 +01:00
|
|
|
qreal symWidth(const std::vector<SymId>&) const;
|
2013-11-11 15:11:28 +01:00
|
|
|
QRectF symBbox(SymId id) const;
|
2016-01-04 14:48:58 +01:00
|
|
|
QRectF symBbox(const std::vector<SymId>&) const;
|
2015-06-03 10:23:01 +02:00
|
|
|
QPointF symStemDownNW(SymId id) const;
|
|
|
|
QPointF symStemUpSE(SymId id) const;
|
2014-05-12 05:00:54 +02:00
|
|
|
QPointF symCutOutNE(SymId id) const;
|
|
|
|
QPointF symCutOutNW(SymId id) const;
|
|
|
|
QPointF symCutOutSE(SymId id) const;
|
|
|
|
QPointF symCutOutSW(SymId id) const;
|
2015-05-08 08:57:24 +02:00
|
|
|
qreal symAdvance(SymId id) const;
|
2016-01-04 14:48:58 +01:00
|
|
|
std::vector<SymId> toTimeSigString(const QString& s) const;
|
2014-01-09 13:09:58 +01:00
|
|
|
bool symIsValid(SymId id) const;
|
2014-04-09 16:09:21 +02:00
|
|
|
|
2016-02-04 17:06:32 +01:00
|
|
|
bool concertPitch() const;
|
|
|
|
|
2014-06-20 22:48:34 +02:00
|
|
|
virtual Element* nextElement(); //< Used for navigation
|
|
|
|
virtual Element* prevElement(); //< next-element and prev-element command
|
|
|
|
|
2016-02-04 17:06:32 +01:00
|
|
|
virtual QString accessibleInfo() const; //< used to populate the status bar
|
|
|
|
virtual QString screenReaderInfo() const { //< by default returns accessibleInfo, but can be overriden
|
|
|
|
return accessibleInfo();
|
|
|
|
}
|
|
|
|
// if the screen-reader needs a special string (see note for example)
|
|
|
|
virtual QString accessibleExtraInfo() const { // used to return info that will be appended to accessibleInfo
|
|
|
|
return QString(); // and passed only to the screen-reader
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------
|
2016-02-17 14:54:23 +01:00
|
|
|
// check type
|
2016-02-06 11:41:16 +01:00
|
|
|
//
|
|
|
|
// Example for ChordRest:
|
|
|
|
//
|
|
|
|
// bool isChordRest()
|
2016-02-04 17:06:32 +01:00
|
|
|
//---------------------------------------------------
|
2016-03-02 13:20:19 +01:00
|
|
|
// DEBUG: check to catch old (now renamed) ambitious Segment->isChordRest() calls
|
|
|
|
// (which check the subtype)
|
2016-02-04 17:06:32 +01:00
|
|
|
|
2016-03-02 13:20:19 +01:00
|
|
|
bool isChordRest() const { Q_ASSERT(type() != Element::Type::SEGMENT); return type() == Element::Type::REST || type() == Element::Type::CHORD
|
|
|
|
|| type() == Element::Type::REPEAT_MEASURE; }
|
|
|
|
bool isChordRest1() const { return type() == Element::Type::REST || type() == Element::Type::CHORD
|
2016-02-10 18:35:35 +01:00
|
|
|
|| type() == Element::Type::REPEAT_MEASURE; }
|
2016-02-09 13:51:19 +01:00
|
|
|
bool isDurationElement() const { return isChordRest() || (type() == Element::Type::TUPLET); }
|
|
|
|
bool isSLine() const;
|
|
|
|
bool isSLineSegment() const;
|
2016-02-06 11:41:16 +01:00
|
|
|
|
2016-02-10 18:35:35 +01:00
|
|
|
#define CONVERT(a,b) \
|
2016-03-08 09:46:33 +01:00
|
|
|
bool is##a() const { return type() == Element::Type::b; }
|
2016-02-10 18:35:35 +01:00
|
|
|
|
|
|
|
CONVERT(Note, NOTE);
|
|
|
|
CONVERT(Rest, REST);
|
|
|
|
CONVERT(Chord, CHORD);
|
|
|
|
CONVERT(BarLine, BAR_LINE);
|
|
|
|
CONVERT(Articulation, ARTICULATION);
|
|
|
|
CONVERT(Marker, MARKER);
|
|
|
|
CONVERT(Clef, CLEF);
|
|
|
|
CONVERT(KeySig, KEYSIG);
|
|
|
|
CONVERT(TimeSig, TIMESIG);
|
|
|
|
CONVERT(Measure, MEASURE);
|
|
|
|
CONVERT(TempoText, TEMPO_TEXT);
|
|
|
|
CONVERT(Breath, BREATH);
|
|
|
|
CONVERT(HBox, HBOX);
|
|
|
|
CONVERT(VBox, VBOX);
|
|
|
|
CONVERT(TBox, TBOX);
|
|
|
|
CONVERT(FBox, FBOX);
|
|
|
|
CONVERT(Tie, TIE);
|
|
|
|
CONVERT(Slur, SLUR);
|
|
|
|
CONVERT(Glissando, GLISSANDO);
|
|
|
|
CONVERT(SystemDivider, SYSTEM_DIVIDER);
|
|
|
|
CONVERT(RehearsalMark, REHEARSAL_MARK);
|
|
|
|
CONVERT(Harmony, HARMONY);
|
|
|
|
CONVERT(Volta, VOLTA);
|
|
|
|
CONVERT(Jump, JUMP);
|
|
|
|
CONVERT(StaffText, STAFF_TEXT);
|
|
|
|
CONVERT(Ottava, OTTAVA);
|
|
|
|
CONVERT(LayoutBreak, LAYOUT_BREAK);
|
|
|
|
CONVERT(Segment, SEGMENT);
|
2016-02-16 21:21:28 +01:00
|
|
|
CONVERT(Tremolo, TREMOLO);
|
|
|
|
CONVERT(System, SYSTEM);
|
2016-03-02 13:20:19 +01:00
|
|
|
CONVERT(Lyrics, LYRICS);
|
2016-03-19 08:18:54 +01:00
|
|
|
CONVERT(Stem, STEM);
|
2016-04-20 10:45:51 +02:00
|
|
|
CONVERT(Beam, BEAM);
|
2016-04-27 16:33:30 +02:00
|
|
|
CONVERT(Hook, HOOK);
|
|
|
|
CONVERT(StemSlash, STEM_SLASH);
|
2016-04-20 10:45:51 +02:00
|
|
|
CONVERT(SlurSegment, SLUR_SEGMENT);
|
2016-05-02 13:41:41 +02:00
|
|
|
CONVERT(Spacer, SPACER);
|
2016-02-04 17:06:32 +01:00
|
|
|
#undef CONVERT
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
2016-02-17 14:54:23 +01:00
|
|
|
//---------------------------------------------------
|
2016-03-02 13:20:19 +01:00
|
|
|
// safe casting of Element
|
2016-02-17 14:54:23 +01:00
|
|
|
//
|
|
|
|
// Example for ChordRest:
|
|
|
|
//
|
|
|
|
// ChordRest* toChordRest(Element* e)
|
|
|
|
//---------------------------------------------------
|
|
|
|
|
|
|
|
static inline ChordRest* toChordRest(Element* e) {
|
|
|
|
Q_ASSERT(e == 0 || e->type() == Element::Type::CHORD || e->type() == Element::Type::REST
|
|
|
|
|| e->type() == Element::Type::REPEAT_MEASURE);
|
|
|
|
return (ChordRest*)e;
|
|
|
|
}
|
|
|
|
static inline const ChordRest* toChordRest(const Element* e) {
|
|
|
|
Q_ASSERT(e == 0 || e->type() == Element::Type::CHORD || e->type() == Element::Type::REST
|
|
|
|
|| e->type() == Element::Type::REPEAT_MEASURE);
|
|
|
|
return (const ChordRest*)e;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CONVERT(a,b) \
|
|
|
|
static inline a* to##a(Element* e) { Q_ASSERT(e == 0 || e->type() == Element::Type::b); return (a*)e; } \
|
|
|
|
static inline const a* to##a(const Element* e) { Q_ASSERT(e == 0 || e->type() == Element::Type::b); return (const a*)e; }
|
|
|
|
|
|
|
|
CONVERT(Note, NOTE);
|
|
|
|
CONVERT(Rest, REST);
|
|
|
|
CONVERT(Chord, CHORD);
|
|
|
|
CONVERT(BarLine, BAR_LINE);
|
|
|
|
CONVERT(Articulation, ARTICULATION);
|
|
|
|
CONVERT(Marker, MARKER);
|
|
|
|
CONVERT(Clef, CLEF);
|
|
|
|
CONVERT(KeySig, KEYSIG);
|
|
|
|
CONVERT(TimeSig, TIMESIG);
|
|
|
|
CONVERT(Measure, MEASURE);
|
|
|
|
CONVERT(TempoText, TEMPO_TEXT);
|
|
|
|
CONVERT(Breath, BREATH);
|
|
|
|
CONVERT(HBox, HBOX);
|
|
|
|
CONVERT(VBox, VBOX);
|
|
|
|
CONVERT(TBox, TBOX);
|
|
|
|
CONVERT(FBox, FBOX);
|
|
|
|
CONVERT(Tie, TIE);
|
|
|
|
CONVERT(Slur, SLUR);
|
|
|
|
CONVERT(Glissando, GLISSANDO);
|
|
|
|
CONVERT(SystemDivider, SYSTEM_DIVIDER);
|
|
|
|
CONVERT(RehearsalMark, REHEARSAL_MARK);
|
|
|
|
CONVERT(Harmony, HARMONY);
|
|
|
|
CONVERT(Volta, VOLTA);
|
|
|
|
CONVERT(Jump, JUMP);
|
|
|
|
CONVERT(StaffText, STAFF_TEXT);
|
|
|
|
CONVERT(Ottava, OTTAVA);
|
|
|
|
CONVERT(LayoutBreak, LAYOUT_BREAK);
|
|
|
|
CONVERT(Segment, SEGMENT);
|
|
|
|
CONVERT(Tremolo, TREMOLO);
|
|
|
|
CONVERT(System, SYSTEM);
|
2016-03-02 13:20:19 +01:00
|
|
|
CONVERT(Lyrics, LYRICS);
|
2016-03-19 08:18:54 +01:00
|
|
|
CONVERT(Stem, STEM);
|
2016-04-20 10:45:51 +02:00
|
|
|
CONVERT(Beam, BEAM);
|
2016-04-27 16:33:30 +02:00
|
|
|
CONVERT(Hook, HOOK);
|
|
|
|
CONVERT(StemSlash, STEM_SLASH);
|
2016-04-20 10:45:51 +02:00
|
|
|
CONVERT(SlurSegment, SLUR_SEGMENT);
|
2016-05-02 13:41:41 +02:00
|
|
|
CONVERT(Spacer, SPACER);
|
2016-02-17 14:54:23 +01:00
|
|
|
#undef CONVERT
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// ElementList
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2016-02-06 22:03:43 +01:00
|
|
|
class ElementList : public std::vector<Element*> {
|
2012-05-26 14:26:10 +02:00
|
|
|
public:
|
|
|
|
ElementList() {}
|
|
|
|
bool remove(Element*);
|
|
|
|
void replace(Element* old, Element* n);
|
|
|
|
void write(Xml&) const;
|
|
|
|
void write(Xml&, const char* name) const;
|
|
|
|
};
|
|
|
|
|
2012-07-25 11:49:34 +02:00
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @@ StaffLines
|
2014-05-16 13:44:32 +02:00
|
|
|
/// The StaffLines class is the graphic representation of a staff,
|
|
|
|
/// it draws the horizontal staff lines.
|
2012-07-25 11:49:34 +02:00
|
|
|
//-------------------------------------------------------------------
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
class StaffLines : public Element {
|
2012-05-28 11:29:21 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
qreal dist;
|
|
|
|
qreal lw;
|
|
|
|
int lines;
|
|
|
|
|
|
|
|
public:
|
|
|
|
StaffLines(Score*);
|
|
|
|
virtual StaffLines* clone() const { return new StaffLines(*this); }
|
2014-06-24 18:36:02 +02:00
|
|
|
virtual Element::Type type() const { return Element::Type::STAFF_LINES; }
|
2012-05-26 14:26:10 +02:00
|
|
|
virtual void layout();
|
|
|
|
|
|
|
|
Measure* measure() const { return (Measure*)parent(); }
|
|
|
|
virtual void draw(QPainter*) const;
|
2013-07-23 19:08:24 +02:00
|
|
|
virtual QPointF pagePos() const; ///< position in page coordinates
|
|
|
|
virtual QPointF canvasPos() const; ///< position in page coordinates
|
2012-05-26 14:26:10 +02:00
|
|
|
qreal y1() const;
|
2013-07-17 12:17:49 +02:00
|
|
|
qreal staffHeight() const { return (lines-1) * dist; }
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2012-07-25 11:49:34 +02:00
|
|
|
// @@ Line
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class Line : public Element {
|
2012-05-28 11:29:21 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
Spatium _width;
|
|
|
|
Spatium _len;
|
2012-09-02 22:21:49 +02:00
|
|
|
int _z; ///< stacking order when drawing or selecting;
|
|
|
|
///< elements are drawn from high number to low number;
|
|
|
|
///< default is type() * 100;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool vertical;
|
|
|
|
|
2016-02-06 11:41:16 +01:00
|
|
|
public:
|
2012-05-26 14:26:10 +02:00
|
|
|
Line(Score*);
|
|
|
|
Line(Score*, bool vertical);
|
|
|
|
Line &operator=(const Line&);
|
|
|
|
|
2014-06-24 18:36:02 +02:00
|
|
|
virtual Line* clone() const { return new Line(*this); }
|
|
|
|
virtual Element::Type type() const { return Element::Type::LINE; }
|
2012-05-26 14:26:10 +02:00
|
|
|
virtual void layout();
|
|
|
|
|
|
|
|
virtual void draw(QPainter*) const;
|
|
|
|
void writeProperties(Xml& xml) const;
|
2013-01-11 18:10:18 +01:00
|
|
|
bool readProperties(XmlReader&);
|
2012-05-26 14:26:10 +02:00
|
|
|
void dump() const;
|
|
|
|
|
|
|
|
Spatium len() const { return _len; }
|
|
|
|
Spatium lineWidth() const { return _width; }
|
|
|
|
void setLen(Spatium);
|
|
|
|
void setLineWidth(Spatium);
|
2012-09-02 22:21:49 +02:00
|
|
|
virtual int z() const { return _z; }
|
|
|
|
void setZ(int val) { _z = val; }
|
2012-05-26 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2012-07-25 11:49:34 +02:00
|
|
|
// @@ Compound
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class Compound : public Element {
|
2012-05-28 11:29:21 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2014-05-13 17:53:31 +02:00
|
|
|
QList<Element*> elements;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
protected:
|
2014-05-13 17:53:31 +02:00
|
|
|
const QList<Element*>& getElements() const { return elements; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
Compound(Score*);
|
|
|
|
Compound(const Compound&);
|
2014-06-24 18:36:02 +02:00
|
|
|
virtual Element::Type type() const = 0;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
virtual void draw(QPainter*) const;
|
|
|
|
virtual void addElement(Element*, qreal x, qreal y);
|
|
|
|
void clear();
|
|
|
|
virtual void setSelected(bool f);
|
|
|
|
virtual void setVisible(bool);
|
|
|
|
virtual void layout();
|
|
|
|
};
|
|
|
|
|
|
|
|
extern bool elementLessThan(const Element* const, const Element* const);
|
|
|
|
extern void collectElements(void* data, Element* e);
|
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
|
|
|
|
} // namespace Ms
|
|
|
|
|
2014-06-24 18:36:02 +02:00
|
|
|
Q_DECLARE_METATYPE(Ms::Element::Type);
|
2014-06-24 17:27:58 +02:00
|
|
|
Q_DECLARE_METATYPE(Ms::Element::Placement);
|
2012-09-13 18:01:34 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
#endif
|
|
|
|
|