LCOV - code coverage report
Current view: top level - src/engraving/dom - input.h Coverage Total Hit
Test: filtered_coverage.info Lines: 63.6 % 33 21
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              : #ifndef MU_ENGRAVING_INPUT_H
      24              : #define MU_ENGRAVING_INPUT_H
      25              : 
      26              : #include <set>
      27              : 
      28              : #include "accidental.h"
      29              : #include "chord.h"
      30              : #include "durationtype.h"
      31              : #include "mscore.h"
      32              : #include "noteval.h"
      33              : 
      34              : #include "../types/types.h"
      35              : 
      36              : namespace mu::engraving {
      37              : class ChordRest;
      38              : class Drumset;
      39              : class EngravingItem;
      40              : class Note;
      41              : class Score;
      42              : class Segment;
      43              : class Selection;
      44              : class Slur;
      45              : class Staff;
      46              : 
      47              : // no ordinal for the visual repres. of string
      48              : // (topmost in TAB varies according to visual order and presence of bass strings)
      49              : static constexpr int VISUAL_INVALID_STRING_INDEX = -100;
      50              : 
      51              : //---------------------------------------------------------
      52              : //   NoteEntryMethod
      53              : //---------------------------------------------------------
      54              : 
      55              : enum class NoteEntryMethod : char {
      56              :     UNKNOWN, BY_NOTE_NAME, BY_DURATION, REPITCH, RHYTHM, REALTIME_AUTO, REALTIME_MANUAL, TIMEWISE
      57              : };
      58              : 
      59              : //---------------------------------------------------------
      60              : //   InputState
      61              : //---------------------------------------------------------
      62              : 
      63              : class InputState
      64              : {
      65              : public:
      66              :     bool isValid() const;
      67              : 
      68              :     ChordRest* cr() const;
      69              : 
      70              :     Fraction tick() const;
      71              : 
      72          103 :     void setDuration(const TDuration& d) { m_duration = d; }
      73          144 :     TDuration duration() const { return m_duration; }
      74              :     void setDots(int n);
      75            0 :     Fraction ticks() const { return m_duration.ticks(); }
      76              : 
      77         1823 :     Segment* segment() const { return m_segment; }
      78              :     void setSegment(Segment* s);
      79              : 
      80           20 :     Segment* lastSegment() const { return m_lastSegment; }
      81         1341 :     void setLastSegment(Segment* s) { m_lastSegment = s; }
      82              : 
      83              :     Staff* staff() const;
      84              :     staff_idx_t staffIdx() const;
      85              : 
      86              :     Drumset* drumset() const;
      87              : 
      88            0 :     int drumNote() const { return m_drumNote; }
      89           25 :     void setDrumNote(int v) { m_drumNote = v; }
      90              : 
      91              :     // Used in the input-by-duration mode
      92            0 :     const NoteValList& notes() const { return m_notes; }
      93            0 :     void setNotes(const NoteValList& v) { m_notes = v; }
      94              : 
      95           43 :     voice_idx_t voice() const { return m_track == muse::nidx ? 0 : (m_track % VOICES); }
      96              :     void setVoice(voice_idx_t v);
      97          279 :     track_idx_t track() const { return m_track; }
      98         1478 :     void setTrack(track_idx_t v) { m_prevTrack = m_track; m_track = v; }
      99            0 :     track_idx_t prevTrack() const { return m_prevTrack; }
     100              : 
     101            0 :     int string() const { return m_string; }
     102            0 :     void setString(int val) { m_string = val; }
     103              : 
     104              :     StaffGroup staffGroup() const;
     105              : 
     106           25 :     bool rest() const { return m_rest; }
     107           20 :     void setRest(bool v) { m_rest = v; }
     108              : 
     109              :     NoteType noteType() const { return m_noteType; }
     110            0 :     void setNoteType(NoteType t) { m_noteType = t; }
     111              : 
     112              :     BeamMode beamMode() const { return m_beamMode; }
     113            0 :     void setBeamMode(BeamMode m) { m_beamMode = m; }
     114              : 
     115          269 :     bool noteEntryMode() const { return m_noteEntryMode; }
     116           20 :     void setNoteEntryMode(bool v) { m_noteEntryMode = v; }
     117              : 
     118          544 :     NoteEntryMethod noteEntryMethod() const { return m_noteEntryMethod; }
     119           11 :     void setNoteEntryMethod(NoteEntryMethod m) { m_noteEntryMethod = m; }
     120          438 :     bool usingNoteEntryMethod(NoteEntryMethod m) const { return m == noteEntryMethod(); }
     121              : 
     122          115 :     AccidentalType accidentalType() const { return m_accidentalType; }
     123           96 :     void setAccidentalType(AccidentalType val) { m_accidentalType = val; }
     124              : 
     125          100 :     const std::set<SymId>& articulationIds() const { return m_articulationIds; }
     126            0 :     void setArticulationIds(const std::set<SymId>& ids) { m_articulationIds = ids; }
     127              : 
     128         1212 :     Slur* slur() const { return m_slur; }
     129            0 :     void setSlur(Slur* s) { m_slur = s; }
     130              : 
     131              :     void update(Selection& selection);
     132              :     void moveInputPos(EngravingItem* e);
     133              :     void moveToNextInputPos();
     134              : 
     135           98 :     bool beyondScore() const { return m_beyondScore; }
     136            0 :     void setBeyondScore(bool val) { m_beyondScore = val; }
     137              : 
     138              :     // TODO: unify with Selection::cr()?
     139              :     static Note* note(EngravingItem*);
     140              :     static ChordRest* chordRest(EngravingItem*);
     141              : 
     142              : private:
     143              : 
     144              :     Segment* nextInputPos() const;
     145              : 
     146              :     track_idx_t m_track = 0;
     147              :     track_idx_t m_prevTrack = 0; // used for navigation
     148              : 
     149              :     int m_drumNote = -1;
     150              :     int m_string = VISUAL_INVALID_STRING_INDEX; // visual string selected for input (TAB staves only)
     151              : 
     152              :     NoteValList m_notes;
     153              : 
     154              :     Segment* m_lastSegment = nullptr;
     155              :     Segment* m_segment = nullptr; // current segment
     156              : 
     157              :     bool m_noteEntryMode = false;
     158              :     NoteEntryMethod m_noteEntryMethod = NoteEntryMethod::BY_NOTE_NAME;
     159              : 
     160              :     TDuration m_duration = DurationType::V_INVALID; // currently duration
     161              :     bool m_rest = false; // rest mode
     162              : 
     163              :     NoteType m_noteType = NoteType::NORMAL;
     164              :     BeamMode m_beamMode = BeamMode::AUTO;
     165              : 
     166              :     AccidentalType m_accidentalType = AccidentalType::NONE;
     167              :     Slur* m_slur = nullptr;
     168              : 
     169              :     std::set<SymId> m_articulationIds;
     170              : 
     171              :     bool m_beyondScore = false;
     172              : };
     173              : } // namespace mu::engraving
     174              : #endif
        

Generated by: LCOV version 2.0-1