From: Daekwang Ryu Date: Fri, 24 Mar 2023 06:02:52 +0000 (+0900) Subject: [NUI] Add a new WindowLayout Sample X-Git-Tag: accepted/tizen/unified/20231205.024657~273 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=d3d8b83eef3f970b59911e0097f1c517a1c93ff3;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Add a new WindowLayout Sample --- diff --git a/test/NUIWindowLayout/.pic/quarters-screen.png b/test/NUIWindowLayout/.pic/quarters-screen.png new file mode 100644 index 0000000..73057e1 Binary files /dev/null and b/test/NUIWindowLayout/.pic/quarters-screen.png differ diff --git a/test/NUIWindowLayout/.pic/thirds-screen.png b/test/NUIWindowLayout/.pic/thirds-screen.png new file mode 100644 index 0000000..4316342 Binary files /dev/null and b/test/NUIWindowLayout/.pic/thirds-screen.png differ diff --git a/test/NUIWindowLayout/NUIWindowLayout.cs b/test/NUIWindowLayout/NUIWindowLayout.cs new file mode 100755 index 0000000..c57b170 --- /dev/null +++ b/test/NUIWindowLayout/NUIWindowLayout.cs @@ -0,0 +1,95 @@ +using System; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Components; +using System.Collections.Generic; + +namespace NUIWindowLayout +{ + class Program : NUIApplication + { + private uint numOfWindows; + private List windows = new List(); + private Color[] colors = { Color.DarkGreen, Color.Aqua, Color.Coral, Color.DimGrey }; + + public Program(uint numOfWindows) : base(ThemeOptions.None, new DefaultBorder()) + { + if (numOfWindows > 0 && numOfWindows <= 4) + { + this.numOfWindows = numOfWindows; + } + else + { + Tizen.Log.Error("WindowLayout", "numOfWindows is not valid. Put 0 < numOfWindows <= 4"); + } + } + protected override void OnCreate() + { + base.OnCreate(); + Window window = NUIApplication.GetDefaultWindow(); + window.KeyEvent += OnKeyEvent; + Initialize(); + } + + void Initialize() + { + windows.Add(NUIApplication.GetDefaultWindow()); + + for (int i = 1; i < numOfWindows; i++) + { + windows.Add(new Window((i + 1).ToString() + "window", new DefaultBorder())); + } + + for (int i = 0; i < numOfWindows; i++) + { + Window window = windows[i]; + window.BackgroundColor = colors[i]; + + ScrollableBase scrollableBase = new ScrollableBase(); + scrollableBase.WidthSpecification = LayoutParamPolicies.MatchParent; + scrollableBase.HeightSpecification = LayoutParamPolicies.MatchParent; + scrollableBase.ScrollingDirection = ScrollableBase.Direction.Vertical; + + scrollableBase.Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + }; + + for (int idxType = 0; idxType < System.Enum.GetValues(typeof(WindowLayoutType)).Length; idxType++) + { + Button button = new Button(); + button.TextLabel.Text = idxType.ToString() + "." + (WindowLayoutType)idxType; // Set text to the enum value + button.Size = new Size(200, 50); + + button.Clicked += (object sender, ClickedEventArgs e) => + { + int number; + number = int.Parse(((Button)sender).TextLabel.Text.Split('.')[0]); + WindowLayoutType type = (WindowLayoutType)number; + Tizen.Log.Info("WindowLayout", type.ToString()); + window.SetLayout((WindowLayoutType)number); + }; + scrollableBase.Add(button); + } + + window.Add(scrollableBase); + } + } + + public void OnKeyEvent(object sender, Window.KeyEventArgs e) + { + if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape")) + { + Exit(); + } + } + + static void Main(string[] args) + { + var app = new Program(4); + app.Run(args); + } + } +} diff --git a/test/NUIWindowLayout/NUIWindowLayout.csproj b/test/NUIWindowLayout/NUIWindowLayout.csproj new file mode 100755 index 0000000..7853929 --- /dev/null +++ b/test/NUIWindowLayout/NUIWindowLayout.csproj @@ -0,0 +1,24 @@ + + + + Exe + netcoreapp3.1 + + + + portable + + + None + + + + + + + + + + + + diff --git a/test/NUIWindowLayout/README.md b/test/NUIWindowLayout/README.md new file mode 100644 index 0000000..b6f811b --- /dev/null +++ b/test/NUIWindowLayout/README.md @@ -0,0 +1,13 @@ +# NUIWindowLayout +This app shows how to use the WindowLayout feature. +When you use Window.SetLayout(), you can move and resize the window, for instance moving and resizing the window to the left half of the screen. + + +## ScreenShot ++ LeftThird, CenterThird, RightThird +![](./.pic/thirds-screen.png) + + + ++ UpperLeftQuarter, UpperRightQuarter, LowerLeftQuarter, LowerRightQuarter +![](./.pic/quarters-screen.png) \ No newline at end of file diff --git a/test/NUIWindowLayout/shared/res/NUIWindowLayout.png b/test/NUIWindowLayout/shared/res/NUIWindowLayout.png new file mode 100755 index 0000000..9f3cb98 Binary files /dev/null and b/test/NUIWindowLayout/shared/res/NUIWindowLayout.png differ diff --git a/test/NUIWindowLayout/tizen-manifest.xml b/test/NUIWindowLayout/tizen-manifest.xml new file mode 100755 index 0000000..01affb8 --- /dev/null +++ b/test/NUIWindowLayout/tizen-manifest.xml @@ -0,0 +1,16 @@ + + + + + + NUIWindowLayout.png + + +