LCOV - code coverage report
Current view: top level - src/engraving/editing - cmd.h Coverage Total Hit
Test: filtered_coverage.info Lines: 100.0 % 9 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) 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 <vector>
      25              : 
      26              : #include "../dom/engravingobject.h"
      27              : #include "../types/types.h"
      28              : 
      29              : namespace mu::engraving {
      30              : //---------------------------------------------------------
      31              : //   UpdateState
      32              : //---------------------------------------------------------
      33              : 
      34              : struct UpdateState
      35              : {
      36              :     RectF refresh;           ///< area to update, canvas coordinates
      37              :     bool playNote = false;       ///< play selected note after command
      38              :     bool playChord = false;      ///< play whole chord for the selected note
      39              :     bool selectionChanged = false;
      40              : };
      41              : 
      42              : //---------------------------------------------------------
      43              : //   CmdState
      44              : //
      45              : //    the following variables are reset on startCmd()
      46              : //    modified during cmd processing and used in endCmd() to
      47              : //    determine what to layout and what to repaint:
      48              : //---------------------------------------------------------
      49              : 
      50              : class CmdState
      51              : {
      52              : public:
      53              :     LayoutFlags layoutFlags;
      54              : 
      55              :     bool excerptsChanged = false;
      56              :     bool instrumentsChanged = false;
      57              : 
      58              :     void reset();
      59              :     UpdateMode updateMode() const { return m_updateMode; }
      60              :     void setUpdateMode(UpdateMode m);
      61              :     void _setUpdateMode(UpdateMode m);
      62         1597 :     bool layoutRange() const { return m_updateMode == UpdateMode::Layout; }
      63          495 :     bool updateAll() const { return int(m_updateMode) >= int(UpdateMode::UpdateAll); }
      64          442 :     bool updateRange() const { return m_updateMode == UpdateMode::Update; }
      65              :     void setTick(const Fraction& t);
      66              :     void setStaff(staff_idx_t staff);
      67              :     void setElement(const EngravingItem* e);
      68              :     void unsetElement(const EngravingItem* e);
      69         2557 :     Fraction startTick() const { return m_startTick; }
      70         2557 :     Fraction endTick() const { return m_endTick; }
      71         1467 :     staff_idx_t startStaff() const { return m_startStaff; }
      72         1467 :     staff_idx_t endStaff() const { return m_endStaff; }
      73              :     const EngravingItem* element() const;
      74              : 
      75              :     void deleteLater(EngravingObject* e);
      76              :     std::vector<EngravingObject*> takePostponedDeletions();
      77              : 
      78         4000 :     void lock() { m_locked = true; }
      79         4000 :     void unlock() { m_locked = false; }
      80              : #ifndef NDEBUG
      81              :     void dump();
      82              : #endif
      83              : 
      84              : private:
      85              :     void setMeasureBase(const MeasureBase* mb);
      86              : 
      87              :     UpdateMode m_updateMode = UpdateMode::DoNothing;
      88              :     Fraction m_startTick { -1, 1 };            // start tick for mode LayoutTick
      89              :     Fraction m_endTick   { -1, 1 };              // end tick for mode LayoutTick
      90              :     staff_idx_t m_startStaff = muse::nidx;
      91              :     staff_idx_t m_endStaff = muse::nidx;
      92              :     const EngravingItem* m_el = nullptr;
      93              :     const MeasureBase* m_mb = nullptr;
      94              :     bool m_oneElement = true;
      95              :     bool m_oneMeasureBase = true;
      96              :     std::vector<EngravingObject*> m_postponedDeletions;
      97              : 
      98              :     bool m_locked = false;
      99              : };
     100              : }
        

Generated by: LCOV version 2.0-1