LCOV - code coverage report
Current view: top level - src/notation - notationtypes.h Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 19 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 <QPixmap>
      26              : #include <QDate>
      27              : #include <string>
      28              : 
      29              : #include "global/containers.h"
      30              : 
      31              : #include "engraving/dom/articulation.h"
      32              : #include "engraving/dom/chord.h"
      33              : #include "engraving/dom/durationtype.h"
      34              : #include "engraving/dom/engravingitem.h"
      35              : #include "engraving/dom/guitarbend.h"
      36              : #include "engraving/dom/hairpin.h"
      37              : #include "engraving/dom/hook.h"
      38              : #include "engraving/dom/key.h"
      39              : #include "engraving/dom/measure.h"
      40              : #include "engraving/dom/mscore.h"
      41              : #include "engraving/dom/note.h"
      42              : #include "engraving/dom/ottava.h"
      43              : #include "engraving/dom/page.h"
      44              : #include "engraving/dom/rest.h"
      45              : #include "engraving/dom/slur.h"
      46              : #include "engraving/dom/stem.h"
      47              : #include "engraving/dom/system.h"
      48              : #include "engraving/dom/timesig.h"
      49              : #include "engraving/types/types.h"
      50              : 
      51              : namespace mu::notation {
      52              : using Page = mu::engraving::Page;
      53              : using System = mu::engraving::System;
      54              : using EngravingItem = mu::engraving::EngravingItem;
      55              : using ElementType = mu::engraving::ElementType;
      56              : using Note = mu::engraving::Note;
      57              : using Measure = mu::engraving::Measure;
      58              : using DurationType = mu::engraving::DurationType;
      59              : using Duration = mu::engraving::TDuration;
      60              : using SelectType = mu::engraving::SelectType;
      61              : using SymbolId = mu::engraving::SymId;
      62              : using Key = mu::engraving::Key;
      63              : using KeyMode = mu::engraving::KeyMode;
      64              : using TimeSigType = mu::engraving::TimeSigType;
      65              : using TimeSignature = mu::engraving::TimeSig;
      66              : using NoteHead = mu::engraving::NoteHead;
      67              : using TransposeMode = mu::engraving::TransposeMode;
      68              : using TransposeDirection = mu::engraving::TransposeDirection;
      69              : using Fraction = mu::engraving::Fraction;
      70              : using Chord = mu::engraving::Chord;
      71              : using ChordRest = mu::engraving::ChordRest;
      72              : using Articulation = mu::engraving::Articulation;
      73              : using SlurSegment = mu::engraving::SlurSegment;
      74              : using Rest = mu::engraving::Rest;
      75              : using Stem = mu::engraving::Stem;
      76              : using Hook = mu::engraving::Hook;
      77              : using Fraction = mu::engraving::Fraction;
      78              : using AccidentalType = mu::engraving::AccidentalType;
      79              : using OttavaType = mu::engraving::OttavaType;
      80              : using HairpinType = mu::engraving::HairpinType;
      81              : using TextBase = mu::engraving::TextBase;
      82              : using GraceNoteType = mu::engraving::NoteType;
      83              : using BeamMode = mu::engraving::BeamMode;
      84              : using LayoutBreakType = mu::engraving::LayoutBreakType;
      85              : using Interval = mu::engraving::Interval;
      86              : using BracketType = mu::engraving::BracketType;
      87              : using Segment = mu::engraving::Segment;
      88              : using TextStyleType = mu::engraving::TextStyleType;
      89              : using PageList = std::vector<Page*>;
      90              : using voice_idx_t = mu::engraving::voice_idx_t;
      91              : using track_idx_t = mu::engraving::track_idx_t;
      92              : using staff_idx_t = mu::engraving::staff_idx_t;
      93              : using GuitarBendType = mu::engraving::GuitarBendType;
      94              : using Pid = mu::engraving::Pid;
      95              : using VoiceAssignment = mu::engraving::VoiceAssignment;
      96              : 
      97              : enum class DragMode : unsigned char
      98              : {
      99              :     BothXY = 0,
     100              :     OnlyX,
     101              :     OnlyY
     102              : };
     103              : 
     104              : enum class MoveDirection : unsigned char
     105              : {
     106              :     Undefined = 0,
     107              :     Left,
     108              :     Right,
     109              :     Up,
     110              :     Down
     111              : };
     112              : 
     113              : enum class SelectionTarget : unsigned char
     114              : {
     115              :     Undefined = 0,
     116              :     FirstItem,
     117              :     LastItem,
     118              :     NextItem,
     119              :     PrevItem,
     120              :     NextSegmentItem,
     121              :     PrevSegmentItem,
     122              :     NextChord,
     123              :     PrevChord,
     124              :     NextMeasure,
     125              :     PrevMeasure,
     126              :     NextTrack,
     127              :     PrevTrack,
     128              :     NextFrame,
     129              :     PrevFrame,
     130              :     NextSystem,
     131              :     PrevSystem,
     132              :     AboveStaff,
     133              :     BelowStaff,
     134              :     UpNoteInChord,
     135              :     DownNoteInChord,
     136              :     TopNoteInChord,
     137              :     BottomNoteInChord,
     138              :     TopStaff,
     139              :     EmptyTrailingMeasure,
     140              :     Similar,
     141              :     SimilarInStaff,
     142              :     SimilarInRange,
     143              :     NotesInChord,
     144              :     All,
     145              :     Section,
     146              : };
     147              : 
     148              : enum PlayMode {
     149              :     NoPlay, PlayNote, PlayChord
     150              : };
     151              : 
     152              : enum class MoveSelectionType : unsigned char
     153              : {
     154              :     Undefined = 0,
     155              :     EngravingItem,
     156              :     Chord,
     157              :     Measure,
     158              :     Track,
     159              :     Frame,
     160              :     System,
     161              :     String // TAB Staff
     162              : };
     163              : 
     164              : enum class ExpandSelectionMode : unsigned char
     165              : {
     166              :     BeginSystem,
     167              :     EndSystem,
     168              :     BeginScore,
     169              :     EndScore,
     170              : };
     171              : 
     172              : enum class AddRemoveSystemLockType : signed char
     173              : {
     174              :     AfterEachSystem = -1,
     175              :     None = 0,
     176              :     MeasuresInterval
     177              : };
     178              : 
     179              : enum class BoxType : unsigned char
     180              : {
     181              :     Unknown,
     182              :     Vertical,
     183              :     Horizontal,
     184              :     Measure,
     185              :     Text,
     186              :     Fret
     187              : };
     188              : 
     189              : enum class AddBoxesTarget : unsigned char {
     190              :     AfterSelection,
     191              :     BeforeSelection,
     192              :     AtStartOfScore,
     193              :     AtEndOfScore
     194              : };
     195              : 
     196              : enum class NoteName : unsigned char
     197              : {
     198              :     C = 0,
     199              :     D,
     200              :     E,
     201              :     F,
     202              :     G,
     203              :     A,
     204              :     B
     205              : };
     206              : 
     207              : enum class PastingType : unsigned char {
     208              :     Default,
     209              :     Half,
     210              :     Double,
     211              :     Special
     212              : };
     213              : 
     214              : struct FilterElementsOptions
     215              : {
     216              :     ElementType elementType = ElementType::INVALID;
     217              :     int staffStart = -1;
     218              :     int staffEnd = -1;
     219              :     int voice = -1;
     220              :     const mu::engraving::System* system = nullptr;
     221              :     Fraction durationTicks{ -1, 1 };
     222              :     Fraction beat{ 0, 0 };
     223              :     const mu::engraving::Measure* measure = nullptr;
     224              : 
     225              :     bool bySubtype = false;
     226              :     int subtype = -1;
     227              : 
     228              :     bool isValid() const
     229              :     {
     230              :         return elementType != ElementType::INVALID;
     231              :     }
     232              : 
     233            0 :     virtual ~FilterElementsOptions() = default;
     234              : };
     235              : 
     236              : struct FilterNotesOptions : FilterElementsOptions
     237              : {
     238              :     int pitch = -1;
     239              :     int string = mu::engraving::INVALID_STRING_INDEX;
     240              :     int tpc = mu::engraving::Tpc::TPC_INVALID;
     241              :     mu::engraving::NoteHeadGroup notehead = mu::engraving::NoteHeadGroup::HEAD_INVALID;
     242              :     mu::engraving::TDuration durationType = mu::engraving::TDuration();
     243              :     mu::engraving::NoteType noteType = mu::engraving::NoteType::INVALID;
     244              : };
     245              : 
     246              : struct TransposeOptions
     247              : {
     248              :     TransposeMode mode = TransposeMode::UNKNOWN;
     249              :     TransposeDirection direction = TransposeDirection::UNKNOWN;
     250              :     Key key = Key::C;
     251              :     int interval = 0;
     252              :     bool needTransposeKeys = false;
     253              :     bool needTransposeChordNames = false;
     254              :     bool needTransposeDoubleSharpsFlats = false;
     255              : };
     256              : 
     257              : enum class ScoreConfigType : unsigned char
     258              : {
     259              :     ShowInvisibleElements,
     260              :     ShowUnprintableElements,
     261              :     ShowFrames,
     262              :     ShowPageMargins,
     263              :     ShowSoundFlags,
     264              :     MarkIrregularMeasures
     265              : };
     266              : 
     267              : struct ScoreConfig
     268              : {
     269              :     std::map<ScoreConfigType, bool> config = {
     270              :         { ScoreConfigType::ShowInvisibleElements, false },
     271              :         { ScoreConfigType::ShowUnprintableElements, false },
     272              :         { ScoreConfigType::ShowFrames, false },
     273              :         { ScoreConfigType::ShowPageMargins, false },
     274              :         { ScoreConfigType::ShowSoundFlags, false },
     275              :         { ScoreConfigType::MarkIrregularMeasures, false },
     276              :     };
     277              : 
     278            0 :     bool isShown(ScoreConfigType type) const
     279              :     {
     280            0 :         auto it = config.find(type);
     281            0 :         if (it != config.end()) {
     282            0 :             return it->second;
     283              :         }
     284            0 :         return false;
     285              :     }
     286              : 
     287            0 :     void setShown(ScoreConfigType type, bool show)
     288              :     {
     289            0 :         config[type] = show;
     290            0 :     }
     291              : 
     292            0 :     bool operator==(const ScoreConfig& other) const
     293              :     {
     294            0 :         return config == other.config;
     295              :     }
     296              : };
     297              : 
     298              : enum class BracketsType : unsigned char
     299              : {
     300              :     Brackets,
     301              :     Braces,
     302              :     Parentheses
     303              : };
     304              : 
     305              : static constexpr int MIN_NOTES_INTERVAL = -10;
     306              : static constexpr int MAX_NOTES_INTERVAL = 10;
     307              : 
     308              : static constexpr int MAX_FRET = 14;
     309              : 
     310            0 : constexpr bool isNotesIntervalValid(int interval)
     311              : {
     312            0 :     return interval >= MIN_NOTES_INTERVAL && interval <= MAX_NOTES_INTERVAL
     313            0 :            && interval != 0 && interval != -1;
     314              : }
     315              : 
     316            0 : constexpr bool isVoiceIndexValid(voice_idx_t voiceIndex)
     317              : {
     318            0 :     return voiceIndex < mu::engraving::VOICES;
     319              : }
     320              : 
     321            0 : inline bool isVerticalBoxTextStyle(TextStyleType type)
     322              : {
     323              :     static const std::set<TextStyleType> types {
     324              :         TextStyleType::TITLE,
     325              :         TextStyleType::SUBTITLE,
     326              :         TextStyleType::COMPOSER,
     327              :         TextStyleType::LYRICIST,
     328              :         TextStyleType::INSTRUMENT_EXCERPT,
     329            0 :     };
     330              : 
     331            0 :     return muse::contains(types, type);
     332              : }
     333              : 
     334              : static const mu::engraving::ElementTypeSet NOTE_REST_TYPES {
     335              :     mu::engraving::ElementType::NOTE,
     336              :     mu::engraving::ElementType::REST,
     337              : };
     338              : }
        

Generated by: LCOV version 2.0-1