-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
245 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/Tizen.NUI.PenWave/src/public/Tools/Canvas/BackgroundColorIcon.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* 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; | ||
|
||
string url = $"{FrameworkInformation.ResourcePath}images/light/color_icon_base.png"; | ||
|
||
InitializeIcon(url, mColor); | ||
} | ||
|
||
public override bool IconClick(object sender, View.TouchEventArgs args) | ||
{ | ||
if (base.IconClick(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; | ||
} | ||
} |
124 changes: 124 additions & 0 deletions
124
src/Tizen.NUI.PenWave/src/public/Tools/Canvas/CanvasTool.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* | ||
* 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 ToolBase.ToolType Type => ToolBase.ToolType.Canvas; | ||
|
||
private static readonly string popupBgUrl = $"{FrameworkInformation.ResourcePath}images/light/canvas_popup_bg.png"; | ||
private static readonly List<Color> BgColors = new List<Color> | ||
{ | ||
new Color("#FFFEFE"), | ||
new Color("#F0F0F0"), | ||
new Color("#B7B7B7"), | ||
new Color("#E3F2FF"), | ||
new Color("#202022"), | ||
new Color("#515151"), | ||
new Color("#17234D"), | ||
new Color("#090E21"), | ||
}; | ||
|
||
public CanvasTool() | ||
{ | ||
|
||
} | ||
|
||
protected override void StartDrawing(Vector2 position, uint touchTime) | ||
{ | ||
} | ||
|
||
protected override void ContinueDrawing(Vector2 position, uint touchTime) | ||
{ | ||
} | ||
|
||
protected override void EndDrawing() | ||
{ | ||
} | ||
|
||
protected override void Deactivate() | ||
{ | ||
EndDrawing(); | ||
} | ||
|
||
public override View GetUI() | ||
{ | ||
View rootView = new View | ||
{ | ||
// Layout = new LinearLayout() | ||
// { | ||
// LinearOrientation = LinearLayout.Orientation.Horizontal, | ||
// }, | ||
Layout = new GridLayout { Columns = 1, RowSpacing = 4 } | ||
}; | ||
var icon = new PalettIcon(); | ||
rootView.Add(icon); | ||
icon.IconSelected += OnIconSelected; | ||
|
||
MakePopup(rootView); | ||
|
||
return rootView; | ||
} | ||
|
||
private void MakePopup(View rootView) | ||
{ | ||
var bgImage = new ImageView | ||
{ | ||
BackgroundImage = popupBgUrl, | ||
WidthSpecification = LayoutParamPolicies.WrapContent, | ||
HeightSpecification = LayoutParamPolicies.WrapContent, | ||
Layout = new GridLayout { Columns = 1, RowSpacing = 4 } | ||
}; | ||
AddIconsToView(bgImage, BgColors, color => new BackgroundColorIcon(color)); | ||
rootView.Add(bgImage); | ||
} | ||
|
||
private void AddIconsToView<T>(View rootView, IEnumerable<T>items, Func<T, Icon> iconFactory) | ||
{ | ||
var view = new View | ||
{ | ||
// Layout = new LinearLayout() | ||
// { | ||
// LinearOrientation = LinearLayout.Orientation.Horizontal, | ||
// }, | ||
Layout = new GridLayout { Columns = 4, ColumnSpacing = 8, RowSpacing = 8 }, | ||
}; | ||
foreach (var item in items) | ||
{ | ||
var icon = iconFactory(item); | ||
view.Add(icon); | ||
// icon.IconSelected += OnIconSelected; | ||
} | ||
rootView.Add(view); | ||
} | ||
|
||
// protected override void OnIconSelected() | ||
// { | ||
// base.OnIconSelected(); | ||
|
||
|
||
// } | ||
|
||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/Tizen.NUI.PenWave/src/public/Tools/Canvas/PalettIcon.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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 PalettIcon : Icon | ||
{ | ||
private static readonly string url = $"{FrameworkInformation.ResourcePath}images/light/icon_color_palette.png"; | ||
|
||
private ImageView bgImage; | ||
|
||
public PalettIcon() : base() | ||
{ | ||
InitializeIcon(url, new Color("#17234d")); | ||
} | ||
|
||
public override bool IconClick(object sender, View.TouchEventArgs args) | ||
{ | ||
if (base.IconClick(sender, args)) | ||
{ | ||
Tizen.Log.Error("NUI", $"PalettIcon show\n"); | ||
// 캔버스 색상 팝업 | ||
} | ||
return true; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters