MuseScore/libmscore/fret.h

141 lines
4.5 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;
2015-01-15 12:50:03 +01:00
static const int DEFAULT_STRINGS = 6;
static const int DEFAULT_FRETS = 5;
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
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 : public Element {
2015-11-02 11:20:40 +01:00
#ifdef SCRIPT_INTERFACE
Q_OBJECT
2015-11-02 11:20:40 +01:00
Q_PROPERTY(qreal userMag READ userMag WRITE undoSetUserMag)
Q_PROPERTY(int strings READ strings WRITE undoSetStrings)
Q_PROPERTY(int frets READ frets WRITE undoSetFrets)
Q_PROPERTY(int barre READ barre WRITE undoSetBarre)
Q_PROPERTY(int fretOffset READ fretOffset WRITE undoSetFretOffset)
public:
void undoSetUserMag(qreal val);
void undoSetStrings(int val);
void undoSetFrets(int val);
void undoSetBarre(int val);
void undoSetFretOffset(int val);
private:
#endif
2015-01-15 12:50:03 +01:00
int _strings { DEFAULT_STRINGS };
int maxStrings { 0 };
int _frets { DEFAULT_FRETS };
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
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
static FretDiagram* fromString(Score* score, const QString &s);
2015-01-15 14:50:50 +01:00
virtual Element::Type type() const override { return Element::Type::FRET_DIAGRAM; }
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 setOffset(int offset);
2012-05-26 14:26:10 +02:00
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
2014-08-13 21:01:21 +02:00
virtual bool acceptDrop(const DropData&) const override;
2015-01-15 14:50:50 +01:00
virtual Element* drop(const DropData&) 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;
virtual QVariant getProperty(P_ID propertyId) const override;
virtual bool setProperty(P_ID propertyId, const QVariant&) override;
virtual QVariant propertyDefault(P_ID) const override;
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