LCOV - code coverage report
Current view: top level - src/engraving/dom - mscore.h Coverage Total Hit
Test: filtered_coverage.info Lines: 73.7 % 19 14
Test Date: 2026-11-19 04:14:36

            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 "global/containers.h"
      26              : 
      27              : #include "engraving/types/constants.h"
      28              : #include "engraving/types/types.h"
      29              : 
      30              : namespace mu::engraving {
      31       541941 : inline constexpr track_idx_t staff2track(staff_idx_t staffIdx, voice_idx_t voiceIdx = 0)
      32              : {
      33       541941 :     return staffIdx != muse::nidx ? staffIdx * MAX_VOICES + voiceIdx : muse::nidx;
      34              : }
      35              : 
      36     41475148 : inline constexpr staff_idx_t track2staff(track_idx_t track)
      37              : {
      38     41475148 :     return track != muse::nidx ? track / MAX_VOICES : muse::nidx;
      39              : }
      40              : 
      41      2775975 : inline constexpr voice_idx_t track2voice(track_idx_t track)
      42              : {
      43      2775975 :     return track != muse::nidx ? track % MAX_VOICES : muse::nidx;
      44              : }
      45              : 
      46        12310 : inline constexpr track_idx_t trackZeroVoice(track_idx_t track)
      47              : {
      48        12310 :     return track != muse::nidx ? (track / MAX_VOICES) * MAX_VOICES : muse::nidx;
      49              : }
      50              : 
      51           13 : inline constexpr bool isUpVoice(voice_idx_t voiceIdx)
      52              : {
      53           13 :     return !(voiceIdx & 1);
      54              : }
      55              : 
      56              : inline constexpr bool isDownVoice(voice_idx_t voiceIdx)
      57              : {
      58              :     return voiceIdx & 1;
      59              : }
      60              : 
      61              : static constexpr int MAX_HEADERS = 3;
      62              : static constexpr int MAX_FOOTERS = 3;
      63              : 
      64              : // UNIVERSAL UNITS
      65              : static constexpr double INCH      = 25.4; // millimitres per inch
      66              : static constexpr double PPI       = 72.0; // typographical points per inch
      67              : 
      68              : // INTERNAL DRAWING UNITS
      69              : static constexpr double DPI = 1200;
      70              : static constexpr double DPMM = DPI / INCH;
      71              : 
      72              : static constexpr double UI_ICONS_DEFAULT_FONT_SIZE = 12.0;
      73              : 
      74              : static constexpr int MAX_STAVES = 4;
      75              : 
      76              : static constexpr char mimeSymbolFormat[]     = "application/musescore/symbol";
      77              : static constexpr char mimeSymbolListFormat[] = "application/musescore/symbollist";
      78              : static constexpr char mimeStaffListFormat[]  = "application/musescore/stafflist";
      79              : 
      80              : static constexpr int INVALID_STRING_INDEX = -1; // no ordinal for a physical string (0 = topmost in instrument)
      81              : static constexpr int INVALID_FRET_INDEX   = -1; // no ordinal for a fret
      82              : 
      83              : static constexpr muse::ID INVALID_ID = 0;
      84              : 
      85              : //---------------------------------------------------------
      86              : //   TransposeDirection
      87              : //---------------------------------------------------------
      88              : 
      89              : enum class TransposeDirection : char {
      90              :     UP, DOWN, CLOSEST, UNKNOWN
      91              : };
      92              : 
      93              : //---------------------------------------------------------
      94              : //   TransposeMode
      95              : //---------------------------------------------------------
      96              : 
      97              : enum class TransposeMode : char {
      98              :     TO_KEY, BY_INTERVAL, DIATONICALLY, UNKNOWN
      99              : };
     100              : 
     101              : //---------------------------------------------------------
     102              : //   SelectType
     103              : //---------------------------------------------------------
     104              : 
     105              : enum class SelectType : char {
     106              :     SINGLE, RANGE, ADD, REPLACE
     107              : };
     108              : 
     109              : //---------------------------------------------------------
     110              : //   OffsetType
     111              : //---------------------------------------------------------
     112              : 
     113              : enum class OffsetType : unsigned char {
     114              :     ABS,         ///< offset in point units
     115              :     SPATIUM      ///< offset in staff space units
     116              : };
     117              : 
     118              : //---------------------------------------------------------
     119              : //   MScoreError
     120              : //---------------------------------------------------------
     121              : 
     122              : enum class MsError : unsigned char {
     123              :     MS_NO_ERROR,
     124              :     NO_NOTE_SELECTED,
     125              :     NO_CHORD_REST_SELECTED,
     126              :     NO_LYRICS_SELECTED,
     127              :     NO_NOTE_REST_SELECTED,
     128              :     NO_FLIPPABLE_SELECTED,
     129              :     NO_MEASURE_SELECTED,
     130              :     NO_STAFF_SELECTED,
     131              :     NO_NOTE_FIGUREDBASS_SELECTED,
     132              :     NO_NOTE_REST_HARMONY_SELECTED,
     133              :     CANNOT_INSERT_TUPLET,
     134              :     CANNOT_SPLIT_TUPLET,
     135              :     CANNOT_SPLIT_MEASURE_FIRST_BEAT,
     136              :     CANNOT_SPLIT_MEASURE_TUPLET,
     137              :     INSUFFICIENT_MEASURES,
     138              :     CANNOT_SPLIT_MEASURE_REPEAT,
     139              :     CANNOT_SPLIT_MEASURE_TOO_SHORT,
     140              :     CANNOT_REMOVE_TIME_TUPLET,
     141              :     CANNOT_REMOVE_TIME_MEASURE_REPEAT,
     142              :     NO_DEST,
     143              :     SOURCE_PARTIAL_TUPLET,
     144              :     DEST_TUPLET,
     145              :     TUPLET_CROSSES_BAR,
     146              :     DEST_LOCAL_TIME_SIGNATURE,
     147              :     SOURCE_PARTIAL_TREMOLO,
     148              :     DEST_TREMOLO,
     149              :     NO_MIME,
     150              :     DEST_NO_CR,
     151              :     CANNOT_CHANGE_LOCAL_TIMESIG_MEASURE_NOT_EMPTY,
     152              :     CANNOT_CHANGE_LOCAL_TIMESIG_HAS_EXCERPTS,
     153              :     CORRUPTED_MEASURE,
     154              :     CANNOT_REMOVE_KEY_SIG,
     155              :     CANNOT_JOIN_MEASURE_STAFFTYPE_CHANGE,
     156              :     CANNOT_REPEAT_SELECTION,
     157              :     TRANSPOSE_NO_FRET_DIAGRAM,
     158              :     CANNOT_EXPLODE_IMPLODE_LOCAL_TIMESIG,
     159              :     NO_SPACE_FOR_TUPLET,
     160              :     TUPLET_NOTE_VALUE_TOO_SHORT,
     161              :     TUPLET_RATIO_NOT_POSSIBLE,
     162              : };
     163              : 
     164              : /// \cond PLUGIN_API \private \endcond
     165              : struct MScoreError {
     166              :     MsError no;
     167              :     const char* group;
     168              :     const char* txt;
     169              : };
     170              : 
     171              : //---------------------------------------------------------
     172              : //   MScore
     173              : //    MuseScore application object
     174              : //---------------------------------------------------------
     175              : 
     176              : class MScore
     177              : {
     178              :     static int _hRaster, _vRaster;
     179              :     static bool _verticalOrientation;
     180              : 
     181              : public:
     182              : 
     183              :     static MsError _error;
     184              :     static bool _errorIsWarning;
     185              : 
     186              :     static void registerUiTypes();
     187              : 
     188            0 :     static double hRaster() { return _hRaster; }
     189            0 :     static double vRaster() { return _vRaster; }
     190            0 :     static void setHRaster(int val) { _hRaster = val; }
     191            0 :     static void setVRaster(int val) { _vRaster = val; }
     192           18 :     static void setNudgeStep(double val) { nudgeStep = val; }
     193           18 :     static void setNudgeStep10(double val) { nudgeStep10 = val; }
     194              : 
     195          166 :     static bool verticalOrientation() { return _verticalOrientation; }
     196            0 :     static void setVerticalOrientation(bool val) { _verticalOrientation = val; }
     197              : 
     198              :     static bool warnPitchRange;
     199              :     static bool warnGuitarBends;
     200              :     static int pedalEventsMinTicks;
     201              : 
     202              :     static double nudgeStep;
     203              :     static double nudgeStep10;
     204              : 
     205              : // #ifndef NDEBUG
     206              :     static bool noHorizontalStretch;
     207              :     static bool noVerticalStretch;
     208              :     static bool useFallbackFont;
     209              : // #endif
     210              :     static bool debugMode;
     211              :     static bool testMode;
     212              :     static bool testWriteStyleToScore;
     213              : 
     214              :     static bool saveTemplateMode;
     215              :     static bool noGui;
     216              : 
     217              :     static bool noImages;
     218              : 
     219              :     static bool pdfPrinting;
     220              :     static bool svgPrinting;
     221              : 
     222              :     static double verticalPageGap;
     223              :     static double horizontalPageGapEven;
     224              :     static double horizontalPageGapOdd;
     225              : 
     226         1561 :     static void setError(MsError e, bool warning = false) { _error = e; _errorIsWarning = warning; }
     227              : 
     228              :     static std::string errorToString(MsError err);
     229              : };
     230              : } // namespace mu::engraving
        

Generated by: LCOV version 2.0-1