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  void SetContainer(LayerElement *container) { m_container.push(container); }
58  LayerElement *GetContainer() const { return m_container.top(); }
59  bool HasContainer() const { return (!m_container.empty()); }
60 
61  bool HasAccid() const { return m_accid.HasAccid(); }
62  data_ACCIDENTAL_WRITTEN GetAccid() const { return m_accid.GetAccid(); }
63  void SetAccid(data_ACCIDENTAL_WRITTEN accid);
64  bool IsAccidImplicit() const { return m_isAccidImplicit; }
65  void SetAccidImplicit(bool isAccidImplicit);
66  void SetAccidValue(const Accid *accid);
67  std::pair<data_ACCIDENTAL_WRITTEN, data_ACCIDENTAL_GESTURAL> GetAccidValue();
68 
69  Accid *GetAccidElement() { return &m_accid; }
70 
71  bool IsRestMode() const { return m_restMode; }
72  void SetRestMode(bool restMode);
73 
74  enum ChordMode : int8_t { CHORD_NONE = 0, NEW, EDIT_NEW, EDIT_EXISTING };
75 
76  ChordMode GetChordMode() const { return m_chordMode; }
77  void SetChordMode(ChordMode chordMode);
78  bool IsChordMode() const { return (m_chordMode != ChordMode::CHORD_NONE); }
79  bool IsChordEditMode() const
80  {
81  return (m_chordMode == ChordMode::EDIT_NEW) || (m_chordMode == ChordMode::EDIT_EXISTING);
82  }
83 
84  enum TieMode : int8_t { TIE_NONE = 0, TIE, COPY };
85 
86  TieMode GetTieMode() const { return m_tieMode; }
87  void SetTieMode(TieMode tieMode);
88  bool IsTieMode() const { return (m_tieMode != TieMode::TIE_NONE); }
89 
90  enum InputMode : int8_t { PITCH_FIRST = 0, DURATION_FIRST };
91 
92  InputMode GetInputMode() const { return m_inputMode; }
93  void SetInputMode(InputMode inputMode);
94 
95  int GetYRelPitchC() const { return m_yRelPitchC; }
96  void SetYRelPitchC(int yRelPitchC) { m_yRelPitchC = yRelPitchC; }
97 
98  bool Veto(const std::string &attribute) const;
99  void OnSet(const std::string &attribute);
100 
101  //----------//
102  // Functors //
103  //----------//
104 
109  FunctorCode Accept(Functor &functor) override;
110  FunctorCode Accept(ConstFunctor &functor) const override;
111  FunctorCode AcceptEnd(Functor &functor) override;
112  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
114 
115 private:
116  //
117 public:
118  //
119 private:
121  LayerElement *m_position;
123  Accid m_accid;
125  bool m_isAccidImplicit;
127  bool m_restMode;
129  ChordMode m_chordMode;
131  InputMode m_inputMode;
133  int m_yRelPitchC;
135  TieMode m_tieMode;
137  std::stack<LayerElement *> m_container;
138 };
139 
140 } // namespace vrv
141 
142 #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