2012-05-26 14:26:10 +02:00
|
|
|
//=============================================================================
|
|
|
|
// MuseScore
|
|
|
|
// Music Composition & Notation
|
|
|
|
//
|
|
|
|
// 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"
|
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
class QPainter;
|
|
|
|
|
|
|
|
namespace Ms {
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
class MuseScoreView;
|
|
|
|
class Segment;
|
|
|
|
|
2013-03-07 20:01:22 +01:00
|
|
|
static const int DEFAULT_BARLINE_TO = 4 * 2;
|
|
|
|
static const int MIN_BARLINE_FROMTO_DIST = 2;
|
|
|
|
static const int MIN_BARLINE_SPAN_FROMTO = -2;
|
|
|
|
|
2012-12-10 12:56:54 +01:00
|
|
|
// bar line span for 1-line staves is special: goes from 2sp above the line to 2sp below the line;
|
2013-03-23 15:49:11 +01:00
|
|
|
static const int BARLINE_SPAN_1LINESTAFF_FROM = -4;
|
|
|
|
static const int BARLINE_SPAN_1LINESTAFF_TO = 4;
|
2013-03-07 20:01:22 +01:00
|
|
|
|
2012-11-05 20:31:57 +01:00
|
|
|
// 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
|
2013-03-07 20:01:22 +01:00
|
|
|
|
|
|
|
static const int UNKNOWN_BARLINE_TO = -4;
|
2012-10-20 20:32:40 +02:00
|
|
|
|
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 {
|
2012-05-28 11:29:21 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2013-03-05 20:23:59 +01:00
|
|
|
BarLineType _barLineType;
|
2012-10-14 13:46:04 +02:00
|
|
|
bool _customSpan;
|
2012-11-06 14:57:04 +01:00
|
|
|
bool _customSubtype;
|
2012-05-26 14:26:10 +02:00
|
|
|
int _span;
|
2012-10-14 00:35:11 +02:00
|
|
|
int _spanFrom, _spanTo;
|
2013-03-07 20:01:22 +01:00
|
|
|
|
2012-10-14 19:48:36 +02:00
|
|
|
// 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;
|
2013-03-18 13:01:50 +01:00
|
|
|
void updateCustomSpan();
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
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&);
|
2013-03-08 12:55:12 +01:00
|
|
|
void setCustomSpan(bool val) { _customSpan = val; }
|
2012-11-06 14:57:04 +01:00
|
|
|
void setCustomSubtype(bool val) { _customSubtype = val; }
|
2013-03-18 13:01:50 +01:00
|
|
|
void setSpan(int val) { _span = val; updateCustomSpan(); }
|
|
|
|
void setSpanFrom(int val) { _spanFrom = val; updateCustomSpan(); }
|
|
|
|
void setSpanTo(int val) { _spanTo = val; updateCustomSpan(); }
|
2013-03-08 12:55:12 +01:00
|
|
|
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
|
|
|
|
2012-10-22 14:46:35 +02:00
|
|
|
virtual bool isEditable() const { return parent()->type() == SEGMENT; }
|
2012-10-14 19:48:36 +02:00
|
|
|
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;
|
|
|
|
|
2013-03-08 12:55:12 +01:00
|
|
|
ElementList* el() { return &_el; }
|
|
|
|
const ElementList* el() const { return &_el; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-03-05 20:23:59 +01:00
|
|
|
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&);
|
2013-03-07 20:01:22 +01:00
|
|
|
virtual QVariant propertyDefault(P_ID propertyId) const;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2012-10-14 13:46:04 +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
|
|
|
};
|
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
|
|
|
|
} // namespace Ms
|
2012-05-26 14:26:10 +02:00
|
|
|
#endif
|
|
|
|
|