MuseScore/libmscore/fret.h

120 lines
3.9 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 __FRET_H__
#define __FRET_H__
#include "element.h"
2013-05-13 18:49:17 +02:00
namespace Ms {
class StringData;
2012-05-26 14:26:10 +02:00
class Chord;
class Harmony;
//---------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ FretDiagram
/// Fretboard diagram
2015-11-02 11:20:40 +01:00
//
// @P userMag qreal
// @P strings int number of strings
// @P frets int number of frets
// @P barre int barre
// @P fretOffset int
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class FretDiagram final : public Element {
2018-07-12 10:15:56 +02:00
int _strings;
2015-01-15 12:50:03 +01:00
int maxStrings { 0 };
2018-07-12 10:15:56 +02:00
int _frets;
2015-01-15 12:50:03 +01:00
int _fretOffset { 0 };
int _maxFrets { 24 };
2015-11-02 14:09:03 +01:00
int _barre { 0 };
2015-01-15 12:50:03 +01:00
char* _dots { 0 };
char* _marker { 0 };
char* _fingering { 0 };
2015-01-15 12:50:03 +01:00
Harmony* _harmony { 0 };
2012-05-26 14:26:10 +02:00
qreal lw1;
qreal lw2; // top line
qreal stringDist;
qreal fretDist;
QFont font;
2015-01-15 14:50:50 +01:00
qreal _userMag { 1.0 }; // allowed 0.1 - 10.0
int _numPos;
2012-05-26 14:26:10 +02:00
public:
FretDiagram(Score* s);
FretDiagram(const FretDiagram&);
~FretDiagram();
2015-01-15 14:50:50 +01:00
virtual void draw(QPainter*) const override;
virtual FretDiagram* clone() const override { return new FretDiagram(*this); }
2012-05-26 14:26:10 +02:00
Segment* segment() { return toSegment(parent()); }
static FretDiagram* fromString(Score* score, const QString &s);
2017-01-18 14:16:33 +01:00
virtual ElementType type() const override { return ElementType::FRET_DIAGRAM; }
2015-01-15 14:50:50 +01:00
virtual void layout() override;
2016-11-19 11:51:21 +01:00
virtual void write(XmlWriter& xml) const override;
2015-01-15 14:50:50 +01:00
virtual void read(XmlReader&) override;
virtual QLineF dragAnchor() const override;
virtual QPointF pagePos() const override;
2012-05-26 14:26:10 +02:00
// read / write MusicXML
2013-01-11 18:10:18 +01:00
void readMusicXML(XmlReader& de);
2016-11-19 11:51:21 +01:00
void writeMusicXML(XmlWriter& xml) const;
2012-05-26 14:26:10 +02:00
int strings() const { return _strings; }
int frets() const { return _frets; }
void setStrings(int n);
2015-01-15 12:50:03 +01:00
void setFrets(int n) { _frets = n; }
2012-05-26 14:26:10 +02:00
void setDot(int string, int fret);
2015-01-15 12:50:03 +01:00
void setBarre(int fret) { _barre = fret; }
2012-05-26 14:26:10 +02:00
void setMarker(int string, int marker);
void setFingering(int string, int finger);
int fretOffset() const { return _fretOffset; }
void setFretOffset(int val) { _fretOffset = val; }
int maxFrets() const { return _maxFrets; }
void setMaxFrets(int val) { _maxFrets = val; }
2014-08-12 12:55:38 +02:00
char dot(int s) const { return _dots ? _dots[s] : 0; }
char marker(int s) const { return _marker ? _marker[s] : 0; }
char fingering(int s) const { return _fingering ? _fingering[s] : 0; }
2015-01-15 12:50:03 +01:00
int barre() const { return _barre; }
2014-08-12 12:55:38 +02:00
2012-12-10 21:15:28 +01:00
Harmony* harmony() const { return _harmony; }
void init(Ms::StringData *, Chord*);
2012-05-26 14:26:10 +02:00
2015-01-15 14:50:50 +01:00
virtual void add(Element*) override;
virtual void remove(Element*) override;
2012-05-26 14:26:10 +02:00
2017-03-31 13:03:15 +02:00
virtual bool acceptDrop(EditData&) const override;
virtual Element* drop(EditData&) override;
2012-05-26 14:26:10 +02:00
2015-01-15 14:50:50 +01:00
virtual void scanElements(void* data, void (*func)(void*, Element*), bool all=true) override;
2018-03-27 15:36:00 +02:00
virtual QVariant getProperty(Pid propertyId) const override;
virtual bool setProperty(Pid propertyId, const QVariant&) override;
virtual QVariant propertyDefault(Pid) const override;
2015-01-15 14:50:50 +01:00
qreal userMag() const { return _userMag; }
void setUserMag(qreal m) { _userMag = m; }
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