LCOV - code coverage report
Current view: top level - src/engraving/dom - keysig.h Coverage Total Hit
Test: filtered_coverage.info Lines: 93.5 % 31 29
Test Date: 2026-11-19 04:14:36

            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              : #pragma once
      24              : 
      25              : #include "key.h"
      26              : #include "engravingitem.h"
      27              : 
      28              : namespace mu::engraving {
      29              : class Factory;
      30              : class Segment;
      31              : class Transaction;
      32              : 
      33              : class KeySig final : public EngravingItem
      34              : {
      35        15216 :     OBJECT_ALLOCATOR(engraving, KeySig)
      36         1525 :     DECLARE_CLASSOF(ElementType::KEYSIG)
      37              : 
      38         3488 :     M_PROPERTY2(bool, isCourtesy, setIsCourtesy, false)
      39              : 
      40              : public:
      41              : 
      42          206 :     KeySig* clone() const override { return new KeySig(*this); }
      43           18 :     void setOwnershipParent(DummyParentOr<Segment> parent) { EngravingItem::setOwnershipParent(parent); }
      44              : 
      45              :     bool acceptDrop(EditData&) const override;
      46              :     EngravingItem* drop(Transaction& tx, EditData&) override;
      47              : 
      48              :     double mag() const override;
      49              : 
      50              :     void setKey(Key concertKey, Key transposedKey);
      51              :     void setKey(Key concertKey);
      52              : 
      53       104885 :     Segment* segment() const { return (Segment*)ownershipParent(); }
      54        52597 :     Measure* measure() const { return ownershipParent() ? (Measure*)ownershipParent()->ownershipParent() : nullptr; }
      55              : 
      56        28498 :     Key key() const { return m_sig.key(); }
      57         2479 :     Key concertKey() const { return m_sig.concertKey(); }
      58           50 :     const std::vector<CustDef>& customKeyDefs() const { return m_sig.customKeyDefs(); }
      59           98 :     int degInKey(int degree) const { return m_sig.degInKey(degree); }
      60           98 :     SymId symInKey(SymId sym, int degree) const { return m_sig.symInKey(sym, degree); }
      61        28090 :     bool isCustom() const { return m_sig.custom(); }
      62         1361 :     bool isAtonal() const { return m_sig.isAtonal(); }
      63              :     bool isChange() const;
      64         3722 :     const KeySigEvent& keySigEvent() const { return m_sig; }
      65              :     bool operator==(const KeySig&) const;
      66              :     void changeKeySigEvent(const KeySigEvent&);
      67        21847 :     void setKeySigEvent(const KeySigEvent& e) { m_sig = e; }
      68              : 
      69        54860 :     bool showCourtesy() const { return m_showCourtesy; }
      70           90 :     void setShowCourtesy(bool v) { m_showCourtesy = v; }
      71              : 
      72         2006 :     KeyMode mode() const { return m_sig.mode(); }
      73          307 :     void setMode(KeyMode v) { m_sig.setMode(v); }
      74              : 
      75         1261 :     JianpuNumbering jianpuNumbering() const { return m_sig.jianpuNumbering(); }
      76            8 :     void setJianpuNumbering(JianpuNumbering v) { m_sig.setJianpuNumbering(v); }
      77           29 :     Key jianpuTonicKey() const { return m_sig.jianpuTonicKey(); }
      78            8 :     void setJianpuTonicKey(Key v) { m_sig.setJianpuTonicKey(v); }
      79           27 :     KeyMode jianpuTonicMode() const { return m_sig.jianpuTonicMode(); }
      80            8 :     void setJianpuTonicMode(KeyMode v) { m_sig.setJianpuTonicMode(v); }
      81              : 
      82              :     PointF staffOffset() const override;
      83              : 
      84        26292 :     bool hideNaturals() const { return m_hideNaturals; }
      85            0 :     void setHideNaturals(bool hide) { m_hideNaturals = hide; }
      86              : 
      87              :     void setForInstrumentChange(bool forInstrumentChange) { m_sig.setForInstrumentChange(forInstrumentChange); }
      88         1266 :     bool forInstrumentChange() const { return m_sig.forInstrumentChange(); }
      89              : 
      90              :     PropertyValue getProperty(Pid propertyId) const override;
      91              :     bool setProperty(Pid propertyId, const PropertyValue&) override;
      92              :     using EngravingItem::undoChangeProperty;
      93              :     void undoChangeProperty(Pid id, const PropertyValue& v, PropertyFlags ps) override;
      94              :     PropertyValue propertyDefault(Pid id) const override;
      95              :     PropertyDelegate resolvePropertyDelegate(Pid) const override;
      96              : 
      97              :     EngravingItem* nextSegmentElement() override;
      98              :     EngravingItem* prevSegmentElement() override;
      99              :     String accessibleInfo() const override;
     100              : 
     101            0 :     int subtype() const override { return int(key()) + 7; }
     102              :     muse::TranslatableString subtypeUserName() const override;
     103              : 
     104              :     struct LayoutData : public EngravingItem::LayoutData {
     105              :         std::vector<KeySym> keySymbols;
     106              :         String jianpuLabel;    // Jianpu key label (e.g. "1=C"); drawn instead of keySymbols when non-empty
     107              :     };
     108        53870 :     DECLARE_LAYOUTDATA_METHODS(KeySig)
     109              : 
     110              : private:
     111              :     friend class Factory;
     112              : 
     113              :     KeySig(DummyParentOr<Segment>);
     114              :     KeySig(const KeySig&);
     115              : 
     116              :     void addLayout(SymId sym, int line);
     117              : 
     118              :     bool m_showCourtesy;
     119              :     bool m_hideNaturals;       // used in layout to override score style (needed for the Continuous panel)
     120              :     KeySigEvent m_sig;
     121              : };
     122              : }
        

Generated by: LCOV version 2.0-1