LCOV - code coverage report
Current view: top level - src/engraving/dom - tie.h Coverage Total Hit
Test: filtered_coverage.info Lines: 96.3 % 27 26
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 "slurtie.h"
      26              : 
      27              : namespace mu::engraving {
      28              : class TieJumpPointList;
      29              : class TieJumpPoint;
      30              : //---------------------------------------------------------
      31              : //   @@ TieSegment
      32              : ///    a single segment of a tie
      33              : //---------------------------------------------------------
      34              : 
      35              : class TieSegment : public SlurTieSegment
      36              : {
      37         4383 :     OBJECT_ALLOCATOR(engraving, TieSegment)
      38              :     DECLARE_CLASSOF(ElementType::TIE_SEGMENT)
      39              : 
      40              : public:
      41              :     TieSegment(Tie* sp);
      42              :     TieSegment(const TieSegment& s);
      43              : 
      44          448 :     TieSegment* clone() const override { return new TieSegment(*this); }
      45              : 
      46        24559 :     void addAdjustmentOffset(const PointF& offset, Grip grip) { m_adjustmentOffsets[static_cast<size_t>(grip)] += offset; }
      47         5415 :     void resetAdjustmentOffset() { m_adjustmentOffsets.fill(PointF()); }
      48            0 :     PointF adjustmentOffset(Grip grip) { return m_adjustmentOffsets[static_cast<size_t>(grip)]; }
      49              :     void consolidateAdjustmentOffsetIntoUserOffset();
      50              : 
      51              :     bool isEdited() const;
      52              :     RectF drag(EditData&) override;
      53              :     void dragGrip(EditData&) override;
      54              : 
      55        52635 :     Tie* tie() const { return (Tie*)spanner(); }
      56              : 
      57          595 :     void setStaffMove(int val) { m_staffMove = val; }
      58        25462 :     staff_idx_t vStaffIdx() const override { return staffIdx() + m_staffMove; }
      59              : 
      60              :     virtual double minShoulderHeight() const;
      61              :     virtual double maxShoulderHeight() const;
      62              :     double endWidth() const override;
      63              :     double midWidth() const override;
      64              :     double dottedWidth() const override;
      65              : 
      66              :     struct LayoutData : public SlurTieSegment::LayoutData {
      67              :         bool allJumpPointsInactive = false;
      68              :     };
      69        35647 :     DECLARE_LAYOUTDATA_METHODS(TieSegment)
      70              : 
      71              : protected:
      72              :     TieSegment(const ElementType& type, Tie* sp);
      73              :     void changeAnchor(EditData&, EngravingItem*) override;
      74              : 
      75              : private:
      76              :     int m_staffMove = 0;
      77              :     std::array<PointF, static_cast<size_t>(Grip::GRIPS)> m_adjustmentOffsets;
      78              : };
      79              : 
      80              : //---------------------------------------------------------
      81              : //   @@ Tie
      82              : //!    a Tie has a Note as startElement/endElement
      83              : //---------------------------------------------------------
      84              : 
      85              : class Tie : public SlurTie
      86              : {
      87         4132 :     OBJECT_ALLOCATOR(engraving, Tie)
      88         1059 :     DECLARE_CLASSOF(ElementType::TIE)
      89              : 
      90              : public:
      91              :     Tie(DummyParentOr<Note> parent);
      92              :     Tie(const Tie& t);
      93              : 
      94           43 :     Tie* clone() const override { return new Tie(*this); }
      95         4066 :     void setOwnershipParent(DummyParentOr<Note> parent) { EngravingItem::setOwnershipParent(parent); }
      96              : 
      97         7342 :     Anchor anchor() const override { return Anchor::NOTE; }
      98              : 
      99         3875 :     virtual ~Tie() {}
     100              : 
     101              :     virtual Note* startNote() const;
     102              :     virtual void setStartNote(Note* note);
     103              :     virtual Note* endNote() const;
     104         1638 :     virtual void setEndNote(Note* note) { setEndElement((EngravingItem*)note); }
     105              : 
     106        16485 :     bool isInside() const { return m_isInside; }
     107         4820 :     void setIsInside(bool val) { m_isInside = val; }
     108              :     virtual bool isOuterTieOfChord(Grip startOrEnd) const;
     109              :     bool hasTiedSecondInside() const;
     110              :     bool isCrossStaff() const;
     111              : 
     112              :     PropertyValue getProperty(Pid propertyId) const override;
     113              :     PropertyValue propertyDefault(Pid id) const override;
     114              :     bool setProperty(Pid propertyId, const PropertyValue& v) override;
     115              : 
     116          105 :     TieSegment* frontSegment() { return toTieSegment(Spanner::frontSegment()); }
     117              :     const TieSegment* frontSegment() const { return toTieSegment(Spanner::frontSegment()); }
     118          100 :     TieSegment* backSegment() { return toTieSegment(Spanner::backSegment()); }
     119              :     const TieSegment* backSegment() const { return toTieSegment(Spanner::backSegment()); }
     120         5070 :     TieSegment* segmentAt(int n) { return toTieSegment(Spanner::segmentAt(n)); }
     121              :     const TieSegment* segmentAt(int n) const { return toTieSegment(Spanner::segmentAt(n)); }
     122              : 
     123         1921 :     SlurTieSegment* newSlurTieSegment() override { return new TieSegment(this); }
     124              : 
     125              :     double scalingFactor() const override;
     126              : 
     127         5488 :     const TiePlacement& tiePlacement() const { return m_tiePlacement; }
     128            5 :     void setTiePlacement(const TiePlacement& val) { m_tiePlacement = val; }
     129              : 
     130              :     // Outgoing ties before repeats
     131              :     void updatePossibleJumpPoints();
     132              :     void addTiesToJumpPoints();
     133              :     void undoRemoveTiesFromJumpPoints();
     134              :     virtual bool allJumpPointsInactive() const;
     135              :     virtual TieJumpPointList* tieJumpPoints();
     136              :     virtual const TieJumpPointList* tieJumpPoints() const;
     137              : 
     138              :     // Incoming ties after repeats
     139         1314 :     void setJumpPoint(TieJumpPoint* jumpPoint) { m_jumpPoint = jumpPoint; }
     140              :     void updateStartTieOnRemoval();
     141          287 :     TieJumpPoint* jumpPoint() const { return m_jumpPoint; }
     142              :     Tie* startTie() const;
     143              : 
     144              :     static void changeTieType(Tie* oldTie, Note* endNote = nullptr);
     145              : 
     146              : protected:
     147              :     Tie(const ElementType& type, DummyParentOr<Note> parent);
     148              : 
     149         3093 :     bool isInSpannerMap() const override { return false; }
     150              : 
     151              :     bool m_isInside = false;
     152              :     TiePlacement m_tiePlacement = TiePlacement::AUTO;
     153              : 
     154              :     // Jump point information for incoming ties after repeats
     155              :     TieJumpPoint* m_jumpPoint = nullptr;
     156              :     TieJumpPointList* startTieJumpPoints() const;
     157              : };
     158              : } // namespace mu::engraving
        

Generated by: LCOV version 2.0-1