Verovio
Source code documentation
editortoolkit.h
1 // Name: editortoolkit.h
3 // Author: Laurent Pugin, Juliette Regimbal
4 // Created: 16/05/2018
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_EDITOR_TOOLKIT_H__
9 #define __VRV_EDITOR_TOOLKIT_H__
10 
11 #include <cmath>
12 #include <string>
13 #include <utility>
14 
15 //--------------------------------------------------------------------------------
16 
17 #include "doc.h"
18 #include "view.h"
19 
20 #include "jsonxx.h"
21 
22 namespace vrv {
23 
24 //--------------------------------------------------------------------------------
25 // EditorToolkit
26 //--------------------------------------------------------------------------------
27 
29 public:
30  EditorToolkit(Doc *doc, View *view)
31  {
32  m_doc = doc;
33  m_view = view;
34  m_editInfo.reset();
35  }
36  virtual ~EditorToolkit() {}
37 
41  virtual bool ParseEditorAction(const std::string &json_editorAction) = 0;
45  virtual std::string EditInfo() { return m_editInfo.json(); }
46 
47 #ifndef NO_EDIT_SUPPORT
48 protected:
49  bool AppendChild(const std::string &elementId, const std::string &elementName);
50  bool InsertBefore(const std::string &elementId, const std::string &elementName);
51  bool InsertAfter(const std::string &elementId, const std::string &elementName);
52  Object *GetElement(const std::string &elementId);
53  Object *PrepareInsertion(Object *parent, const std::string &elementName);
54 #endif
55 
56 protected:
57  Doc *m_doc;
58  View *m_view;
59  jsonxx::Object m_editInfo;
60 };
61 } // namespace vrv
62 
63 #endif
This class is a hold the data and corresponds to the model of a MVC design pattern.
Definition: doc.h:41
Definition: editortoolkit.h:28
virtual std::string EditInfo()
Get information on the last editor function used.
Definition: editortoolkit.h:45
virtual bool ParseEditorAction(const std::string &json_editorAction)=0
In child classes, this parses the provided editor action and then performs the correct action.
This class represents a basic object.
Definition: object.h:62
This class is a drawing context and corresponds to the view of a MVC design pattern.
Definition: view.h:106