MuseScore/libmscore/symbol.h

93 lines
2.8 KiB
C
Raw Normal View History

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 __SYMBOL_H__
#define __SYMBOL_H__
#include "bsymbol.h"
2013-05-13 18:49:17 +02:00
namespace Ms {
class Segment;
class ScoreFont;
enum class SymId;
2013-05-13 18:49:17 +02:00
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ Symbol
/// Symbol constructed from builtin symbol.
//
// @P symbol string the SMuFL name of the symbol
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class Symbol : public BSymbol {
protected:
SymId _sym;
const ScoreFont* _scoreFont = nullptr;
2012-05-26 14:26:10 +02:00
public:
Symbol(Score* s, ElementFlags f = ElementFlag::MOVABLE);
2012-05-26 14:26:10 +02:00
Symbol(const Symbol&);
2014-06-27 13:41:49 +02:00
Symbol &operator=(const Symbol&) = delete;
2012-05-26 14:26:10 +02:00
virtual Symbol* clone() const { return new Symbol(*this); }
virtual ElementType type() const { return ElementType::SYMBOL; }
2012-05-26 14:26:10 +02:00
void setSym(SymId s, const ScoreFont* sf = nullptr) { _sym = s; _scoreFont = sf; }
SymId sym() const { return _sym; }
QString symName() const;
2012-05-26 14:26:10 +02:00
virtual void draw(QPainter*) const override;
2016-11-19 11:51:21 +01:00
virtual void write(XmlWriter& xml) const override;
virtual void read(XmlReader&) override;
virtual void layout() override;
2012-05-26 14:26:10 +02:00
virtual QVariant getProperty(Pid) const override;
virtual bool setProperty(Pid, const QVariant&) override;
virtual qreal baseLine() const { return 0.0; }
2015-07-25 08:43:02 +02:00
virtual Segment* segment() const { return (Segment*)parent(); }
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ FSymbol
/// Symbol constructed from a font glyph.
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class FSymbol final : public BSymbol {
2012-05-26 14:26:10 +02:00
QFont _font;
int _code;
public:
FSymbol(Score* s);
FSymbol(const FSymbol&);
virtual FSymbol* clone() const { return new FSymbol(*this); }
2017-01-18 14:16:33 +01:00
virtual ElementType type() const { return ElementType::FSYMBOL; }
2012-05-26 14:26:10 +02:00
virtual void draw(QPainter*) const;
2016-11-19 11:51:21 +01:00
virtual void write(XmlWriter& xml) const;
2013-01-11 18:10:18 +01:00
virtual void read(XmlReader&);
2012-05-26 14:26:10 +02:00
virtual void layout();
virtual qreal baseLine() const { return 0.0; }
Segment* segment() const { return (Segment*)parent(); }
QFont font() const { return _font; }
int code() const { return _code; }
2012-05-26 14:26:10 +02:00
void setFont(const QFont& f);
void setCode(int val) { _code = val; }
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