MyScript Interactive Ink SDK  3.0.1
Editor.h
1 // Copyright @ MyScript. All rights reserved.
2 
3 #pragma once
4 
5 #include <iink/Engine.h>
6 #include <iink/PointerEvent.h>
7 #include <iink/graphics/Point.h>
8 #include <iink/graphics/Rectangle.h>
9 #include <iink/text/IFontMetricsProvider.h>
10 #include <iink/ContentSelection.h>
11 #include <iink/MimeType.h>
12 
13 #include <cstdint>
14 #include <memory>
15 #include <type_traits>
16 #include <vector>
17 
18 namespace myscript {
19 namespace iink {
20 
21 class Engine;
22 class Configuration;
23 class Renderer;
24 class ToolController;
25 class IEditorListener;
26 class IGestureHandler;
27 class IImagePainter;
28 class ContentPart;
29 class ContentBlock;
30 class ParameterSet;
31 
32 namespace graphics {
33 
34 class ICanvas;
35 struct Transform;
36 
37 }
38 
43 {
44  ALLOWED = 0,
46  UNSUPPORTED = 1 << 0,
47  NULL_SELECTION = 1 << 1,
48  PARTIAL_BLOCKS = 1 << 2,
49  MULTIPLE_BLOCKS = 1 << 3,
50  BEAUTIFIED_BLOCKS = 1 << 4,
51  TEXT_BLOCKS = 1 << 5,
52  MATH_BLOCKS = 1 << 6,
53  DRAWING_BLOCKS = 1 << 7,
54  GUIDES = 1 << 8,
55  INVALID = 1 << 9,
56  NON_INVERTIBLE = 1 << 10,
57  BAD_NUMERIC = 1 << 11,
58  HAS_ROTATION = 1 << 12,
59  HAS_SCALE = 1 << 13,
60  HAS_NEGATIVE_SCALE = 1 << 14,
61  HAS_SHEAR = 1 << 15,
62  HAS_TRANSLATION = 1 << 16,
63 };
64 
70 enum class TextFormat
71 {
72  H1 = 0,
73  H2 = 1,
74  PARAGRAPH = 2,
75  LIST_BULLET = 3,
76  LIST_CHECKBOX = 4,
77  LIST_NUMBERED = 5,
78 };
79 
86 {
87  IndentationLevels(size_t low_, size_t high_, size_t max_)
88  : low(low_), high(high_), max(max_) {}
89 
90  size_t low;
91  size_t high;
92  size_t max;
93 };
94 
99 {
100  NONE = 0,
101  LASSO = 1,
102  ITEM = 2,
103  RESIZE = 3,
104  REFLOW = 4
105 };
106 
113 class Editor
114 {
115 public:
116 
117  virtual ~Editor() = default;
118 
124  virtual void addListener(std::shared_ptr<IEditorListener> listener) noexcept = 0;
125 
131  virtual void removeListener(std::shared_ptr<IEditorListener> listener) noexcept = 0;
132 
140  virtual void setGestureHandler(std::shared_ptr<IGestureHandler> handler) = 0;
141 
147  virtual void removeGestureHandler() = 0;
148 
154  virtual void setFontMetricsProvider(std::shared_ptr<myscript::iink::text::IFontMetricsProvider> fontMetricsProvider) noexcept = 0;
155 
161  virtual std::shared_ptr<Engine> getEngine() noexcept = 0;
162 
168  virtual std::shared_ptr<Renderer> getRenderer() noexcept = 0;
169 
177  virtual std::shared_ptr<ToolController> getToolController() noexcept = 0;
178 
184  virtual std::shared_ptr<ContentPart> getPart() noexcept = 0;
185 
196  virtual void setPart(std::shared_ptr<ContentPart> part) = 0;
197 
203  virtual void clear() = 0;
204 
210  virtual bool canUndo() noexcept = 0;
211 
216  virtual void undo() = 0;
217 
223  virtual bool canRedo() noexcept = 0;
224 
229  virtual void redo() = 0;
230 
247  virtual int getUndoStackIndex() = 0;
248 
258  virtual int getPossibleUndoCount() = 0;
259 
269  virtual int getPossibleRedoCount() = 0;
270 
284  virtual String getUndoRedoIdAt(int stackIndex) = 0;
285 
306  virtual String pointerDown(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId) = 0;
307 
325  virtual void pointerMove(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId) = 0;
326 
343  virtual void pointerUp(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId) = 0;
344 
350  virtual void pointerCancel(int pointerId) = 0;
351 
367  virtual void pointerEvents(const std::vector<PointerEvent>& events, bool processGestures = true) = 0;
368 
378  virtual void setViewSize(int width, int height) = 0;
379 
387  virtual int getViewWidth() = 0;
388 
396  virtual int getViewHeight() = 0;
397 
406  virtual void clampViewOffset(graphics::Point& viewOffset) = 0;
407 
417  virtual void setTheme(const String& styleSheet) = 0;
418 
424  virtual String getTheme() const noexcept = 0;
425 
431  virtual std::shared_ptr<ContentBlock> getRootBlock() = 0;
432 
441  virtual std::shared_ptr<ContentBlock> getBlockById(const String& id) = 0;
442 
453  virtual bool isEmpty(std::shared_ptr<ContentSelection> selection) = 0;
454 
464  virtual std::vector<String> getSupportedAddBlockTypes() noexcept = 0;
465 
473  virtual std::vector<MimeType> getSupportedAddBlockDataMimeTypes(const String& type) noexcept = 0;
474 
493  virtual std::shared_ptr<ContentBlock> addBlock(float x, float y, const String& type) = 0;
494 
519  virtual std::shared_ptr<ContentBlock> addBlock(float x, float y, const String& type, MimeType mimeType, const String& data) = 0;
520 
545  virtual std::shared_ptr<ContentBlock> addImage(float x, float y, const String& inputFile, MimeType mimeType) = 0;
546 
559  virtual void erase(std::shared_ptr<ContentSelection> selection) = 0;
560 
570  virtual std::shared_ptr<ContentBlock> hitBlock(float x, float y) = 0;
571 
582  virtual std::vector<ConversionState> getSupportedTargetConversionStates(std::shared_ptr<ContentSelection> selection) = 0;
583 
599  virtual void convert(std::shared_ptr<ContentSelection> selection, ConversionState targetState) = 0;
600 
610  virtual std::vector<MimeType> getSupportedExportMimeTypes(std::shared_ptr<ContentSelection> selection) = 0;
611 
633  virtual String export_(std::shared_ptr<ContentSelection> selection, MimeType mimeType, std::shared_ptr<ParameterSet> overrideConfiguration = nullptr) = 0;
634 
660  virtual void export_(std::shared_ptr<ContentSelection> selection, const String& outputFile, std::shared_ptr<IImagePainter> imagePainter, std::shared_ptr<ParameterSet> overrideConfiguration = nullptr) = 0;
661 
687  virtual void export_(std::shared_ptr<ContentSelection> selection, const String& outputFile, MimeType mimeType, std::shared_ptr<IImagePainter> imagePainter, std::shared_ptr<ParameterSet> overrideConfiguration = nullptr) = 0;
688 
698  virtual std::vector<MimeType> getSupportedImportMimeTypes(std::shared_ptr<ContentSelection> selection) = 0;
699 
716  virtual void import_(MimeType mimeType, const String& data, std::shared_ptr<ContentSelection> selection = nullptr, std::shared_ptr<ParameterSet> overrideConfiguration = nullptr) = 0;
717 
730  virtual void copy(std::shared_ptr<ContentSelection> selection) = 0;
731 
749  virtual void paste(float x, float y) = 0;
750 
756  virtual bool isIdle() noexcept = 0;
757 
761  virtual void waitForIdle() noexcept = 0;
762 
771  virtual bool isScrollAllowed() noexcept = 0;
772 
778  virtual std::shared_ptr<Configuration> getConfiguration() noexcept = 0;
779 
796  virtual void drawStroke(const std::vector<PointerEvent>& events, std::shared_ptr<graphics::ICanvas> canvas) = 0;
797 
807  virtual bool hasSelection() = 0;
808 
820  virtual std::shared_ptr<ContentSelection> getSelection() = 0;
821 
835  virtual void setSelection(std::shared_ptr<ContentSelection> selection) = 0;
836 
849  virtual std::shared_ptr<ContentSelection> hitSelection(float x, float y) = 0;
850 
864  virtual std::vector<String> getIntersectingBlocks(std::shared_ptr<ContentSelection> selection) = 0;
865 
879  virtual std::vector<String> getIncludedBlocks(std::shared_ptr<ContentSelection> selection) = 0;
880 
881 
895  virtual std::underlying_type<TransformError>::type getTransformStatus(std::shared_ptr<ContentSelection> selection, const myscript::iink::graphics::Transform& transform) = 0;
896 
912  virtual void transform(std::shared_ptr<ContentSelection> selection, const myscript::iink::graphics::Transform& transform) = 0;
913 
927  virtual void applyStyle(std::shared_ptr<ContentSelection> selection, const String& style) = 0;
928 
940  virtual std::vector<TextFormat> getSupportedTextFormats(std::shared_ptr<ContentSelection> selection) = 0;
941 
954  virtual void setTextFormat(std::shared_ptr<ContentSelection> selection, TextFormat format) = 0;
955 
966 
979  virtual void setSelectionMode(ContentSelectionMode mode) = 0;
980 
991 
1007  virtual void setSelectionType(std::shared_ptr<ContentSelection> selection, const String& type, bool forceSingleBlock) = 0;
1008 
1021  virtual std::vector<String> getAvailableSelectionTypes(std::shared_ptr<ContentSelection> selection) = 0;
1022 
1038  virtual IndentationLevels getIndentationLevels(std::shared_ptr<ContentSelection> selection) = 0;
1039 
1060  virtual void indent(std::shared_ptr<ContentSelection> selection, int offset) = 0;
1061 
1074  virtual myscript::iink::graphics::Rectangle getBox(std::shared_ptr<ContentSelection> selection) = 0;
1075 
1089  virtual std::underlying_type<ConversionState>::type getConversionState(std::shared_ptr<ContentSelection> selection) = 0;
1090 };
1091 
1092 }
1093 }
Definition: Configuration.h:20
Definition: ContentBlock.h:21
Definition: ContentPart.h:24
Definition: ContentSelection.h:33
Definition: Editor.h:114
virtual std::underlying_type< TransformError >::type getTransformStatus(std::shared_ptr< ContentSelection > selection, const myscript::iink::graphics::Transform &transform)=0
virtual void setTheme(const String &styleSheet)=0
virtual int getPossibleUndoCount()=0
virtual bool isScrollAllowed() noexcept=0
virtual void setGestureHandler(std::shared_ptr< IGestureHandler > handler)=0
virtual void erase(std::shared_ptr< ContentSelection > selection)=0
virtual ContentSelectionMode getSelectionMode()=0
virtual void setFontMetricsProvider(std::shared_ptr< myscript::iink::text::IFontMetricsProvider > fontMetricsProvider) noexcept=0
virtual void drawStroke(const std::vector< PointerEvent > &events, std::shared_ptr< graphics::ICanvas > canvas)=0
virtual void removeListener(std::shared_ptr< IEditorListener > listener) noexcept=0
virtual int getViewHeight()=0
virtual void clampViewOffset(graphics::Point &viewOffset)=0
virtual std::shared_ptr< Configuration > getConfiguration() noexcept=0
virtual std::shared_ptr< ContentBlock > getBlockById(const String &id)=0
virtual void setViewSize(int width, int height)=0
virtual bool canRedo() noexcept=0
virtual void undo()=0
virtual void setTextFormat(std::shared_ptr< ContentSelection > selection, TextFormat format)=0
virtual int getPossibleRedoCount()=0
virtual bool isIdle() noexcept=0
virtual void applyStyle(std::shared_ptr< ContentSelection > selection, const String &style)=0
virtual myscript::iink::graphics::Rectangle getBox(std::shared_ptr< ContentSelection > selection)=0
virtual void removeGestureHandler()=0
virtual void addListener(std::shared_ptr< IEditorListener > listener) noexcept=0
virtual std::shared_ptr< Engine > getEngine() noexcept=0
virtual void pointerEvents(const std::vector< PointerEvent > &events, bool processGestures=true)=0
virtual bool isEmpty(std::shared_ptr< ContentSelection > selection)=0
virtual std::vector< ConversionState > getSupportedTargetConversionStates(std::shared_ptr< ContentSelection > selection)=0
virtual void setSelectionMode(ContentSelectionMode mode)=0
virtual std::vector< String > getSupportedAddBlockTypes() noexcept=0
virtual std::vector< MimeType > getSupportedImportMimeTypes(std::shared_ptr< ContentSelection > selection)=0
virtual bool canUndo() noexcept=0
virtual void setPart(std::shared_ptr< ContentPart > part)=0
virtual void convert(std::shared_ptr< ContentSelection > selection, ConversionState targetState)=0
virtual std::shared_ptr< ContentBlock > addBlock(float x, float y, const String &type)=0
virtual std::vector< MimeType > getSupportedAddBlockDataMimeTypes(const String &type) noexcept=0
virtual void setSelection(std::shared_ptr< ContentSelection > selection)=0
virtual IndentationLevels getIndentationLevels(std::shared_ptr< ContentSelection > selection)=0
virtual void import_(MimeType mimeType, const String &data, std::shared_ptr< ContentSelection > selection=nullptr, std::shared_ptr< ParameterSet > overrideConfiguration=nullptr)=0
virtual std::vector< TextFormat > getSupportedTextFormats(std::shared_ptr< ContentSelection > selection)=0
virtual String getTheme() const noexcept=0
virtual void setSelectionType(std::shared_ptr< ContentSelection > selection, const String &type, bool forceSingleBlock)=0
virtual void paste(float x, float y)=0
virtual void pointerUp(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId)=0
virtual std::shared_ptr< ContentBlock > getRootBlock()=0
virtual std::shared_ptr< ContentBlock > addImage(float x, float y, const String &inputFile, MimeType mimeType)=0
virtual std::shared_ptr< ContentBlock > hitBlock(float x, float y)=0
virtual std::shared_ptr< ContentSelection > hitSelection(float x, float y)=0
virtual std::vector< String > getIntersectingBlocks(std::shared_ptr< ContentSelection > selection)=0
virtual int getUndoStackIndex()=0
virtual bool hasSelection()=0
virtual void redo()=0
virtual void waitForIdle() noexcept=0
virtual std::vector< String > getIncludedBlocks(std::shared_ptr< ContentSelection > selection)=0
virtual std::shared_ptr< Renderer > getRenderer() noexcept=0
virtual std::shared_ptr< ContentSelection > getSelection()=0
virtual String export_(std::shared_ptr< ContentSelection > selection, MimeType mimeType, std::shared_ptr< ParameterSet > overrideConfiguration=nullptr)=0
virtual String pointerDown(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId)=0
virtual ~Editor()=default
virtual std::shared_ptr< ToolController > getToolController() noexcept=0
virtual std::vector< ContentSelectionMode > getAvailableSelectionModes()=0
virtual int getViewWidth()=0
virtual void transform(std::shared_ptr< ContentSelection > selection, const myscript::iink::graphics::Transform &transform)=0
virtual void pointerCancel(int pointerId)=0
virtual void indent(std::shared_ptr< ContentSelection > selection, int offset)=0
virtual std::vector< String > getAvailableSelectionTypes(std::shared_ptr< ContentSelection > selection)=0
virtual std::underlying_type< ConversionState >::type getConversionState(std::shared_ptr< ContentSelection > selection)=0
virtual String getUndoRedoIdAt(int stackIndex)=0
virtual void pointerMove(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId)=0
virtual std::vector< MimeType > getSupportedExportMimeTypes(std::shared_ptr< ContentSelection > selection)=0
virtual std::shared_ptr< ContentPart > getPart() noexcept=0
virtual void clear()=0
virtual void copy(std::shared_ptr< ContentSelection > selection)=0
Definition: IImagePainter.h:19
Definition: ParameterSet.h:16
Definition: Renderer.h:21
Definition: String.h:30
Definition: ToolController.h:31
Definition: ICanvas.h:23
TransformError
Definition: Editor.h:43
@ HAS_SCALE
Definition: Editor.h:59
@ TEXT_BLOCKS
Definition: Editor.h:51
@ INVALID
Definition: Editor.h:55
@ MATH_BLOCKS
Definition: Editor.h:52
@ NULL_SELECTION
Definition: Editor.h:47
@ ALLOWED
Definition: Editor.h:44
@ HAS_NEGATIVE_SCALE
Definition: Editor.h:60
@ HAS_SHEAR
Definition: Editor.h:61
@ GUIDES
Definition: Editor.h:54
@ MULTIPLE_BLOCKS
Definition: Editor.h:49
@ BAD_NUMERIC
Definition: Editor.h:57
@ BEAUTIFIED_BLOCKS
Definition: Editor.h:50
@ NON_INVERTIBLE
Definition: Editor.h:56
@ HAS_ROTATION
Definition: Editor.h:58
@ UNSUPPORTED
Definition: Editor.h:46
@ PARTIAL_BLOCKS
Definition: Editor.h:48
@ HAS_TRANSLATION
Definition: Editor.h:62
@ DRAWING_BLOCKS
Definition: Editor.h:53
TextFormat
Definition: Editor.h:71
ConversionState
Definition: ContentSelection.h:21
PointerType
Definition: PointerEvent.h:16
ContentSelectionMode
Definition: Editor.h:99
MimeType
Definition: MimeType.h:15
Definition: Configuration.h:11
Definition: Editor.h:86
IndentationLevels(size_t low_, size_t high_, size_t max_)
Definition: Editor.h:87
size_t max
Definition: Editor.h:92
size_t low
Definition: Editor.h:90
size_t high
Definition: Editor.h:91
Definition: PointerEvent.h:43
Definition: Transform.h:30