LCOV - code coverage report
Current view: top level - src/engraving/editing - editfretboarddiagram.h Coverage Total Hit
Test: filtered_coverage.info Lines: 69.2 % 39 27
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) 2025 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 "transaction/undoablecommand.h"
      26              : 
      27              : #include "../dom/fret.h"
      28              : 
      29              : namespace mu::engraving {
      30              : class FretUndoData
      31              : {
      32              : public:
      33           36 :     FretUndoData() = default;
      34              :     FretUndoData(FretDiagram* fd);
      35              : 
      36              :     void updateDiagram();
      37              : 
      38              : private:
      39              :     FretDiagram* m_diagram = nullptr;
      40              :     BarreMap m_barres;
      41              :     MarkerMap m_markers;
      42              :     DotMap m_dots;
      43              : 
      44              :     int m_strings = 0;
      45              :     int m_frets = 0;
      46              :     int m_fretOffset = 0;
      47              :     int m_maxFrets = 0;
      48              :     bool m_showNut = true;
      49              :     bool m_showFingering = false;
      50              :     Orientation m_orientation = Orientation::VERTICAL;
      51              :     double m_userMag = 1.0;
      52              : };
      53              : 
      54              : class FretDataChange : public UndoableCommand
      55              : {
      56           64 :     OBJECT_ALLOCATOR(engraving, FretDataChange)
      57              : 
      58              :     FretDiagram* m_diagram = nullptr;
      59              :     FretUndoData m_undoData;
      60              :     String m_harmonyName;
      61              : 
      62              :     void redo() override;
      63              :     void undo() override;
      64              : 
      65              : public:
      66           32 :     FretDataChange(FretDiagram* d, const String& harmonyName)
      67           32 :         : m_diagram(d), m_harmonyName(harmonyName) {}
      68              : 
      69           64 :     UNDO_TYPE(CommandType::FretDataChange)
      70              : 
      71            0 :     UNDO_NAME("FretDataChange")
      72              : 
      73          192 :     UNDO_CHANGED_OBJECTS({ m_diagram })
      74              : };
      75              : 
      76              : class FretDot : public UndoableCommand
      77              : {
      78            2 :     OBJECT_ALLOCATOR(engraving, FretDot)
      79              : 
      80              :     FretDiagram* diagram = nullptr;
      81              :     int string = 0;
      82              :     int fret = 0;
      83              :     bool add = 0;
      84              :     FretDotType dtype;
      85              :     FretUndoData undoData;
      86              : 
      87              :     void redo() override;
      88              :     void undo() override;
      89              : 
      90              : public:
      91            1 :     FretDot(FretDiagram* d, int _string, int _fret, bool _add = false, FretDotType _dtype = FretDotType::NORMAL)
      92            1 :         : diagram(d), string(_string), fret(_fret), add(_add), dtype(_dtype) {}
      93              : 
      94            2 :     UNDO_TYPE(CommandType::FretDot)
      95            0 :     UNDO_NAME("FretDot")
      96            6 :     UNDO_CHANGED_OBJECTS({ diagram })
      97              : };
      98              : 
      99              : class FretMarker : public UndoableCommand
     100              : {
     101            2 :     OBJECT_ALLOCATOR(engraving, FretMarker)
     102              : 
     103              :     FretDiagram* diagram = nullptr;
     104              :     int string = 0;
     105              :     FretMarkerType mtype;
     106              :     FretUndoData undoData;
     107              : 
     108              :     void redo() override;
     109              :     void undo() override;
     110              : 
     111              : public:
     112            1 :     FretMarker(FretDiagram* d, int _string, FretMarkerType _mtype)
     113            1 :         : diagram(d), string(_string), mtype(_mtype) {}
     114              : 
     115            2 :     UNDO_TYPE(CommandType::FretMarker)
     116            0 :     UNDO_NAME("FretMarker")
     117            6 :     UNDO_CHANGED_OBJECTS({ diagram })
     118              : };
     119              : 
     120              : class FretBarre : public UndoableCommand
     121              : {
     122            2 :     OBJECT_ALLOCATOR(engraving, FretBarre)
     123              : 
     124              :     FretDiagram* diagram = nullptr;
     125              :     int string = 0;
     126              :     int fret = 0;
     127              :     bool add = 0;
     128              :     FretUndoData undoData;
     129              : 
     130              :     void redo() override;
     131              :     void undo() override;
     132              : 
     133              : public:
     134            1 :     FretBarre(FretDiagram* d, int _string, int _fret, bool _add = false)
     135            1 :         : diagram(d), string(_string), fret(_fret), add(_add) {}
     136              : 
     137            2 :     UNDO_TYPE(CommandType::FretBarre)
     138            0 :     UNDO_NAME("FretBarre")
     139            6 :     UNDO_CHANGED_OBJECTS({ diagram })
     140              : };
     141              : 
     142              : class FretClear : public UndoableCommand
     143              : {
     144            2 :     OBJECT_ALLOCATOR(engraving, FretClear)
     145              : 
     146              :     FretDiagram* diagram = nullptr;
     147              :     FretUndoData undoData;
     148              : 
     149              :     void redo() override;
     150              :     void undo() override;
     151              : 
     152              : public:
     153            1 :     FretClear(FretDiagram* d)
     154            1 :         : diagram(d) {}
     155              : 
     156            2 :     UNDO_TYPE(CommandType::FretClear)
     157            0 :     UNDO_NAME("FretClear")
     158            6 :     UNDO_CHANGED_OBJECTS({ diagram })
     159              : };
     160              : 
     161              : class AddFretDiagramToFretBox : public UndoableCommand
     162              : {
     163           44 :     OBJECT_ALLOCATOR(engraving, AddFretDiagramToFretBox)
     164              : 
     165              :     FretDiagram* m_fretDiagram = nullptr;
     166              :     size_t m_idx = muse::nidx;
     167              : 
     168              :     void redo() override;
     169              :     void undo() override;
     170              : 
     171              : public:
     172              :     AddFretDiagramToFretBox(FretDiagram* f, size_t idx);
     173              : 
     174            0 :     UNDO_TYPE(CommandType::AddFretDiagramToFretBox)
     175            0 :     UNDO_NAME("AddFretDiagramToFretBox")
     176            0 :     UNDO_CHANGED_OBJECTS({ m_fretDiagram })
     177              : };
     178              : 
     179              : class RemoveFretDiagramFromFretBox : public UndoableCommand
     180              : {
     181            0 :     OBJECT_ALLOCATOR(engraving, RemoveFretDiagramFromFretBox)
     182              : 
     183              :     FretDiagram* m_fretDiagram = nullptr;
     184              :     size_t m_idx = muse::nidx;
     185              : 
     186              :     void redo() override;
     187              :     void undo() override;
     188              : 
     189              : public:
     190              :     RemoveFretDiagramFromFretBox(FretDiagram* f);
     191              : 
     192            0 :     UNDO_TYPE(CommandType::RemoveFretDiagramFromFretBox)
     193            0 :     UNDO_NAME("RemoveFretDiagramFromFretBox")
     194            0 :     UNDO_CHANGED_OBJECTS({ m_fretDiagram })
     195              : };
     196              : }
        

Generated by: LCOV version 2.0-1