LCOV - code coverage report
Current view: top level - src/engraving/rendering - paddingtable.h Coverage Total Hit
Test: filtered_coverage.info Lines: 100.0 % 16 16
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) 2023 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              : #pragma once
      23              : 
      24              : #include <array>
      25              : 
      26              : #include "../types/types.h"
      27              : 
      28              : namespace mu::engraving {
      29              : class EngravingItem;
      30              : class MStyle;
      31              : 
      32              : template<typename T>
      33              : struct PaddingVector : std::array<T, TOT_ELEMENT_TYPES>
      34              : {
      35    135869888 :     T& operator [](size_t i) { return std::array<T, TOT_ELEMENT_TYPES>::operator [](i); }
      36      8786424 :     T& operator [](ElementType et) { return std::array<T, TOT_ELEMENT_TYPES>::operator [](static_cast<size_t>(et)); }
      37      8255173 :     const T& at(ElementType et) const { return std::array<T, TOT_ELEMENT_TYPES>::at(static_cast<size_t>(et)); }
      38              : };
      39              : 
      40              : struct PaddingTable : public PaddingVector<PaddingVector<double> >
      41              : {
      42              : public:
      43              :     void update(const MStyle& style);
      44              : 
      45              : private:
      46              :     void init(double minPadUnit);
      47              : };
      48              : 
      49              : struct ParenPaddingTable
      50              : {
      51              : public:
      52         8380 :     virtual ~ParenPaddingTable() = default;
      53              : 
      54              :     virtual void update(const MStyle& style) = 0;
      55              :     double padding(ElementType type1, ElementType type2) const;
      56              : 
      57              : protected:
      58              :     void init(double minPadUnit);
      59              :     PaddingVector<double> m_parenBefore;
      60              :     PaddingVector<double> m_parenAfter;
      61              : };
      62              : 
      63              : struct NoteParenPaddingTable : public ParenPaddingTable {
      64              :     void update(const MStyle& style) override;
      65              : };
      66              : 
      67              : struct KeySigParenPaddingTable : public ParenPaddingTable {
      68              :     void update(const MStyle& style) override;
      69              : };
      70              : 
      71              : struct TimeSigParenPaddingTable : public ParenPaddingTable {
      72              :     void update(const MStyle& style) override;
      73              : };
      74              : 
      75              : struct ClefParenPaddingTable : public ParenPaddingTable {
      76              :     void update(const MStyle& style) override;
      77              : };
      78              : 
      79              : struct ParenPaddingTables {
      80         2792 :     void update(const MStyle& style)
      81              :     {
      82         2792 :         noteParenPaddingTable.update(style);
      83         2792 :         keySigParenPaddingTable.update(style);
      84         2792 :         timeSigParenPaddingTable.update(style);
      85         2792 :         clefParenPaddingTable.update(style);
      86         2792 :     }
      87              : 
      88              :     const ParenPaddingTable& getTableFor(const EngravingItem* item) const;
      89              : 
      90              : private:
      91              :     NoteParenPaddingTable noteParenPaddingTable;
      92              :     KeySigParenPaddingTable keySigParenPaddingTable;
      93              :     TimeSigParenPaddingTable timeSigParenPaddingTable;
      94              :     ClefParenPaddingTable clefParenPaddingTable;
      95              : };
      96              : 
      97              : struct PaddingTables {
      98      4512954 :     const PaddingTable& horizontalPaddingTable() const { return m_horizontalPaddingTable; }
      99        61067 :     const ParenPaddingTable& parenthesisPaddingTableFor(const EngravingItem* item) const { return m_parenPaddingTables.getTableFor(item); }
     100              : 
     101         2792 :     void update(const MStyle& style)
     102              :     {
     103         2792 :         m_horizontalPaddingTable.update(style);
     104         2792 :         m_parenPaddingTables.update(style);
     105         2792 :     }
     106              : 
     107              : private:
     108              :     PaddingTable m_horizontalPaddingTable;
     109              :     ParenPaddingTables m_parenPaddingTables;
     110              : };
     111              : }
        

Generated by: LCOV version 2.0-1