LCOV - code coverage report
Current view: top level - src/engraving/dom - stafflines.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 46.7 % 30 14
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              : #include "stafflines.h"
      24              : 
      25              : #include "measure.h"
      26              : #include "score.h"
      27              : #include "staff.h"
      28              : #include "system.h"
      29              : 
      30              : using namespace mu;
      31              : 
      32              : // Anatomy of StaffLines:
      33              : //
      34              : //    step         - The possible vertical positions of a note are counted as steps.
      35              : //                   The top staff line is step position zero.
      36              : //    lines        - number of visible staff lines
      37              : //    lineDistance - The distance between lines, measured in step units. A standard five line
      38              : //                   staff has a line distance of two steps.
      39              : //    stepDistance - The distance between steps measured in scaled spatium/2 units. A standard five
      40              : //                   line staff has a step distance of 0.5 which results in a line distance of
      41              : //                   one spatium. The spatium unit is scaled by staff size.
      42              : //    yoffset      - vertical offset to align with other staves of different height
      43              : //    stepOffset   - This value changes the staff line step numbering.
      44              : //
      45              : 
      46              : namespace mu::engraving {
      47              : //---------------------------------------------------------
      48              : //   StaffLines
      49              : //---------------------------------------------------------
      50              : 
      51        24600 : StaffLines::StaffLines(DummyParentOr<Measure> parent)
      52        24600 :     : EngravingItem(ElementType::STAFF_LINES, parent)
      53              : {
      54        24600 :     setSelectable(false);
      55        24600 : }
      56              : 
      57              : //---------------------------------------------------------
      58              : //   pagePos
      59              : //---------------------------------------------------------
      60              : 
      61         1077 : PointF StaffLines::pagePos() const
      62              : {
      63         1077 :     System* system = measure()->system();
      64         1077 :     return PointF(measure()->x() + system->x(), system->staff(staffIdx())->y() + system->y());
      65              : }
      66              : 
      67              : //---------------------------------------------------------
      68              : //   canvasPos
      69              : //---------------------------------------------------------
      70              : 
      71            0 : PointF StaffLines::canvasPos() const
      72              : {
      73            0 :     PointF p(pagePos());
      74            0 :     EngravingItem* e = layoutParent();
      75            0 :     while (e) {
      76            0 :         if (e->type() == ElementType::PAGE) {
      77            0 :             p += e->pos();
      78            0 :             break;
      79              :         }
      80            0 :         e = e->layoutParent();
      81              :     }
      82            0 :     return p;
      83              : }
      84              : 
      85            0 : RectF StaffLines::hitBBox() const
      86              : {
      87            0 :     double clickablePadding = spatium();
      88            0 :     if (m_lines.size() <= 1) {
      89            0 :         return ldata()->bbox().adjusted(0.0, -clickablePadding, 0.0, clickablePadding);
      90              :     }
      91            0 :     return ldata()->bbox();
      92              : }
      93              : 
      94            0 : Shape StaffLines::hitShape() const
      95              : {
      96            0 :     return Shape(hitBBox(), this);
      97              : }
      98              : 
      99           40 : bool StaffLines::collectForDrawing() const
     100              : {
     101           40 :     staff_idx_t idx = staffIdx();
     102           80 :     return EngravingItem::collectForDrawing() && (measure()->visible(idx) || measure()->isCutawayClef(idx))
     103           80 :            && score()->staff(idx)->show();
     104              : }
     105              : 
     106              : //---------------------------------------------------------
     107              : //   y1
     108              : //---------------------------------------------------------
     109              : 
     110        10326 : double StaffLines::y1() const
     111              : {
     112        10326 :     System* system = measure()->system();
     113              : /*      if (system == 0 || staffIdx() >= system->staves()->size())
     114              :             return 0.0;
     115              :       */
     116        10326 :     return system->staff(staffIdx())->y() + ldata()->pos().y();
     117              : }
     118              : }
        

Generated by: LCOV version 2.0-1