MuseScore/libmscore/barline.h

119 lines
4.5 KiB
C
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
// $Id: barline.h 5242 2012-01-23 17:25:56Z wschweer $
//
// 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 __BARLINE_H__
#define __BARLINE_H__
#include "element.h"
class MuseScoreView;
class Segment;
class QPainter;
static const int DEFAULT_BARLINE_TO = 4 * 2;
static const int MIN_BARLINE_FROMTO_DIST = 2;
static const int MIN_BARLINE_SPAN_FROMTO = -2;
// bar line span for 1-line staves is special: goes from 2sp above the line to 2sp below the line;
// for some reason, the single staff line counts as line -1 rather than as line 0
// thus, 2sp above it is -2 rather than -4 and 2sp below it is 6 rather than 4
// (see StaffLines::y1() function in element.cpp)
static const int BARLINE_SPAN_1LINESTAFF_FROM = -2;
static const int BARLINE_SPAN_1LINESTAFF_TO = 6;
// used while reading a score for a default spanTo (to last staff line) toward a staff not yet read;
// fixed once all staves are read
static const int UNKNOWN_BARLINE_TO = -4;
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ BarLine
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class BarLine : public Element {
Q_OBJECT
BarLineType _barLineType;
bool _customSpan;
bool _customSubtype;
2012-05-26 14:26:10 +02:00
int _span;
2012-10-14 00:35:11 +02:00
int _spanFrom, _spanTo;
// static variables used while dragging
static int _origSpan, _origSpanFrom, _origSpanTo; // original span value before editing
2012-10-14 00:35:11 +02:00
static qreal yoff1, yoff2; // used during drag edit to extend y1 and y2
static bool ctrlDrag; // used to mark if [CTRL] has been used while dragging
2012-05-26 14:26:10 +02:00
void getY(qreal*, qreal*) const;
ElementList _el; ///< fermata or other articulations
void drawDots(QPainter* painter, qreal x) const;
public:
BarLine(Score*);
BarLine &operator=(const BarLine&);
virtual BarLine* clone() const { return new BarLine(*this); }
virtual ElementType type() const { return BAR_LINE; }
virtual void write(Xml& xml) const;
2013-01-11 18:10:18 +01:00
virtual void read(XmlReader&);
2012-05-26 14:26:10 +02:00
virtual void draw(QPainter*) const;
virtual Space space() const;
virtual QPointF pagePos() const; ///< position in canvas coordinates
virtual void layout();
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true);
virtual void add(Element*);
virtual void remove(Element*);
virtual QPainterPath shape() const;
virtual bool acceptDrop(MuseScoreView*, const QPointF&, Element*) const;
virtual Element* drop(const DropData&);
void setCustomSpan(bool val) { _customSpan = val; }
void setCustomSubtype(bool val) { _customSubtype = val; }
void setSpan(int val) { _span = val; }
void setSpanFrom(int val) { _spanFrom = val; }
void setSpanTo(int val) { _spanTo = val; }
bool customSpan() const { return _customSpan; }
bool customSubtype() const { return _customSubtype;}
int span() const { return _span; }
int spanFrom() const { return _spanFrom; }
int spanTo() const { return _spanTo; }
2012-05-26 14:26:10 +02:00
virtual bool isEditable() const { return parent()->type() == SEGMENT; }
virtual void startEdit(MuseScoreView*, const QPointF&);
2012-05-26 14:26:10 +02:00
virtual void endEdit();
virtual void editDrag(const EditData&);
virtual void endEditDrag();
virtual void updateGrips(int*, QRectF*) const;
int tick() const;
ElementList* el() { return &_el; }
const ElementList* el() const { return &_el; }
QString barLineTypeName() const;
void setBarLineType(const QString& s);
void setBarLineType(BarLineType i) { _barLineType = i; }
BarLineType barLineType() const { return _barLineType; }
2012-05-26 14:26:10 +02:00
virtual QVariant getProperty(P_ID propertyId) const;
virtual bool setProperty(P_ID propertyId, const QVariant&);
virtual QVariant propertyDefault(P_ID propertyId) const;
2012-05-26 14:26:10 +02:00
static void setCtrlDrag(bool val) { ctrlDrag = val; }
2012-08-02 18:33:43 +02:00
static qreal layoutWidth(Score*, BarLineType, qreal mag);
2012-05-26 14:26:10 +02:00
};
#endif