LCOV - code coverage report
Current view: top level - src/engraving/rendering/score - harmonylayout.h Coverage Total Hit
Test: filtered_coverage.info Lines: 100.0 % 6 6
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 <stack>
      25              : #include <vector>
      26              : 
      27              : #include "layoutcontext.h"
      28              : #include "dom/harmony.h"
      29              : 
      30              : namespace mu::engraving {
      31              : class Segment;
      32              : class System;
      33              : }
      34              : 
      35              : namespace mu::engraving::rendering::score {
      36              : class HarmonyLayout
      37              : {
      38              : public:
      39              :     static void layoutHarmony(Harmony* item, Harmony::LayoutData* ldata, const LayoutContext& ctx);
      40              : 
      41              : private:
      42              : 
      43              :     struct HarmonyRenderCtx {
      44              :         PointF pos = PointF(0.0, 0.0);
      45              :         std::vector<HarmonyRenderItem*> renderItemList;
      46              : 
      47              :         // Reset every single chord
      48              :         bool hAlign = true;
      49              :         HarmonyInfo* info = nullptr;
      50              : 
      51              :         // Reset every render() call
      52              :         std::stack<PointF> stack;
      53              :         int tpc = Tpc::TPC_INVALID;
      54              :         NoteSpellingType noteSpelling = NoteSpellingType::STANDARD;
      55              :         NoteCaseType noteCase = NoteCaseType::AUTO;
      56              :         double scale = 1.0;
      57              : 
      58        14388 :         double x() const { return pos.x(); }
      59        10778 :         double y() const { return pos.y(); }
      60              : 
      61           32 :         void setx(double v) { pos.setX(v); }
      62        10682 :         void movex(double v) { pos.setX(pos.x() + v); }
      63           32 :         void sety(double v) { pos.setY(v); }
      64          238 :         void movey(double v) { pos.setY(pos.y() + v); }
      65              :     };
      66              : 
      67              :     static PointF calculateBoundingRect(const Harmony* item, Harmony::LayoutData* ldata, const LayoutContext& ctx);
      68              :     static void layoutModifierParentheses(const Harmony* item, const LayoutContext& ctx);
      69              : 
      70              :     static void render(Harmony* item, Harmony::LayoutData* ldata, const LayoutContext& ctx);
      71              :     static void doRenderSingleHarmony(Harmony* item, Harmony::LayoutData* ldata, HarmonyRenderCtx& harmonyCtx, int rootTpc, int bassTpc,
      72              :                                       const LayoutContext& ctx);
      73              :     static void renderSingleHarmony(Harmony* item, Harmony::LayoutData* ldata, HarmonyRenderCtx& harmonyCtx, const LayoutContext& ctx);
      74              :     static void renderRomanNumeral(Harmony* item, Harmony::LayoutData* ldata);
      75              :     static void render(Harmony* item, Harmony::LayoutData* ldata, const String& str, HarmonyRenderCtx& harmonyCtx);
      76              :     static void render(Harmony* item, Harmony::LayoutData* ldata, SymId sym, HarmonyRenderCtx& harmonyCtx, const LayoutContext& ctx);
      77              :     static void render(Harmony* item, Harmony::LayoutData* ldata, const std::vector<RenderActionPtr>& renderList,
      78              :                        HarmonyRenderCtx& harmonyCtx, const LayoutContext& ctx, int tpc,
      79              :                        NoteSpellingType noteSpelling = NoteSpellingType::STANDARD, NoteCaseType noteCase = NoteCaseType::AUTO,
      80              :                        double noteMag = 1.0);
      81              : 
      82              :     static void renderAction(Harmony* item, Harmony::LayoutData* ldata, const RenderActionPtr& a, HarmonyRenderCtx& harmonyCtx,
      83              :                              const LayoutContext& ctx);
      84              :     static void renderActionSet(Harmony* item, Harmony::LayoutData* ldata, const RenderActionSetPtr& a, HarmonyRenderCtx& harmonyCtx,
      85              :                                 const LayoutContext& ctx);
      86              :     static void renderActionMove(Harmony* item, const RenderActionMovePtr& a, HarmonyRenderCtx& harmonyCtx);
      87              :     static void renderActionMoveXHeight(Harmony* item, const RenderActionMoveXHeightPtr& a, HarmonyRenderCtx& harmonyCtx);
      88              :     static void renderActionPush(HarmonyRenderCtx& harmonyCtx);
      89              :     static void renderActionPop(const RenderActionPopPtr& a, HarmonyRenderCtx& harmonyCtx);
      90              :     static void renderActionNote(Harmony* item, Harmony::LayoutData* ldata, HarmonyRenderCtx& harmonyCtx);
      91              :     static void renderActionAcc(Harmony* item, Harmony::LayoutData* ldata, HarmonyRenderCtx& harmonyCtx, const LayoutContext& ctx);
      92              :     static void renderActionAlign(HarmonyRenderCtx& harmonyCtx);
      93              :     static void renderActionScale(const RenderActionScalePtr& a, HarmonyRenderCtx& harmonyCtx);
      94              :     static void renderActionParen(Harmony* item, const RenderActionParenPtr& a, HarmonyRenderCtx& harmonyCtx);
      95              : 
      96              :     static void kernCharacters(const Harmony* item, const String& text, HarmonyRenderCtx& harmonyCtx, const LayoutContext& ctx);
      97              : };
      98              : }
        

Generated by: LCOV version 2.0-1