LCOV - code coverage report
Current view: top level - src/engraving/dom - symbol.h Coverage Total Hit
Test: filtered_coverage.info Lines: 47.4 % 19 9
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : 
      23              : #ifndef MU_ENGRAVING_SYMBOL_H
      24              : #define MU_ENGRAVING_SYMBOL_H
      25              : 
      26              : #include <memory>
      27              : 
      28              : #include "draw/types/font.h"
      29              : 
      30              : #include "modularity/ioc.h"
      31              : #include "../iengravingfontsprovider.h"
      32              : 
      33              : #include "bsymbol.h"
      34              : 
      35              : namespace mu::engraving {
      36              : class Segment;
      37              : class IEngravingFont;
      38              : 
      39              : //---------------------------------------------------------
      40              : //   @@ Symbol
      41              : ///    Symbol constructed from builtin symbol.
      42              : //
      43              : //   @P symbol       string       the SMuFL name of the symbol
      44              : //---------------------------------------------------------
      45              : 
      46              : class Symbol : public BSymbol
      47              : {
      48          195 :     OBJECT_ALLOCATOR(engraving, Symbol)
      49         1106 :     DECLARE_CLASSOF(ElementType::SYMBOL)
      50              : 
      51              : public:
      52            0 :     Symbol(const ElementType& type, EngravingObject* parent, ElementFlags f = ElementFlag::MOVABLE);
      53          108 :     Symbol(EngravingObject* parent, ElementFlags f = ElementFlag::MOVABLE);
      54              :     Symbol(const Symbol&);
      55              : 
      56              :     Symbol& operator=(const Symbol&) = delete;
      57              : 
      58            4 :     Symbol* clone() const override { return new Symbol(*this); }
      59              : 
      60              :     void setSym(SymId s, const std::shared_ptr<IEngravingFont>& sf = nullptr);
      61         2474 :     SymId sym() const { return m_sym; }
      62          124 :     const std::shared_ptr<IEngravingFont>& scoreFont() const { return m_scoreFont; }
      63           41 :     double symbolsSize() const { return m_symbolsSize; }
      64            0 :     double symAngle() const { return m_symAngle; }
      65              :     AsciiStringView symName() const;
      66              : 
      67              :     String accessibleInfo() const override;
      68              : 
      69            0 :     int subtype() const override { return int(m_sym); }
      70              :     muse::TranslatableString subtypeUserName() const override;
      71              : 
      72              :     PropertyValue getProperty(Pid) const override;
      73              :     bool setProperty(Pid, const PropertyValue&) override;
      74              :     virtual PropertyValue propertyDefault(Pid) const override;
      75              : 
      76           72 :     double baseLine() const override { return 0.0; }
      77            0 :     virtual Segment* segment() const { return (Segment*)ownershipParent(); }
      78              : 
      79              :     void reset() override;
      80              : 
      81              : protected:
      82              :     SymId m_sym = SymId::noSym;
      83              :     std::shared_ptr<IEngravingFont> m_scoreFont = nullptr;
      84              :     double m_symbolsSize =  1.0;
      85              :     double m_symAngle = 0.0;
      86              : };
      87              : 
      88              : //---------------------------------------------------------
      89              : //   @@ FSymbol
      90              : ///    Symbol constructed from a font glyph (i.e. a text character or emoji).
      91              : //---------------------------------------------------------
      92              : 
      93              : class FSymbol final : public BSymbol
      94              : {
      95            0 :     OBJECT_ALLOCATOR(engraving, FSymbol)
      96         1106 :     DECLARE_CLASSOF(ElementType::FSYMBOL)
      97              : 
      98              : public:
      99              :     FSymbol(DummyParentOr<EngravingItem> parent);
     100              :     FSymbol(const FSymbol&);
     101              : 
     102            0 :     FSymbol* clone() const override { return new FSymbol(*this); }
     103              : 
     104              :     String toString() const;
     105              :     String accessibleInfo() const override;
     106              : 
     107            0 :     double baseLine() const override { return 0.0; }
     108              :     Segment* segment() const { return (Segment*)ownershipParent(); }
     109            0 :     const muse::draw::Font& font() const { return m_font; }
     110            0 :     char32_t code() const { return m_code; }
     111              :     void setFont(const muse::draw::Font& f);
     112            0 :     void setCode(char32_t val) { m_code = val; }
     113              : 
     114              : private:
     115              :     muse::draw::Font m_font;
     116              :     char32_t m_code = 0; // character code point (Unicode)
     117              : };
     118              : } // namespace mu::engraving
     119              : #endif
        

Generated by: LCOV version 2.0-1