diff --git a/src/Tizen.NUI.PenWave/src/internal/Canvas/CanvasRenderer.cs b/src/Tizen.NUI.PenWave/src/Internal/Canvas/CanvasRenderer.cs similarity index 73% rename from src/Tizen.NUI.PenWave/src/internal/Canvas/CanvasRenderer.cs rename to src/Tizen.NUI.PenWave/src/Internal/Canvas/CanvasRenderer.cs index 373055a65f3..241f002f16d 100644 --- a/src/Tizen.NUI.PenWave/src/internal/Canvas/CanvasRenderer.cs +++ b/src/Tizen.NUI.PenWave/src/Internal/Canvas/CanvasRenderer.cs @@ -45,6 +45,7 @@ internal class CanvasRenderer // Canvas id. private uint canvasId; + private PenWave engine; /// /// Constructor. Creates a new instance of CanvasRenderer. This constructor sets the current canvas to the specified canvas id. Also it sets paths to resources and initializes textures. @@ -53,10 +54,11 @@ internal class CanvasRenderer public CanvasRenderer(uint canvasId) { this.canvasId = canvasId; - PWEngine.SetCurrentCanvas(canvasId); - PWEngine.SetResourcePath(FrameworkInformation.ResourcePath + "images/"); - PWEngine.SetFontPath(FontPath); - PWEngine.SetTexturePaths(TexturePaths, TexturePaths.Length); + engine = PenWave.Instance; + engine.SetCurrentCanvas(canvasId); + engine.SetResourcePath(FrameworkInformation.ResourcePath + "images/"); + engine.SetFontPath(FontPath); + engine.SetTexturePaths(TexturePaths, TexturePaths.Length); } /// @@ -64,7 +66,7 @@ public CanvasRenderer(uint canvasId) /// public void InitializeGL() { - PWEngine.InitializeGL(); + engine.InitializeGL(); } /// @@ -72,7 +74,7 @@ public void InitializeGL() /// public void TerminateGL() { - PWEngine.TerminateGL(); + engine.TerminateGL(); } /// @@ -82,7 +84,7 @@ public void TerminateGL() /// public int RenderFrame(in DirectRenderingGLView.RenderCallbackInput input) { - return PWEngine.RenderFrameGL(); + return engine.RenderFrameGL(); } /// @@ -92,8 +94,8 @@ public int RenderFrame(in DirectRenderingGLView.RenderCallbackInput input) /// public void Resize(int width, int height) { - PWEngine.UpdateGLWindowSize(width, height); - PWEngine.RenderFullyReDraw(); + engine.UpdateGLWindowSize(width, height); + engine.RenderFullyReDraw(); } /// @@ -101,7 +103,7 @@ public void Resize(int width, int height) /// public void ClearCanvas() { - PWEngine.ClearCurrentCanvas(); + engine.ClearCurrentCanvas(); } /// @@ -110,7 +112,7 @@ public void ClearCanvas() /// public void AddPicture(string path, Size2D size, Position2D position) { - PWEngine.AddPicture(path, position.X, position.Y, size.Width, size.Height); + engine.AddPicture(path, position.X, position.Y, size.Width, size.Height); } /// @@ -119,7 +121,7 @@ public void AddPicture(string path, Size2D size, Position2D position) /// public void ToggleGrid(GridDensityType gridType) { - PWEngine.ToggleGrid((int)gridType); + engine.ToggleGrid((int)gridType); } /// @@ -128,7 +130,7 @@ public void ToggleGrid(GridDensityType gridType) /// public void SetCanvasColor(Color color) { - PWEngine.CanvasSetColor(ToHex(color), 1.0f); + engine.CanvasSetColor(ToHex(color), 1.0f); } /// @@ -137,7 +139,7 @@ public void SetCanvasColor(Color color) /// public void SaveCanvas(string path) { - PWEngine.SaveCanvas(canvasId, path); + engine.SaveCanvas(canvasId, path); } /// @@ -152,10 +154,25 @@ public void LoadCanvas(string path) } else { - PWEngine.LoadCanvas(canvasId, path); + engine.LoadCanvas(canvasId, path); } } + /// + /// Takes screenshot of the current canvas and saves it to the specified path. The area of the screenshot is defined by the coordinates and dimensions. The callback is called when the screenshot is saved. The callback has one parameter which is the path to the saved image. If the path is null, then the screenshot was not saved successfully. + /// + /// + /// + /// + /// + /// + /// + public void TakeScreenShot(string path, int x, int y, int width, int height, PenWave.ThumbnailSavedCallback callback) + { + engine.TakeScreenshot(canvasId, path, x, y, width, height, callback); + } + + // Converts Color to hex string. private string ToHex(Color color) { var red = (uint)(color.R * 255); diff --git a/src/Tizen.NUI.PenWave/src/Interop/PenWave.cs b/src/Tizen.NUI.PenWave/src/Interop/PenWave.cs new file mode 100644 index 00000000000..db40f94b37f --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/Interop/PenWave.cs @@ -0,0 +1,366 @@ +using System; +using System.Text; +using System.Runtime.InteropServices; + +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using System.ComponentModel; +using System.Net.Http.Headers; +using System.Data; + +namespace Tizen.NUI.PenWave +{ + internal static partial class Interop + { + public static partial class PenWave + { + public const string Lib = "libhand-drawing-engine.so"; + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "InitializeGL")] + public static extern void InitializeGL(); + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "RenderFrameGL")] + public static extern int RenderFrameGL(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "RenderFullyReDraw")] + public static extern void RenderFullyReDraw(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "TerminateGL")] + public static extern void TerminateGL(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "UpdateGLWindowSize")] + public static extern void UpdateGLWindowSize(int w, int h); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "UpdateGLWindowOrientation")] + public static extern void UpdateGLWindowOrientation(int angle); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "BeginShapeDraw")] + public static extern uint BeginShapeDraw(float x, float y, uint time = 1); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "DrawShape")] + public static extern int DrawShape(uint shapeID, float x, float y, uint time = 1); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "EndShapeDraw")] + public static extern int EndShapeDraw(uint shapeID, uint time = 1); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "StopErasing")] + public static extern void StopErasing(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "EraseShape")] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool EraseShape(int x, int y, float radius, [MarshalAs(UnmanagedType.I1)] bool partial); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "AddRectanglePath")] + public static extern uint AddRectanglePath(float xStart, float yStart, float x, float y, bool finished); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "AddArcPath")] + public static extern uint AddArcPath(float xCenter, float yCenter, float radius, float x, float y, bool finished); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ResizeShapePath")] + public static extern int ResizeShapePath(uint shapeID, float x, float y); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "FinishShapePath")] + public static extern int FinishShapePath(uint shapeID); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasZoomBegin")] + public static extern bool CanvasZoomBegin(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasZoom")] + public static extern bool CanvasZoom(float x, float y, float zoom, float dx, float dy); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasZoomEnd")] + public static extern bool CanvasZoomEnd(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasGetZoomValue")] + public static extern int CanvasGetZoomValue(); + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasSetZoomValue")] + public static extern float CanvasSetZoomValue(float zoomValue); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasMoveBegin")] + public static extern bool CanvasMoveBegin(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasMove")] + public static extern bool CanvasMove(int x, int y); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasMoveEnd")] + public static extern bool CanvasMoveEnd(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasSetColor")] + public static extern void CanvasSetColor([MarshalAs(UnmanagedType.LPStr)] string hexColor, float a); + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasSetSize")] + public static extern void CanvasSetSize(int width, int height); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetResourcePath")] + public static extern void SetResourcePath([MarshalAs(UnmanagedType.LPStr)] string resourcePath); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetFontPath")] + public static extern void SetFontPath([MarshalAs(UnmanagedType.LPStr)] string fontPath); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetTexturePaths")] + public static extern void SetTexturePaths([MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr)] string[] texturePaths, int textureCount); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetStrokeSize")] + public static extern void SetStrokeSize(float val); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetStrokeColor")] + public static extern void SetStrokeColor([MarshalAs(UnmanagedType.LPStr)] string hexColor, float a); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetStrokeType")] + public static extern void SetStrokeType(int brushId); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetBrushTexture")] + public static extern void SetBrushTexture(int textureId); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetBrushDistance")] + public static extern void SetBrushDistance(float distance); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetDashArray")] + public static extern void SetDashArray([MarshalAs(UnmanagedType.LPStr)] string dashArray); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetLineAngle")] + public static extern void SetLineAngle(float angle); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetBrushSize")] + public static extern float GetBrushSize(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetBrushColor")] + public static extern float GetBrushColor([MarshalAs(UnmanagedType.LPStr)] StringBuilder hex); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetBrushType")] + public static extern int GetBrushType(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetBrushTexture")] + public static extern int GetBrushTexture(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetBrushDistance")] + public static extern float GetBrushDistance(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetLineAngle")] + public static extern float GetLineAngle(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetShapeCount")] + public static extern int GetShapeCount(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CreateCanvas")] + public static extern uint CreateCanvas(int canvasWidth, int canvasHeight); + + // #if PICTURE + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CreateCanvasWithBackgroundImage")] + public static extern uint CreateCanvasWithBackgroundImage([MarshalAs(UnmanagedType.LPStr)] string path); + // #endif + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetCurrentCanvas")] + public static extern void SetCurrentCanvas(uint canvasID); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ClearCurrentCanvas")] + public static extern void ClearCurrentCanvas(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "StartSelectingArea")] + public static extern void StartSelectingArea(float x, float y); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ResizeSelectedArea")] + public static extern void ResizeSelectedArea(float x, float y); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "InsideSelectedArea")] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool InsideSelectedArea(float x, float y); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetSelectionDimensions")] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool GetSelectionDimensions(ref float x, ref float y, ref float width, ref float height); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "TouchedDrawable")] + public static extern int TouchedDrawable(float x, float y); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SelectDrawable")] + public static extern int SelectDrawable(float x, float y); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SelectDrawables")] + public static extern int SelectDrawables(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "DragSelectedDrawables")] + public static extern void DragSelectedDrawables(float x, float y); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "EndDraging")] + public static extern void EndDraging(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "StartRotating")] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool StartRotating(float x, float y); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "RotateSelected")] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool RotateSelected(float x, float y); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "EndRotating")] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool EndRotating(float x, float y); + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "StartSelectionScale")] + public static extern void StartSelectionScale(bool anchorLeft, bool anchorRight, bool anchorTop, bool anchorBottom, ref float anchorX, ref float anchorY); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ScaleSelection")] + public static extern void ScaleSelection(float scaleFactorX, float scaleFactorY); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "EndSelectionScale")] + public static extern void EndSelectionScale(float scaleFactorX, float scaleFactorY); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "DropSelectedDrawables")] + public static extern void DropSelectedDrawables(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SelectedAreaZoom")] + public static extern void SelectedAreaZoom(float x, float y, float zoom); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SaveCanvas")] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool SaveCanvas(uint canvasID, [MarshalAs(UnmanagedType.LPStr)] string path); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "LoadCanvas")] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool LoadCanvas(uint canvasID, [MarshalAs(UnmanagedType.LPStr)] string path); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "TakeScreenshot")] + public static extern void TakeScreenshot(uint canvasID, [MarshalAs(UnmanagedType.LPStr)] string path, int x, int y, int width, int height, [MarshalAs(UnmanagedType.FunctionPtr)] Tizen.NUI.PenWave.PenWave.ThumbnailSavedCallback thumbSaved); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ToggleGrid")] + public static extern void ToggleGrid(int densityType); + + // #if CHART + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ToggleChartGrid")] + public static extern void ToggleChartGrid(int densityType); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetChartGridDensity")] + public static extern int GetChartGridDensity(); + // #endif + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "Dump")] + public static extern void Dump(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "Copy")] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool Copy(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "Paste")] + public static extern int Paste(float x, float y); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "Cut")] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool Cut(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "Remove")] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool Remove(); + + // #if CHART + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "AddChart")] + public static extern void AddChart(int chartType, [MarshalAs(UnmanagedType.LPStr)] string path); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ChangeMode")] + public static extern void ChangeMode(int mode); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ChartPosition")] + public static extern void ChartPosition(ref float x, ref float y); + // #endif + + // #if PICTURE + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "PlacePicture")] + public static extern void AddPicture([MarshalAs(UnmanagedType.LPStr)] string path, float x, float y, float width, float height); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetCanvasBackground")] + public static extern void SetCanvasBackground([MarshalAs(UnmanagedType.LPStr)] string path, float x, float y, float width, float height); + // #endif + + // #if TEXT + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "AddText")] + public static extern void AddText([MarshalAs(UnmanagedType.LPStr)] string text, float x, float y, float size); + // #endif + // #if NOTES + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "AddNote")] + public static extern uint AddNote(float x, float y, float w, float h); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "RemoveNote")] + public static extern void RemoveNote(uint noteID); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ClearNote")] + public static extern void ClearNote(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "DragNote")] + public static extern bool DragNote(float x, float y); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "EndNoteDragging")] + public static extern bool EndNoteDragging(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetNoteColor")] + public static extern void SetNoteColor([MarshalAs(UnmanagedType.LPStr)] string hexColor, float a); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetActiveNote")] + public static extern void SetActiveNote(uint noteID); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "TouchedNote")] + public static extern uint TouchedNote(float x, float y); + // #endif + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "Undo")] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool Undo(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "Redo")] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool Redo(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ResetUndo")] + public static extern void ResetUndo(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ResetRedo")] + public static extern void ResetRedo(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetConfigurationCount")] + public static extern int GetConfigurationCount(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetAllConfigurations", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr GetAllConfigurations(); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetConfiguration", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr GetConfiguration([MarshalAs(UnmanagedType.LPStr)] string key); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetConfigurationInt", CallingConvention = CallingConvention.Cdecl)] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool SetConfigurationInt([MarshalAs(UnmanagedType.LPStr)] string key, int value); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetConfigurationFloat", CallingConvention = CallingConvention.Cdecl)] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool SetConfigurationFloat([MarshalAs(UnmanagedType.LPStr)] string key, float value); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetConfigurationString", CallingConvention = CallingConvention.Cdecl)] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool SetConfigurationString([MarshalAs(UnmanagedType.LPStr)] string key, [MarshalAs(UnmanagedType.LPStr)] string value); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetConfigurationBool", CallingConvention = CallingConvention.Cdecl)] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool SetConfigurationBool([MarshalAs(UnmanagedType.LPStr)] string key, [MarshalAs(UnmanagedType.I1)] bool value); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SaveProfiler")] + [return:MarshalAs(UnmanagedType.I1)] + public static extern bool SaveProfiler([MarshalAs(UnmanagedType.LPStr)] string path); + + [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ResetProfiler")] + public static extern void ResetProfiler(); + + //Wrappers for Marshalled APIS + // public static void GetConfigurations(out ConfigParameter[] configParameters, out int count) + // { + // IntPtr configArrayPtr = GetAllConfigurations(); + // int engineConfigCount = GetConfigurationCount(); + // count = engineConfigCount; + + // ConfigParameter[] configArray = new ConfigParameter[count]; + + // for (int i = 0; i < count; i++) + // { + // configArray[i] = Marshal.PtrToStructure(configArrayPtr); + // configArrayPtr += Marshal.SizeOf(); + // } + + // configParameters = configArray; + // } + } + } +} diff --git a/src/Tizen.NUI.PenWave/src/public/Canvas/PWEngine.cs b/src/Tizen.NUI.PenWave/src/public/Canvas/PWEngine.cs deleted file mode 100644 index dac6dcdd278..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Canvas/PWEngine.cs +++ /dev/null @@ -1,374 +0,0 @@ -using System; -using System.Text; -using System.Runtime.InteropServices; - -using Tizen.NUI; -using Tizen.NUI.BaseComponents; -using System.ComponentModel; -using System.Net.Http.Headers; -using System.Data; - -namespace Tizen.NUI.PenWave -{ - - public class PWEngineDelegates - { - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate void ThumbnailSavedDelegate(); - - static public ThumbnailSavedDelegate mSwapThumbnailsDelegate = null; - } - - - public static class PWEngine - { - - public const string Lib = "libhand-drawing-engine.so"; - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "InitializeGL")] - public static extern void InitializeGL(); - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "RenderFrameGL")] - public static extern int RenderFrameGL(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "RenderFullyReDraw")] - public static extern void RenderFullyReDraw(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "TerminateGL")] - public static extern void TerminateGL(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "UpdateGLWindowSize")] - public static extern void UpdateGLWindowSize(int w, int h); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "UpdateGLWindowOrientation")] - public static extern void UpdateGLWindowOrientation(int angle); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "BeginShapeDraw")] - public static extern uint BeginShapeDraw(float x, float y, uint time = 1); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "DrawShape")] - public static extern int DrawShape(uint shapeID, float x, float y, uint time = 1); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "EndShapeDraw")] - public static extern int EndShapeDraw(uint shapeID, uint time = 1); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "StopErasing")] - public static extern void StopErasing(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "EraseShape")] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool EraseShape(int x, int y, float radius, [MarshalAs(UnmanagedType.I1)] bool partial); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "AddRectanglePath")] - public static extern uint AddRectanglePath(float xStart, float yStart, float x, float y, bool finished); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "AddArcPath")] - public static extern uint AddArcPath(float xCenter, float yCenter, float radius, float x, float y, bool finished); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ResizeShapePath")] - public static extern int ResizeShapePath(uint shapeID, float x, float y); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "FinishShapePath")] - public static extern int FinishShapePath(uint shapeID); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasZoomBegin")] - public static extern bool CanvasZoomBegin(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasZoom")] - public static extern bool CanvasZoom(float x, float y, float zoom, float dx, float dy); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasZoomEnd")] - public static extern bool CanvasZoomEnd(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasGetZoomValue")] - public static extern int CanvasGetZoomValue(); - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasSetZoomValue")] - public static extern float CanvasSetZoomValue(float zoomValue); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasMoveBegin")] - public static extern bool CanvasMoveBegin(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasMove")] - public static extern bool CanvasMove(int x, int y); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasMoveEnd")] - public static extern bool CanvasMoveEnd(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasSetColor")] - public static extern void CanvasSetColor([MarshalAs(UnmanagedType.LPStr)] string hexColor, float a); - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CanvasSetSize")] - public static extern void CanvasSetSize(int width, int height); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetResourcePath")] - public static extern void SetResourcePath([MarshalAs(UnmanagedType.LPStr)] string resourcePath); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetFontPath")] - public static extern void SetFontPath([MarshalAs(UnmanagedType.LPStr)] string fontPath); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetTexturePaths")] - public static extern void SetTexturePaths([MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr)] string[] texturePaths, int textureCount); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetStrokeSize")] - public static extern void SetStrokeSize(float val); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetStrokeColor")] - public static extern void SetStrokeColor([MarshalAs(UnmanagedType.LPStr)] string hexColor, float a); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetStrokeType")] - public static extern void SetStrokeType(int brushId); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetBrushTexture")] - public static extern void SetBrushTexture(int textureId); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetBrushDistance")] - public static extern void SetBrushDistance(float distance); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetDashArray")] - public static extern void SetDashArray([MarshalAs(UnmanagedType.LPStr)] string dashArray); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetLineAngle")] - public static extern void SetLineAngle(float angle); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetBrushSize")] - public static extern float GetBrushSize(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetBrushColor")] - public static extern float GetBrushColor([MarshalAs(UnmanagedType.LPStr)] StringBuilder hex); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetBrushType")] - public static extern int GetBrushType(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetBrushTexture")] - public static extern int GetBrushTexture(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetBrushDistance")] - public static extern float GetBrushDistance(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetLineAngle")] - public static extern float GetLineAngle(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetShapeCount")] - public static extern int GetShapeCount(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CreateCanvas")] - public static extern uint CreateCanvas(int canvasWidth, int canvasHeight); - - // #if PICTURE - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "CreateCanvasWithBackgroundImage")] - public static extern uint CreateCanvasWithBackgroundImage([MarshalAs(UnmanagedType.LPStr)] string path); - // #endif - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetCurrentCanvas")] - public static extern void SetCurrentCanvas(uint canvasID); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ClearCurrentCanvas")] - public static extern void ClearCurrentCanvas(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "StartSelectingArea")] - public static extern void StartSelectingArea(float x, float y); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ResizeSelectedArea")] - public static extern void ResizeSelectedArea(float x, float y); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "InsideSelectedArea")] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool InsideSelectedArea(float x, float y); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetSelectionDimensions")] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool GetSelectionDimensions(ref float x, ref float y, ref float width, ref float height); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "TouchedDrawable")] - public static extern int TouchedDrawable(float x, float y); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SelectDrawable")] - public static extern int SelectDrawable(float x, float y); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SelectDrawables")] - public static extern int SelectDrawables(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "DragSelectedDrawables")] - public static extern void DragSelectedDrawables(float x, float y); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "EndDraging")] - public static extern void EndDraging(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "StartRotating")] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool StartRotating(float x, float y); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "RotateSelected")] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool RotateSelected(float x, float y); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "EndRotating")] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool EndRotating(float x, float y); - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "StartSelectionScale")] - public static extern void StartSelectionScale(bool anchorLeft, bool anchorRight, bool anchorTop, bool anchorBottom, ref float anchorX, ref float anchorY); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ScaleSelection")] - public static extern void ScaleSelection(float scaleFactorX, float scaleFactorY); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "EndSelectionScale")] - public static extern void EndSelectionScale(float scaleFactorX, float scaleFactorY); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "DropSelectedDrawables")] - public static extern void DropSelectedDrawables(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SelectedAreaZoom")] - public static extern void SelectedAreaZoom(float x, float y, float zoom); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SaveCanvas")] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool SaveCanvas(uint canvasID, [MarshalAs(UnmanagedType.LPStr)] string path); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "LoadCanvas")] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool LoadCanvas(uint canvasID, [MarshalAs(UnmanagedType.LPStr)] string path); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "TakeScreenshot")] - public static extern void TakeScreenshot(uint canvasID, [MarshalAs(UnmanagedType.LPStr)] string path, int x, int y, int width, int height, [MarshalAs(UnmanagedType.FunctionPtr)] PWEngineDelegates.ThumbnailSavedDelegate thumbSaved); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ToggleGrid")] - public static extern void ToggleGrid(int densityType); - - // #if CHART - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ToggleChartGrid")] - public static extern void ToggleChartGrid(int densityType); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetChartGridDensity")] - public static extern int GetChartGridDensity(); - // #endif - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "Dump")] - public static extern void Dump(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "Copy")] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool Copy(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "Paste")] - public static extern int Paste(float x, float y); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "Cut")] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool Cut(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "Remove")] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool Remove(); - - // #if CHART - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "AddChart")] - public static extern void AddChart(int chartType, [MarshalAs(UnmanagedType.LPStr)] string path); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ChangeMode")] - public static extern void ChangeMode(int mode); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ChartPosition")] - public static extern void ChartPosition(ref float x, ref float y); - // #endif - - // #if PICTURE - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "PlacePicture")] - public static extern void AddPicture([MarshalAs(UnmanagedType.LPStr)] string path, float x, float y, float width, float height); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetCanvasBackground")] - public static extern void SetCanvasBackground([MarshalAs(UnmanagedType.LPStr)] string path, float x, float y, float width, float height); - // #endif - - // #if TEXT - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "AddText")] - public static extern void AddText([MarshalAs(UnmanagedType.LPStr)] string text, float x, float y, float size); - // #endif - // #if NOTES - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "AddNote")] - public static extern uint AddNote(float x, float y, float w, float h); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "RemoveNote")] - public static extern void RemoveNote(uint noteID); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ClearNote")] - public static extern void ClearNote(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "DragNote")] - public static extern bool DragNote(float x, float y); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "EndNoteDragging")] - public static extern bool EndNoteDragging(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetNoteColor")] - public static extern void SetNoteColor([MarshalAs(UnmanagedType.LPStr)] string hexColor, float a); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetActiveNote")] - public static extern void SetActiveNote(uint noteID); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "TouchedNote")] - public static extern uint TouchedNote(float x, float y); - // #endif - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "Undo")] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool Undo(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "Redo")] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool Redo(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ResetUndo")] - public static extern void ResetUndo(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ResetRedo")] - public static extern void ResetRedo(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetConfigurationCount")] - public static extern int GetConfigurationCount(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetAllConfigurations", CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr GetAllConfigurations(); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "GetConfiguration", CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr GetConfiguration([MarshalAs(UnmanagedType.LPStr)] string key); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetConfigurationInt", CallingConvention = CallingConvention.Cdecl)] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool SetConfigurationInt([MarshalAs(UnmanagedType.LPStr)] string key, int value); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetConfigurationFloat", CallingConvention = CallingConvention.Cdecl)] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool SetConfigurationFloat([MarshalAs(UnmanagedType.LPStr)] string key, float value); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetConfigurationString", CallingConvention = CallingConvention.Cdecl)] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool SetConfigurationString([MarshalAs(UnmanagedType.LPStr)] string key, [MarshalAs(UnmanagedType.LPStr)] string value); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SetConfigurationBool", CallingConvention = CallingConvention.Cdecl)] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool SetConfigurationBool([MarshalAs(UnmanagedType.LPStr)] string key, [MarshalAs(UnmanagedType.I1)] bool value); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "SaveProfiler")] - [return:MarshalAs(UnmanagedType.I1)] - public static extern bool SaveProfiler([MarshalAs(UnmanagedType.LPStr)] string path); - - [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ResetProfiler")] - public static extern void ResetProfiler(); - - //Wrappers for Marshalled APIS - // public static void GetConfigurations(out ConfigParameter[] configParameters, out int count) - // { - // IntPtr configArrayPtr = GetAllConfigurations(); - // int engineConfigCount = GetConfigurationCount(); - // count = engineConfigCount; - - // ConfigParameter[] configArray = new ConfigParameter[count]; - - // for (int i = 0; i < count; i++) - // { - // configArray[i] = Marshal.PtrToStructure(configArrayPtr); - // configArrayPtr += Marshal.SizeOf(); - // } - - // configParameters = configArray; - // } - } -} diff --git a/src/Tizen.NUI.PenWave/src/public/Canvas/PenWave.cs b/src/Tizen.NUI.PenWave/src/public/Canvas/PenWave.cs new file mode 100644 index 00000000000..efaeec7cad3 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/public/Canvas/PenWave.cs @@ -0,0 +1,593 @@ +using System; +using System.Text; +using System.ComponentModel; +using System.Runtime.InteropServices; + +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using System.ComponentModel; +using System.Net.Http.Headers; +using System.Data; + +namespace Tizen.NUI.PenWave +{ + public class PenWave + { + /// + /// The delegate for the thumbnail saved callback. + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + [EditorBrowsable(EditorBrowsableState.Never)] + public delegate void ThumbnailSavedCallback(); + + private static readonly PenWave instance = new PenWave(); + private PenWave() { } + + /// + /// Gets the singleton instance of PenWave. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static PenWave Instance => instance; + + /// + /// Initializes the PenWave library. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void InitializeGL() + { + Interop.PenWave.InitializeGL(); + } + + /// + /// Renders the frame using OpenGL. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public int RenderFrameGL() + { + return Interop.PenWave.RenderFrameGL(); + } + + /// + /// Renders the fully redraw frame using OpenGL. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void RenderFullyReDraw() + { + Interop.PenWave.RenderFullyReDraw(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void TerminateGL() + { + Interop.PenWave.TerminateGL(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void UpdateGLWindowSize(int w, int h) + { + Interop.PenWave.UpdateGLWindowSize(w, h); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void UpdateGLWindowOrientation(int angle) + { + Interop.PenWave.UpdateGLWindowOrientation(angle); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public uint BeginShapeDraw(float x, float y, uint time = 1) + { + return Interop.PenWave.BeginShapeDraw(x, y, time); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public int DrawShape(uint shapeID, float x, float y, uint time = 1) + { + return Interop.PenWave.DrawShape(shapeID, x, y, time); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public int EndShapeDraw(uint shapeID, uint time = 1) + { + return Interop.PenWave.EndShapeDraw(shapeID, time); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void StopErasing() + { + Interop.PenWave.StopErasing(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool EraseShape(int x, int y, float radius, bool partial) + { + return Interop.PenWave.EraseShape(x, y, radius, partial); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public uint AddRectanglePath(float xStart, float yStart, float x, float y, bool finished) + { + return Interop.PenWave.AddRectanglePath(xStart, yStart, x, y, finished); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public uint AddArcPath(float xCenter, float yCenter, float radius, float x, float y, bool finished) + { + return Interop.PenWave.AddArcPath(xCenter, yCenter, radius, x, y, finished); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public int ResizeShapePath(uint shapeID, float x, float y) + { + return Interop.PenWave.ResizeShapePath(shapeID, x, y); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public int FinishShapePath(uint shapeID) + { + return Interop.PenWave.FinishShapePath(shapeID); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool CanvasZoomBegin() + { + return Interop.PenWave.CanvasZoomBegin(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool CanvasZoom(float x, float y, float zoom, float dx, float dy) + { + return Interop.PenWave.CanvasZoom(x, y, zoom, dx, dy); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool CanvasZoomEnd() + { + return Interop.PenWave.CanvasZoomEnd(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public int CanvasGetZoomValue() + { + return Interop.PenWave.CanvasGetZoomValue(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public float CanvasSetZoomValue(float zoomValue) + { + return Interop.PenWave.CanvasSetZoomValue(zoomValue); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool CanvasMoveBegin() + { + return Interop.PenWave.CanvasMoveBegin(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool CanvasMove(int x, int y) + { + return Interop.PenWave.CanvasMove(x, y); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool CanvasMoveEnd() + { + return Interop.PenWave.CanvasMoveEnd(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void CanvasSetColor(string hexColor, float a) + { + Interop.PenWave.CanvasSetColor(hexColor, a); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void CanvasSetSize(int width, int height) + { + Interop.PenWave.CanvasSetSize(width, height); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetResourcePath(string resourcePath) + { + Interop.PenWave.SetResourcePath(resourcePath); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetFontPath(string fontPath) + { + Interop.PenWave.SetFontPath(fontPath); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetTexturePaths(string[] texturePaths, int textureCount) + { + Interop.PenWave.SetTexturePaths(texturePaths, textureCount); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetStrokeSize(float val) + { + Interop.PenWave.SetStrokeSize(val); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetStrokeColor(string hexColor, float a) + { + Interop.PenWave.SetStrokeColor(hexColor, a); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetStrokeType(int brushId) + { + Interop.PenWave.SetStrokeType(brushId); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetBrushTexture(int textureId) + { + Interop.PenWave.SetBrushTexture(textureId); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetBrushDistance(float distance) + { + Interop.PenWave.SetBrushDistance(distance); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetDashArray(string dashArray) + { + Interop.PenWave.SetDashArray(dashArray); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetLineAngle(float angle) + { + Interop.PenWave.SetLineAngle(angle); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public float GetBrushSize() + { + return Interop.PenWave.GetBrushSize(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public float GetBrushColor(StringBuilder hex) + { + return Interop.PenWave.GetBrushColor(hex); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public int GetBrushType() + { + return Interop.PenWave.GetBrushType(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public int GetBrushTexture() + { + return Interop.PenWave.GetBrushTexture(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public float GetBrushDistance() + { + return Interop.PenWave.GetBrushDistance(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public float GetLineAngle() + { + return Interop.PenWave.GetLineAngle(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public int GetShapeCount() + { + return Interop.PenWave.GetShapeCount(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public uint CreateCanvas(int canvasWidth, int canvasHeight) + { + return Interop.PenWave.CreateCanvas(canvasWidth, canvasHeight); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public uint CreateCanvasWithBackgroundImage(string path) + { + return Interop.PenWave.CreateCanvasWithBackgroundImage(path); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetCurrentCanvas(uint canvasID) + { + Interop.PenWave.SetCurrentCanvas(canvasID); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void ClearCurrentCanvas() + { + Interop.PenWave.ClearCurrentCanvas(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void StartSelectingArea(float x, float y) + { + Interop.PenWave.StartSelectingArea(x, y); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void ResizeSelectedArea(float x, float y) + { + Interop.PenWave.ResizeSelectedArea(x, y); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool InsideSelectedArea(float x, float y) + { + return Interop.PenWave.InsideSelectedArea(x, y); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool GetSelectionDimensions(ref float x, ref float y, ref float width, ref float height) + { + return Interop.PenWave.GetSelectionDimensions(ref x, ref y, ref width, ref height); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public int TouchedDrawable(float x, float y) + { + return Interop.PenWave.TouchedDrawable(x, y); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public int SelectDrawable(float x, float y) + { + return Interop.PenWave.SelectDrawable(x, y); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public int SelectDrawables() + { + return Interop.PenWave.SelectDrawables(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void DragSelectedDrawables(float x, float y) + { + Interop.PenWave.DragSelectedDrawables(x, y); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void EndDraging() + { + Interop.PenWave.EndDraging(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool StartRotating(float x, float y) + { + return Interop.PenWave.StartRotating(x, y); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool RotateSelected(float x, float y) + { + return Interop.PenWave.RotateSelected(x, y); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool EndRotating(float x, float y) + { + return Interop.PenWave.EndRotating(x, y); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void StartSelectionScale(bool anchorLeft, bool anchorRight, bool anchorTop, bool anchorBottom, ref float anchorX, ref float anchorY) + { + Interop.PenWave.StartSelectionScale(anchorLeft, anchorRight, anchorTop, anchorBottom, ref anchorX, ref anchorY); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void ScaleSelection(float scaleFactorX, float scaleFactorY) + { + Interop.PenWave.ScaleSelection(scaleFactorX, scaleFactorY); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void EndSelectionScale(float scaleFactorX, float scaleFactorY) + { + Interop.PenWave.EndSelectionScale(scaleFactorX, scaleFactorY); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void DropSelectedDrawables() + { + Interop.PenWave.DropSelectedDrawables(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void SelectedAreaZoom(float x, float y, float zoom) + { + Interop.PenWave.SelectedAreaZoom(x, y, zoom); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool SaveCanvas(uint canvasID, string path) + { + return Interop.PenWave.SaveCanvas(canvasID, path); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool LoadCanvas(uint canvasID, string path) + { + return Interop.PenWave.LoadCanvas(canvasID, path); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void TakeScreenshot(uint canvasID, string path, int x, int y, int width, int height, ThumbnailSavedCallback thumbSaved) + { + Interop.PenWave.TakeScreenshot(canvasID, path, x, y, width, height, thumbSaved); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void ToggleGrid(int densityType) + { + Interop.PenWave.ToggleGrid(densityType); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void ToggleChartGrid(int densityType) + { + Interop.PenWave.ToggleChartGrid(densityType); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public int GetChartGridDensity() + { + return Interop.PenWave.GetChartGridDensity(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void Dump() + { + Interop.PenWave.Dump(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Copy() + { + return Interop.PenWave.Copy(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public int Paste(float x, float y) + { + return Interop.PenWave.Paste(x, y); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Cut() + { + return Interop.PenWave.Cut(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Remove() + { + return Interop.PenWave.Remove(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void AddChart(int chartType, string path) + { + Interop.PenWave.AddChart(chartType, path); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void ChangeMode(int mode) + { + Interop.PenWave.ChangeMode(mode); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void ChartPosition(ref float x, ref float y) + { + Interop.PenWave.ChartPosition(ref x, ref y); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void AddPicture(string path, float x, float y, float width, float height) + { + Interop.PenWave.AddPicture(path, x, y, width, height); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetCanvasBackground(string path, float x, float y, float width, float height) + { + Interop.PenWave.SetCanvasBackground(path, x, y, width, height); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void AddText(string text, float x, float y, float size) + { + Interop.PenWave.AddText(text, x, y, size); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public uint AddNote(float x, float y, float w, float h) + { + return Interop.PenWave.AddNote(x, y, w, h); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void RemoveNote(uint noteID) + { + Interop.PenWave.RemoveNote(noteID); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void ClearNote() + { + Interop.PenWave.ClearNote(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool DragNote(float x, float y) + { + return Interop.PenWave.DragNote(x, y); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool EndNoteDragging() + { + return Interop.PenWave.EndNoteDragging(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetNoteColor(string hexColor, float a) + { + Interop.PenWave.SetNoteColor(hexColor, a); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetActiveNote(uint noteID) + { + Interop.PenWave.SetActiveNote(noteID); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public uint TouchedNote(float x, float y) + { + return Interop.PenWave.TouchedNote(x, y); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Undo() + { + return Interop.PenWave.Undo(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Redo() + { + return Interop.PenWave.Redo(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void ResetUndo() + { + Interop.PenWave.ResetUndo(); + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public void ResetRedo() + { + Interop.PenWave.ResetRedo(); + } + } +} diff --git a/src/Tizen.NUI.PenWave/src/public/Canvas/PWCanvasView.cs b/src/Tizen.NUI.PenWave/src/public/Canvas/PenWaveCanvas.cs similarity index 74% rename from src/Tizen.NUI.PenWave/src/public/Canvas/PWCanvasView.cs rename to src/Tizen.NUI.PenWave/src/public/Canvas/PenWaveCanvas.cs index ae2687a93f7..08300615327 100644 --- a/src/Tizen.NUI.PenWave/src/public/Canvas/PWCanvasView.cs +++ b/src/Tizen.NUI.PenWave/src/public/Canvas/PenWaveCanvas.cs @@ -24,18 +24,21 @@ namespace Tizen.NUI.PenWave { /// - /// PWCanvasView is a view that allows drawing on it using various tools. + /// PenWaveCanvas is a view that allows drawing on it using various tools. /// - public class PWCanvasView : DirectRenderingGLView + [EditorBrowsable(EditorBrowsableState.Never)] + public class PenWaveCanvas : DirectRenderingGLView { /// /// Events that are triggered when the tool starts an action. /// + [EditorBrowsable(EditorBrowsableState.Never)] public event EventHandler ActionStarted; /// /// Events that are triggered when the tool finishes an action. /// + [EditorBrowsable(EditorBrowsableState.Never)] public event EventHandler ActionFinished; private UnRedoManager unredoManager; @@ -44,21 +47,23 @@ public class PWCanvasView : DirectRenderingGLView private ToolBase currentTool; /// - /// Creates a new instance of a PWCanvasView. + /// Creates a new instance of a PenWaveCanvas. /// - public PWCanvasView() : base(DirectRenderingGLView.ColorFormat.RGBA8888, DirectRenderingGLView.BackendMode.UnsafeDirectRendering) + [EditorBrowsable(EditorBrowsableState.Never)] + public PenWaveCanvas() : base(DirectRenderingGLView.ColorFormat.RGBA8888, DirectRenderingGLView.BackendMode.UnsafeDirectRendering) { - renderer = new CanvasRenderer(PWEngine.CreateCanvas(-1, -1)); + renderer = new CanvasRenderer(PenWave.Instance.CreateCanvas(-1, -1)); InitializeCanvas(); } /// - /// Creates a new instance of a PWCanvasView with a background image. + /// Creates a new instance of a PenWaveCanvas with a background image. /// /// - public PWCanvasView(string backgroundPath) : base(DirectRenderingGLView.ColorFormat.RGBA8888, DirectRenderingGLView.BackendMode.UnsafeDirectRendering) + [EditorBrowsable(EditorBrowsableState.Never)] + public PenWaveCanvas(string backgroundPath) : base(DirectRenderingGLView.ColorFormat.RGBA8888, DirectRenderingGLView.BackendMode.UnsafeDirectRendering) { - renderer = new CanvasRenderer(PWEngine.CreateCanvasWithBackgroundImage(backgroundPath)); + renderer = new CanvasRenderer(PenWave.Instance.CreateCanvasWithBackgroundImage(backgroundPath)); InitializeCanvas(); } @@ -87,6 +92,7 @@ private void InitializeCanvas() /// /// The tool used to draw on the canvas. If the tool is changed, the previous tool will be deactivated and the new tool will be activated. /// + [EditorBrowsable(EditorBrowsableState.Never)] public ToolBase Tool { get => currentTool; @@ -126,6 +132,7 @@ private void OnFinished(object sender, EventArgs e) /// /// Clears the canvas. /// + [EditorBrowsable(EditorBrowsableState.Never)] public void ClearCanvas() { var command = new Command(() => renderer.ClearCanvas()); @@ -135,16 +142,19 @@ public void ClearCanvas() /// /// Returns true if there are any actions that can be undone. Otherwise returns false. /// + [EditorBrowsable(EditorBrowsableState.Never)] public bool CanUndo => unredoManager.CanUndo; /// /// Returns true if there are any actions that can be redone. Otherwise returns false. /// + [EditorBrowsable(EditorBrowsableState.Never)] public bool CanRedo => unredoManager.CanRedo; /// /// Undoes the last action. If there are no actions to undo, nothing happens. /// + [EditorBrowsable(EditorBrowsableState.Never)] public void Undo() { unredoManager.Undo(); @@ -153,6 +163,7 @@ public void Undo() /// /// Redoes the last action. If there are no actions to redo, nothing happens. /// + [EditorBrowsable(EditorBrowsableState.Never)] public void Redo() { unredoManager.Redo(); @@ -162,6 +173,7 @@ public void Redo() /// Sets the color of the canvas. /// /// + [EditorBrowsable(EditorBrowsableState.Never)] public void SetCanvasColor(Color color) { renderer.SetCanvasColor(color); @@ -171,6 +183,7 @@ public void SetCanvasColor(Color color) /// Toggles the visibility of the grid. /// /// + [EditorBrowsable(EditorBrowsableState.Never)] public void ToggleGrid(GridDensityType gridType) { renderer.ToggleGrid(gridType); @@ -182,6 +195,7 @@ public void ToggleGrid(GridDensityType gridType) /// /// /// + [EditorBrowsable(EditorBrowsableState.Never)] public void AddPicture(string path, Size2D size, Position2D position) { var command = new Command(() => renderer.AddPicture(path, size, position)); @@ -192,6 +206,7 @@ public void AddPicture(string path, Size2D size, Position2D position) /// Handles touch events. This touch event is delivered to the current tool. /// /// + [EditorBrowsable(EditorBrowsableState.Never)] public void HandleInput(Touch touch) { currentTool?.HandleInput(touch, unredoManager); @@ -201,6 +216,7 @@ public void HandleInput(Touch touch) /// Saves the canvas to a file. /// /// + [EditorBrowsable(EditorBrowsableState.Never)] public void SaveCanvas(string path) { renderer.SaveCanvas(path); @@ -210,13 +226,29 @@ public void SaveCanvas(string path) /// Loads the canvas from a file. /// /// + [EditorBrowsable(EditorBrowsableState.Never)] public void LoadCanvas(string path) { renderer.LoadCanvas(path); } /// - /// Disposes the PWCanvasView. + /// Takes a screen shot of the canvas and saves it to a file. + /// + /// + /// + /// + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void TakeScreenShot(string path, int x, int y, int width, int height, PenWave.ThumbnailSavedCallback callback) + { + renderer.TakeScreenShot(path, x, y, width, height, callback); + } + + /// + /// Disposes the PenWaveCanvas. /// /// protected override void Dispose(DisposeTypes type) diff --git a/src/Tizen.NUI.PenWave/src/public/Common/PWConstants.cs b/src/Tizen.NUI.PenWave/src/public/Common/PWConstants.cs index 60b8c250800..96ffb0b259a 100644 --- a/src/Tizen.NUI.PenWave/src/public/Common/PWConstants.cs +++ b/src/Tizen.NUI.PenWave/src/public/Common/PWConstants.cs @@ -23,6 +23,10 @@ internal struct FrameworkInformation public readonly static string ResourcePath = "/usr/share/dotnet.tizen/framework/res/"; } + /// + /// Enumeration for the grid density type. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public enum GridDensityType { None = 0, diff --git a/src/Tizen.NUI.PenWave/src/public/Picker/PWToolPicker.cs b/src/Tizen.NUI.PenWave/src/public/Picker/PWToolPicker.cs index aa06e08a367..c2526f6089b 100644 --- a/src/Tizen.NUI.PenWave/src/public/Picker/PWToolPicker.cs +++ b/src/Tizen.NUI.PenWave/src/public/Picker/PWToolPicker.cs @@ -15,6 +15,7 @@ * */ using System; +using System.ComponentModel; using System.Collections.Generic; using Tizen.NUI; using Tizen.NUI.BaseComponents; @@ -22,11 +23,15 @@ namespace Tizen.NUI.PenWave { + /// + /// PWToolPicker class provides a user interface for selecting and configuring various drawing tools in the PenWave application. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public class PWToolPicker : View { private static readonly string ResourcePath = FrameworkInformation.ResourcePath + "images/light/"; - // 도구별 아이콘 및 색상 매핑 + // the icons for different brush types private static readonly Dictionary BrushIconMap = new Dictionary { { PencilTool.BrushType.Stroke, "icon_pencil.png" }, @@ -40,6 +45,7 @@ public class PWToolPicker : View { PencilTool.BrushType.SharpBrush, "icon_sharp_brush.png" }, }; + // the color palette for brushes private static readonly List BrushColorMap = new List { new Color("#F7B32C"), new Color("#FD5703"), new Color("#DA1727"), @@ -47,19 +53,21 @@ public class PWToolPicker : View new Color("#070044"), new Color("#0E0E0E") }; + // the icons for different eraser types private static readonly Dictionary EraserIconMap = new Dictionary { { EraserTool.EraserType.Partial, "icon_eraser.png" }, { EraserTool.EraserType.Full, "icon_full_eraser.png" }, }; - + // the color palette for canvas background color private static readonly List CanvasColor = new List { new Color("#F0F0F0"), new Color("#B7B7B7"), new Color("#E3F2FF"), new Color("#202022"), new Color("#515151"), new Color("#17234D"), }; + // the icons for different grid density types private static readonly Dictionary GridIconMap = new Dictionary { { GridDensityType.Small, "icon_small_grid_density.png" }, @@ -67,7 +75,7 @@ public class PWToolPicker : View { GridDensityType.Large, "icon_large_grid_density.png" }, }; - private readonly PWCanvasView canvasView; + private readonly PenWaveCanvas canvasView; private readonly Dictionary tools; private View rootView; @@ -75,17 +83,35 @@ public class PWToolPicker : View private ImageView undoButton; private ImageView redoButton; - // UI 상태 색상 정의 + private const string IconStateNormalColor = "#17234d"; private const string IconStateSelectedColor = "#FF6200"; private const string IconStateDisabledColor = "#CACACA"; + /// + /// The PickerView property. It contains the view that holds the tool buttons. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public View PickerView { get; private set; } + + /// + /// The PopupView property. It contains the view that holds the tool settings. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public View PopupView { get; private set; } + + /// + /// The ToolChanged event. It is triggered when the selected tool changes. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public event Action ToolChanged; - public PWToolPicker(PWCanvasView canvasView) + /// + /// Creates a new instance of PWToolPicker. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public PWToolPicker(PenWaveCanvas canvasView) { this.canvasView = canvasView; tools = new Dictionary(); @@ -93,11 +119,13 @@ public PWToolPicker(PWCanvasView canvasView) canvasView.ActionFinished += OnFinished; } + // Update UI when action finished. This method is called when the current action is finished. private void OnFinished(object sender, EventArgs e) { UpdateUI(); } + // Initialize the tool picker and its components. public void Initialize() { InitializeUI(); @@ -106,6 +134,7 @@ public void Initialize() UpdateUI(); } + // Initialize the UI components of the tool picker. private void InitializeUI() { WidthResizePolicy = ResizePolicyType.FillToParent; @@ -164,6 +193,7 @@ private void InitializeUI() canvasView.Add(this); } + // Initialize the canvas tools and their corresponding buttons. private void InitializeCanvasTools() { var backgroundColorButton = CreateToolButton(ResourcePath + "icon_color_palette.png", () => @@ -200,6 +230,7 @@ private void InitializeCanvasTools() PickerView.Add(clearButton); } + // Show the color palette setting for the canvas background color. private void ShowPaletteSetting() { ClearPopupView(); @@ -239,6 +270,7 @@ private void ShowPaletteSetting() PopupView.Add(colorPicker); } + // Show the grid density setting for the canvas grid. private void ShowGridSetting() { ClearPopupView(); @@ -267,6 +299,7 @@ private void ShowGridSetting() PopupView.Add(gridPicker); } + // Initialize the tools and add them to the tool picker. Each tool has its own settings and behavior. private void InitializeTools() { var pencilToll = new PencilTool(PencilTool.BrushType.Stroke, Color.Black, 3.0f); @@ -276,9 +309,10 @@ private void InitializeTools() AddTool(eraserTool, "icon_eraser.png"); AddTool(selectionTool, "icon_select.png"); - canvasView.Tool = pencilToll; // 기본 도구 설정 + canvasView.Tool = pencilToll; } + // Add a tool to the tool picker and create a button for it. The button will be used to select the tool and show its settings. private void AddTool(ToolBase tool, string icon) { tools[tool.GetType()] = tool; @@ -291,7 +325,8 @@ private void AddTool(ToolBase tool, string icon) } - public void SetTool(ToolBase tool) + // Set the current tool of the canvas view and show its settings. + private void SetTool(ToolBase tool) { if (tools.ContainsKey(tool.GetType())) { @@ -301,6 +336,7 @@ public void SetTool(ToolBase tool) } } + // Show the settings for the given tool in the popup view. Each tool has its own settings and behavior. private void ShowToolSettings(ToolBase tool) { ClearPopupView(); @@ -315,6 +351,7 @@ private void ShowToolSettings(ToolBase tool) PopupView.Show(); } + // Show the settings for the pencil tool in the popup view. The pencil tool has brush type, color, and size settings. private void ShowPencilToolSettings(PencilTool pencilTool) { AddBrushPicker(pencilTool); @@ -322,17 +359,20 @@ private void ShowPencilToolSettings(PencilTool pencilTool) AddSizeSlider(pencilTool); } + // Show the settings for the eraser tool in the popup view. The eraser tool has eraser type and size settings. private void ShowEraserToolSettings(EraserTool eraserTool) { AddEraserTypePicker(eraserTool); AddSizeSlider(eraserTool); } + // Show the settings for the selection tool in the popup view. The selection tool has selection type settings. private void ShowSelectionToolSettings(SelectionTool selectionTool) { AddSelectionTypePicker(selectionTool); } + // Create a button for the given tool and add it to the popup view. private void AddBrushPicker(PencilTool pencilTool) { var brushPicker = new View @@ -358,6 +398,7 @@ private void AddBrushPicker(PencilTool pencilTool) PopupView.Add(brushPicker); } + // Create a button for the given color and add it to the popup view. private void AddColorPicker(PencilTool pencilTool) { var colorPicker = new View @@ -394,6 +435,7 @@ private void AddColorPicker(PencilTool pencilTool) PopupView.Add(colorPicker); } + // Create a slider for the given tool and add it to the popup view. The slider controls the size of the tool. private void AddSizeSlider(ToolBase tool) { @@ -431,6 +473,7 @@ private void AddSizeSlider(ToolBase tool) PopupView.Add(slider); } + // Create a button for the given eraser type and add it to the popup view. The button toggles between partial and full eraser modes. private void AddEraserTypePicker(EraserTool eraserTool) { var eraserPicker = new View @@ -457,6 +500,7 @@ private void AddEraserTypePicker(EraserTool eraserTool) PopupView.Add(eraserPicker); } + // Create a button for the given selection type and add it to the popup view. The button toggles between move, resize, and rotate modes. private void AddSelectionTypePicker(SelectionTool selectionTool) { var picker = new View @@ -480,6 +524,10 @@ private void AddSelectionTypePicker(SelectionTool selectionTool) PopupView.Add(picker); } + /// + /// Create a tool button with the given icon path and click action. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public ImageView CreateToolButton(string iconPath, Action OnClick) { var button = new ImageView @@ -507,6 +555,7 @@ public ImageView CreateToolButton(string iconPath, Action OnClick) return button; } + // Update the UI based on the current state of the canvas view. This includes updating the selected tool, the undo/redo buttons, and the tool settings. private void UpdateUI() { ClearPopupView(); @@ -523,6 +572,10 @@ private void UpdateUI() } + /// + /// Clear the popup view and hide it. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public void ClearPopupView() { int childNum = (int)PopupView.ChildCount; @@ -533,6 +586,7 @@ public void ClearPopupView() PopupView.Hide(); } + // Dispose the tool picker and its components. protected override void Dispose(DisposeTypes type) { if(disposed) return; diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Command.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Command.cs index fb83aae3c26..b8879c25f82 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Command.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Command.cs @@ -16,10 +16,15 @@ */ using System; +using System.ComponentModel; namespace Tizen.NUI.PenWave { - internal class Command : ICommand + /// + /// Represents a command that can be executed. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class Command : ICommand { /// /// The action to be executed when command is invoked. @@ -30,6 +35,7 @@ internal class Command : ICommand /// Constructor. /// /// The action to be executed when the command is invoked. + [EditorBrowsable(EditorBrowsableState.Never)] public Command(Action executeAction) { this.executeAction = executeAction; @@ -38,6 +44,7 @@ public Command(Action executeAction) /// /// Executes the command. /// + [EditorBrowsable(EditorBrowsableState.Never)] public void Execute() { executeAction?.Invoke(); diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserTool.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserTool.cs index b66731f2ccc..41fefd582da 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserTool.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserTool.cs @@ -23,35 +23,66 @@ namespace Tizen.NUI.PenWave { + /// + /// The EraserTool class provides functionality to erase shapes from the canvas. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public class EraserTool : ToolBase { + /// + /// The type of eraser tool. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public enum EraserType { Partial = 0, Full, } + /// + /// Constructor + /// + [EditorBrowsable(EditorBrowsableState.Never)] public EraserTool(EraserType eraserType, float radius) { Eraser = eraserType; EraserRadius = radius; } + /// + /// The type of eraser tool. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public EraserType Eraser { get; set; } + /// + /// The radius of the eraser tool. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public float EraserRadius { get; set; } + /// + /// Activate the tool. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public override void Activate() { - } + /// + /// Deactivate the tool. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public override void Deactivate() { EndDrawing(); } - public override void HandleInput(Touch touch, UnRedoManager unredoManager) + /// + /// Handle input events. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + internal override void HandleInput(Touch touch, UnRedoManager unredoManager) { if (touch == null || touch.GetPointCount() == 0) return; @@ -81,20 +112,23 @@ public override void HandleInput(Touch touch, UnRedoManager unredoManager) } } + // Start drawing at the given position. private void StartDrawing(Vector2 position, uint touchTime) { - PWEngine.EraseShape((int)position.X, (int)position.Y, EraserRadius, (Eraser == EraserType.Partial)); + PenWave.Instance.EraseShape((int)position.X, (int)position.Y, EraserRadius, (Eraser == EraserType.Partial)); NotifyActionStarted(); } + // Continue drawing at the given position. private void ContinueDrawing(Vector2 position, uint touchTime) { - PWEngine.EraseShape((int)position.X, (int)position.Y, EraserRadius, (Eraser == EraserType.Partial)); + PenWave.Instance.EraseShape((int)position.X, (int)position.Y, EraserRadius, (Eraser == EraserType.Partial)); } + // End drawing at the given position. private void EndDrawing() { - PWEngine.StopErasing(); + PenWave.Instance.StopErasing(); NotifyActionFinished(); } diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/ICommand.cs b/src/Tizen.NUI.PenWave/src/public/Tools/ICommand.cs index bf4fc924e39..cf9847d230a 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/ICommand.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/ICommand.cs @@ -15,17 +15,21 @@ * */ +using System; +using System.ComponentModel; namespace Tizen.NUI.PenWave { /// /// Commands that can be executed. /// + [EditorBrowsable(EditorBrowsableState.Never)] public interface ICommand { /// /// Executes the command. /// + [EditorBrowsable(EditorBrowsableState.Never)] void Execute(); } } diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/BrushStrategyFactory.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/BrushStrategyFactory.cs index b4857863711..2ff0b2e85ac 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/BrushStrategyFactory.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/BrushStrategyFactory.cs @@ -23,13 +23,25 @@ namespace Tizen.NUI.PenWave { + /// + /// The factory class that creates brush strategies. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public sealed class BrushStrategyFactory { private static readonly BrushStrategyFactory instance = new BrushStrategyFactory(); private Dictionary brushStrategies = new Dictionary(); + /// + /// Gets the singleton instance of the BrushStrategyFactory. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public static BrushStrategyFactory Instance => instance; + /// + /// Gets the brush strategy for the specified brush type. + /// + /// The brush type. public IBrushStrategy GetBrushStrategy(PencilTool.BrushType brushType) { if (!brushStrategies.ContainsKey(brushType)) diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/DashedLineBrush.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/DashedLineBrush.cs index 76f91ba1dd7..95a8a017bd5 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/DashedLineBrush.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/DashedLineBrush.cs @@ -15,17 +15,27 @@ * */ +using System; +using System.ComponentModel; using Tizen.NUI; using Tizen.NUI.BaseComponents; namespace Tizen.NUI.PenWave { + /// + /// The dashed line brush strategy. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public class DashedLineBrush : IBrushStrategy { + /// + /// Apply brush settings. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PWEngine.SetStrokeType(5); - PWEngine.SetDashArray("1 3"); + PenWave.Instance.SetStrokeType(5); + PenWave.Instance.SetDashArray("1 3"); } } } diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/DotBrush .cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/DotBrush .cs index fed8b380b2c..31bdccceac8 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/DotBrush .cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/DotBrush .cs @@ -15,18 +15,28 @@ * */ +using System; +using System.ComponentModel; using Tizen.NUI; using Tizen.NUI.BaseComponents; namespace Tizen.NUI.PenWave { + /// + /// The dot brush strategy. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public class DotBrush : IBrushStrategy { + /// + /// Apply the brush settings. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PWEngine.SetStrokeType(1); - PWEngine.SetBrushTexture(1); - PWEngine.SetBrushDistance(2.0f); + PenWave.Instance.SetStrokeType(1); + PenWave.Instance.SetBrushTexture(1); + PenWave.Instance.SetBrushDistance(2.0f); } } } diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/HighlighterBrush.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/HighlighterBrush.cs index 252f898c572..44c65643d70 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/HighlighterBrush.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/HighlighterBrush.cs @@ -15,18 +15,28 @@ * */ +using System; +using System.ComponentModel; using Tizen.NUI; using Tizen.NUI.BaseComponents; namespace Tizen.NUI.PenWave { + /// + /// The highlighter brush strategy. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public class HighlighterBrush : IBrushStrategy { + /// + /// Apply the brush settings. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PWEngine.SetStrokeType(1); - PWEngine.SetBrushTexture(3); - PWEngine.SetBrushDistance(0.25f); + PenWave.Instance.SetStrokeType(1); + PenWave.Instance.SetBrushTexture(3); + PenWave.Instance.SetBrushDistance(0.25f); } } } diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/IBrushStrategy.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/IBrushStrategy.cs index b3858f67f00..bdcf2b049ba 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/IBrushStrategy.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/IBrushStrategy.cs @@ -23,8 +23,16 @@ namespace Tizen.NUI.PenWave { + /// + /// Interface for brush strategy. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public interface IBrushStrategy { + /// + /// Apply brush settings. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings(); } } diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/SharpBrush.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/SharpBrush.cs index 02b51316141..e376d60ed68 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/SharpBrush.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/SharpBrush.cs @@ -15,16 +15,26 @@ * */ +using System; +using System.ComponentModel; using Tizen.NUI; using Tizen.NUI.BaseComponents; namespace Tizen.NUI.PenWave { + /// + /// The sharp brush strategy. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public class SharpBrush : IBrushStrategy { + /// + /// Apply the brush settings. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PWEngine.SetStrokeType(8); + PenWave.Instance.SetStrokeType(8); } } } diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/SoftBrush.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/SoftBrush.cs index 023e8fc72ea..29c3e5ceb40 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/SoftBrush.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/SoftBrush.cs @@ -15,18 +15,28 @@ * */ +using System; +using System.ComponentModel; using Tizen.NUI; using Tizen.NUI.BaseComponents; namespace Tizen.NUI.PenWave { + /// + /// The soft brush strategy. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public class SoftBrush : IBrushStrategy { + /// + /// Apply the brush settings. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PWEngine.SetStrokeType(1); - PWEngine.SetBrushTexture(4); - PWEngine.SetBrushDistance(1.0f); + PenWave.Instance.SetStrokeType(1); + PenWave.Instance.SetBrushTexture(4); + PenWave.Instance.SetBrushDistance(1.0f); } } } diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/SprayBrush.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/SprayBrush.cs index 10850a26aa8..bb976748a1d 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/SprayBrush.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/SprayBrush.cs @@ -15,18 +15,28 @@ * */ +using System; +using System.ComponentModel; using Tizen.NUI; using Tizen.NUI.BaseComponents; namespace Tizen.NUI.PenWave { + /// + /// The spray brush strategy. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public class SprayBrush : IBrushStrategy { + /// + /// Apply the brush settings. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PWEngine.SetStrokeType(1); - PWEngine.SetBrushTexture(0); - PWEngine.SetBrushDistance(3.0f); + PenWave.Instance.SetStrokeType(1); + PenWave.Instance.SetBrushTexture(0); + PenWave.Instance.SetBrushDistance(3.0f); } } } diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/StrokeBrush.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/StrokeBrush.cs index 8aa16e515c9..e02682b10d1 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/StrokeBrush.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/StrokeBrush.cs @@ -15,16 +15,26 @@ * */ +using System; +using System.ComponentModel; using Tizen.NUI; using Tizen.NUI.BaseComponents; namespace Tizen.NUI.PenWave { + /// + /// The stroke brush strategy. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public class StrokeBrush : IBrushStrategy { + /// + /// Apply the brush settings. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PWEngine.SetStrokeType(0); + PenWave.Instance.SetStrokeType(0); } } } diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/VarStrokeBrush.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/VarStrokeBrush.cs index 5c51222607f..b5c16e8707a 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/VarStrokeBrush.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/VarStrokeBrush.cs @@ -15,16 +15,26 @@ * */ +using System; +using System.ComponentModel; using Tizen.NUI; using Tizen.NUI.BaseComponents; namespace Tizen.NUI.PenWave { + /// + /// A brush strategy that applies a variable stroke type. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public class VarStrokeBrush : IBrushStrategy { + /// + /// Applies the settings for the brush. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PWEngine.SetStrokeType(6); + PenWave.Instance.SetStrokeType(6); } } } diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/VarStrokeIncBrush.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/VarStrokeIncBrush.cs index 5d4b2b71784..d082add6c83 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/VarStrokeIncBrush.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/VarStrokeIncBrush.cs @@ -15,16 +15,26 @@ * */ +using System; +using System.ComponentModel; using Tizen.NUI; using Tizen.NUI.BaseComponents; namespace Tizen.NUI.PenWave { + /// + /// The brush strategy that increases the stroke size as the user draws longer strokes. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public class VarStrokeIncBrush : IBrushStrategy { + /// + /// Apply the brush settings to the PenWave instance. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PWEngine.SetStrokeType(7); + PenWave.Instance.SetStrokeType(7); } } } diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PencilTool.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PencilTool.cs index 908404e6f03..da574e59b98 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PencilTool.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PencilTool.cs @@ -23,8 +23,16 @@ namespace Tizen.NUI.PenWave { + /// + /// The pencil tool allows the user to draw shapes on the canvas using a stylus or finger. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public class PencilTool : ToolBase { + /// + /// The type of brush used to draw. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public enum BrushType { Stroke = 0, @@ -38,6 +46,7 @@ public enum BrushType SharpBrush } + // The error codes returned from the native side when adding points to a shape. private enum ErrorShapeAddPointsType { NoError, @@ -50,8 +59,13 @@ private enum ErrorShapeAddPointsType DrawingCanceled } + // The id of the current shape being drawn. private uint currentShapeId; + /// + /// Creates a new instance of a PencilTool. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public PencilTool(BrushType brushType, Color color, float size) { Brush = brushType; @@ -59,12 +73,25 @@ public PencilTool(BrushType brushType, Color color, float size) BrushSize = size; } + /// + /// The type of brush used to draw. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public BrushType Brush { get; set; } + /// + /// The color of the brush used to draw. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public Color BrushColor { get; set; } + /// + /// The size of the brush used to draw. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public float BrushSize { get; set; } + // Converts a color to a hex string. Used to pass colors to the native side. private string ToHex(Color color) { var red = (uint)(color.R * 255); @@ -73,6 +100,7 @@ private string ToHex(Color color) return $"#{red:X2}{green:X2}{blue:X2}"; } + // Sets the brush type and applies the settings for that brush. private void SetBrushType(BrushType brushType) { var brushStragety = BrushStrategyFactory.Instance.GetBrushStrategy(brushType); @@ -82,19 +110,30 @@ private void SetBrushType(BrushType brushType) } } + /// + /// Activates the tool. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public override void Activate() { SetBrushType(Brush); - PWEngine.SetStrokeColor(ToHex(BrushColor), 1.0f); - PWEngine.SetStrokeSize(BrushSize); + PenWave.Instance.SetStrokeColor(ToHex(BrushColor), 1.0f); + PenWave.Instance.SetStrokeSize(BrushSize); } + /// + /// Deactivates the tool. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public override void Deactivate() { EndDrawing(); } - public override void HandleInput(Touch touch, UnRedoManager unredoManager) + /// + /// Handles input from the user. + /// + internal override void HandleInput(Touch touch, UnRedoManager unredoManager) { if (touch == null || touch.GetPointCount() == 0) return; @@ -125,17 +164,19 @@ public override void HandleInput(Touch touch, UnRedoManager unredoManager) } } + // Starts drawing a new shape. This will create a new shape on the canvas. private void StartDrawing(Vector2 position, uint touchTime) { - currentShapeId = PWEngine.BeginShapeDraw(position.X, position.Y, touchTime); + currentShapeId = PenWave.Instance.BeginShapeDraw(position.X, position.Y, touchTime); NotifyActionStarted(); } + // Continues drawing the current shape. private void ContinueDrawing(Vector2 position, uint touchTime) { if (currentShapeId > 0) { - var result = (ErrorShapeAddPointsType)PWEngine.DrawShape(currentShapeId, position.X, position.Y, touchTime); + var result = (ErrorShapeAddPointsType)PenWave.Instance.DrawShape(currentShapeId, position.X, position.Y, touchTime); if (result == ErrorShapeAddPointsType.OverflowShape) { EndDrawing(); @@ -148,9 +189,10 @@ private void ContinueDrawing(Vector2 position, uint touchTime) } } + // Ends drawing the current shape. private void EndDrawing() { - PWEngine.EndShapeDraw(currentShapeId, 0); + PenWave.Instance.EndShapeDraw(currentShapeId, 0); currentShapeId = 0; NotifyActionFinished(); } diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Selection/SelectionTool.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Selection/SelectionTool.cs index 6e83dffe089..8eab0dea467 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Selection/SelectionTool.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Selection/SelectionTool.cs @@ -28,6 +28,7 @@ public class SelectionTool : ToolBase /// /// Enumeration for the type of selection operation /// + [EditorBrowsable(EditorBrowsableState.Never)] public enum SelectionType { Move = 0, @@ -78,6 +79,7 @@ private enum Mode /// Constructor for the selection tool. /// /// + [EditorBrowsable(EditorBrowsableState.Never)] public SelectionTool(SelectionType selectionType) { Selection = selectionType; @@ -86,19 +88,22 @@ public SelectionTool(SelectionType selectionType) /// /// The type of selection operation. Default is move. /// + [EditorBrowsable(EditorBrowsableState.Never)] public SelectionType Selection { get; set; } /// - /// Activate the selection tool. This method is called when the tool is selected from the tools + /// Activate the selection tool. /// + [EditorBrowsable(EditorBrowsableState.Never)] public override void Activate() { } /// - /// Deactivate the selection tool. This method is called when the tool is deselected from the tools + /// Deactivate the selection tool. /// + [EditorBrowsable(EditorBrowsableState.Never)] public override void Deactivate() { currentMode = Mode.None; @@ -110,7 +115,7 @@ public override void Deactivate() /// /// /// - public override void HandleInput(Touch touch, UnRedoManager unredoManager) + internal override void HandleInput(Touch touch, UnRedoManager unredoManager) { if (touch == null || touch.GetPointCount() == 0) return; @@ -143,25 +148,25 @@ public override void HandleInput(Touch touch, UnRedoManager unredoManager) private void StartDrawing(Vector2 position, uint touchTime) { initialTouch = new Vector2(position.X, position.Y); - isTouchedInsideSelectedArea = PWEngine.InsideSelectedArea(position.X, position.Y); + isTouchedInsideSelectedArea = PenWave.Instance.InsideSelectedArea(position.X, position.Y); if (!isTouchedInsideSelectedArea) { - PWEngine.DropSelectedDrawables(); - drawableType = (DrawableType)PWEngine.SelectDrawable(position.X, position.Y); + PenWave.Instance.DropSelectedDrawables(); + drawableType = (DrawableType)PenWave.Instance.SelectDrawable(position.X, position.Y); } else { if (Selection == SelectionType.Rotate) { - PWEngine.StartRotating(position.X, position.Y); + PenWave.Instance.StartRotating(position.X, position.Y); } else if (Selection == SelectionType.Scale) { float topLeftX = 0, topLeftY = 0, widthSelection = 0, heightSelection = 0; - PWEngine.GetSelectionDimensions(ref topLeftX, ref topLeftY, ref widthSelection, ref heightSelection); + PenWave.Instance.GetSelectionDimensions(ref topLeftX, ref topLeftY, ref widthSelection, ref heightSelection); if (!Double.IsNaN(topLeftX)) { - PWEngine.StartSelectionScale( + PenWave.Instance.StartSelectionScale( initialTouch.X >= topLeftX+widthSelection*0.5f, initialTouch.X < topLeftX+widthSelection*0.5f, initialTouch.Y >= topLeftY+heightSelection*0.5f, @@ -186,26 +191,26 @@ private void ContinueDrawing(Vector2 position, uint touchTime) { if (currentMode == Mode.None) { - PWEngine.StartSelectingArea(position.X, position.Y); + PenWave.Instance.StartSelectingArea(position.X, position.Y); } - PWEngine.ResizeSelectedArea(position.X, position.Y); + PenWave.Instance.ResizeSelectedArea(position.X, position.Y); currentMode = Mode.Resize; } else if (currentMode != Mode.Resize && drawableType != DrawableType.None) { if (Selection == SelectionType.Move) { - PWEngine.DragSelectedDrawables(position.X, position.Y); + PenWave.Instance.DragSelectedDrawables(position.X, position.Y); currentMode = Mode.Move; } else if (Selection == SelectionType.Rotate) { - PWEngine.RotateSelected(position.X, position.Y); + PenWave.Instance.RotateSelected(position.X, position.Y); currentMode = Mode.Rotate; } else if (Selection == SelectionType.Scale) { - PWEngine.ScaleSelection( + PenWave.Instance.ScaleSelection( (position.X-anchorX)/(startScaleX-anchorX), (position.Y-anchorY)/(startScaleY-anchorY) ); @@ -220,23 +225,23 @@ private void EndDrawing(Vector2 position, uint touchTime) switch (currentMode) { case Mode.Move : - PWEngine.EndDraging(); + PenWave.Instance.EndDraging(); break; case Mode.Resize : - drawableType = (DrawableType)PWEngine.SelectDrawables(); + drawableType = (DrawableType)PenWave.Instance.SelectDrawables(); break; case Mode.Rotate : - PWEngine.EndRotating(position.X, position.Y); + PenWave.Instance.EndRotating(position.X, position.Y); break; case Mode.Scale : - PWEngine.EndRotating(position.X, position.Y); - PWEngine.EndSelectionScale( + PenWave.Instance.EndRotating(position.X, position.Y); + PenWave.Instance.EndSelectionScale( (position.X-anchorX)/(startScaleX-anchorX), (position.Y-anchorY)/(startScaleY-anchorY) ); break; default : - PWEngine.DropSelectedDrawables(); + PenWave.Instance.DropSelectedDrawables(); break; } isTouchedInsideSelectedArea = false; diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Toolbase.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Toolbase.cs index 10a4f36fdc7..253fdfd136f 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Toolbase.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Toolbase.cs @@ -14,13 +14,16 @@ * limitations under the License. * */ + using System; +using System.ComponentModel; namespace Tizen.NUI.PenWave { /// /// The base class for all tools in the PenWave. /// + [EditorBrowsable(EditorBrowsableState.Never)] public abstract class ToolBase { /// @@ -38,16 +41,18 @@ public abstract class ToolBase /// /// The touch event data. /// The manager responsible for handling undo and redo operations. - public virtual void HandleInput(Touch touch, UnRedoManager unredoManager) {} + internal virtual void HandleInput(Touch touch, UnRedoManager unredoManager) {} /// /// Activates the tool, making it ready to receive input and perform its functionality. /// + [EditorBrowsable(EditorBrowsableState.Never)] public abstract void Activate(); /// /// Deactivates the tool, stopping it from receiving input and performing its functionality. /// + [EditorBrowsable(EditorBrowsableState.Never)] public abstract void Deactivate(); /// diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/UnRedoManager.cs b/src/Tizen.NUI.PenWave/src/public/Tools/UnRedoManager.cs index b7cfb3a5262..9eb3f5c9627 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/UnRedoManager.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/UnRedoManager.cs @@ -15,10 +15,16 @@ * */ +using System; +using System.ComponentModel; using System.Collections.Generic; namespace Tizen.NUI.PenWave { + /// + /// The UnRedoManager class manages undo and redo operations for commands. + /// + [EditorBrowsable(EditorBrowsableState.Never)] public class UnRedoManager { // Stacks to store undo and redo commands @@ -29,6 +35,7 @@ public class UnRedoManager /// Executes a command and clears the redo stack. /// /// The command to be executed. + [EditorBrowsable(EditorBrowsableState.Never)] public void Execute(ICommand command) { command.Execute(); @@ -39,12 +46,13 @@ public void Execute(ICommand command) /// /// Undoes the last executed command and pushes it to the redo stack. /// + [EditorBrowsable(EditorBrowsableState.Never)] public void Undo() { if (undoStack.Count > 0) { ICommand command = undoStack.Pop(); - PWEngine.Undo(); + PenWave.Instance.Undo(); redoStack.Push(command); } } @@ -52,12 +60,13 @@ public void Undo() /// /// Redoes the last undone command and pushes it to the undo stack. /// + [EditorBrowsable(EditorBrowsableState.Never)] public void Redo() { if (redoStack.Count > 0) { ICommand command = redoStack.Pop(); - PWEngine.Redo(); + PenWave.Instance.Redo(); undoStack.Push(command); } } @@ -65,11 +74,13 @@ public void Redo() /// /// Determines whether an undo operation is possible. /// + [EditorBrowsable(EditorBrowsableState.Never)] public bool CanUndo => undoStack.Count > 0; /// /// Determines whether a redo operation is possible. /// + [EditorBrowsable(EditorBrowsableState.Never)] public bool CanRedo => redoStack.Count > 0; } } diff --git a/test/Tizen.NUI.PenWave.Sample/src/PenWaveSample.cs b/test/Tizen.NUI.PenWave.Sample/src/PenWaveSample.cs index b2ecb0eaf5d..1497ffd5cf7 100644 --- a/test/Tizen.NUI.PenWave.Sample/src/PenWaveSample.cs +++ b/test/Tizen.NUI.PenWave.Sample/src/PenWaveSample.cs @@ -43,7 +43,7 @@ private void ToolPicker() var screenShotButton = mToolPickerView.CreateToolButton(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "images/icon_picture.png", () => { - PenWave.ThumbnailSavedDelegate ThumbnailsDelegate = OnThumbnails; + PenWave.ThumbnailSavedCallback ThumbnailsDelegate = OnThumbnails; canvasView.TakeScreenShot("/home/puro/workspace/submit/TizenFX/test/Tizen.NUI.PenWave.Sample/screenshot.png", 0, 0, 1920, 1080, ThumbnailsDelegate); }); mToolPickerView.PickerView.Add(screenShotButton);