MuseScore  3.4
Music composition and notation
symbol.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2002-2011 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __SYMBOL_H__
14 #define __SYMBOL_H__
15 
16 #include "bsymbol.h"
17 
18 namespace Ms {
19 
20 class Segment;
21 class ScoreFont;
22 enum class SymId;
23 
24 //---------------------------------------------------------
25 // @@ Symbol
27 //
28 // @P symbol string the SMuFL name of the symbol
29 //---------------------------------------------------------
30 
31 class Symbol : public BSymbol {
32  protected:
34  const ScoreFont* _scoreFont = nullptr;
35 
36  public:
38  Symbol(const Symbol&);
39 
40  Symbol &operator=(const Symbol&) = delete;
41 
42  virtual Symbol* clone() const { return new Symbol(*this); }
43  virtual ElementType type() const { return ElementType::SYMBOL; }
44 
45  void setSym(SymId s, const ScoreFont* sf = nullptr) { _sym = s; _scoreFont = sf; }
46  SymId sym() const { return _sym; }
47  QString symName() const;
48 
49  virtual void draw(QPainter*) const override;
50  virtual void write(XmlWriter& xml) const override;
51  virtual void read(XmlReader&) override;
52  virtual void layout() override;
53 
54  virtual QVariant getProperty(Pid) const override;
55  virtual bool setProperty(Pid, const QVariant&) override;
56 
57  virtual qreal baseLine() const { return 0.0; }
58  virtual Segment* segment() const { return (Segment*)parent(); }
59  };
60 
61 //---------------------------------------------------------
62 // @@ FSymbol
64 //---------------------------------------------------------
65 
66 class FSymbol final : public BSymbol {
67  QFont _font;
68  int _code;
69 
70  public:
71  FSymbol(Score* s);
72  FSymbol(const FSymbol&);
73 
74  virtual FSymbol* clone() const { return new FSymbol(*this); }
75  virtual ElementType type() const { return ElementType::FSYMBOL; }
76 
77  virtual void draw(QPainter*) const;
78  virtual void write(XmlWriter& xml) const;
79  virtual void read(XmlReader&);
80  virtual void layout();
81 
82  virtual qreal baseLine() const { return 0.0; }
83  Segment* segment() const { return (Segment*)parent(); }
84  QFont font() const { return _font; }
85  int code() const { return _code; }
86  void setFont(const QFont& f);
87  void setCode(int val) { _code = val; }
88  };
89 
90 } // namespace Ms
91 #endif
92 
Pid
Definition: property.h:62
Definition: xml.h:67
QFlags< ElementFlag > ElementFlags
Definition: element.h:101
virtual ElementType type() const
Definition: symbol.h:43
QFont font() const
Definition: symbol.h:84
Symbol & operator=(const Symbol &)=delete
virtual bool setProperty(Pid, const QVariant &) override
Definition: symbol.cpp:176
Segment * segment() const
Definition: symbol.h:83
virtual void draw(QPainter *) const override
Definition: symbol.cpp:82
Symbol constructed from a font glyph.
Definition: symbol.h:66
virtual qreal baseLine() const
Definition: symbol.h:57
SymId
Definition: sym.h:30
int code() const
Definition: symbol.h:85
Element * parent() const
Definition: element.h:192
Definition: score.h:391
virtual FSymbol * clone() const
Definition: symbol.h:74
QFont _font
Definition: symbol.h:67
base class for Symbol and Image
Definition: bsymbol.h:25
void setCode(int val)
Definition: symbol.h:87
void setSym(SymId s, const ScoreFont *sf=nullptr)
Definition: symbol.h:45
virtual void write(XmlWriter &xml) const override
Definition: symbol.cpp:97
Definition: sym.h:2768
virtual ElementType type() const
Definition: symbol.h:75
Definition: segment.h:50
Definition: aeolus.cpp:26
const ScoreFont * _scoreFont
Definition: symbol.h:34
virtual QVariant getProperty(Pid) const override
Definition: symbol.cpp:161
Definition: xml.h:218
Symbol constructed from builtin symbol.
Definition: symbol.h:31
int _code
Definition: symbol.h:68
virtual void layout() override
Definition: symbol.cpp:57
virtual void read(XmlReader &) override
Definition: symbol.cpp:111
QString symName() const
Definition: symbol.cpp:46
virtual Symbol * clone() const
Definition: symbol.h:42
ElementType
Definition: types.h:34
virtual Segment * segment() const
Definition: symbol.h:58
Symbol(Score *s, ElementFlags f=ElementFlag::MOVABLE)
Definition: symbol.cpp:29
virtual qreal baseLine() const
Definition: symbol.h:82
SymId sym() const
Definition: symbol.h:46
SymId _sym
Definition: symbol.h:33