MyScript Interactive Ink SDK 4.5.0
Editor.h
1// Copyright @ MyScript. All rights reserved.
2
3#pragma once
4
5#include <iink/ContentSelection.h>
6#include <iink/Engine.h>
7#include <iink/graphics/Point.h>
8#include <iink/graphics/Rectangle.h>
9#include <iink/MimeType.h>
10#include <iink/PlaceholderController.h>
11#include <iink/PointerEvent.h>
12#include <iink/text/IFontMetricsProvider.h>
13
14#include <cstdint>
15#include <memory>
16#include <type_traits>
17#include <vector>
18
19namespace myscript {
20namespace iink {
21
22class Engine;
23class Configuration;
24class ContentBlock;
25class ContentPart;
26class IEditorListener;
27class IGestureHandler;
28class IImagePainter;
29class MathSolverController;
30class ParameterSet;
31class Renderer;
32class ToolController;
33
34namespace graphics {
35
36class ICanvas;
37struct Transform;
38
39}
40
45{
46 ALLOWED = 0,
48 UNSUPPORTED = 1 << 0,
49 NULL_SELECTION = 1 << 1,
50 PARTIAL_BLOCKS = 1 << 2,
51 MULTIPLE_BLOCKS = 1 << 3,
53 TEXT_BLOCKS = 1 << 5,
54 MATH_BLOCKS = 1 << 6,
55 DRAWING_BLOCKS = 1 << 7,
56 GUIDES = 1 << 8,
57 INVALID = 1 << 9,
58 NON_INVERTIBLE = 1 << 10,
59 BAD_NUMERIC = 1 << 11,
60 HAS_ROTATION = 1 << 12,
61 HAS_SCALE = 1 << 13,
63 HAS_SHEAR = 1 << 15,
64 HAS_TRANSLATION = 1 << 16,
65};
66
72enum class TextFormat
73{
74 H1 = 0,
75 H2 = 1,
76 PARAGRAPH = 2,
77 LIST_BULLET = 3,
78 LIST_CHECKBOX = 4,
79 LIST_NUMBERED = 5,
80};
81
88{
89 IndentationLevels(size_t low_, size_t high_, size_t max_)
90 : low(low_), high(high_), max(max_) {}
91
92 size_t low;
93 size_t high;
94 size_t max;
95};
96
101{
102 NONE = 0,
103 LASSO = 1,
104 ITEM = 2,
105 RESIZE = 3,
106 REFLOW = 4
107};
108
114enum class ImageFit
115{
116 FILL = 0,
117 CONTAIN = 1,
118 COVER = 2,
119};
120
128{
129public:
130
131 virtual ~Editor() = default;
132
138 virtual void addListener(std::shared_ptr<IEditorListener> listener) noexcept = 0;
139
145 virtual void removeListener(std::shared_ptr<IEditorListener> listener) noexcept = 0;
146
154 virtual void setGestureHandler(std::shared_ptr<IGestureHandler> handler) = 0;
155
161 virtual void removeGestureHandler() = 0;
162
168 virtual void setFontMetricsProvider(std::shared_ptr<myscript::iink::text::IFontMetricsProvider> fontMetricsProvider) noexcept = 0;
169
175 virtual std::shared_ptr<Engine> getEngine() noexcept = 0;
176
182 virtual std::shared_ptr<Renderer> getRenderer() noexcept = 0;
183
191 virtual std::shared_ptr<PlaceholderController> getPlaceholderController() = 0;
192
200 virtual std::shared_ptr<ToolController> getToolController() noexcept = 0;
201
209 virtual std::shared_ptr<MathSolverController> getMathSolverController() = 0;
210
216 virtual std::shared_ptr<ContentPart> getPart() noexcept = 0;
217
232 virtual void setPart(std::shared_ptr<ContentPart> part, bool forceReconfigure = false) = 0;
233
239 virtual void clear() = 0;
240
246 virtual bool canUndo() noexcept = 0;
247
252 virtual void undo() = 0;
253
259 virtual bool canRedo() noexcept = 0;
260
265 virtual void redo() = 0;
266
283 virtual int getUndoStackIndex() = 0;
284
294 virtual int getPossibleUndoCount() = 0;
295
305 virtual int getPossibleRedoCount() = 0;
306
320 virtual String getUndoRedoIdAt(int stackIndex) = 0;
321
327 virtual void clearUndoRedoStack() = 0;
328
349 virtual String pointerDown(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId) = 0;
350
377 virtual String pointerDown(float x, float y, int64_t t, float f, float tilt, float orientation, PointerType pointerType, int pointerId) = 0;
378
396 virtual void pointerMove(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId) = 0;
397
421 virtual void pointerMove(float x, float y, int64_t t, float f, float tilt, float orientation, PointerType pointerType, int pointerId) = 0;
422
439 virtual void pointerUp(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId) = 0;
440
463 virtual void pointerUp(float x, float y, int64_t t, float f, float tilt, float orientation, PointerType pointerType, int pointerId) = 0;
464
470 virtual void pointerCancel(int pointerId) = 0;
471
487 virtual void pointerEvents(const std::vector<PointerEvent>& events, bool processGestures = true) = 0;
488
498 virtual void setViewSize(int width, int height) = 0;
499
507 virtual int getViewWidth() = 0;
508
516 virtual int getViewHeight() = 0;
517
526 virtual void clampViewOffset(graphics::Point& viewOffset) = 0;
527
537 virtual void setTheme(const String& styleSheet) = 0;
538
544 virtual String getTheme() const noexcept = 0;
545
551 virtual std::shared_ptr<ContentBlock> getRootBlock() = 0;
552
561 virtual std::shared_ptr<ContentBlock> getBlockById(const String& id) = 0;
562
573 virtual bool isEmpty(std::shared_ptr<ContentSelection> selection) = 0;
574
581 virtual std::vector<String> getSupportedAddBlockTypes() noexcept = 0;
582
590 virtual std::vector<MimeType> getSupportedAddBlockDataMimeTypes(const String& type) noexcept = 0;
591
610 virtual std::shared_ptr<ContentBlock> addBlock(float x, float y, const String& type) = 0;
611
636 virtual std::shared_ptr<ContentBlock> addBlock(float x, float y, const String& type, MimeType mimeType, const String& data) = 0;
637
662 virtual std::shared_ptr<ContentBlock> addImage(float x, float y, const String& inputFile, MimeType mimeType) = 0;
663
681 virtual void setBackgroundImage(const String& inputFile, MimeType mimeType, ImageFit fit) = 0;
682
692
705 virtual void erase(std::shared_ptr<ContentSelection> selection) = 0;
706
716 virtual std::shared_ptr<ContentBlock> hitBlock(float x, float y) = 0;
717
729 virtual std::shared_ptr<ContentBlock> hitSubBlock(float x, float y) = 0;
730
741 virtual std::vector<ConversionState> getSupportedTargetConversionStates(std::shared_ptr<ContentSelection> selection) = 0;
742
758 virtual void convert(std::shared_ptr<ContentSelection> selection, ConversionState targetState) = 0;
759
769 virtual std::vector<MimeType> getSupportedExportMimeTypes(std::shared_ptr<ContentSelection> selection) = 0;
770
792 virtual String export_(std::shared_ptr<ContentSelection> selection, MimeType mimeType, std::shared_ptr<ParameterSet> overrideConfiguration = nullptr) = 0;
793
819 virtual void export_(std::shared_ptr<ContentSelection> selection, const String& outputFile, std::shared_ptr<IImagePainter> imagePainter, std::shared_ptr<ParameterSet> overrideConfiguration = nullptr) = 0;
820
846 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;
847
857 virtual std::vector<MimeType> getSupportedImportMimeTypes(std::shared_ptr<ContentSelection> selection) = 0;
858
875 virtual void import_(MimeType mimeType, const String& data, std::shared_ptr<ContentSelection> selection = nullptr, std::shared_ptr<ParameterSet> overrideConfiguration = nullptr) = 0;
876
889 virtual void copy(std::shared_ptr<ContentSelection> selection) = 0;
890
908 virtual void paste(float x, float y) = 0;
909
915 virtual bool isIdle() noexcept = 0;
916
920 virtual void waitForIdle() noexcept = 0;
921
930 virtual bool isScrollAllowed() noexcept = 0;
931
937 virtual std::shared_ptr<Configuration> getConfiguration() noexcept = 0;
938
954 virtual void drawStroke(const std::vector<PointerEvent>& events, std::shared_ptr<graphics::ICanvas> canvas) = 0;
955
965 virtual bool hasSelection() = 0;
966
978 virtual std::shared_ptr<ContentSelection> getSelection() = 0;
979
995 virtual void setSelection(std::shared_ptr<ContentSelection> selection, ContentSelectionMode mode = ContentSelectionMode::NONE) = 0;
996
1009 virtual std::shared_ptr<ContentSelection> hitSelection(float x, float y) = 0;
1010
1024 virtual std::vector<String> getIntersectingBlocks(std::shared_ptr<ContentSelection> selection) = 0;
1025
1039 virtual std::vector<String> getIncludedBlocks(std::shared_ptr<ContentSelection> selection) = 0;
1040
1041
1055 virtual std::underlying_type<TransformError>::type getTransformStatus(std::shared_ptr<ContentSelection> selection, const myscript::iink::graphics::Transform& transform) = 0;
1056
1072 virtual void transform(std::shared_ptr<ContentSelection> selection, const myscript::iink::graphics::Transform& transform) = 0;
1073
1087 virtual void applyStyle(std::shared_ptr<ContentSelection> selection, const String& style) = 0;
1088
1100 virtual std::vector<TextFormat> getSupportedTextFormats(std::shared_ptr<ContentSelection> selection) = 0;
1101
1114 virtual void setTextFormat(std::shared_ptr<ContentSelection> selection, TextFormat format) = 0;
1115
1126
1140
1153 virtual std::vector<ContentSelectionMode> getAvailableSelectionModes(std::shared_ptr<ContentSelection> selection = nullptr) = 0;
1154
1170 virtual void setSelectionType(std::shared_ptr<ContentSelection> selection, const String& type, bool forceSingleBlock) = 0;
1171
1184 virtual std::vector<String> getAvailableSelectionTypes(std::shared_ptr<ContentSelection> selection) = 0;
1185
1201 virtual IndentationLevels getIndentationLevels(std::shared_ptr<ContentSelection> selection) = 0;
1202
1223 virtual void indent(std::shared_ptr<ContentSelection> selection, int offset) = 0;
1224
1237 virtual myscript::iink::graphics::Rectangle getBox(std::shared_ptr<ContentSelection> selection) = 0;
1238
1252 virtual std::underlying_type<ConversionState>::type getConversionState(std::shared_ptr<ContentSelection> selection) = 0;
1253};
1254
1255}
1256}
Definition: Configuration.h:19
Definition: ContentBlock.h:22
Definition: ContentPart.h:25
Definition: ContentSelection.h:33
Definition: Editor.h:128
virtual std::shared_ptr< ContentSelection > getSelection()=0
virtual void setTheme(const String &styleSheet)=0
virtual int getPossibleUndoCount()=0
virtual void setPart(std::shared_ptr< ContentPart > part, bool forceReconfigure=false)=0
virtual bool isScrollAllowed() noexcept=0
virtual std::shared_ptr< PlaceholderController > getPlaceholderController()=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 std::vector< String > getAvailableSelectionTypes(std::shared_ptr< ContentSelection > selection)=0
virtual int getViewHeight()=0
virtual std::vector< TextFormat > getSupportedTextFormats(std::shared_ptr< ContentSelection > selection)=0
virtual std::shared_ptr< ContentBlock > getBlockById(const String &id)=0
virtual void clampViewOffset(graphics::Point &viewOffset)=0
virtual std::underlying_type< ConversionState >::type getConversionState(std::shared_ptr< ContentSelection > selection)=0
virtual std::shared_ptr< ContentPart > getPart() noexcept=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 std::vector< String > getIntersectingBlocks(std::shared_ptr< ContentSelection > selection)=0
virtual int getPossibleRedoCount()=0
virtual std::shared_ptr< ContentSelection > hitSelection(float x, float y)=0
virtual bool isIdle() noexcept=0
virtual std::shared_ptr< Engine > getEngine() noexcept=0
virtual std::vector< MimeType > getSupportedImportMimeTypes(std::shared_ptr< ContentSelection > selection)=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 std::shared_ptr< ContentBlock > hitSubBlock(float x, float y)=0
virtual void addListener(std::shared_ptr< IEditorListener > listener) noexcept=0
virtual std::shared_ptr< ContentBlock > hitBlock(float x, float y)=0
virtual void pointerEvents(const std::vector< PointerEvent > &events, bool processGestures=true)=0
virtual std::shared_ptr< ContentBlock > getRootBlock()=0
virtual bool isEmpty(std::shared_ptr< ContentSelection > selection)=0
virtual void setSelectionMode(ContentSelectionMode mode)=0
virtual String getBackgroundImage()=0
virtual bool canUndo() noexcept=0
virtual std::vector< MimeType > getSupportedExportMimeTypes(std::shared_ptr< ContentSelection > selection)=0
virtual void convert(std::shared_ptr< ContentSelection > selection, ConversionState targetState)=0
virtual std::vector< MimeType > getSupportedAddBlockDataMimeTypes(const String &type) noexcept=0
virtual std::vector< ContentSelectionMode > getAvailableSelectionModes(std::shared_ptr< ContentSelection > selection=nullptr)=0
virtual std::underlying_type< TransformError >::type getTransformStatus(std::shared_ptr< ContentSelection > selection, const myscript::iink::graphics::Transform &transform)=0
virtual std::shared_ptr< MathSolverController > getMathSolverController()=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::shared_ptr< ContentBlock > addImage(float x, float y, const String &inputFile, MimeType mimeType)=0
virtual String getTheme() const noexcept=0
virtual void clearUndoRedoStack()=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::vector< ConversionState > getSupportedTargetConversionStates(std::shared_ptr< ContentSelection > selection)=0
virtual std::shared_ptr< ContentBlock > addBlock(float x, float y, const String &type)=0
virtual std::vector< String > getIncludedBlocks(std::shared_ptr< ContentSelection > selection)=0
virtual int getUndoStackIndex()=0
virtual bool hasSelection()=0
virtual void redo()=0
virtual void setSelection(std::shared_ptr< ContentSelection > selection, ContentSelectionMode mode=ContentSelectionMode::NONE)=0
virtual void waitForIdle() noexcept=0
virtual String export_(std::shared_ptr< ContentSelection > selection, MimeType mimeType, std::shared_ptr< ParameterSet > overrideConfiguration=nullptr)=0
virtual std::vector< String > getSupportedAddBlockTypes() noexcept=0
virtual String pointerDown(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId)=0
virtual void setBackgroundImage(const String &inputFile, MimeType mimeType, ImageFit fit)=0
virtual ~Editor()=default
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 String getUndoRedoIdAt(int stackIndex)=0
virtual void pointerMove(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId)=0
virtual std::shared_ptr< Configuration > getConfiguration() noexcept=0
virtual std::shared_ptr< ToolController > getToolController() noexcept=0
virtual void clear()=0
virtual void copy(std::shared_ptr< ContentSelection > selection)=0
virtual std::shared_ptr< Renderer > getRenderer() noexcept=0
Definition: IImagePainter.h:19
Definition: MathSolverController.h:133
Definition: ParameterSet.h:16
Definition: PlaceholderController.h:38
Definition: Renderer.h:21
Definition: String.h:17
Definition: ToolController.h:31
Definition: ICanvas.h:26
TransformError
Definition: Editor.h:45
@ HAS_SCALE
Definition: Editor.h:61
@ TEXT_BLOCKS
Definition: Editor.h:53
@ INVALID
Definition: Editor.h:57
@ MATH_BLOCKS
Definition: Editor.h:54
@ NULL_SELECTION
Definition: Editor.h:49
@ ALLOWED
Definition: Editor.h:46
@ HAS_NEGATIVE_SCALE
Definition: Editor.h:62
@ HAS_SHEAR
Definition: Editor.h:63
@ GUIDES
Definition: Editor.h:56
@ MULTIPLE_BLOCKS
Definition: Editor.h:51
@ BAD_NUMERIC
Definition: Editor.h:59
@ BEAUTIFIED_BLOCKS
Definition: Editor.h:52
@ NON_INVERTIBLE
Definition: Editor.h:58
@ HAS_ROTATION
Definition: Editor.h:60
@ UNSUPPORTED
Definition: Editor.h:48
@ PARTIAL_BLOCKS
Definition: Editor.h:50
@ HAS_TRANSLATION
Definition: Editor.h:64
@ DRAWING_BLOCKS
Definition: Editor.h:55
TextFormat
Definition: Editor.h:73
ConversionState
Definition: ContentSelection.h:21
PointerType
Definition: PointerEvent.h:18
ContentSelectionMode
Definition: Editor.h:101
ImageFit
Definition: Editor.h:115
MimeType
Definition: MimeType.h:15
Definition: Configuration.h:10
Definition: Editor.h:88
IndentationLevels(size_t low_, size_t high_, size_t max_)
Definition: Editor.h:89
size_t max
Definition: Editor.h:94
size_t low
Definition: Editor.h:92
size_t high
Definition: Editor.h:93
Definition: PointerEvent.h:45
Definition: Transform.h:31