8 #ifndef __VRV_EDITOR_TOOLKIT_SHARED_H__
9 #define __VRV_EDITOR_TOOLKIT_SHARED_H__
20 #include "editortoolkit.h"
27 class EditorTreeObject;
41 bool ParseEditorAction(
const std::string &json_editorAction,
bool commitOnly =
false);
44 #ifndef NO_EDIT_SUPPORT
46 enum SelectCustom : int8_t { SELECT_NONE = 0, SELECT_NOTE, SELECT_TEXT_PARENT };
54 enum DeleteNavigation : int8_t { DELETE_NO_NAVIGATON = 0, DELETE_BACKSPACE, DELETE_FORWARD };
60 bool Chain(
const jsonxx::Array &actions);
61 bool ParseContextAction(
const jsonxx::Object ¶m, std::string &elementId,
bool &scores,
bool §ions);
62 bool ParseDeleteAction(
const jsonxx::Object ¶m, std::string &elementId, DeleteNavigation &navigation);
63 bool ParseDragAction(
const jsonxx::Object ¶m, std::string &elementId,
int &x,
int &y);
64 bool ParseKeyDownAction(
65 const jsonxx::Object ¶m, std::string &elementid,
int &key,
bool &shiftKey,
bool &ctrlKey);
66 bool ParseInsertAction(
67 const jsonxx::Object ¶m, std::string &elementName, std::string &elementId, std::string &insertMode);
68 bool ParseInsertControlAction(
69 const jsonxx::Object ¶m, std::string &elementName, std::string &startId, std::string &endId);
70 bool ParseNavigate(
const jsonxx::Object ¶m, std::string &elementId,
int &direction);
71 bool ParsePropertiesAction(
const jsonxx::Object ¶m, std::string &scoreDef);
72 bool ParseResetCursorAction(
const jsonxx::Object ¶m,
bool &maintainChordMode);
73 bool ParseSelectAction(
const jsonxx::Object ¶m, std::string &elementId,
bool &secondary, SelectCustom &custom);
75 const jsonxx::Object ¶m, std::string &elementId, std::string &attribute, std::string &value);
76 bool ParseSetCursorAction(
77 const jsonxx::Object ¶m, std::string &elementId, Cursor::InputMode &inputMode,
bool &chordMode);
78 bool ParseUpdateCursorAction(
79 const jsonxx::Object ¶m,
bool &restMode,
bool &chordMode, Cursor::TieMode &tieMode);
80 bool ParseUpdatePitchAction(
const jsonxx::Object ¶m, std::string &elementId, data_PITCHNAME &pname,
int &oct,
81 data_ACCIDENTAL_WRITTEN &accid,
int &midi);
86 void ReloadEditStatus(
const std::string &statusStr,
bool insertMode);
87 void PrepareUndo(
bool ignoreInsertMode =
false);
88 std::string GetCurrentState();
89 bool ReloadState(
const State &state);
90 void TrimUndoMemory();
100 bool SetCursor(std::string &elementId, Cursor::InputMode inputMode,
bool chordMode);
101 bool UpdateCursor(
bool restMode,
bool chordMode, Cursor::TieMode tieMode);
102 bool ResetCursor(
bool maintainChordMode);
103 bool Delete(std::string &elementId, DeleteNavigation navigation);
104 bool Drag(std::string &elementId,
int x,
int y);
105 bool InsertControl(std::string &elementName, std::string &startId, std::string &endId);
106 bool KeyDown(std::string &elementId,
int key,
bool shiftKey,
bool ctrlKey);
107 bool Navigate(std::string &elementId,
const int &direction);
108 bool Select(std::string &elementId,
bool secondary, SelectCustom custom);
109 bool Set(std::string &elementId,
const std::string &attribute,
const std::string &value);
110 bool UpdatePitch(std::string &elementId, data_PITCHNAME pname,
int oct, data_ACCIDENTAL_WRITTEN accid,
int midi);
115 bool ContextForElement(std::string &elementId);
116 bool ContextForScores(
bool updateResponse);
117 bool ContextForSections(
bool updateResponse);
120 bool SetScoreDef(
const std::string scoreDef);
122 void ContextForObject(
const Object *
object, jsonxx::Object &element,
bool recursive =
false);
123 void ContextForObjects(
const ArrayOfConstObjects &objects, jsonxx::Array &siblings);
124 void ContextForReferences(
const ListOfObjectAttNamePairs &objects, jsonxx::Array &links);
126 ArrayOfConstObjects GetScoreBasedChildrenFor(
const Object *
object);
128 void CollectReferringObjects(
129 const Object *element, std::set<std::string> &toDelete, std::set<const Object *> &visited);
130 void PostProcessDeleteObjects(
const Object *element, std::set<std::string> &toPostProcess);
131 void PostProcessDelete(
const std::string &elementId);
133 void PostEditRestriction(
Object *element);
135 void MoveCursor(
LayerElement *element,
bool maintainChordMode =
false);
137 data_ACCIDENTAL_WRITTEN GetAccidBefore(
const LayerElement *element, data_PITCHNAME pname,
int oct);
138 std::pair<data_ACCIDENTAL_WRITTEN, bool> GetActualAccid(
Object *element, data_ACCIDENTAL_WRITTEN accid);
141 const Staff *GetPreviousStaff(
const Staff *staff);
142 const Layer *GetPreviousLayer(
const Layer *layer);
144 const Staff *GetNextStaff(
const Staff *staff);
145 const Layer *GetNextLayer(
const Layer *layer);
152 std::deque<State> m_undoStack;
153 std::deque<State> m_redoStack;
154 size_t m_undoMemoryUsage = 0;
161 struct MidiSpelling {
162 data_PITCHNAME pname;
163 data_ACCIDENTAL_WRITTEN accid;
166 MidiSpelling SpellMidi(
int midi,
const data_KEYSIGNATURE &keySig);
186 void Reset()
override;
187 std::string GetClassName()
const override {
return m_className; }
203 return vrv_cast<VisibilityDrawingInterface *>(
this);
205 const VisibilityDrawingInterface *GetVisibilityDrawingInterface()
const override
207 return vrv_cast<const VisibilityDrawingInterface *>(
this);
211 ArrayOfConstObjects GetChildObjects()
const;
216 std::string m_className;
217 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:176
bool IsSupportedChild(ClassId classId) override
Base method for checking if a child can be added.
Definition: editortoolkit_shared.h:194
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 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