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;
|
|
|
|
|
2016-02-09 13:51:19 +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;
|
2013-03-07 20:01:22 +01:00
|
|
|
|
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;
|
2016-02-09 13:51:19 +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
|
|
|
|
2014-07-20 00:56:14 +02:00
|
|
|
// data for some preset bar line span types
|
|
|
|
static const int BARLINE_SPAN_TICK1_FROM = -1;
|
|
|
|
static const int BARLINE_SPAN_TICK1_TO = 1;
|
|
|
|
static const int BARLINE_SPAN_TICK2_FROM = -2;
|
|
|
|
static const int BARLINE_SPAN_TICK2_TO = 2;
|
|
|
|
static const int BARLINE_SPAN_SHORT1_FROM = 2;
|
|
|
|
static const int BARLINE_SPAN_SHORT1_TO = 6;
|
|
|
|
static const int BARLINE_SPAN_SHORT2_FROM = 1;
|
|
|
|
static const int BARLINE_SPAN_SHORT2_TO = 7;
|
|
|
|
|
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
|
|
|
|
2016-02-09 13:51:19 +01:00
|
|
|
static const int UNKNOWN_BARLINE_TO = -6;
|
2012-10-20 20:32:40 +02:00
|
|
|
|
2015-02-25 11:54:31 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// BarLineTableItem
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
struct BarLineTableItem {
|
|
|
|
BarLineType type;
|
2016-02-04 17:06:32 +01:00
|
|
|
const char* userName; // user name, translatable
|
2015-02-25 11:54:31 +01:00
|
|
|
const char* name;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
|
2014-12-18 13:21:29 +01:00
|
|
|
BarLineType _barLineType { BarLineType::NORMAL };
|
2016-02-09 13:51:19 +01:00
|
|
|
int _span { 1 }; // number of staves spanned by the barline
|
|
|
|
int _spanFrom { 0 }; // line number on start and end staves
|
2014-12-18 13:21:29 +01:00
|
|
|
int _spanTo { DEFAULT_BARLINE_TO };
|
2016-03-08 09:46:33 +01:00
|
|
|
bool _customSpan { false };
|
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
|
2014-04-08 10:42:25 +02:00
|
|
|
static bool shiftDrag; // used to mark if [SHIFT] 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*);
|
2014-06-27 13:41:49 +02:00
|
|
|
BarLine &operator=(const BarLine&) = delete;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-12-18 13:21:29 +01:00
|
|
|
virtual BarLine* clone() const override { return new BarLine(*this); }
|
|
|
|
virtual Element::Type type() const override { return Element::Type::BAR_LINE; }
|
|
|
|
virtual void write(Xml& xml) const override;
|
|
|
|
virtual void read(XmlReader&) override;
|
|
|
|
virtual void draw(QPainter*) const override;
|
|
|
|
virtual QPointF pagePos() const override; ///< position in canvas coordinates
|
|
|
|
virtual void layout() override;
|
|
|
|
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true) override;
|
|
|
|
virtual void add(Element*) override;
|
|
|
|
virtual void remove(Element*) override;
|
2016-01-04 14:48:58 +01:00
|
|
|
virtual QPainterPath outline() const override;
|
2014-08-13 21:01:21 +02:00
|
|
|
virtual bool acceptDrop(const DropData&) const override;
|
2014-12-18 13:21:29 +01:00
|
|
|
virtual Element* drop(const DropData&) override;
|
2016-06-10 10:30:34 +02:00
|
|
|
virtual bool isEditable() const override { return true; }
|
2014-12-18 13:21:29 +01:00
|
|
|
|
2016-02-09 13:51:19 +01:00
|
|
|
Segment* segment() const { return (Segment*)parent(); }
|
2016-02-04 11:27:47 +01:00
|
|
|
|
2016-02-09 13:51:19 +01:00
|
|
|
void setSpan(int val) { _span = val; }
|
|
|
|
void setSpanFrom(int val) { _spanFrom = val; }
|
|
|
|
void setSpanTo(int val) { _spanTo = val; }
|
2013-03-08 12:55:12 +01:00
|
|
|
int span() const { return _span; }
|
|
|
|
int spanFrom() const { return _spanFrom; }
|
|
|
|
int spanTo() const { return _spanTo; }
|
2016-03-08 09:46:33 +01:00
|
|
|
bool customSpan() const { return _customSpan; }
|
|
|
|
void setCustomSpan(bool v) { _customSpan = v; }
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-12-18 13:21:29 +01:00
|
|
|
virtual void startEdit(MuseScoreView*, const QPointF&) override;
|
|
|
|
virtual void endEdit() override;
|
|
|
|
virtual void editDrag(const EditData&) override;
|
|
|
|
virtual void endEditDrag() override;
|
2015-01-19 12:37:17 +01:00
|
|
|
virtual void updateGrips(Grip*, QVector<QRectF>&) const override;
|
|
|
|
virtual int grips() const override { return 2; }
|
2014-12-18 13:21:29 +01:00
|
|
|
|
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
|
|
|
|
2014-03-24 11:50:26 +01:00
|
|
|
static QString userTypeName(BarLineType);
|
2016-02-04 17:06:32 +01:00
|
|
|
static const BarLineTableItem* barLineTableItem(unsigned);
|
2014-07-10 14:13:37 +02:00
|
|
|
|
2013-03-05 20:23:59 +01:00
|
|
|
QString barLineTypeName() const;
|
2014-09-16 13:20:15 +02:00
|
|
|
static QString barLineTypeName(BarLineType t);
|
2013-03-05 20:23:59 +01:00
|
|
|
void setBarLineType(const QString& s);
|
2016-02-09 13:51:19 +01:00
|
|
|
void setBarLineType(BarLineType i) { _barLineType = i; }
|
2013-03-05 20:23:59 +01:00
|
|
|
BarLineType barLineType() const { return _barLineType; }
|
2016-01-04 14:48:58 +01:00
|
|
|
static BarLineType barLineType(const QString&);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-12-18 13:21:29 +01:00
|
|
|
virtual int subtype() const override { return int(_barLineType); }
|
|
|
|
virtual QString subtypeName() const override { return qApp->translate("barline", barLineTypeName().toUtf8()); }
|
2014-11-06 22:46:06 +01:00
|
|
|
|
2016-03-08 09:46:33 +01:00
|
|
|
|
2014-03-24 11:50:26 +01:00
|
|
|
virtual QVariant getProperty(P_ID propertyId) const override;
|
|
|
|
virtual bool setProperty(P_ID propertyId, const QVariant&) override;
|
|
|
|
virtual QVariant propertyDefault(P_ID propertyId) const override;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-12-18 13:21:29 +01:00
|
|
|
virtual qreal mag() const override;
|
2013-08-06 14:45:03 +02:00
|
|
|
|
2014-12-18 13:21:29 +01:00
|
|
|
static void setCtrlDrag(bool val) { ctrlDrag = val; }
|
2014-04-08 10:42:25 +02:00
|
|
|
static void setShiftDrag(bool val) { shiftDrag = val; }
|
2012-08-02 18:33:43 +02:00
|
|
|
static qreal layoutWidth(Score*, BarLineType, qreal mag);
|
2014-06-20 22:48:34 +02:00
|
|
|
|
|
|
|
virtual Element* nextElement() override;
|
|
|
|
virtual Element* prevElement() override;
|
2014-12-18 13:21:29 +01:00
|
|
|
|
2016-02-04 17:06:32 +01:00
|
|
|
virtual QString accessibleInfo() const override;
|
|
|
|
virtual QString accessibleExtraInfo() 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
|
|
|
|
|