diff --git a/src/Tizen.NUI.PenWave/src/Internal/Canvas/CanvasRenderer.cs b/src/Tizen.NUI.PenWave/src/Internal/Canvas/CanvasRenderer.cs deleted file mode 100644 index 454467e5f43..00000000000 --- a/src/Tizen.NUI.PenWave/src/Internal/Canvas/CanvasRenderer.cs +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright(c) 2025 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -using System.IO; - -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - /// - /// The class that provides rendering functionality for PenWave. - /// - internal class CanvasRenderer - { - // Paths to resources. - private static readonly string s_fontPath = FrameworkInformation.ResourcePath + "fonts/font.ttf"; - private static readonly string[] s_texturePaths = { - FrameworkInformation.ResourcePath + "images/textures/brush_acrylic.png", - FrameworkInformation.ResourcePath + "images/textures/brush_sponge.png", - FrameworkInformation.ResourcePath + "images/textures/dot_brush.png", - FrameworkInformation.ResourcePath + "images/textures/highlighter.png", - FrameworkInformation.ResourcePath + "images/textures/soft_brush.png" - }; - - // Canvas id. - private uint _canvasId; - // PenWave engine. - 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. - /// - /// The canvas id - internal CanvasRenderer(uint canvasId) - { - _canvasId = canvasId; - _engine = PenWave.Instance; - _engine.SetCurrentCanvas(canvasId); - _engine.SetResourcePath(FrameworkInformation.ResourcePath + "images/"); - _engine.SetFontPath(s_fontPath); - _engine.SetTexturePaths(s_texturePaths, s_texturePaths.Length); - } - - /// - /// Initializes OpenGL context. This method must be called before any other methods that require OpenGL context. - /// - internal void InitializeGL() - { - _engine.InitializeGL(); - } - - /// - /// Terminates OpenGL context. This method must be called after all methods that require OpenGL context are finished. - /// - internal void TerminateGL() - { - _engine.TerminateGL(); - } - - /// - /// Renders frame using OpenGL context. This method should be called from the render thread. It returns 0 when there is no more work to do. Otherwise it returns 1. - /// - /// DirectRenderingGLView.RenderCallbackInput - /// - internal int RenderFrame(in DirectRenderingGLView.RenderCallbackInput input) - { - return _engine.RenderFrameGL(); - } - - /// - /// Resizes the current canvas. This method should be called when the size of the window changes. It updates the size of the current canvas and renders the full redraw. - /// - /// The width - /// The height - internal void Resize(int width, int height) - { - _engine.UpdateGLWindowSize(width, height); - _engine.RenderFullyReDraw(); - } - - /// - /// Clears the current canvas. All strokes and pictures will be removed. - /// - internal void ClearCanvas() - { - _engine.ClearCurrentCanvas(); - } - - /// - /// Adds a picture to canvas - /// - /// The image file path - /// The x position - /// The y position - /// The width - /// The height - internal void AddPicture(string path, float x, float y, float width, float height) - { - _engine.AddPicture(path, x, y, width, height); - _engine.RenderFullyReDraw(); - } - - /// - /// Toggles the grid - /// - /// The grid type - internal void ToggleGrid(GridDensityType gridType) - { - _engine.ToggleGrid((int)gridType); - } - - /// - /// Sets the canvas background color - /// - /// The background color - internal void SetCanvasColor(Color color) - { - _engine.CanvasSetColor(ToHex(color), color.A); - } - - /// - /// Saves the canvas - /// - /// The file path - internal void SaveCanvas(string path) - { - _engine.SaveCanvas(_canvasId, path); - } - - /// - /// Loads the canvas from the specified path. - /// - /// The file path - internal void LoadCanvas(string path) - { - if (!File.Exists(path)) - { - Tizen.Log.Error("NUI", $"Loading canvas error: {path}\n"); - } - else - { - _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. - /// - /// The file paht - /// The x position - /// The y position - /// The width - /// The height - /// Callback when screenshot is complete - internal void TakeScreenShot(string path, int x, int y, int width, int height, PenWave.ScreenShotCallback 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); - var green = (uint)(color.G * 255); - var blue = (uint)(color.B * 255); - return $"#{red:X2}{green:X2}{blue:X2}"; - } - - /// - /// Start the canvas movement. - /// - /// True if the canvas move begin is successful, otherwise false - internal bool CanvasMoveBegin() - { - return _engine.CanvasMoveBegin(); - } - - /// - /// Update the canvas movement. - /// - /// The x position - /// The y position - /// True if the canvas move update is successful, otherwise false - internal bool CanvasMoveUpdate(int x, int y) - { - return _engine.CanvasMove(x, y); - } - - /// - /// End the canvas movement. - /// - /// True if the canvas move end is successful, otherwise false - internal bool CanvasMoveEnd() - { - return _engine.CanvasMoveEnd(); - } - - /// - /// Start the canvas zoom - /// - /// True if the canvas zoom begin is successful, otherwise false - internal bool CanvasZoomBegin() - { - return _engine.CanvasZoomBegin(); - } - - /// - /// Update the canvas zoom - /// - /// The x position - /// The y position - /// The zoom value - /// The delta x, It will be zoomed in when it exceeds this value. - /// The delta y, It will be zoomed in when it exceeds this value. - /// True if the canvas zoom update is successful, otherwise false - internal bool CanvasZoomUpdate(float x, float y, float zoom, float dx, float dy) - { - return _engine.CanvasZoom(x, y, zoom, dx, dy); - } - - /// - /// End the canvas zoom - /// - /// True if the canvas zoom end is successful, otherwise false - internal bool CanvasZoomEnd() - { - return _engine.CanvasZoomEnd(); - } - - /// - /// Get the canvas zoom value - /// - /// The zoom value - internal int CanvasGetZoomValue() - { - return _engine.CanvasGetZoomValue(); - } - - /// - /// Set the canvas zoom value - /// - /// The zoom value - internal void CanvasSetZoomValue(int zoomValue) - { - _engine.CanvasSetZoomValue(zoomValue); - } - - /// - /// Zoom to the specified value - /// - /// The x position - /// The y position - /// The zoom value - internal void CanvasSetZoomValue(int x, int y, int zoomValue) - { - _engine.CanvasSetZoomValue(x, y, zoomValue); - } - } -} diff --git a/src/Tizen.NUI.PenWave/src/Interop/Interop.PenWave.cs b/src/Tizen.NUI.PenWave/src/Interop/Interop.PenWaveRenderer.cs similarity index 99% rename from src/Tizen.NUI.PenWave/src/Interop/Interop.PenWave.cs rename to src/Tizen.NUI.PenWave/src/Interop/Interop.PenWaveRenderer.cs index 0682b4cb942..77ed3f8d02d 100644 --- a/src/Tizen.NUI.PenWave/src/Interop/Interop.PenWave.cs +++ b/src/Tizen.NUI.PenWave/src/Interop/Interop.PenWaveRenderer.cs @@ -23,7 +23,7 @@ namespace Tizen.NUI.PenWave { internal static partial class Interop { - internal static partial class PenWave + internal static partial class PenWaveRenderer { private const string Lib = "libhand-drawing-engine.so"; @@ -239,7 +239,7 @@ internal static partial class PenWave 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.ScreenShotCallback thumbSaved); + 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.PenWaveRenderer.ScreenShotCallback thumbSaved); [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "ToggleGrid")] public static extern void ToggleGrid(int densityType); diff --git a/src/Tizen.NUI.PenWave/src/public/Canvas/PenWaveCanvas.cs b/src/Tizen.NUI.PenWave/src/public/Canvas/PenWaveCanvas.cs index b2e3d5ff531..ab549e5fe01 100644 --- a/src/Tizen.NUI.PenWave/src/public/Canvas/PenWaveCanvas.cs +++ b/src/Tizen.NUI.PenWave/src/public/Canvas/PenWaveCanvas.cs @@ -41,10 +41,10 @@ public class PenWaveCanvas : DirectRenderingGLView public event EventHandler ActionFinished; private UnRedoManager _unredoManager; - private CanvasRenderer _renderer; private PropertyNotification _propertyNotification; private ToolBase _currentTool; private ToolBase _canvasTool; + private uint _canvasId; /// /// Creates a new instance of a PenWaveCanvas. @@ -52,7 +52,8 @@ public class PenWaveCanvas : DirectRenderingGLView [EditorBrowsable(EditorBrowsableState.Never)] public PenWaveCanvas() : base(DirectRenderingGLView.ColorFormat.RGBA8888, DirectRenderingGLView.BackendMode.UnsafeDirectRendering) { - _renderer = new CanvasRenderer(PenWave.Instance.CreateCanvas(-1, -1)); + _canvasId = PenWaveRenderer.Instance.CreateCanvas(-1, -1); + PenWaveRenderer.Instance.SetCurrentCanvas(_canvasId); InitializeCanvas(); } @@ -63,7 +64,8 @@ public PenWaveCanvas() : base(DirectRenderingGLView.ColorFormat.RGBA8888, Direct [EditorBrowsable(EditorBrowsableState.Never)] public PenWaveCanvas(string backgroundPath) : base(DirectRenderingGLView.ColorFormat.RGBA8888, DirectRenderingGLView.BackendMode.UnsafeDirectRendering) { - _renderer = new CanvasRenderer(PenWave.Instance.CreateCanvasWithBackgroundImage(backgroundPath)); + _canvasId = PenWaveRenderer.Instance.CreateCanvasWithBackgroundImage(backgroundPath); + PenWaveRenderer.Instance.SetCurrentCanvas(_canvasId); InitializeCanvas(); } @@ -76,7 +78,7 @@ private void InitializeCanvas() this.HeightResizePolicy = ResizePolicyType.FillToParent; this.RenderingMode = GLRenderingMode.Continuous; - this.RegisterGLCallbacks(_renderer.InitializeGL, _renderer.RenderFrame, _renderer.TerminateGL); + this.RegisterGLCallbacks(PenWaveRenderer.Instance.InitializeGL, PenWaveRenderer.Instance.RenderFrame, PenWaveRenderer.Instance.TerminateGL); this.SetGraphicsConfig(false, false, 0, GLESVersion.Version20); _propertyNotification = this.AddPropertyNotification("size", PropertyCondition.Step(1.0f)); @@ -85,7 +87,7 @@ private void InitializeCanvas() Tizen.NUI.BaseComponents.View target = args.PropertyNotification.GetTarget() as Tizen.NUI.BaseComponents.View; if (target != null) { - _renderer.Resize((int)target.SizeWidth, (int)target.SizeHeight); + PenWaveRenderer.Instance.Resize((int)target.SizeWidth, (int)target.SizeHeight); } }; } @@ -159,7 +161,7 @@ private void RegisterUndo() [EditorBrowsable(EditorBrowsableState.Never)] public void ClearCanvas() { - _renderer.ClearCanvas(); + PenWaveRenderer.Instance.ClearCurrentCanvas(); RegisterUndo(); NotifyActionFinished(this, EventArgs.Empty); } @@ -201,7 +203,7 @@ public void Redo() [EditorBrowsable(EditorBrowsableState.Never)] public void SetCanvasColor(Color color) { - _renderer.SetCanvasColor(color); + PenWaveRenderer.Instance.SetCanvasColor(color); } /// @@ -211,7 +213,7 @@ public void SetCanvasColor(Color color) [EditorBrowsable(EditorBrowsableState.Never)] public void ToggleGrid(GridDensityType gridType) { - _renderer.ToggleGrid(gridType); + PenWaveRenderer.Instance.ToggleGrid(gridType); } /// @@ -225,7 +227,7 @@ public void ToggleGrid(GridDensityType gridType) [EditorBrowsable(EditorBrowsableState.Never)] public void AddPicture(string path, float x, float y, float width, float height) { - _renderer.AddPicture(path, x, y, width, height); + PenWaveRenderer.Instance.AddPicture(path, x, y, width, height); RegisterUndo(); NotifyActionFinished(this, EventArgs.Empty); } @@ -243,6 +245,10 @@ public void HandleInput(Touch touch) } } + /// + /// Handles wheel events. This wheel event is delivered to the current tool. + /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public void HandleInput(Wheel wheel) { @@ -259,7 +265,7 @@ public void HandleInput(Wheel wheel) [EditorBrowsable(EditorBrowsableState.Never)] public void SaveCanvas(string path) { - _renderer.SaveCanvas(path); + PenWaveRenderer.Instance.SaveCanvas(_canvasId, path); } /// @@ -269,7 +275,7 @@ public void SaveCanvas(string path) [EditorBrowsable(EditorBrowsableState.Never)] public void LoadCanvas(string path) { - _renderer.LoadCanvas(path); + PenWaveRenderer.Instance.LoadCanvas(_canvasId, path); } @@ -285,7 +291,7 @@ public void LoadCanvas(string path) [EditorBrowsable(EditorBrowsableState.Never)] public void TakeScreenShot(string path, int x, int y, int width, int height, EventHandler callback) { - _renderer.TakeScreenShot(path, x, y, width, height, () => { + PenWaveRenderer.Instance.TakeScreenShot(_canvasId, path, x, y, width, height, () => { callback?.Invoke(this, EventArgs.Empty); }); } @@ -297,7 +303,7 @@ public void TakeScreenShot(string path, int x, int y, int width, int height, Eve [EditorBrowsable(EditorBrowsableState.Never)] public bool MoveBegin() { - return _renderer.CanvasMoveBegin(); + return PenWaveRenderer.Instance.CanvasMoveBegin(); } /// @@ -309,7 +315,7 @@ public bool MoveBegin() [EditorBrowsable(EditorBrowsableState.Never)] public bool MoveUpdate(int x, int y) { - return _renderer.CanvasMoveUpdate(x, y); + return PenWaveRenderer.Instance.CanvasMove(x, y); } /// @@ -319,7 +325,7 @@ public bool MoveUpdate(int x, int y) [EditorBrowsable(EditorBrowsableState.Never)] public bool MoveEnd() { - return _renderer.CanvasMoveEnd(); + return PenWaveRenderer.Instance.CanvasMoveEnd(); } /// @@ -329,7 +335,7 @@ public bool MoveEnd() [EditorBrowsable(EditorBrowsableState.Never)] public bool ZoomBegin() { - return _renderer.CanvasZoomBegin(); + return PenWaveRenderer.Instance.CanvasZoomBegin(); } /// @@ -344,7 +350,7 @@ public bool ZoomBegin() [EditorBrowsable(EditorBrowsableState.Never)] public bool ZoomUpdate(float x, float y, float zoom, float dx, float dy) { - return _renderer.CanvasZoomUpdate(x, y, zoom, dx, dy); + return PenWaveRenderer.Instance.CanvasZoom(x, y, zoom, dx, dy); } /// @@ -354,7 +360,7 @@ public bool ZoomUpdate(float x, float y, float zoom, float dx, float dy) [EditorBrowsable(EditorBrowsableState.Never)] public bool ZoomEnd() { - return _renderer.CanvasZoomEnd(); + return PenWaveRenderer.Instance.CanvasZoomEnd(); } /// @@ -364,7 +370,7 @@ public bool ZoomEnd() [EditorBrowsable(EditorBrowsableState.Never)] public int GetZoomValue() { - return _renderer.CanvasGetZoomValue(); + return PenWaveRenderer.Instance.CanvasGetZoomValue(); } /// @@ -374,7 +380,7 @@ public int GetZoomValue() [EditorBrowsable(EditorBrowsableState.Never)] public void SetZoomValue(int zoomValue) { - _renderer.CanvasSetZoomValue(zoomValue); + PenWaveRenderer.Instance.CanvasSetZoomValue(zoomValue); } /// @@ -386,7 +392,7 @@ public void SetZoomValue(int zoomValue) [EditorBrowsable(EditorBrowsableState.Never)] public void SetZoomValue(int x, int y, int zoomValue) { - _renderer.CanvasSetZoomValue(x, y, zoomValue); + PenWaveRenderer.Instance.CanvasSetZoomValue(x, y, zoomValue); } /// @@ -398,7 +404,7 @@ protected override void Dispose(DisposeTypes type) if(disposed) return; _currentTool.ActionStarted -= OnStarted; _currentTool.ActionFinished -= OnFinished;; - _renderer.TerminateGL(); + PenWaveRenderer.Instance.TerminateGL(); base.Dispose(type); } } diff --git a/src/Tizen.NUI.PenWave/src/public/Canvas/PenWave.cs b/src/Tizen.NUI.PenWave/src/public/Canvas/PenWaveRenderer.cs similarity index 78% rename from src/Tizen.NUI.PenWave/src/public/Canvas/PenWave.cs rename to src/Tizen.NUI.PenWave/src/public/Canvas/PenWaveRenderer.cs index 37d268a057d..0dbd098b195 100644 --- a/src/Tizen.NUI.PenWave/src/public/Canvas/PenWave.cs +++ b/src/Tizen.NUI.PenWave/src/public/Canvas/PenWaveRenderer.cs @@ -1,5 +1,5 @@ /* - * Copyright(c) 2024 Samsung Electronics Co., Ltd. + * Copyright(c) 2025 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,17 +15,29 @@ * */ +using System.IO; +using Tizen.NUI.BaseComponents; + using System.ComponentModel; using System.Runtime.InteropServices; namespace Tizen.NUI.PenWave { /// - /// PenWave class provides functions to draw on the canvas. + /// PenWaveRenderer class provides functions to draw on the canvas. /// [EditorBrowsable(EditorBrowsableState.Never)] - public class PenWave + public class PenWaveRenderer { + private static readonly string s_fontPath = FrameworkInformation.ResourcePath + "fonts/font.ttf"; + private static readonly string[] s_texturePaths = { + FrameworkInformation.ResourcePath + "images/textures/brush_acrylic.png", + FrameworkInformation.ResourcePath + "images/textures/brush_sponge.png", + FrameworkInformation.ResourcePath + "images/textures/dot_brush.png", + FrameworkInformation.ResourcePath + "images/textures/highlighter.png", + FrameworkInformation.ResourcePath + "images/textures/soft_brush.png" + }; + /// /// The delegate for the thumbnail saved callback. /// @@ -33,14 +45,30 @@ public class PenWave [EditorBrowsable(EditorBrowsableState.Never)] public delegate void ScreenShotCallback(); - private static readonly PenWave s_instance = new PenWave(); - private PenWave() { } + private static readonly PenWaveRenderer s_instance = new PenWaveRenderer(); + private PenWaveRenderer() + { + SetResourcePath(FrameworkInformation.ResourcePath + "images/"); + SetFontPath(s_fontPath); + SetTexturePaths(s_texturePaths, s_texturePaths.Length); + } + + /// + /// Gets the singleton instance of PenWaveRenderer. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static PenWaveRenderer Instance => s_instance; /// - /// Gets the singleton instance of PenWave. + /// Renders frame using OpenGL context. This method should be called from the render thread. It returns 0 when there is no more work to do. Otherwise it returns 1. /// + /// DirectRenderingGLView.RenderCallbackInput + /// [EditorBrowsable(EditorBrowsableState.Never)] - public static PenWave Instance => s_instance; + public int RenderFrame(in DirectRenderingGLView.RenderCallbackInput input) + { + return RenderFrameGL(); + } /// /// Initializes the PenWave library. @@ -48,7 +76,7 @@ private PenWave() { } [EditorBrowsable(EditorBrowsableState.Never)] public void InitializeGL() { - Interop.PenWave.InitializeGL(); + Interop.PenWaveRenderer.InitializeGL(); } /// @@ -57,7 +85,7 @@ public void InitializeGL() [EditorBrowsable(EditorBrowsableState.Never)] public int RenderFrameGL() { - return Interop.PenWave.RenderFrameGL(); + return Interop.PenWaveRenderer.RenderFrameGL(); } /// @@ -66,7 +94,7 @@ public int RenderFrameGL() [EditorBrowsable(EditorBrowsableState.Never)] public void RenderFullyReDraw() { - Interop.PenWave.RenderFullyReDraw(); + Interop.PenWaveRenderer.RenderFullyReDraw(); } /// @@ -75,7 +103,7 @@ public void RenderFullyReDraw() [EditorBrowsable(EditorBrowsableState.Never)] public void TerminateGL() { - Interop.PenWave.TerminateGL(); + Interop.PenWaveRenderer.TerminateGL(); } /// @@ -84,9 +112,10 @@ public void TerminateGL() /// The width /// The height [EditorBrowsable(EditorBrowsableState.Never)] - public void UpdateGLWindowSize(int w, int h) + public void Resize(int w, int h) { - Interop.PenWave.UpdateGLWindowSize(w, h); + Interop.PenWaveRenderer.UpdateGLWindowSize(w, h); + RenderFullyReDraw(); } /// @@ -96,7 +125,7 @@ public void UpdateGLWindowSize(int w, int h) [EditorBrowsable(EditorBrowsableState.Never)] public void UpdateGLWindowOrientation(int angle) { - Interop.PenWave.UpdateGLWindowOrientation(angle); + Interop.PenWaveRenderer.UpdateGLWindowOrientation(angle); } /// @@ -109,7 +138,7 @@ public void UpdateGLWindowOrientation(int angle) [EditorBrowsable(EditorBrowsableState.Never)] public uint BeginShapeDraw(float x, float y, uint time = 1) { - return Interop.PenWave.BeginShapeDraw(x, y, time); + return Interop.PenWaveRenderer.BeginShapeDraw(x, y, time); } /// @@ -130,7 +159,7 @@ public uint BeginShapeDraw(float x, float y, uint time = 1) [EditorBrowsable(EditorBrowsableState.Never)] public ErrorShapeAddPointsType DrawShape(uint shapeID, float x, float y, uint time = 1) { - return (ErrorShapeAddPointsType)Interop.PenWave.DrawShape(shapeID, x, y, time); + return (ErrorShapeAddPointsType)Interop.PenWaveRenderer.DrawShape(shapeID, x, y, time); } /// @@ -149,7 +178,7 @@ public ErrorShapeAddPointsType DrawShape(uint shapeID, float x, float y, uint ti [EditorBrowsable(EditorBrowsableState.Never)] public ErrorShapeAddPointsType EndShapeDraw(uint shapeID, uint time = 1) { - return (ErrorShapeAddPointsType)Interop.PenWave.EndShapeDraw(shapeID, time); + return (ErrorShapeAddPointsType)Interop.PenWaveRenderer.EndShapeDraw(shapeID, time); } /// @@ -161,7 +190,7 @@ public ErrorShapeAddPointsType EndShapeDraw(uint shapeID, uint time = 1) [EditorBrowsable(EditorBrowsableState.Never)] public uint BeginLineDraw(float x, float y, uint time = 1) { - return Interop.PenWave.BeginLineDraw(x, y, time); + return Interop.PenWaveRenderer.BeginLineDraw(x, y, time); } /// @@ -181,7 +210,7 @@ public uint BeginLineDraw(float x, float y, uint time = 1) [EditorBrowsable(EditorBrowsableState.Never)] public ErrorShapeAddPointsType DrawLine(uint shapeID, float x, float y, uint time = 1) { - return (ErrorShapeAddPointsType)Interop.PenWave.DrawLine(shapeID, x, y, time); + return (ErrorShapeAddPointsType)Interop.PenWaveRenderer.DrawLine(shapeID, x, y, time); } /// @@ -199,7 +228,7 @@ public ErrorShapeAddPointsType DrawLine(uint shapeID, float x, float y, uint tim [EditorBrowsable(EditorBrowsableState.Never)] public ErrorShapeAddPointsType EndLineDraw(uint shapeID, uint time = 1) { - return (ErrorShapeAddPointsType)Interop.PenWave.EndLineDraw(shapeID, time); + return (ErrorShapeAddPointsType)Interop.PenWaveRenderer.EndLineDraw(shapeID, time); } @@ -210,7 +239,7 @@ public ErrorShapeAddPointsType EndLineDraw(uint shapeID, uint time = 1) [EditorBrowsable(EditorBrowsableState.Never)] public void StopErasing() { - Interop.PenWave.StopErasing(); + Interop.PenWaveRenderer.StopErasing(); } /// @@ -224,7 +253,7 @@ public void StopErasing() [EditorBrowsable(EditorBrowsableState.Never)] public bool EraseShape(int x, int y, float radius, bool partial) { - return Interop.PenWave.EraseShape(x, y, radius, partial); + return Interop.PenWaveRenderer.EraseShape(x, y, radius, partial); } /// @@ -239,7 +268,7 @@ public bool EraseShape(int x, int y, float radius, bool 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); + return Interop.PenWaveRenderer.AddRectanglePath(xStart, yStart, x, y, finished); } /// @@ -255,7 +284,7 @@ public uint AddRectanglePath(float xStart, float yStart, float x, float y, bool [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); + return Interop.PenWaveRenderer.AddArcPath(xCenter, yCenter, radius, x, y, finished); } /// @@ -275,7 +304,7 @@ public uint AddArcPath(float xCenter, float yCenter, float radius, float x, floa [EditorBrowsable(EditorBrowsableState.Never)] public ErrorShapeAddPointsType ResizeShapePath(uint shapeID, float x, float y) { - return (ErrorShapeAddPointsType)Interop.PenWave.ResizeShapePath(shapeID, x, y); + return (ErrorShapeAddPointsType)Interop.PenWaveRenderer.ResizeShapePath(shapeID, x, y); } /// @@ -293,7 +322,7 @@ public ErrorShapeAddPointsType ResizeShapePath(uint shapeID, float x, float y) [EditorBrowsable(EditorBrowsableState.Never)] public int FinishShapePath(uint shapeID) { - return Interop.PenWave.FinishShapePath(shapeID); + return Interop.PenWaveRenderer.FinishShapePath(shapeID); } /// @@ -303,7 +332,7 @@ public int FinishShapePath(uint shapeID) [EditorBrowsable(EditorBrowsableState.Never)] public bool CanvasZoomBegin() { - return Interop.PenWave.CanvasZoomBegin(); + return Interop.PenWaveRenderer.CanvasZoomBegin(); } /// @@ -318,7 +347,7 @@ public bool 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); + return Interop.PenWaveRenderer.CanvasZoom(x, y, zoom, dx, dy); } /// @@ -328,7 +357,7 @@ public bool CanvasZoom(float x, float y, float zoom, float dx, float dy) [EditorBrowsable(EditorBrowsableState.Never)] public bool CanvasZoomEnd() { - return Interop.PenWave.CanvasZoomEnd(); + return Interop.PenWaveRenderer.CanvasZoomEnd(); } /// @@ -338,7 +367,7 @@ public bool CanvasZoomEnd() [EditorBrowsable(EditorBrowsableState.Never)] public int CanvasGetZoomValue() { - return Interop.PenWave.CanvasGetZoomValue(); + return Interop.PenWaveRenderer.CanvasGetZoomValue(); } /// @@ -348,7 +377,7 @@ public int CanvasGetZoomValue() [EditorBrowsable(EditorBrowsableState.Never)] public void CanvasSetZoomValue(int zoomValue) { - Interop.PenWave.CanvasSetZoomValue((float)zoomValue); + Interop.PenWaveRenderer.CanvasSetZoomValue((float)zoomValue); } /// @@ -360,7 +389,7 @@ public void CanvasSetZoomValue(int zoomValue) [EditorBrowsable(EditorBrowsableState.Never)] public void CanvasSetZoomValue(int x, int y, int zoomValue) { - Interop.PenWave.CanvasSetZoomValue(x, y, (float)zoomValue); + Interop.PenWaveRenderer.CanvasSetZoomValue(x, y, (float)zoomValue); } /// @@ -370,7 +399,7 @@ public void CanvasSetZoomValue(int x, int y, int zoomValue) [EditorBrowsable(EditorBrowsableState.Never)] public bool CanvasMoveBegin() { - return Interop.PenWave.CanvasMoveBegin(); + return Interop.PenWaveRenderer.CanvasMoveBegin(); } /// @@ -382,7 +411,7 @@ public bool CanvasMoveBegin() [EditorBrowsable(EditorBrowsableState.Never)] public bool CanvasMove(int x, int y) { - return Interop.PenWave.CanvasMove(x, y); + return Interop.PenWaveRenderer.CanvasMove(x, y); } /// @@ -392,7 +421,18 @@ public bool CanvasMove(int x, int y) [EditorBrowsable(EditorBrowsableState.Never)] public bool CanvasMoveEnd() { - return Interop.PenWave.CanvasMoveEnd(); + return Interop.PenWaveRenderer.CanvasMoveEnd(); + } + + /// + /// Set Canvas Color + /// + /// The rgb color value + /// The alpha value + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetCanvasColor(string hexColor, float a) + { + Interop.PenWaveRenderer.CanvasSetColor(hexColor, a); } /// @@ -401,9 +441,9 @@ public bool CanvasMoveEnd() /// The rgb color value /// The alpha value [EditorBrowsable(EditorBrowsableState.Never)] - public void CanvasSetColor(string hexColor, float a) + public void SetCanvasColor(Color color) { - Interop.PenWave.CanvasSetColor(hexColor, a); + SetCanvasColor(ToHex(color), color.A); } /// @@ -414,7 +454,7 @@ public void CanvasSetColor(string hexColor, float a) [EditorBrowsable(EditorBrowsableState.Never)] public void CanvasSetSize(int width, int height) { - Interop.PenWave.CanvasSetSize(width, height); + Interop.PenWaveRenderer.CanvasSetSize(width, height); } /// @@ -424,7 +464,7 @@ public void CanvasSetSize(int width, int height) [EditorBrowsable(EditorBrowsableState.Never)] public void SetResourcePath(string resourcePath) { - Interop.PenWave.SetResourcePath(resourcePath); + Interop.PenWaveRenderer.SetResourcePath(resourcePath); } /// @@ -434,7 +474,7 @@ public void SetResourcePath(string resourcePath) [EditorBrowsable(EditorBrowsableState.Never)] public void SetFontPath(string fontPath) { - Interop.PenWave.SetFontPath(fontPath); + Interop.PenWaveRenderer.SetFontPath(fontPath); } /// @@ -445,7 +485,7 @@ public void SetFontPath(string fontPath) [EditorBrowsable(EditorBrowsableState.Never)] public void SetTexturePaths(string[] texturePaths, int textureCount) { - Interop.PenWave.SetTexturePaths(texturePaths, textureCount); + Interop.PenWaveRenderer.SetTexturePaths(texturePaths, textureCount); } /// @@ -455,7 +495,7 @@ public void SetTexturePaths(string[] texturePaths, int textureCount) [EditorBrowsable(EditorBrowsableState.Never)] public void SetStrokeSize(float size) { - Interop.PenWave.SetStrokeSize(size); + Interop.PenWaveRenderer.SetStrokeSize(size); } /// @@ -466,7 +506,7 @@ public void SetStrokeSize(float size) [EditorBrowsable(EditorBrowsableState.Never)] public void SetStrokeColor(string hexColor, float a) { - Interop.PenWave.SetStrokeColor(hexColor, a); + Interop.PenWaveRenderer.SetStrokeColor(hexColor, a); } /// @@ -476,7 +516,7 @@ public void SetStrokeColor(string hexColor, float a) [EditorBrowsable(EditorBrowsableState.Never)] public void SetStrokeType(int brushType) { - Interop.PenWave.SetStrokeType(brushType); + Interop.PenWaveRenderer.SetStrokeType(brushType); } /// @@ -486,7 +526,7 @@ public void SetStrokeType(int brushType) [EditorBrowsable(EditorBrowsableState.Never)] public void SetBrushTexture(int textureId) { - Interop.PenWave.SetBrushTexture(textureId); + Interop.PenWaveRenderer.SetBrushTexture(textureId); } /// @@ -496,7 +536,7 @@ public void SetBrushTexture(int textureId) [EditorBrowsable(EditorBrowsableState.Never)] public void SetBrushDistance(float distance) { - Interop.PenWave.SetBrushDistance(distance); + Interop.PenWaveRenderer.SetBrushDistance(distance); } /// @@ -506,7 +546,7 @@ public void SetBrushDistance(float distance) [EditorBrowsable(EditorBrowsableState.Never)] public void SetDashArray(string dashArray) { - Interop.PenWave.SetDashArray(dashArray); + Interop.PenWaveRenderer.SetDashArray(dashArray); } /// @@ -516,7 +556,7 @@ public void SetDashArray(string dashArray) [EditorBrowsable(EditorBrowsableState.Never)] public void SetLineAngle(float angle) { - Interop.PenWave.SetLineAngle(angle); + Interop.PenWaveRenderer.SetLineAngle(angle); } /// @@ -526,7 +566,7 @@ public void SetLineAngle(float angle) [EditorBrowsable(EditorBrowsableState.Never)] public float GetBrushSize() { - return Interop.PenWave.GetBrushSize(); + return Interop.PenWaveRenderer.GetBrushSize(); } /// @@ -536,7 +576,7 @@ public float GetBrushSize() [EditorBrowsable(EditorBrowsableState.Never)] public int GetBrushType() { - return Interop.PenWave.GetBrushType(); + return Interop.PenWaveRenderer.GetBrushType(); } /// @@ -546,7 +586,7 @@ public int GetBrushType() [EditorBrowsable(EditorBrowsableState.Never)] public int GetBrushTexture() { - return Interop.PenWave.GetBrushTexture(); + return Interop.PenWaveRenderer.GetBrushTexture(); } /// @@ -556,7 +596,7 @@ public int GetBrushTexture() [EditorBrowsable(EditorBrowsableState.Never)] public float GetBrushDistance() { - return Interop.PenWave.GetBrushDistance(); + return Interop.PenWaveRenderer.GetBrushDistance(); } /// @@ -566,7 +606,7 @@ public float GetBrushDistance() [EditorBrowsable(EditorBrowsableState.Never)] public float GetLineAngle() { - return Interop.PenWave.GetLineAngle(); + return Interop.PenWaveRenderer.GetLineAngle(); } /// @@ -576,7 +616,7 @@ public float GetLineAngle() [EditorBrowsable(EditorBrowsableState.Never)] public int GetShapeCount() { - return Interop.PenWave.GetShapeCount(); + return Interop.PenWaveRenderer.GetShapeCount(); } /// @@ -588,7 +628,7 @@ public int GetShapeCount() [EditorBrowsable(EditorBrowsableState.Never)] public uint CreateCanvas(int canvasWidth, int canvasHeight) { - return Interop.PenWave.CreateCanvas(canvasWidth, canvasHeight); + return Interop.PenWaveRenderer.CreateCanvas(canvasWidth, canvasHeight); } /// @@ -599,7 +639,7 @@ public uint CreateCanvas(int canvasWidth, int canvasHeight) [EditorBrowsable(EditorBrowsableState.Never)] public uint CreateCanvasWithBackgroundImage(string path) { - return Interop.PenWave.CreateCanvasWithBackgroundImage(path); + return Interop.PenWaveRenderer.CreateCanvasWithBackgroundImage(path); } /// @@ -609,7 +649,7 @@ public uint CreateCanvasWithBackgroundImage(string path) [EditorBrowsable(EditorBrowsableState.Never)] public void SetCurrentCanvas(uint canvasID) { - Interop.PenWave.SetCurrentCanvas(canvasID); + Interop.PenWaveRenderer.SetCurrentCanvas(canvasID); } /// @@ -618,7 +658,7 @@ public void SetCurrentCanvas(uint canvasID) [EditorBrowsable(EditorBrowsableState.Never)] public void ClearCurrentCanvas() { - Interop.PenWave.ClearCurrentCanvas(); + Interop.PenWaveRenderer.ClearCurrentCanvas(); } /// @@ -629,7 +669,7 @@ public void ClearCurrentCanvas() [EditorBrowsable(EditorBrowsableState.Never)] public void StartSelectingArea(float x, float y) { - Interop.PenWave.StartSelectingArea(x, y); + Interop.PenWaveRenderer.StartSelectingArea(x, y); } /// @@ -640,7 +680,7 @@ public void StartSelectingArea(float x, float y) [EditorBrowsable(EditorBrowsableState.Never)] public void ResizeSelectedArea(float x, float y) { - Interop.PenWave.ResizeSelectedArea(x, y); + Interop.PenWaveRenderer.ResizeSelectedArea(x, y); } /// @@ -652,7 +692,7 @@ public void ResizeSelectedArea(float x, float y) [EditorBrowsable(EditorBrowsableState.Never)] public bool InsideSelectedArea(float x, float y) { - return Interop.PenWave.InsideSelectedArea(x, y); + return Interop.PenWaveRenderer.InsideSelectedArea(x, y); } /// @@ -666,7 +706,7 @@ public bool InsideSelectedArea(float x, float 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); + return Interop.PenWaveRenderer.GetSelectionDimensions(ref x, ref y, ref width, ref height); } /// @@ -678,7 +718,7 @@ public bool GetSelectionDimensions(ref float x, ref float y, ref float width, re [EditorBrowsable(EditorBrowsableState.Never)] public int TouchedDrawable(float x, float y) { - return Interop.PenWave.TouchedDrawable(x, y); + return Interop.PenWaveRenderer.TouchedDrawable(x, y); } /// @@ -690,7 +730,7 @@ public int TouchedDrawable(float x, float y) [EditorBrowsable(EditorBrowsableState.Never)] public int SelectDrawable(float x, float y) { - return Interop.PenWave.SelectDrawable(x, y); + return Interop.PenWaveRenderer.SelectDrawable(x, y); } /// @@ -700,7 +740,7 @@ public int SelectDrawable(float x, float y) [EditorBrowsable(EditorBrowsableState.Never)] public int SelectDrawables() { - return Interop.PenWave.SelectDrawables(); + return Interop.PenWaveRenderer.SelectDrawables(); } /// @@ -711,7 +751,7 @@ public int SelectDrawables() [EditorBrowsable(EditorBrowsableState.Never)] public void DragSelectedDrawables(float x, float y) { - Interop.PenWave.DragSelectedDrawables(x, y); + Interop.PenWaveRenderer.DragSelectedDrawables(x, y); } /// @@ -720,7 +760,7 @@ public void DragSelectedDrawables(float x, float y) [EditorBrowsable(EditorBrowsableState.Never)] public void EndDraging() { - Interop.PenWave.EndDraging(); + Interop.PenWaveRenderer.EndDraging(); } /// @@ -732,7 +772,7 @@ public void EndDraging() [EditorBrowsable(EditorBrowsableState.Never)] public bool StartRotating(float x, float y) { - return Interop.PenWave.StartRotating(x, y); + return Interop.PenWaveRenderer.StartRotating(x, y); } /// @@ -744,7 +784,7 @@ public bool StartRotating(float x, float y) [EditorBrowsable(EditorBrowsableState.Never)] public bool RotateSelected(float x, float y) { - return Interop.PenWave.RotateSelected(x, y); + return Interop.PenWaveRenderer.RotateSelected(x, y); } /// @@ -756,7 +796,7 @@ public bool RotateSelected(float x, float y) [EditorBrowsable(EditorBrowsableState.Never)] public bool EndRotating(float x, float y) { - return Interop.PenWave.EndRotating(x, y); + return Interop.PenWaveRenderer.EndRotating(x, y); } /// @@ -772,7 +812,7 @@ public bool EndRotating(float x, float 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); + Interop.PenWaveRenderer.StartSelectionScale(anchorLeft, anchorRight, anchorTop, anchorBottom, ref anchorX, ref anchorY); } /// @@ -783,7 +823,7 @@ public void StartSelectionScale(bool anchorLeft, bool anchorRight, bool anchorTo [EditorBrowsable(EditorBrowsableState.Never)] public void ScaleSelection(float scaleFactorX, float scaleFactorY) { - Interop.PenWave.ScaleSelection(scaleFactorX, scaleFactorY); + Interop.PenWaveRenderer.ScaleSelection(scaleFactorX, scaleFactorY); } /// @@ -794,7 +834,7 @@ public void ScaleSelection(float scaleFactorX, float scaleFactorY) [EditorBrowsable(EditorBrowsableState.Never)] public void EndSelectionScale(float scaleFactorX, float scaleFactorY) { - Interop.PenWave.EndSelectionScale(scaleFactorX, scaleFactorY); + Interop.PenWaveRenderer.EndSelectionScale(scaleFactorX, scaleFactorY); } /// @@ -803,7 +843,7 @@ public void EndSelectionScale(float scaleFactorX, float scaleFactorY) [EditorBrowsable(EditorBrowsableState.Never)] public void DropSelectedDrawables() { - Interop.PenWave.DropSelectedDrawables(); + Interop.PenWaveRenderer.DropSelectedDrawables(); } /// @@ -815,7 +855,7 @@ public void DropSelectedDrawables() [EditorBrowsable(EditorBrowsableState.Never)] public void SelectedAreaZoom(float x, float y, float zoom) { - Interop.PenWave.SelectedAreaZoom(x, y, zoom); + Interop.PenWaveRenderer.SelectedAreaZoom(x, y, zoom); } /// @@ -827,7 +867,7 @@ public void SelectedAreaZoom(float x, float y, float zoom) [EditorBrowsable(EditorBrowsableState.Never)] public bool SaveCanvas(uint canvasID, string path) { - return Interop.PenWave.SaveCanvas(canvasID, path); + return Interop.PenWaveRenderer.SaveCanvas(canvasID, path); } /// @@ -839,7 +879,12 @@ public bool SaveCanvas(uint canvasID, string path) [EditorBrowsable(EditorBrowsableState.Never)] public bool LoadCanvas(uint canvasID, string path) { - return Interop.PenWave.LoadCanvas(canvasID, path); + if (!File.Exists(path)) + { + Tizen.Log.Error("NUI", $"Loading canvas error. canvasID :{canvasID} path : {path}\n"); + return false; + } + return Interop.PenWaveRenderer.LoadCanvas(canvasID, path); } /// @@ -853,19 +898,19 @@ public bool LoadCanvas(uint canvasID, string path) /// Height /// save callback function [EditorBrowsable(EditorBrowsableState.Never)] - public void TakeScreenshot(uint canvasID, string path, int x, int y, int width, int height, ScreenShotCallback thumbSaved) + public void TakeScreenShot(uint canvasID, string path, int x, int y, int width, int height, ScreenShotCallback thumbSaved) { - Interop.PenWave.TakeScreenshot(canvasID, path, x, y, width, height, thumbSaved); + Interop.PenWaveRenderer.TakeScreenShot(canvasID, path, x, y, width, height, thumbSaved); } /// /// ToggleGrid /// - /// The density type + /// The density type [EditorBrowsable(EditorBrowsableState.Never)] - public void ToggleGrid(int densityType) + public void ToggleGrid(GridDensityType gridType) { - Interop.PenWave.ToggleGrid(densityType); + Interop.PenWaveRenderer.ToggleGrid((int)gridType); } /// @@ -875,7 +920,7 @@ public void ToggleGrid(int densityType) [EditorBrowsable(EditorBrowsableState.Never)] public void ToggleChartGrid(int densityType) { - Interop.PenWave.ToggleChartGrid(densityType); + Interop.PenWaveRenderer.ToggleChartGrid(densityType); } /// @@ -885,7 +930,7 @@ public void ToggleChartGrid(int densityType) [EditorBrowsable(EditorBrowsableState.Never)] public int GetChartGridDensity() { - return Interop.PenWave.GetChartGridDensity(); + return Interop.PenWaveRenderer.GetChartGridDensity(); } /// @@ -893,9 +938,9 @@ public int GetChartGridDensity() /// /// Returns true if successful. otherwise false [EditorBrowsable(EditorBrowsableState.Never)] - public bool Copy() + public bool CopySelectedDrawables() { - return Interop.PenWave.Copy(); + return Interop.PenWaveRenderer.Copy(); } /// @@ -905,9 +950,9 @@ public bool Copy() /// Point Y coordinate /// Returns true if successful. otherwise false [EditorBrowsable(EditorBrowsableState.Never)] - public int Paste(float x, float y) + public int PasteDrawables(float x, float y) { - return Interop.PenWave.Paste(x, y); + return Interop.PenWaveRenderer.Paste(x, y); } /// @@ -915,9 +960,9 @@ public int Paste(float x, float y) /// /// Returns true if successful. otherwise false [EditorBrowsable(EditorBrowsableState.Never)] - public bool Cut() + public bool CutSelectedDrawables() { - return Interop.PenWave.Cut(); + return Interop.PenWaveRenderer.Cut(); } /// @@ -927,7 +972,7 @@ public bool Cut() [EditorBrowsable(EditorBrowsableState.Never)] public bool Remove() { - return Interop.PenWave.Remove(); + return Interop.PenWaveRenderer.Remove(); } /// @@ -938,7 +983,7 @@ public bool Remove() [EditorBrowsable(EditorBrowsableState.Never)] public void AddChart(int chartType, string path) { - Interop.PenWave.AddChart(chartType, path); + Interop.PenWaveRenderer.AddChart(chartType, path); } /// @@ -948,7 +993,7 @@ public void AddChart(int chartType, string path) [EditorBrowsable(EditorBrowsableState.Never)] public void ChangeMode(int mode) { - Interop.PenWave.ChangeMode(mode); + Interop.PenWaveRenderer.ChangeMode(mode); } /// @@ -959,7 +1004,7 @@ public void ChangeMode(int mode) [EditorBrowsable(EditorBrowsableState.Never)] public void ChartPosition(ref float x, ref float y) { - Interop.PenWave.ChartPosition(ref x, ref y); + Interop.PenWaveRenderer.ChartPosition(ref x, ref y); } /// @@ -973,7 +1018,8 @@ public void ChartPosition(ref float x, ref float 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); + Interop.PenWaveRenderer.AddPicture(path, x, y, width, height); + RenderFullyReDraw(); } /// @@ -986,9 +1032,9 @@ public void AddPicture(string path, float x, float y, float width, float height) /// Width /// Height [EditorBrowsable(EditorBrowsableState.Never)] - public void SetCanvasBackground(string path, float x, float y, float width, float height) + public void SetCanvasBackgroundImage(string path, float x, float y, float width, float height) { - Interop.PenWave.SetCanvasBackground(path, x, y, width, height); + Interop.PenWaveRenderer.SetCanvasBackground(path, x, y, width, height); } /// @@ -1001,7 +1047,7 @@ public void SetCanvasBackground(string path, float x, float y, float width, floa [EditorBrowsable(EditorBrowsableState.Never)] public void AddText(string text, float x, float y, float size) { - Interop.PenWave.AddText(text, x, y, size); + Interop.PenWaveRenderer.AddText(text, x, y, size); } /// @@ -1015,7 +1061,7 @@ public void AddText(string text, float x, float y, float size) [EditorBrowsable(EditorBrowsableState.Never)] public uint AddNote(float x, float y, float width, float height) { - return Interop.PenWave.AddNote(x, y, width, height); + return Interop.PenWaveRenderer.AddNote(x, y, width, height); } /// @@ -1025,7 +1071,7 @@ public uint AddNote(float x, float y, float width, float height) [EditorBrowsable(EditorBrowsableState.Never)] public void RemoveNote(uint noteID) { - Interop.PenWave.RemoveNote(noteID); + Interop.PenWaveRenderer.RemoveNote(noteID); } /// @@ -1034,7 +1080,7 @@ public void RemoveNote(uint noteID) [EditorBrowsable(EditorBrowsableState.Never)] public void ClearNote() { - Interop.PenWave.ClearNote(); + Interop.PenWaveRenderer.ClearNote(); } /// @@ -1046,7 +1092,7 @@ public void ClearNote() [EditorBrowsable(EditorBrowsableState.Never)] public bool DragNote(float x, float y) { - return Interop.PenWave.DragNote(x, y); + return Interop.PenWaveRenderer.DragNote(x, y); } /// @@ -1056,7 +1102,7 @@ public bool DragNote(float x, float y) [EditorBrowsable(EditorBrowsableState.Never)] public bool EndNoteDragging() { - return Interop.PenWave.EndNoteDragging(); + return Interop.PenWaveRenderer.EndNoteDragging(); } /// @@ -1067,7 +1113,7 @@ public bool EndNoteDragging() [EditorBrowsable(EditorBrowsableState.Never)] public void SetNoteColor(string hexColor, float a) { - Interop.PenWave.SetNoteColor(hexColor, a); + Interop.PenWaveRenderer.SetNoteColor(hexColor, a); } /// @@ -1077,7 +1123,7 @@ public void SetNoteColor(string hexColor, float a) [EditorBrowsable(EditorBrowsableState.Never)] public void SetActiveNote(uint noteID) { - Interop.PenWave.SetActiveNote(noteID); + Interop.PenWaveRenderer.SetActiveNote(noteID); } /// @@ -1087,7 +1133,7 @@ public void SetActiveNote(uint noteID) [EditorBrowsable(EditorBrowsableState.Never)] public bool Undo() { - return Interop.PenWave.Undo(); + return Interop.PenWaveRenderer.Undo(); } /// @@ -1097,7 +1143,7 @@ public bool Undo() [EditorBrowsable(EditorBrowsableState.Never)] public bool Redo() { - return Interop.PenWave.Redo(); + return Interop.PenWaveRenderer.Redo(); } /// @@ -1107,7 +1153,7 @@ public bool Redo() [EditorBrowsable(EditorBrowsableState.Never)] public bool CanUndo() { - return Interop.PenWave.CanUndo(); + return Interop.PenWaveRenderer.CanUndo(); } /// @@ -1117,7 +1163,7 @@ public bool CanUndo() [EditorBrowsable(EditorBrowsableState.Never)] public bool CanRedo() { - return Interop.PenWave.CanRedo(); + return Interop.PenWaveRenderer.CanRedo(); } /// @@ -1126,7 +1172,7 @@ public bool CanRedo() [EditorBrowsable(EditorBrowsableState.Never)] public void ResetUndo() { - Interop.PenWave.ResetUndo(); + Interop.PenWaveRenderer.ResetUndo(); } /// @@ -1135,7 +1181,16 @@ public void ResetUndo() [EditorBrowsable(EditorBrowsableState.Never)] public void ResetRedo() { - Interop.PenWave.ResetRedo(); + Interop.PenWaveRenderer.ResetRedo(); + } + + // Converts Color to hex string. + private string ToHex(Color color) + { + var red = (uint)(color.R * 255); + var green = (uint)(color.G * 255); + var blue = (uint)(color.B * 255); + return $"#{red:X2}{green:X2}{blue:X2}"; } } } diff --git a/src/Tizen.NUI.PenWave/src/public/Common/PenWaveConstants.cs b/src/Tizen.NUI.PenWave/src/public/Common/PenWaveConstants.cs index ea1bd2cd0de..31ec33b5010 100644 --- a/src/Tizen.NUI.PenWave/src/public/Common/PenWaveConstants.cs +++ b/src/Tizen.NUI.PenWave/src/public/Common/PenWaveConstants.cs @@ -91,27 +91,53 @@ public enum EraserType } /// - /// Enumeration for the type of selection operation + /// Enumeration for the type of selection transform /// [EditorBrowsable(EditorBrowsableState.Never)] - public enum SelectionType + public enum SelectionTransformType { /// - /// The move selection type. + /// The move type. /// Move = 0, /// - /// The scale selection type. + /// The scale type. /// Scale, /// - /// The rotate selection type. + /// The rotate type. /// Rotate, } + /// + /// Enumeration for the type of selection operation + /// + public enum SelectionOperationType + { + /// + /// The none operation type. + /// + None, + + /// + /// The copy operation type. + /// + Copy, + + /// + /// The cut operation type. + /// + Cut, + + /// + /// The paste operation type. + /// + Paste, + } + /// /// Enumeration for the grid density type. /// diff --git a/src/Tizen.NUI.PenWave/src/public/Picker/PenWaveToolPicker.cs b/src/Tizen.NUI.PenWave/src/public/Picker/PenWaveToolPicker.cs index 4365dd658ea..a2eb3a07c33 100644 --- a/src/Tizen.NUI.PenWave/src/public/Picker/PenWaveToolPicker.cs +++ b/src/Tizen.NUI.PenWave/src/public/Picker/PenWaveToolPicker.cs @@ -298,7 +298,7 @@ private void InitializeTools() var eraserTool = new EraserTool(EraserType.Partial, 48.0f); AddTool(eraserTool, "icon_eraser.png"); - var selectionTool = new SelectionTool(SelectionType.Move); + var selectionTool = new SelectionTool(SelectionTransformType.Move); AddTool(selectionTool, "icon_select.png"); var rulerTool = new RulerTool(RulerType.Line); @@ -367,6 +367,7 @@ private void ShowEraserToolSettings(EraserTool eraserTool) private void ShowSelectionToolSettings(SelectionTool selectionTool) { AddSelectionTypePicker(selectionTool); + AddCopyPastePicker(selectionTool); } private void ShowRulerToolSettings(RulerTool rulerTool) @@ -401,6 +402,7 @@ private void AddBrushPicker(PencilTool pencilTool) _popupView.Add(brushPicker); } + private ImageView _currentColorBorderButton; // Create a button for the given color and add it to the popup view. private void AddColorPicker(PencilTool pencilTool) { @@ -423,6 +425,11 @@ private void AddColorPicker(PencilTool pencilTool) Color = color, ResourceUrl = s_resourcePath + "/color_icon_base.png", }; + var buttonBorder = new ImageView + { + Size2D = new Size2D(48, 48), + }; + button.Add(buttonBorder); button.TouchEvent += (s, e) => { if (e.Touch.GetState(0) == PointStateType.Down) @@ -432,6 +439,19 @@ private void AddColorPicker(PencilTool pencilTool) } return true; }; + buttonBorder.TouchEvent += (s, e) => + { + if (e.Touch.GetState(0) == PointStateType.Down) + { + if (_currentColorBorderButton) + { + _currentColorBorderButton.ResourceUrl = ""; + } + buttonBorder.ResourceUrl = s_resourcePath + "/color_icon_selected.png"; + _currentColorBorderButton = buttonBorder;; + } + return false; + }; colorPicker.Add(button); } @@ -517,12 +537,12 @@ private void AddSelectionTypePicker(SelectionTool selectionTool) } }; - var types = Enum.GetValues(typeof(SelectionType)); - foreach (SelectionType type in types) + var types = Enum.GetValues(typeof(SelectionTransformType)); + foreach (SelectionTransformType type in types) { var button = CreateToolButton(s_resourcePath + $"icon_{type.ToString().ToLower()}.png", () => { - selectionTool.Selection = type; + selectionTool.Transform = type; }); picker.Add(button); } @@ -530,6 +550,33 @@ private void AddSelectionTypePicker(SelectionTool selectionTool) _popupView.Add(picker); } + private void AddCopyPastePicker(SelectionTool selectionTool) + { + var picker = new View + { + Layout = new LinearLayout + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + CellPadding = new Size2D(5, 5), + } + }; + + var types = Enum.GetValues(typeof(SelectionOperationType)); + foreach (SelectionOperationType type in types) + { + if (type != SelectionOperationType.None) + { + var button = CreateToolButton(s_resourcePath + $"icon_{type.ToString().ToLower()}.png", () => + { + selectionTool.DoOperation(type); + }); + button.Color = new Color(_iconStateDisabledColor); + picker.Add(button); + } + } + _popupView.Add(picker); + } + // Create a button for the given ruler type and add it to the popup view. The button toggles between line, rectangle, and circular ruler modes. private void AddRulerTypePicker(RulerTool rulerTool) { @@ -649,6 +696,30 @@ private void UpdateUI() _redoButton.Color = _canvasView.CanRedo ? new Color(_iconStateNormalColor) : new Color(_iconStateDisabledColor); } + // TODO + // if (_canvasView.CurrentTool is SelectionTool selectionTool) + // { + // if (selectionTool.CanCopyPaste) + // { + // foreach (var child in _popupView.Children) + // { + // if (child is ImageView imageView && (imageView.ResourceUrl.Contains("icon_copy") || imageView.ResourceUrl.Contains("icon_paste"))) + // { + // imageView.Color = new Color(_iconStateNormalColor); + // } + // } + // } + // else + // { + // foreach (var child in _popupView.Children) + // { + // if (child is ImageView imageView && (imageView.ResourceUrl.Contains("icon_copy") || imageView.ResourceUrl.Contains("icon_paste"))) + // { + // imageView.Color = new Color(_iconStateDisabledColor); + // } + // } + // } + // } } /// 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 3cc52942580..d5010440fe1 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserTool.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserTool.cs @@ -108,14 +108,14 @@ public override bool HandleInput(Touch touch) private void StartDrawing(float positionX, float positionY, uint touchTime) { _isActive = true; - PenWave.Instance.EraseShape((int)positionX, (int)positionY, EraserRadius, (Eraser == EraserType.Partial)); + PenWaveRenderer.Instance.EraseShape((int)positionX, (int)positionY, EraserRadius, (Eraser == EraserType.Partial)); NotifyActionStarted(); } // Continue drawing at the given position. private void ContinueDrawing(float positionX, float positionY, uint touchTime) { - PenWave.Instance.EraseShape((int)positionX, (int)positionY, EraserRadius, (Eraser == EraserType.Partial)); + PenWaveRenderer.Instance.EraseShape((int)positionX, (int)positionY, EraserRadius, (Eraser == EraserType.Partial)); } // End drawing at the given position. @@ -123,7 +123,7 @@ private void EndDrawing() { if (_isActive) { - PenWave.Instance.StopErasing(); + PenWaveRenderer.Instance.StopErasing(); NotifyActionFinished(); _isActive = false; } 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 bb6b57bd144..99b96014e99 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 @@ -31,8 +31,8 @@ public class DashedLineBrush : IBrushStrategy [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PenWave.Instance.SetStrokeType(5); - PenWave.Instance.SetDashArray("1 3"); + PenWaveRenderer.Instance.SetStrokeType(5); + PenWaveRenderer.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 db52f1b213a..58b89674b88 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 @@ -31,9 +31,9 @@ public class DotBrush : IBrushStrategy [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PenWave.Instance.SetStrokeType(1); - PenWave.Instance.SetBrushTexture(1); - PenWave.Instance.SetBrushDistance(2.0f); + PenWaveRenderer.Instance.SetStrokeType(1); + PenWaveRenderer.Instance.SetBrushTexture(1); + PenWaveRenderer.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 6091b5cc0de..32356b6ddeb 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 @@ -31,9 +31,9 @@ public class HighlighterBrush : IBrushStrategy [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PenWave.Instance.SetStrokeType(1); - PenWave.Instance.SetBrushTexture(3); - PenWave.Instance.SetBrushDistance(0.25f); + PenWaveRenderer.Instance.SetStrokeType(1); + PenWaveRenderer.Instance.SetBrushTexture(3); + PenWaveRenderer.Instance.SetBrushDistance(0.25f); } } } 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 5b0d9c5c503..8fb77f4150d 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 @@ -31,7 +31,7 @@ public class SharpBrush : IBrushStrategy [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PenWave.Instance.SetStrokeType(8); + PenWaveRenderer.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 ab97ba3ac76..7d09dd33fcb 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 @@ -31,9 +31,9 @@ public class SoftBrush : IBrushStrategy [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PenWave.Instance.SetStrokeType(1); - PenWave.Instance.SetBrushTexture(4); - PenWave.Instance.SetBrushDistance(1.0f); + PenWaveRenderer.Instance.SetStrokeType(1); + PenWaveRenderer.Instance.SetBrushTexture(4); + PenWaveRenderer.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 62bafc25763..95c09c774da 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 @@ -31,9 +31,9 @@ public class SprayBrush : IBrushStrategy [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PenWave.Instance.SetStrokeType(1); - PenWave.Instance.SetBrushTexture(0); - PenWave.Instance.SetBrushDistance(3.0f); + PenWaveRenderer.Instance.SetStrokeType(1); + PenWaveRenderer.Instance.SetBrushTexture(0); + PenWaveRenderer.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 030eed9a878..6a8cd083591 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 @@ -31,7 +31,7 @@ public class StrokeBrush : IBrushStrategy [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PenWave.Instance.SetStrokeType(0); + PenWaveRenderer.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 e13abf7541a..ea10b9c3a38 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 @@ -31,7 +31,7 @@ public class VarStrokeBrush : IBrushStrategy [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PenWave.Instance.SetStrokeType(6); + PenWaveRenderer.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 08d5eac9678..2c54b8e0b53 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 @@ -31,7 +31,7 @@ public class VarStrokeIncBrush : IBrushStrategy [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyBrushSettings() { - PenWave.Instance.SetStrokeType(7); + PenWaveRenderer.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 60494674b23..ea038435650 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PencilTool.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PencilTool.cs @@ -84,8 +84,8 @@ private void SetBrushType(BrushType brushType) public override void Activate() { SetBrushType(Brush); - PenWave.Instance.SetStrokeColor(ToHex(BrushColor), 1.0f); - PenWave.Instance.SetStrokeSize(BrushSize); + PenWaveRenderer.Instance.SetStrokeColor(ToHex(BrushColor), 1.0f); + PenWaveRenderer.Instance.SetStrokeSize(BrushSize); } /// @@ -136,7 +136,7 @@ public override bool HandleInput(Touch touch) // Starts drawing a new shape. This will create a new shape on the canvas. private void StartDrawing(float positionX, float positionY, uint touchTime) { - _currentShapeId = PenWave.Instance.BeginShapeDraw(positionX, positionY, touchTime); + _currentShapeId = PenWaveRenderer.Instance.BeginShapeDraw(positionX, positionY, touchTime); if (_currentShapeId > 0) { NotifyActionStarted(); @@ -148,7 +148,7 @@ private void ContinueDrawing(float positionX, float positionY, uint touchTime) { if (_currentShapeId > 0) { - var result = PenWave.Instance.DrawShape(_currentShapeId, positionX, positionY, touchTime); + var result = PenWaveRenderer.Instance.DrawShape(_currentShapeId, positionX, positionY, touchTime); if (result == ErrorShapeAddPointsType.OverflowShape) { EndDrawing(); @@ -166,7 +166,7 @@ private void EndDrawing() { if (_currentShapeId > 0) { - PenWave.Instance.EndShapeDraw(_currentShapeId, 0); + PenWaveRenderer.Instance.EndShapeDraw(_currentShapeId, 0); _currentShapeId = 0; NotifyActionFinished(); } diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Ruler/RulerTool.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Ruler/RulerTool.cs index 10bfca5301a..1c4a0f46efe 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Ruler/RulerTool.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Ruler/RulerTool.cs @@ -107,7 +107,7 @@ private void StartDrawing(float positionX, float positionY, uint touchTime) if (Ruler == RulerType.Line) { - _currentShapeId = PenWave.Instance.BeginLineDraw(positionX, positionY, touchTime); + _currentShapeId = PenWaveRenderer.Instance.BeginLineDraw(positionX, positionY, touchTime); _isDrawingCircular = false; } else if (Ruler == RulerType.Circle) @@ -121,13 +121,13 @@ private void StartDrawing(float positionX, float positionY, uint touchTime) else { double rad = Math.Sqrt(((_dragStartX - positionX) * (_dragStartX - positionX)) + ((_dragStartY - positionY) * (_dragStartY - positionY))); - _currentShapeId = PenWave.Instance.AddArcPath(_dragStartX, _dragStartY,(float) rad, positionX, positionY, false ); + _currentShapeId = PenWaveRenderer.Instance.AddArcPath(_dragStartX, _dragStartY,(float) rad, positionX, positionY, false ); _isDrawingCircular = false; } } else if (Ruler == RulerType.Rectangle) { - _currentShapeId = PenWave.Instance.AddRectanglePath(positionX, positionY, 400.0f, 400.0f, false); + _currentShapeId = PenWaveRenderer.Instance.AddRectanglePath(positionX, positionY, 400.0f, 400.0f, false); _isDrawingCircular = false; } @@ -144,14 +144,14 @@ private void ContinueDrawing(float positionX, float positionY, uint touchTime) { if (Ruler == RulerType.Line) { - PenWave.Instance.DrawLine(_currentShapeId, positionX, positionY, touchTime); + PenWaveRenderer.Instance.DrawLine(_currentShapeId, positionX, positionY, touchTime); } else { - var res = PenWave.Instance.ResizeShapePath(_currentShapeId, positionX, positionY); + var res = PenWaveRenderer.Instance.ResizeShapePath(_currentShapeId, positionX, positionY); if (res == ErrorShapeAddPointsType.DrawingCanceled) { - PenWave.Instance.FinishShapePath(_currentShapeId); + PenWaveRenderer.Instance.FinishShapePath(_currentShapeId); } } } @@ -163,11 +163,11 @@ private void EndDrawing() { if (Ruler == RulerType.Line) { - PenWave.Instance.EndLineDraw(_currentShapeId, 0); + PenWaveRenderer.Instance.EndLineDraw(_currentShapeId, 0); } else { - PenWave.Instance.FinishShapePath(_currentShapeId); + PenWaveRenderer.Instance.FinishShapePath(_currentShapeId); } _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 c296b6adfc9..1aa36aea9b7 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Selection/SelectionTool.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Selection/SelectionTool.cs @@ -73,16 +73,48 @@ private enum Mode /// /// [EditorBrowsable(EditorBrowsableState.Never)] - public SelectionTool(SelectionType selectionType) + public SelectionTool(SelectionTransformType selectionType) { - Selection = selectionType; + Transform = selectionType; } /// /// The type of selection operation. Default is move. /// [EditorBrowsable(EditorBrowsableState.Never)] - public SelectionType Selection { get; set; } + public SelectionTransformType Transform { get; set; } = SelectionTransformType.Move; + + /// + /// The type of selection operation. Default is none. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public SelectionOperationType Operation { get; set; } = SelectionOperationType.None; + + /// + /// Indicates whether the selected drawables can be copied or pasted. This will be true if there is exactly one drawable selected. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool CanCopyPaste => _drawableType != DrawableType.None; + + /// + /// Perform the specified operation on the selected drawables. + /// + /// The operation to perform. + public void DoOperation(SelectionOperationType operation) + { + Operation = operation; + switch (operation) + { + case SelectionOperationType.Copy: + PenWaveRenderer.Instance.CopySelectedDrawables(); + break; + case SelectionOperationType.Cut: + PenWaveRenderer.Instance.CutSelectedDrawables(); + break; + default: + break; + } + } /// @@ -142,27 +174,34 @@ public override bool HandleInput(Touch touch) // Start drawing the selection area or interacting with the selected drawables. private void StartDrawing(float positionX, float positionY, uint touchTime) { + if (Operation == SelectionOperationType.Paste) + { + PenWaveRenderer.Instance.PasteDrawables(positionX, positionY); + Operation = SelectionOperationType.None; + return; + } + _initialTouchX = positionX; _initialTouchY = positionY; - _isTouchedInsideSelectedArea = PenWave.Instance.InsideSelectedArea(positionX, positionY); + _isTouchedInsideSelectedArea = PenWaveRenderer.Instance.InsideSelectedArea(positionX, positionY); if (!_isTouchedInsideSelectedArea) { - PenWave.Instance.DropSelectedDrawables(); - _drawableType = (DrawableType)PenWave.Instance.SelectDrawable(positionX, positionY); + PenWaveRenderer.Instance.DropSelectedDrawables(); + _drawableType = (DrawableType)PenWaveRenderer.Instance.SelectDrawable(positionX, positionY); } else { - if (Selection == SelectionType.Rotate) + if (Transform == SelectionTransformType.Rotate) { - PenWave.Instance.StartRotating(positionX, positionY); + PenWaveRenderer.Instance.StartRotating(positionX, positionY); } - else if (Selection == SelectionType.Scale) + else if (Transform == SelectionTransformType.Scale) { float topLeftX = 0, topLeftY = 0, widthSelection = 0, heightSelection = 0; - PenWave.Instance.GetSelectionDimensions(ref topLeftX, ref topLeftY, ref widthSelection, ref heightSelection); + PenWaveRenderer.Instance.GetSelectionDimensions(ref topLeftX, ref topLeftY, ref widthSelection, ref heightSelection); if (!Double.IsNaN(topLeftX)) { - PenWave.Instance.StartSelectionScale( + PenWaveRenderer.Instance.StartSelectionScale( _initialTouchX >= topLeftX + widthSelection * 0.5f, _initialTouchX < topLeftX + widthSelection * 0.5f, _initialTouchY >= topLeftY + heightSelection * 0.5f, @@ -187,26 +226,26 @@ private void ContinueDrawing(float positionX, float positionY, uint touchTime) { if (_currentMode == Mode.None) { - PenWave.Instance.StartSelectingArea(positionX, positionY); + PenWaveRenderer.Instance.StartSelectingArea(positionX, positionY); } - PenWave.Instance.ResizeSelectedArea(positionX, positionY); + PenWaveRenderer.Instance.ResizeSelectedArea(positionX, positionY); _currentMode = Mode.Resize; } else if (_currentMode != Mode.Resize && _drawableType != DrawableType.None) { - if (Selection == SelectionType.Move) + if (Transform == SelectionTransformType.Move) { - PenWave.Instance.DragSelectedDrawables(positionX, positionY); + PenWaveRenderer.Instance.DragSelectedDrawables(positionX, positionY); _currentMode = Mode.Move; } - else if (Selection == SelectionType.Rotate) + else if (Transform == SelectionTransformType.Rotate) { - PenWave.Instance.RotateSelected(positionX, positionY); + PenWaveRenderer.Instance.RotateSelected(positionX, positionY); _currentMode = Mode.Rotate; } - else if (Selection == SelectionType.Scale) + else if (Transform == SelectionTransformType.Scale) { - PenWave.Instance.ScaleSelection( + PenWaveRenderer.Instance.ScaleSelection( (positionX - _anchorX) / (_startScaleX - _anchorX), (positionY - _anchorY) / (_startScaleY - _anchorY)); _currentMode = Mode.Scale; @@ -220,22 +259,22 @@ private void EndDrawing(float positionX, float positionY, uint touchTime) switch (_currentMode) { case Mode.Move : - PenWave.Instance.EndDraging(); + PenWaveRenderer.Instance.EndDraging(); break; case Mode.Resize : - _drawableType = (DrawableType)PenWave.Instance.SelectDrawables(); + _drawableType = (DrawableType)PenWaveRenderer.Instance.SelectDrawables(); break; case Mode.Rotate : - PenWave.Instance.EndRotating(positionX, positionY); + PenWaveRenderer.Instance.EndRotating(positionX, positionY); break; case Mode.Scale : - PenWave.Instance.EndRotating(positionX, positionY); - PenWave.Instance.EndSelectionScale( + PenWaveRenderer.Instance.EndRotating(positionX, positionY); + PenWaveRenderer.Instance.EndSelectionScale( (positionX - _anchorX) / (_startScaleX - _anchorX), (positionY - _anchorY) / (_startScaleY - _anchorY)); break; default : - PenWave.Instance.DropSelectedDrawables(); + PenWaveRenderer.Instance.DropSelectedDrawables(); break; } _isTouchedInsideSelectedArea = false; diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/UnRedoManager.cs b/src/Tizen.NUI.PenWave/src/public/Tools/UnRedoManager.cs index c9a2311645b..0fbe01fc1d5 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/UnRedoManager.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/UnRedoManager.cs @@ -50,7 +50,7 @@ internal void Undo() if (_undoStack > 0) { _undoStack--; // Pop command from undo stack - PenWave.Instance.Undo(); + PenWaveRenderer.Instance.Undo(); _redoStack++; // Push command to redo stack } } @@ -64,7 +64,7 @@ internal void Redo() if (_redoStack > 0) { _redoStack--; // Pop command from redo stack - PenWave.Instance.Redo(); + PenWaveRenderer.Instance.Redo(); _undoStack++; // Push command to undo stack } } diff --git a/test/Tizen.NUI.PenWave.Sample/src/PenWaveSample.cs b/test/Tizen.NUI.PenWave.Sample/src/PenWaveSample.cs index 4a35bd79123..af93b6efb0c 100644 --- a/test/Tizen.NUI.PenWave.Sample/src/PenWaveSample.cs +++ b/test/Tizen.NUI.PenWave.Sample/src/PenWaveSample.cs @@ -13,11 +13,11 @@ namespace PenWaveSample { class Program : NUIApplication { - public static Program app; - private Window mWindow; - private PenWaveToolPicker mToolPickerView; - private PenWaveCanvas canvasView; - private ImageView thumbnailView; + public static Program App; + private Window _window; + private PenWaveToolPicker _toolPickerView; + private PenWaveCanvas _canvasView; + private ImageView _thumbnailView; public class TestTool : ToolBase { @@ -54,9 +54,9 @@ protected override void OnCreate() private void ToolPicker() { - mToolPickerView = new PenWaveToolPicker(canvasView); + _toolPickerView = new PenWaveToolPicker(_canvasView); - mToolPickerView.AddButtonToPickerView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "images/icon_picture.png", () => + _toolPickerView.AddButtonToPickerView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "images/icon_picture.png", () => { var picker = new View { @@ -73,17 +73,17 @@ private void ToolPicker() }; button.Clicked += (o, e) => { - canvasView.AddPicture(Tizen.Applications.Application.Current.DirectoryInfo.Resource+"images/pictures/venus.png", 100, 200, 500, 500); + _canvasView.AddPicture(Tizen.Applications.Application.Current.DirectoryInfo.Resource+"images/pictures/venus.png", 100, 200, 500, 500); }; picker.Add(button); } - mToolPickerView.SetViewToPopupView(picker); - mToolPickerView.ShowPopupView(); + _toolPickerView.SetViewToPopupView(picker); + _toolPickerView.ShowPopupView(); }); - mToolPickerView.AddButtonToPickerView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "images/icon_picture.png", () => + _toolPickerView.AddButtonToPickerView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "images/icon_picture.png", () => { - canvasView.TakeScreenShot("/home/puro/workspace/submit/TizenFX/test/Tizen.NUI.PenWave.Sample/screenshot.png", 0, 0, 1920, 1080, OnThumbnails); + _canvasView.TakeScreenShot("/home/puro/workspace/submit/TizenFX/test/Tizen.NUI.PenWave.Sample/screenshot.png", 0, 0, 1920, 1080, OnThumbnails); }); } @@ -93,15 +93,15 @@ private void OnThumbnails(object sender, EventArgs e) string source = "/home/puro/workspace/submit/TizenFX/test/Tizen.NUI.PenWave.Sample/screenshot.png"; string destination = "/home/puro/workspace/submit/TizenFX/test/Tizen.NUI.PenWave.Sample/screenshot_copy.png"; File.Copy(source, destination, true); - thumbnailView.ResourceUrl = destination; - thumbnailView.Size2D = new Size2D(300, 300); + _thumbnailView.ResourceUrl = destination; + _thumbnailView.Size2D = new Size2D(300, 300); } private void Buttons() { - canvasView.AddPicture(Tizen.Applications.Application.Current.DirectoryInfo.Resource+"images/pictures/venus.png", 100, 100, 500, 500); - canvasView.CurrentTool = new PencilTool(BrushType.DashedLine, Color.Blue, 10); + _canvasView.AddPicture(Tizen.Applications.Application.Current.DirectoryInfo.Resource+"images/pictures/venus.png", 100, 100, 500, 500); + _canvasView.CurrentTool = new PencilTool(BrushType.DashedLine, Color.Blue, 10); var view = new View() { WidthResizePolicy = ResizePolicyType.FillToParent, @@ -111,13 +111,13 @@ private void Buttons() LinearOrientation = LinearLayout.Orientation.Vertical, }, }; - canvasView.Add(view); + _canvasView.Add(view); var button = new Button() { Text = "Eraser" }; button.Clicked += (o, e) => { - canvasView.CurrentTool = new EraserTool(EraserType.Partial, 20); + _canvasView.CurrentTool = new EraserTool(EraserType.Partial, 20); }; view.Add(button); @@ -126,7 +126,7 @@ private void Buttons() Text = "Move" }; button2.Clicked += (o, e) => { - canvasView.CurrentTool = new SelectionTool(SelectionType.Move); + _canvasView.CurrentTool = new SelectionTool(SelectionTransformType.Move); }; view.Add(button2); @@ -135,7 +135,7 @@ private void Buttons() Text = "Scale" }; button3.Clicked += (o, e) => { - canvasView.CurrentTool = new SelectionTool(SelectionType.Scale); + _canvasView.CurrentTool = new SelectionTool(SelectionTransformType.Scale); }; view.Add(button3); @@ -149,19 +149,19 @@ private void Buttons() Text = "Redo" }; - Undo.IsEnabled = canvasView.CanUndo; + Undo.IsEnabled = _canvasView.CanUndo; Undo.Clicked += (o, e) => { - canvasView.Undo(); - Redo.IsEnabled = canvasView.CanRedo; - Undo.IsEnabled = canvasView.CanUndo; + _canvasView.Undo(); + Redo.IsEnabled = _canvasView.CanRedo; + Undo.IsEnabled = _canvasView.CanUndo; }; view.Add(Undo); - Redo.IsEnabled = canvasView.CanRedo; + Redo.IsEnabled = _canvasView.CanRedo; Redo.Clicked += (o, e) => { - canvasView.Redo(); - Undo.IsEnabled = canvasView.CanUndo; - Redo.IsEnabled = canvasView.CanRedo; + _canvasView.Redo(); + Undo.IsEnabled = _canvasView.CanUndo; + Redo.IsEnabled = _canvasView.CanRedo; }; view.Add(Redo); @@ -171,7 +171,7 @@ private void Buttons() Text = "Save" }; Save.Clicked += (o, e) => { - canvasView.SaveCanvas("/home/puro/workspace/submit/TizenFX/test/Tizen.NUI.PenWave.Sample/savecanvas.txt"); + _canvasView.SaveCanvas("/home/puro/workspace/submit/TizenFX/test/Tizen.NUI.PenWave.Sample/savecanvas.txt"); }; view.Add(Save); @@ -180,7 +180,7 @@ private void Buttons() Text = "Load" }; Load.Clicked += (o, e) => { - canvasView.LoadCanvas("/home/puro/workspace/submit/TizenFX/test/Tizen.NUI.PenWave.Sample/savecanvas.txt"); + _canvasView.LoadCanvas("/home/puro/workspace/submit/TizenFX/test/Tizen.NUI.PenWave.Sample/savecanvas.txt"); }; view.Add(Load); @@ -191,27 +191,27 @@ private void Buttons() Text = "Clear" }; Clear.Clicked += (o, e) => { - canvasView.ClearCanvas(); + _canvasView.ClearCanvas(); }; view.Add(Clear); - canvasView.ToggleGrid(GridDensityType.Small); - canvasView.SetCanvasColor(Color.AquaMarine); + _canvasView.ToggleGrid(GridDensityType.Small); + _canvasView.SetCanvasColor(Color.AquaMarine); } private void InitializeView() { - mWindow = GetDefaultWindow(); - mWindow.BackgroundColor = Color.White; - canvasView = new PenWaveCanvas(); - mWindow.Add(canvasView); + _window = GetDefaultWindow(); + _window.BackgroundColor = Color.White; + _canvasView = new PenWaveCanvas(); + _window.Add(_canvasView); - canvasView.TouchEvent += OnTouchEvent; - canvasView.WheelEvent += OnWheelEvent; - thumbnailView = new ImageView(); - canvasView.Add(thumbnailView); + _canvasView.TouchEvent += OnTouchEvent; + _canvasView.WheelEvent += OnWheelEvent; + _thumbnailView = new ImageView(); + _canvasView.Add(_thumbnailView); ToolPicker(); @@ -220,18 +220,18 @@ private void InitializeView() } - private float mInitialTouchX; - private float mInitialTouchY; - private bool mIsCanvasMoving = false; + private float _initialTouchX; + private float _initialTouchY; + private bool _isCanvasMoving = false; private bool OnTouchEvent(object sender, View.TouchEventArgs args) { - canvasView.HandleInput(args.Touch); + _canvasView.HandleInput(args.Touch); return false; } private bool OnWheelEvent(object sender, View.WheelEventArgs args) { - canvasView.HandleInput(args.Wheel); + _canvasView.HandleInput(args.Wheel); return false; } @@ -241,9 +241,9 @@ static void Main(string[] args) WindowData newWindowData = new WindowData(); newWindowData.FrontBufferRendering = true; newWindowData.WindowMode = WindowMode.Opaque; - app = new Program(ThemeOptions.None, newWindowData); - app.Run(args); - app.Dispose(); + App = new Program(ThemeOptions.None, newWindowData); + App.Run(args); + App.Dispose(); } } }