Verovio
Source code documentation
cursor.h
1 // Name: cursor.h
3 // Author: Laurent Pugin
4 // Created: 2026
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_CURSOR_H__
9 #define __VRV_CURSOR_H__
10 
11 #include <stack>
12 
13 //----------------------------------------------------------------------------
14 
15 #include "elementpart.h"
16 #include "note.h"
17 
18 namespace vrv {
19 
20 //----------------------------------------------------------------------------
21 // Cursor
22 //----------------------------------------------------------------------------
23 
27 class Cursor : public Note {
28 public:
34  Cursor();
35  virtual ~Cursor();
36  Object *Clone() const override { return new Cursor(*this); }
37  void Reset() override;
38  std::string GetClassName() const override { return "cursor"; }
40 
44  void CloneReset() override;
45 
46  bool IsCursor() const override { return true; }
47 
48  int GetDrawingX() const override;
49 
50  void SetCursorAlignment(Alignment *alignment);
51  void ResetCursorAlignment();
52 
53  void SetPosition(LayerElement *position) { m_position = position; }
54  LayerElement *GetPosition() const { return m_position; }
55  bool HasPosition() const { return (m_position); }
56 
57  Object *GetInsertTargetObject() const;
58 
59  void PushContainer(LayerElement *container) { m_containers.push_back(container); }
60  void PopContainer() { m_containers.pop_back(); }
61  LayerElement *GetContainer() const { return m_containers.back(); }
62  bool HasContainer() const { return (!m_containers.empty()); }
63  bool HasContainer(ClassId classId) const;
64  void ClearContainers() { m_containers.clear(); }
65 
66  bool HasAccid() const { return m_accid.HasAccid(); }
67  data_ACCIDENTAL_WRITTEN GetAccid() const { return m_accid.GetAccid(); }
68  void SetAccid(data_ACCIDENTAL_WRITTEN accid);
69  bool IsAccidImplicit() const { return m_isAccidImplicit; }
70  void SetAccidImplicit(bool isAccidImplicit);
71  void SetAccidValue(const Accid *accid);
72  std::pair<data_ACCIDENTAL_WRITTEN, data_ACCIDENTAL_GESTURAL> GetAccidValue();
73 
74  Accid *GetAccidElement() { return &m_accid; }
75 
76  bool IsRestMode() const { return m_restMode; }
77  void SetRestMode(bool restMode);
78 
79  enum ChordMode : int8_t { CHORD_NONE = 0, NEW, EDIT_NEW, EDIT_EXISTING };
80 
81  ChordMode GetChordMode() const { return m_chordMode; }
82  void SetChordMode(ChordMode chordMode);
83  bool IsChordMode() const { return (m_chordMode != ChordMode::CHORD_NONE); }
84  bool IsChordEditMode() const
85  {
86  return (m_chordMode == ChordMode::EDIT_NEW) || (m_chordMode == ChordMode::EDIT_EXISTING);
87  }
88 
89  enum TieMode : int8_t { TIE_NONE = 0, TIE, COPY };
90 
91  TieMode GetTieMode() const { return m_tieMode; }
92  void SetTieMode(TieMode tieMode);
93  bool IsTieMode() const { return (m_tieMode != TieMode::TIE_NONE); }
94 
95  enum InputMode : int8_t { PITCH_FIRST = 0, DURATION_FIRST };
96 
97  InputMode GetInputMode() const { return m_inputMode; }
98  void SetInputMode(InputMode inputMode);
99 
100  bool IsAutoBeam() const { return m_autoBeam; }
101  void SetAutoBeam(bool autoBeam) { m_autoBeam = autoBeam; }
102 
103  int GetYRelPitchC() const { return m_yRelPitchC; }
104  void SetYRelPitchC(int yRelPitchC) { m_yRelPitchC = yRelPitchC; }
105 
106  bool Veto(const std::string &attribute) const;
107  void OnSet(const std::string &attribute);
108 
109  //----------//
110  // Functors //
111  //----------//
112 
117  FunctorCode Accept(Functor &functor) override;
118  FunctorCode Accept(ConstFunctor &functor) const override;
119  FunctorCode AcceptEnd(Functor &functor) override;
120  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
122 
123 private:
124  //
125 public:
126  //
127 private:
129  LayerElement *m_position;
131  Accid m_accid;
133  bool m_isAccidImplicit;
135  bool m_restMode;
137  ChordMode m_chordMode;
139  InputMode m_inputMode;
141  int m_yRelPitchC;
143  TieMode m_tieMode;
145  std::vector<LayerElement *> m_containers;
147  bool m_autoBeam;
148 };
149 
150 } // namespace vrv
151 
152 #endif
This class models the MEI <accid> element.
Definition: accid.h:41
This class stores an alignment position elements will point to.
Definition: horizontalaligner.h:77
This abstract class is the base class for all const functors.
Definition: functor.h:126
This class implements a curor for the editor.
Definition: cursor.h:27
bool IsCursor() const override
Flag indicator if or Cursor instance.
Definition: cursor.h:46
void Reset() override
Virtual reset method.
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
void CloneReset() override
Overriding CloneReset() method to be called after copy / assignment calls.
Object * Clone() const override
Method call for copying child classes.
Definition: cursor.h:36
This abstract class is the base class for all mutable functors.
Definition: functor.h:101
This class is a base class for the Layer (<layer>) content.
Definition: layerelement.h:51
This class models the MEI <note> element.
Definition: note.h:69
This class represents a basic object.
Definition: object.h:66