Verovio
Source code documentation
editortoolkit_cmn.h
1 // Name: editortoolkit_cmn.h
3 // Author: Juliette Regimbal
4 // Created: 04/06/2019
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_EDITOR_TOOLKIT_CMN_H__
9 #define __VRV_EDITOR_TOOLKIT_CMN_H__
10 
11 #include <cmath>
12 #include <string>
13 #include <utility>
14 
15 //--------------------------------------------------------------------------------
16 
17 #include "doc.h"
18 #include "editortoolkit.h"
19 #include "view.h"
20 
21 #include "jsonxx.h"
22 
23 namespace vrv {
24 
25 //--------------------------------------------------------------------------------
26 // EditorToolkitCMN
27 //--------------------------------------------------------------------------------
28 
30 public:
31  EditorToolkitCMN(Doc *doc, View *view) : EditorToolkit(doc, view) {}
32  bool ParseEditorAction(const std::string &json_editorAction) override
33  {
34  return ParseEditorAction(json_editorAction, false);
35  }
36  bool ParseEditorAction(const std::string &json_editorAction, bool commitOnly = false);
37  std::string EditInfo() override;
38 
39 protected:
40 #ifndef NO_EDIT_SUPPORT
45  bool Chain(jsonxx::Array actions);
46  bool ParseDeleteAction(jsonxx::Object param, std::string &elementId);
47  bool ParseDragAction(jsonxx::Object param, std::string &elementId, int &x, int &y);
48  bool ParseKeyDownAction(jsonxx::Object param, std::string &elementid, int &key, bool &shiftKey, bool &ctrlKey);
49  bool ParseInsertAction(jsonxx::Object param, std::string &elementType, std::string &startid, std::string &endid);
50  bool ParseSetAction(jsonxx::Object param, std::string &elementId, std::string &attribute, std::string &value);
52 
57  bool Delete(std::string &elementId);
58  bool Drag(std::string &elementId, int x, int y);
59  bool KeyDown(std::string &elementId, int key, bool shiftKey, bool ctrlKey);
60  bool Insert(std::string &elementType, std::string const &startid, std::string const &endid);
61  bool Insert(std::string &elementType, std::string const &startid);
62  bool Set(std::string &elementId, std::string const &attribute, std::string const &value);
64 
65  bool InsertNote(Object *object);
66 
67  bool DeleteNote(Note *note);
68 
69  Object *GetElement(std::string &elementId);
70 
71 public:
72  //
73 protected:
74  std::string m_chainedId;
75 #endif /* NO_EDIT_SUPPORT */
76 };
77 } // namespace vrv
78 
79 #endif
This class is a hold the data and corresponds to the model of a MVC design pattern.
Definition: doc.h:41
Definition: editortoolkit_cmn.h:29
bool Delete(std::string &elementId)
Experimental editor functions.
bool Chain(jsonxx::Array actions)
Parse JSON instructions for experimental editor functions.
std::string EditInfo() override
Get information on the last editor function used.
bool ParseEditorAction(const std::string &json_editorAction) override
In child classes, this parses the provided editor action and then performs the correct action.
Definition: editortoolkit_cmn.h:32
Definition: editortoolkit.h:28
This class models the MEI <note> element.
Definition: note.h:67
This class represents a basic object.
Definition: object.h:61
This class is a drawing context and corresponds to the view of a MVC design pattern.
Definition: view.h:106