LCOV - code coverage report
Current view: top level - src/notation/internal - notationselection.h Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 1 0
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) 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 "../inotationselection.h"
      26              : 
      27              : #include "igetscore.h"
      28              : #include "../notationtypes.h"
      29              : #include "../inotationelements.h"
      30              : 
      31              : namespace mu::notation {
      32              : //! NOTE Helper interface,
      33              : // which contains interaction methods called in the selection.
      34              : // This may not be necessary after refactoring,
      35              : // or it could be implemented differently.
      36              : class IInteractionForSelection
      37              : {
      38              : public:
      39              : 
      40            0 :     virtual ~IInteractionForSelection() = default;
      41              : 
      42              :     virtual void showItem(const mu::engraving::EngravingItem* item, int staffIndex = -1) = 0;
      43              :     virtual void resetHitElementContext() = 0;
      44              : 
      45              :     virtual bool isTextEditingStarted() const = 0;
      46              :     virtual void selectAllText() = 0;
      47              :     virtual bool isEditingElement() const = 0;
      48              :     virtual void navigateToNearText(MoveDirection direction) = 0;
      49              :     virtual void endEditElement() = 0;
      50              :     virtual void startEditElement(EngravingItem* element) = 0;
      51              : 
      52              :     virtual INotationElementsPtr elements() const = 0;
      53              : };
      54              : 
      55              : class NotationSelection : public INotationSelection
      56              : {
      57              : public:
      58              :     NotationSelection(IGetScore* getScore, IInteractionForSelection* interaction);
      59              : 
      60              :     bool isNone() const override;
      61              :     bool isSingle() const override;
      62              :     bool isRange() const override;
      63              :     SelectionState state() const override;
      64              : 
      65              :     muse::Ret canCopy() const override;
      66              :     muse::ByteArray mimeData() const override;
      67              :     QMimeData* qMimeData() const override;
      68              : 
      69              :     engraving::EngravingItem* element() const override;
      70              :     const std::vector<engraving::EngravingItem*>& elements() const override;
      71              : 
      72              :     std::vector<engraving::Note*> notes(NoteFilter filter) const override;
      73              : 
      74              :     muse::RectF canvasBoundingRect() const override;
      75              : 
      76              :     INotationSelectionRangePtr range() const override;
      77              : 
      78              :     engraving::EngravingItem* lastElementHit() const override;
      79              : 
      80              :     void onElementHit(engraving::EngravingItem*);
      81              : 
      82              :     mu::engraving::MeasureBase* startMeasureBase() const override;
      83              :     mu::engraving::MeasureBase* endMeasureBase() const override;
      84              :     std::vector<mu::engraving::MeasureBase*> measureBasesInSelection() const override;
      85              :     std::vector<mu::engraving::System*> selectedSystems() const override;
      86              :     std::vector<mu::engraving::Page*> pagesContainingSelection() const override;
      87              : 
      88              :     bool elementsSelected(const mu::engraving::ElementTypeSet& types) const override;
      89              : 
      90              :     void select(SelectionTarget target);
      91              :     void addToSelection(SelectionTarget target);
      92              :     void select(const std::vector<EngravingItem*>& elements, SelectType type = SelectType::REPLACE, staff_idx_t staffIndex = 0);
      93              :     void clearSelection();
      94              :     muse::async::Notification selectionChanged() const;
      95              :     void notifyAboutSelectionChangedIfNeed();
      96              :     void moveSelection(MoveDirection d, MoveSelectionType type);
      97              : 
      98              : private:
      99              :     mu::engraving::Score* score() const;
     100              : 
     101              :     void doSelect(const std::vector<EngravingItem*>& elements, SelectType type, engraving::staff_idx_t staffIndex = 0);
     102              : 
     103              :     void selectElementsWithSameTypeOnSegment(mu::engraving::ElementType elementType, mu::engraving::Segment* segment);
     104              :     void selectFirstElement(bool frame = false);
     105              :     void selectLastElement();
     106              :     void addToSelection(MoveDirection d, MoveSelectionType type);
     107              :     void moveElementSelection(MoveDirection d);
     108              :     void moveStringSelection(MoveDirection d);
     109              :     void moveSegmentSelection(MoveDirection d);
     110              :     void moveChordNoteSelection(MoveDirection d);
     111              :     void selectTopOrBottomOfChord(MoveDirection d);
     112              :     void selectTopStaff();
     113              :     void selectEmptyTrailingMeasure();
     114              :     void selectAllSimilarElements();
     115              :     void selectAllSimilarElementsInStaff();
     116              :     void selectAllSimilarElementsInRange();
     117              :     void selectAllNotesInChord();
     118              :     FilterElementsOptions elementsFilterOptions(const EngravingItem* element) const;
     119              :     void selectAll();
     120              :     void selectSection();
     121              : 
     122              :     ChordRest* activeCr(const mu::engraving::Score* score) const;
     123              : 
     124              :     engraving::EngravingItem* m_lastElementHit = nullptr;
     125              :     IGetScore* m_getScore = nullptr;
     126              :     IInteractionForSelection* m_interaction = nullptr;
     127              :     INotationSelectionRangePtr m_range;
     128              :     muse::async::Notification m_selectionChanged;
     129              : };
     130              : }
        

Generated by: LCOV version 2.0-1