From 87561436cc3945391814b1de65b1edca405ab3f7 Mon Sep 17 00:00:00 2001 From: "joogab.yun" Date: Mon, 11 Nov 2024 16:37:56 +0900 Subject: [PATCH] PenWave --- src/Tizen.NUI.PenWave/src/backup/EventBus.cs | 41 ++++ .../src/backup/PopupManager.cs | 55 +++++ .../Tools/Canvas/BackgroundColorIcon.cs | 73 ++++++ .../src/backup/Tools/Canvas/CanvasTool.cs | 102 +++++++++ .../Tools/Canvas/CanvasToolActionHandler.cs | 42 ++++ .../src/backup/Tools/Canvas/ClearIcon.cs | 51 +++++ .../src/backup/Tools/Canvas/GridIcon.cs | 59 +++++ .../src/backup/Tools/Canvas/PaletteIcon.cs | 50 +++++ .../src/backup/Tools/Canvas/RedoIcon.cs | 51 +++++ .../src/backup/Tools/Canvas/UndoIcon.cs | 51 +++++ .../src/backup/Tools/Eraser/EraserIcon.cs | 49 ++++ .../src/backup/Tools/Eraser/EraserTool.cs | 35 +++ .../Tools/Eraser/EraserToolActionHandler.cs | 93 ++++++++ .../src/backup/Tools/IToolAction.cs | 32 +++ .../src/backup/Tools/IToolActionHandler.cs | 34 +++ .../src/backup/Tools/Icon.cs | 182 +++++++++++++++ .../src/backup/Tools/IconStateManager.cs | 53 +++++ .../backup/Tools/Pencil/Brush/BrushIcon.cs | 86 +++++++ .../Pencil/Brush/BrushStrategyFactory.cs | 46 ++++ .../Tools/Pencil/Brush/DashedLineBrush.cs | 31 +++ .../backup/Tools/Pencil/Brush/DotBrush .cs | 32 +++ .../Tools/Pencil/Brush/HighlighterBrush.cs | 32 +++ .../Tools/Pencil/Brush/IBrushStrategy.cs | 30 +++ .../backup/Tools/Pencil/Brush/SharpBrush.cs | 30 +++ .../backup/Tools/Pencil/Brush/SoftBrush.cs | 32 +++ .../backup/Tools/Pencil/Brush/SprayBrush.cs | 32 +++ .../backup/Tools/Pencil/Brush/StrokeBrush.cs | 30 +++ .../Tools/Pencil/Brush/VarStrokeBrush.cs | 30 +++ .../Tools/Pencil/Brush/VarStrokeIncBrush.cs | 30 +++ .../src/backup/Tools/Pencil/ColorIcon.cs | 73 ++++++ .../src/backup/Tools/Pencil/PenInk.cs | 108 +++++++++ .../src/backup/Tools/Pencil/PencilTool.cs | 163 ++++++++++++++ .../Tools/Pencil/PencilToolActionHandler.cs | 114 ++++++++++ .../src/backup/Tools/Pencil/SizeIcon.cs | 59 +++++ .../src/backup/Tools/Select/SelectIcon.cs | 50 +++++ .../src/backup/Tools/Select/SelectTool.cs | 35 +++ .../Tools/Select/SelectToolActionHandler.cs | 137 ++++++++++++ .../src/backup/Tools/ToolBase.cs | 90 ++++++++ .../src/backup/Tools/ToolFactory.cs | 36 +++ .../src/backup/Tools/ToolManager.cs | 74 ++++++ .../src/backup/Tools/ToolPickerView.cs | 150 +++++++++++++ .../src/public/CanvasUIManager.cs | 50 ----- .../src/public/Common/PWConstants.cs | 30 ++- src/Tizen.NUI.PenWave/src/public/EventBus.cs | 41 ---- .../IToolActionHandler.cs => IToolAction.cs} | 13 +- .../src/public/PWCanvasView.cs | 42 +++- src/Tizen.NUI.PenWave/src/public/PWEngine.cs | 13 -- .../src/public/PencilToolAction.cs | 40 ++++ .../src/public/PopupManager.cs | 55 ----- .../Tools/Canvas/BackgroundColorIcon.cs | 73 ------ .../src/public/Tools/Canvas/CanvasTool.cs | 102 --------- .../src/public/Tools/Canvas/ClearIcon.cs | 51 ----- .../src/public/Tools/Canvas/GridIcon.cs | 59 ----- .../src/public/Tools/Canvas/PaletteIcon.cs | 50 ----- .../src/public/Tools/Canvas/RedoIcon.cs | 51 ----- .../src/public/Tools/Canvas/UndoIcon.cs | 51 ----- .../src/public/Tools/Eraser/EraserIcon.cs | 49 ---- .../src/public/Tools/Eraser/EraserTool.cs | 79 ++++++- .../Tools/Eraser/EraserToolActionHandler.cs | 93 -------- .../src/public/Tools/Icon.cs | 182 --------------- .../src/public/Tools/IconStateManager.cs | 53 ----- .../public/Tools/Pencil/Brush/BrushIcon.cs | 86 ------- .../Pencil/Brush/BrushStrategyFactory.cs | 26 ++- .../Tools/Pencil/Brush/IBrushStrategy.cs | 2 +- .../src/public/Tools/Pencil/ColorIcon.cs | 73 ------ .../src/public/Tools/Pencil/PenInk.cs | 108 --------- .../src/public/Tools/Pencil/PencilTool.cs | 194 ++++++++-------- .../Tools/Pencil/PencilToolActionHandler.cs | 114 ---------- .../src/public/Tools/Pencil/SizeIcon.cs | 59 ----- .../src/public/Tools/Select/SelectIcon.cs | 50 ----- .../src/public/Tools/Select/SelectTool.cs | 35 --- .../Tools/Select/SelectToolActionHandler.cs | 137 ------------ .../public/Tools/Selection/SelectionTool.cs | 211 ++++++++++++++++++ .../src/public/Tools/ToolBase.cs | 90 -------- .../src/public/Tools/ToolFactory.cs | 36 --- .../src/public/Tools/ToolManager.cs | 34 ++- .../src/public/Tools/ToolPickerView.cs | 150 ------------- ...CanvasToolActionHandler.cs => Toolbase.cs} | 18 +- .../src/PenWaveSample.cs | 38 +++- 79 files changed, 3146 insertions(+), 2075 deletions(-) create mode 100644 src/Tizen.NUI.PenWave/src/backup/EventBus.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/PopupManager.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/BackgroundColorIcon.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/CanvasTool.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/CanvasToolActionHandler.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/ClearIcon.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/GridIcon.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/PaletteIcon.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/RedoIcon.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/UndoIcon.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Eraser/EraserIcon.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Eraser/EraserTool.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Eraser/EraserToolActionHandler.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/IToolAction.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/IToolActionHandler.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Icon.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/IconStateManager.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/BrushIcon.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/BrushStrategyFactory.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/DashedLineBrush.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/DotBrush .cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/HighlighterBrush.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/IBrushStrategy.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/SharpBrush.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/SoftBrush.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/SprayBrush.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/StrokeBrush.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/VarStrokeBrush.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/VarStrokeIncBrush.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/ColorIcon.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/PenInk.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/PencilTool.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/PencilToolActionHandler.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/SizeIcon.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Select/SelectIcon.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Select/SelectTool.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/Select/SelectToolActionHandler.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/ToolBase.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/ToolFactory.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/ToolManager.cs create mode 100644 src/Tizen.NUI.PenWave/src/backup/Tools/ToolPickerView.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/CanvasUIManager.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/EventBus.cs rename src/Tizen.NUI.PenWave/src/public/{Tools/IToolActionHandler.cs => IToolAction.cs} (71%) create mode 100644 src/Tizen.NUI.PenWave/src/public/PencilToolAction.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/PopupManager.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Canvas/BackgroundColorIcon.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Canvas/CanvasTool.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Canvas/ClearIcon.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Canvas/GridIcon.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Canvas/PaletteIcon.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Canvas/RedoIcon.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Canvas/UndoIcon.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserIcon.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserToolActionHandler.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Icon.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/IconStateManager.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/BrushIcon.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Pencil/ColorIcon.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PenInk.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PencilToolActionHandler.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Pencil/SizeIcon.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Select/SelectIcon.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Select/SelectTool.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Select/SelectToolActionHandler.cs create mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/Selection/SelectionTool.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/ToolBase.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/ToolFactory.cs delete mode 100644 src/Tizen.NUI.PenWave/src/public/Tools/ToolPickerView.cs rename src/Tizen.NUI.PenWave/src/public/Tools/{Canvas/CanvasToolActionHandler.cs => Toolbase.cs} (74%) diff --git a/src/Tizen.NUI.PenWave/src/backup/EventBus.cs b/src/Tizen.NUI.PenWave/src/backup/EventBus.cs new file mode 100644 index 00000000000..ae00084a1cb --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/EventBus.cs @@ -0,0 +1,41 @@ +// /* +// * Copyright(c) 2024 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; +// using System.Collections.Generic; + +// namespace Tizen.NUI.PenWave +// { +// public static class EventBus +// { +// private static readonly Dictionary> events = new(); + +// public static void Subscribe(string eventName, Action callback) +// { +// if (events.ContainsKey(eventName)) +// events[eventName] += callback; +// else +// events[eventName] = callback; +// } + +// public static void Publish(string eventName, object eventArgs = null) +// { +// if (events.TryGetValue(eventName, out var action)) +// action.Invoke(eventArgs); +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/PopupManager.cs b/src/Tizen.NUI.PenWave/src/backup/PopupManager.cs new file mode 100644 index 00000000000..dfa24a05843 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/PopupManager.cs @@ -0,0 +1,55 @@ +// /* +// * Copyright(c) 2024 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; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class PopupManager +// { +// private View popupView; +// private View parentView; + +// public PopupManager(View parentView) +// { +// this.parentView = parentView; +// this.parentView.TouchEvent += (s, e) => { return true; }; // To prevent touch event propagation to parent view. +// } + +// public void ShowPopup(View contentView, Position2D position) +// { +// if (popupView != null) HidePopup(); + +// popupView = new View(); +// popupView.Add(contentView); +// parentView.Position2D = position; +// parentView.Add(popupView); +// } + +// public void HidePopup() +// { +// if (popupView != null) +// { +// parentView.Remove(popupView); +// popupView = null; +// } +// } +// } + +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/BackgroundColorIcon.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/BackgroundColorIcon.cs new file mode 100644 index 00000000000..3dab3ceb799 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/BackgroundColorIcon.cs @@ -0,0 +1,73 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class BackgroundColorIcon : Icon +// { +// private readonly string mColorHex; +// private readonly Color mColor; + +// public BackgroundColorIcon(Tizen.NUI.Color color) : base() +// { +// mColorHex = ToHex(color); +// mColor = color; + +// IconStateNormalColor = mColorHex; +// IconStateSelectedColor = mColorHex; +// IconStatePressedColor = mColorHex; +// IconStateDisabledColor = mColorHex; + +// InitializeIcon(); +// } + +// protected override string GetDefaultImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/color_icon_base.png"; +// } + +// protected override string GetSelectedImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; +// } + +// public override bool OnIconClicked(object sender, View.TouchEventArgs args) +// { +// if (base.OnIconClicked(sender, args)) +// { +// PWEngine.CanvasSetColor(GetColorHex(), 1.0f); +// } +// return true; +// } + +// 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}"; +// } + +// public string GetColorHex() => mColorHex; +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/CanvasTool.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/CanvasTool.cs new file mode 100644 index 00000000000..15848a1bb37 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/CanvasTool.cs @@ -0,0 +1,102 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class CanvasTool : ToolBase +// { +// public override PenWaveToolType Type => PenWaveToolType.Canvas; + +// private static readonly string s_popupBgUrl = $"{FrameworkInformation.ResourcePath}images/light/canvas_popup_bg.png"; +// private static readonly List s_bgColors = new List +// { +// new Color("#FFFEFE"), +// new Color("#F0F0F0"), +// new Color("#B7B7B7"), +// new Color("#E3F2FF"), +// new Color("#202022"), +// new Color("#515151"), +// new Color("#17234D"), +// new Color("#090E21"), +// }; + +// // private Icon paletteIcon; +// // private Icon gridIcon; + +// public CanvasTool() : base(new CanvasToolActionHandler()) +// { +// // paletteIcon = new PaletteIcon(); +// // AddIcon(paletteIcon); + +// // gridIcon = new GridIcon(); +// // AddIcon(gridIcon); + +// // AddIcon(new UndoIcon()); +// // AddIcon(new RedoIcon()); +// // AddIcon(new ClearIcon()); +// } + +// // protected override void OnIconSelected(object sender) +// // { +// // Tizen.Log.Info("NUI", $"OnIconSelected\n"); +// // if (sender is PaletteIcon) +// // { +// // CreateColorIconsView(); +// // } +// // else +// // { +// // PopupManager.HidePopup(); +// // } +// // } + +// // private void CreateColorIconsView() +// // { +// // var view = new ImageView +// // { +// // BackgroundImage = s_popupBgUrl, +// // WidthSpecification = LayoutParamPolicies.WrapContent, +// // HeightSpecification = LayoutParamPolicies.WrapContent, +// // Layout = new GridLayout { Columns = 1, RowSpacing = 4 } +// // }; +// // AddIconsToView(view, s_bgColors, color => new BackgroundColorIcon(color)); +// // Position2D position = new Position2D((int)paletteIcon.ScreenPosition.X, (int)paletteIcon.ScreenPosition.Y + 60); +// // PopupManager.ShowPopup(view, position); +// // } + +// // private void AddIconsToView(View rootView, IEnumerableitems, Func iconFactory) +// // { +// // var view = new View +// // { +// // Layout = new GridLayout { Columns = 4, ColumnSpacing = 8, RowSpacing = 8 }, +// // }; +// // foreach (var item in items) +// // { +// // var icon = iconFactory(item); +// // view.Add(icon); +// // } + +// // rootView.Add(view); +// // } + +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/CanvasToolActionHandler.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/CanvasToolActionHandler.cs new file mode 100644 index 00000000000..2b0c203a20a --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/CanvasToolActionHandler.cs @@ -0,0 +1,42 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class CanvasToolActionHandler : IToolActionHandler +// { +// public void Activate() +// { +// } + +// public void Deactivate() +// { +// } + +// public void HandleInput(Touch touch) +// { +// } +// } +// } + + diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/ClearIcon.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/ClearIcon.cs new file mode 100644 index 00000000000..baec46d014e --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/ClearIcon.cs @@ -0,0 +1,51 @@ +// /* +// * Copyright(c) 2024 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 Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class ClearIcon : Icon +// { +// public ClearIcon() : base() +// { +// InitializeIcon(); +// } + +// protected override string GetDefaultImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/icon_clear.png"; +// } + +// protected override string GetSelectedImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; +// } + +// public override bool OnIconClicked(object sender, View.TouchEventArgs args) +// { +// if (base.OnIconClicked(sender, args)) +// { +// Tizen.Log.Info("NUI", $"ClearIcon\n"); +// PWEngine.ClearCurrentCanvas(); +// } +// return true; +// } + +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/GridIcon.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/GridIcon.cs new file mode 100644 index 00000000000..615a1f47d7a --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/GridIcon.cs @@ -0,0 +1,59 @@ +// /* +// * Copyright(c) 2024 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 Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class GridIcon : Icon +// { +// public enum GridDensityType +// { +// None = 0, +// Small = 1, +// Medium = 2, +// Large = 4 +// } + +// public GridIcon() : base() +// { +// InitializeIcon(); +// } + +// protected override string GetDefaultImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/icon_grid.png"; +// } + +// protected override string GetSelectedImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; +// } + +// public override bool OnIconClicked(object sender, View.TouchEventArgs args) +// { +// if (base.OnIconClicked(sender, args)) +// { +// Tizen.Log.Info("NUI", $"GridIcon\n"); +// PWEngine.ToggleGrid((int)GridDensityType.Small); +// } +// return true; +// } + +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/PaletteIcon.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/PaletteIcon.cs new file mode 100644 index 00000000000..378c0d4b5cf --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/PaletteIcon.cs @@ -0,0 +1,50 @@ +// /* +// * Copyright(c) 2024 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 Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class PaletteIcon : Icon +// { +// public PaletteIcon() : base() +// { +// InitializeIcon(); +// } + +// protected override string GetDefaultImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/icon_color_palette.png"; +// } + +// protected override string GetSelectedImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; +// } + +// public override bool OnIconClicked(object sender, View.TouchEventArgs args) +// { +// if (base.OnIconClicked(sender, args)) +// { +// Tizen.Log.Info("NUI", $"PaletteIcon\n"); +// } +// return true; +// } + +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/RedoIcon.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/RedoIcon.cs new file mode 100644 index 00000000000..1768e93d38b --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/RedoIcon.cs @@ -0,0 +1,51 @@ +// /* +// * Copyright(c) 2024 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 Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class RedoIcon : Icon +// { +// public RedoIcon() : base() +// { +// InitializeIcon(); +// } + +// protected override string GetDefaultImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/icon_redo.png"; +// } + +// protected override string GetSelectedImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; +// } + +// public override bool OnIconClicked(object sender, View.TouchEventArgs args) +// { +// if (base.OnIconClicked(sender, args)) +// { +// Tizen.Log.Info("NUI", $"RedoIcon\n"); +// PWEngine.Redo(); +// } +// return true; +// } + +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/UndoIcon.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/UndoIcon.cs new file mode 100644 index 00000000000..09e279d0155 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Canvas/UndoIcon.cs @@ -0,0 +1,51 @@ +// /* +// * Copyright(c) 2024 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 Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class UndoIcon : Icon +// { +// public UndoIcon() : base() +// { +// InitializeIcon(); +// } + +// protected override string GetDefaultImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/icon_undo.png"; +// } + +// protected override string GetSelectedImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; +// } + +// public override bool OnIconClicked(object sender, View.TouchEventArgs args) +// { +// if (base.OnIconClicked(sender, args)) +// { +// Tizen.Log.Info("NUI", $"UndoIcon\n"); +// PWEngine.Undo(); +// } +// return true; +// } + +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Eraser/EraserIcon.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Eraser/EraserIcon.cs new file mode 100644 index 00000000000..6e6fa015274 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Eraser/EraserIcon.cs @@ -0,0 +1,49 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class EraserIcon : Icon +// { +// public EraserIcon() : base() +// { +// InitializeIcon(); +// } + +// protected override string GetDefaultImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/icon_eraser.png"; +// } + +// protected override string GetSelectedImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; +// } + +// public override bool OnIconClicked(object sender, View.TouchEventArgs args) +// { +// base.OnIconClicked(sender, args); +// return true; +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Eraser/EraserTool.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Eraser/EraserTool.cs new file mode 100644 index 00000000000..8cdaf1d1dc8 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Eraser/EraserTool.cs @@ -0,0 +1,35 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class EraserTool : ToolBase +// { +// public override PenWaveToolType Type => PenWaveToolType.Eraser; + +// public EraserTool() : base(new EraserToolActionHandler()) +// { +// // AddIcon(new EraserIcon()); +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Eraser/EraserToolActionHandler.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Eraser/EraserToolActionHandler.cs new file mode 100644 index 00000000000..c630ff3805b --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Eraser/EraserToolActionHandler.cs @@ -0,0 +1,93 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class EraserToolActionHandler : IToolActionHandler +// { +// enum Mode +// { +// Partial, +// Full +// } + +// private Mode mode = Mode.Partial; +// private float radiusEraser = 48; // 지우개 사이즈 설정 가능해야 함 + +// public void Activate() +// { +// } + +// public void Deactivate() +// { +// EndDrawing(); +// } + +// public void HandleInput(Touch touch) +// { +// if (touch == null || touch.GetPointCount() == 0) return; + +// uint pointStateIndex = 0; +// uint touchTime = touch.GetTime(); + +// List touchPositionList = new List(); +// for (uint i = 0; i < touch.GetPointCount(); ++i) +// { +// touchPositionList.Add(touch.GetLocalPosition(i)); +// } + +// Vector2 position = touchPositionList[(int)pointStateIndex]; +// switch (touch.GetState(pointStateIndex)) +// { +// case PointStateType.Down: +// StartDrawing(position, touchTime); +// break; +// case PointStateType.Motion: +// ContinueDrawing(position, touchTime); +// break; +// case PointStateType.Up: +// case PointStateType.Leave: +// EndDrawing(); +// break; +// } +// } + +// private void StartDrawing(Vector2 position, uint touchTime) +// { +// PWEngine.EraseShape((int)position.X, (int)position.Y, radiusEraser, (mode == Mode.Partial)); +// } + +// private void ContinueDrawing(Vector2 position, uint touchTime) +// { +// PWEngine.EraseShape((int)position.X, (int)position.Y, radiusEraser, (mode == Mode.Partial)); +// } + +// private void EndDrawing() +// { +// PWEngine.StopErasing(); +// } + +// } +// } + + diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/IToolAction.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/IToolAction.cs new file mode 100644 index 00000000000..245b96e7e8c --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/IToolAction.cs @@ -0,0 +1,32 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public interface IToolAction +// { +// void Execute(); +// } +// } + + diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/IToolActionHandler.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/IToolActionHandler.cs new file mode 100644 index 00000000000..0caf4a6e830 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/IToolActionHandler.cs @@ -0,0 +1,34 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public interface IToolActionHandler +// { +// void HandleInput(Touch touch); +// void Activate(); +// void Deactivate(); +// } +// } + + diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Icon.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Icon.cs new file mode 100644 index 00000000000..be47f653e8f --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Icon.cs @@ -0,0 +1,182 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// // Abstract class representing an icon that extends ImageView. +// public abstract class Icon : ImageView +// { +// // Enumeration for the Icon states. +// public enum IconState +// { +// // Icon Normal State +// Normal = 0, +// // Icon Pressed State +// Pressed, +// // Icon Selected State +// Selected, +// // Icon Disabled State +// Disabled +// } + +// // Properties to define colors for different states. +// public string IconStateNormalColor { get; set; } = "#17234d"; +// public string IconStateSelectedColor { get; set; } = "#FF6200"; +// public string IconStatePressedColor { get; set; } = "#FF6200"; +// public string IconStateDisabledColor { get; set; } = "#CACACA"; + +// // Event handler for when the icon is selected. +// public event Action IconSelected; + +// // Image views for the default and selected states of the icon. +// public ImageView DefaultImage; +// public ImageView SelectedImage; + +// // Default size of the icon. +// private int defaultSize = 48; +// // Current state of the icon. +// private IconState currentState; + +// // Property to get and set the current state of the icon. +// public IconState CurrentState +// { +// get => currentState; +// set +// { +// currentState = value; +// UpdateIconState(); // Update the icon's appearance based on the new state. +// } +// } + +// // Constructor for the Icon class. +// public Icon() +// { +// currentState = IconState.Normal; // Set the initial state to normal. +// GrabTouchAfterLeave = true; + +// // Set layout properties to center the icon within its parent. +// Layout = new LinearLayout() +// { +// HorizontalAlignment = HorizontalAlignment.Center, +// VerticalAlignment = VerticalAlignment.Center, +// }; +// // Set the default size of the icon. +// this.Size2D = new Size2D(defaultSize, defaultSize); + +// // Attach a touch event handler to handle click events on the icon. +// this.TouchEvent += OnIconClicked; +// } + +// // Override the Dispose method to clean up resources. +// protected override void Dispose(DisposeTypes type) +// { +// base.Dispose(type); +// // Dispose of the default and selected image views. +// DefaultImage?.Dispose(); +// SelectedImage?.Dispose(); +// } + +// // Method to initialize the icon with default and selected images. +// protected void InitializeIcon() +// { +// // Create a default image view with the specified properties. +// DefaultImage = new ImageView +// { +// WidthResizePolicy = ResizePolicyType.FillToParent, +// HeightResizePolicy = ResizePolicyType.FillToParent, +// Color = new Color(IconStateNormalColor), +// ResourceUrl = GetDefaultImageUrl() // Get the URL for the default image. +// }; +// // Add the default image view to the icon. +// this.Add(DefaultImage); + +// // Create a selected image view with the specified properties. +// SelectedImage = new ImageView +// { +// WidthResizePolicy = ResizePolicyType.FillToParent, +// HeightResizePolicy = ResizePolicyType.FillToParent, +// ResourceUrl = GetSelectedImageUrl() // Get the URL for the selected image. +// }; +// // Add the selected image view to the default image view. +// DefaultImage.Add(SelectedImage); +// // Hide the selected image view initially. +// SelectedImage.Hide(); +// } + +// // Method to update the icon's appearance based on its current state. +// public virtual void UpdateIconState() +// { +// switch (currentState) +// { +// case IconState.Normal: +// // Hide the selected image and set the color of the default image to normal color. +// SelectedImage.Hide(); +// DefaultImage.Color = new Color(IconStateNormalColor); +// break; +// case IconState.Selected: +// // Show the selected image and set the color of the default image to selected color. +// SelectedImage.Show(); +// DefaultImage.Color = new Color(IconStateSelectedColor); +// break; +// case IconState.Pressed: +// // Set the color of the default image to pressed color. +// DefaultImage.Color = new Color(IconStatePressedColor); +// break; +// case IconState.Disabled: +// // Set the color of the default image to disabled color and hide the selected image. +// DefaultImage.Color = new Color(IconStateDisabledColor); +// SelectedImage.Hide(); +// break; +// default: +// break; +// } +// } + +// // Method to handle touch events on the icon. +// public virtual bool OnIconClicked(object sender, View.TouchEventArgs args) +// { +// if (args.Touch.GetState(0) == PointStateType.Down) +// { +// // Set the currently selected icon to this instance and invoke the IconSelected event. +// IconStateManager.Instance.CurrentPressedIcon = this; +// IconSelected?.Invoke(sender); +// return true; +// } +// else if (args.Touch.GetState(0) == PointStateType.Up) +// { +// CurrentState = IconState.Selected; +// } +// return false; +// } + +// public void SetDisabled(bool isDisabled) +// { +// CurrentState = isDisabled ? IconState.Disabled : IconState.Normal; +// } + +// public bool IsSelected => CurrentState == IconState.Selected; + +// // Abstract methods to be implemented by derived classes to return the URLs for default and selected images. +// protected abstract string GetDefaultImageUrl(); +// protected abstract string GetSelectedImageUrl(); +// } +// } \ No newline at end of file diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/IconStateManager.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/IconStateManager.cs new file mode 100644 index 00000000000..6e4d4d8fc40 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/IconStateManager.cs @@ -0,0 +1,53 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public sealed class IconStateManager +// { +// private static readonly IconStateManager instance = new IconStateManager(); + +// private Icon _currentPressedIcon; + +// private IconStateManager() {} + +// public static IconStateManager Instance => instance; + +// public Icon CurrentPressedIcon +// { +// get => _currentPressedIcon; +// set +// { +// if (_currentPressedIcon != null && _currentPressedIcon != value) +// { +// _currentPressedIcon.CurrentState = Icon.IconState.Normal; +// } +// _currentPressedIcon = value; +// if (_currentPressedIcon != null) +// { +// _currentPressedIcon.CurrentState = Icon.IconState.Pressed; +// } +// } +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/BrushIcon.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/BrushIcon.cs new file mode 100644 index 00000000000..db4402f6f3b --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/BrushIcon.cs @@ -0,0 +1,86 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class BrushIcon : Icon +// { +// private PWEngine.BrushType brushType; +// private readonly IBrushStrategy brushStrategy; + +// private static readonly Dictionary IconMap = new Dictionary +// { +// { PWEngine.BrushType.Stroke, "icon_pencil" }, +// { PWEngine.BrushType.VarStroke, "icon_varstroke_dec" }, +// { PWEngine.BrushType.VarStrokeInc, "icon_varstroke_inc" }, +// { PWEngine.BrushType.SprayBrush, "icon_spray" }, +// { PWEngine.BrushType.DotBrush, "icon_dot" }, +// { PWEngine.BrushType.DashedLine, "icon_dashed_line" }, +// { PWEngine.BrushType.Highlighter, "icon_highlighter" }, +// { PWEngine.BrushType.SoftBrush, "icon_soft_brush" }, +// { PWEngine.BrushType.SharpBrush, "icon_sharp_brush" }, +// }; + +// private ImageView mImgView; +// public BrushIcon(PWEngine.BrushType brushType) : base() +// { +// brushStrategy = BrushStrategyFactory.GetBrushStrategy(brushType); + +// this.brushType = brushType; + +// mImgView = new ImageView(); +// mImgView.Size2D = new Size2D(48, 48); + +// InitializeIcon(); +// } + +// protected override string GetDefaultImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/{GetIconUrl(brushType)}.png"; +// } + +// protected override string GetSelectedImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; +// } + +// private string GetIconUrl(PWEngine.BrushType brushType) +// { +// return IconMap.ContainsKey(brushType) ? IconMap[brushType] : string.Empty; +// } + + +// public PWEngine.BrushType GetBrushType() => brushType; + + +// public override bool OnIconClicked(object sender, View.TouchEventArgs args) +// { +// if (base.OnIconClicked(sender, args)) +// { +// brushStrategy.ApplyBrushSettings(); +// } +// return true; +// } + +// } +// } \ No newline at end of file diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/BrushStrategyFactory.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/BrushStrategyFactory.cs new file mode 100644 index 00000000000..dcba6487e8d --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/BrushStrategyFactory.cs @@ -0,0 +1,46 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public static class BrushStrategyFactory +// { +// public static IBrushStrategy GetBrushStrategy(PWEngine.BrushType brushType) +// { +// return brushType switch +// { +// PWEngine.BrushType.Stroke => new StrokeBrush(), +// PWEngine.BrushType.VarStroke => new VarStrokeBrush(), +// PWEngine.BrushType.VarStrokeInc => new VarStrokeIncBrush(), +// PWEngine.BrushType.SprayBrush => new SprayBrush(), +// PWEngine.BrushType.DotBrush => new DotBrush(), +// PWEngine.BrushType.DashedLine => new DashedLineBrush(), +// PWEngine.BrushType.Highlighter => new HighlighterBrush(), +// PWEngine.BrushType.SoftBrush => new SoftBrush(), +// PWEngine.BrushType.SharpBrush => new SharpBrush(), +// _ => throw new ArgumentOutOfRangeException(nameof(brushType), brushType, null) +// }; +// } + +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/DashedLineBrush.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/DashedLineBrush.cs new file mode 100644 index 00000000000..704f9b7fdfe --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/DashedLineBrush.cs @@ -0,0 +1,31 @@ +// /* +// * Copyright(c) 2024 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 Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class DashedLineBrush : IBrushStrategy +// { +// public void ApplyBrushSettings() +// { +// PWEngine.SetStrokeType(5); +// PWEngine.SetDashArray("1 3"); +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/DotBrush .cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/DotBrush .cs new file mode 100644 index 00000000000..1f19f07eb8f --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/DotBrush .cs @@ -0,0 +1,32 @@ +// /* +// * Copyright(c) 2024 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 Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class DotBrush : IBrushStrategy +// { +// public void ApplyBrushSettings() +// { +// PWEngine.SetStrokeType(1); +// PWEngine.SetBrushTexture(1); +// PWEngine.SetBrushDistance(2.0f); +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/HighlighterBrush.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/HighlighterBrush.cs new file mode 100644 index 00000000000..9215ae658a8 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/HighlighterBrush.cs @@ -0,0 +1,32 @@ +// /* +// * Copyright(c) 2024 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 Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class HighlighterBrush : IBrushStrategy +// { +// public void ApplyBrushSettings() +// { +// PWEngine.SetStrokeType(1); +// PWEngine.SetBrushTexture(3); +// PWEngine.SetBrushDistance(0.25f); +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/IBrushStrategy.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/IBrushStrategy.cs new file mode 100644 index 00000000000..fcbbee5f202 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/IBrushStrategy.cs @@ -0,0 +1,30 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public interface IBrushStrategy +// { +// void ApplyBrushSettings(); +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/SharpBrush.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/SharpBrush.cs new file mode 100644 index 00000000000..1e2a1e89d42 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/SharpBrush.cs @@ -0,0 +1,30 @@ +// /* +// * Copyright(c) 2024 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 Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class SharpBrush : IBrushStrategy +// { +// public void ApplyBrushSettings() +// { +// PWEngine.SetStrokeType(8); +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/SoftBrush.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/SoftBrush.cs new file mode 100644 index 00000000000..809ea88f78f --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/SoftBrush.cs @@ -0,0 +1,32 @@ +// /* +// * Copyright(c) 2024 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 Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class SoftBrush : IBrushStrategy +// { +// public void ApplyBrushSettings() +// { +// PWEngine.SetStrokeType(1); +// PWEngine.SetBrushTexture(4); +// PWEngine.SetBrushDistance(1.0f); +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/SprayBrush.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/SprayBrush.cs new file mode 100644 index 00000000000..571606e88b6 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/SprayBrush.cs @@ -0,0 +1,32 @@ +// /* +// * Copyright(c) 2024 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 Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class SprayBrush : IBrushStrategy +// { +// public void ApplyBrushSettings() +// { +// PWEngine.SetStrokeType(1); +// PWEngine.SetBrushTexture(0); +// PWEngine.SetBrushDistance(3.0f); +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/StrokeBrush.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/StrokeBrush.cs new file mode 100644 index 00000000000..80f57d00c0a --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/StrokeBrush.cs @@ -0,0 +1,30 @@ +// /* +// * Copyright(c) 2024 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 Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class StrokeBrush : IBrushStrategy +// { +// public void ApplyBrushSettings() +// { +// PWEngine.SetStrokeType(0); +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/VarStrokeBrush.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/VarStrokeBrush.cs new file mode 100644 index 00000000000..22b09e94379 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/VarStrokeBrush.cs @@ -0,0 +1,30 @@ +// /* +// * Copyright(c) 2024 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 Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class VarStrokeBrush : IBrushStrategy +// { +// public void ApplyBrushSettings() +// { +// PWEngine.SetStrokeType(6); +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/VarStrokeIncBrush.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/VarStrokeIncBrush.cs new file mode 100644 index 00000000000..48a638f9928 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/Brush/VarStrokeIncBrush.cs @@ -0,0 +1,30 @@ +// /* +// * Copyright(c) 2024 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 Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class VarStrokeIncBrush : IBrushStrategy +// { +// public void ApplyBrushSettings() +// { +// PWEngine.SetStrokeType(7); +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/ColorIcon.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/ColorIcon.cs new file mode 100644 index 00000000000..6dfa8da4511 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/ColorIcon.cs @@ -0,0 +1,73 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class ColorIcon : Icon +// { +// private readonly string mColorHex; +// private readonly Color mColor; + + + +// public ColorIcon(Tizen.NUI.Color color) : base() +// { +// mColorHex = ToHex(color); +// mColor = color; +// IconStateNormalColor = mColorHex; +// IconStateSelectedColor = mColorHex; +// IconStatePressedColor = mColorHex; +// IconStateDisabledColor = mColorHex; +// InitializeIcon(); +// } + +// protected override string GetDefaultImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/color_icon_base.png"; +// } + +// protected override string GetSelectedImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; +// } + +// public override bool OnIconClicked(object sender, View.TouchEventArgs args) +// { +// if (base.OnIconClicked(sender, args)) +// { +// PWEngine.SetStrokeColor(mColorHex, 1.0f); +// } +// return true; +// } + +// 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}"; +// } + +// public Color GetColor() => mColor; +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/PenInk.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/PenInk.cs new file mode 100644 index 00000000000..ac0b5898a4b --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/PenInk.cs @@ -0,0 +1,108 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using System.Linq; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class PenInk +// { +// public List Colors { get; private set; } +// public List Sizes { get; private set; } +// public List BrushTypes { get; private set; } + +// private Color mCurrentColor; +// private float mCurrentSize; +// private PWEngine.BrushType mCurrentBrushType; + +// private List InitializeDefaultColors() +// { +// return new List +// { +// new Color("#F7B32C"), +// new Color("#FD5703"), +// new Color("#DA1727"), +// new Color("#FF00A8"), +// new Color("#74BFB8"), +// new Color("#4087C5"), +// new Color("#070044"), +// new Color("#0E0E0E"), +// }; +// } + +// private List InitializeDefaultSizes() +// { +// return new List { 3.0f, 6.5f, 12.0f }; +// } + +// private List InitializeDefaultBrushTypes() +// { +// List brushTypes = new List(); +// foreach (PWEngine.BrushType item in Enum.GetValues(typeof(PWEngine.BrushType))) +// { +// brushTypes.Add(item); +// } +// return brushTypes; +// } + +// public PenInk() +// { +// Colors = InitializeDefaultColors(); +// Sizes = InitializeDefaultSizes(); +// BrushTypes = InitializeDefaultBrushTypes(); +// mCurrentColor = Colors.First(); +// mCurrentSize = Sizes.First(); +// mCurrentBrushType = BrushTypes.First(); +// } + +// public PenInk(List colors, List sizes, List brushTypes) +// { +// Colors = colors; +// Sizes = sizes; +// BrushTypes = BrushTypes; + +// mCurrentColor = Colors.First(); +// mCurrentSize = Sizes.First(); +// mCurrentBrushType = BrushTypes.First(); +// } + +// public void SetCurrentColor(Color color) +// { +// mCurrentColor = color; +// } + +// public void SetCurrentSize(float size) +// { +// mCurrentSize = size; +// } + +// public void SetCurrentBrushType(PWEngine.BrushType brushType) +// { +// mCurrentBrushType = brushType; +// } + +// public Color GetCurrentColor() => mCurrentColor; +// public float GetCurrentSize() => mCurrentSize; +// public PWEngine.BrushType GetCurrentBrushType() => mCurrentBrushType; + +// } +// } \ No newline at end of file diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/PencilTool.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/PencilTool.cs new file mode 100644 index 00000000000..48990bc4ca6 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/PencilTool.cs @@ -0,0 +1,163 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class PencilTool : ToolBase +// { +// public override PenWaveToolType Type => PenWaveToolType.Pencil; + +// // private static readonly string popupBgUrl = $"{FrameworkInformation.ResourcePath}images/light/canvas_popup_bg.png"; + +// // private PenInk ink; +// private uint mCurrentShapeId; +// private bool mIsDrawing = false; + +// // private Icon pencilIcon; +// // private Icon sizeIcon; +// // private Icon colorIcon; + + +// public PencilTool() : base(new PencilToolActionHandler()) +// { +// // ink = new PenInk(); + +// // InitializePencilTool(); +// } + +// // public PencilTool(PenInk penInk) : base(new PencilToolActionHandler()) +// // { +// // ink = penInk ?? new PenInk(); + +// // InitializePencilTool(); +// // } + +// // private void InitializePencilTool() +// // { +// // pencilIcon = new BrushIcon(PWEngine.BrushType.Stroke); // 현재 선택된 브러쉬 타입으로 업데이트 필요 +// // AddIcon(pencilIcon); + +// // sizeIcon = new SizeIcon(12.0f); +// // AddIcon(sizeIcon); + +// // colorIcon = new ColorIcon(Color.Black); // 현재 선택된 색상으로 업데이트 필요 +// // AddIcon(colorIcon); +// // } + +// // protected override void OnIconSelected(object sender) +// // { +// // base.OnIconSelected(sender); +// // if (sender is BrushIcon) +// // { +// // Tizen.Log.Info("NUI", $"BrushIcon Selected\n"); +// // CreateBrushIconsView(); +// // } +// // else if (sender is SizeIcon) +// // { +// // Tizen.Log.Info("NUI", $"SizeIcon Selected\n"); +// // CreateSizeIconsView(); +// // } +// // else if (sender is ColorIcon) +// // { +// // Tizen.Log.Info("NUI", $"ColorIcon Selected\n"); +// // CreateColorIconsView(); +// // } +// // } + +// // private void CreateBrushIconsView() +// // { +// // var view = new ImageView +// // { +// // BackgroundImage = popupBgUrl, +// // WidthSpecification = LayoutParamPolicies.WrapContent, +// // HeightSpecification = LayoutParamPolicies.WrapContent, +// // Layout = new GridLayout { Columns = 1, RowSpacing = 4 } +// // }; +// // AddIcons(view, ink.BrushTypes, brushType => new BrushIcon(brushType)); +// // Position2D position = new Position2D((int)pencilIcon.ScreenPosition.X, (int)pencilIcon.ScreenPosition.Y + 60); +// // PopupManager.ShowPopup(view, position); +// // } + +// // private void CreateSizeIconsView() +// // { +// // var view = new ImageView +// // { +// // BackgroundImage = popupBgUrl, +// // WidthSpecification = LayoutParamPolicies.WrapContent, +// // HeightSpecification = LayoutParamPolicies.WrapContent, +// // Layout = new GridLayout { Columns = 1, RowSpacing = 4 } +// // }; +// // AddIcons(view, ink.Sizes, size => new SizeIcon(size)); +// // Position2D position = new Position2D((int)sizeIcon.ScreenPosition.X, (int)sizeIcon.ScreenPosition.Y + 60); +// // PopupManager.ShowPopup(view, position); +// // } + +// // private void CreateColorIconsView() +// // { +// // var view = new ImageView +// // { +// // BackgroundImage = popupBgUrl, +// // WidthSpecification = LayoutParamPolicies.WrapContent, +// // HeightSpecification = LayoutParamPolicies.WrapContent, +// // Layout = new GridLayout { Columns = 1, RowSpacing = 4 } +// // }; +// // AddIcons(view, ink.Colors, color => new ColorIcon(color)); +// // Position2D position = new Position2D((int)colorIcon.ScreenPosition.X, (int)colorIcon.ScreenPosition.Y + 60); +// // PopupManager.ShowPopup(view, position); +// // } + +// // private void AddIcons(View rootView, IEnumerableitems, Func iconFactory) +// // { +// // var view = new View +// // { +// // Layout = new GridLayout { Columns = 4, ColumnSpacing = 16, RowSpacing = 16 }, +// // }; +// // foreach (var item in items) +// // { +// // var icon = iconFactory(item); +// // view.Add(icon); +// // icon.IconSelected += OnPopUnIconSelected; +// // } +// // rootView.Add(view); +// // } + +// // private void OnPopUnIconSelected(object sender) +// // { +// // if (sender is BrushIcon) +// // { +// // pencilIcon.DefaultImage.ResourceUrl = IconStateManager.Instance.CurrentPressedIcon.DefaultImage.ResourceUrl; +// // } +// // else if (sender is SizeIcon) +// // { +// // sizeIcon.DefaultImage.Size2D = IconStateManager.Instance.CurrentPressedIcon.DefaultImage.Size2D; +// // } +// // else if (sender is ColorIcon) +// // { +// // colorIcon.DefaultImage.Color = (sender as ColorIcon).GetColor(); +// // } +// // } + +// } + + +// } \ No newline at end of file diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/PencilToolActionHandler.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/PencilToolActionHandler.cs new file mode 100644 index 00000000000..53564fa07b2 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/PencilToolActionHandler.cs @@ -0,0 +1,114 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class PencilToolActionHandler : IToolActionHandler +// { + + +// enum ErrorShapeAddPointsType +// { +// noError, +// overflowShape, +// noCanvasSet, +// noShapesInCanvas, +// badIdShape, +// drawableIsNotAShape, +// drawableIsNotALine, +// drawingCanceled +// } + +// private uint currentShapeId; + +// public void Activate() +// { + +// } + +// public void Deactivate() +// { +// EndDrawing(); +// } + +// public void HandleInput(Touch touch) +// { +// if (touch == null || touch.GetPointCount() == 0) return; + +// uint pointStateIndex = 0; +// uint touchTime = touch.GetTime(); + +// List touchPositionList = new List(); +// for (uint i = 0; i < touch.GetPointCount(); ++i) +// { +// touchPositionList.Add(touch.GetLocalPosition(i)); +// } + +// Vector2 position = touchPositionList[(int)pointStateIndex]; +// switch (touch.GetState(pointStateIndex)) +// { +// case PointStateType.Down: +// StartDrawing(position, touchTime); +// break; +// case PointStateType.Motion: +// ContinueDrawing(position, touchTime); +// break; +// case PointStateType.Up: +// case PointStateType.Leave: +// EndDrawing(); +// break; +// } +// } + +// private void StartDrawing(Vector2 position, uint touchTime) +// { +// currentShapeId = PWEngine.BeginShapeDraw(position.X, position.Y, touchTime); +// } + +// private void ContinueDrawing(Vector2 position, uint touchTime) +// { +// if (currentShapeId > 0) +// { +// var result = (ErrorShapeAddPointsType)PWEngine.DrawShape(currentShapeId, position.X, position.Y, touchTime); +// if (result == ErrorShapeAddPointsType.overflowShape) +// { +// EndDrawing(); +// StartDrawing(position, touchTime); +// } +// else if (result == ErrorShapeAddPointsType.drawingCanceled) +// { +// EndDrawing(); +// } +// } +// } + +// private void EndDrawing() +// { +// PWEngine.EndShapeDraw(currentShapeId, 0); +// currentShapeId = 0; +// } + +// } +// } + + diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/SizeIcon.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/SizeIcon.cs new file mode 100644 index 00000000000..c8c4f4e80fd --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Pencil/SizeIcon.cs @@ -0,0 +1,59 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class SizeIcon : Icon +// { +// private readonly float size; + +// public SizeIcon(float size) : base() +// { +// this.size = size; + +// InitializeIcon(); +// DefaultImage.Size2D = new Size2D((int)(size * 2), (int)(size * 2)); +// } + +// protected override string GetDefaultImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/color_icon_base.png"; +// } + +// protected override string GetSelectedImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; +// } + +// public override bool OnIconClicked(object sender, View.TouchEventArgs args) +// { +// if (base.OnIconClicked(sender, args)) +// { +// PWEngine.SetStrokeSize(GetSize()); +// } +// return true; +// } + +// public float GetSize() => size; +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Select/SelectIcon.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Select/SelectIcon.cs new file mode 100644 index 00000000000..27a890c74f1 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Select/SelectIcon.cs @@ -0,0 +1,50 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class SelectIcon : Icon +// { +// public SelectIcon() : base() +// { + +// InitializeIcon(); +// } + +// protected override string GetDefaultImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/icon_select_area.png"; +// } + +// protected override string GetSelectedImageUrl() +// { +// return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; +// } + +// public override bool OnIconClicked(object sender, View.TouchEventArgs args) +// { +// base.OnIconClicked(sender, args); +// return true; +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Select/SelectTool.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Select/SelectTool.cs new file mode 100644 index 00000000000..ce834c4572e --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Select/SelectTool.cs @@ -0,0 +1,35 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class SelectTool : ToolBase +// { +// public override PenWaveToolType Type => PenWaveToolType.Select; + +// public SelectTool() : base(new SelectToolActionHandler()) +// { +// // AddIcon(new SelectIcon()); +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/Select/SelectToolActionHandler.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/Select/SelectToolActionHandler.cs new file mode 100644 index 00000000000..2704eb113d3 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/Select/SelectToolActionHandler.cs @@ -0,0 +1,137 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class SelectToolActionHandler : IToolActionHandler +// { +// enum SelectMode +// { +// Resize, +// Move, +// None +// } + +// enum DrawableType +// { +// None, //nothing found/selected +// Multi, //more than one drawable selected +// Shape, +// Chart, +// Picture, +// Text +// } + +// private bool isTouchedInsideSelectedArea = false; +// private SelectMode mode = SelectMode.None; +// private DrawableType drawableType = DrawableType.None; + +// public void Activate() +// { +// } + +// public void Deactivate() +// { +// mode = SelectMode.None; +// EndDrawing(); +// } + +// public void HandleInput(Touch touch) +// { +// if (touch == null || touch.GetPointCount() == 0) return; + +// uint pointStateIndex = 0; +// uint touchTime = touch.GetTime(); + +// List touchPositionList = new List(); +// for (uint i = 0; i < touch.GetPointCount(); ++i) +// { +// touchPositionList.Add(touch.GetLocalPosition(i)); +// } + +// Vector2 position = touchPositionList[(int)pointStateIndex]; +// switch (touch.GetState(pointStateIndex)) +// { +// case PointStateType.Down: +// StartDrawing(position, touchTime); +// break; +// case PointStateType.Motion: +// ContinueDrawing(position, touchTime); +// break; +// case PointStateType.Up: +// case PointStateType.Leave: +// EndDrawing(); +// break; +// } +// } + +// private void StartDrawing(Vector2 position, uint touchTime) +// { +// isTouchedInsideSelectedArea = PWEngine.InsideSelectedArea(position.X, position.Y); +// if (!isTouchedInsideSelectedArea) +// { +// PWEngine.DropSelectedDrawables(); +// drawableType = (DrawableType)PWEngine.SelectDrawable(position.X, position.Y); +// } +// } + +// private void ContinueDrawing(Vector2 position, uint touchTime) +// { +// if (drawableType == DrawableType.None) +// { +// if (mode == SelectMode.None) +// { +// PWEngine.StartSelectingArea(position.X, position.Y); +// } +// PWEngine.ResizeSelectedArea(position.X, position.Y); +// mode = SelectMode.Resize; +// } +// else if (isTouchedInsideSelectedArea || drawableType != DrawableType.None) +// { +// PWEngine.DragSelectedDrawables(position.X, position.Y); +// mode = SelectMode.Move; +// } +// } + +// private void EndDrawing() +// { +// switch (mode) +// { +// case SelectMode.Move : +// PWEngine.EndDraging(); +// break; +// case SelectMode.Resize : +// drawableType = (DrawableType)PWEngine.SelectDrawables(); +// break; +// default : +// PWEngine.DropSelectedDrawables(); +// break; +// } +// isTouchedInsideSelectedArea = false; +// mode = SelectMode.None; +// } + +// } +// } + + diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/ToolBase.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/ToolBase.cs new file mode 100644 index 00000000000..2f9b6f140ef --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/ToolBase.cs @@ -0,0 +1,90 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public abstract class ToolBase +// { + +// public abstract PenWaveToolType Type { get; } + +// protected IToolActionHandler ActionHandler { get; private set; } + +// public event Action ToolSelected; + +// // protected List Icons { get; } = new List(); + +// // protected PopupManager PopupManager { get; private set; } + +// public ToolBase(IToolActionHandler actionHandler) +// { +// ActionHandler = actionHandler; +// } + +// // public void SetPopupManager(PopupManager popupManager) +// // { +// // PopupManager = popupManager; +// // } + +// // protected virtual void OnIconSelected(object sender) +// // { +// // ToolSelected?.Invoke(Type); +// // } + +// public void Activate() +// { +// ActionHandler.Activate(); +// } + +// public void Deactivate() +// { +// ActionHandler.Deactivate(); +// } + +// public virtual void HandleInput(Touch touch) +// { +// ActionHandler.HandleInput(touch); +// } + +// // public virtual View GetUI() +// // { +// // var view = new View +// // { +// // Layout = new LinearLayout() +// // { +// // // HorizontalAlignment = HorizontalAlignment.Center, +// // // VerticalAlignment = VerticalAlignment.Center, +// // LinearOrientation = LinearLayout.Orientation.Horizontal, +// // } +// // }; +// // foreach (var icon in Icons) +// // { +// // icon.IconSelected += OnIconSelected; +// // view.Add(icon); +// // } +// // return view; +// // } + +// // protected void AddIcon(Icon icon) => Icons.Add(icon); +// } +// } \ No newline at end of file diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/ToolFactory.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/ToolFactory.cs new file mode 100644 index 00000000000..bda98006cc7 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/ToolFactory.cs @@ -0,0 +1,36 @@ +// /* +// * Copyright(c) 2024 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; + +// namespace Tizen.NUI.PenWave +// { +// public static class ToolFactory +// { +// public static ToolBase CreateTool(PenWaveToolType toolType) +// { +// return toolType switch +// { +// PenWaveToolType.Pencil => new PencilTool(), +// PenWaveToolType.Eraser => new EraserTool(), +// PenWaveToolType.Select => new SelectTool(), +// PenWaveToolType.Canvas => new CanvasTool(), +// _ => throw new ArgumentException("Unknown ToolType") +// }; +// } +// } +// } \ No newline at end of file diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/ToolManager.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/ToolManager.cs new file mode 100644 index 00000000000..89a38953da0 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/ToolManager.cs @@ -0,0 +1,74 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class ToolManager +// { +// public Dictionary Tools { get; } = new(); +// private ToolBase currentTool; + +// public ToolManager() {} + +// public void RegisterTool(ToolBase tool) +// { +// if (Tools.ContainsKey(tool.Type)) +// { +// Tizen.Log.Error("NUI", $"Already registered tool type {tool.Type}\n"); +// } +// else +// { +// Tools.Add(tool.Type, tool); +// tool.ToolSelected += OnToolSelected; +// } +// } + +// public void UnregisterTool(ToolBase tool) +// { +// Tools.Remove(tool.Type); +// } + +// public void SelectTool(PenWaveToolType toolType) +// { +// currentTool?.Deactivate(); +// if (Tools.TryGetValue(toolType, out currentTool)) +// { +// currentTool.Activate(); +// // EventBus.Publish("ToolChanged", toolType); +// } +// } + +// public void HandleInput(Touch touch) +// { +// currentTool?.HandleInput(touch); +// } + +// private void OnToolSelected(PenWaveToolType toolType) +// { +// Tizen.Log.Info("NUI", $"OnToolSelected {toolType}\n"); +// SelectTool(toolType); +// } + +// public PenWaveToolType GetCurrentToolType() => currentTool?.Type ?? PenWaveToolType.Pencil; +// } +// } \ No newline at end of file diff --git a/src/Tizen.NUI.PenWave/src/backup/Tools/ToolPickerView.cs b/src/Tizen.NUI.PenWave/src/backup/Tools/ToolPickerView.cs new file mode 100644 index 00000000000..fcdebc4f392 --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/backup/Tools/ToolPickerView.cs @@ -0,0 +1,150 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class ToolPickerView : View +// { +// private ToolManager _toolManager; +// private Dictionary _toolUIs; +// private PopupManager _popupManager; + +// public ToolPickerView(PWCanvasView canvasView) +// { +// _toolManager = canvasView.ToolManager; +// EventBus.Subscribe("ToolChanged", OnToolChanged); +// _toolUIs = new Dictionary(); + +// InitializeUI(); +// } + +// private void InitializeUI() +// { +// WidthResizePolicy = ResizePolicyType.FillToParent; +// HeightResizePolicy = ResizePolicyType.FillToParent; + +// var rootView = new View +// { +// WidthResizePolicy = ResizePolicyType.FillToParent, +// HeightResizePolicy = ResizePolicyType.FillToParent, +// Layout = new LinearLayout() +// { +// HorizontalAlignment = HorizontalAlignment.Center, +// VerticalAlignment = VerticalAlignment.Top, +// LinearOrientation = LinearLayout.Orientation.Vertical, +// } +// }; + +// var pickerView = new View +// { +// CornerRadius = new Vector4(10, 10, 10, 10), +// BackgroundImage = FrameworkInformation.ResourcePath + "images/" + "light" + "/menu_bg.png", +// WidthSpecification = LayoutParamPolicies.WrapContent, +// HeightSpecification = LayoutParamPolicies.WrapContent, +// Layout = new LinearLayout +// { +// VerticalAlignment = VerticalAlignment.Center, +// HorizontalAlignment = HorizontalAlignment.Center +// }, +// }; + +// var popupView = new View +// { +// WidthSpecification = LayoutParamPolicies.WrapContent, +// HeightSpecification = LayoutParamPolicies.WrapContent, +// Layout = new LinearLayout +// { +// VerticalAlignment = VerticalAlignment.Center, +// HorizontalAlignment = HorizontalAlignment.Center +// } +// }; + +// _popupManager = new PopupManager(popupView); + +// foreach (var tool in _toolManager.Tools) +// { +// tool.Value.SetPopupManager(_popupManager); +// var toolUI = tool.Value.GetUI(); +// if (_toolUIs.TryAdd(tool.Key, toolUI)) +// { +// pickerView.Add(toolUI); +// } +// } +// rootView.Add(pickerView); +// Add(rootView); +// Add(popupView); + +// TouchEvent += OnTouchEvent; +// } + +// private bool OnTouchEvent(object sender, View.TouchEventArgs args) +// { +// IconStateManager.Instance.CurrentPressedIcon = null; +// _popupManager.HidePopup(); +// return false; +// } + +// public void ShowPopup(View contentView, Position2D position) +// { +// _popupManager.ShowPopup(contentView, position); +// } + +// public void HidePopup() +// { +// _popupManager.HidePopup(); +// } + + +// private void OnToolChanged(object toolType) +// { +// Tizen.Log.Info("NUI", $"OnToolChanged {toolType}\n"); +// _popupManager.HidePopup(); +// } + + +// public void ShowTool(PenWaveToolType type) +// { +// if (_toolUIs.TryGetValue(type, out var toolView)) +// { +// Add(toolView); +// } +// } + +// public void HideTool(PenWaveToolType type) +// { +// if (_toolUIs.TryGetValue(type, out var toolView)) +// { +// Remove(toolView); +// } +// } + +// public void CustomizeToolUI(PenWaveToolType toolType, View customUI) +// { +// HideTool(toolType); +// if (_toolUIs.TryAdd(toolType, customUI)) +// { +// Add(customUI); +// } +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/public/CanvasUIManager.cs b/src/Tizen.NUI.PenWave/src/public/CanvasUIManager.cs deleted file mode 100644 index fd9c355d250..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/CanvasUIManager.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class CanvasUIManager - { - private PWCanvasView canvasView; - - - public CanvasUIManager(PWCanvasView canvasView) - { - this.canvasView = canvasView; - InitializeUI(); - } - - private void InitializeUI() - { - // 기본 UI 구성 로직 - canvasView.WidthResizePolicy = ResizePolicyType.FillToParent; - canvasView.HeightResizePolicy = ResizePolicyType.FillToParent; - } - - public void UpdateUI() - { - // 캔버스 상태에 따라 UI 갱신 - } - - } -} \ No newline at end of file diff --git a/src/Tizen.NUI.PenWave/src/public/Common/PWConstants.cs b/src/Tizen.NUI.PenWave/src/public/Common/PWConstants.cs index 0b924a0f885..978d4c3b89b 100644 --- a/src/Tizen.NUI.PenWave/src/public/Common/PWConstants.cs +++ b/src/Tizen.NUI.PenWave/src/public/Common/PWConstants.cs @@ -23,12 +23,38 @@ internal struct FrameworkInformation public readonly static string ResourcePath = "/usr/share/dotnet.tizen/framework/res/"; } - public enum PenWaveToolType : int + public enum PWToolType : int { Pencil, Eraser, - Select, + Selection, Scale, Canvas, } + + public enum PWBrushType : int + { + Stroke, + VarStroke, + DotBrush, + SprayBrush, + DashedLine, + Highlighter, + VarStrokeInc, + SoftBrush, + SharpBrush + } + + public enum PWSelectionType : int + { + Move, + Scale, + Rotate, + } + + public enum PWEraserType : int + { + Partial, + Full, + } } \ No newline at end of file diff --git a/src/Tizen.NUI.PenWave/src/public/EventBus.cs b/src/Tizen.NUI.PenWave/src/public/EventBus.cs deleted file mode 100644 index fb0ca4c0391..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/EventBus.cs +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.Collections.Generic; - -namespace Tizen.NUI.PenWave -{ - public static class EventBus - { - private static readonly Dictionary> events = new(); - - public static void Subscribe(string eventName, Action callback) - { - if (events.ContainsKey(eventName)) - events[eventName] += callback; - else - events[eventName] = callback; - } - - public static void Publish(string eventName, object eventArgs = null) - { - if (events.TryGetValue(eventName, out var action)) - action.Invoke(eventArgs); - } - } -} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/IToolActionHandler.cs b/src/Tizen.NUI.PenWave/src/public/IToolAction.cs similarity index 71% rename from src/Tizen.NUI.PenWave/src/public/Tools/IToolActionHandler.cs rename to src/Tizen.NUI.PenWave/src/public/IToolAction.cs index 3aafff4a2bb..92a22889560 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/IToolActionHandler.cs +++ b/src/Tizen.NUI.PenWave/src/public/IToolAction.cs @@ -15,20 +15,11 @@ * */ -using System; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; namespace Tizen.NUI.PenWave { - public interface IToolActionHandler + public interface IToolAction { - void HandleInput(Touch touch); - void Activate(); - void Deactivate(); + void Execute(); } } - - diff --git a/src/Tizen.NUI.PenWave/src/public/PWCanvasView.cs b/src/Tizen.NUI.PenWave/src/public/PWCanvasView.cs index 717278ed267..871aee59a53 100644 --- a/src/Tizen.NUI.PenWave/src/public/PWCanvasView.cs +++ b/src/Tizen.NUI.PenWave/src/public/PWCanvasView.cs @@ -28,8 +28,7 @@ public class PWCanvasView : DirectRenderingGLView private CanvasRenderer renderer; private PropertyNotification propertyNotification; - public ToolManager ToolManager {get; private set;} - public event Action OnPageChanged; + internal ToolManager ToolManager {get; private set;} public PWCanvasView() : base(DirectRenderingGLView.ColorFormat.RGBA8888, DirectRenderingGLView.BackendMode.UnsafeDirectRendering) { @@ -48,17 +47,26 @@ public static PWCanvasView CreateDefaultCanvas() { var canvasView = new PWCanvasView(); - var canvasTool = ToolFactory.CreateTool(PenWaveToolType.Canvas); - var pencilTool = ToolFactory.CreateTool(PenWaveToolType.Pencil); - var eraserTool = ToolFactory.CreateTool(PenWaveToolType.Eraser); - var selectTool = ToolFactory.CreateTool(PenWaveToolType.Select); + // var canvasTool = ToolFactory.CreateTool(PenWaveToolType.Canvas); + // var pencilTool = ToolFactory.CreateTool(PenWaveToolType.Pencil); + // var eraserTool = ToolFactory.CreateTool(PenWaveToolType.Eraser); + // var selectTool = ToolFactory.CreateTool(PenWaveToolType.Select); - canvasView.ToolManager.RegisterTool(canvasTool); - canvasView.ToolManager.RegisterTool(pencilTool); - canvasView.ToolManager.RegisterTool(eraserTool); - canvasView.ToolManager.RegisterTool(selectTool); + // canvasView.ToolManager.RegisterTool(canvasTool); + // canvasView.ToolManager.RegisterTool(pencilTool); + // canvasView.ToolManager.RegisterTool(eraserTool); + // canvasView.ToolManager.RegisterTool(selectTool); - canvasView.ToolManager.SelectTool(pencilTool.Type); + // canvasView.ToolManager.SelectTool(pencilTool.Type); + + var pencilTool = new PencilTool(); + var selectionTool = new SelectionTool(); + var eraserTool = new EraserTool(); + canvasView.AddTool(pencilTool); + canvasView.AddTool(eraserTool); + canvasView.AddTool(selectionTool); + + canvasView.SelectTool(pencilTool.Type); return canvasView; } @@ -89,6 +97,16 @@ private void InitializeCanvas() }; } + public void AddTool(ToolBase tool) + { + ToolManager.RegisterTool(tool); + } + + public ToolBase GetTool(PWToolType toolType) + { + return ToolManager.GetTool(toolType); + } + public void ClearCanvas() { renderer.ClearCanvas(); @@ -99,7 +117,7 @@ public void AddPicture(string path, Size2D size, Position2D position) renderer.AddPicture(path); } - public void SelectTool(PenWaveToolType toolType) + public void SelectTool(PWToolType toolType) { ToolManager.SelectTool(toolType); } diff --git a/src/Tizen.NUI.PenWave/src/public/PWEngine.cs b/src/Tizen.NUI.PenWave/src/public/PWEngine.cs index 95ecb69850f..e5b7feff005 100644 --- a/src/Tizen.NUI.PenWave/src/public/PWEngine.cs +++ b/src/Tizen.NUI.PenWave/src/public/PWEngine.cs @@ -23,19 +23,6 @@ public class PWEngineDelegates public static class PWEngine { - public enum BrushType - { - Stroke, - VarStroke, - DotBrush, - SprayBrush, - DashedLine, - Highlighter, - VarStrokeInc, - SoftBrush, - SharpBrush - } - public const string Lib = "libhand-drawing-engine.so"; [global::System.Runtime.InteropServices.DllImport(Lib, EntryPoint = "InitializeGL")] diff --git a/src/Tizen.NUI.PenWave/src/public/PencilToolAction.cs b/src/Tizen.NUI.PenWave/src/public/PencilToolAction.cs new file mode 100644 index 00000000000..5746b56d87f --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/public/PencilToolAction.cs @@ -0,0 +1,40 @@ +// /* +// * Copyright(c) 2024 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; +// using System.ComponentModel; +// using System.Collections.Generic; +// using Tizen.NUI; +// using Tizen.NUI.BaseComponents; + +// namespace Tizen.NUI.PenWave +// { +// public class PencilToolAction : IToolAction +// { +// private readonly PencilTool pencilTool; + +// public PencilToolAction(PencilTool pencilTool) +// { +// this.pencilTool = pencilTool; +// } + +// public void Execute() +// { +// pencilTool.Execute(); +// } +// } +// } diff --git a/src/Tizen.NUI.PenWave/src/public/PopupManager.cs b/src/Tizen.NUI.PenWave/src/public/PopupManager.cs deleted file mode 100644 index f5cecb0bb16..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/PopupManager.cs +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright(c) 2024 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; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class PopupManager - { - private View popupView; - private View parentView; - - public PopupManager(View parentView) - { - this.parentView = parentView; - this.parentView.TouchEvent += (s, e) => { return true; }; // To prevent touch event propagation to parent view. - } - - public void ShowPopup(View contentView, Position2D position) - { - if (popupView != null) HidePopup(); - - popupView = new View(); - popupView.Add(contentView); - parentView.Position2D = position; - parentView.Add(popupView); - } - - public void HidePopup() - { - if (popupView != null) - { - parentView.Remove(popupView); - popupView = null; - } - } - } - -} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/BackgroundColorIcon.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/BackgroundColorIcon.cs deleted file mode 100644 index ecf5315ec03..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/BackgroundColorIcon.cs +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class BackgroundColorIcon : Icon - { - private readonly string mColorHex; - private readonly Color mColor; - - public BackgroundColorIcon(Tizen.NUI.Color color) : base() - { - mColorHex = ToHex(color); - mColor = color; - - IconStateNormalColor = mColorHex; - IconStateSelectedColor = mColorHex; - IconStatePressedColor = mColorHex; - IconStateDisabledColor = mColorHex; - - InitializeIcon(); - } - - protected override string GetDefaultImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/color_icon_base.png"; - } - - protected override string GetSelectedImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; - } - - public override bool OnIconClicked(object sender, View.TouchEventArgs args) - { - if (base.OnIconClicked(sender, args)) - { - PWEngine.CanvasSetColor(GetColorHex(), 1.0f); - } - return true; - } - - 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}"; - } - - public string GetColorHex() => mColorHex; - } -} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/CanvasTool.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/CanvasTool.cs deleted file mode 100644 index e8d9b6aaf39..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/CanvasTool.cs +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class CanvasTool : ToolBase - { - public override PenWaveToolType Type => PenWaveToolType.Canvas; - - private static readonly string s_popupBgUrl = $"{FrameworkInformation.ResourcePath}images/light/canvas_popup_bg.png"; - private static readonly List s_bgColors = new List - { - new Color("#FFFEFE"), - new Color("#F0F0F0"), - new Color("#B7B7B7"), - new Color("#E3F2FF"), - new Color("#202022"), - new Color("#515151"), - new Color("#17234D"), - new Color("#090E21"), - }; - - private Icon paletteIcon; - private Icon gridIcon; - - public CanvasTool() : base(new CanvasToolActionHandler()) - { - paletteIcon = new PaletteIcon(); - AddIcon(paletteIcon); - - gridIcon = new GridIcon(); - AddIcon(gridIcon); - - AddIcon(new UndoIcon()); - AddIcon(new RedoIcon()); - AddIcon(new ClearIcon()); - } - - protected override void OnIconSelected(object sender) - { - Tizen.Log.Info("NUI", $"OnIconSelected\n"); - if (sender is PaletteIcon) - { - CreateColorIconsView(); - } - else - { - PopupManager.HidePopup(); - } - } - - private void CreateColorIconsView() - { - var view = new ImageView - { - BackgroundImage = s_popupBgUrl, - WidthSpecification = LayoutParamPolicies.WrapContent, - HeightSpecification = LayoutParamPolicies.WrapContent, - Layout = new GridLayout { Columns = 1, RowSpacing = 4 } - }; - AddIconsToView(view, s_bgColors, color => new BackgroundColorIcon(color)); - Position2D position = new Position2D((int)paletteIcon.ScreenPosition.X, (int)paletteIcon.ScreenPosition.Y + 60); - PopupManager.ShowPopup(view, position); - } - - private void AddIconsToView(View rootView, IEnumerableitems, Func iconFactory) - { - var view = new View - { - Layout = new GridLayout { Columns = 4, ColumnSpacing = 8, RowSpacing = 8 }, - }; - foreach (var item in items) - { - var icon = iconFactory(item); - view.Add(icon); - } - - rootView.Add(view); - } - - } -} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/ClearIcon.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/ClearIcon.cs deleted file mode 100644 index 731ff20c081..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/ClearIcon.cs +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright(c) 2024 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 Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class ClearIcon : Icon - { - public ClearIcon() : base() - { - InitializeIcon(); - } - - protected override string GetDefaultImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/icon_clear.png"; - } - - protected override string GetSelectedImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; - } - - public override bool OnIconClicked(object sender, View.TouchEventArgs args) - { - if (base.OnIconClicked(sender, args)) - { - Tizen.Log.Info("NUI", $"ClearIcon\n"); - PWEngine.ClearCurrentCanvas(); - } - return true; - } - - } -} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/GridIcon.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/GridIcon.cs deleted file mode 100644 index c87f5572e28..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/GridIcon.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright(c) 2024 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 Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class GridIcon : Icon - { - public enum GridDensityType - { - None = 0, - Small = 1, - Medium = 2, - Large = 4 - } - - public GridIcon() : base() - { - InitializeIcon(); - } - - protected override string GetDefaultImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/icon_grid.png"; - } - - protected override string GetSelectedImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; - } - - public override bool OnIconClicked(object sender, View.TouchEventArgs args) - { - if (base.OnIconClicked(sender, args)) - { - Tizen.Log.Info("NUI", $"GridIcon\n"); - PWEngine.ToggleGrid((int)GridDensityType.Small); - } - return true; - } - - } -} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/PaletteIcon.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/PaletteIcon.cs deleted file mode 100644 index 638f852b6ce..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/PaletteIcon.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright(c) 2024 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 Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class PaletteIcon : Icon - { - public PaletteIcon() : base() - { - InitializeIcon(); - } - - protected override string GetDefaultImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/icon_color_palette.png"; - } - - protected override string GetSelectedImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; - } - - public override bool OnIconClicked(object sender, View.TouchEventArgs args) - { - if (base.OnIconClicked(sender, args)) - { - Tizen.Log.Info("NUI", $"PaletteIcon\n"); - } - return true; - } - - } -} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/RedoIcon.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/RedoIcon.cs deleted file mode 100644 index a49ff545f48..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/RedoIcon.cs +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright(c) 2024 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 Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class RedoIcon : Icon - { - public RedoIcon() : base() - { - InitializeIcon(); - } - - protected override string GetDefaultImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/icon_redo.png"; - } - - protected override string GetSelectedImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; - } - - public override bool OnIconClicked(object sender, View.TouchEventArgs args) - { - if (base.OnIconClicked(sender, args)) - { - Tizen.Log.Info("NUI", $"RedoIcon\n"); - PWEngine.Redo(); - } - return true; - } - - } -} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/UndoIcon.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/UndoIcon.cs deleted file mode 100644 index 9576fd28fca..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/UndoIcon.cs +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright(c) 2024 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 Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class UndoIcon : Icon - { - public UndoIcon() : base() - { - InitializeIcon(); - } - - protected override string GetDefaultImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/icon_undo.png"; - } - - protected override string GetSelectedImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; - } - - public override bool OnIconClicked(object sender, View.TouchEventArgs args) - { - if (base.OnIconClicked(sender, args)) - { - Tizen.Log.Info("NUI", $"UndoIcon\n"); - PWEngine.Undo(); - } - return true; - } - - } -} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserIcon.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserIcon.cs deleted file mode 100644 index 726c6d9ad88..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserIcon.cs +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class EraserIcon : Icon - { - public EraserIcon() : base() - { - InitializeIcon(); - } - - protected override string GetDefaultImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/icon_eraser.png"; - } - - protected override string GetSelectedImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; - } - - public override bool OnIconClicked(object sender, View.TouchEventArgs args) - { - base.OnIconClicked(sender, args); - return true; - } - } -} 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 358b4af41d3..cb12103cdca 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserTool.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserTool.cs @@ -25,11 +25,84 @@ namespace Tizen.NUI.PenWave { public class EraserTool : ToolBase { - public override PenWaveToolType Type => PenWaveToolType.Eraser; + public override PWToolType Type => PWToolType.Eraser; - public EraserTool() : base(new EraserToolActionHandler()) + private PWEraserType currentEraserType; + private float radiusEraser = 48.0f; + + public PWEraserType EraserType + { + get => currentEraserType; + set + { + currentEraserType = value; + } + } + + public float EraserSize { - AddIcon(new EraserIcon()); + get => radiusEraser; + set + { + radiusEraser = value; + } } + + + public override void Activate() + { + + } + + public override void Deactivate() + { + EndDrawing(); + } + + public override void HandleInput(Touch touch) + { + if (touch == null || touch.GetPointCount() == 0) return; + + uint pointStateIndex = 0; + uint touchTime = touch.GetTime(); + + List touchPositionList = new List(); + for (uint i = 0; i < touch.GetPointCount(); ++i) + { + touchPositionList.Add(touch.GetLocalPosition(i)); + } + + Vector2 position = touchPositionList[(int)pointStateIndex]; + switch (touch.GetState(pointStateIndex)) + { + case PointStateType.Down: + StartDrawing(position, touchTime); + break; + case PointStateType.Motion: + ContinueDrawing(position, touchTime); + break; + case PointStateType.Up: + case PointStateType.Leave: + EndDrawing(); + break; + } + } + + private void StartDrawing(Vector2 position, uint touchTime) + { + PWEngine.EraseShape((int)position.X, (int)position.Y, radiusEraser, (currentEraserType == PWEraserType.Partial)); + } + + private void ContinueDrawing(Vector2 position, uint touchTime) + { + PWEngine.EraseShape((int)position.X, (int)position.Y, radiusEraser, (currentEraserType == PWEraserType.Partial)); + } + + private void EndDrawing() + { + PWEngine.StopErasing(); + } + } } + diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserToolActionHandler.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserToolActionHandler.cs deleted file mode 100644 index 78125786dd5..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Eraser/EraserToolActionHandler.cs +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class EraserToolActionHandler : IToolActionHandler - { - enum Mode - { - Partial, - Full - } - - private Mode mode = Mode.Partial; - private float radiusEraser = 48; // 지우개 사이즈 설정 가능해야 함 - - public void Activate() - { - } - - public void Deactivate() - { - EndDrawing(); - } - - public void HandleInput(Touch touch) - { - if (touch == null || touch.GetPointCount() == 0) return; - - uint pointStateIndex = 0; - uint touchTime = touch.GetTime(); - - List touchPositionList = new List(); - for (uint i = 0; i < touch.GetPointCount(); ++i) - { - touchPositionList.Add(touch.GetLocalPosition(i)); - } - - Vector2 position = touchPositionList[(int)pointStateIndex]; - switch (touch.GetState(pointStateIndex)) - { - case PointStateType.Down: - StartDrawing(position, touchTime); - break; - case PointStateType.Motion: - ContinueDrawing(position, touchTime); - break; - case PointStateType.Up: - case PointStateType.Leave: - EndDrawing(); - break; - } - } - - private void StartDrawing(Vector2 position, uint touchTime) - { - PWEngine.EraseShape((int)position.X, (int)position.Y, radiusEraser, (mode == Mode.Partial)); - } - - private void ContinueDrawing(Vector2 position, uint touchTime) - { - PWEngine.EraseShape((int)position.X, (int)position.Y, radiusEraser, (mode == Mode.Partial)); - } - - private void EndDrawing() - { - PWEngine.StopErasing(); - } - - } -} - - diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Icon.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Icon.cs deleted file mode 100644 index 2be2d383e08..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Icon.cs +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - // Abstract class representing an icon that extends ImageView. - public abstract class Icon : ImageView - { - // Enumeration for the Icon states. - public enum IconState - { - // Icon Normal State - Normal = 0, - // Icon Pressed State - Pressed, - // Icon Selected State - Selected, - // Icon Disabled State - Disabled - } - - // Properties to define colors for different states. - public string IconStateNormalColor { get; set; } = "#17234d"; - public string IconStateSelectedColor { get; set; } = "#FF6200"; - public string IconStatePressedColor { get; set; } = "#FF6200"; - public string IconStateDisabledColor { get; set; } = "#CACACA"; - - // Event handler for when the icon is selected. - public event Action IconSelected; - - // Image views for the default and selected states of the icon. - public ImageView DefaultImage; - public ImageView SelectedImage; - - // Default size of the icon. - private int defaultSize = 48; - // Current state of the icon. - private IconState currentState; - - // Property to get and set the current state of the icon. - public IconState CurrentState - { - get => currentState; - set - { - currentState = value; - UpdateIconState(); // Update the icon's appearance based on the new state. - } - } - - // Constructor for the Icon class. - public Icon() - { - currentState = IconState.Normal; // Set the initial state to normal. - GrabTouchAfterLeave = true; - - // Set layout properties to center the icon within its parent. - Layout = new LinearLayout() - { - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - }; - // Set the default size of the icon. - this.Size2D = new Size2D(defaultSize, defaultSize); - - // Attach a touch event handler to handle click events on the icon. - this.TouchEvent += OnIconClicked; - } - - // Override the Dispose method to clean up resources. - protected override void Dispose(DisposeTypes type) - { - base.Dispose(type); - // Dispose of the default and selected image views. - DefaultImage?.Dispose(); - SelectedImage?.Dispose(); - } - - // Method to initialize the icon with default and selected images. - protected void InitializeIcon() - { - // Create a default image view with the specified properties. - DefaultImage = new ImageView - { - WidthResizePolicy = ResizePolicyType.FillToParent, - HeightResizePolicy = ResizePolicyType.FillToParent, - Color = new Color(IconStateNormalColor), - ResourceUrl = GetDefaultImageUrl() // Get the URL for the default image. - }; - // Add the default image view to the icon. - this.Add(DefaultImage); - - // Create a selected image view with the specified properties. - SelectedImage = new ImageView - { - WidthResizePolicy = ResizePolicyType.FillToParent, - HeightResizePolicy = ResizePolicyType.FillToParent, - ResourceUrl = GetSelectedImageUrl() // Get the URL for the selected image. - }; - // Add the selected image view to the default image view. - DefaultImage.Add(SelectedImage); - // Hide the selected image view initially. - SelectedImage.Hide(); - } - - // Method to update the icon's appearance based on its current state. - public virtual void UpdateIconState() - { - switch (currentState) - { - case IconState.Normal: - // Hide the selected image and set the color of the default image to normal color. - SelectedImage.Hide(); - DefaultImage.Color = new Color(IconStateNormalColor); - break; - case IconState.Selected: - // Show the selected image and set the color of the default image to selected color. - SelectedImage.Show(); - DefaultImage.Color = new Color(IconStateSelectedColor); - break; - case IconState.Pressed: - // Set the color of the default image to pressed color. - DefaultImage.Color = new Color(IconStatePressedColor); - break; - case IconState.Disabled: - // Set the color of the default image to disabled color and hide the selected image. - DefaultImage.Color = new Color(IconStateDisabledColor); - SelectedImage.Hide(); - break; - default: - break; - } - } - - // Method to handle touch events on the icon. - public virtual bool OnIconClicked(object sender, View.TouchEventArgs args) - { - if (args.Touch.GetState(0) == PointStateType.Down) - { - // Set the currently selected icon to this instance and invoke the IconSelected event. - IconStateManager.Instance.CurrentPressedIcon = this; - IconSelected?.Invoke(sender); - return true; - } - else if (args.Touch.GetState(0) == PointStateType.Up) - { - CurrentState = IconState.Selected; - } - return false; - } - - public void SetDisabled(bool isDisabled) - { - CurrentState = isDisabled ? IconState.Disabled : IconState.Normal; - } - - public bool IsSelected => CurrentState == IconState.Selected; - - // Abstract methods to be implemented by derived classes to return the URLs for default and selected images. - protected abstract string GetDefaultImageUrl(); - protected abstract string GetSelectedImageUrl(); - } -} \ No newline at end of file diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/IconStateManager.cs b/src/Tizen.NUI.PenWave/src/public/Tools/IconStateManager.cs deleted file mode 100644 index 336f948b01f..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/IconStateManager.cs +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public sealed class IconStateManager - { - private static readonly IconStateManager instance = new IconStateManager(); - - private Icon _currentPressedIcon; - - private IconStateManager() {} - - public static IconStateManager Instance => instance; - - public Icon CurrentPressedIcon - { - get => _currentPressedIcon; - set - { - if (_currentPressedIcon != null && _currentPressedIcon != value) - { - _currentPressedIcon.CurrentState = Icon.IconState.Normal; - } - _currentPressedIcon = value; - if (_currentPressedIcon != null) - { - _currentPressedIcon.CurrentState = Icon.IconState.Pressed; - } - } - } - } -} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/BrushIcon.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/BrushIcon.cs deleted file mode 100644 index c6b46e5c63b..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/Brush/BrushIcon.cs +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class BrushIcon : Icon - { - private PWEngine.BrushType brushType; - private readonly IBrushStrategy brushStrategy; - - private static readonly Dictionary IconMap = new Dictionary - { - { PWEngine.BrushType.Stroke, "icon_pencil" }, - { PWEngine.BrushType.VarStroke, "icon_varstroke_dec" }, - { PWEngine.BrushType.VarStrokeInc, "icon_varstroke_inc" }, - { PWEngine.BrushType.SprayBrush, "icon_spray" }, - { PWEngine.BrushType.DotBrush, "icon_dot" }, - { PWEngine.BrushType.DashedLine, "icon_dashed_line" }, - { PWEngine.BrushType.Highlighter, "icon_highlighter" }, - { PWEngine.BrushType.SoftBrush, "icon_soft_brush" }, - { PWEngine.BrushType.SharpBrush, "icon_sharp_brush" }, - }; - - private ImageView mImgView; - public BrushIcon(PWEngine.BrushType brushType) : base() - { - brushStrategy = BrushStrategyFactory.GetBrushStrategy(brushType); - - this.brushType = brushType; - - mImgView = new ImageView(); - mImgView.Size2D = new Size2D(48, 48); - - InitializeIcon(); - } - - protected override string GetDefaultImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/{GetIconUrl(brushType)}.png"; - } - - protected override string GetSelectedImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; - } - - private string GetIconUrl(PWEngine.BrushType brushType) - { - return IconMap.ContainsKey(brushType) ? IconMap[brushType] : string.Empty; - } - - - public PWEngine.BrushType GetBrushType() => brushType; - - - public override bool OnIconClicked(object sender, View.TouchEventArgs args) - { - if (base.OnIconClicked(sender, args)) - { - brushStrategy.ApplyBrushSettings(); - } - return true; - } - - } -} \ No newline at end of file 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 f1585161b7f..91815e171a0 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,21 +23,25 @@ namespace Tizen.NUI.PenWave { - public static class BrushStrategyFactory + public sealed class BrushStrategyFactory { - public static IBrushStrategy GetBrushStrategy(PWEngine.BrushType brushType) + private static readonly BrushStrategyFactory instance = new BrushStrategyFactory(); + + public static BrushStrategyFactory Instance => instance; + + public IBrushStrategy GetBrushStrategy(PWBrushType brushType) { return brushType switch { - PWEngine.BrushType.Stroke => new StrokeBrush(), - PWEngine.BrushType.VarStroke => new VarStrokeBrush(), - PWEngine.BrushType.VarStrokeInc => new VarStrokeIncBrush(), - PWEngine.BrushType.SprayBrush => new SprayBrush(), - PWEngine.BrushType.DotBrush => new DotBrush(), - PWEngine.BrushType.DashedLine => new DashedLineBrush(), - PWEngine.BrushType.Highlighter => new HighlighterBrush(), - PWEngine.BrushType.SoftBrush => new SoftBrush(), - PWEngine.BrushType.SharpBrush => new SharpBrush(), + PWBrushType.Stroke => new StrokeBrush(), + PWBrushType.VarStroke => new VarStrokeBrush(), + PWBrushType.VarStrokeInc => new VarStrokeIncBrush(), + PWBrushType.SprayBrush => new SprayBrush(), + PWBrushType.DotBrush => new DotBrush(), + PWBrushType.DashedLine => new DashedLineBrush(), + PWBrushType.Highlighter => new HighlighterBrush(), + PWBrushType.SoftBrush => new SoftBrush(), + PWBrushType.SharpBrush => new SharpBrush(), _ => throw new ArgumentOutOfRangeException(nameof(brushType), brushType, null) }; } 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 ffbd409ce88..b3858f67f00 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 @@ -25,6 +25,6 @@ namespace Tizen.NUI.PenWave { public interface IBrushStrategy { - void ApplyBrushSettings(); + public void ApplyBrushSettings(); } } diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/ColorIcon.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/ColorIcon.cs deleted file mode 100644 index 6c9932b4de5..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/ColorIcon.cs +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class ColorIcon : Icon - { - private readonly string mColorHex; - private readonly Color mColor; - - - - public ColorIcon(Tizen.NUI.Color color) : base() - { - mColorHex = ToHex(color); - mColor = color; - IconStateNormalColor = mColorHex; - IconStateSelectedColor = mColorHex; - IconStatePressedColor = mColorHex; - IconStateDisabledColor = mColorHex; - InitializeIcon(); - } - - protected override string GetDefaultImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/color_icon_base.png"; - } - - protected override string GetSelectedImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; - } - - public override bool OnIconClicked(object sender, View.TouchEventArgs args) - { - if (base.OnIconClicked(sender, args)) - { - PWEngine.SetStrokeColor(mColorHex, 1.0f); - } - return true; - } - - 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}"; - } - - public Color GetColor() => mColor; - } -} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PenInk.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PenInk.cs deleted file mode 100644 index 29448e57791..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PenInk.cs +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using System.Linq; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class PenInk - { - public List Colors { get; private set; } - public List Sizes { get; private set; } - public List BrushTypes { get; private set; } - - private Color mCurrentColor; - private float mCurrentSize; - private PWEngine.BrushType mCurrentBrushType; - - private List InitializeDefaultColors() - { - return new List - { - new Color("#F7B32C"), - new Color("#FD5703"), - new Color("#DA1727"), - new Color("#FF00A8"), - new Color("#74BFB8"), - new Color("#4087C5"), - new Color("#070044"), - new Color("#0E0E0E"), - }; - } - - private List InitializeDefaultSizes() - { - return new List { 3.0f, 6.5f, 12.0f }; - } - - private List InitializeDefaultBrushTypes() - { - List brushTypes = new List(); - foreach (PWEngine.BrushType item in Enum.GetValues(typeof(PWEngine.BrushType))) - { - brushTypes.Add(item); - } - return brushTypes; - } - - public PenInk() - { - Colors = InitializeDefaultColors(); - Sizes = InitializeDefaultSizes(); - BrushTypes = InitializeDefaultBrushTypes(); - mCurrentColor = Colors.First(); - mCurrentSize = Sizes.First(); - mCurrentBrushType = BrushTypes.First(); - } - - public PenInk(List colors, List sizes, List brushTypes) - { - Colors = colors; - Sizes = sizes; - BrushTypes = BrushTypes; - - mCurrentColor = Colors.First(); - mCurrentSize = Sizes.First(); - mCurrentBrushType = BrushTypes.First(); - } - - public void SetCurrentColor(Color color) - { - mCurrentColor = color; - } - - public void SetCurrentSize(float size) - { - mCurrentSize = size; - } - - public void SetCurrentBrushType(PWEngine.BrushType brushType) - { - mCurrentBrushType = brushType; - } - - public Color GetCurrentColor() => mCurrentColor; - public float GetCurrentSize() => mCurrentSize; - public PWEngine.BrushType GetCurrentBrushType() => mCurrentBrushType; - - } -} \ No newline at end of file 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 d8049daf38e..c3ce9fb2608 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PencilTool.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PencilTool.cs @@ -25,139 +25,139 @@ namespace Tizen.NUI.PenWave { public class PencilTool : ToolBase { - public override PenWaveToolType Type => PenWaveToolType.Pencil; + public override PWToolType Type => PWToolType.Pencil; - private static readonly string popupBgUrl = $"{FrameworkInformation.ResourcePath}images/light/canvas_popup_bg.png"; - - private PenInk ink; - private uint mCurrentShapeId; - private bool mIsDrawing = false; - - private Icon pencilIcon; - private Icon sizeIcon; - private Icon colorIcon; - - - public PencilTool() : base(new PencilToolActionHandler()) + private enum ErrorShapeAddPointsType { - ink = new PenInk(); - - InitializePencilTool(); + noError, + overflowShape, + noCanvasSet, + noShapesInCanvas, + badIdShape, + drawableIsNotAShape, + drawableIsNotALine, + drawingCanceled } - public PencilTool(PenInk penInk) : base(new PencilToolActionHandler()) - { - ink = penInk ?? new PenInk(); - - InitializePencilTool(); - } + private PWBrushType currentBrushType; + private Color currentColor; + private float currentSize; + private uint currentShapeId; - private void InitializePencilTool() + public PWBrushType BrushType { - pencilIcon = new BrushIcon(PWEngine.BrushType.Stroke); // 현재 선택된 브러쉬 타입으로 업데이트 필요 - AddIcon(pencilIcon); - - sizeIcon = new SizeIcon(12.0f); - AddIcon(sizeIcon); - - colorIcon = new ColorIcon(Color.Black); // 현재 선택된 색상으로 업데이트 필요 - AddIcon(colorIcon); + get => currentBrushType; + set + { + currentBrushType = value; + SetBrushType(currentBrushType); + } } - protected override void OnIconSelected(object sender) + public Color BrushColor { - base.OnIconSelected(sender); - if (sender is BrushIcon) + get => currentColor; + set { - Tizen.Log.Info("NUI", $"BrushIcon Selected\n"); - CreateBrushIconsView(); + currentColor = value; + PWEngine.SetStrokeColor(ToHex(currentColor), 1.0f); } - else if (sender is SizeIcon) - { - Tizen.Log.Info("NUI", $"SizeIcon Selected\n"); - CreateSizeIconsView(); - } - else if (sender is ColorIcon) + } + + public float BrushSize + { + get => currentSize; + set { - Tizen.Log.Info("NUI", $"ColorIcon Selected\n"); - CreateColorIconsView(); + currentSize = value; + PWEngine.SetStrokeSize(currentSize); } } - private void CreateBrushIconsView() + private string ToHex(Color color) { - var view = new ImageView - { - BackgroundImage = popupBgUrl, - WidthSpecification = LayoutParamPolicies.WrapContent, - HeightSpecification = LayoutParamPolicies.WrapContent, - Layout = new GridLayout { Columns = 1, RowSpacing = 4 } - }; - AddIcons(view, ink.BrushTypes, brushType => new BrushIcon(brushType)); - Position2D position = new Position2D((int)pencilIcon.ScreenPosition.X, (int)pencilIcon.ScreenPosition.Y + 60); - PopupManager.ShowPopup(view, position); + 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}"; } - private void CreateSizeIconsView() + private void SetBrushType(PWBrushType brushType) { - var view = new ImageView + var brushStragety = BrushStrategyFactory.Instance.GetBrushStrategy(brushType); + if (brushStragety!= null) { - BackgroundImage = popupBgUrl, - WidthSpecification = LayoutParamPolicies.WrapContent, - HeightSpecification = LayoutParamPolicies.WrapContent, - Layout = new GridLayout { Columns = 1, RowSpacing = 4 } - }; - AddIcons(view, ink.Sizes, size => new SizeIcon(size)); - Position2D position = new Position2D((int)sizeIcon.ScreenPosition.X, (int)sizeIcon.ScreenPosition.Y + 60); - PopupManager.ShowPopup(view, position); + brushStragety.ApplyBrushSettings(); + } } - private void CreateColorIconsView() + public override void Activate() { - var view = new ImageView - { - BackgroundImage = popupBgUrl, - WidthSpecification = LayoutParamPolicies.WrapContent, - HeightSpecification = LayoutParamPolicies.WrapContent, - Layout = new GridLayout { Columns = 1, RowSpacing = 4 } - }; - AddIcons(view, ink.Colors, color => new ColorIcon(color)); - Position2D position = new Position2D((int)colorIcon.ScreenPosition.X, (int)colorIcon.ScreenPosition.Y + 60); - PopupManager.ShowPopup(view, position); + } - private void AddIcons(View rootView, IEnumerableitems, Func iconFactory) + public override void Deactivate() { - var view = new View - { - Layout = new GridLayout { Columns = 4, ColumnSpacing = 16, RowSpacing = 16 }, - }; - foreach (var item in items) - { - var icon = iconFactory(item); - view.Add(icon); - icon.IconSelected += OnPopUnIconSelected; - } - rootView.Add(view); + EndDrawing(); } - private void OnPopUnIconSelected(object sender) + public override void HandleInput(Touch touch) { - if (sender is BrushIcon) + if (touch == null || touch.GetPointCount() == 0) return; + + uint pointStateIndex = 0; + uint touchTime = touch.GetTime(); + + List touchPositionList = new List(); + for (uint i = 0; i < touch.GetPointCount(); ++i) { - pencilIcon.DefaultImage.ResourceUrl = IconStateManager.Instance.CurrentPressedIcon.DefaultImage.ResourceUrl; + touchPositionList.Add(touch.GetLocalPosition(i)); } - else if (sender is SizeIcon) + + Vector2 position = touchPositionList[(int)pointStateIndex]; + switch (touch.GetState(pointStateIndex)) { - sizeIcon.DefaultImage.Size2D = IconStateManager.Instance.CurrentPressedIcon.DefaultImage.Size2D; + case PointStateType.Down: + StartDrawing(position, touchTime); + break; + case PointStateType.Motion: + ContinueDrawing(position, touchTime); + break; + case PointStateType.Up: + case PointStateType.Leave: + EndDrawing(); + break; } - else if (sender is ColorIcon) + } + + private void StartDrawing(Vector2 position, uint touchTime) + { + currentShapeId = PWEngine.BeginShapeDraw(position.X, position.Y, touchTime); + } + + private void ContinueDrawing(Vector2 position, uint touchTime) + { + if (currentShapeId > 0) { - colorIcon.DefaultImage.Color = (sender as ColorIcon).GetColor(); + var result = (ErrorShapeAddPointsType)PWEngine.DrawShape(currentShapeId, position.X, position.Y, touchTime); + if (result == ErrorShapeAddPointsType.overflowShape) + { + EndDrawing(); + StartDrawing(position, touchTime); + } + else if (result == ErrorShapeAddPointsType.drawingCanceled) + { + EndDrawing(); + } } } - } + private void EndDrawing() + { + PWEngine.EndShapeDraw(currentShapeId, 0); + currentShapeId = 0; + } + } +} -} \ No newline at end of file diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PencilToolActionHandler.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PencilToolActionHandler.cs deleted file mode 100644 index 260620618f3..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/PencilToolActionHandler.cs +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class PencilToolActionHandler : IToolActionHandler - { - - - enum ErrorShapeAddPointsType - { - noError, - overflowShape, - noCanvasSet, - noShapesInCanvas, - badIdShape, - drawableIsNotAShape, - drawableIsNotALine, - drawingCanceled - } - - private uint currentShapeId; - - public void Activate() - { - - } - - public void Deactivate() - { - EndDrawing(); - } - - public void HandleInput(Touch touch) - { - if (touch == null || touch.GetPointCount() == 0) return; - - uint pointStateIndex = 0; - uint touchTime = touch.GetTime(); - - List touchPositionList = new List(); - for (uint i = 0; i < touch.GetPointCount(); ++i) - { - touchPositionList.Add(touch.GetLocalPosition(i)); - } - - Vector2 position = touchPositionList[(int)pointStateIndex]; - switch (touch.GetState(pointStateIndex)) - { - case PointStateType.Down: - StartDrawing(position, touchTime); - break; - case PointStateType.Motion: - ContinueDrawing(position, touchTime); - break; - case PointStateType.Up: - case PointStateType.Leave: - EndDrawing(); - break; - } - } - - private void StartDrawing(Vector2 position, uint touchTime) - { - currentShapeId = PWEngine.BeginShapeDraw(position.X, position.Y, touchTime); - } - - private void ContinueDrawing(Vector2 position, uint touchTime) - { - if (currentShapeId > 0) - { - var result = (ErrorShapeAddPointsType)PWEngine.DrawShape(currentShapeId, position.X, position.Y, touchTime); - if (result == ErrorShapeAddPointsType.overflowShape) - { - EndDrawing(); - StartDrawing(position, touchTime); - } - else if (result == ErrorShapeAddPointsType.drawingCanceled) - { - EndDrawing(); - } - } - } - - private void EndDrawing() - { - PWEngine.EndShapeDraw(currentShapeId, 0); - currentShapeId = 0; - } - - } -} - - diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/SizeIcon.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/SizeIcon.cs deleted file mode 100644 index 553c53c2328..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Pencil/SizeIcon.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class SizeIcon : Icon - { - private readonly float size; - - public SizeIcon(float size) : base() - { - this.size = size; - - InitializeIcon(); - DefaultImage.Size2D = new Size2D((int)(size * 2), (int)(size * 2)); - } - - protected override string GetDefaultImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/color_icon_base.png"; - } - - protected override string GetSelectedImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; - } - - public override bool OnIconClicked(object sender, View.TouchEventArgs args) - { - if (base.OnIconClicked(sender, args)) - { - PWEngine.SetStrokeSize(GetSize()); - } - return true; - } - - public float GetSize() => size; - } -} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Select/SelectIcon.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Select/SelectIcon.cs deleted file mode 100644 index 8ba72c0ce32..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Select/SelectIcon.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class SelectIcon : Icon - { - public SelectIcon() : base() - { - - InitializeIcon(); - } - - protected override string GetDefaultImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/icon_select_area.png"; - } - - protected override string GetSelectedImageUrl() - { - return $"{FrameworkInformation.ResourcePath}images/light/color_icon_selected.png"; - } - - public override bool OnIconClicked(object sender, View.TouchEventArgs args) - { - base.OnIconClicked(sender, args); - return true; - } - } -} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Select/SelectTool.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Select/SelectTool.cs deleted file mode 100644 index c6c630a22a7..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Select/SelectTool.cs +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class SelectTool : ToolBase - { - public override PenWaveToolType Type => PenWaveToolType.Select; - - public SelectTool() : base(new SelectToolActionHandler()) - { - AddIcon(new SelectIcon()); - } - } -} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Select/SelectToolActionHandler.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Select/SelectToolActionHandler.cs deleted file mode 100644 index e8460735869..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Select/SelectToolActionHandler.cs +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class SelectToolActionHandler : IToolActionHandler - { - enum SelectMode - { - Resize, - Move, - None - } - - enum DrawableType - { - None, //nothing found/selected - Multi, //more than one drawable selected - Shape, - Chart, - Picture, - Text - } - - private bool isTouchedInsideSelectedArea = false; - private SelectMode mode = SelectMode.None; - private DrawableType drawableType = DrawableType.None; - - public void Activate() - { - } - - public void Deactivate() - { - mode = SelectMode.None; - EndDrawing(); - } - - public void HandleInput(Touch touch) - { - if (touch == null || touch.GetPointCount() == 0) return; - - uint pointStateIndex = 0; - uint touchTime = touch.GetTime(); - - List touchPositionList = new List(); - for (uint i = 0; i < touch.GetPointCount(); ++i) - { - touchPositionList.Add(touch.GetLocalPosition(i)); - } - - Vector2 position = touchPositionList[(int)pointStateIndex]; - switch (touch.GetState(pointStateIndex)) - { - case PointStateType.Down: - StartDrawing(position, touchTime); - break; - case PointStateType.Motion: - ContinueDrawing(position, touchTime); - break; - case PointStateType.Up: - case PointStateType.Leave: - EndDrawing(); - break; - } - } - - private void StartDrawing(Vector2 position, uint touchTime) - { - isTouchedInsideSelectedArea = PWEngine.InsideSelectedArea(position.X, position.Y); - if (!isTouchedInsideSelectedArea) - { - PWEngine.DropSelectedDrawables(); - drawableType = (DrawableType)PWEngine.SelectDrawable(position.X, position.Y); - } - } - - private void ContinueDrawing(Vector2 position, uint touchTime) - { - if (drawableType == DrawableType.None) - { - if (mode == SelectMode.None) - { - PWEngine.StartSelectingArea(position.X, position.Y); - } - PWEngine.ResizeSelectedArea(position.X, position.Y); - mode = SelectMode.Resize; - } - else if (isTouchedInsideSelectedArea || drawableType != DrawableType.None) - { - PWEngine.DragSelectedDrawables(position.X, position.Y); - mode = SelectMode.Move; - } - } - - private void EndDrawing() - { - switch (mode) - { - case SelectMode.Move : - PWEngine.EndDraging(); - break; - case SelectMode.Resize : - drawableType = (DrawableType)PWEngine.SelectDrawables(); - break; - default : - PWEngine.DropSelectedDrawables(); - break; - } - isTouchedInsideSelectedArea = false; - mode = SelectMode.None; - } - - } -} - - diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Selection/SelectionTool.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Selection/SelectionTool.cs new file mode 100644 index 00000000000..b90b0fda1ce --- /dev/null +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Selection/SelectionTool.cs @@ -0,0 +1,211 @@ +/* + * Copyright(c) 2024 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; +using System.ComponentModel; +using System.Collections.Generic; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI.PenWave +{ + public class SelectionTool : ToolBase + { + public override PWToolType Type => PWToolType.Selection; + + enum DrawableType + { + None, //nothing found/selected + Multi, //more than one drawable selected + Shape, + Chart, + Picture, + Text + } + + enum Mode + { + None, + Move, + Resize, + Scale, + Rotate + } + + private bool isTouchedInsideSelectedArea = false; + private PWSelectionType currentSelectionType = PWSelectionType.Move; + private Mode currentMode = Mode.None; + private DrawableType drawableType = DrawableType.None; + private Vector2 initialTouch = new Vector2(0, 0); + private float startScaleX; + private float startScaleY; + private float anchorX; + private float anchorY; + + public PWSelectionType SelectionType + { + get => currentSelectionType; + set + { + currentSelectionType = value; + } + } + + + public override void Activate() + { + + } + + public override void Deactivate() + { + currentMode = Mode.None; + EndDrawing(new Vector2(), 0); + } + + public override void HandleInput(Touch touch) + { + if (touch == null || touch.GetPointCount() == 0) return; + + uint pointStateIndex = 0; + uint touchTime = touch.GetTime(); + + List touchPositionList = new List(); + for (uint i = 0; i < touch.GetPointCount(); ++i) + { + touchPositionList.Add(touch.GetLocalPosition(i)); + } + + Vector2 position = touchPositionList[(int)pointStateIndex]; + switch (touch.GetState(pointStateIndex)) + { + case PointStateType.Down: + StartDrawing(position, touchTime); + break; + case PointStateType.Motion: + ContinueDrawing(position, touchTime); + break; + case PointStateType.Up: + case PointStateType.Leave: + EndDrawing(position, touchTime); + break; + } + } + + private void StartDrawing(Vector2 position, uint touchTime) + { + initialTouch = new Vector2(position.X, position.Y); + isTouchedInsideSelectedArea = PWEngine.InsideSelectedArea(position.X, position.Y); + if (!isTouchedInsideSelectedArea) + { + PWEngine.DropSelectedDrawables(); + drawableType = (DrawableType)PWEngine.SelectDrawable(position.X, position.Y); + } + else + { + if (currentSelectionType == PWSelectionType.Rotate) + { + PWEngine.StartRotating(position.X, position.Y); + } + else if (currentSelectionType == PWSelectionType.Scale) + { + float topLeftX = 0, topLeftY = 0, widthSelection = 0, heightSelection = 0; + PWEngine.GetSelectionDimensions(ref topLeftX, ref topLeftY, ref widthSelection, ref heightSelection); + if (!Double.IsNaN(topLeftX)) + { + PWEngine.StartSelectionScale( + initialTouch.X >= topLeftX+widthSelection*0.5f, + initialTouch.X < topLeftX+widthSelection*0.5f, + initialTouch.Y >= topLeftY+heightSelection*0.5f, + initialTouch.Y < topLeftY+heightSelection*0.5f, + ref anchorX, + ref anchorY + ); + + currentMode = Mode.Scale; + } + startScaleX = initialTouch.X; + startScaleY = initialTouch.Y; + } + } + } + + private void ContinueDrawing(Vector2 position, uint touchTime) + { + if (drawableType == DrawableType.None) + { + if (currentMode == Mode.None) + { + PWEngine.StartSelectingArea(position.X, position.Y); + } + PWEngine.ResizeSelectedArea(position.X, position.Y); + currentMode = Mode.Resize; + } + else if (currentMode != Mode.Resize && drawableType != DrawableType.None) + { + if (currentSelectionType == PWSelectionType.Move) + { + PWEngine.DragSelectedDrawables(position.X, position.Y); + currentMode = Mode.Move; + } + else if (currentSelectionType == PWSelectionType.Rotate) + { + PWEngine.RotateSelected(position.X, position.Y); + currentMode = Mode.Rotate; + } + else if (currentSelectionType == PWSelectionType.Scale) + { + PWEngine.ScaleSelection( + (position.X-anchorX)/(startScaleX-anchorX), + (position.Y-anchorY)/(startScaleY-anchorY) + ); + currentMode = Mode.Scale; + } + } + } + + private void EndDrawing(Vector2 position, uint touchTime) + { + switch (currentMode) + { + case Mode.Move : + PWEngine.EndDraging(); + break; + case Mode.Resize : + drawableType = (DrawableType)PWEngine.SelectDrawables(); + break; + case Mode.Rotate : + PWEngine.EndRotating(position.X, position.Y); + break; + case Mode.Scale : + PWEngine.EndRotating(position.X, position.Y); + PWEngine.EndSelectionScale( + (position.X-anchorX)/(startScaleX-anchorX), + (position.Y-anchorY)/(startScaleY-anchorY) + ); + break; + default : + PWEngine.DropSelectedDrawables(); + break; + } + isTouchedInsideSelectedArea = false; + currentMode = Mode.None; + } + + } +} + diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/ToolBase.cs b/src/Tizen.NUI.PenWave/src/public/Tools/ToolBase.cs deleted file mode 100644 index 88ebb891a64..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/ToolBase.cs +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public abstract class ToolBase - { - - public abstract PenWaveToolType Type { get; } - - protected IToolActionHandler ActionHandler { get; private set; } - - public event Action ToolSelected; - - protected List Icons { get; } = new List(); - - protected PopupManager PopupManager { get; private set; } - - public ToolBase(IToolActionHandler actionHandler) - { - ActionHandler = actionHandler; - } - - public void SetPopupManager(PopupManager popupManager) - { - PopupManager = popupManager; - } - - protected virtual void OnIconSelected(object sender) - { - ToolSelected?.Invoke(Type); - } - - public void Activate() - { - ActionHandler.Activate(); - } - - public void Deactivate() - { - ActionHandler.Deactivate(); - } - - public virtual void HandleInput(Touch touch) - { - ActionHandler.HandleInput(touch); - } - - public virtual View GetUI() - { - var view = new View - { - Layout = new LinearLayout() - { - // HorizontalAlignment = HorizontalAlignment.Center, - // VerticalAlignment = VerticalAlignment.Center, - LinearOrientation = LinearLayout.Orientation.Horizontal, - } - }; - foreach (var icon in Icons) - { - icon.IconSelected += OnIconSelected; - view.Add(icon); - } - return view; - } - - protected void AddIcon(Icon icon) => Icons.Add(icon); - } -} \ No newline at end of file diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/ToolFactory.cs b/src/Tizen.NUI.PenWave/src/public/Tools/ToolFactory.cs deleted file mode 100644 index f15e7762267..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/ToolFactory.cs +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright(c) 2024 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; - -namespace Tizen.NUI.PenWave -{ - public static class ToolFactory - { - public static ToolBase CreateTool(PenWaveToolType toolType) - { - return toolType switch - { - PenWaveToolType.Pencil => new PencilTool(), - PenWaveToolType.Eraser => new EraserTool(), - PenWaveToolType.Select => new SelectTool(), - PenWaveToolType.Canvas => new CanvasTool(), - _ => throw new ArgumentException("Unknown ToolType") - }; - } - } -} \ No newline at end of file diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/ToolManager.cs b/src/Tizen.NUI.PenWave/src/public/Tools/ToolManager.cs index b9701a33ed2..b05545c6233 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/ToolManager.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/ToolManager.cs @@ -25,10 +25,12 @@ namespace Tizen.NUI.PenWave { public class ToolManager { - public Dictionary Tools { get; } = new(); + internal Dictionary Tools { get; } = new(); private ToolBase currentTool; - public ToolManager() {} + public ToolManager() + { + } public void RegisterTool(ToolBase tool) { @@ -39,7 +41,6 @@ public void RegisterTool(ToolBase tool) else { Tools.Add(tool.Type, tool); - tool.ToolSelected += OnToolSelected; } } @@ -48,27 +49,36 @@ public void UnregisterTool(ToolBase tool) Tools.Remove(tool.Type); } - public void SelectTool(PenWaveToolType toolType) + public ToolBase GetTool(PWToolType toolType) + { + ToolBase tool = null; + Tools.TryGetValue(toolType, out tool); + return tool; + } + + public void SelectTool(PWToolType toolType) { + Tizen.Log.Error("NUI", $"SelectTool {toolType}\n"); currentTool?.Deactivate(); if (Tools.TryGetValue(toolType, out currentTool)) { + Tizen.Log.Error("NUI", $"SelectTool Activate {toolType}\n"); currentTool.Activate(); - EventBus.Publish("ToolChanged", toolType); } } - public void HandleInput(Touch touch) + public void ExecuteCurrentToolAction() { - currentTool?.HandleInput(touch); + if (currentTool!= null && currentTool.Action != null) + { + currentTool.Action.Execute(); + } } - private void OnToolSelected(PenWaveToolType toolType) + public void HandleInput(Touch touch) { - Tizen.Log.Info("NUI", $"OnToolSelected {toolType}\n"); - SelectTool(toolType); + currentTool?.HandleInput(touch); } - public PenWaveToolType GetCurrentToolType() => currentTool?.Type ?? PenWaveToolType.Pencil; } -} \ No newline at end of file +} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/ToolPickerView.cs b/src/Tizen.NUI.PenWave/src/public/Tools/ToolPickerView.cs deleted file mode 100644 index e86ad9a8d0d..00000000000 --- a/src/Tizen.NUI.PenWave/src/public/Tools/ToolPickerView.cs +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright(c) 2024 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; -using System.ComponentModel; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI.PenWave -{ - public class ToolPickerView : View - { - private ToolManager _toolManager; - private Dictionary _toolUIs; - private PopupManager _popupManager; - - public ToolPickerView(PWCanvasView canvasView) - { - _toolManager = canvasView.ToolManager; - EventBus.Subscribe("ToolChanged", OnToolChanged); - _toolUIs = new Dictionary(); - - InitializeUI(); - } - - private void InitializeUI() - { - WidthResizePolicy = ResizePolicyType.FillToParent; - HeightResizePolicy = ResizePolicyType.FillToParent; - - var rootView = new View - { - WidthResizePolicy = ResizePolicyType.FillToParent, - HeightResizePolicy = ResizePolicyType.FillToParent, - Layout = new LinearLayout() - { - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Top, - LinearOrientation = LinearLayout.Orientation.Vertical, - } - }; - - var pickerView = new View - { - CornerRadius = new Vector4(10, 10, 10, 10), - BackgroundImage = FrameworkInformation.ResourcePath + "images/" + "light" + "/menu_bg.png", - WidthSpecification = LayoutParamPolicies.WrapContent, - HeightSpecification = LayoutParamPolicies.WrapContent, - Layout = new LinearLayout - { - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Center - }, - }; - - var popupView = new View - { - WidthSpecification = LayoutParamPolicies.WrapContent, - HeightSpecification = LayoutParamPolicies.WrapContent, - Layout = new LinearLayout - { - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Center - } - }; - - _popupManager = new PopupManager(popupView); - - foreach (var tool in _toolManager.Tools) - { - tool.Value.SetPopupManager(_popupManager); - var toolUI = tool.Value.GetUI(); - if (_toolUIs.TryAdd(tool.Key, toolUI)) - { - pickerView.Add(toolUI); - } - } - rootView.Add(pickerView); - Add(rootView); - Add(popupView); - - TouchEvent += OnTouchEvent; - } - - private bool OnTouchEvent(object sender, View.TouchEventArgs args) - { - IconStateManager.Instance.CurrentPressedIcon = null; - _popupManager.HidePopup(); - return false; - } - - public void ShowPopup(View contentView, Position2D position) - { - _popupManager.ShowPopup(contentView, position); - } - - public void HidePopup() - { - _popupManager.HidePopup(); - } - - - private void OnToolChanged(object toolType) - { - Tizen.Log.Info("NUI", $"OnToolChanged {toolType}\n"); - _popupManager.HidePopup(); - } - - - public void ShowTool(PenWaveToolType type) - { - if (_toolUIs.TryGetValue(type, out var toolView)) - { - Add(toolView); - } - } - - public void HideTool(PenWaveToolType type) - { - if (_toolUIs.TryGetValue(type, out var toolView)) - { - Remove(toolView); - } - } - - public void CustomizeToolUI(PenWaveToolType toolType, View customUI) - { - HideTool(toolType); - if (_toolUIs.TryAdd(toolType, customUI)) - { - Add(customUI); - } - } - } -} diff --git a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/CanvasToolActionHandler.cs b/src/Tizen.NUI.PenWave/src/public/Tools/Toolbase.cs similarity index 74% rename from src/Tizen.NUI.PenWave/src/public/Tools/Canvas/CanvasToolActionHandler.cs rename to src/Tizen.NUI.PenWave/src/public/Tools/Toolbase.cs index 9ddffa7e0d3..f2a28999e1a 100644 --- a/src/Tizen.NUI.PenWave/src/public/Tools/Canvas/CanvasToolActionHandler.cs +++ b/src/Tizen.NUI.PenWave/src/public/Tools/Toolbase.cs @@ -23,20 +23,16 @@ namespace Tizen.NUI.PenWave { - public class CanvasToolActionHandler : IToolActionHandler + public abstract class ToolBase { - public void Activate() - { - } + public abstract PWToolType Type { get; } - public void Deactivate() - { - } + public IToolAction Action { get; set; } - public void HandleInput(Touch touch) - { - } + public virtual void HandleInput(Touch touch) {} + + public abstract void Activate(); + public abstract void Deactivate(); } } - diff --git a/test/Tizen.NUI.PenWave.Sample/src/PenWaveSample.cs b/test/Tizen.NUI.PenWave.Sample/src/PenWaveSample.cs index 53f45cc9d3d..fb1fef85cc6 100644 --- a/test/Tizen.NUI.PenWave.Sample/src/PenWaveSample.cs +++ b/test/Tizen.NUI.PenWave.Sample/src/PenWaveSample.cs @@ -5,6 +5,7 @@ using Tizen.NUI; using Tizen.NUI.BaseComponents; +using Tizen.NUI.Components; using Tizen.NUI.PenWave; namespace PenWaveSample @@ -13,7 +14,7 @@ class Program : NUIApplication { public static Program app; private Window mWindow; - private ToolPickerView mToolPickerView; + // private ToolPickerView mToolPickerView; private PWCanvasView canvasView; public Program(ThemeOptions option, WindowData windowData) : base(option, windowData) @@ -32,16 +33,45 @@ private void InitializeView() mWindow = GetDefaultWindow(); mWindow.BackgroundColor = Color.White; canvasView = PWCanvasView.CreateDefaultCanvas(); + // canvasView = new PWCanvasView(); + // PencilTool pencilTool = new PencilTool(); + // canvasView.AddTool(pencilTool); + + var pencilTool = (PencilTool)canvasView.GetTool(PWToolType.Pencil); + pencilTool.BrushColor = Color.Red; + pencilTool.BrushType = PWBrushType.DashedLine;; + + // canvasView.SelectTool(pencilTool.Type); + // var selectionTool = (SelectionTool)canvasView.GetTool(PWToolType.Selection); + // selectionTool.SelectionType = PWSelectionType.Rotate; + // canvasView.SelectTool(PWToolType.Selection); + mWindow.Add(canvasView); - mToolPickerView = new ToolPickerView(canvasView); + // mToolPickerView = new ToolPickerView(canvasView); - canvasView.Add(mToolPickerView); + // canvasView.Add(mToolPickerView); canvasView.TouchEvent += OnTouchEvent; canvasView.AddPicture(Tizen.Applications.Application.Current.DirectoryInfo.Resource+"images/pictures/venus.png", new Size2D(100, 100), new Position2D(0, 0)); - canvasView.SelectTool(PenWaveToolType.Select); + + + // canvasView.SelectTool(PWToolType.Select); + + + + + var button = new Button() + { + Text = "Eraser" + }; + button.Clicked += (o, e) => { + var eraserTool = (EraserTool)canvasView.GetTool(PWToolType.Eraser); + eraserTool.EraserType = PWEraserType.Full; + canvasView.SelectTool(PWToolType.Eraser); + }; + canvasView.Add(button); }