MyScript Interactive Ink SDK  3.2.0
Editor.h
1 // Copyright @ MyScript. All rights reserved.
2 
3 #pragma once
4 
5 #include <iink/Engine.h>
6 #include <iink/PlaceholderController.h>
7 #include <iink/PointerEvent.h>
8 #include <iink/graphics/Point.h>
9 #include <iink/graphics/Rectangle.h>
10 #include <iink/text/IFontMetricsProvider.h>
11 #include <iink/ContentSelection.h>
12 #include <iink/MimeType.h>
13 
14 #include <cstdint>
15 #include <memory>
16 #include <type_traits>
17 #include <vector>
18 
19 namespace myscript {
20 namespace iink {
21 
22 class Engine;
23 class Configuration;
24 class Renderer;
25 class ToolController;
26 class IEditorListener;
27 class IGestureHandler;
28 class IImagePainter;
29 class ContentPart;
30 class ContentBlock;
31 class ParameterSet;
32 
33 namespace graphics {
34 
35 class ICanvas;
36 struct Transform;
37 
38 }
39 
44 {
45  ALLOWED = 0,
47  UNSUPPORTED = 1 << 0,
48  NULL_SELECTION = 1 << 1,
49  PARTIAL_BLOCKS = 1 << 2,
50  MULTIPLE_BLOCKS = 1 << 3,
51  BEAUTIFIED_BLOCKS = 1 << 4,
52  TEXT_BLOCKS = 1 << 5,
53  MATH_BLOCKS = 1 << 6,
54  DRAWING_BLOCKS = 1 << 7,
55  GUIDES = 1 << 8,
56  INVALID = 1 << 9,
57  NON_INVERTIBLE = 1 << 10,
58  BAD_NUMERIC = 1 << 11,
59  HAS_ROTATION = 1 << 12,
60  HAS_SCALE = 1 << 13,
61  HAS_NEGATIVE_SCALE = 1 << 14,
62  HAS_SHEAR = 1 << 15,
63  HAS_TRANSLATION = 1 << 16,
64 };
65 
71 enum class TextFormat
72 {
73  H1 = 0,
74  H2 = 1,
75  PARAGRAPH = 2,
76  LIST_BULLET = 3,
77  LIST_CHECKBOX = 4,
78  LIST_NUMBERED = 5,
79 };
80 
87 {
88  IndentationLevels(size_t low_, size_t high_, size_t max_)
89  : low(low_), high(high_), max(max_) {}
90 
91  size_t low;
92  size_t high;
93  size_t max;
94 };
95 
100 {
101  NONE = 0,
102  LASSO = 1,
103  ITEM = 2,
104  RESIZE = 3,
105  REFLOW = 4
106 };
107 
114 class Editor
115 {
116 public:
117 
118  virtual ~Editor() = default;
119 
125  virtual void addListener(std::shared_ptr<IEditorListener> listener) noexcept = 0;
126 
132  virtual void removeListener(std::shared_ptr<IEditorListener> listener) noexcept = 0;
133 
141  virtual void setGestureHandler(std::shared_ptr<IGestureHandler> handler) = 0;
142 
148  virtual void removeGestureHandler() = 0;
149 
155  virtual void setFontMetricsProvider(std::shared_ptr<myscript::iink::text::IFontMetricsProvider> fontMetricsProvider) noexcept = 0;
156 
162  virtual std::shared_ptr<Engine> getEngine() noexcept = 0;
163 
169  virtual std::shared_ptr<Renderer> getRenderer() noexcept = 0;
170 
178  virtual std::shared_ptr<PlaceholderController> getPlaceholderController() = 0;
179 
187  virtual std::shared_ptr<ToolController> getToolController() noexcept = 0;
188 
194  virtual std::shared_ptr<ContentPart> getPart() noexcept = 0;
195 
206  virtual void setPart(std::shared_ptr<ContentPart> part) = 0;
207 
213  virtual void clear() = 0;
214 
220  virtual bool canUndo() noexcept = 0;
221 
226  virtual void undo() = 0;
227 
233  virtual bool canRedo() noexcept = 0;
234 
239  virtual void redo() = 0;
240 
257  virtual int getUndoStackIndex() = 0;
258 
268  virtual int getPossibleUndoCount() = 0;
269 
279  virtual int getPossibleRedoCount() = 0;
280 
294  virtual String getUndoRedoIdAt(int stackIndex) = 0;
295 
316  virtual String pointerDown(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId) = 0;
317 
335  virtual void pointerMove(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId) = 0;
336 
353  virtual void pointerUp(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId) = 0;
354 
360  virtual void pointerCancel(int pointerId) = 0;
361 
377  virtual void pointerEvents(const std::vector<PointerEvent>& events, bool processGestures = true) = 0;
378 
388  virtual void setViewSize(int width, int height) = 0;
389 
397  virtual int getViewWidth() = 0;
398 
406  virtual int getViewHeight() = 0;
407 
416  virtual void clampViewOffset(graphics::Point& viewOffset) = 0;
417 
427  virtual void setTheme(const String& styleSheet) = 0;
428 
434  virtual String getTheme() const noexcept = 0;
435 
441  virtual std::shared_ptr<ContentBlock> getRootBlock() = 0;
442 
451  virtual std::shared_ptr<ContentBlock> getBlockById(const String& id) = 0;
452 
463  virtual bool isEmpty(std::shared_ptr<ContentSelection> selection) = 0;
464 
471  virtual std::vector<String> getSupportedAddBlockTypes() noexcept = 0;
472 
480  virtual std::vector<MimeType> getSupportedAddBlockDataMimeTypes(const String& type) noexcept = 0;
481 
500  virtual std::shared_ptr<ContentBlock> addBlock(float x, float y, const String& type) = 0;
501 
526  virtual std::shared_ptr<ContentBlock> addBlock(float x, float y, const String& type, MimeType mimeType, const String& data) = 0;
527 
552  virtual std::shared_ptr<ContentBlock> addImage(float x, float y, const String& inputFile, MimeType mimeType) = 0;
553 
566  virtual void erase(std::shared_ptr<ContentSelection> selection) = 0;
567 
577  virtual std::shared_ptr<ContentBlock> hitBlock(float x, float y) = 0;
578 
589  virtual std::vector<ConversionState> getSupportedTargetConversionStates(std::shared_ptr<ContentSelection> selection) = 0;
590 
606  virtual void convert(std::shared_ptr<ContentSelection> selection, ConversionState targetState) = 0;
607 
617  virtual std::vector<MimeType> getSupportedExportMimeTypes(std::shared_ptr<ContentSelection> selection) = 0;
618 
640  virtual String export_(std::shared_ptr<ContentSelection> selection, MimeType mimeType, std::shared_ptr<ParameterSet> overrideConfiguration = nullptr) = 0;
641 
667  virtual void export_(std::shared_ptr<ContentSelection> selection, const String& outputFile, std::shared_ptr<IImagePainter> imagePainter, std::shared_ptr<ParameterSet> overrideConfiguration = nullptr) = 0;
668 
694  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;
695 
705  virtual std::vector<MimeType> getSupportedImportMimeTypes(std::shared_ptr<ContentSelection> selection) = 0;
706 
723  virtual void import_(MimeType mimeType, const String& data, std::shared_ptr<ContentSelection> selection = nullptr, std::shared_ptr<ParameterSet> overrideConfiguration = nullptr) = 0;
724 
737  virtual void copy(std::shared_ptr<ContentSelection> selection) = 0;
738 
756  virtual void paste(float x, float y) = 0;
757 
763  virtual bool isIdle() noexcept = 0;
764 
768  virtual void waitForIdle() noexcept = 0;
769 
778  virtual bool isScrollAllowed() noexcept = 0;
779 
785  virtual std::shared_ptr<Configuration> getConfiguration() noexcept = 0;
786 
802  virtual void drawStroke(const std::vector<PointerEvent>& events, std::shared_ptr<graphics::ICanvas> canvas) = 0;
803 
813  virtual bool hasSelection() = 0;
814 
826  virtual std::shared_ptr<ContentSelection> getSelection() = 0;
827 
841  virtual void setSelection(std::shared_ptr<ContentSelection> selection) = 0;
842 
855  virtual std::shared_ptr<ContentSelection> hitSelection(float x, float y) = 0;
856 
870  virtual std::vector<String> getIntersectingBlocks(std::shared_ptr<ContentSelection> selection) = 0;
871 
885  virtual std::vector<String> getIncludedBlocks(std::shared_ptr<ContentSelection> selection) = 0;
886 
887 
901  virtual std::underlying_type<TransformError>::type getTransformStatus(std::shared_ptr<ContentSelection> selection, const myscript::iink::graphics::Transform& transform) = 0;
902 
918  virtual void transform(std::shared_ptr<ContentSelection> selection, const myscript::iink::graphics::Transform& transform) = 0;
919 
933  virtual void applyStyle(std::shared_ptr<ContentSelection> selection, const String& style) = 0;
934 
946  virtual std::vector<TextFormat> getSupportedTextFormats(std::shared_ptr<ContentSelection> selection) = 0;
947 
960  virtual void setTextFormat(std::shared_ptr<ContentSelection> selection, TextFormat format) = 0;
961 
972 
985  virtual void setSelectionMode(ContentSelectionMode mode) = 0;
986 
997 
1013  virtual void setSelectionType(std::shared_ptr<ContentSelection> selection, const String& type, bool forceSingleBlock) = 0;
1014 
1027  virtual std::vector<String> getAvailableSelectionTypes(std::shared_ptr<ContentSelection> selection) = 0;
1028 
1044  virtual IndentationLevels getIndentationLevels(std::shared_ptr<ContentSelection> selection) = 0;
1045 
1066  virtual void indent(std::shared_ptr<ContentSelection> selection, int offset) = 0;
1067 
1080  virtual myscript::iink::graphics::Rectangle getBox(std::shared_ptr<ContentSelection> selection) = 0;
1081 
1095  virtual std::underlying_type<ConversionState>::type getConversionState(std::shared_ptr<ContentSelection> selection) = 0;
1096 };
1097 
1098 }
1099 }
Definition: Configuration.h:20
Definition: ContentBlock.h:19
Definition: ContentPart.h:24
Definition: ContentSelection.h:33
Definition: Editor.h:115
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 std::shared_ptr< PlaceholderController > getPlaceholderController()=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: PlaceholderController.h:38
Definition: Renderer.h:21
Definition: String.h:27
Definition: ToolController.h:31
Definition: ICanvas.h:25
TransformError
Definition: Editor.h:44
@ HAS_SCALE
Definition: Editor.h:60
@ TEXT_BLOCKS
Definition: Editor.h:52
@ INVALID
Definition: Editor.h:56
@ MATH_BLOCKS
Definition: Editor.h:53
@ NULL_SELECTION
Definition: Editor.h:48
@ ALLOWED
Definition: Editor.h:45
@ HAS_NEGATIVE_SCALE
Definition: Editor.h:61
@ HAS_SHEAR
Definition: Editor.h:62
@ GUIDES
Definition: Editor.h:55
@ MULTIPLE_BLOCKS
Definition: Editor.h:50
@ BAD_NUMERIC
Definition: Editor.h:58
@ BEAUTIFIED_BLOCKS
Definition: Editor.h:51
@ NON_INVERTIBLE
Definition: Editor.h:57
@ HAS_ROTATION
Definition: Editor.h:59
@ UNSUPPORTED
Definition: Editor.h:47
@ PARTIAL_BLOCKS
Definition: Editor.h:49
@ HAS_TRANSLATION
Definition: Editor.h:63
@ DRAWING_BLOCKS
Definition: Editor.h:54
TextFormat
Definition: Editor.h:72
ConversionState
Definition: ContentSelection.h:21
PointerType
Definition: PointerEvent.h:16
ContentSelectionMode
Definition: Editor.h:100
MimeType
Definition: MimeType.h:15
Definition: Configuration.h:11
Definition: Editor.h:87
IndentationLevels(size_t low_, size_t high_, size_t max_)
Definition: Editor.h:88
size_t max
Definition: Editor.h:93
size_t low
Definition: Editor.h:91
size_t high
Definition: Editor.h:92
Definition: PointerEvent.h:43
Definition: Transform.h:31