8 #ifndef __VRV_EDITOR_TOOLKIT_SHARED_H__
9 #define __VRV_EDITOR_TOOLKIT_SHARED_H__
20 #include "editortoolkit.h"
27 class EditorTreeObject;
43 bool ParseEditorAction(
const std::string &json_editorAction,
bool commitOnly =
false);
46 #ifndef NO_EDIT_SUPPORT
48 enum SelectCustom : int8_t { SELECT_NONE = 0, SELECT_NOTE, SELECT_TEXT_PARENT };
56 enum DeleteNavigation : int8_t { DELETE_NO_NAVIGATON = 0, DELETE_BACKSPACE, DELETE_FORWARD };
58 enum ScoreDefUpdate : int8_t { INSERT_ABOVE = 0, INSERT_BELOW, MOVE_UP, MOVE_DOWN, DELETE_STAFF };
64 bool Chain(
const jsonxx::Array &actions);
65 bool ParseContextAction(
const jsonxx::Object ¶m, std::string &elementId,
bool &scores,
bool §ions);
66 bool ParseDeleteAction(
const jsonxx::Object ¶m, std::string &elementId, DeleteNavigation &navigation);
67 bool ParseDragAction(
const jsonxx::Object ¶m, std::string &elementId,
int &x,
int &y);
68 bool ParseKeyDownAction(
69 const jsonxx::Object ¶m, std::string &elementid,
int &key,
bool &shiftKey,
bool &ctrlKey);
70 bool ParseInsertAction(
71 const jsonxx::Object ¶m, std::string &elementName, std::string &elementId, std::string &insertMode);
72 bool ParseInsertControlAction(
73 const jsonxx::Object ¶m, std::string &elementName, std::string &startId, std::string &endId);
74 bool ParseNavigate(
const jsonxx::Object ¶m, std::string &elementId,
int &direction);
75 bool ParseGetScoreDefAction(
const jsonxx::Object ¶m);
76 bool ParseGetScoreDefKeySigAction(
const jsonxx::Object ¶m,
bool &selected);
77 bool ParseGetScoreDefMeterSigAction(
const jsonxx::Object ¶m,
bool &selected);
78 bool ParseGetScoreDefStaffDefAction(
const jsonxx::Object ¶m);
79 bool ParseGetScoreDefStaffGrpAction(
const jsonxx::Object ¶m,
bool &selected);
80 bool ParseResetCursorAction(
const jsonxx::Object ¶m,
bool &maintainChordMode);
81 bool ParseSelectAction(
const jsonxx::Object ¶m, std::string &elementId,
bool &secondary, SelectCustom &custom);
83 const jsonxx::Object ¶m, std::string &elementId, std::string &attribute, std::string &value);
84 bool ParseSetCursorAction(
const jsonxx::Object ¶m, std::string &elementId, Cursor::InputMode &inputMode,
85 bool &chordMode,
bool &autoBeam);
86 bool ParseUpdateCursorAction(
87 const jsonxx::Object ¶m,
bool &restMode,
bool &chordMode, Cursor::TieMode &tieMode,
bool &autoBeam);
88 bool ParseUpdatePitchAction(
const jsonxx::Object ¶m, std::string &elementId, data_PITCHNAME &pname,
int &oct,
89 data_ACCIDENTAL_WRITTEN &accid,
int &midi);
90 bool ParseSetScoreDefAction(
const jsonxx::Object ¶m, jsonxx::Object &subTree);
91 bool ParseSetScoreDefKeySigAction(
const jsonxx::Object ¶m,
bool &selected, jsonxx::Object &subTree);
92 bool ParseSetScoreDefMeterSigAction(
const jsonxx::Object ¶m,
bool &selected, jsonxx::Object &subTree);
93 bool ParseSetScoreDefStaffDefAction(
const jsonxx::Object ¶m, jsonxx::Object &subTree);
94 bool ParseSetScoreDefStaffGrpAction(
const jsonxx::Object ¶m,
bool &selected, jsonxx::Object &subTree);
95 bool ParseUpdateScoreDefAction(
const jsonxx::Object ¶m, ScoreDefUpdate &update);
100 void ReloadEditStatus(
const std::string &statusStr,
bool insertMode);
101 void PrepareUndo(
bool ignoreInsertMode =
false);
102 std::string GetCurrentState();
103 bool ReloadState(
const State &state);
104 void TrimUndoMemory();
105 bool CanUndo()
const;
106 bool CanRedo()
const;
114 bool SetCursor(std::string &elementId, Cursor::InputMode inputMode,
bool chordMode,
bool autoBeam);
115 bool UpdateCursor(
bool restMode,
bool chordMode, Cursor::TieMode tieMode,
bool autoBeam);
116 bool ResetCursor(
bool maintainChordMode);
117 bool Delete(std::string &elementId, DeleteNavigation navigation);
118 bool Drag(std::string &elementId,
int x,
int y);
119 bool InsertControl(std::string &elementName, std::string &startId, std::string &endId);
120 bool KeyDown(std::string &elementId,
int key,
bool shiftKey,
bool ctrlKey);
121 bool Navigate(std::string &elementId,
const int &direction);
122 bool Select(std::string &elementId,
bool secondary, SelectCustom custom);
123 bool Set(std::string &elementId,
const std::string &attribute,
const std::string &value);
124 bool UpdatePitch(std::string &elementId, data_PITCHNAME pname,
int oct, data_ACCIDENTAL_WRITTEN accid,
int midi);
129 bool ContextForElement(std::string &elementId);
130 bool ContextForScores(
bool updateResponse);
131 bool ContextForSections(
bool updateResponse);
134 bool GetScoreDefKeySig(
bool selected);
135 bool GetScoreDefMeterSig(
bool selected);
136 bool GetScoreDefStaffDef();
137 bool GetScoreDefStaffGrp(
bool selected);
138 bool SetScoreDef(
const jsonxx::Object &subTree);
139 bool SetScoreDefKeySig(
bool selected,
const jsonxx::Object &subTree);
140 bool SetScoreDefMeterSig(
bool selected,
const jsonxx::Object &subTree);
141 bool SetScoreDefStaffDef(
const jsonxx::Object &subTree);
142 bool SetScoreDefStaffGrp(
bool selected,
const jsonxx::Object &subTree);
143 bool UpdateScoreDef(ScoreDefUpdate update);
145 ScoreDef *ResolveScoreDef(
bool selected);
146 Staff *ResolveScoreDefStaff();
147 void FinalizeScoreDefUpdate();
149 void ContextForObject(
const Object *
object, jsonxx::Object &element,
bool recursive =
false);
150 void ContextForObjects(
const ArrayOfConstObjects &objects, jsonxx::Array &siblings);
151 void ContextForReferences(
const ListOfObjectAttNamePairs &objects, jsonxx::Array &links);
153 ArrayOfConstObjects GetScoreBasedChildrenFor(
const Object *
object);
155 void PostProcessDeleteObjects(
const Object *element, std::set<std::string> &toPostProcess);
156 void PostProcessDelete(
const std::string &elementId);
158 void PostEditRestriction(
Object *element);
160 void MoveCursor(
LayerElement *element,
bool maintainChordMode =
false);
162 data_ACCIDENTAL_WRITTEN GetAccidBefore(
const LayerElement *element, data_PITCHNAME pname,
int oct);
163 std::pair<data_ACCIDENTAL_WRITTEN, bool> GetActualAccid(
Object *element, data_ACCIDENTAL_WRITTEN accid);
166 const Staff *GetPreviousStaff(
const Staff *staff);
167 const Layer *GetPreviousLayer(
const Layer *layer);
169 const Staff *GetNextStaff(
const Staff *staff);
170 const Layer *GetNextLayer(
const Layer *layer);
177 std::deque<State> m_undoStack;
178 std::deque<State> m_redoStack;
179 size_t m_undoMemoryUsage = 0;
186 struct MidiSpelling {
187 data_PITCHNAME pname;
188 data_ACCIDENTAL_WRITTEN accid;
191 MidiSpelling SpellMidi(
int midi,
const data_KEYSIGNATURE &keySig);
211 void Reset()
override;
212 std::string GetClassName()
const override {
return m_className; }
228 return vrv_cast<VisibilityDrawingInterface *>(
this);
230 const VisibilityDrawingInterface *GetVisibilityDrawingInterface()
const override
232 return vrv_cast<const VisibilityDrawingInterface *>(
this);
236 ArrayOfConstObjects GetChildObjects()
const;
241 std::string m_className;
242 const Object *m_object;
This class is a hold the data and corresponds to the model of a MVC design pattern.
Definition: doc.h:41
This class stores an alignment position elements will point to.
Definition: editortoolkit_shared.h:201
bool IsSupportedChild(ClassId classId) override
Base method for checking if a child can be added.
Definition: editortoolkit_shared.h:219
This class is a base class for the Layer (<layer>) content.
Definition: layerelement.h:51
This class represents a layer in a laid-out score (Doc).
Definition: layer.h:40
This class represents a measure in a page-based score (Doc).
Definition: measure.h:46
This class represents a basic object.
Definition: object.h:66
This class represents a MEI scoreDef.
Definition: scoredef.h:136
This class represents a staff in a laid-out score (Doc).
Definition: staff.h:110
This class is a drawing context and corresponds to the view of a MVC design pattern.
Definition: view.h:109
This class is an interface for MEI element that can be hidden during drawing.
Definition: drawinginterface.h:448