From: dongsug.song Date: Wed, 1 Nov 2017 04:58:31 +0000 (+0900) Subject: [NUI]ImageView OrientationCorrection support X-Git-Tag: 5.0.0-preview1-00362~2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F45%2F158445%2F4;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI]ImageView OrientationCorrection support - sample: tizenfx\test\NUITestSample\NUITestSample\examples\image-orientation-correct-test.cs Change-Id: I0556bd9f6553e1349038ecf181a074ebd4eb7cb5 Signed-off-by: dongsug.song --- diff --git a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs index 635fb1376..4d0c1f31b 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs @@ -417,6 +417,25 @@ namespace Tizen.NUI.BaseComponents } } + /// + /// Gets or sets whether to correct orientation of image automatically.
+ ///
+ /// 5 + public bool OrientationCorrection + { + get + { + return _orientationCorrection ?? false; + } + set + { + _orientationCorrection = value; + UpdateImage(); + } + } + + + private void UpdateImage() { if (_url != null) @@ -428,15 +447,17 @@ namespace Tizen.NUI.BaseComponents _nPatchMap.Add(NpatchImageVisualProperty.URL, new PropertyValue(_url)); _nPatchMap.Add(NpatchImageVisualProperty.Border, new PropertyValue(_border)); if (_borderOnly != null) { _nPatchMap.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)_borderOnly)); } - if (_synchronousLoading != null) _nPatchMap.Add(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); + if (_synchronousLoading != null) { _nPatchMap.Add(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); } + if (_orientationCorrection != null) { _nPatchMap.Add(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)_orientationCorrection)); } SetProperty(ImageView.Property.IMAGE, new PropertyValue(_nPatchMap)); } - else if (_synchronousLoading != null) + else if (_synchronousLoading != null || _orientationCorrection != null) { // for normal image, with synchronous loading property PropertyMap imageMap = new PropertyMap(); imageMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); imageMap.Add(ImageVisualProperty.URL, new PropertyValue(_url)); - imageMap.Add(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); + if (_synchronousLoading != null) { imageMap.Add(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); } + if (_orientationCorrection != null) { imageMap.Add(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)_orientationCorrection)); } SetProperty(ImageView.Property.IMAGE, new PropertyValue(imageMap)); } else @@ -451,7 +472,7 @@ namespace Tizen.NUI.BaseComponents private bool? _synchronousLoading = null; private bool? _borderOnly = null; private string _url = null; - + private bool? _orientationCorrection = null; } } diff --git a/src/Tizen.NUI/src/public/NUIConstants.cs b/src/Tizen.NUI/src/public/NUIConstants.cs index 7b35e44e6..2e47cb3e8 100755 --- a/src/Tizen.NUI/src/public/NUIConstants.cs +++ b/src/Tizen.NUI/src/public/NUIConstants.cs @@ -1215,7 +1215,13 @@ namespace Tizen.NUI /// /// 4 public static readonly int FrameDelay = NDalic.IMAGE_VISUAL_FRAME_DELAY; - + /// + /// Whether to corrcet orientation of image + /// + /// 5 + /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly int OrientationCorrection = CropToMask + 3; } /// diff --git a/test/NUITestSample/NUITestSample.sln b/test/NUITestSample/NUITestSample.sln new file mode 100755 index 000000000..f89637ef1 --- /dev/null +++ b/test/NUITestSample/NUITestSample.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27004.2006 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NUITestSample", "NUITestSample\NUITestSample.csproj", "{848AFBC8-7318-4856-8FA5-51AFA4919838}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {848AFBC8-7318-4856-8FA5-51AFA4919838}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {848AFBC8-7318-4856-8FA5-51AFA4919838}.Debug|Any CPU.Build.0 = Debug|Any CPU + {848AFBC8-7318-4856-8FA5-51AFA4919838}.Release|Any CPU.ActiveCfg = Release|Any CPU + {848AFBC8-7318-4856-8FA5-51AFA4919838}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1121C38F-65D0-4F7B-8097-9A363A641DF2} + EndGlobalSection +EndGlobal diff --git a/test/NUITestSample/NUITestSample/NUITestSample.cs b/test/NUITestSample/NUITestSample/NUITestSample.cs new file mode 100755 index 000000000..4c626f3de --- /dev/null +++ b/test/NUITestSample/NUITestSample/NUITestSample.cs @@ -0,0 +1,42 @@ +using System; + +namespace NUITestSample +{ + class Application + { + [STAThread] + static void Main(string[] args) + { + //new ControlDashboard.Example().Run(args); + //new DatePickerTest.Example().Run(args); + //new DatePickerUsingJson.Example().Run(args); + //new HelloTest.Example().Run(args); + //new HelloWorldTest.Example().Run(args); + //new Test1.Example().Run(args); + //new SiblingOrderTest.Example().Run(args); + //new UserAlphaFunctionTest.Example().Run(args); + //new MyCSharpExample.Example().Run(args); + //new CustomControlTest.Example().Run(args); + //new ScrollViewTest.Example().Run(args); + //new ImageViewTest.Example().Run(args); + //new FlexContainerTest.SampleMain().Run(args); + //new DaliTest.Example().Run(args); + //new RelativeVectorTest.Example().Run(args); + //new VisaulAnimationExample.Example().Run(args); + //new VisaulAnimationExample.Example2().Run(args); + //new VisaulAnimationExample.Example3().Run(args); + //new VisualViewTest.Example().Run(args); + //new VisualViewTest2.VisualSample().Run(args); + //new PositionUsesPivotPointTest.Example().Run(args); + //new VisualViewTest3.Example().Run(args); + //new VisualsUsingCustomView.VisualsExample().Run(args); + //new FirstScreen.FirstScreenApp().Run(args); + //new VisualsExampleTest.Example().Run(args); + //new AsIsTest.Example().Run(args); + //new WidgetViewTest.Example().Run(args); + //new DisposeTest.Example().Run(args); + //new SvgTest.Program().Run(args); + new ImageViewOrientationCorrectionTest.Program().Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/NUITestSample.csproj b/test/NUITestSample/NUITestSample/NUITestSample.csproj new file mode 100755 index 000000000..df7cfc85c --- /dev/null +++ b/test/NUITestSample/NUITestSample/NUITestSample.csproj @@ -0,0 +1,28 @@ + + + + Exe + netcoreapp2.0 + + + + portable + + + None + + + + + + + + + + Runtime + + + + + + diff --git a/test/NUITestSample/NUITestSample/examples/as-is-test-sample.cs b/test/NUITestSample/NUITestSample/examples/as-is-test-sample.cs new file mode 100755 index 000000000..da94300d4 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/as-is-test-sample.cs @@ -0,0 +1,255 @@ +using System; +using Tizen.NUI.BaseComponents; +using Tizen.NUI; + +namespace AsIsTest +{ + class Example : NUIApplication + { + private Timer myTimer; + + private View myView; + private TextLabel myTextLabel; + + + //=========================== + Layer layer; + View vi1, vi2, vi3; + TextLabel tl1, tl2, tl3; + ToggleButton tb1, tb2, tb3; + + + protected override void OnCreate() + { + base.OnCreate(); + + myView = new View(); + myView.Size2D = new Size2D(100, 100); + myView.Position = new Position(100, 100, 0); + myView.BackgroundColor = Color.Red; + myView.Name = "myView"; + myView.SizeWidth = 111; + + Window.Instance.GetDefaultLayer().Add(myView); + + myTextLabel = new TextLabel(); + myTextLabel.Position = new Position(100, 100, 0); + myTextLabel.Size2D = new Size2D(100, 100); + myTextLabel.Name = "myTextLabel"; + + myView.Add(myTextLabel); + + //=========================== + LayerTest2(); + + myTimer = new Timer(500); + myTimer.Tick += Mytimer_Tick; + myTimer.Start(); + } + + private void ObjectDumpTrigger() + { + for (int i = 0; i < Window.LayerCount; i++) + { + BFS(Window.GetLayer((uint)i), 1); + } + } + + + + private static void BFS(Animatable o, int depth) + { + if (o == null) + { + Tizen.Log.Fatal("NUI-APP", "##### o == null! return here!"); + return; + } + + Tizen.Log.Fatal("NUI-APP", "##### o.GetTypeName()=" + o.GetTypeName()); + + if (o is View) + { + View myView = o as View; + + if (o is TextLabel) + { + TextLabel myTextLabel = o as TextLabel; + + Tizen.Log.Fatal("NUI-APP", string.Format("it is TextLabel, {0}", myTextLabel.Text)); + + return; + } + else + { + Tizen.Log.Fatal("NUI-APP", string.Format("it is not TextLaebl")); + } + + for (int i = 0; i < myView.ChildCount; i++) + { + BFS(myView.GetChildAt((uint)i), depth + 1); + } + } + else if (o is Layer) + { + Layer myLayer = o as Layer; + + for (int i = 0; i < myLayer.ChildCount; i++) + { + BFS(myLayer.GetChildAt((uint)i), depth + 1); + } + } + else + { + return; + } + } + + private bool Mytimer_Tick(object source, Timer.TickEventArgs e) + { + ObjectDumpTrigger(); + ObjectDumpTrigger2(); + Tizen.Log.Debug("NUI", " === Size property set/get test!"); + myView.Size2D.Width += 5; //this is not working, because stage's Size is Vector2 but view's Size is Vector3. need to figure out. + myView.SizeHeight += 5; + Tizen.Log.Debug("NUI", $" view's size width= {myView.Size2D.Width} heigh={myView.Size2D.Height}"); + + return true; + } + + + + //====================================================================== + void LayerTest2() + { + layer = new Layer(); + + vi1 = new View(); + vi2 = new View(); + vi3 = new View(); + + tl1 = new TextLabel(); + tl2 = new TextLabel(); + tl3 = new TextLabel(); + + tb1 = new ToggleButton(); + tb2 = new ToggleButton(); + tb3 = new ToggleButton(); + + vi1.Add(vi3); + vi1.Add(tl1); + vi1.Add(tl2); + + vi3.Add(tb1); + vi3.Add(tb2); + + vi2.Add(tl3); + + layer.Add(vi1); + layer.Add(vi2); + layer.Add(tb3); + + Window.Instance.AddLayer(layer); + } + + void ObjectDumpTrigger2() + { + uint layerCnt = Window.LayerCount; + Tizen.Log.Fatal("NUI-APP", "layerCnt=" + layerCnt); + + for (uint i = 0; i < layerCnt; i++) + { + Tizen.Log.Fatal("NUI-APP", "T[" + DateTime.Now + "]__________ layer #" + i + " traverse"); + CheckViewsInLayer(Window.GetLayer(i)); + } + } + void CheckViewsInLayer(Animatable obj) + { + if (obj is Layer) + { + var layer = obj as Layer; + if (layer == null) + { + Tizen.Log.Fatal("NUI-APP", "### layer is null! just return!"); + return; + } + uint childCnt = layer.ChildCount; + if (childCnt > 0) + { + for (uint i = 0; i < childCnt; i++) + { + var temp = layer.GetChildAt(i) as View; + Tizen.Log.Fatal("NUI-APP", "depth[1] child in layer! type=" + temp?.GetTypeName()); + ViewCheckRecurse(temp, 1); + } + } + else + { + Tizen.Log.Fatal("NUI-APP", "### there is no child in this layer! just return!"); + } + } + else + { + Tizen.Log.Fatal("NUI-APP", "obj is NOT Layer! do nothing!"); + } + } + void ViewCheckRecurse(View view, int depth) + { + if (view) + { + uint childCnt = view.ChildCount; + if (childCnt > 0) + { + depth = depth + 1; + for (uint i = 0; i < childCnt; i++) + { + var temp = view.GetChildAt(i) as View; + Tizen.Log.Fatal("NUI-APP", "depth[" + depth + "] child in layer! type=" + temp.GetTypeName() + " AS-IS Test: IsView?=" + (temp is View) + " IsTextLabel?=" + (temp is TextLabel) ); + + if (temp is TextLabel) + { + ToggleButton _toggleBt = temp as ToggleButton; + if(_toggleBt == null) + { + Tizen.Log.Debug("NUI", $"temp is TextLabel! try to do invalid cast! should return null! OK!GOOD!"); + } + else + { + Tizen.Log.Debug("NUI", $"temp is TextLabel! try to do invalid cast! should return null! BAD!ERROR!"); + } + } + else if (temp is ToggleButton) + { + TextLabel _textLb = temp as TextLabel; + if(_textLb == null) + { + Tizen.Log.Debug("NUI", $"temp is ToggleButton! try to do invalid cast! should return null! OK!GOOD!"); + } + else + { + Tizen.Log.Debug("NUI", $"temp is ToggleButton! try to do invalid cast! should return null! BAD!ERROR!"); + } + } + + ViewCheckRecurse(temp, depth); + } + } + else + { + //Tizen.Log.Fatal("NUI-APP", "depth[" + depth + "] child in layer! type=" + view.GetTypeName()); + return; + } + } + else + { + //Tizen.Log.Fatal("NUI-APP", "### view is null! just return!"); + } + } + + private static void _Main(string[] args) + { + //Create an Application + Example myProgram = new Example(); + myProgram.Run(args); + } + } +} \ No newline at end of file diff --git a/test/NUITestSample/NUITestSample/examples/color-test.cs b/test/NUITestSample/NUITestSample/examples/color-test.cs new file mode 100755 index 000000000..660841802 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/color-test.cs @@ -0,0 +1,89 @@ +using Tizen.NUI; +using Tizen.NUI.BaseComponents; + +namespace ColorTest +{ + internal class Example : NUIApplication + { + View mainView; + TextLabel title; + + public Example() : base("", WindowMode.Transparent) + { + } + + Size2D screenSize; + int pixelSize; + + protected override void OnCreate() + { + base.OnCreate(); + + Window.Instance.BackgroundColor = Color.Transparent; + Window.Instance.KeyEvent += Instance_KeyEvent; + + screenSize = Window.Instance.Size; + pixelSize = screenSize.Width / 10; + + mainView = new View(); + mainView.Size2D = screenSize; + mainView.BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 1.0f); + mainView.PivotPoint = PivotPoint.TopLeft; + mainView.Position = new Position(0, 0, 0); + Window.Instance.GetDefaultLayer().Add(mainView); + + title = new TextLabel("Ambient is the new off"); + title.PivotPoint = PivotPoint.TopLeft; + title.Size2D = new Size2D(screenSize.Width, screenSize.Height / 2); + title.Position = new Position(0, 0, 0); + //title.TextColor = new Color(1.0f, 1.0f, 1.0f, 1.0f); + title.TextColor = new Color(255.0f, 255.0f, 255.0f, 255.0f); + title.PixelSize = pixelSize; + title.HorizontalAlignment = HorizontalAlignment.Center; + title.VerticalAlignment = VerticalAlignment.Center; + title.MultiLine = true; + + mainView.Add(title); + } + + private void Instance_KeyEvent(object sender, Window.KeyEventArgs e) + { + //////NUILog.Debug("State=" + e.Key.State.ToString() + " Pressed=" + e.Key.KeyPressedName + " Time=" + e.Key.Time); + + if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "BackSpace" || e.Key.KeyPressedName == "XF86Back")) + { + Exit(); + } + + if (e.Key.State == Key.StateType.Down) + { + if (e.Key.KeyPressedName == "Left") + { + mainView.Remove(title); + title.Dispose(); + title = null; + + mainView = new View(); + mainView.Size2D = screenSize; + mainView.BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 1.0f); + mainView.PivotPoint = PivotPoint.TopLeft; + mainView.Position = new Position(0, 0, 0); + Window.Instance.GetDefaultLayer().Add(mainView); + + title = new TextLabel("Ambient is the new off"); + title.PivotPoint = PivotPoint.TopLeft; + title.Size2D = new Size2D(screenSize.Width, screenSize.Height / 2); + title.Position = new Position(0, 0, 0); + //title.TextColor = new Color(1.0f, 1.0f, 1.0f, 1.0f); + title.TextColor = new Color(255.0f, 255.0f, 255.0f, 255.0f); + title.PixelSize = pixelSize; + title.HorizontalAlignment = HorizontalAlignment.Center; + title.VerticalAlignment = VerticalAlignment.Center; + title.MultiLine = true; + + mainView.Add(title); + } + } + } + } +} \ No newline at end of file diff --git a/test/NUITestSample/NUITestSample/examples/control-dashboard.cs b/test/NUITestSample/NUITestSample/examples/control-dashboard.cs new file mode 100755 index 000000000..bea0ec6a7 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/control-dashboard.cs @@ -0,0 +1,502 @@ +/* + * Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; + +namespace ControlDashboard +{ + class Example : NUIApplication + { + // This is simple structure to contain Control name and implement state at once + // name : control name + // isImplemented : the state which the control is implemented in public or not + private struct Item + { + public String name; + public bool isImplemented; + + public Item(String name, bool isImplemented) + { + this.name = name; + this.isImplemented = isImplemented; + } + } + + private TableView _contentContainer; + private Timer _timer; + private Window _window; + private Popup _popup; + private ProgressBar _progressBar; + //private const string _resPath = "/home/owner/apps_rw/NUISamples.TizenTV/res"; + private const string _resPath = "./res"; //for ubuntu + + + // List of items + private Item[] mViewList = { + new Item("PushButton", true), new Item("DropDown", false), new Item("Toggle", true), + new Item("InputField", false), new Item("AnimateGif", false), new Item("Loading", false), + new Item("ProgressBar", true), new Item("CheckBox", false), new Item("RadioButton", true), + new Item("Tooltip", true), new Item("Popup", true), new Item("Toast", true), + new Item("ItemView", false), new Item("CheckBox", true) + }; + + public Example() : base() + { + } + + public Example(string stylesheet) : base(stylesheet) + { + } + + public Example(string stylesheet, NUIApplication.WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + public void Initialize() + { + Tizen.Log.Debug("NUI", "Customized Application Initialize event handler"); + _window = Window.Instance; + _window.BackgroundColor = Color.White; + + // Top label + TextLabel topLabel = new TextLabel(); + topLabel.WidthResizePolicy = ResizePolicyType.FillToParent; + topLabel.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent; + topLabel.PivotPoint = PivotPoint.TopCenter; + topLabel.SetSizeModeFactor(new Vector3(0.0f, 0.1f, 0.0f)); + topLabel.BackgroundColor = new Color(43.0f / 255.0f, 145.0f / 255.0f, 175.0f / 255.0f, 1.0f); + topLabel.TextColor = Color.White; + topLabel.Text = " DALi Views"; + topLabel.HorizontalAlignment = HorizontalAlignment.Begin; + topLabel.VerticalAlignment = VerticalAlignment.Center; + topLabel.PointSize = 42.0f; + _window.Add(topLabel); + //StyleManager.Get().ApplyStyle(topLabel, _resPath + "/json/control-dashboard-theme.json", "TextFieldFontSize4"); + topLabel.SetStyleName("TextFieldFontSize4"); + + // Grid container to contain items. Use tableView because FlexContainer support focus navigation just two direction ( up/down or left/right ) + _contentContainer = new TableView(6, 5); + _contentContainer.WidthResizePolicy = ResizePolicyType.FillToParent; + _contentContainer.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent; + _contentContainer.SetSizeModeFactor(new Vector3(0.0f, 0.9f, 0.0f)); + _contentContainer.PivotPoint = PivotPoint.BottomCenter; + _contentContainer.Position = new Position(0, _window.Size.Height * 0.1f, 0); + _contentContainer.SetRelativeHeight(0, 0.07f); + _contentContainer.SetRelativeHeight(1, 0.26f); + _contentContainer.SetRelativeHeight(2, 0.07f); + _contentContainer.SetRelativeHeight(3, 0.26f); + _contentContainer.SetRelativeHeight(4, 0.07f); + _contentContainer.SetRelativeHeight(5, 0.26f); + _contentContainer.Focusable = (true); + _window.Add(_contentContainer); + + CreateContent(); + + FocusManager.Instance.PreFocusChange += OnPreFocusChange; + } + + // Callback for KeyboardFocusManager + private View OnPreFocusChange(object source, FocusManager.PreFocusChangeEventArgs e) + { + if (!e.ProposedView && !e.CurrentView) + { + e.ProposedView = _contentContainer.GetChildAt(1); + } + return e.ProposedView; + } + + private void CreateContent() + { + for (int i = 0; i < mViewList.Length; i++) + { + CreateItem(mViewList[i], i); + } + } + + private void CreateItem(Item item, int idx) + { + // Make label for item + TextLabel itemLabel = new TextLabel(" " + item.name); + itemLabel.Size2D = new Size2D((int)(_window.Size.Width * 0.2f), (int)(_window.Size.Height * 0.05f)); + itemLabel.HorizontalAlignment = HorizontalAlignment.Begin; + itemLabel.VerticalAlignment = VerticalAlignment.Bottom; + //itemLabel.PointSize = 18.0f; + _contentContainer.AddChild(itemLabel, new TableView.CellPosition(((uint)idx / 5) * 2, (uint)idx % 5)); + + // If item is implemented in public, attach it on window + if (item.isImplemented) + { + if (item.name.CompareTo("PushButton") == 0) + { + PushButton pushButton = new PushButton(); + pushButton.LabelText = "Push Button"; + pushButton.WidthResizePolicy = ResizePolicyType.FillToParent; + pushButton.HeightResizePolicy = ResizePolicyType.FillToParent; + pushButton.UnselectedColor = new Vector4(1.0f, 0.0f, 0.0f, 1.0f); + pushButton.SelectedColor = new Vector4(0.0f, 1.0f, 0.0f, 1.0f); + pushButton.Clicked += (obj, e) => + { + Button sender = obj as Button; + sender.LabelText = "Click Me"; + sender.UnselectedColor = new Vector4(0.0f, 0.0f, 1.0f, 1.0f); + return true; + }; + + _contentContainer.AddChild(pushButton, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5)); + } + if (item.name.CompareTo("DropDown") == 0) + { + + } + if (item.name.CompareTo("Toggle") == 0) + { + ToggleButton toggleButton = new ToggleButton(); + PropertyArray array = new PropertyArray(); + array.Add(new PropertyValue(_resPath + "/images/star-highlight.png")); + array.Add(new PropertyValue(_resPath + "/images/star-mod.png")); + array.Add(new PropertyValue(_resPath + "/images/star-dim.png")); + toggleButton.StateVisuals = array; + + PropertyArray tooltips = new PropertyArray(); + tooltips.Add(new PropertyValue("State A")); + tooltips.Add(new PropertyValue("State B")); + tooltips.Add(new PropertyValue("State C")); + toggleButton.Tooltips = tooltips; + + toggleButton.WidthResizePolicy = ResizePolicyType.FillToParent; + toggleButton.HeightResizePolicy = ResizePolicyType.FillToParent; + toggleButton.Clicked += (obj, e) => + { + Tizen.Log.Debug("NUI", "Toggle button state changed."); + return true; + }; + + _contentContainer.AddChild(toggleButton, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5)); + } + if (item.name.CompareTo("InputField") == 0) + { + + } + if (item.name.CompareTo("AnimateGif") == 0) + { + + } + if (item.name.CompareTo("Loading") == 0) + { + + } + if (item.name.CompareTo("ProgressBar") == 0) + { + _progressBar = new ProgressBar(); + _progressBar.WidthResizePolicy = ResizePolicyType.FillToParent; + _progressBar.HeightResizePolicy = ResizePolicyType.Fixed; + _progressBar.Size2D = new Size2D(0, 100); + + _progressBar.ValueChanged += OnProgressBarValueChanged; + + _timer = new Timer(100); + _timer.Tick += (obj, e) => + { + float progress = (float)Math.Round(_progressBar.ProgressValue, 2); + + if (progress == 1.0f) + { + _progressBar.ProgressValue = 0.0f; + _progressBar.SecondaryProgressValue = 0.01f; + } + else + { + _progressBar.ProgressValue = progress + 0.01f; + _progressBar.SecondaryProgressValue = progress + 0.21f; + } + return true; + }; + _timer.Start(); + + _contentContainer.AddChild(_progressBar, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5)); + } + if (item.name.CompareTo("ScrollBar") == 0) + { + + } + if (item.name.CompareTo("CheckBox") == 0) + { + CheckBoxButton checkBoxButton = new CheckBoxButton(); + checkBoxButton.LabelText = "Yes"; + + _contentContainer.AddChild(checkBoxButton, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5)); + } + if (item.name.CompareTo("RadioButton") == 0) + { + TableView tableView = new TableView(2, 1); + tableView.WidthResizePolicy = ResizePolicyType.FillToParent; + tableView.HeightResizePolicy = ResizePolicyType.FillToParent; + + RadioButton rButton = new RadioButton(); + rButton.LabelText = "Yes"; + rButton.Selected = true; + tableView.AddChild(rButton, new TableView.CellPosition(0, 0)); + + rButton = new RadioButton(); + rButton.LabelText = "No"; + + tableView.AddChild(rButton, new TableView.CellPosition(1, 0)); + + _contentContainer.AddChild(tableView, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5)); + } + if (item.name.CompareTo("Tooltip") == 0) + { + TableView tableView = new TableView(2, 1); + tableView.WidthResizePolicy = ResizePolicyType.FillToParent; + tableView.HeightResizePolicy = ResizePolicyType.FillToParent; + + // Create two push buttons and add them to a table view + PushButton buttonWithSimpleTooltip = new PushButton(); + buttonWithSimpleTooltip.LabelText = "Tooltip with text only"; + buttonWithSimpleTooltip.UnselectedColor = new Vector4(0.5f, 0.5f, 0.7f, 1.0f); + buttonWithSimpleTooltip.SelectedColor = new Vector4(0.7f, 0.5f, 0.7f, 1.0f); + buttonWithSimpleTooltip.WidthResizePolicy = ResizePolicyType.FillToParent; + tableView.AddChild(buttonWithSimpleTooltip, new TableView.CellPosition(0, 0)); + + PushButton buttonWithIconTooltip = new PushButton(); + buttonWithIconTooltip.LabelText = "Tooltip with Text and Icon"; + buttonWithIconTooltip.WidthResizePolicy = ResizePolicyType.FillToParent; + buttonWithIconTooltip.UnselectedColor = new Vector4(0.5f, 0.5f, 0.7f, 1.0f); + buttonWithIconTooltip.SelectedColor = new Vector4(0.7f, 0.5f, 0.7f, 1.0f); + tableView.AddChild(buttonWithIconTooltip, new TableView.CellPosition(1, 0)); + + // Add a simple text only tooltip to the first push button + buttonWithSimpleTooltip.TooltipText = "Simple Tooltip"; + + // Create a property map for a tooltip with one icon and one text + PropertyArray iconTooltipContent = new PropertyArray(); + + PropertyMap iconVisual = new PropertyMap(); + iconVisual.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)) + .Add(ImageVisualProperty.URL, new PropertyValue(_resPath + "/images/star-highlight.png")); + iconTooltipContent.Add(new PropertyValue(iconVisual)); + + PropertyMap textVisual = new PropertyMap(); + textVisual.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text)) + .Add(TextVisualProperty.Text, new PropertyValue("Tooltip with Icon")); + iconTooltipContent.Add(new PropertyValue(textVisual)); + + PropertyMap iconTooltip = new PropertyMap(); + iconTooltip.Add(Tizen.NUI.Constants.Tooltip.Property.Content, new PropertyValue(iconTooltipContent)) + .Add(Tizen.NUI.Constants.Tooltip.Property.Tail, new PropertyValue(true)); + + // Add the tooltip with icon and text to the second push button + buttonWithIconTooltip.Tooltip = iconTooltip; + + _contentContainer.AddChild(tableView, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5)); + } + if (item.name.CompareTo("Popup") == 0) + { + PushButton button = new PushButton(); + button.LabelText = "Popup"; + button.PivotPoint = PivotPoint.Center; + button.MaximumSize = new Size2D(150, 100); + _popup = CreatePopup(); + _popup.SetTitle(CreateTitle("Popup")); + + TextLabel text = new TextLabel("This will erase the file permanently. Are you sure?"); + text.BackgroundColor = Color.White; + text.MultiLine = true; + text.WidthResizePolicy = ResizePolicyType.FillToParent; + text.HeightResizePolicy = ResizePolicyType.DimensionDependency; + text.SetPadding(new PaddingType(10.0f, 10.0f, 20.0f, 0.0f)); + _popup.SetContent(text); + _popup.Focusable = (true); + _popup.SetDisplayState(Popup.DisplayStateType.Hidden); + + button.Clicked += (obj, ee) => + { + _window.Add(_popup); + _popup.SetDisplayState(Popup.DisplayStateType.Shown); + FocusManager.Instance.SetCurrentFocusView((_popup.FindChildByName("Footer")).FindChildByName("OKButton")); + return true; + }; + _contentContainer.AddChild(button, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5)); + } + if (item.name.CompareTo("Toast") == 0) + { + PushButton button = new PushButton(); + button.LabelText = "Toast"; + button.PivotPoint = PivotPoint.Center; + button.Clicked += (obj, ee) => + { + Popup toast = new Popup(); + toast.SizeModeFactor = new Vector3(0.75f, 0.75f, 0.75f); + toast.WidthResizePolicy = ResizePolicyType.SizeRelativeToParent; + toast.HeightResizePolicy = ResizePolicyType.UseNaturalSize; + toast.ContextualMode = Popup.ContextualModeType.NonContextual; + toast.AnimationDuration = 0.65f; + toast.TailVisibility = false; + + // Disable the dimmed backing. + toast.BackingEnabled = false; + + // The toast popup should fade in (not zoom). + toast.AnimationMode = Popup.AnimationModeType.Fade; + + // The toast popup should auto-hide. + toast.AutoHideDelay = 3000; + + // Align to the bottom of the screen. + toast.ParentOrigin = new Position(0.5f, 0.94f, 0.5f); + toast.PivotPoint = PivotPoint.BottomCenter; + + // Let events pass through the toast popup. + toast.TouchTransparent = true; + + TextLabel text = new TextLabel("This is a Toast.\nIt will auto-hide itself"); + text.TextColor = Color.White; + text.MultiLine = true; + text.HorizontalAlignment = HorizontalAlignment.Center; + toast.SetTitle(text); + _window.Add(toast); + toast.DisplayState = Popup.DisplayStateType.Shown; + + return true; + }; + _contentContainer.AddChild(button, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5)); + } + if (item.name.CompareTo("ItemView") == 0) + { + + } + } + else + { + ImageView notSupportView = new ImageView(_resPath + "/images/not_yet_sign.png"); + notSupportView.Size2D = new Size2D((int)(_window.Size.Width * 0.2f), (int)(_window.Size.Height * 0.25f)); + notSupportView.Focusable = (true); + _contentContainer.AddChild(notSupportView, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5)); + } + } + Popup CreatePopup() + { + Popup confirmationPopup = new Popup(); + + View footer = new View(); + footer.Name = ("Footer"); + footer.WidthResizePolicy = ResizePolicyType.FillToParent; + footer.HeightResizePolicy = ResizePolicyType.Fixed; + footer.Size2D = new Size2D(0, 80); + footer.PivotPoint = PivotPoint.Center; + + PushButton okButton = CreateOKButton(); + okButton.PivotPoint = PivotPoint.Center; + okButton.WidthResizePolicy = ResizePolicyType.SizeFixedOffsetFromParent; + okButton.HeightResizePolicy = ResizePolicyType.SizeFixedOffsetFromParent; + okButton.SetSizeModeFactor(new Vector3(-20.0f, -20.0f, 0.0f)); + + PushButton cancelButton = CreateCancelButton(); + cancelButton.PivotPoint = PivotPoint.Center; + cancelButton.WidthResizePolicy = ResizePolicyType.SizeFixedOffsetFromParent; + cancelButton.HeightResizePolicy = ResizePolicyType.SizeFixedOffsetFromParent; + cancelButton.SetSizeModeFactor(new Vector3(-20.0f, -20.0f, 0.0f)); + + TableView controlLayout = new TableView(1, 2); + controlLayout.PivotPoint = PivotPoint.Center; + controlLayout.WidthResizePolicy = ResizePolicyType.FillToParent; + controlLayout.HeightResizePolicy = ResizePolicyType.FillToParent; + controlLayout.SetCellPadding(new Size2D(10, 10)); + controlLayout.SetRelativeWidth(0, 0.5f); + controlLayout.SetRelativeWidth(1, 0.5f); + controlLayout.SetCellAlignment(new TableView.CellPosition(0, 0), HorizontalAlignmentType.Center, VerticalAlignmentType.Center); + controlLayout.SetCellAlignment(new TableView.CellPosition(0, 1), HorizontalAlignmentType.Center, VerticalAlignmentType.Center); + controlLayout.AddChild(okButton, new TableView.CellPosition(0, 0)); + controlLayout.AddChild(cancelButton, new TableView.CellPosition(0, 1)); + + footer.Add(controlLayout); + + confirmationPopup.SetFooter(footer); + return confirmationPopup; + } + View CreateTitle(string title) + { + TextLabel titleView = new TextLabel(title); + titleView.TextColor = Color.White; + titleView.MultiLine = true; + titleView.HorizontalAlignment = HorizontalAlignment.Center; + return titleView; + } + + PushButton CreateOKButton() + { + PushButton okayButton = new PushButton(); + okayButton.Name = ("OKButton"); + okayButton.LabelText = "OK"; + okayButton.Focusable = (true); + okayButton.Clicked += (obj, ee) => + { + _popup.SetDisplayState(Popup.DisplayStateType.Hidden); + return true; + }; + return okayButton; + } + PushButton CreateCancelButton() + { + PushButton cancelButton = new PushButton(); + cancelButton.LabelText = "Cancel"; + cancelButton.Focusable = (true); + cancelButton.Clicked += (obj, ee) => + { + _popup.SetDisplayState(Popup.DisplayStateType.Hidden); + return true; + }; + return cancelButton; + } + + void OnProgressBarValueChanged(object source, ProgressBar.ValueChangedEventArgs e) + { + PropertyMap labelVisual = new PropertyMap(); + labelVisual.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text)) + .Add(TextVisualProperty.Text, new PropertyValue(Math.Round(e.ProgressBar.ProgressValue, 2) + " / " + Math.Round(e.ProgressBar.SecondaryProgressValue, 2))) + .Add(TextVisualProperty.PointSize, new PropertyValue(10.0f)); + e.ProgressBar.LabelVisual = labelVisual; + return; + } + + + /// + /// The main entry point for the application. + /// + + [STAThread] + static void _Main(string[] args) + { + Tizen.Log.Debug("NUI", "Hello Mono World"); + + Example example = new Example("/home/owner/apps_rw/NUISamples.TizenTV/res/json/control-dashboard-theme.json"); + + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/custom-control.cs b/test/NUITestSample/NUITestSample/examples/custom-control.cs new file mode 100755 index 000000000..df9e60eb9 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/custom-control.cs @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; +using Tizen.NUI; + +namespace CustomControlTest +{ + + // A custom control for star rating (draggable to change the rating) + class StarRating : CustomView + { + private const string resources = "/home/owner/apps_rw/NUISamples.TizenTV/res"; + private FlexContainer _container; + private ImageView[] _images; + private Vector3 _gestureDisplacement; + private int _currentValue; + private int _myRating; + private bool _myDragEnabled; + + // Called by DALi Builder if it finds a StarRating control in a JSON file + static CustomView CreateInstance() + { + return new StarRating(); + } + + // static constructor registers the control type (only runs once) + static StarRating() + { + // ViewRegistry registers control type with DALi type registery + // also uses introspection to find any properties that need to be registered with type registry + CustomViewRegistry.Instance.Register(CreateInstance, typeof(StarRating) ); + } + + public StarRating() : base(typeof(StarRating).Name, CustomViewBehaviour.ViewBehaviourDefault) + { + } + + public override void OnInitialize() + { + // Create a container for the star images + _container = new FlexContainer(); + + _container.FlexDirection = FlexContainer.FlexDirectionType.Row; + _container.WidthResizePolicy = ResizePolicyType.FillToParent; + _container.HeightResizePolicy = ResizePolicyType.FillToParent; + + this.Add(_container); + + // Create the images + _images = new ImageView[5]; + + for(int i = 0; i < 5; i++) + { + _images[i] = new ImageView(resources+"/images/star-dim.png"); + _container.Add( _images[i] ); + } + + // Update the images according to the rating (dimmed star by default) + _myRating = 0; + UpdateStartImages(_myRating); + + // Enable pan gesture detection + EnableGestureDetection(Gesture.GestureType.Pan); + _myDragEnabled = true; // Allow dragging by default (can be disabled) + } + + // Pan gesture handling + public override void OnPan(PanGesture gesture) + { + // Only handle pan gesture if dragging is allowed + if(_myDragEnabled) + { + switch (gesture.State) + { + case Gesture.StateType.Started: + { + _gestureDisplacement = new Vector3(0.0f, 0.0f, 0.0f); + _currentValue = 0; + break; + } + case Gesture.StateType.Continuing: + { + // Calculate the rating according to pan desture displacement + _gestureDisplacement.X += gesture.Displacement.X; + int delta = (int)Math.Ceiling(_gestureDisplacement.X / 40.0f); + _currentValue = _myRating + delta; + + // Clamp the rating + if(_currentValue < 0) _currentValue = 0; + if(_currentValue > 5) _currentValue = 5; + + // Update the images according to the rating + UpdateStartImages(_currentValue); + break; + } + default: + { + _myRating = _currentValue; + break; + } + } + } + } + + // Update the images according to the rating + private void UpdateStartImages(int rating) + { + for(int i = 0; i < rating; i++) + { + _images[i].WidthResizePolicy = ResizePolicyType.UseNaturalSize; + _images[i].HeightResizePolicy = ResizePolicyType.UseNaturalSize; + _images[i].SetImage(resources+"/images/star-highlight.png"); + } + + for(int i = rating; i < 5; i++) + { + _images[i].WidthResizePolicy = ResizePolicyType.UseNaturalSize; + _images[i].HeightResizePolicy = ResizePolicyType.UseNaturalSize; + _images[i].SetImage(resources+"/images/star-dim.png"); + } + } + + // Rating property of type int: + public int Rating + { + get + { + return _myRating; + } + set + { + _myRating = value; + UpdateStartImages(_myRating); + } + } + + // DragEnabled property of type bool: + public bool DragEnabled + { + get + { + return _myDragEnabled; + } + set + { + _myDragEnabled = value; + } + } + } + + class Example : NUIApplication + { + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + delegate void CallbackDelegate(); + private const string resources = "/home/owner/apps_rw/NUISamples.TizenTV/res"; + + + public Example() : base() + { + } + + public Example(string stylesheet) : base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + // Create a container to layout the rows of image and rating vertically + FlexContainer container = new FlexContainer(); + + container.ParentOrigin = ParentOrigin.TopLeft; + container.PivotPoint = PivotPoint.TopLeft; + container.FlexDirection = (int)FlexContainer.FlexDirectionType.Column; + container.WidthResizePolicy = ResizePolicyType.FillToParent; + container.HeightResizePolicy = ResizePolicyType.FillToParent; + + window.Add(container); + + Random random = new Random(); + + for(int i = 0; i < 6; i++) // 6 rows in total + { + // Create a container to layout the image and rating (in each row) horizontally + FlexContainer imageRow = new FlexContainer(); + imageRow.ParentOrigin = ParentOrigin.TopLeft; + imageRow.PivotPoint = PivotPoint.TopLeft; + imageRow.FlexDirection = FlexContainer.FlexDirectionType.Row; + imageRow.Flex = 1.0f; + container.Add(imageRow); + + // Add the image view to the row + ImageView image = new ImageView(resources+"/images/gallery-" + i + ".jpg"); + image.Size2D = new Size2D(120, 120); + image.WidthResizePolicy = ResizePolicyType.Fixed; + image.HeightResizePolicy = ResizePolicyType.Fixed; + image.AlignSelf = (int)FlexContainer.Alignment.AlignCenter; + image.Flex = 0.3f; + image.FlexMargin = new Vector4(10.0f, 0.0f, 0.0f, 0.0f); + imageRow.Add(image); + + // Create a rating control + StarRating view = new StarRating(); + + // Add the rating control to the row + view.ParentOrigin = ParentOrigin.Center; + view.PivotPoint = PivotPoint.Center; + view.Size2D = new Size2D(200, 40); + view.Flex = 0.7f; + view.AlignSelf = (int)FlexContainer.Alignment.AlignCenter; + view.FlexMargin = new Vector4(30.0f, 0.0f, 0.0f, 0.0f); + imageRow.Add(view); + + // Set the initial rating randomly between 1 and 5 + view.Rating = random.Next(1, 6); + } + } + + /// + /// The main entry point for the application. + /// + [STAThread] + static void _Main(string[] args) + { + //System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (typeof(MyCSharpExample.StarRating).TypeHandle); + + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/dali-test.cs b/test/NUITestSample/NUITestSample/examples/dali-test.cs new file mode 100755 index 000000000..08aadd604 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/dali-test.cs @@ -0,0 +1,914 @@ +/* + * Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; + +namespace DaliTest +{ + class MyView : View + { + private string _myOwnName; + public int _myCurrentValue; + + public MyView() + { + _myCurrentValue = 0; + } + + public string MyOwnName + { + get + { + return _myOwnName; + } + set + { + _myOwnName = value; + } + } + } + + class MyButton : PushButton + { + private string _myOwnName; + public int _myCurrentValue; + + public MyButton() + { + _myCurrentValue = 0; + } + + public string MyOwnName + { + get + { + return _myOwnName; + } + set + { + _myOwnName = value; + } + } + } + + class MySpin : Spin + { + private string _myOwnName; + public int _myCurrentValue; + + public MySpin() + { + _myCurrentValue = 0; + } + + public string MyOwnName + { + get + { + return _myOwnName; + } + set + { + _myOwnName = value; + } + } + } + + class Example : NUIApplication + { + //private const string _resPath = "/home/owner/apps_rw/NUISamples.TizenTV/res"; + private const string _resPath = "./res"; //for ubuntu + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + delegate void CallbackDelegate(IntPtr appPtr); // void, void delgate + + public Example() : base() + { + } + + public Example(string stylesheet) : base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + public void Initialize() + { + DowncastTest(); + + NavigationPropertiesTests(); + + OperatorTests(); + + CustomViewPropertyTest(); + + VisibilityChangeTest(); + + ResourceReadyTest(); + + ViewFocusTest(); + + WindowDevelPropertyTest(); + + Animatable handle = new Animatable(); + int myPropertyIndex = handle.RegisterProperty("myProperty", new PropertyValue(10.0f), PropertyAccessMode.ReadWrite); + float myProperty = 0.0f; + handle.GetProperty(myPropertyIndex).Get(out myProperty); + Tizen.Log.Debug("NUI", "myProperty value: " + myProperty ); + + int myPropertyIndex2 = handle.RegisterProperty("myProperty2", new PropertyValue(new Size(5.0f, 5.0f, 0.0f)), PropertyAccessMode.ReadWrite); + Size2D myProperty2 = new Size2D(0, 0); + handle.GetProperty(myPropertyIndex2).Get(myProperty2); + Tizen.Log.Debug("NUI", "myProperty2 value: " + myProperty2.Width + ", " + myProperty2.Height ); + + View view = new View(); + view.Size2D = new Size2D(200, 200); + view.Name = "MyView"; + //view.MixColor = new Color(1.0f, 0.0f, 1.0f, 0.8f); + Tizen.Log.Debug("NUI", "View size: " + view.Size2D.Width + ", " + view.Size2D.Height); + Tizen.Log.Debug("NUI", "View name: " + view.Name); + + Window window = Window.Instance; + window.BackgroundColor = Color.White; + Size windowSize = new Size(window.Size.Width, window.Size.Height, 0.0f); + Tizen.Log.Debug("NUI", "Window size: " + windowSize.Width + ", " + windowSize.Height); + window.Add(view); + + TextLabel text = new TextLabel("Hello Mono World"); + text.ParentOrigin = ParentOrigin.Center; + text.PivotPoint = PivotPoint.Center; + text.HorizontalAlignment = HorizontalAlignment.Center; + window.Add(text); + + Tizen.Log.Debug("NUI", "Text label text: " + text.Text ); + + Tizen.Log.Debug("NUI", "Text label point size: " + text.PointSize ); + text.PointSize = 32.0f; + Tizen.Log.Debug("NUI", "Text label new point size: " + text.PointSize ); + + RectanglePaddingClassTest(); + + Tizen.Log.Debug("NUI", " *************************" ); + Size Size = new Size(100, 50, 0); + Tizen.Log.Debug("NUI", " Created " + Size ); + Tizen.Log.Debug("NUI", " Size x = " + Size.Width + ", y = " + Size.Height ); + Size += new Size(20, 20, 0); + Tizen.Log.Debug("NUI", " Size x = " + Size.Width + ", y = " + Size.Height ); + Size.Width += 10; + Size.Height += 10; + Tizen.Log.Debug("NUI", " Size width = " + Size.Width + ", height = " + Size.Height ); + + Tizen.Log.Debug("NUI", " *************************" ); + Position Position = new Position(20, 100, 50); + Tizen.Log.Debug("NUI", " Created " + Position ); + Tizen.Log.Debug("NUI", " Position x = " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z ); + Position += new Position(20, 20, 20); + Tizen.Log.Debug("NUI", " Position x = " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z ); + Position.X += 10; + Position.Y += 10; + Position.Z += 10; + Tizen.Log.Debug("NUI", " Position width = " + Position.X + ", height = " + Position.Y + ", depth = " + Position.Z ); + + Tizen.Log.Debug("NUI", " *************************" ); + Color color = new Color(20, 100, 50, 200); + Tizen.Log.Debug("NUI", " Created " + color ); + Tizen.Log.Debug("NUI", " Color R = " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A ); + color += new Color(20, 20, 20, 20); + Tizen.Log.Debug("NUI", " Color R = " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A ); + color.R += 10; + color.G += 10; + color.B += 10; + color.A += 10; + Tizen.Log.Debug("NUI", " Color r = " + color.R + ", g = " + color.G + ", b = " + color.B + ", a = " + color.A ); + + ViewDownCastTest(); + } + + public void RectanglePaddingClassTest() + { + using (Rectangle r1 = new Rectangle(2, 5, 20, 30)) + { + Tizen.Log.Debug("NUI", " Created " + r1 ); + Tizen.Log.Debug("NUI", " IsEmpty() = " + r1.IsEmpty() ); + Tizen.Log.Debug("NUI", " Left = " + r1.Left() ); + Tizen.Log.Debug("NUI", " Right = " + r1.Right() ); + Tizen.Log.Debug("NUI", " Top = " + r1.Top() ); + Tizen.Log.Debug("NUI", " Bottom = " + r1.Bottom() ); + Tizen.Log.Debug("NUI", " Area = " + r1.Area() ); + } + + Tizen.Log.Debug("NUI", " *************************" ); + + using (Rectangle r2 = new Rectangle(2, 5, 20, 30)) + { + Tizen.Log.Debug("NUI", " Created " + r2 ); + r2.Set(1,1,40,40); + Tizen.Log.Debug("NUI", " IsEmpty() = " + r2.IsEmpty() ); + Tizen.Log.Debug("NUI", " Left = " + r2.Left() ); + Tizen.Log.Debug("NUI", " Right = " + r2.Right() ); + Tizen.Log.Debug("NUI", " Top = " + r2.Top() ); + Tizen.Log.Debug("NUI", " Bottom = " + r2.Bottom() ); + Tizen.Log.Debug("NUI", " Area = " + r2.Area() ); + } + + Tizen.Log.Debug("NUI", " *************************" ); + + Rectangle r3 = new Rectangle(10, 10, 20, 20); + Rectangle r4 = new Rectangle(10, 10, 20, 20); + + if (r3 == r4) + { + Tizen.Log.Debug("NUI", "r3 == r4"); + } + else + { + Tizen.Log.Debug("NUI", "r3 != r4"); + } + + r4 = new Rectangle(12, 10, 20, 20); + + if (r3 == r4) + { + Tizen.Log.Debug("NUI", "r3 == r4"); + } + else + { + Tizen.Log.Debug("NUI", "r3 != r4"); + } + + PaddingType p1 = new PaddingType(10.5f, 10.7f, 20.8f, 20.8f); + PaddingType p2 = new PaddingType(10.5f, 10.7f, 20.8f, 20.8f); + + if (p1 == p2) + { + Tizen.Log.Debug("NUI", "p1 == p2"); + } + else + { + Tizen.Log.Debug("NUI", "p1 != p2"); + } + + p2 = new PaddingType(12.0f, 10.7f, 20.2f, 20.0f); + + if (p1 == p2) + { + Tizen.Log.Debug("NUI", "p1 == p2"); + } + else + { + Tizen.Log.Debug("NUI", "p1 != p2"); + } + } + + public void NavigationPropertiesTests() + { + View view = new View(); + View leftView, rightView, upView, downView, tmpView; + + leftView = new View(); + leftView.Name = "leftView"; + rightView = new View(); + rightView.Name = "rightView"; + upView = new View(); + upView.Name = "upView"; + downView = new View(); + downView.Name = "downView"; + + Window.Instance.Add(leftView); + Window.Instance.Add(rightView); + Window.Instance.Add(upView); + Window.Instance.Add(downView); + + view.LeftFocusableView = leftView; + tmpView = view.LeftFocusableView; + if (string.Compare(tmpView.Name, "leftView") == 0) + { + Tizen.Log.Debug("NUI", "Passed: LeftFocusedView = " + tmpView.Name); + } + else + { + Tizen.Log.Debug("NUI", "Failed: LeftFocusedView = " + tmpView.Name); + } + + view.RightFocusableView = rightView; + tmpView = view.RightFocusableView; + if (string.Compare(tmpView.Name, "rightView") == 0) + { + Tizen.Log.Debug("NUI", "Passed: RightFocusedView = " + tmpView.Name); + } + else + { + Tizen.Log.Debug("NUI", "Failed: RightFocusedView = " + tmpView.Name); + } + + Window.Instance.Add(view); + + view.UpFocusableView = upView; + tmpView = view.UpFocusableView; + if (string.Compare(tmpView.Name, "upView") == 0) + { + Tizen.Log.Debug("NUI", "Passed: UpFocusedView = " + tmpView.Name); + } + else + { + Tizen.Log.Debug("NUI", "Failed: UpFocusedView = " + tmpView.Name); + } + + view.DownFocusableView = downView; + tmpView = view.DownFocusableView; + if (string.Compare(tmpView.Name, "downView") == 0) + { + Tizen.Log.Debug("NUI", "Passed: DownFocusedView = " + tmpView.Name); + } + else + { + Tizen.Log.Debug("NUI", "Failed: DownFocusedView = " + tmpView.Name); + } + + Window.Instance.Remove(leftView); + tmpView = view.LeftFocusableView; + if (!tmpView) + { + Tizen.Log.Debug("NUI", "Passed: NULL LeftFocusedView"); + } + else + { + Tizen.Log.Debug("NUI", "Failed: LeftFocusedView = " + tmpView.Name); + } + } + + public void OperatorTests() + { + View view = new View(); + View differentView = new View(); + View viewSame = view; + View nullView = null; + + // test the true operator + if ( view ) + { + Tizen.Log.Debug("NUI", "BaseHandle Operator true (view) : test passed "); + } + else + { + Tizen.Log.Debug("NUI", "BaseHandle Operator true (view): test failed "); + } + + View parent = view.Parent; + + if ( parent ) + { + Tizen.Log.Debug("NUI", "Handle with Empty body :failed "); + } + else + { + Tizen.Log.Debug("NUI", "Valid with Empty body :passed "); + } + + view.Add( differentView ); + + // here we test two different C# objects, which on the native side have the same body/ ref-object + if ( view == differentView.Parent ) + { + Tizen.Log.Debug("NUI", "view == differentView.GetParent() :passed "); + } + else + { + Tizen.Log.Debug("NUI", "view == differentView.GetParent() :failed "); + } + + if ( differentView == differentView.Parent ) + { + Tizen.Log.Debug("NUI", "differentView == differentView.GetParent() :failed "); + } + else + { + Tizen.Log.Debug("NUI", "differentView == differentView.GetParent() :passed "); + } + + if ( nullView ) + { + Tizen.Log.Debug("NUI", "BaseHandle Operator true (nullView) : test failed "); + } + else + { + Tizen.Log.Debug("NUI", "BaseHandle Operator true (nullView): test passed "); + } + + // ! operator + if ( !view ) + { + Tizen.Log.Debug("NUI", "BaseHandle Operator !(view) : test failed "); + } + else + { + Tizen.Log.Debug("NUI", "BaseHandle Operator !(view): test passed "); + } + + if ( !nullView ) + { + Tizen.Log.Debug("NUI", "BaseHandle Operator !(nullView) : test passed "); + } + else + { + Tizen.Log.Debug("NUI", "BaseHandle Operator !(nullView): test failed "); + } + + // Note: operator false only used inside & operator + // test equality operator == + if ( view == viewSame ) + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (view == viewSame) : test passed"); + } + else + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (view == viewSame) : test failed"); + } + + if ( view == differentView ) + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (view == differentView) : test failed"); + } + else + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (view == differentView) : test passed"); + } + + if ( view == nullView ) + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (view == nullView) : test failed"); + } + else + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (view == nullView) : test passed"); + } + + if ( nullView == nullView ) + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (nullView == nullView) : test passed"); + } + else + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (nullView == nullView) : test failed"); + } + + // test || operator + if ( view || viewSame ) + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (view || viewSame) : test passed"); + } + else + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (view || viewSame) : test failed"); + } + + if ( view || nullView ) + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (view || nullView) : test passed"); + } + else + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (view || nullView) : test failed"); + } + + if ( nullView || nullView ) + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (nullView || nullView) : test failed"); + } + else + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (nullView || nullView) : test passed"); + } + + // test && operator + if ( view && viewSame ) + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (view && viewSame) : test passed"); + } + else + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (view && viewSame) : test failed"); + } + + if ( view && nullView ) + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (view && nullView) : test failed"); + } + else + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (view && nullView) : test passed"); + } + + if ( nullView && nullView ) + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (nullView && nullView) : test failed"); + } + else + { + Tizen.Log.Debug("NUI", "BaseHandle Operator (nullView && nullView) : test passed"); + } + } + + + private TextLabel label; + public void VisibilityChangeTest() + { + label = new TextLabel(); + label.Text = "Visibility"; + label.TextColor = Color.Red; + label.PointSize = 30.0f; + label.ParentOrigin = ParentOrigin.TopLeft; + label.PivotPoint = PivotPoint.TopLeft; + label.Position = new Position(0.0f, 50.0f, 0.0f); + Window.Instance.Add(label); + label.VisibilityChanged += (sender, e) => + { + if (e.Visibility) + Tizen.Log.Debug("NUI", "VisibilityChanged, label show."); + else + Tizen.Log.Debug("NUI", "VisibilityChanged, label hide."); + }; + + PushButton button = new PushButton(); + button.LabelText = "Change Visibility"; + button.ParentOrigin = ParentOrigin.TopLeft; + button.PivotPoint = PivotPoint.TopLeft; + Window.Instance.Add(button); + button.Clicked += (sender, e) => + { + if (label.Visible) + { + label.Hide(); + } + else + { + label.Show(); + } + + return true; + }; + } + + public void ResourceReadyTest() + { + ImageView image = new ImageView(); + image.ResourceUrl = _resPath + "/images/dog-anim.gif"; + image.Size2D = new Size2D(150, 150); + image.ParentOrigin = ParentOrigin.TopLeft; + image.PivotPoint = PivotPoint.TopLeft; + image.Position = new Position(0.0f, 150.0f, 0.0f); + image.ResourceReady += (sender, e) => + { + Tizen.Log.Debug("NUI", "Resource is ready!"); + }; + Window.Instance.Add(image); + } + + public void ViewFocusTest() + { + View view1 = new View(); + view1.BackgroundColor = Color.Red; + view1.Size2D = new Size2D(80, 50); + view1.ParentOrigin = ParentOrigin.CenterLeft; + view1.PivotPoint = PivotPoint.CenterLeft; + view1.Position = new Position(10.0f, 50.0f, 0.0f); + view1.Focusable = true; + View view2 = new View(); + view2.BackgroundColor = Color.Cyan; + view2.Size2D = new Size2D(80, 50); + view2.ParentOrigin = ParentOrigin.CenterLeft; + view2.PivotPoint = PivotPoint.CenterLeft; + view2.Position = new Position(100.0f, 50.0f, 0.0f); + view2.Focusable = true; + view1.RightFocusableView = view2; + view2.LeftFocusableView = view1; + Window.Instance.Add(view1); + Window.Instance.Add(view2); + FocusManager.Instance.SetCurrentFocusView(view1); + + PushButton button = new PushButton(); + button.LabelText = "Focus Back"; + button.Size2D = new Size2D(150, 50); + button.ParentOrigin = ParentOrigin.CenterLeft; + button.PivotPoint = PivotPoint.CenterLeft; + button.Position = new Position(190.0f, 50.0f, 0.0f); + + button.Focusable = true; + view2.RightFocusableView = button; + + button.Pressed += (obj, e) => + { + FocusManager.Instance.MoveFocusBackward(); + return true; + }; + Window.Instance.Add(button); + } + + public void WindowDevelPropertyTest() + { + Window window = Window.Instance; + uint count = window.GetSupportedAuxiliaryHintCount(); + if (count > 0) + { + window.BackgroundColor = Color.Blue; + } + uint id = window.AddAuxiliaryHint("wm.policy.win.effect.disable", "1"); + window.RemoveAuxiliaryHint(id); + window.RemoveAuxiliaryHint(2); + + id = window.AddAuxiliaryHint("wm.policy.win.effect.disable", "1"); + window.SetAuxiliaryHintValue(id, "0"); + string value = window.GetAuxiliaryHintValue(id); + if(value.Length > 0) + { + window.BackgroundColor = Color.Red; + } + + window.SetInputRegion(new Rectangle(0, 0, 0, 0)); + WindowType type = window.Type; + Tizen.Log.Debug("NUI", "window type is "+type); + window.Type = WindowType.Notification; + + NotificationLevel level = window.GetNotificationLevel(); + window.SetNotificationLevel(NotificationLevel.High); + level = window.GetNotificationLevel(); + Tizen.Log.Debug("NUI", "window notification level is " + level); + + window.SetOpaqueState(true); + Tizen.Log.Debug("NUI", "window is opaque? " + window.IsOpaqueState()); + + window.SetScreenOffMode(ScreenOffMode.Never); + ScreenOffMode screenMode = window.GetScreenOffMode(); + Tizen.Log.Debug("NUI", "window screen mode is " + screenMode); + + bool ret = window.SetBrightness(50); + int brightness = window.GetBrightness(); + Tizen.Log.Debug("NUI", "window brightness is " + brightness, ", return "+ret); + } + + public void CustomViewPropertyTest() + { + // Create a Spin control + Spin spin = new Spin(); + + // Background property + PropertyMap background = new PropertyMap(); + background.Add( Visual.Property.Type, new PropertyValue((int)Visual.Type.Color) ) + .Add( ColorVisualProperty.MixColor, new PropertyValue(Color.Red) ); + spin.Background = background; + + background = spin.Background; + Color backgroundColor = new Color(); + background.Find(ColorVisualProperty.MixColor, "mixColor")?.Get(backgroundColor); + if( backgroundColor == Color.Red ) + { + Tizen.Log.Debug("NUI", "Custom View Background property : test passed"); + } + else + { + Tizen.Log.Debug("NUI", "Custom View Background property : test failed"); + } + + // BackgroundColor property + spin.BackgroundColor = Color.Yellow; + if(spin.BackgroundColor == Color.Yellow) + { + Tizen.Log.Debug("NUI", "Custom View BackgroundColor property : test passed"); + } + else + { + Tizen.Log.Debug("NUI", "Custom View BackgroundColor property : test failed"); + } + + // BackgroundImage property + spin.BackgroundImage = "background-image.jpg"; + if(spin.BackgroundImage == "background-image.jpg") + { + Tizen.Log.Debug("NUI", "Custom View BackgroundImage property : test passed"); + } + else + { + Tizen.Log.Debug("NUI", "Custom View BackgroundImage property : test failed"); + } + + // StyleName property + spin.StyleName = "MyCustomStyle"; + if(spin.StyleName == "MyCustomStyle") + { + Tizen.Log.Debug("NUI", "Custom View StyleName property : test passed"); + } + else + { + Tizen.Log.Debug("NUI", "Custom View StyleName property : test failed"); + } + } + + public void ViewDownCastTest() + { + View container = new View(); + container.Position = new Position(-800.0f, -800.0f, 0.0f); + Window.Instance.Add(container); + Tizen.Log.Debug("NUI", "winow layer count is "+Window.Instance.LayerCount); + Tizen.Log.Debug("NUI", "winow default layer child at 0 is "+Window.Instance.GetDefaultLayer().GetChildAt(0)); + // Test downcast for native control + TextLabel myLabel = new TextLabel(); + myLabel.Name = "MyLabelName"; + myLabel.Text = "MyText"; + + Tizen.Log.Debug("NUI", "myLabel.Name = " + myLabel.Name + ", Text = " + myLabel.Text); + + container.Add(myLabel); + + View myLabelView = container.FindChildByName("MyLabelName"); + if(myLabelView) + { + TextLabel newLabel = myLabelView as TextLabel; + if(newLabel) + { + Tizen.Log.Debug("NUI", "Downcast to TextLabel successful: newLabel Name = " + newLabel.Name + ", Text = " + newLabel.Text); + } + else + { + Tizen.Log.Debug("NUI", "Downcast to TextLabel failed!"); + } + } + + // Test downcast for class directly inherited from View + MyView myView = new MyView(); + myView.Name = "MyViewName"; + myView.MyOwnName = "MyOwnViewName"; + myView._myCurrentValue = 5; + + Tizen.Log.Debug("NUI", "myView.Name = " + myView.Name + ", MyOwnName = " + myView.MyOwnName + ", myCurrentValue = " + myView._myCurrentValue); + + container.Add(myView); + + View myViewView = container.FindChildByName("MyViewName"); + if(myViewView) + { + MyView newView = myViewView as MyView; + if(newView) + { + Tizen.Log.Debug("NUI", "Downcast to MyView successful: newView Name = " + newView.Name + ", MyOwnName = " + newView.MyOwnName + ", myCurrentValue = " + newView._myCurrentValue); + } + else + { + Tizen.Log.Debug("NUI", "Downcast to MyView failed!"); + } + } + + // Test downcast for class directly inherited from native control + MyButton myButton = new MyButton(); + myButton.Name = "MyButtonName"; + myButton.MyOwnName = "MyOwnViewName"; + myButton.LabelText = "MyLabelText"; + myButton._myCurrentValue = 5; + + Tizen.Log.Debug("NUI", "myButton.Name = " + myButton.Name + ", MyOwnName = " + myButton.MyOwnName + ", LabelText = " + myButton.LabelText + ", myCurrentValue = " + myButton._myCurrentValue); + + container.Add(myButton); + + View myButtonView = container.FindChildByName("MyButtonName"); + if(myButtonView) + { + MyButton newButton = myButtonView as MyButton; + if(newButton) + { + Tizen.Log.Debug("NUI", "Downcast to MyButton successful: newButton Name = " + newButton.Name + ", MyOwnName = " + newButton.MyOwnName + ", LabelText = " + myButton.LabelText + ", myCurrentValue = " + newButton._myCurrentValue); + } + else + { + Tizen.Log.Debug("NUI", "Downcast to MyButton failed!"); + } + } + + // Test downcast for a CustomView + Spin spin = new Spin(); + spin.Name = "SpinName"; + spin.MaxValue = 8888; + + Tizen.Log.Debug("NUI", "spin.Name = " + spin.Name + ", MaxValue = " + spin.MaxValue); + + container.Add(spin); + + View spinView = container.FindChildByName("SpinName"); + if(spinView) + { + Spin newSpin = spinView as Spin; + if(newSpin) + { + Tizen.Log.Debug("NUI", "Downcast to Spin successful: newSpin Name = " + newSpin.Name + ", MaxValue = " + newSpin.MaxValue); + } + else + { + Tizen.Log.Debug("NUI", "Downcast to Spin failed!"); + } + } + + // Test downcast for class inherited from a CustomView + MySpin mySpin = new MySpin(); + mySpin.Name = "MySpinName"; + mySpin.MyOwnName = "MyOwnSpinName"; + mySpin.MaxValue = 8888; + mySpin._myCurrentValue = 5; + + Tizen.Log.Debug("NUI", "mySpin.Name = " + mySpin.Name + ", MyOwnName = " + mySpin.MyOwnName + ", MaxValue = " + mySpin.MaxValue + ", currentValue = " + mySpin._myCurrentValue); + + container.Add(mySpin); + + View mySpinView = container.FindChildByName("MySpinName"); + if(mySpinView) + { + MySpin newSpin = mySpinView as MySpin; + if(newSpin) + { + Tizen.Log.Debug("NUI", "Downcast to MySpin successful: newSpin Name = " + newSpin.Name + ", MyOwnName = " + newSpin.MyOwnName + ", MaxValue = " + newSpin.MaxValue + ", currentValue = " + newSpin._myCurrentValue); + } + else + { + Tizen.Log.Debug("NUI", "Downcast to MySpin failed!"); + } + } + } + + + + public void DowncastTest() + { + //Create a View as a child of parent View, get it use parent.GetChildAt(i), then DownCast to View handle, but call BackgroundColor property will crash. + View parent = new View(); + View[] childs = new View[5]; + + for (int i = 0; i < 5; i++) + { + childs[i] = new View(); + childs[i].Name = "child_view_" + i; + childs[i].BackgroundColor = Color.Red; + parent.Add(childs[i]); + } + + for (uint i = 0; i < parent.ChildCount; i++) + { + View childView = parent.GetChildAt(i); + if (childView) + { + Tizen.Log.Debug("NUI", "Type[" + childView.GetTypeName() + "] BGColor[" + childView.BackgroundColor.R + "]" + " Name[" + childView.Name + "]"); + } + } + + PushButton button = new PushButton(); + button.LabelText = "ButtonTest!"; + button.BackgroundColor = Color.White; + View parentView = new View(); + parentView.Add(button); + PushButton view = parentView.GetChildAt(0) as PushButton; + if (view) + { + Tizen.Log.Debug("NUI", "NUI view GetTypeName= " + view.GetTypeName()); + Tizen.Log.Debug("NUI", "NUI view LabelText= " + view.LabelText); + Tizen.Log.Debug("NUI", "NUI view color= " + view.BackgroundColor.R); + } + } + + + + /// + /// The main entry point for the application. + /// + [STAThread] + static void _Main(string[] args) + { + Tizen.Log.Debug("NUI", "Hello Mono World"); + + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/date-picker-using-json/ViewRegistryHelper.cs b/test/NUITestSample/NUITestSample/examples/date-picker-using-json/ViewRegistryHelper.cs new file mode 100755 index 000000000..95a86d8de --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/date-picker-using-json/ViewRegistryHelper.cs @@ -0,0 +1,16 @@ +using System; +using Tizen.NUI; + + +namespace DatePickerUsingJson +{ + public class ViewRegistryHelper + { + static public void Initialize() + { + // Register all views with the type registry + System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (typeof(Spin).TypeHandle); + } + } +} + diff --git a/test/NUITestSample/NUITestSample/examples/date-picker-using-json/date-picker-using-json.cs b/test/NUITestSample/NUITestSample/examples/date-picker-using-json/date-picker-using-json.cs new file mode 100755 index 000000000..56e7ab956 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/date-picker-using-json/date-picker-using-json.cs @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; + +namespace DatePickerUsingJson +{ + // A spin control (for continously changing values when users can easily predict a set of values) + + class Example : NUIApplication + { + private Spin _spinYear; // spin control for year + private Spin _spinMonth; // spin control for month + private Spin _spinDay; // spin control for day + //private Builder _builder; // DALi Builder + + //private const string _resPath = "/home/owner/apps_rw/NUISamples.TizenTV/res"; + private const string _resPath = "./res"; //for ubuntu + + public Example() : base() + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + //This is required for the Application which uses JSON theme and style of Dali builder + ViewRegistryHelper.Initialize(); + /* + // load date JSON template... + _builder = new Builder (); + + // Optional constant to see logging information coming out + // of DALi JSON parser (builder) + PropertyMap constants = new PropertyMap(); + constants.Insert( "CONFIG_SCRIPT_LOG_LEVEL", new PropertyValue( "Verbose") ); + _builder.AddConstants( constants ); + + _builder.LoadFromFile(_resPath + "/json/date-picker-template.json" ); + + // create the date-picker from the template in the json file + View actorTree = _builder.Create( "date-picker"); + + window.Add( actorTree ); + + View year = actorTree.FindChildByName("Year"); + View month = actorTree.FindChildByName("Month" ); + View day = actorTree.FindChildByName("Day"); + + // need to get the actual C# Spin object associated with the actor, + _spinYear = year as Spin; + _spinMonth = month as Spin; + _spinDay = day as Spin; + + _spinYear.Value = 2099; + _spinMonth.Value = 5; + _spinDay.Value = 23; + + _spinYear.Focusable = (true); + _spinMonth.Focusable = (true); + _spinDay.Focusable = (true); + + FocusManager keyboardFocusManager = FocusManager.Instance; + keyboardFocusManager.PreFocusChange += OnKeyboardPreFocusChange; + //keyboardFocusManager.FocusedViewActivated += OnFocusedViewActivated; + + StyleManager.Get().ApplyTheme(_resPath + "/json/date-picker-theme.json"); + */ + } + + private View OnKeyboardPreFocusChange(object source, FocusManager.PreFocusChangeEventArgs e) + { + View nextFocusView = e.ProposedView; + + // When nothing has been focused initially, focus the text field in the first spin + if (!e.CurrentView && !e.ProposedView) + { + nextFocusView = _spinYear.SpinText; + } + else if(e.Direction == View.FocusDirection.Left) + { + // Move the focus to the spin in the left of the current focused spin + if(e.CurrentView == _spinMonth.SpinText) + { + nextFocusView = _spinYear.SpinText; + } + else if(e.CurrentView == _spinDay.SpinText) + { + nextFocusView = _spinMonth.SpinText; + } + } + else if(e.Direction == View.FocusDirection.Right) + { + // Move the focus to the spin in the right of the current focused spin + if(e.CurrentView == _spinYear.SpinText) + { + nextFocusView = _spinMonth.SpinText; + } + else if(e.CurrentView == _spinMonth.SpinText) + { + nextFocusView = _spinDay.SpinText; + } + } + + return nextFocusView; + } + /* + private void OnFocusedViewActivated(object source, FocusManager.FocusedViewActivatedEventArgs e) + { + // Make the text field in the current focused spin to take the key input + KeyInputFocusManager manager = KeyInputFocusManager.Get(); + + if (e.View == _spinYear.SpinText) + { + if (manager.GetCurrentFocusControl() != _spinYear.SpinText) + { + manager.SetFocus(_spinYear.SpinText); + } + } + else if (e.View == _spinMonth.SpinText) + { + if (manager.GetCurrentFocusControl() != _spinMonth.SpinText) + { + manager.SetFocus(_spinMonth.SpinText); + } + } + else if (e.View == _spinDay.SpinText) + { + if (manager.GetCurrentFocusControl() != _spinDay.SpinText) + { + manager.SetFocus(_spinDay.SpinText); + } + } + } + */ + + /// + /// The main entry point for the application. + /// + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/date-picker.cs b/test/NUITestSample/NUITestSample/examples/date-picker.cs new file mode 100755 index 000000000..1163ee4b4 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/date-picker.cs @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.UIComponents; + + +namespace DatePickerTest +{ + // A spin control (for continously changing values when users can easily predict a set of values) + + class Example : NUIApplication + { + private FlexContainer _container; // Flex container to hold spin controls + private Spin _spinYear; // spin control for year + private Spin _spinMonth; // spin control for month + private Spin _spinDay; // spin control for day + + public Example() : base() + { + + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + // Create a container for the spins + _container = new FlexContainer(); + + _container.FlexDirection = FlexContainer.FlexDirectionType.Row; + _container.Size2D = new Size2D(480, 150); + + window.Add(_container); + + // Create a Spin control for year + _spinYear = new Spin(); + _spinYear.Flex = 0.3f; + _spinYear.FlexMargin = new Vector4(5.0f, 0.0f, 5.0f, 0.0f); + _container.Add(_spinYear); + + _spinYear.MinValue = 1900; + _spinYear.MaxValue = 2100; + _spinYear.Value = 2016; + _spinYear.Step = 1; + _spinYear.MaxTextLength = 4; + _spinYear.TextPointSize = 15; + _spinYear.TextColor = Color.Red; + _spinYear.Focusable = (true); + _spinYear.Name = "_spinYear"; + + // Create a Spin control for month + _spinMonth = new Spin(); + _spinMonth.Flex = 0.3f; + _spinMonth.FlexMargin = new Vector4(5.0f, 0.0f, 5.0f, 0.0f); + _container.Add(_spinMonth); + + _spinMonth.MinValue = 1; + _spinMonth.MaxValue = 12; + _spinMonth.Value = 10; + _spinMonth.Step = 1; + _spinMonth.MaxTextLength = 2; + _spinMonth.TextPointSize = 15; + _spinMonth.TextColor = Color.Green; + _spinMonth.Focusable = (true); + _spinMonth.Name = "_spinMonth"; + + // Create a Spin control for day + _spinDay = new Spin(); + _spinDay.Flex = 0.3f; + _spinDay.FlexMargin = new Vector4(5.0f, 0.0f, 5.0f, 0.0f); + _container.Add(_spinDay); + + _spinDay.MinValue = 1; + _spinDay.MaxValue = 31; + _spinDay.Value = 26; + _spinDay.Step = 1; + _spinDay.MaxTextLength = 2; + _spinDay.TextPointSize = 15; + _spinDay.TextColor = Color.Blue; + _spinDay.Focusable = (true); + _spinDay.Name = "_spinDay"; + + FocusManager keyboardFocusManager = FocusManager.Instance; + keyboardFocusManager.PreFocusChange += OnKeyboardPreFocusChange; + keyboardFocusManager.FocusedViewActivated += OnFocusedViewActivated; + } + + private View OnKeyboardPreFocusChange(object source, FocusManager.PreFocusChangeEventArgs e) + { + View nextFocusView = e.ProposedView; + + // When nothing has been focused initially, focus the text field in the first spin + if (!e.CurrentView && !e.ProposedView) + { + nextFocusView = _spinYear.SpinText; + } + else if(e.Direction == View.FocusDirection.Left) + { + // Move the focus to the spin in the left of the current focused spin + if(e.CurrentView == _spinMonth.SpinText) + { + nextFocusView = _spinYear.SpinText; + } + else if(e.CurrentView == _spinDay.SpinText) + { + nextFocusView = _spinMonth.SpinText; + } + } + else if(e.Direction == View.FocusDirection.Right) + { + // Move the focus to the spin in the right of the current focused spin + if(e.CurrentView == _spinYear.SpinText) + { + nextFocusView = _spinMonth.SpinText; + } + else if(e.CurrentView == _spinMonth.SpinText) + { + nextFocusView = _spinDay.SpinText; + } + } + + return nextFocusView; + } + + private void OnFocusedViewActivated(object source, FocusManager.FocusedViewActivatedEventArgs e) + { + + } + + /// + /// The main entry point for the application. + /// + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/dispose-test.cs b/test/NUITestSample/NUITestSample/examples/dispose-test.cs new file mode 100755 index 000000000..fbce64590 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/dispose-test.cs @@ -0,0 +1,485 @@ + +using System; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; +using System.Collections.Generic; + +namespace DisposeTest +{ + class Example : NUIApplication + { + private static string resourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource; + protected override void OnCreate() + { + base.OnCreate(); + ImageDisposeTest(); + AddButtons(); + TimerDisposeTest(); + GcTest(); + } + private ImageView image; + private Timer timer; + private bool flag; + private Animation ani; + private void ImageDisposeTest() + { + Layer layer = new Layer(); + layer.RaiseToTop(); + Window.Instance.AddLayer(layer); + + image = new ImageView(); + image.ResourceUrl = resourcePath + "/images/application-icon-0.png"; + image.Size2D = new Size2D(333, 333); + image.ParentOrigin = ParentOrigin.Center; + image.PivotPoint = PivotPoint.Center; + image.PositionUsesPivotPoint = true; + image.Position = new Position(0, 0, 0); + layer.Add(image); + + timer = new Timer(1000); + timer.Tick += Timer_Tick; + timer.Start(); + + ani = new Animation(); + ani.AnimateTo(image, "Scale", new Size(2.0f, 2.0f, 2.0f), 0, 3000); + ani.AnimateTo(image, "Scale", new Size(1.0f, 1.0f, 1.0f), 3000, 6000); + ani.Finished += Ani_Finished; + ani.Play(); + } + + private void Ani_Finished(object sender, EventArgs e) + { + ////NUILog.Debug("scale animation finished! start again in Finshied callback!"); + ani.Play(); + } + + private bool Timer_Tick(object source, Timer.TickEventArgs e) + { + if (flag) + { + image.ResourceUrl = resourcePath + "/images/gallery-2.jpg"; + PropertyMap map = new PropertyMap(); + map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.SVG)); + string url = $"{resourcePath}/images/gallery-2.jpg"; + //string url = $"{resourcePath}/3.svg"; + map.Add(ImageVisualProperty.URL, new PropertyValue(url)); + map.Add((int)Visual.Property.MixColor, new PropertyValue(new Color(0.7f, 0.0f, 0.0f, 1.0f))); + //image.ImageMap = map; + + flag = false; + ////NUILog.Debug("flag = false!"); + } + else + { + image.ResourceUrl = resourcePath + "/images/test-image.png"; + flag = true; + ////NUILog.Debug("flag = true!"); + } + return true; + } + + private Window window; + private Layer layer; + PushButton pushButton1, pushButton2; + public void AddButtons() + { + //NUILog.Debug("Customized Application Initialize event handler"); + window = Window.Instance; + window.BackgroundColor = Color.Magenta; + window.TouchEvent += OnWindowTouched; + window.WheelEvent += OnWindowWheelMoved; + window.KeyEvent += OnWindowKeyPressed; + //window.EventProcessingFinished += OnWindowEventProcessingFinished; + + layer = window.GetDefaultLayer(); + + pushButton1 = new PushButton(); + pushButton1.ParentOrigin = ParentOrigin.BottomLeft; + pushButton1.PivotPoint = PivotPoint.BottomLeft; + pushButton1.PositionUsesPivotPoint = true; + pushButton1.LabelText = "start animation"; + pushButton1.Position = new Vector3(0.0f, window.Size.Height * 0.1f, 0.0f); + pushButton1.Clicked += OnPushButtonClicked1; + window.Add(pushButton1); + + pushButton2 = new PushButton(); + pushButton2.ParentOrigin = ParentOrigin.BottomLeft; + pushButton2.PivotPoint = PivotPoint.BottomLeft; + pushButton2.PositionUsesPivotPoint = true; + pushButton2.LabelText = "reload image with same URL"; + pushButton2.Position = new Vector3(0.0f, window.Size.Height * 0.2f, 0.0f); + pushButton2.Clicked += OnPushButtonClicked2; + window.Add(pushButton2); + } + + public bool OnPushButtonClicked1(object sender, EventArgs e) + { + //NUILog.Debug("### push button 1 clicked!"); + return true; + } + + public bool OnPushButtonClicked2(object sender, EventArgs e) + { + //NUILog.Debug("### push button 2 clicked!"); + return true; + } + + public void OnWindowEventProcessingFinished(object sender, EventArgs e) + { + //NUILog.Debug("OnWindowEventProcessingFinished()!"); + if (e != null) + { + //NUILog.Debug("e != null !"); + } + } + + public void OnWindowKeyPressed(object sender, Window.KeyEventArgs e) + { + //NUILog.Debug("OnWindowKeyEventOccured()!"); + //NUILog.Debug("keyPressedName=" + e.Key.KeyPressedName); + //NUILog.Debug("state=" + e.Key.State); + } + + public void OnWindowWheelMoved(object sender, Window.WheelEventArgs e) + { + //NUILog.Debug("OnWindowWheelEventOccured()!"); + //NUILog.Debug("direction=" + e.Wheel.Direction); + //NUILog.Debug("type=" + e.Wheel.Type); + } + + // Callback for window touched signal handling + public void OnWindowTouched(object sender, Window.TouchEventArgs e) + { + //NUILog.Debug("OnWindowTouched()! e.TouchData.GetState(0)=" + e.Touch.GetState(0)); + + distest(null, null); + //NUILog.Debug("### 3 timers are disposed!"); + } + + + List timerList; + void TimerDisposeTest() + { + timerList = new List(); + //NUILog.Debug("TimerDisposeTest()!"); + + for (int i = 0; i < 3; i++) + { + Timer timer = new Timer(100); + if (0 == i) timer.Tick += Timer_Tick0; + if (1 == i) timer.Tick += Timer_Tick1; + if (2 == i) timer.Tick += Timer_Tick2; + timerList.Add(timer); + } + ////NUILog.Debug($"TimerDisposeTest() dp1 timerlist cnt={timerList.Count}"); + + foreach (Timer timer in timerList) + { + timer.Start(); + } + + distest = new DisposeTest(Timer_Tick0); + } + + private delegate bool DisposeTest(object source, Timer.TickEventArgs e); + DisposeTest distest; + + private bool Timer_Tick0(object source, Timer.TickEventArgs e) + { + foreach (Timer timer in timerList) + { + timer?.Dispose(); + } + timerList.Clear(); + ////NUILog.Debug("### Timer_Tick0=> 3 timers are disposed!"); + + for (int i = 0; i < 100; i++) + { + Timer timer = new Timer(100); + if (0 == i%3) timer.Tick += Timer_Tick0; + if (1 == i%3) timer.Tick += Timer_Tick1; + if (2 == i%3) timer.Tick += Timer_Tick2; + timerList.Add(timer); + } + + ////NUILog.Debug($"Timer_Tick0=> timerlist cnt={timerList.Count}"); + foreach (Timer timer in timerList) + { + timer.Start(); + } + return true; + } + + private bool Timer_Tick1(object source, Timer.TickEventArgs e) + { + foreach (Timer timer in timerList) + { + timer?.Dispose(); + } + timerList.Clear(); + ////NUILog.Debug("### Timer_Tick1=> 3 timers are disposed!"); + + for (int i = 0; i < 100; i++) + { + Timer timer = new Timer(100); + if (0 == i % 3) timer.Tick += Timer_Tick0; + if (1 == i % 3) timer.Tick += Timer_Tick1; + if (2 == i % 3) timer.Tick += Timer_Tick2; + timerList.Add(timer); + } + + ////NUILog.Debug($"Timer_Tick1=> timerlist cnt={timerList.Count}"); + foreach (Timer timer in timerList) + { + timer.Start(); + } + return true; + } + + private bool Timer_Tick2(object source, Timer.TickEventArgs e) + { + foreach (Timer timer in timerList) + { + timer?.Dispose(); + } + timerList.Clear(); + //NUILog.Debug("### Timer_Tick2=> 3 timers are disposed!"); + + for (int i = 0; i < 100; i++) + { + Timer timer = new Timer(100); + if (0 == i % 3) timer.Tick += Timer_Tick0; + if (1 == i % 3) timer.Tick += Timer_Tick1; + if (2 == i % 3) timer.Tick += Timer_Tick2; + timerList.Add(timer); + } + + //NUILog.Debug($"Timer_Tick2=> timerlist cnt={timerList.Count}"); + foreach (Timer timer in timerList) + { + timer.Start(); + } + return true; + } + + private Timer myTimer; + private List myViewList; + private const int numberOfObjects = 999; + private Random myRandom; + + void GcTest() + { + myViewList = new List(); + myRandom = new Random(); + for (int i = 0; i < numberOfObjects; i++) + { + View v = new View(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + myTimer = new Timer(1000); + + myTimer.Tick += MyTimer_Tick; + + myTimer.Start(); + } + + private bool MyTimer_Tick(object source, System.EventArgs e) + { + //Remove current Scene, + foreach (View v in myViewList) + { + Window.Instance.GetDefaultLayer().Remove(v); + } + + myViewList.Clear(); + + ////Add View + + GC.Collect(); + GC.WaitForPendingFinalizers(); + + for (int i = 0; i < 50; i++) + { + TextLabel v = new TextLabel(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + v.Text = "label " + i; + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 50; i < 100; i++) + { + PushButton v = new PushButton(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + v.LabelText = "button " + i; + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 100; i < 150; i++) + { + ImageView v = new ImageView(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + v.ResourceUrl = resourcePath + "/images/gallery-3.jpg"; + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 150; i < 200; i++) + { + //TextEditor v = new TextEditor(); + TextLabel v = new TextLabel("2"); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + v.Text = "editor" + i; + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 200; i < 250; i++) + { + //TextField v = new TextField(); + TextLabel v = new TextLabel("1"); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + v.Text = "field " + i; + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 250; i < 300; i++) + { + CheckBoxButton v = new CheckBoxButton(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + v.LabelText = "check " + i; + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 300; i < 350; i++) + { + ScrollBar v = new ScrollBar(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 350; i < 400; i++) + { + Slider v = new Slider(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 400; i < 450; i++) + { + TableView v = new TableView(1, 1); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 450; i < numberOfObjects; i++) + { + View v = new View(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + return true; + } + + /// + /// The main entry point for the application. + /// + [STAThread] + static void _Main(string[] args) + { + ////NUILog.Debug("Main() called!"); + + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/feedkey-test.cs b/test/NUITestSample/NUITestSample/examples/feedkey-test.cs new file mode 100755 index 000000000..01383760a --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/feedkey-test.cs @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; + +namespace FeedKeyTest +{ + class Example : NUIApplication + { + public Example() : base() + { + } + + public Example(string stylesheet) : base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + View view1 = new View() + { + Position2D = new Position2D(10, 10), + BackgroundColor = Color.Magenta, + Size2D = new Size2D(200, 200), + Focusable = true + }; + + View view2 = new View() + { + Position2D = new Position2D(10, 240), + BackgroundColor = Color.Red, + Size2D = new Size2D(200, 200), + Focusable = true + }; + + window.Add(view1); + window.Add(view2); + + FocusManager.Instance.SetCurrentFocusView(view1); + view2.UpFocusableView = view1; + view1.DownFocusableView = view2; + + view1.KeyEvent += (obj, e) => + { + if (e.Key.State != Key.StateType.Down) + { + return false; + } + Tizen.Log.Debug("NUI", "View1 KeyPressedName: " + e.Key.KeyPressedName); + Window.FeedKeyEvent(e.Key); + return false; + }; + + view2.KeyEvent += (obj, e) => + { + if (e.Key.State != Key.StateType.Down) + { + // Tizen.Log.Debug("NUI", "View2 key state != Down"); + return false; + } + + // Tizen.Log.Debug("NUI", "View2 KeyPressedName: " + e.Key.KeyPressedName); + View v = obj as View; + if(v == view1) + { + Tizen.Log.Debug("NUI", "View2 received view1 feed event: " + e.Key.KeyPressedName); + } + if (v == view2) + { + Tizen.Log.Debug("NUI", "View2 received event: " + e.Key.KeyPressedName); + } + return false; + }; + } + + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/flex-container.cs b/test/NUITestSample/NUITestSample/examples/flex-container.cs new file mode 100755 index 000000000..f753255c1 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/flex-container.cs @@ -0,0 +1,196 @@ + +using System; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; + +namespace FlexContainerTest +{ + public class SampleMain : NUIApplication + { + public readonly static string[] samples = new string[] + { + "AnimationSample", + "BasicElement", + "TextSample", + "ImageViewSample", + "EventSample", + "FlexContainer", + "FrameAnimationSample" + }; + + TextLabel[] label; + FlexContainer container; + View focusIndicator; + int numOfSamples; + PushButton pushButton1, pushButton2; + private int _cnt; + private Animation _ani; + + protected override void OnCreate() + { + base.OnCreate(); + + Window.Instance.BackgroundColor = new Color(0.1f, 0.8f, 0.1f, 1.0f); + + container = new FlexContainer(); + container.Size2D = new Size2D(Window.Instance.Size.Width, Window.Instance.Size.Height); + container.PivotPoint = PivotPoint.TopLeft; + container.Padding = new Vector4(100, 100, 100, 100); + + container.FlexWrap = FlexContainer.WrapType.Wrap; + container.FlexDirection = FlexContainer.FlexDirectionType.Column; + + Window.Instance.Add(container); + + numOfSamples = samples.GetLength(0); + Tizen.Log.Debug("NUI", "NUM = " + numOfSamples); + label = new TextLabel[numOfSamples]; + for (int i = 0; i < numOfSamples; i++) + { + label[i] = new TextLabel(); + label[i].Focusable = true; + label[i].BackgroundColor = Color.Red; + //label[i].Size = new Size(100, 50, 0); + label[i].Text = samples[i]; + label[i].FlexMargin = new Vector4(20, 20, 20, 20); + label[i].PointSize = 10; + label[i].Name = "label" + i.ToString(); + container.Add(label[i]); + } + + //label[3].SetKeyInputFocus(); //removed + FocusManager.Instance.SetCurrentFocusView(label[3]); + + FocusManager.Instance.PreFocusChange += Instance_PreFocusChange; + //added + FocusManager.Instance.FocusChanged += (sender, e) => + { + if(e.CurrentView) Tizen.Log.Debug("NUI", "FocusManager FocusChanged signal callback! e.CurrentView.Name=" + e.CurrentView.Name); + else Tizen.Log.Debug("NUI", "FocusManager FocusChanged signal callback! e.CurrentView is null!"); + if (e.NextView) Tizen.Log.Debug("NUI", "FocusManager FocusChanged signal callback! e.NextView.Name=" + e.NextView.Name); + else Tizen.Log.Debug("NUI", "FocusManager FocusChanged signal callback! e.NextView is null!"); + }; + //added + FocusManager.Instance.FocusedViewActivated += (sender, e) => + { + if (e.View) Tizen.Log.Debug("NUI", "FocusManager FocusedViewEnterKeyPressed signal callback! e.View.Name=" + e.View.Name); + else Tizen.Log.Debug("NUI", "FocusManager FocusChanged signal callback! e.View is null!"); + }; + + //added + Window.Instance.TouchEvent += (sender, e) => + { + Tizen.Log.Debug("NUI", "Window Touch signal callback! To avoid crash, when losing key focus, set here again unless the NextView is null"); + FocusManager.Instance.SetCurrentFocusView(label[3]); + }; + + //added + pushButton1 = new PushButton(); + pushButton1.MinimumSize = new Size2D(400, 200); + pushButton1.LabelText = "+PreFocusChange"; + pushButton1.ParentOrigin = ParentOrigin.TopLeft; + pushButton1.PivotPoint = PivotPoint.TopLeft; + pushButton1.Position2D = new Position2D(200, 800); + pushButton1.Clicked += (sender, e) => + { + Tizen.Log.Debug("NUI", "pushbutton1 clicked! add handler!"); + _cnt++; + FocusManager.Instance.PreFocusChange += Instance_PreFocusChange; + _ani.Finished += _ani_Finished; + pushButton1.LabelText = "Add Handler" + _cnt; + pushButton2.LabelText = "Remove Handler" + _cnt; + return true; + }; + Window.Instance.Add(pushButton1); + + pushButton2 = new PushButton(); + pushButton2.MinimumSize = new Size2D(400, 200); + pushButton2.LabelText = "-PreFocusChange"; + pushButton2.ParentOrigin = ParentOrigin.TopLeft; + pushButton2.PivotPoint = PivotPoint.TopLeft; + pushButton2.Position2D = new Position2D(800, 800); + pushButton2.Clicked += (sender, e) => + { + Tizen.Log.Debug("NUI", "pushbutton2 clicked! remove handler!"); + _cnt--; + FocusManager.Instance.PreFocusChange -= Instance_PreFocusChange; + _ani.Finished -= _ani_Finished; + pushButton1.LabelText = "Add Handler" + _cnt; + pushButton2.LabelText = "Remove Handler" + _cnt; + return true; + }; + Window.Instance.Add(pushButton2); + + //added + _ani = new Animation(2000); + _ani.AnimateTo(pushButton1, "Opacity", 0.0f); + _ani.AnimateTo(pushButton2, "Opacity", 0.0f); + _ani.EndAction = Animation.EndActions.Discard; + _ani.Finished += _ani_Finished; + + } + + private void _ani_Finished(object sender, EventArgs e) + { + Tizen.Log.Debug("NUI", "_ani finished! _cnt=" + _cnt); + } + + private View Instance_PreFocusChange(object source, FocusManager.PreFocusChangeEventArgs e) + { + View nextView; + Tizen.Log.Debug("NUI", "Instance_PreFocusChange = " + e.Direction.ToString()); + + //added + if (e.CurrentView == null) e.CurrentView = label[0]; + if (e.ProposedView == null) e.ProposedView = label[0]; + + int index = Array.FindIndex(label, x => x == e.CurrentView); + + Tizen.Log.Debug("NUI", "index = " + index); + + switch (e.Direction) + { + case View.FocusDirection.Up: + index = (index + numOfSamples - 2) % numOfSamples; //changed + _ani.Play(); + break; + case View.FocusDirection.Down: + index = (index + 2) % numOfSamples; //changed + Tizen.Log.Debug("NUI", "pushbutton1 Visible=" + pushButton1.Visible + " pushbutton2 Visible=" + pushButton2.Visible); //added + break; + case View.FocusDirection.Left: + //added + pushButton1.Show(); + pushButton2.Show(); + break; + case View.FocusDirection.Right: + //added + pushButton1.Hide(); + pushButton2.Hide(); + break; + default: + break; + } + + Tizen.Log.Debug("NUI", "next index = " + index); + nextView = label[index]; + + if (e.CurrentView.HasFocus()) + { + //currentView?.ClearKeyInputFocus(); //removed + } + //nextView?.SetKeyInputFocus(); //removed + + return nextView; + } + + static void _Main(string[] args) + { + + SampleMain sample = new SampleMain(); + sample.Run(args); + } + } +} + diff --git a/test/NUITestSample/NUITestSample/examples/gc-test.cs b/test/NUITestSample/NUITestSample/examples/gc-test.cs new file mode 100755 index 000000000..04c9b29a9 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/gc-test.cs @@ -0,0 +1,261 @@ + +using System.Collections.Generic; +using System; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.UIComponents; + +namespace TizenVDUIApplication19 +{ + using Tizen.NUI; + + internal class Program : NUIApplication + { + private Timer myTimer; + private List myViewList; + private const int numberOfObjects = 500; + private Random myRandom; + private const string resources = "/home/owner/apps_rw/NUISamples.TizenTV/res"; + + protected override void OnCreate() + { + base.OnCreate(); + + Window.Instance.BackgroundColor = Color.White; + + myViewList = new List(); + + myRandom = new Random(); + + for (int i = 0; i < numberOfObjects; i++) + { + View v = new View(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + myTimer = new Timer(1000); + + myTimer.Tick += MyTimer_Tick; + + myTimer.Start(); + } + + private bool MyTimer_Tick(object source, System.EventArgs e) + { + //Remove current Scene, + foreach (View v in myViewList) + { + Window.Instance.GetDefaultLayer().Remove(v); + } + + myViewList.Clear(); + + ////Add View + + GC.Collect(); + GC.WaitForPendingFinalizers(); + + for (int i = 0; i < 50; i++) + { + TextLabel v = new TextLabel(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + v.Text = "label " + i; + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 50; i < 100; i++) + { + PushButton v = new PushButton(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + v.LabelText = "button " + i; + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 100; i < 150; i++) + { + ImageView v = new ImageView(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + v.ResourceUrl = resources + "/images/gallery-3.jpg"; + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 150; i < 200; i++) + { + TextEditor v = new TextEditor(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + v.Text = "editor" + i; + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 200; i < 250; i++) + { + TextField v = new TextField(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + v.Text = "field " + i; + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 250; i < 300; i++) + { + CheckBoxButton v = new CheckBoxButton(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + v.LabelText = "check " + i; + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 300; i < 350; i++) + { + ScrollBar v = new ScrollBar(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 350; i < 400; i++) + { + Slider v = new Slider(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 400; i < 450; i++) + { + TableView v = new TableView(1, 1); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + for (int i = 450; i < numberOfObjects; i++) + { + View v = new View(); + + float intensity = myRandom.Next(0, 255) / 255.0f; + v.BackgroundColor = new Color(intensity, intensity, intensity, 1); + v.Position = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0); + v.PivotPoint = PivotPoint.TopLeft; + v.Size2D = new Size2D(100, 100); + + myViewList.Add(v); + + Window.Instance.GetDefaultLayer().Add(v); + } + + return true; + } + + protected override void OnPause() + { + //This function is called when the window's visibility is changed from visible to invisible. + base.OnPause(); + } + + protected override void OnResume() + { + //This function is called when the window's visibility is changed from invisible to visible. + base.OnResume(); + } + + protected override void OnTerminate() + { + //This function is called when the app exit normally. + base.OnTerminate(); + } + /* + protected override void OnLowMemory(LowMemoryEventArgs e) + { + //This function is called when the system is low on memory. + base.OnLowMemory(e); + } + protected override void OnLocaleChanged(LocaleChangedEventArgs e) + { + //This function is called when the language is changed. + base.OnLocaleChanged(e); + } + */ + private static void _Main(string[] args) + { + //Create an Application + Program myProgram = new Program(); + myProgram.Run(args); + } + } +} \ No newline at end of file diff --git a/test/NUITestSample/NUITestSample/examples/hello-test.cs b/test/NUITestSample/NUITestSample/examples/hello-test.cs new file mode 100755 index 000000000..e67995f2f --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/hello-test.cs @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; +//using Tizen.Applications; + +//------------------------------------------------------------------------------ +// +// +// This file can only run on Tizen target. You should compile it with DaliApplication.cs, and +// add tizen c# application related library as reference. +//------------------------------------------------------------------------------ +namespace HelloTest +{ + class Example : NUIApplication + { + private Animation _animation; + private TextLabel _text; + private Window _window; + + public Example():base() + { + } + + public Example(string stylesheet):base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode):base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + private void Initialize() + { + // Connect the signal callback for window touched signal + _window = Window.Instance; + _window.TouchEvent += OnWindowTouched; + + // Add a _text label to the window + _text = new TextLabel("Hello Mono World"); + _text.ParentOrigin = ParentOrigin.Center; + _text.PivotPoint = PivotPoint.Center; + _text.HorizontalAlignment = HorizontalAlignment.Center; + _text.PointSize = 32.0f; + + _window.Add(_text); + } + + // Callback for _animation finished signal handling + private void AnimationFinished(object sender, EventArgs e) + { + if (_animation) + { + Tizen.Log.Debug("NUI", "Duration= " + _animation.Duration); + Tizen.Log.Debug("NUI", "EndAction= " + _animation.EndAction); + } + } + + // Callback for window touched signal handling + private void OnWindowTouched(object sender, Window.TouchEventArgs e) + { + // Only animate the _text label when touch down happens + if (e.Touch.GetState(0) == PointStateType.Down) + { + // Create a new _animation + if (_animation) + { + _animation.Reset(); + } + + _animation = new Animation(1000); // 1 second of duration + + _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), Vector3.XAxis), 0, 500); + _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), Vector3.XAxis), 500, 1000); + _animation.EndAction = Animation.EndActions.Discard; + + // Connect the signal callback for animaiton finished signal + _animation.Finished += AnimationFinished; + + // Play the _animation + _animation.Play(); + } + } + + /// + /// The main entry point for the application. + /// + + [STAThread] + static void _Main(string[] args) + { + Tizen.Log.Debug("NUI", "Hello mono world."); + //Example example = new Example(); + //Example example = new Example("stylesheet"); + Example example = new Example("stylesheet", WindowMode.Transparent); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/hello-world.cs b/test/NUITestSample/NUITestSample/examples/hello-world.cs new file mode 100755 index 000000000..8609a9689 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/hello-world.cs @@ -0,0 +1,335 @@ +/* +* Copyright (c) 2017 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.Threading.Tasks; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; + +namespace HelloWorldTest +{ + class Example : NUIApplication + { + private Animation _animation; + private TextLabel _text; + private int cnt; + private View _view; + TextField textFieldPlaceholderTest; + TextLabel keySubclassTest; + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + TextLabel pixelLabel; + TextLabel pointLabel; + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + window.TouchEvent += OnWindowTouched; + window.KeyEvent += OnWindowKeyEvent; + window.Resized += (obj, e) => + { + Tizen.Log.Fatal("NUI", "Height: " + e.WindowSize.Height); + Tizen.Log.Fatal("NUI", "Width: " + e.WindowSize.Width); + }; + + pixelLabel = new TextLabel("Test Pixel Size 32.0f"); + pixelLabel.Position2D = new Position2D(10, 10); + pixelLabel.PixelSize = 32.0f; + window.Add(pixelLabel); + + pointLabel = new TextLabel("Test Point Size 32.0f"); + pointLabel.Position2D = new Position2D(10, 70); + pointLabel.PointSize = 32.0f; + window.Add(pointLabel); + + Task.Factory.StartNew(() => + { + try + { + TextLabel ellipsis = new TextLabel("Ellipsis of TextLabel is enabled."); + ellipsis.Size2D = new Size2D(100, 100); + ellipsis.Position2D = new Position2D(10, 250); + ellipsis.PointSize = 20.0f; + ellipsis.Ellipsis = true; + window.Add(ellipsis); + } + catch (Exception e) + { + Tizen.Log.Fatal("NUI", $"exception caught! e={e}"); + } + }).Wait(); + + TextField textFieldEllipsisTest = new TextField(); + textFieldEllipsisTest.Text = "TextField Ellipsis Test, ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + textFieldEllipsisTest.Size2D = new Size2D(200, 100); + textFieldEllipsisTest.Position2D = new Position2D(10, 150); + textFieldEllipsisTest.PointSize = 30.0f; + textFieldEllipsisTest.Ellipsis = false; + window.Add(textFieldEllipsisTest); + + TextField textFieldEllipsisTest2 = new TextField(); + textFieldEllipsisTest2.Text = "TextField Ellipsis Test, ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + textFieldEllipsisTest2.Size2D = new Size2D(200, 100); + textFieldEllipsisTest2.Position2D = new Position2D(300, 150); + textFieldEllipsisTest2.PointSize = 30.0f; + textFieldEllipsisTest2.Ellipsis = true; + window.Add(textFieldEllipsisTest2); + + + textFieldPlaceholderTest = new TextField(); + + PropertyMap propertyMap = new PropertyMap(); + propertyMap.Add("placeholderText", new PropertyValue("TextField Placeholder Test")); + propertyMap.Add("placeholderTextFocused", new PropertyValue("Placeholder Text Focused")); + propertyMap.Add("placeholderColor", new PropertyValue(Color.Blue)); + propertyMap.Add("placeholderPointSize", new PropertyValue(20.0f)); + + PropertyMap fontStyleMap = new PropertyMap(); + fontStyleMap.Add("weight", new PropertyValue("bold")); + fontStyleMap.Add("width", new PropertyValue("condensed")); + fontStyleMap.Add("slant", new PropertyValue("italic")); + propertyMap.Add("placeholderFontStyle", new PropertyValue(fontStyleMap)); + + textFieldPlaceholderTest.Size2D = new Size2D(300, 50); + textFieldPlaceholderTest.Position2D = new Position2D(10, 230); + textFieldPlaceholderTest.BackgroundColor = Color.Magenta; + textFieldPlaceholderTest.Placeholder = propertyMap; + textFieldPlaceholderTest.Focusable = true; + window.Add(textFieldPlaceholderTest); + + keySubclassTest = new TextLabel(); + keySubclassTest.Text = "Key Subclass Test!"; + keySubclassTest.Size2D = new Size2D(900, 50); + keySubclassTest.Position2D = new Position2D(10, 300); + keySubclassTest.BackgroundColor = Color.Cyan; + keySubclassTest.PointSize = 20; + keySubclassTest.Focusable = true; + window.Add(keySubclassTest); + + + TextLabel autoScrollStopMode = new TextLabel("AutoScrollStopMode is finish-loop. PointSize=30"); + autoScrollStopMode.Size2D = new Size2D(400, 100); + autoScrollStopMode.Position2D = new Position2D(10, 500); + autoScrollStopMode.PointSize = 30.0f; + autoScrollStopMode.AutoScrollStopMode = AutoScrollStopMode.Immediate; + autoScrollStopMode.AutoScrollLoopDelay = 3.0f; + autoScrollStopMode.EnableAutoScroll = true; + autoScrollStopMode.AutoScrollLoopCount = 0; + window.Add(autoScrollStopMode); + + _text = new TextLabel("Hello NUI World"); + _text.Position2D = new Position2D(10, 500); + _text.HorizontalAlignment = HorizontalAlignment.Center; + _text.PointSize = 20.0f; + _text.TextColor = Color.Magenta; + window.Add(_text); + + _view = new View(); + _view.Size2D = new Size2D(100, 100); + _view.SizeWidth = 50; + Tizen.Log.Fatal("NUI", "[1]_view SizeWidth=" + _view.SizeWidth); + + _animation = new Animation + { + Duration = 2000 + }; + _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500); + _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000); + _animation.AnimateBy(_text, "ScaleX", 3, 1000, 1500); + _animation.AnimateBy(_text, "ScaleY", 4.0f, 1500, 2000); + _animation.EndAction = Animation.EndActions.Discard; + _animation.Finished += AnimationFinished; + + _view.SizeWidth = 50; + Tizen.Log.Fatal("NUI", "[2]_view SizeWidth=" + _view.SizeWidth); + + TextLabelLineWrapModeTest(); + ViewLayoutDirectionTest(); + + textFieldPlaceholderTest.DownFocusableView = keySubclassTest; + keySubclassTest.UpFocusableView = textFieldPlaceholderTest; + FocusManager.Instance.SetCurrentFocusView(keySubclassTest); + } + + + private View view1, view11, view12, view111, view121; + public void ViewLayoutDirectionTest() + { + view1 = new View(); + view1.Name = "view 1"; + view1.LayoutDirection = ViewLayoutDirectionType.RTL; + Window.Instance.GetDefaultLayer().Add(view1); + view1.LayoutDirectionChanged += View1_LayoutDirectionChanged; + + view11 = new View(); + view11.Name = "view 11"; + view11.InheritLayoutDirection = true; + view1.Add(view11); + + view12 = new View(); + view12.Name = "view 12"; + view12.LayoutDirection = ViewLayoutDirectionType.LTR; + view1.Add(view12); + + view111 = new View(); + view111.Name = "view 111"; + view111.InheritLayoutDirection = true; + view11.Add(view111); + + view121 = new View(); + view121.Name = "view 121"; + view121.InheritLayoutDirection = true; + view12.Add(view121); + } + + private void View1_LayoutDirectionChanged(object sender, View.LayoutDirectionChangedEventArgs e) + { + Tizen.Log.Error("NUI", "View1_LayoutDirectionChanged()! e.Type=" + e.Type); + } + + public void AnimationFinished(object sender, EventArgs e) + { + Tizen.Log.Fatal("NUI", "AnimationFinished()! cnt=" + (cnt)); + if (_animation) + { + Tizen.Log.Fatal("NUI", "Duration= " + _animation.Duration + "EndAction= " + _animation.EndAction); + } + _view.SizeWidth = 50; + Tizen.Log.Fatal("NUI", "[3]_view SizeWidth=" + _view.SizeWidth); + } + + int win_test; + public void OnWindowKeyEvent(object sender, Window.KeyEventArgs e) + { + Tizen.Log.Fatal("NUI", "e.Key.KeyPressedName=" + e.Key.KeyPressedName); + + if (e.Key.State == Key.StateType.Down) + { + keySubclassTest.Text = $"DeviceSubClass={e.Key.DeviceSubClass}, DeviceClass={e.Key.DeviceClass}, DeviceName={e.Key.DeviceName}, KeyCode={e.Key.KeyCode}"; + + if (e.Key.KeyPressedName == "Up") + { + if (_animation) + { + _animation.Finished += AnimationFinished; + cnt++; + Tizen.Log.Fatal("NUI", "AnimationFinished added!"); + } + //pointLabel.TextColorAnimatable = Color.Blue; + //pixelLabel.TextColorAnimatable = Color.Blue; + + Tizen.Log.Fatal("NUI", $"LineWrapMode 1st={ myTextLabel?.LineWrapMode} 2nd={ myTextLabel2?.LineWrapMode}"); + } + else if (e.Key.KeyPressedName == "Down") + { + if (_animation) + { + _animation.Finished -= AnimationFinished; + cnt--; + Tizen.Log.Fatal("NUI", "AnimationFinished removed!"); + } + //pointLabel.TextColorAnimatable = Color.Red; + //pixelLabel.TextColorAnimatable = Color.Red; + + Window.Instance.SetClass($"Window.SetClass() Test #{win_test++}", ""); + Tizen.Log.Fatal("NUI", $"Check with enlightenment_info -topwins ! Window.SetClass() Test #{win_test}"); + } + else if (e.Key.KeyPressedName == "Return") + { + _animation.Play(); + Tizen.Log.Fatal("NUI", "_animation play here!"); + } + } + } + + public void OnWindowTouched(object sender, Window.TouchEventArgs e) + { + if (e.Touch.GetState(0) == PointStateType.Down) + { + _animation.Play(); + } + } + + private TextLabel myTextLabel; + private TextLabel myTextLabel2; + private TextEditor myTextEditor; + private TextEditor myTextEditor2; + public void TextLabelLineWrapModeTest() + { + Tizen.Log.Fatal("NUI", "WrapModeTest START!"); + myTextLabel = new TextLabel(); + myTextLabel.Position2D = new Position2D(10, 600); + myTextLabel.Size2D = new Size2D(400, 90); + myTextLabel.BackgroundColor = Color.Blue; + myTextLabel.PointSize = 20; + myTextLabel.TextColor = Color.White; + myTextLabel.MultiLine = true; + myTextLabel.LineWrapMode = LineWrapMode.Character; + myTextLabel.Text = $"[TextLabel LineWrapMode.Character] hello ABCDEFGHI is my name, it is very very long beautiful hansome awesome name."; + Window.Instance.GetDefaultLayer().Add(myTextLabel); + + myTextLabel2 = new TextLabel(); + myTextLabel2.Position2D = new Position2D(450, 600); + myTextLabel2.Size2D = new Size2D(400, 90); + myTextLabel2.BackgroundColor = Color.Blue; + myTextLabel2.PointSize = 20; + myTextLabel2.TextColor = Color.White; + myTextLabel2.MultiLine = true; + myTextLabel2.LineWrapMode = LineWrapMode.Word; + myTextLabel2.Text = $"[TextLabel LineWrapMode.Word] hello ABCDEFGHI is my name, it is very very long beautiful hansome awesome name."; + Window.Instance.GetDefaultLayer().Add(myTextLabel2); + + Tizen.Log.Fatal("NUI", $"TextLabel LineWrapMode 1st={ myTextLabel?.LineWrapMode} 2nd={ myTextLabel2?.LineWrapMode}"); + + myTextEditor = new TextEditor(); + myTextEditor.Position2D = new Position2D(10, 700); + myTextEditor.Size2D = new Size2D(400, 90); + myTextEditor.BackgroundColor = Color.Red; + myTextEditor.PointSize = 20; + myTextEditor.TextColor = Color.White; + //myTextEditor.MultiLine = true; + myTextEditor.LineWrapMode = LineWrapMode.Character; + myTextEditor.Text = $"[TextEditor LineWrapMode.Character] hello ABCDEFGHI is my name, it is very very long beautiful hansome awesome name."; + Window.Instance.GetDefaultLayer().Add(myTextEditor); + + myTextEditor2 = new TextEditor(); + myTextEditor2.Position2D = new Position2D(450, 700); + myTextEditor2.Size2D = new Size2D(400, 90); + myTextEditor2.BackgroundColor = Color.Red; + myTextEditor2.PointSize = 20; + myTextEditor2.TextColor = Color.White; + //myTextEditor2.MultiLine = true; + myTextEditor2.LineWrapMode = LineWrapMode.Word; + myTextEditor2.Text = $"[TextEditor LineWrapMode.Word] hello ABCDEFGHI is my name, it is very very long beautiful hansome awesome name."; + Window.Instance.GetDefaultLayer().Add(myTextEditor2); + + Tizen.Log.Fatal("NUI", $"TextEditor LineWrapMode 1st={ myTextEditor?.LineWrapMode} 2nd={ myTextEditor2?.LineWrapMode}"); + } + + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/image-orientation-correct-test.cs b/test/NUITestSample/NUITestSample/examples/image-orientation-correct-test.cs new file mode 100755 index 000000000..2425ca35d --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/image-orientation-correct-test.cs @@ -0,0 +1,147 @@ +using Tizen.NUI; +using Tizen.NUI.BaseComponents; + +namespace ImageViewOrientationCorrectionTest +{ + class Program : NUIApplication + { + //private static string resourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource; + string testUrl0 = "/home/owner/apps_rw/org.tizen.example.NUITestSample/res/images/test-image.png"; + string testUrl1 = "/home/owner/apps_rw/org.tizen.example.NUITestSample/res/images/test-image2.png"; + string testUrl3 = "/home/owner/apps_rw/org.tizen.example.NUITestSample/res/images/test-image3.jpg"; + string testUrl4 = "/home/owner/apps_rw/org.tizen.example.NUITestSample/res/images/test-image4.jpg"; + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + TextField[] textField = new TextField[5]; + ImageView[] imageView = new ImageView[5]; + int resol = 1; + int iPointSize = 20; + + void Initialize() + { + //NUILog.Debug($"ImageViewOrientationCorrectionTest => Initialize()"); + + Window window = Window.Instance; + window.BackgroundColor = Color.White; + Vector2 dpi = new Vector2(); + dpi = window.Dpi; + //NUILog.Debug($"Window.Dpi X={dpi.X}, Y={dpi.Y}"); + + textField[0] = new TextField(); + textField[0].Size2D = new Size2D(350 * resol, 64 * resol); + textField[0].Position2D = new Position2D(10 * resol, 600 * resol); + textField[0].PivotPoint = PivotPoint.TopLeft; + textField[0].BackgroundColor = Color.White; + textField[0].PointSize = iPointSize * resol; + textField[0].Text = "png file, orientation correct=false"; + textField[0].TextColor = Color.Red; + + textField[1] = new TextField(); + textField[1].Size2D = new Size2D(350 * resol, 64 * resol); + textField[1].Position2D = new Position2D(400 * resol, 600 * resol); + textField[1].PivotPoint = PivotPoint.TopLeft; + textField[1].BackgroundColor = Color.White; + textField[1].PointSize = iPointSize * resol; + textField[1].Text = "png file, orientation correct=true"; + textField[1].TextColor = Color.Red; + + textField[2] = new TextField(); + textField[2].Size2D = new Size2D(350 * resol, 64 * resol); + textField[2].Position2D = new Position2D(750 * resol, 600 * resol); + textField[2].PivotPoint = PivotPoint.TopLeft; + textField[2].BackgroundColor = Color.White; + textField[2].PointSize = iPointSize * resol; + textField[2].Text = "jpg file, orientation correct=false"; + textField[2].TextColor = Color.Red; + + textField[3] = new TextField(); + textField[3].Size2D = new Size2D(350 * resol, 64 * resol); + textField[3].Position2D = new Position2D(1100 * resol, 600 * resol); + textField[3].PivotPoint = PivotPoint.TopLeft; + textField[3].BackgroundColor = Color.White; + textField[3].PointSize = iPointSize * resol; + textField[3].Text = "jpg file, orientation correct=true"; + textField[3].TextColor = Color.Red; + + window.Add(textField[0]); + window.Add(textField[1]); + window.Add(textField[2]); + window.Add(textField[3]); + + //PropertyMap map0 = new PropertyMap(); + //map0.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); + //map0.Add(ImageVisualProperty.URL, new PropertyValue(testUrl0)); + //map0.Add(ImageVisualProperty.CropToMask + 3, new PropertyValue(false)); + //imageView[0] = new ImageView(); + //imageView[0].Image = map0; + imageView[0] = new ImageView(); + imageView[0].ResourceUrl = testUrl0; + //imageView[0].OrientationCorrection = false; + imageView[0].Size2D = new Size2D(300 * resol, 400 * resol); + imageView[0].Position2D = new Position2D(10 * resol, 20 * resol); + imageView[0].PivotPoint = PivotPoint.TopLeft; + imageView[0].ParentOrigin = ParentOrigin.TopLeft; + imageView[0].BackgroundColor = Color.Black; + window.Add(imageView[0]); + + //PropertyMap map1 = new PropertyMap(); + //map1.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); + //map1.Add(ImageVisualProperty.URL, new PropertyValue(testUrl1)); + //map1.Add(ImageVisualProperty.CropToMask + 3, new PropertyValue(true)); + //imageView[1] = new ImageView(); + //imageView[1].Image = map1; + imageView[1] = new ImageView(); + imageView[1].ResourceUrl = testUrl1; + //imageView[1].OrientationCorrection = true; + imageView[1].Size2D = new Size2D(300 * resol, 400 * resol); + imageView[1].Position2D = new Position2D(400 * resol, 20 * resol); + imageView[1].PivotPoint = PivotPoint.TopLeft; + imageView[1].ParentOrigin = ParentOrigin.TopLeft; + imageView[1].BackgroundColor = Color.Black; + window.Add(imageView[1]); + + //PropertyMap map2 = new PropertyMap(); + //map2.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); + //map2.Add(ImageVisualProperty.URL, new PropertyValue(testUrl3)); + //map2.Add(ImageVisualProperty.CropToMask + 3, new PropertyValue(false)); + //imageView[2] = new ImageView(); + //imageView[2].Image = map2; + imageView[2] = new ImageView(); + imageView[2].ResourceUrl = testUrl3; + //imageView[2].OrientationCorrection = false; + imageView[2].Size2D = new Size2D(300 * resol, 400 * resol); + imageView[2].Position2D = new Position2D(750 * resol, 20 * resol); + imageView[2].PivotPoint = PivotPoint.TopLeft; + imageView[2].ParentOrigin = ParentOrigin.TopLeft; + imageView[2].BackgroundColor = Color.Black; + window.Add(imageView[2]); + + //PropertyMap map3 = new PropertyMap(); + //map3.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); + //map3.Add(ImageVisualProperty.URL, new PropertyValue(testUrl4)); + //map3.Add(ImageVisualProperty.CropToMask + 3, new PropertyValue(true)); + //imageView[3] = new ImageView(); + //imageView[3].Image = map3; + imageView[3] = new ImageView(); + imageView[3].ResourceUrl = testUrl4; + //imageView[3].OrientationCorrection = true; + imageView[3].Size2D = new Size2D(300 * resol, 400 * resol); + imageView[3].Position2D = new Position2D(1100 * resol, 20 * resol); + imageView[3].PivotPoint = PivotPoint.TopLeft; + imageView[3].ParentOrigin = ParentOrigin.TopLeft; + imageView[3].BackgroundColor = Color.Black; + window.Add(imageView[3]); + } + + static void _Main(string[] args) + { + var app = new Program(); + app.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/image-view.cs b/test/NUITestSample/NUITestSample/examples/image-view.cs new file mode 100755 index 000000000..f073f5f01 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/image-view.cs @@ -0,0 +1,288 @@ +/* +* Copyright (c) 2017 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.UIComponents; +using Tizen.NUI.BaseComponents; + +namespace ImageViewTest +{ + class Example : NUIApplication + { + private static string resourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource; + private Animation _animation; + private ImageView _imageView; + private bool _isAniFinised = true; + private Layer layer, _layer1, _layer2; + private PushButton _pushButton1, _pushButton2; + private Window window; + private bool urlNullTest = false; + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + ImageUrlTest(); + } + + private ImageView image; + private Timer timer; + private bool flag; + private void ImageUrlTest() + { + image = new ImageView(); + image.ResourceUrl = resourcePath + "/images/application-icon-0.png"; + image.Size2D = new Size2D(333, 333); + image.ParentOrigin = ParentOrigin.Center; + image.PivotPoint = PivotPoint.Center; + image.PositionUsesPivotPoint = true; + Window.Instance.Add(image); + + timer = new Timer(1000); + timer.Tick += Timer_Tick; + timer.Start(); + } + + private bool Timer_Tick(object source, Timer.TickEventArgs e) + { + if (flag) + { + image.ResourceUrl = resourcePath + "/images/application-icon-0.png"; + flag = false; + //////NUILog.Debug("flag = false!"); + } + else + { + if (urlNullTest) + { + image.ResourceUrl = ""; + } + else + { + image.ResourceUrl = resourcePath + "/images/image-1.jpg"; + } + flag = true; + ////NUILog.Debug("flag = true!"); + } + return true; + } + + public void Initialize() + { + //////NUILog.Debug("Customized Application Initialize event handler"); + window = Window.Instance; + window.BackgroundColor = Color.Cyan; + window.TouchEvent += OnWindowTouched; + window.WheelEvent += OnWindowWheelMoved; + window.KeyEvent += OnWindowKeyPressed; + //window.EventProcessingFinished += OnWindowEventProcessingFinished; + + layer = window.GetDefaultLayer(); + _layer1 = new Layer(); + _layer2 = new Layer(); + window.AddLayer(_layer1); + window.AddLayer(_layer2); + //////NUILog.Debug("_layer1.Behavior =" + _layer1.Behavior); + if (_layer1.Behavior == Layer.LayerBehavior.LayerUI) + { + _layer1.Behavior = Layer.LayerBehavior.Layer2D; + ////NUILog.Debug("again _layer1.Behavior =" + _layer1.Behavior); + } + // Add a ImageView to the window + // PropertyMap map = new PropertyMap(); + // map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch)); + // map.Add(NpatchImageVisualProperty.URL, new PropertyValue(resourcePath+"/images/00_popup_bg.9.png")); + // map.Add(NpatchImageVisualProperty.Border, new PropertyValue(new Rectangle(100, 100, 100, 100))); + _imageView = new ImageView(); + //_imageView.ImageMap = map; + _imageView.ResourceUrl = resourcePath + "/images/gallery-0.jpg"; + //_imageView.Border = new Rectangle(100, 100, 100, 100); + _imageView.ParentOrigin = ParentOrigin.TopLeft; + _imageView.PivotPoint = PivotPoint.TopLeft; + _imageView.Position = new Position(5.0f, 5.0f, 0.0f); + _imageView.PixelArea = new Vector4(0.0f, 0.0f, 0.5f, 0.5f); + _imageView.Size2D = new Size2D(200, 80); + //_imageView.SetResizePolicy(ResizePolicyType.USE_NATURAL_SIZE, DimensionType.ALL_DIMENSIONS); + layer.Add(_imageView); + + _pushButton1 = new PushButton(); + _pushButton1.ParentOrigin = ParentOrigin.BottomLeft; + _pushButton1.PivotPoint = PivotPoint.BottomLeft; + _pushButton1.LabelText = "start animation"; + _pushButton1.Position = new Vector3(0.0f, window.Size.Height * 0.1f, 0.0f); + _pushButton1.Clicked += OnPushButtonClicked1; + _layer1.Add(_pushButton1); + + _pushButton2 = new PushButton(); + _pushButton2.ParentOrigin = ParentOrigin.BottomLeft; + _pushButton2.PivotPoint = PivotPoint.BottomLeft; + _pushButton2.LabelText = "reload image with same URL"; + _pushButton2.Position = new Vector3(0.0f, window.Size.Height * 0.2f, 0.0f); + _pushButton2.Clicked += OnPushButtonClicked2; + _layer2.Add(_pushButton2); + + ImageView syncImage = new ImageView(); + syncImage.ParentOrigin = ParentOrigin.CenterLeft; + syncImage.PivotPoint = PivotPoint.CenterLeft; + syncImage.PositionUsesPivotPoint = true; + syncImage.Size2D = new Size2D(150, 150); + syncImage.ResourceUrl = resourcePath + "/images/gallery-3.jpg"; + syncImage.SynchronosLoading = true; + layer.Add(syncImage); + + PropertyMap _map = new PropertyMap(); + _map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch)); + _map.Add(NpatchImageVisualProperty.URL, new PropertyValue(resourcePath + "/images/gallery-4.jpg")); + _map.Add(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue(true)); + ImageView nPatchImage = new ImageView(); + nPatchImage.ParentOrigin = ParentOrigin.BottomLeft; + nPatchImage.PivotPoint = PivotPoint.BottomLeft; + nPatchImage.PositionUsesPivotPoint = true; + nPatchImage.Size2D = new Size2D(300, 100); + nPatchImage.ImageMap = _map; + layer.Add(nPatchImage); + + ImageView syncNineImage = new ImageView(); + syncNineImage.ParentOrigin = ParentOrigin.CenterLeft; + syncNineImage.PivotPoint = PivotPoint.CenterLeft; + syncNineImage.Position2D = new Position2D(0, 200); + syncNineImage.PositionUsesPivotPoint = true; + syncNineImage.Size2D = new Size2D(150, 150); + syncNineImage.ResourceUrl = resourcePath + "/images/gallery-5.jpg"; + syncNineImage.SynchronosLoading = true; + syncNineImage.Border = new Rectangle(0, 0, 0, 0); + layer.Add(syncNineImage); + } + + public bool OnPushButtonClicked2(object sender, EventArgs e) + { + if (_imageView) + { + //////NUILog.Debug("OnPushButtonClicked2()!"); + layer.Remove(_imageView); + _imageView = new ImageView(); + _imageView.ResourceUrl = resourcePath + "/images/gallery-3.jpg"; + _imageView.ParentOrigin = ParentOrigin.Center; + _imageView.PivotPoint = PivotPoint.Center; + _imageView.PixelArea = new Vector4(0.0f, 0.0f, 0.5f, 0.5f); + //_imageView.SetResizePolicy(ResizePolicyType.USE_NATURAL_SIZE, DimensionType.ALL_DIMENSIONS); + layer.Add(_imageView); + } + + return true; + } + + public bool OnPushButtonClicked1(object sender, EventArgs e) + { + if (_isAniFinised == true) + { + _isAniFinised = false; + ////NUILog.Debug("OnPushButtonClicked1()!"); + + // Create a new _animation + if (_animation) + { + //_animation.Stop(Tizen.NUI.Constants.Animation.EndAction.Stop); + _animation.Reset(); + } + + _animation = new Animation(); + _animation.AnimateTo(_imageView, "PixelArea", new Vector4(0.5f, 0.0f, 0.5f, 0.5f), 0, 1000); + _animation.AnimateTo(_imageView, "PixelArea", new Vector4(0.5f, 0.5f, 0.5f, 0.5f), 1000, 2000); + _animation.AnimateTo(_imageView, "PixelArea", new Vector4(0.0f, 0.0f, 1.0f, 1.0f), 2000, 3000); + _animation.AnimateTo(_imageView, "PixelArea", new Vector4(0.5f, 0.5f, 0.5f, 0.5f), 3000, 4000); + + KeyFrames _keyFrames = new KeyFrames(); + _keyFrames.Add(0.0f, new Size(0.0f, 0.0f, 0.0f)); + _keyFrames.Add(0.3f, new Size(window.Size.Width * 0.7f, window.Size.Height * 0.7f, 0.0f)); + _keyFrames.Add(1.0f, new Size(window.Size)); + _animation.AnimateBetween(_imageView, "Size", _keyFrames, 4000, 6000, Animation.Interpolation.Linear); + + _animation.EndAction = Animation.EndActions.Discard; + + // Connect the signal callback for animaiton finished signal + _animation.Finished += AnimationFinished; + _animation.Finished += AnimationFinished2; + + // Play the _animation + _animation.Play(); + } + + return true; + } + + // Callback for _animation finished signal handling + public void AnimationFinished(object sender, EventArgs e) + { + ////NUILog.Debug("AnimationFinished()!"); + } + + // Callback for second _animation finished signal handling + public void AnimationFinished2(object sender, EventArgs e) + { + ////NUILog.Debug("AnimationFinished2()!"); + if (_animation) + { + ////NUILog.Debug("Duration= " + _animation.Duration); + ////NUILog.Debug("EndAction= " + _animation.EndAction); + _isAniFinised = true; + } + } + + public void OnWindowEventProcessingFinished(object sender, EventArgs e) + { + ////NUILog.Debug("OnWindowEventProcessingFinished()!"); + if (e != null) + { + //////NUILog.Debug("e != null !"); + } + } + + public void OnWindowKeyPressed(object sender, Window.KeyEventArgs e) + { + ////NUILog.Debug("OnWindowKeyEventOccured()!"); + ////NUILog.Debug("keyPressedName=" + e.Key.KeyPressedName); + ////NUILog.Debug("state=" + e.Key.State); + } + + public void OnWindowWheelMoved(object sender, Window.WheelEventArgs e) + { + ////NUILog.Debug("OnWindowWheelEventOccured()!"); + ////NUILog.Debug("direction=" + e.Wheel.Direction); + ////NUILog.Debug("type=" + e.Wheel.Type); + } + + // Callback for window touched signal handling + public void OnWindowTouched(object sender, Window.TouchEventArgs e) + { + ////NUILog.Debug("OnWindowTouched()! e.TouchData.GetState(0)=" + e.Touch.GetState(0)); + } + + /// + /// The main entry point for the application. + /// + [STAThread] + static void _Main(string[] args) + { + ////NUILog.Debug("Main() called!"); + + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/positionUsesPivotPoint-test.cs b/test/NUITestSample/NUITestSample/examples/positionUsesPivotPoint-test.cs new file mode 100755 index 000000000..d2088a2a6 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/positionUsesPivotPoint-test.cs @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; +//using Tizen.Applications; + +//------------------------------------------------------------------------------ +// +// +// This file can only run on Tizen target. You should compile it with DaliApplication.cs, and +// add tizen c# application related library as reference. +//------------------------------------------------------------------------------ +namespace PositionUsesPivotPointTest +{ + class Example : NUIApplication + { + private TextLabel _text1; + private TextLabel _text2; + private Window _window; + + public Example():base() + { + } + + public Example(string stylesheet):base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode):base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + private void Initialize() + { + // Connect the signal callback for window touched signal + _window = Window.Instance; + _text1 = new TextLabel("PositionUsesPivotPoint"); + _text1.ParentOrigin = ParentOrigin.Center; + _text1.PivotPoint = PivotPoint.Center; + _text1.Position = new Position(0, 0, 0); + _text1.PositionUsesPivotPoint = true; + _text1.HorizontalAlignment = HorizontalAlignment.Center; + _text1.Size2D = new Size2D(200, 100); + _text1.PointSize = 10.0f; + _text1.BackgroundColor = Color.Blue; + _window.Add(_text1); + + _text2 = new TextLabel("PositionNotUsesPivotPoint"); + _text2.ParentOrigin = ParentOrigin.Center; + _text2.PivotPoint = PivotPoint.Center; + _text2.Position = new Position(0, 0, 0); + _text2.PositionUsesPivotPoint = false; + _text2.HorizontalAlignment = HorizontalAlignment.Center; + _text2.Size2D = new Size2D(200, 100); + _text2.PointSize = 10.0f; + _text2.BackgroundColor = Color.Red; + _window.Add(_text2); + } + + + + /// + /// The main entry point for the application. + /// + [STAThread] + static void _Main(string[] args) + { + Tizen.Log.Debug("NUI", "Hello mono world."); + Example example = new Example("stylesheet", WindowMode.Transparent); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/relative-vector.cs b/test/NUITestSample/NUITestSample/examples/relative-vector.cs new file mode 100755 index 000000000..eb27855d6 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/relative-vector.cs @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; +//using Tizen.Applications; + +//------------------------------------------------------------------------------ +// +// +// This file can only run on Tizen target. You should compile it with DaliApplication.cs, and +// add tizen c# application related library as reference. +//------------------------------------------------------------------------------ +namespace RelativeVectorTest +{ + class Example : NUIApplication + { + private Animation _animation; + private ImageView _imageView; + private Window _window; + private const string resources = "/home/owner/apps_rw/NUISamples.TizenTV/res"; + + public Example():base() + { + } + + public Example(string stylesheet):base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode):base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + private void Initialize() + { + _window = Window.Instance; + _window.TouchEvent += OnWindowTouched; + + _imageView = new ImageView(); + _imageView.ResourceUrl = resources+"/images/gallery-3.jpg"; + _imageView.ParentOrigin = ParentOrigin.Center; + _imageView.PivotPoint = PivotPoint.Center; + _imageView.PixelArea = new RelativeVector4(0.0f, 0.0f, 0.0f, 0.0f); + + _window.Add(_imageView); + } + + // Callback for window touched signal handling + private void OnWindowTouched(object sender, Window.TouchEventArgs e) + { + // Only animate the _text label when touch down happens + if (e.Touch.GetState(0) == PointStateType.Down) + { + // Create a new _animation + if (_animation) + { + _animation.Reset(); + } + + _animation = new Animation(1000); // 1 second of duration + _animation.AnimateTo(_imageView, "PixelArea", new RelativeVector4(0.0f, 0.0f, 1.0f, 1.0f), 0, 1000); + _animation.EndAction = Animation.EndActions.Discard; + _animation.PlayRange = new RelativeVector2(0.2f, 0.8f); + + // Play the _animation + _animation.Play(); + } + } + + /// + /// The main entry point for the application. + /// + + [STAThread] + static void _Main(string[] args) + { + Tizen.Log.Debug("NUI", "Hello mono world."); + Example example = new Example("stylesheet", WindowMode.Transparent); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/scroll-view.cs b/test/NUITestSample/NUITestSample/examples/scroll-view.cs new file mode 100755 index 000000000..15eab9164 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/scroll-view.cs @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; + +namespace ScrollViewTest +{ + class Example : NUIApplication + { + private const string resources = "/home/owner/apps_rw/NUISamples.TizenTV/res"; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + delegate void CallbackDelegate(IntPtr data); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + delegate void ActorCallbackDelegate(IntPtr data); + + private ScrollView _scrollView; + private ScrollBar _scrollBar; + private Animation _animation; + private TextLabel _text; + + public Example() : base() + { + } + + public Example(string stylesheet) : base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + public void Initialize() + { + CreateScrollView(); + } + + private void CreateScrollView() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + // Create a scroll view + _scrollView = new ScrollView(); + Size windowSize = new Size(window.Size.Width, window.Size.Height, 0.0f); + _scrollView.Size2D = new Size2D((int)windowSize.Width, (int)windowSize.Height); + _scrollView.ParentOrigin = ParentOrigin.Center; + _scrollView.PivotPoint = PivotPoint.Center; + window.Add(_scrollView); + + // Add actors to a scroll view with 3 pages + int pageRows = 1; + int pageColumns = 3; + for(int pageRow = 0; pageRow < pageRows; pageRow++) + { + for(int pageColumn = 0; pageColumn < pageColumns; pageColumn++) + { + View pageActor = new View(); + pageActor.WidthResizePolicy = ResizePolicyType.FillToParent; + pageActor.HeightResizePolicy = ResizePolicyType.FillToParent; + pageActor.ParentOrigin = ParentOrigin.Center; + pageActor.PivotPoint = PivotPoint.Center; + pageActor.Position = new Position(pageColumn * windowSize.Width, pageRow * windowSize.Height, 0.0f); + + // Add images in a 3x4 grid layout for each page + int imageRows = 4; + int imageColumns = 3; + float margin = 10.0f; + Position imageSize = new Position((windowSize.Width / imageColumns) - margin, (windowSize.Height / imageRows) - margin, 0.0f); + + for(int row = 0; row < imageRows; row++) + { + for(int column = 0; column < imageColumns;column++) + { + int imageId = (row * imageColumns + column) % 2 + 1; + ImageView imageView = new ImageView(resources+"/images/image-" + imageId + ".jpg"); + imageView.ParentOrigin = ParentOrigin.Center; + imageView.PivotPoint = PivotPoint.Center; + imageView.Size2D = new Size2D((int)imageSize.X, (int)imageSize.Y); + imageView.Position = new Position( margin * 0.5f + (imageSize.X + margin) * column - windowSize.Width * 0.5f + imageSize.X * 0.5f, + margin * 0.5f + (imageSize.Y + margin) * row - windowSize.Height * 0.5f + imageSize.Y * 0.5f, 0.0f ); + pageActor.Add(imageView); + } + } + + _scrollView.Add(pageActor); + } + } + + _scrollView.SetAxisAutoLock(true); + + // Set scroll view to have 3 pages in X axis and allow page snapping, + // and also disable scrolling in Y axis. + PropertyMap rulerMap = new PropertyMap(); + rulerMap.Add((int)ScrollModeType.XAxisScrollEnabled, new PropertyValue(true)); + rulerMap.Add((int)ScrollModeType.XAxisSnapToInterval, new PropertyValue(windowSize.Width)); + rulerMap.Add((int)ScrollModeType.XAxisScrollBoundary, new PropertyValue(windowSize.Width * pageColumns ) ); + rulerMap.Add((int)ScrollModeType.YAxisScrollEnabled, new PropertyValue( false ) ); + _scrollView.ScrollMode = rulerMap; + + // Create a horizontal scroll bar in the bottom of scroll view (which is optional) + _scrollBar = new ScrollBar(ScrollBar.Direction.Horizontal); + _scrollBar.ParentOrigin = ParentOrigin.BottomLeft; + _scrollBar.PivotPoint = PivotPoint.TopLeft; + _scrollBar.WidthResizePolicy = ResizePolicyType.FitToChildren; + _scrollBar.HeightResizePolicy = ResizePolicyType.FillToParent; + _scrollBar.Orientation = new Rotation( new Radian( new Degree( 270.0f ) ), Vector3.ZAxis ); + _scrollView.Add(_scrollBar); + + // Connect to the OnRelayout signal + _scrollView.Relayout += OnScrollViewRelayout; + //_scrollView.Touched += OnTouch; + _scrollView.WheelEvent += Onwheel; + _scrollView.FocusGained += OnKey; + _text = new TextLabel("View Touch Event Handler Test"); + _text.ParentOrigin = ParentOrigin.Center; + _text.PivotPoint = PivotPoint.Center; + _text.HorizontalAlignment = HorizontalAlignment.Center; + _text.PointSize = 20.0f; + + _scrollView.Add(_text); + } + + // Callback for _animation finished signal handling + public void AnimationFinished(object sender, EventArgs e) + { + Tizen.Log.Debug("NUI", "Customized Animation Finished Event handler"); + } + private void OnKey(object source, EventArgs e) + { + Tizen.Log.Debug("NUI", "View Keyevent EVENT callback...."); + } + + private bool Onwheel(object source, View.WheelEventArgs e) + { + Tizen.Log.Debug("NUI", "View Wheel EVENT callback...."); + return true; + } + + private bool OnTouch(object source, View.TouchEventArgs e) + { + Tizen.Log.Debug("NUI", "View TOUCH EVENT callback...."); + + // Only animate the _text label when touch down happens + if( e.Touch.GetState(0) == PointStateType.Down ) + { + Tizen.Log.Debug("NUI", "Customized Window Touch event handler"); + // Create a new _animation + if( _animation ) + { + _animation.Reset(); + } + + _animation = new Animation(1); // 1 second of duration + + _animation.AnimateTo(_text, "Orientation", new Rotation( new Radian( new Degree( 180.0f ) ), Vector3.XAxis ), 0, 500); + _animation.AnimateTo(_text, "Orientation", new Rotation( new Radian( new Degree( 0.0f ) ), Vector3.XAxis ), 500, 1000); + + // Connect the signal callback for animaiton finished signal + _animation.Finished += AnimationFinished; + + // Play the _animation + _animation.Play(); + } + return true; + } + + private void OnScrollViewRelayout(object source, EventArgs e) + { + Tizen.Log.Debug("NUI", "View OnRelayoutEventArgs EVENT callback...."); + + // Set the correct scroll bar size after size negotiation of scroll view is done + _scrollBar.Size2D = new Size2D(0, (int)_scrollView.GetRelayoutSize(DimensionType.Width)); + } + + /// + /// The main entry point for the application. + /// + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/sibling-order-test.cs b/test/NUITestSample/NUITestSample/examples/sibling-order-test.cs new file mode 100755 index 000000000..eaf9f699a --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/sibling-order-test.cs @@ -0,0 +1,195 @@ +// Copyright (c) 2017 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.UIComponents; +using Tizen.NUI.BaseComponents; +using System.Collections.Generic; + + +// 1) sibling order test +namespace SiblingOrderTest +{ + class Example : NUIApplication + { + public Example() : base() + { + } + + public Example(string stylesheet) : base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + Window _window; + + public void Initialize() + { + _window = Window.Instance; + _window.BackgroundColor = Color.White; + + // sibling order test + // By default, the SiblingOrder is 0. + SiblingTest1(); + + // sibling order test + // Set the SiblingOrder 0 -> 9 + SiblingTest2(); + + // sibling order test + // Set the SiblingOrder 10 -> 1 + SiblingTest3(); + + // sibling order test + // Set the SiblingOrder 5 -> 1 & 0 -> 4 + SiblingTest4(); + + // sibling order test + // Set the SiblingOrder 0 -> 4 & 5 -> 1 + SiblingTest5(); + } + + public void SiblingTest1() + { + Position2D _myPos = new Position2D(100, 30); + + for (int i = 0; i < 10; i++) + { + PushButton _view = new PushButton(); + + _view.Name = "sibling" + i; + _view.LabelText = "view" + i; + _view.MinimumSize = new Size2D(100, 50); + _view.ParentOrigin = ParentOrigin.TopLeft; + _view.PivotPoint = PivotPoint.TopLeft; + _view.Position2D = _myPos + new Position2D(20 * i, 10 * i); + + _window.Add(_view); + } + } + + public void SiblingTest2() + { + Position2D _myPos = new Position2D(100, 180); + + for (int i = 0; i < 10; i++) + { + PushButton _view = new PushButton(); + + _view.Name = "sibling" + i; + _view.LabelText = "view" + i; + _view.MinimumSize = new Size2D(100, 50); + _view.ParentOrigin = ParentOrigin.TopLeft; + _view.PivotPoint = PivotPoint.TopLeft; + _view.Position2D = _myPos + new Position2D(20 * i, 10 * i); + + _window.Add(_view); + _view.SiblingOrder = i; + } + } + + public void SiblingTest3() + { + Position2D _myPos = new Position2D(100, 330); + + for (int i = 0; i < 10; i++) + { + PushButton _view = new PushButton(); + + _view.Name = "sibling" + i; + _view.LabelText = "view" + i; + _view.MinimumSize = new Size2D(100, 50); + _view.ParentOrigin = ParentOrigin.TopLeft; + _view.PivotPoint = PivotPoint.TopLeft; + _view.Position2D = _myPos + new Position2D(20 * i, 10 * i); + + _window.Add(_view); + _view.SiblingOrder = 10-i; + } + } + + public void SiblingTest4() + { + Position2D _myPos = new Position2D(100, 480); + + for (int i = 0; i < 10; i++) + { + PushButton _view = new PushButton(); + + _view.Name = "sibling" + i; + _view.LabelText = "view" + i; + _view.MinimumSize = new Size2D(100, 50); + _view.ParentOrigin = ParentOrigin.TopLeft; + _view.PivotPoint = PivotPoint.TopLeft; + _view.Position2D = _myPos + new Position2D(20 * i, 10 * i); + + _window.Add(_view); + + if (i<5) + { + _view.SiblingOrder = 5-i; + } + else + { + _view.SiblingOrder = i-5; + } + } + } + + public void SiblingTest5() + { + Position2D _myPos = new Position2D(100, 630); + + for (int i = 0; i < 10; i++) + { + PushButton _view = new PushButton(); + + _view.Name = "sibling" + i; + _view.LabelText = "view" + i; + _view.MinimumSize = new Size2D(100, 50); + _view.ParentOrigin = ParentOrigin.TopLeft; + _view.PivotPoint = PivotPoint.TopLeft; + _view.Position2D = _myPos + new Position2D(20 * i, 10 * i); + + _window.Add(_view); + + if (i<5) + { + _view.SiblingOrder = i; + } + else + { + _view.SiblingOrder = 10-i; + } + } + } + + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/svg-test.cs b/test/NUITestSample/NUITestSample/examples/svg-test.cs new file mode 100755 index 000000000..80da1bd60 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/svg-test.cs @@ -0,0 +1,142 @@ +using Tizen.NUI; +using Tizen.NUI.BaseComponents; + +namespace SvgTest +{ + class Program : NUIApplication + { + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + string test_url = "/home/owner/apps_rw/org.tizen.example.NUITemplate3/res/3.svg"; + + TextField[] textField = new TextField[5]; + ImageView[] imageView = new ImageView[10]; + int iSVGimage = 50, iSynchronous = 0, iTextColor = 0, iPointSize = 20, iPointSize2 = 20, mImageCombinationIndex = 0; + int resol = 1; + + void Initialize() + { + //NUILog.Debug("### SvgTest => OnCreate()!"); + + Window window = Window.Instance; + window.BackgroundColor = Color.White; + //NUILog.Debug($"### window.Dpi={window.Dpi}"); + + Vector2 dpi = new Vector2(); + dpi = window.Dpi; + //NUILog.Debug($"### window.Dpi x={dpi.X}, y={dpi.Y}"); + + textField[0] = new TextField(); + textField[0].Size2D = new Size2D(300 * resol, 64 * resol); + textField[0].Position2D = new Position2D(10 * resol, 600 * resol); + textField[0].PivotPoint = PivotPoint.TopLeft; + textField[0].BackgroundColor = Color.White; + textField[0].PointSize = iPointSize * resol; + textField[0].PlaceholderText = "imageview setsize X"; + textField[0].TextColor = Color.Red; + + textField[1] = new TextField(); + textField[1].Size2D = new Size2D(350 * resol, 64 * resol); + textField[1].Position2D = new Position2D(400 * resol, 600 * resol); + textField[1].PivotPoint = PivotPoint.TopLeft; + textField[1].BackgroundColor = Color.White; + textField[1].PointSize = iPointSize * resol; + textField[1].PlaceholderText = "imageview setsize 200,400"; + textField[1].TextColor = Color.Red; + + textField[2] = new TextField(); + textField[2].Size2D = new Size2D(350 * resol, 64 * resol); + textField[2].Position2D = new Position2D(750 * resol, 600 * resol); + textField[2].PivotPoint = PivotPoint.TopLeft; + textField[2].BackgroundColor = Color.White; + textField[2].PointSize = iPointSize * resol; + textField[2].PlaceholderText = "imageview setsize 300,300"; + textField[2].TextColor = Color.Red; + + textField[3] = new TextField(); + textField[3].Size2D = new Size2D(350 * resol, 64 * resol); + textField[3].Position2D = new Position2D(1100 * resol, 600 * resol); + textField[3].PivotPoint = PivotPoint.TopLeft; + textField[3].BackgroundColor = Color.White; + textField[3].PointSize = iPointSize * resol; + textField[3].PlaceholderText = "imageview setsize 500,500"; + textField[3].TextColor = Color.Red; + + window.Add(textField[0]); + window.Add(textField[1]); + window.Add(textField[2]); + window.Add(textField[3]); + + PropertyMap map0 = new PropertyMap(); + map0.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); + string test_url0 = "/home/owner/apps_rw/org.tizen.example.NUITemplate3/res/images/test-image.png"; + map0.Add(ImageVisualProperty.URL, new PropertyValue(test_url0)); + map0.Add(ImageVisualProperty.CropToMask + 3, new PropertyValue(true)); + imageView[0] = new ImageView(); + imageView[0].Position2D = new Position2D(10 * resol, 20 * resol); + imageView[0].PivotPoint = PivotPoint.TopLeft; + imageView[0].ParentOrigin = ParentOrigin.TopLeft; + imageView[0].ImageMap = map0; + imageView[0].BackgroundColor = Color.Black; + window.Add(imageView[0]); + + return; + + PropertyMap map1 = new PropertyMap(); + map1.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.SVG)); + //map1.Add(ImageVisualProperty.URL, new PropertyValue(IMAGE_PATH[iSVGimage])); + map1.Add(ImageVisualProperty.URL, new PropertyValue(test_url)); + map1.Add((int)Visual.Property.MixColor, new PropertyValue(new Color(0.7f, 0.0f, 0.0f, 1.0f))); + imageView[1] = new ImageView(); + imageView[1].Size2D = new Size2D(200 * resol, 400 * resol); + imageView[1].Position2D = new Position2D(400 * resol, 20 * resol); + imageView[1].PivotPoint = PivotPoint.TopLeft; + imageView[1].ParentOrigin = ParentOrigin.TopLeft; + imageView[1].Image = map1; + imageView[1].BackgroundColor = Color.Black; + // ConnectSignal(imageView[1]); + + PropertyMap map2 = new PropertyMap(); + map2.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.SVG)); + //map2.Add(ImageVisualProperty.URL, new PropertyValue(IMAGE_PATH[iSVGimage])); + map2.Add(ImageVisualProperty.URL, new PropertyValue(test_url)); + imageView[2] = new ImageView(); + imageView[2].Size2D = new Size2D(300 * resol, 300 * resol); + imageView[2].Position2D = new Position2D(700 * resol, 20 * resol); + imageView[2].PivotPoint = PivotPoint.TopLeft; + imageView[2].ParentOrigin = ParentOrigin.TopLeft; + imageView[2].Image = map2; + imageView[2].BackgroundColor = Color.Black; + // ConnectSignal(imageView[2]); + + PropertyMap map3 = new PropertyMap(); + map3.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.SVG)); + //map3.Add(ImageVisualProperty.URL, new PropertyValue(IMAGE_PATH[iSVGimage])); + map3.Add(ImageVisualProperty.URL, new PropertyValue(test_url)); + imageView[3] = new ImageView(); + imageView[3].Size2D = new Size2D(500 * resol, 500 * resol); + imageView[3].Position2D = new Position2D(1100 * resol, 20 * resol); + imageView[3].PivotPoint = PivotPoint.TopLeft; + imageView[3].ParentOrigin = ParentOrigin.TopLeft; + imageView[3].Image = map3; + imageView[3].BackgroundColor = Color.Black; + // ConnectSignal(imageView[3]); + + + + window.Add(imageView[1]); + window.Add(imageView[2]); + window.Add(imageView[3]); + } + + static void _Main(string[] args) + { + var app = new Program(); + app.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/test1.cs b/test/NUITestSample/NUITestSample/examples/test1.cs new file mode 100755 index 000000000..583784d0f --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/test1.cs @@ -0,0 +1,317 @@ +// Copyright (c) 2017 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.UIComponents; +using Tizen.NUI.BaseComponents; +using System.Collections.Generic; + + +// 1) sibling order test +namespace Test1 +{ + class Example : NUIApplication + { + public Example() : base() + { + } + + public Example(string stylesheet) : base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + Window _window; + StyleManager _style; + + public void Initialize() + { + _window = Window.Instance; + _window.BackgroundColor = Color.White; + + // 1) sibling order test + SiblingTest(); + // 2) text visual test + dali_VisualBase_Creation_test(); + + // 3) visual creation test + VisualTest2(); + + _style = StyleManager.Get(); + //_style.StyleChanged += _style_StyleChanged; + _style.StyleChanged += (obj, e) => + { + Tizen.Log.Debug("NUI", "in stylechanged.. C#side..\n"); + //flag = true; + }; + + _style.ApplyTheme("/home/owner/apps_rw/NUISamples.TizenTV/res/json/date-picker-theme.json"); + Tizen.Log.Debug("NUI", "#### 1) first change!"); + + + AnimatePath_1(); + } + + private void _style_StyleChanged(object sender, StyleManager.StyleChangedEventArgs e) + { + Tizen.Log.Debug("NUI", "style changed event handler comes"); + } + + public void SiblingTest() + { + View _prev = null; + Position2D _myPos = new Position2D(100, 100); + List list_view = new List(); + TextLabel _txt = new TextLabel(); + + for (int i = 0; i < 10; i++) + { + View _view0 = new PushButton(); + PushButton _view = _view0 as PushButton; + + _view.Name = "sibling" + i; + _view.MinimumSize = new Size2D(100, 50); + _view.LabelText = "sibling" + i; + _view.ParentOrigin = ParentOrigin.TopLeft; + _view.PivotPoint = PivotPoint.TopLeft; + _view.Position2D = _myPos + new Position2D(20 * i, 10 * i); + _view.Clicked += (sender, ee) => + { + View curr = sender as View; + Tizen.Log.Debug("NUI", "clicked curr view name=" + curr.Name + " sibling=" + curr.SiblingOrder); + curr.RaiseToTop(); + if (_prev) + { + _prev.LowerToBottom(); + Tizen.Log.Debug("NUI", "raise on top is called!curr sibling=" + curr.SiblingOrder + " prev name=" + _prev.Name + " sibling=" + _prev.SiblingOrder); + } + _prev = curr; + _txt.Text = "on top: " + curr.Name + ", sibling order=" + curr.SiblingOrder; + + _style.ApplyTheme("/home/owner/apps_rw/NUISamples.TizenTV/res/json/style-example-theme-one.json"); + Tizen.Log.Debug("NUI", "#### 2) second change!"); + + return true; + }; + list_view.Add(_view); + } + + for (int i = 0; i < 10; i++) + { + _window.Add(list_view[i]); + Tizen.Log.Debug("NUI", list_view[i].Name + "'s sibling order=" + list_view[i].SiblingOrder); + } + + _txt.ParentOrigin = ParentOrigin.TopLeft; + _txt.PivotPoint = PivotPoint.TopLeft; + _txt.Text = "on top: sibling#, sibling order=?"; + _txt.Position2D = _myPos + new Position2D(-50, 200); + _txt.TextColor = Color.Blue; + _window.Add(_txt); + + } + + public class VisualTest : CustomView + { + private int TextVisualPropertyIndex = -1; + private VisualBase _textVisual; + private string _string; + + public VisualTest() : base(typeof(VisualTest).Name, CustomViewBehaviour.RequiresKeyboardNavigationSupport) + { + } + public string TextVisual + { + get + { + return _string; + } + set + { + _string = value; + + TextVisualPropertyIndex = RegisterProperty("textvisualtest", new PropertyValue("textvisualtest"), PropertyAccessMode.ReadWrite); + + PropertyMap textVisual = new PropertyMap(); + textVisual.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text)) + .Add(TextVisualProperty.Text, new PropertyValue(_string)) + .Add(TextVisualProperty.TextColor, new PropertyValue(Color.Blue)) + .Add(TextVisualProperty.PointSize, new PropertyValue(10)) + .Add(TextVisualProperty.HorizontalAlignment, new PropertyValue("CENTER")) + .Add(TextVisualProperty.VerticalAlignment, new PropertyValue("CENTER")); + _textVisual = VisualFactory.Instance.CreateVisual(textVisual); + RegisterVisual(TextVisualPropertyIndex, _textVisual); + _textVisual.DepthIndex = TextVisualPropertyIndex; + } + } + } + + //when use belowing testcase, Time is out and this case is BLOCK + public void dali_VisualBase_Creation_test() + { + try + { + Tizen.Log.Debug("NUI", "##### start! ######"); + + VisualTest _visualTest = new VisualTest(); + _visualTest.TextVisual = "Hello NUI Text Visual!"; + _visualTest.ParentOrigin = ParentOrigin.TopLeft; + _visualTest.PivotPoint = PivotPoint.TopLeft; + _visualTest.Size2D = new Size2D(600, 200); + _visualTest.Position2D = new Position2D(50, 400); + _visualTest.BackgroundColor = Color.Yellow; + _window.Add(_visualTest); + } + catch (Exception e) + { + Tizen.Log.Error("NUI", "##### Caught Exception" + e.ToString()); + throw new System.InvalidOperationException("visual test error!!!"); + } + } + + public void VisualTest2() + { + try + { + Tizen.Log.Debug("NUI", "##### VisualTest2() start! ######"); + + VisualFactory visualfactory = VisualFactory.Instance; + PropertyMap textMap1 = new PropertyMap(); + textMap1.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text)); + textMap1.Insert(TextVisualProperty.Text, new PropertyValue("Hello")); + textMap1.Insert(TextVisualProperty.PointSize, new PropertyValue(10.0f)); + + PropertyMap textMap2 = new PropertyMap(); + VisualBase textVisual1 = visualfactory.CreateVisual(textMap1); + textVisual1.Creation = textMap2; + } + catch (Exception e) + { + Tizen.Log.Error("NUI", "Caught Exception" + e.ToString()); + throw new System.InvalidOperationException("visual test2 error!!!"); + //LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString()); + //Assert.IsTrue(e is ArgumentException, "Argument Exception Not Recieved"); + } + } + + //[Property("AUTHOR", "Feng Jin, feng16.jin@samsung.com")] + public void AnimatePath_1() + { + Tizen.Log.Debug("NUI", "#### 1) animate path test !"); + /* TEST CODE */ + View view = new View(); + view.ParentOrigin = ParentOrigin.TopLeft; + view.PivotPoint = PivotPoint.TopLeft; + view.MinimumSize = new Size2D(100, 100); + view.BackgroundColor = Color.Red; + _window.Add(view); + + Position position0 = new Position(200.0f, 200.0f, 0.0f); + Position position1 = new Position(300.0f, 300.0f, 0.0f); + Position position2 = new Position(400.0f, 400.0f, 0.0f); + + Path path = new Path(); + path.AddPoint(position0); + path.AddPoint(position1); + path.AddPoint(position2); + //Control points for first segment + path.AddControlPoint(new Vector3(39.0f, 90.0f, 0.0f)); + path.AddControlPoint(new Vector3(56.0f, 119.0f, 0.0f)); + //Control points for second segment + path.AddControlPoint(new Vector3(78.0f, 120.0f, 0.0f)); + path.AddControlPoint(new Vector3(93.0f, 104.0f, 0.0f)); + + Animation animation = new Animation(); + animation.AnimatePath(view, path, Vector3.XAxis, 0, 5000, new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear)); + animation.Play(); + Vector3 position = new Vector3(); + Vector3 tangent = new Vector3(); + + path.Sample(0.0f, position, tangent); + Rotation rotation = new Rotation(new Radian(new Degree(0.0f)), tangent); + Tizen.Log.Debug("NUI", "################ progress = 0! "); + Tizen.Log.Debug("NUI", "position=(" + position.X + "," + position.Y + "," + position.Z + ")"); + Tizen.Log.Debug("NUI", "view position=(" + view.Position.X + "," + view.Position.Y + "," + view.Position.Z + ")"); + Tizen.Log.Debug("NUI", "view position=(" + view.PositionX + "," + view.PositionY + "," + view.PositionZ + ")"); + Tizen.Log.Debug("NUI", "view cur position=(" + view.CurrentPosition.X + "," + view.CurrentPosition.Y + "," + view.CurrentPosition.Z + ")"); + Tizen.Log.Debug("NUI", "tangent=(" + tangent.X + "," + tangent.Y + "," + tangent.Z + ")"); + Tizen.Log.Debug("NUI", "angle between=" + Rotation.AngleBetween(view.Orientation, rotation) + " view orientation length=" + view.Orientation.Length() + " rotation length=" + rotation.Length()); + //Assert.AreEqual(position.X, view.PositionX, "The actor's PositionX of is not correct"); + //Assert.AreEqual(position.Y, actor.PositionY, "The actor's PositionY of is not correct"); + //Assert.AreEqual(position.Z, actor.PositionZ, "The actor's PositionZ of is not correct"); + //Assert.IsTrue(rotation.Equals(actor.Orientation)); + //await Task.Delay(250); + path.Sample(0.25f, position, tangent); + rotation = new Rotation(new Radian(new Degree(0.0f)), tangent); + Tizen.Log.Debug("NUI", "################ progress = 0.25! "); + Tizen.Log.Debug("NUI", "position=(" + position.X + "," + position.Y + "," + position.Z + ")"); + Tizen.Log.Debug("NUI", "view position=(" + view.Position.X + "," + view.Position.Y + "," + view.Position.Z + ")"); + Tizen.Log.Debug("NUI", "view position=(" + view.PositionX + "," + view.PositionY + "," + view.PositionZ + ")"); + Tizen.Log.Debug("NUI", "view cur position=(" + view.CurrentPosition.X + "," + view.CurrentPosition.Y + "," + view.CurrentPosition.Z + ")"); + Tizen.Log.Debug("NUI", "tangent=(" + tangent.X + "," + tangent.Y + "," + tangent.Z + ")"); + Tizen.Log.Debug("NUI", "angle between=" + Rotation.AngleBetween(view.Orientation, rotation) + " view orientation length=" + view.Orientation.Length() + " rotation length=" + rotation.Length()); + //Assert.AreEqual(position.X, actor.PositionX, "The PositionX of actor is not correct"); + //Assert.AreEqual(position.Y, actor.PositionY, "The PositionY of actor is not correct"); + //Assert.AreEqual(position.Z, actor.PositionZ, "The PositionZ of actor is not correct"); + //Assert.IsTrue(rotation.Equals(actor.Orientation)); + //await Task.Delay(500); + path.Sample(0.75f, position, tangent); + rotation = new Rotation(new Radian(new Degree(0.0f)), tangent); + Tizen.Log.Debug("NUI", "################ progress = 0.75! "); + Tizen.Log.Debug("NUI", "position=(" + position.X + "," + position.Y + "," + position.Z + ")"); + Tizen.Log.Debug("NUI", "view position=(" + view.Position.X + "," + view.Position.Y + "," + view.Position.Z + ")"); + Tizen.Log.Debug("NUI", "view position=(" + view.PositionX + "," + view.PositionY + "," + view.PositionZ + ")"); + Tizen.Log.Debug("NUI", "view cur position=(" + view.CurrentPosition.X + "," + view.CurrentPosition.Y + "," + view.CurrentPosition.Z + ")"); + Tizen.Log.Debug("NUI", "tangent=(" + tangent.X + "," + tangent.Y + "," + tangent.Z + ")"); + Tizen.Log.Debug("NUI", "angle between=" + Rotation.AngleBetween(view.Orientation, rotation) + " view orientation length=" + view.Orientation.Length() + " rotation length=" + rotation.Length()); + //Assert.AreEqual(position.X, actor.PositionX, "The PositionX of actor is not correct here"); + //Assert.AreEqual(position.Y, actor.PositionY, "The PositionY of actor is not correct here"); + //Assert.AreEqual(position.Z, actor.PositionZ, "The PositionZ of actor is not correct here"); + //Assert.IsTrue(rotation.Equals(actor.Orientation)); + + path.Sample(1.0f, position, tangent); + rotation = new Rotation(new Radian(new Degree(0.0f)), tangent); + Tizen.Log.Debug("NUI", "################ progress = 1.0! "); + Tizen.Log.Debug("NUI", "position=(" + position.X + "," + position.Y + "," + position.Z + ")"); + Tizen.Log.Debug("NUI", "view position=(" + view.Position.X + "," + view.Position.Y + "," + view.Position.Z + ")"); + Tizen.Log.Debug("NUI", "view position=(" + view.PositionX + "," + view.PositionY + "," + view.PositionZ + ")"); + Tizen.Log.Debug("NUI", "view cur position=(" + view.CurrentPosition.X + "," + view.CurrentPosition.Y + "," + view.CurrentPosition.Z + ")"); + Tizen.Log.Debug("NUI", "tangent=(" + tangent.X + "," + tangent.Y + "," + tangent.Z + ")"); + Tizen.Log.Debug("NUI", "angle between=" + Rotation.AngleBetween(view.Orientation, rotation) + " view orientation length=" + view.Orientation.Length() + " rotation length=" + rotation.Length()); + + + Tizen.Log.Debug("NUI", "#### 2) animate path test end!"); + } + + + + + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/text-test.cs b/test/NUITestSample/NUITestSample/examples/text-test.cs new file mode 100755 index 000000000..11bc56a8f --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/text-test.cs @@ -0,0 +1,177 @@ +/* +* Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; + +namespace TextTest +{ + class Example : NUIApplication + { + TextLabel _pointLabel; + Boolean _colorToggle; + + public Example() : base() + { + } + + public Example(string stylesheet) : base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + private bool LabelTouched(object sender, View.TouchEventArgs e) + { + if (e.Touch.GetState(0) == PointStateType.Down) + { + Animation textColorAnimation = new Animation(1000); + if (_colorToggle) + { + textColorAnimation.AnimateTo(_pointLabel, "TextColorAnimatable", Color.Blue ); + _colorToggle = false; + } + else + { + textColorAnimation.AnimateTo(_pointLabel, "TextColorAnimatable", Color.Green ); + _colorToggle = true; + } + textColorAnimation.Play(); + } + return true; + } + + + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + TextLabel pixelLabel = new TextLabel("Test Pixel Size 32.0f"); + pixelLabel.Position2D = new Position2D(10, 10); + pixelLabel.PixelSize = 32.0f; + pixelLabel.BackgroundColor = Color.Magenta; + window.Add(pixelLabel); + + _pointLabel = new TextLabel("Test Point Size 32.0f"); + _pointLabel.Position2D = new Position2D(10, 100); + _pointLabel.PointSize = 32.0f; + _pointLabel.BackgroundColor = Color.Red; + //_pointLabel.TextColorAnimatable = Color.Green; // Set initial text color using animatable property + _pointLabel.TouchEvent += LabelTouched; + _colorToggle = true; + + window.Add(_pointLabel); + + + TextLabel ellipsis = new TextLabel("Ellipsis of TextLabel is enabled."); + ellipsis.Size2D = new Size2D(100, 80); + ellipsis.Position2D = new Position2D(10, 200); + ellipsis.PointSize = 20.0f; + ellipsis.Ellipsis = true; + ellipsis.BackgroundColor = Color.Cyan; + window.Add(ellipsis); + + TextLabel autoScrollStopMode = new TextLabel("AutoScrollStopMode is finish-loop."); + autoScrollStopMode.Size2D = new Size2D(400, 50); + autoScrollStopMode.Position2D = new Position2D(10, 300); + autoScrollStopMode.PointSize = 15.0f; + autoScrollStopMode.BackgroundColor = Color.Green; + autoScrollStopMode.AutoScrollStopMode = AutoScrollStopMode.FinishLoop; + autoScrollStopMode.EnableAutoScroll = true; + window.Add(autoScrollStopMode); + + TextField field = new TextField(); + field.Size2D = new Size2D(400, 100); + field.Position2D = new Position2D(10, 400); + field.BackgroundColor = Color.Cyan; + field.PlaceholderText = "input someth..."; + field.PlaceholderTextFocused = "input someth... focused"; + field.Focusable = true; + PropertyMap hiddenMap = new PropertyMap(); + hiddenMap.Add(HiddenInputProperty.Mode, new PropertyValue((int)HiddenInputModeType.ShowLastCharacter)); + hiddenMap.Add(HiddenInputProperty.ShowLastCharacterDuration, new PropertyValue(2)); + hiddenMap.Add(HiddenInputProperty.SubstituteCount, new PropertyValue(4)); + hiddenMap.Add(HiddenInputProperty.SubstituteCharacter, new PropertyValue(0x23)); + field.HiddenInputSettings = hiddenMap; + field.EnableSelection = true; + window.Add(field); + + InputMethod inputMethod = new InputMethod(); + inputMethod.PanelLayout = InputMethod.PanelLayoutType.Number; + inputMethod.ActionButton = InputMethod.ActionButtonTitleType.Go; + inputMethod.AutoCapital = InputMethod.AutoCapitalType.Word; + inputMethod.Variation = 1; + + field.InputMethodSettings = inputMethod.OutputMap; + + PropertyMap propertyMap = new PropertyMap(); + propertyMap.Add("placeholderText", new PropertyValue("Placeholder Text")); + propertyMap.Add("placeholderTextFocused", new PropertyValue("Placeholder Text Focused")); + propertyMap.Add("placeholderColor", new PropertyValue(Color.Red)); + propertyMap.Add("placeholderPointSize", new PropertyValue(15.0f)); + + PropertyMap fontStyleMap = new PropertyMap(); + fontStyleMap.Add("weight", new PropertyValue("bold")); + fontStyleMap.Add("width", new PropertyValue("condensed")); + fontStyleMap.Add("slant", new PropertyValue("italic")); + propertyMap.Add("placeholderFontStyle", new PropertyValue(fontStyleMap)); + + TextEditor editor = new TextEditor(); + editor.Size2D = new Size2D(400, 100); + editor.Position2D = new Position2D(10, 550); + editor.BackgroundColor = Color.Magenta; + editor.EnableScrollBar = true; + editor.EnableSelection = true; + editor.Focusable = true; + editor.Placeholder = propertyMap; + window.Add(editor); + editor.TextChanged += (obj, e) => { + Tizen.Log.Debug("NUI", "editor line count: " + e.TextEditor.LineCount); + }; + + editor.ScrollStateChanged += (obj, e)=> { + Tizen.Log.Debug("NUI", "editor scroll state:" + e.ScrollState); + }; + + Tizen.Log.Debug("NUI", "editor id: " + editor.ID); + + FocusManager.Instance.SetCurrentFocusView(editor); + editor.UpFocusableView = field; + field.DownFocusableView = editor; + } + + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/text-test2.cs b/test/NUITestSample/NUITestSample/examples/text-test2.cs new file mode 100755 index 000000000..75d43fe63 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/text-test2.cs @@ -0,0 +1,222 @@ +/* +* Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; + +namespace TextTest2 +{ + class Example : NUIApplication + { + public Example() : base() + { + } + + public Example(string stylesheet) : base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + private PushButton button; + private TextEditor editor; + private ImfManager imfManager; + + + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + PropertyMap propertyMap = new PropertyMap(); + propertyMap.Add("placeholderText", new PropertyValue("TextEditor Placeholder Text")); + propertyMap.Add("placeholderColor", new PropertyValue(Color.Red)); + propertyMap.Add("placeholderPointSize", new PropertyValue(12.0f)); + + PropertyMap fontStyleMap = new PropertyMap(); + fontStyleMap.Add("weight", new PropertyValue("bold")); + fontStyleMap.Add("width", new PropertyValue("condensed")); + fontStyleMap.Add("slant", new PropertyValue("italic")); + propertyMap.Add("placeholderFontStyle", new PropertyValue(fontStyleMap)); + + + editor = new TextEditor() + { + Size2D = new Size2D(500, 300), + Position2D = new Position2D(10, 550), + BackgroundColor = Color.Magenta, + Focusable = true, + Placeholder = propertyMap + }; + + window.Add(editor); + + editor.TextChanged += (obj, e) => { + Tizen.Log.Fatal("NUI", "editor line count: " + e.TextEditor.LineCount); + }; + + editor.ScrollStateChanged += (obj, e) => { + Tizen.Log.Fatal("NUI", "editor scroll state:" + e.ScrollState); + }; + + editor.KeyEvent += OnKeyEvent; + + + Tizen.Log.Debug("NUI", "editor id: " + editor.ID); + + imfManager = ImfManager.Get(); + imfManager.AutoEnableInputPanel(false); + imfManager.SetInputPanelUserData("layouttype = 1 & entrylimit = 255 & action = clearall_for_voice_commit & caller = org.volt.search - all"); + + + // send privatecommand event + ImfManager.ImfEventData imfevent = new ImfManager.ImfEventData(ImfManager.ImfEvent.PrivateCommand, "", 0, 0); + imfManager.EventReceived += ImfManager_ImfManagerEventReceived; + + imfManager.LanguageChanged += ImfManager_LanguageChanged; + + imfManager.Activated += (obj, e) => { + Tizen.Log.Debug("NUI", "ImfManager Activated !!!!!"); + }; + imfManager.StatusChanged += (obj, e) => { + Tizen.Log.Debug("NUI", "ImfManager StatusChanged: !!!!!" + e.StatusChanged); + }; + imfManager.Resized += (obj, e) => + { + Tizen.Log.Debug("NUI", "ImfManager Resized !!!!!"); + }; + imfManager.KeyboardTypeChanged += (obj, e) => { + Tizen.Log.Debug("NUI", "ImfManager KeyboardTypeChanged: !!!!!" + e.KeyboardType); + }; + + button = new PushButton() + { + LabelText = "Button", + Size2D = new Size2D(400, 200), + Position2D = new Position2D(10, -10), + ParentOrigin = ParentOrigin.BottomLeft, + PivotPoint = PivotPoint.BottomLeft, + PositionUsesPivotPoint = true, + Focusable = true + }; + + window.Add(button); + + button.UpFocusableView = editor; + editor.DownFocusableView = button; + + FocusManager.Instance.SetCurrentFocusView(button); + } + + private bool OnKeyEvent(object source, View.KeyEventArgs e) + { + Tizen.Log.Debug("NUI", "KeyEvent called !!!!!"); + if (e.Key.State != Key.StateType.Down || editor.Focusable == false) + { + Tizen.Log.Debug("NUI", "KeyEvent ignored !!!!!"); + return false; + } + switch (e.Key.KeyPressedName) + { + case "Return": + Tizen.Log.Debug("NUI", "KeyPressedName: Return !!!!!"); + ShowImf(); + return true; + case "Select": + Tizen.Log.Debug("NUI", "KeyPressedName: Select !!!!!"); + HideImf(); + return true; + case "Cancel": + Tizen.Log.Debug("NUI", "KeyPressedName: Cancel !!!!!"); + HideImf(); + return true; + case "Down": + Tizen.Log.Debug("NUI", "KeyPressedName: Down !!!!!"); + HideImf(); + return MoveFocusTo(button); + } + return false; + } + + private void ShowImf() + { + imfManager.Activate(); + imfManager.ShowInputPanel(); + Tizen.Log.Debug("NUI", "IME showed !!!!!"); + } + + private bool MoveFocusTo(View view) + { + if (view == null) return false; + return FocusManager.Instance.SetCurrentFocusView(view); + } + + private void HideImf() + { + imfManager.Deactivate(); + imfManager.HideInputPanel(); + Tizen.Log.Debug("NUI", "IME hided !!!!!"); + } + + public ImfManager.ImfCallbackData ImfManager_ImfManagerEventReceived(object sender, ImfManager.EventReceivedEventArgs e) + { + Tizen.Log.Debug("NUI", "ImfManager_ImfManagerEventReceived()!"); + + Tizen.Log.Debug("NUI", "e.ImfEventData.PredictiveString= " + e?.ImfEventData?.PredictiveString); + Tizen.Log.Debug("NUI", "e.ImfEventData.CursorOffset= " + e?.ImfEventData?.CursorOffset); + Tizen.Log.Debug("NUI", "e.ImfEventData.EventName= " + e?.ImfEventData?.EventName); + Tizen.Log.Debug("NUI", "e.ImfEventData.NumberOfChars= " + e?.ImfEventData?.NumberOfChars); + + //Be able to compare VD specific private command with ImfEventData.predictiveString + if (e.ImfEventData.PredictiveString == "IME_F31") + { + ImfManager.Get().Deactivate(); + ImfManager.Get().HideInputPanel(); + // Do Something the user wants + Tizen.Log.Debug("NUI", "ImfManager ImfEventData.PredictiveString: IME_F31!!!"); + } + ImfManager.ImfCallbackData callbackData = new ImfManager.ImfCallbackData(true, 0, e.ImfEventData.PredictiveString, false); + Tizen.Log.Debug("NUI", "ImfManager return callbackData!!!"); + return callbackData; + } + + public void ImfManager_LanguageChanged(object sender, EventArgs args) + { + Tizen.Log.Debug("NUI", "ImfManager LanguageChanged!!!"); + return; + } + + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/timer-test.cs b/test/NUITestSample/NUITestSample/examples/timer-test.cs new file mode 100755 index 000000000..6b408e7a5 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/timer-test.cs @@ -0,0 +1,112 @@ +using System; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.UIComponents; +using Tizen.NUI.Constants; + +namespace TimerTest +{ + // An example of Visual View control. + class Example : NUIApplication + { + private static int i = 0; + + public Example() : base() + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + TextLabel label = new TextLabel() + { + Text = "Steps: 0", + Size2D = new Size2D(460, 80), + Position2D = new Position2D(10, 10) + }; + + RadioButton radio1 = new RadioButton() + { + LabelText = "Set interval 500", + Size2D = new Size2D(300, 50), + Position2D = new Position2D(10, 100), + }; + RadioButton radio2 = new RadioButton() + { + LabelText = "Set interval 1000", + Size2D = new Size2D(300, 50), + Position2D = new Position2D(10, 160), + Selected = true + }; + RadioButton radio3 = new RadioButton() + { + LabelText = "Set interval 3000", + Size2D = new Size2D(300, 50), + Position2D = new Position2D(10, 220), + }; + + PushButton button1 = new PushButton() + { + LabelText = "Start", + Size2D = new Size2D(100, 50), + Position2D = new Position2D(10, 300), + Focusable = true + }; + + PushButton button2 = new PushButton() + { + LabelText = "Stop", + Size2D = new Size2D(100, 50), + Position2D = new Position2D(140, 300), + Focusable = true + }; + + window.Add(label); + window.Add(radio1); + window.Add(radio2); + window.Add(radio3); + window.Add(button1); + window.Add(button2); + + FocusManager.Instance.SetCurrentFocusView(button1); + button1.LeftFocusableView = button1.RightFocusableView = button2; + button2.RightFocusableView = button2.LeftFocusableView = button1; + button1.UpFocusableView = button2.UpFocusableView = radio3; + radio3.UpFocusableView = radio2; + radio2.UpFocusableView = radio1; + radio1.DownFocusableView = radio2; + radio2.DownFocusableView = radio3; + radio3.DownFocusableView = button1; + + Timer timer = new Timer(1000); + timer.Tick += (obj, e) => + { + Tizen.Log.Fatal("NUI", "NUI Timer tick called!"); + label.Text = "Steps: " + (i++); + return true; + }; + + button1.Clicked += (obj, e) => + { + if (radio1.Selected == true) timer.Interval = 500; + if (radio2.Selected == true) timer.Interval = 1000; + if (radio3.Selected == true) timer.Interval = 3000; + timer.Start(); + return true; + }; + button2.Clicked += (obj, e) => + { + timer.Stop(); + return true; + }; + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/ttsplayer-test.cs b/test/NUITestSample/NUITestSample/examples/ttsplayer-test.cs new file mode 100755 index 000000000..e0807ce35 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/ttsplayer-test.cs @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2017 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; + +namespace TTSPlayerTest +{ + class Example : NUIApplication + { + public Example() : base() + { + } + + public Example(string stylesheet) : base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + TTSPlayer ttsPlayer = TTSPlayer.Get(TTSPlayer.TTSMode.Default); + ttsPlayer.Play("tts player test"); + + ttsPlayer.StateChanged += (s, e) => + { + Tizen.Log.Debug("NUI", "TTS state changed!!!"); + }; + ttsPlayer.Pause(); + ttsPlayer.Resume(); + ttsPlayer.Stop(); + Tizen.Log.Debug("NUI", "TTS state: " + ttsPlayer.GetState()); + } + + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/user-alphafunction.cs b/test/NUITestSample/NUITestSample/examples/user-alphafunction.cs new file mode 100755 index 000000000..f805af021 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/user-alphafunction.cs @@ -0,0 +1,203 @@ +/* +* Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; + +namespace UserAlphaFunctionTest +{ + class Example : NUIApplication + { + private Animation _animation; + private TextLabel _text; + private View _view1, _view2, _view3; + private UserAlphaFunctionDelegate _user_alpha_func; + private int myCount; + + public static void Log(string str) + { + Tizen.Log.Debug("NUI", "[DALI C# SAMPLE] " + str); + } + + public Example() : base() + { + } + + public Example(string stylesheet) : base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + // Declare user alpha function delegate + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + delegate float UserAlphaFunctionDelegate(float progress); + + public void Initialize() + { + Log("Initialize() is called!"); + Window window = Window.Instance; + window.BackgroundColor = Color.White; + window.TouchEvent += OnWindowTouched; + window.TouchEvent += OnWindowTouched2; + //window.EventProcessingFinished += OnEventProcessingFinished; + window.WheelEvent += OnWindowWheelEvent; + + // Add a _text label to the window + _text = new TextLabel("Hello Mono World"); + _text.ParentOrigin = ParentOrigin.BottomCenter; + _text.PivotPoint = PivotPoint.BottomCenter; + _text.HorizontalAlignment = HorizontalAlignment.Center; + _text.PointSize = 32.0f; + window.Add(_text); + + _view1 = new View(); + _view1.Size2D = new Size2D(200, 200); + _view1.BackgroundColor = Color.Green; + _view1.ParentOrigin = ParentOrigin.Center; + _view1.PivotPoint = PivotPoint.Center; + _view1.WidthResizePolicy = ResizePolicyType.Fixed; + _view1.HeightResizePolicy = ResizePolicyType.Fixed; + _view1.AddedToWindow += OnWindow; + window.Add(_view1); + + _view2 = new View(); + _view2.BackgroundColor = Color.Red; + _view2.Size2D = new Size2D(50, 50); + _view2.ParentOrigin = ParentOrigin.TopLeft; + _view2.PivotPoint = PivotPoint.TopLeft; + _view2.WidthResizePolicy = ResizePolicyType.Fixed; + _view2.HeightResizePolicy = ResizePolicyType.Fixed; + _view1.Add(_view2); + + _view3 = new View(); + _view3.BackgroundColor = Color.Blue; + _view3.Size2D = new Size2D(50, 50); + _view3.ParentOrigin = ParentOrigin.TopLeft; + _view3.PivotPoint = PivotPoint.TopLeft; + _view3.WidthResizePolicy = ResizePolicyType.Fixed; + _view3.HeightResizePolicy = ResizePolicyType.Fixed; + _view1.Add(_view3); + + _user_alpha_func = new UserAlphaFunctionDelegate(body); + + MyAnimating(); + } + + // User defines alpha function as custom alpha function + // Important Notification : when this custom alpha-function is implemented, + // the other function call nor other data excess is prevented. + // this method must be implemented to calculate the values of input and output purely. + // unless, this will cause application crash. + float body(float progress) + { + if (progress > 0.2f && progress < 0.7f) + { + return progress + 0.8f; + } + return progress; + } + + // Callback for _animation finished signal handling + public void AnimationFinished(object sender, EventArgs e) + { + Log("AnimationFinished() is called!"); + myCount = 0; + } + + public void MyAnimating() + { + // Create a new _animation + if (_animation) + { + _animation.Clear(); + _animation.Reset(); + } + + _animation = new Animation(10000); // 10000 milli-second of duration + _animation.AnimateTo(_view2, "Position", new Vector3(150.0f, 150.0f, 0.0f), 5000, 10000, new AlphaFunction(_user_alpha_func)); + // Connect the signal callback for animaiton finished signal + _animation.Finished += AnimationFinished; + _animation.EndAction = Animation.EndActions.Discard; + // Play the _animation + _animation.Play(); + } + + // Callback for window touched signal handling + public void OnWindowTouched(object source, Window.TouchEventArgs e) + { + // Only animate the _text label when touch down happens + if (e.Touch.GetState(0) == PointStateType.Down) + { + Log("OnWindowTouched() is called! PointStateType.DOWN came!"); + myCount++; + if (myCount > 1) + { + _animation.Stop(); + Log("_animation.Stop() is called!"); + } + } + } + + // Callback for window touched signal handling + public void OnWindowTouched2(object source, Window.TouchEventArgs e) + { + Log("OnWindowTouched2() is called!state=" + e.Touch.GetState(0)); + } + + public void OnEventProcessingFinished(object source) + { + Log("OnEventProcessingFinished() is called!"); + } + + public void OnWindowWheelEvent(object source, Window.WheelEventArgs e) + { + Log("OnWindowWheelEvent() is called!"); + //Log("OnWindowWheelEvent() is called!direction="+ e.WheelEvent.direction + " timeStamp=" + e.WheelEvent.timeStamp ); + } + + + public void OnWindow(object source, EventArgs e) + { + Log("OnWindow() is called!"); + } + + [STAThread] + static void _Main(string[] args) + { + Log("Main() is called!"); + + Example example = new Example(); + example.Run(args); + + Log("After MainLoop()"); + } + } +} + diff --git a/test/NUITestSample/NUITestSample/examples/view-navi-property.cs b/test/NUITestSample/NUITestSample/examples/view-navi-property.cs new file mode 100755 index 000000000..ce68ed0f7 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/view-navi-property.cs @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2017 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 MyCSharpExample +{ + class Example : NUIApplication + { + const int num = 2; + View[] view; + + View lastFocusedView; + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + public void Initialize() + { + view = new View[2]; + + for (int i = 0; i < num; i++) + { + view[i] = new View(); + view[i].Size2D = new Size2D(200, 200); + view[i].BackgroundColor = Color.Blue; + view[i].Position = new Position(300 + i * 300, 300, 0); + view[i].Name = "MyView" + i; + view[i].Focusable = true; + Window.Instance.Add(view[i]); + view[i].FocusGained += FocusNavigationSample_FocusGained; + view[i].FocusLost += FocusNavigationSample_FocusLost; + view[i].KeyEvent += FocusNavigationSample_KeyEvent; + } + + view[0].RightFocusableView = view[1]; + view[0].LeftFocusableView = view[1]; + view[1].RightFocusableView = view[0]; + view[1].LeftFocusableView = view[0]; + + FocusManager.Instance.SetCurrentFocusView(view[0]); + FocusManager.Instance.PreFocusChange += Instance_PreFocusChange; + + Window.Instance.TouchEvent += Instance_Touch; + } + + private void Instance_Touch(object sender, Window.TouchEventArgs e) + { + Tizen.Log.Debug("NUI", "window touched! set key focus as view[0]!"); + FocusManager.Instance.SetCurrentFocusView(view[0]); + } + + private bool FocusNavigationSample_KeyEvent(object source, View.KeyEventArgs e) + { + Tizen.Log.Debug("NUI", "..."); + View view = source as View; + + Tizen.Log.Debug("NUI", "NUI-1 " + "View-" + view.Name + ", Pressed-" + e.Key.KeyPressedName + e.Key.State.ToString()); + + return false; + } + + private void FocusNavigationSample_FocusLost(object sender, EventArgs e) + { + Tizen.Log.Debug("NUI", "..."); + View view = sender as View; + view.BackgroundColor = Color.Blue; + view.Scale = new Vector3(1.0f, 1.0f, 1.0f); + + Tizen.Log.Debug("NUI", "NUI-2 " + "FocusLost-" + view.Name); + } + + private void FocusNavigationSample_FocusGained(object sender, EventArgs e) + { + Tizen.Log.Debug("NUI", "..."); + View view = sender as View; + view.BackgroundColor = Color.Red; + view.Scale = new Vector3(1.2f, 1.2f, 1.0f); + + Tizen.Log.Debug("NUI", "NUI-3 " + "FocusGained-" + view.Name); + } + + private View Instance_PreFocusChange(object source, FocusManager.PreFocusChangeEventArgs e) + { + Tizen.Log.Debug("NUI", "..."); + View currentView = (e.CurrentView) ?? lastFocusedView; + View nextView = null; + + Tizen.Log.Debug("NUI", "NUI-4 " + "PreFocusChange-" + e.Direction); + + if (currentView != null && currentView.HasBody()) + Tizen.Log.Debug("NUI", "NUI-5 " + " Current-" + currentView.Name); + + if (currentView) + { + switch (e.Direction) + { + case View.FocusDirection.Left: + nextView = currentView.LeftFocusableView; + if (nextView == null) + Tizen.Log.Debug("NUI", "NUI-6 " + "LeftFocusableView is NULL!!!!"); + else + Tizen.Log.Debug("NUI", "NUI-7 " + currentView.Name + ".LeftFocusableView =" + nextView.Name); + break; + case View.FocusDirection.Right: + nextView = currentView.RightFocusableView; + if (nextView == null) + Tizen.Log.Debug("NUI", "NUI-8 " + "RightFocusableView is NULL!!!!"); + else + Tizen.Log.Debug("NUI", "NUI-9 " + currentView.Name + ".RightFocusableView =" + nextView.Name); + break; + case View.FocusDirection.Up: + nextView = currentView.UpFocusableView; + if (nextView == null) + Tizen.Log.Debug("NUI", "NUI-10 " + "UpFocusableView is NULL!!!!"); + else + Tizen.Log.Debug("NUI", "NUI-11 " + currentView.Name + ".UpFocusableView =" + nextView.Name); + break; + case View.FocusDirection.Down: + nextView = currentView.DownFocusableView; + if (nextView == null) + Tizen.Log.Debug("NUI", "NUI-12 " + "DownFocusableView is NULL!!!!"); + else + Tizen.Log.Debug("NUI", "NUI-13 " + currentView.Name + ".DownFocusableView =" + nextView.Name); + break; + default: + nextView = null; //added + break; + } + } + + if (e.ProposedView == null) + { + Tizen.Log.Debug("NUI", "NUI-14 " + "ProposedView in NULL!!"); + } + else if (e.ProposedView.HasBody()) + { + Tizen.Log.Debug("NUI", "NUI-15 " + "ProposedView-" + e.ProposedView.Name); + } + else + { + Tizen.Log.Debug("NUI", "NUI-16 " + "ProposedView does NOT have body!!!" + e.ProposedView); + } + + nextView = nextView ?? (e.ProposedView) ?? currentView; + lastFocusedView = nextView; + + if (nextView != null && nextView.HasBody()) + Tizen.Log.Debug("NUI", "NUI-17 " + "Next-" + nextView.Name); + + return nextView; + } + + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} \ No newline at end of file diff --git a/test/NUITestSample/NUITestSample/examples/visual-animation-test.cs b/test/NUITestSample/NUITestSample/examples/visual-animation-test.cs new file mode 100755 index 000000000..39ea8f49d --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/visual-animation-test.cs @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; + +namespace VisaulAnimationExample +{ + class Example : NUIApplication + { + private VisualView _contentView; + private TextLabel _title; + private PushButton _shadowButton; + private bool _active = false; + private const string _resPath = "/home/owner/apps_rw/NUISamples.TizenTV/res"; //for tizen + //private const string _resPath = "./res"; //for ubuntu + + private Animation _animation1; + private bool _transitionInProgress = false; + private int cnt1, cnt2; + + private SVGVisual svgVisual; + private AnimatedImageVisual gifVisual; + private ImageVisual _icon; + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + TableView titleLayout = new TableView(2, 1); + titleLayout.Name = ("TitleLayout"); + titleLayout.PivotPoint = PivotPoint.TopLeft; + titleLayout.Position2D = new Position2D(10, 10); + titleLayout.Size2D = new Size2D((int)(window.Size.Width * 0.9f), (int)(window.Size.Height * 0.9f)); + titleLayout.SetCellPadding(new Size2D(10, 10)); + titleLayout.BackgroundColor = Color.Cyan; + window.Add(titleLayout); + + _title = new TextLabel("Visual Transition / SVG / AGIF Example"); + _title.Name = ("Title"); + _title.SetStyleName("Title"); + _title.WidthResizePolicy = ResizePolicyType.FillToParent; + _title.HeightResizePolicy = ResizePolicyType.UseNaturalSize; + _title.HorizontalAlignment = HorizontalAlignment.Center; + titleLayout.AddChild(_title, new TableView.CellPosition(0, 0)); + titleLayout.SetFitHeight(0); + + TableView contentLayout = new TableView(3, 2); + contentLayout.Name = ("ContentLayout"); + contentLayout.WidthResizePolicy = ResizePolicyType.FillToParent; + contentLayout.HeightResizePolicy = ResizePolicyType.FillToParent; + contentLayout.PivotPoint = PivotPoint.TopLeft; + contentLayout.SetCellPadding(new Size2D(10, 10)); + contentLayout.BackgroundColor = Color.Magenta; + titleLayout.AddChild(contentLayout, new TableView.CellPosition(1, 0)); + + ////////////////////////////////////////////////////////////////////// + // Create a conttent view + _contentView = new VisualView(); + _contentView.WidthResizePolicy = ResizePolicyType.SizeRelativeToParent; + _contentView.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent; + //_contentView.Size2D = new Size2D(250, 250); + _contentView.BackgroundImage = _resPath + "/images/background-blocks.jpg"; + + _icon = new ImageVisual(); + _icon.URL = _resPath + "/images/application-icon-0.png"; + _icon.DepthIndex = 1; + _icon.Size = new Size2D(50, 50); + _icon.SizePolicy = VisualTransformPolicyType.Absolute; + _icon.Position = new Position2D(5, 5); + _icon.PositionPolicy = VisualTransformPolicyType.Absolute; + _icon.Origin = Visual.AlignType.TopBegin; + _icon.AnchorPoint = Visual.AlignType.TopBegin; + _icon.MixColor = new Color(0, 1, 0, 0.5f); + _icon.Opacity = 0.5f; + _contentView.AddVisual("icon_visual1", _icon); + + contentLayout.AddChild(_contentView, new TableView.CellPosition(0, 0)); + + _shadowButton = new PushButton(); + _shadowButton.LabelText = "Toggle Transition"; + _shadowButton.Name = ("ToggleTransition"); + _shadowButton.ParentOrigin = ParentOrigin.Center; + _shadowButton.PivotPoint = PivotPoint.Center; + _shadowButton.Clicked += (obj, ev) => + { + _active = !_active; + StartTransition(_active); + return true; + }; + _shadowButton.WidthResizePolicy = ResizePolicyType.FillToParent; + _shadowButton.HeightResizePolicy = ResizePolicyType.FillToParent; + contentLayout.AddChild(_shadowButton, new TableView.CellPosition(0, 1)); + + ////////////////////////////////////////////////////////////////////// + // make NPatch visual test + NPatchVisual npatch1 = new NPatchVisual(); + npatch1.URL = _resPath + "/images/gallery-2.jpg"; + npatch1.Size = new Size2D(400, 400); + npatch1.SizePolicy = VisualTransformPolicyType.Absolute; + npatch1.Position = new Position2D(400, 0); + npatch1.PositionPolicy = VisualTransformPolicyType.Absolute; + npatch1.Origin = Visual.AlignType.TopBegin; + npatch1.AnchorPoint = Visual.AlignType.TopBegin; + npatch1.Border = new Rectangle(100, 100, 100, 100); + npatch1.DepthIndex = 2; + npatch1.MixColor = new Color(1, 0, 0, 1); + npatch1.Opacity = 0.5f; + _contentView.AddVisual("npatchImageVisual1", npatch1); + + ////////////////////////////////////////////////////////////////////// + // make SVG visual test + VisualView VisualView1 = new VisualView(); + VisualView1.WidthResizePolicy = ResizePolicyType.FillToParent; + VisualView1.HeightResizePolicy = ResizePolicyType.FillToParent; + VisualView1.BackgroundColor = Color.Black; + contentLayout.AddChild(VisualView1, new TableView.CellPosition(1, 0)); + + svgVisual = new SVGVisual(); + svgVisual.URL = _resPath + "/images/Kid1.svg"; + svgVisual.Size = new Size2D(300, 300); + svgVisual.SizePolicy = VisualTransformPolicyType.Absolute; + svgVisual.Position = new Position2D(0, 0); + svgVisual.PositionPolicy = VisualTransformPolicyType.Absolute; + svgVisual.Origin = Visual.AlignType.TopBegin; + svgVisual.AnchorPoint = Visual.AlignType.TopBegin; + VisualView1.AddVisual("svg_visual1", svgVisual); + + PushButton svgButton = new PushButton(); + svgButton.LabelText = "SVG Visual Test"; + svgButton.Name = ("svg_visual_test"); + svgButton.PivotPoint = PivotPoint.Center; + svgButton.WidthResizePolicy = ResizePolicyType.FillToParent; + svgButton.HeightResizePolicy = ResizePolicyType.FillToParent; + svgButton.Clicked += (obj, ev) => + { + cnt1++; + if (cnt1 % 2 == 0) + { + svgVisual.URL = _resPath + "/images/World.svg"; + } + else + { + svgVisual.URL = _resPath + "/images/Mail.svg"; + } + Tizen.Log.Debug("NUI", "svg button clicked!"); + return true; + }; + contentLayout.AddChild(svgButton, new TableView.CellPosition(1, 1)); + + ////////////////////////////////////////////////////////////////////// + // make AnimatedImage visual test + VisualView VisualView2 = new VisualView(); + VisualView2.WidthResizePolicy = ResizePolicyType.FillToParent; + VisualView2.HeightResizePolicy = ResizePolicyType.FillToParent; + VisualView2.BackgroundColor = Color.Blue; + contentLayout.AddChild(VisualView2, new TableView.CellPosition(2, 0)); + + gifVisual = new AnimatedImageVisual(); + gifVisual.URL = _resPath + "/images/dog-anim.gif"; + gifVisual.Size = new Size2D(200, 200); + gifVisual.SizePolicy = VisualTransformPolicyType.Absolute; + gifVisual.Position = new Position2D(0, 0); + gifVisual.PositionPolicy = VisualTransformPolicyType.Absolute; + gifVisual.Origin = Visual.AlignType.TopBegin; + gifVisual.AnchorPoint = Visual.AlignType.TopBegin; + VisualView2.AddVisual("gif_visual", gifVisual); + + PushButton gifButton = new PushButton(); + gifButton.LabelText = "AnimatedImage Visual Test"; + gifButton.Name = ("gif_visual_test"); + gifButton.PivotPoint = PivotPoint.Center; + gifButton.WidthResizePolicy = ResizePolicyType.FillToParent; + gifButton.HeightResizePolicy = ResizePolicyType.FillToParent; + gifButton.Clicked += (obj, ev) => + { + Tizen.Log.Debug("NUI", "gif button clicked!"); + cnt2++; + int gifNum = cnt2 % 15; + gifVisual.URL = _resPath + "/images/anim-gif/" + gifNum + ".gif"; + gifButton.LabelText = "file:" + gifNum + ".gif"; + return true; + }; + contentLayout.AddChild(gifButton, new TableView.CellPosition(2, 1)); + } + + private void StartTransition(bool activate) + { + if (_animation1) + { + _animation1.Stop(); + _animation1.Finished += OnTransitionFinished1; + } + + if (activate) + { + _contentView.AnimateVisualAdd(_icon, "Size", new Size2D(150, 150), 0, 1000, AlphaFunction.BuiltinFunctions.Linear); + _contentView.AnimateVisualAdd(_icon, "Position", new Position2D(40, 40), 0, 1000); + _animation1 = _contentView.AnimateVisualAddFinish(); + } + else + { + _contentView.AnimateVisualAdd(_icon, "Size", new Position2D(50, 50), 0, 1000, AlphaFunction.BuiltinFunctions.Linear); + _contentView.AnimateVisualAdd(_icon, "Position", new Position2D(5, 5), 0, 1000); + _animation1 = _contentView.AnimateVisualAddFinish(); + } + + if (_animation1) + { + _animation1.Finished += OnTransitionFinished1; + _transitionInProgress = true; + _animation1.Play(); + } + } + private void OnTransitionFinished1(object sender, EventArgs e) + { + _transitionInProgress = false; + if (_animation1) + { + _animation1.Finished += OnTransitionFinished1; + _animation1.Reset(); + } + } + + + /// + /// The main entry point for the application. + /// + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + + + } +} diff --git a/test/NUITestSample/NUITestSample/examples/visual-animation-test2.cs b/test/NUITestSample/NUITestSample/examples/visual-animation-test2.cs new file mode 100755 index 000000000..92528c0cb --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/visual-animation-test2.cs @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; + +namespace VisaulAnimationExample +{ + class Example2 : NUIApplication + { + private VisualView _contentView1; + private VisualView _contentView2; + private VisualView _contentView3; + private TextLabel _title; + private PushButton _shadowButton1; + private PushButton _shadowButton2; + private PushButton _shadowButton3; + private bool _active1 = false; + private bool _active2 = false; + private bool _active3 = false; + private const string _resPath = "/home/owner/apps_rw/NUISamples.TizenTV/res"; + + private Animation _animation; + private bool _transitionInProgress = false; + + public Example2() : base() + { + } + + public Example2(string stylesheet) : base(stylesheet) + { + } + + public Example2(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + TableView titleLayout = new TableView(2, 1); + titleLayout.Name = ("TitleLayout"); + titleLayout.PivotPoint = PivotPoint.TopLeft; + titleLayout.Position2D = new Position2D(10, 10); + titleLayout.Size2D = new Size2D((int)(window.Size.Width * 0.9f), (int)(window.Size.Height * 0.9f)); + titleLayout.SetCellPadding(new Size2D(10, 10)); + titleLayout.BackgroundColor = Color.Cyan; + window.Add(titleLayout); + + _title = new TextLabel("Visual Transition Example"); + _title.Name = ("Title"); + _title.SetStyleName("Title"); + _title.WidthResizePolicy = ResizePolicyType.FillToParent; + _title.HeightResizePolicy = ResizePolicyType.UseNaturalSize; + _title.HorizontalAlignment = HorizontalAlignment.Center; + titleLayout.AddChild(_title, new TableView.CellPosition(0, 0)); + titleLayout.SetFitHeight(0); + + TableView contentLayout = new TableView(3, 2); + contentLayout.Name = ("ContentLayout"); + contentLayout.WidthResizePolicy = ResizePolicyType.FillToParent; + contentLayout.HeightResizePolicy = ResizePolicyType.FillToParent; + contentLayout.PivotPoint = PivotPoint.TopLeft; + contentLayout.SetCellPadding(new Size2D(10, 10)); + contentLayout.BackgroundColor = Color.Magenta; + titleLayout.AddChild(contentLayout, new TableView.CellPosition(1, 0)); + + ////////////////////////////////////////////////////////////////////// + // make visual position animation + _contentView1 = new VisualView(); + _contentView1.WidthResizePolicy = ResizePolicyType.SizeRelativeToParent; + _contentView1.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent; + //_contentView.Size2D = new Size2D(250, 250); + _contentView1.BackgroundImage = _resPath + "/images/background-blocks.jpg"; + + ImageVisual _icon = new ImageVisual(); + _icon.URL = _resPath + "/images/application-icon-0.png"; + _icon.DepthIndex = 1; + _icon.Size = new Size2D(50, 50); + _icon.SizePolicy = VisualTransformPolicyType.Absolute; + _icon.Position = new Position2D(5, 5); + _icon.PositionPolicy = VisualTransformPolicyType.Absolute; + _icon.Origin = Visual.AlignType.TopBegin; + _icon.AnchorPoint = Visual.AlignType.TopBegin; + _icon.MixColor = new Color(0, 1, 0, 0.5f); + _icon.Opacity = 0.5f; + _contentView1.AddVisual("icon_visual1", _icon); + + contentLayout.AddChild(_contentView1, new TableView.CellPosition(0, 0)); + + _shadowButton1 = new PushButton(); + _shadowButton1.LabelText = "Toggle Transition Position"; + _shadowButton1.Name = ("ToggleTransition"); + _shadowButton1.ParentOrigin = ParentOrigin.Center; + _shadowButton1.PivotPoint = PivotPoint.Center; + _shadowButton1.Clicked += (obj, ev) => + { + _active1 = !_active1; + StartTransition(_contentView1, _icon, "Position", _active1); + return true; + }; + _shadowButton1.WidthResizePolicy = ResizePolicyType.FillToParent; + _shadowButton1.HeightResizePolicy = ResizePolicyType.FillToParent; + contentLayout.AddChild(_shadowButton1, new TableView.CellPosition(0, 1)); + + ////////////////////////////////////////////////////////////////////// + // make visual opacity animation + _contentView2 = new VisualView(); + _contentView2.WidthResizePolicy = ResizePolicyType.SizeRelativeToParent; + _contentView2.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent; + //_contentView.Size2D = new Size2D(250, 250); + _contentView2.BackgroundImage = _resPath + "/images/background-blocks.jpg"; + + ImageVisual _icon2 = new ImageVisual(); + _icon2.URL = _resPath + "/images/application-icon-0.png"; + _icon2.DepthIndex = 1; + _icon2.Size = new Size2D(50, 50); + _icon2.SizePolicy = VisualTransformPolicyType.Absolute; + _icon2.Position = new Position2D(5, 5); + _icon2.PositionPolicy = VisualTransformPolicyType.Absolute; + _icon2.Origin = Visual.AlignType.TopBegin; + _icon2.AnchorPoint = Visual.AlignType.TopBegin; + _icon2.MixColor = new Color(0, 1, 0, 0.5f); + _icon2.Opacity = 0.5f; + _contentView2.AddVisual("icon_visual2", _icon2); + + contentLayout.AddChild(_contentView2, new TableView.CellPosition(1, 0)); + + _shadowButton2 = new PushButton(); + _shadowButton2.LabelText = "Toggle Transition Opacity"; + _shadowButton2.Name = ("ToggleTransition"); + _shadowButton2.ParentOrigin = ParentOrigin.Center; + _shadowButton2.PivotPoint = PivotPoint.Center; + _shadowButton2.Clicked += (obj, ev) => + { + _active2 = !_active2; + StartTransition(_contentView2, _icon2, "Opacity", _active2); + return true; + }; + _shadowButton2.WidthResizePolicy = ResizePolicyType.FillToParent; + _shadowButton2.HeightResizePolicy = ResizePolicyType.FillToParent; + contentLayout.AddChild(_shadowButton2, new TableView.CellPosition(1, 1)); + + ////////////////////////////////////////////////////////////////////// + // make AnimatedImage visual test + _contentView3 = new VisualView(); + _contentView3.WidthResizePolicy = ResizePolicyType.SizeRelativeToParent; + _contentView3.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent; + //_contentView.Size2D = new Size2D(250, 250); + _contentView3.BackgroundImage = _resPath + "/images/background-blocks.jpg"; + + ImageVisual _icon3 = new ImageVisual(); + _icon3.URL = _resPath + "/images/application-icon-0.png"; + _icon3.DepthIndex = 1; + _icon3.Size = new Size2D(50, 50); + _icon3.SizePolicy = VisualTransformPolicyType.Absolute; + _icon3.Position = new Position2D(5, 5); + _icon3.PositionPolicy = VisualTransformPolicyType.Absolute; + _icon3.Origin = Visual.AlignType.TopBegin; + _icon3.AnchorPoint = Visual.AlignType.TopBegin; + _icon3.MixColor = new Color(0, 1, 0, 0.5f); + _icon3.Opacity = 0.5f; + _contentView3.AddVisual("icon_visual3", _icon3); + + contentLayout.AddChild(_contentView3, new TableView.CellPosition(2, 0)); + + _shadowButton3 = new PushButton(); + _shadowButton3.LabelText = "Toggle Transition MixColor"; + _shadowButton3.Name = ("ToggleTransition"); + _shadowButton3.ParentOrigin = ParentOrigin.Center; + _shadowButton3.PivotPoint = PivotPoint.Center; + _shadowButton3.Clicked += (obj, ev) => + { + _active3 = !_active3; + StartTransition(_contentView3, _icon3, "MixColor", _active3); + return true; + }; + _shadowButton3.WidthResizePolicy = ResizePolicyType.FillToParent; + _shadowButton3.HeightResizePolicy = ResizePolicyType.FillToParent; + contentLayout.AddChild(_shadowButton3, new TableView.CellPosition(2, 1)); + } + + private void StartTransition(VisualView view, VisualMap target, string property, bool activate) + { + if (_animation) + { + _animation.Stop(); + _animation.Finished += OnTransitionFinished; + } + + if (activate) + { + if (property == "Position") + { + _animation = view.AnimateVisual(target, property, new Position2D(20, 20), 0, 1000, AlphaFunction.BuiltinFunctions.Linear, new Position2D(40, 40)); + } + else if (property == "Opacity") + { + _animation = view.AnimateVisual(target, property, 0.0f, 0, 1000, AlphaFunction.BuiltinFunctions.Linear); + } + else if (property == "MixColor") + { + _animation = view.AnimateVisual(target, property, Color.Green, 0, 1000, AlphaFunction.BuiltinFunctions.Linear); + } + } + else + { + if (property == "Position") + { + _animation = view.AnimateVisual(target, property, new Position2D(5, 5), 0, 1000); + } + else if (property == "Opacity") + { + _animation = view.AnimateVisual(target, property, 1.0f, 0, 1000); + } + else if (property == "MixColor") + { + _animation = view.AnimateVisual(target, property, Color.Red, 0, 1000); + } + } + + if (_animation) + { + _animation.Finished += OnTransitionFinished; + _transitionInProgress = true; + _animation.Play(); + } + } + private void OnTransitionFinished(object sender, EventArgs e) + { + _transitionInProgress = false; + if (_animation) + { + _animation.Finished += OnTransitionFinished; + _animation.Reset(); + } + } + + + /// + /// The main entry point for the application. + /// + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + + + } +} diff --git a/test/NUITestSample/NUITestSample/examples/visual-animation-test3.cs b/test/NUITestSample/NUITestSample/examples/visual-animation-test3.cs new file mode 100755 index 000000000..f356c54a3 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/visual-animation-test3.cs @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; + +namespace VisaulAnimationExample +{ + class Example3 : NUIApplication + { + private VisualView _contentView1; + private VisualView _contentView2; + private VisualView _contentView3; + private TextLabel _title; + private PushButton _shadowButton1; + private PushButton _shadowButton2; + private PushButton _shadowButton3; + private bool _active1 = false; + private bool _active2 = false; + private bool _active3 = false; + //private const string _resPath = "/home/owner/apps_rw/NUISamples.TizenTV/res"; + private const string _resPath = "./res"; //for ubuntu + + private Animation _animation; + private ImageVisual _icon; + private ImageVisual _icon2; + private ImageVisual _icon3; + private ImageVisual _icon4; + private bool _transitionInProgress = false; + + public Example3() : base() + { + } + + public Example3(string stylesheet) : base(stylesheet) + { + } + + public Example3(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + TableView titleLayout = new TableView(2, 1); + titleLayout.Name = ("TitleLayout"); + titleLayout.PivotPoint = PivotPoint.TopLeft; + titleLayout.Position2D = new Position2D(10, 10); + titleLayout.Size2D = new Size2D((int)(window.Size.Width * 0.9f), (int)(window.Size.Height * 0.9f)); + titleLayout.SetCellPadding(new Size2D(10, 10)); + titleLayout.BackgroundColor = Color.Cyan; + window.Add(titleLayout); + + _title = new TextLabel("Visual Transition Example"); + _title.Name = ("Title"); + _title.SetStyleName("Title"); + _title.WidthResizePolicy = ResizePolicyType.FillToParent; + _title.HeightResizePolicy = ResizePolicyType.UseNaturalSize; + _title.HorizontalAlignment = HorizontalAlignment.Center; + titleLayout.AddChild(_title, new TableView.CellPosition(0, 0)); + titleLayout.SetFitHeight(0); + + TableView contentLayout = new TableView(2, 1); + contentLayout.Name = ("ContentLayout"); + contentLayout.WidthResizePolicy = ResizePolicyType.FillToParent; + contentLayout.HeightResizePolicy = ResizePolicyType.FillToParent; + contentLayout.PivotPoint = PivotPoint.TopLeft; + contentLayout.SetCellPadding(new Size2D(10, 10)); + contentLayout.BackgroundColor = Color.Magenta; + titleLayout.AddChild(contentLayout, new TableView.CellPosition(1, 0)); + + // make visual position animation + _contentView1 = new VisualView(); + _contentView1.WidthResizePolicy = ResizePolicyType.SizeRelativeToParent; + _contentView1.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent; + //_contentView.Size2D = new Size2D(250, 250); + _contentView1.BackgroundImage = _resPath + "/images/background-blocks.jpg"; + + _icon = new ImageVisual(); + _icon.URL = _resPath + "/images/application-icon-0.png"; + _icon.DepthIndex = 1; + _icon.Size = new Size2D(50, 50); + _icon.SizePolicy = VisualTransformPolicyType.Absolute; + _icon.Position = new Position2D(5, 5); + _icon.PositionPolicy = VisualTransformPolicyType.Absolute; + _icon.Origin = Visual.AlignType.TopBegin; + _icon.AnchorPoint = Visual.AlignType.TopBegin; + _icon.MixColor = new Color(0, 1, 0, 0.5f); + _icon.Opacity = 0.5f; + _contentView1.AddVisual("icon_visual1", _icon); + + _icon2 = new ImageVisual(); + _icon2.URL = _resPath + "/images/application-icon-0.png"; + _icon2.DepthIndex = 1; + _icon2.Size = new Size2D(50, 50); + _icon2.SizePolicy = VisualTransformPolicyType.Absolute; + _icon2.Position = new Position2D(200, 5); + _icon2.PositionPolicy = VisualTransformPolicyType.Absolute; + _icon2.Origin = Visual.AlignType.TopBegin; + _icon2.AnchorPoint = Visual.AlignType.TopBegin; + _icon2.MixColor = new Color(0, 1, 0, 0.5f); + _icon2.Opacity = 0.5f; + _contentView1.AddVisual("icon_visual2", _icon2); + + _icon3 = new ImageVisual(); + _icon3.URL = _resPath + "/images/application-icon-0.png"; + _icon3.DepthIndex = 1; + _icon3.Size = new Size2D(50, 50); + _icon3.SizePolicy = VisualTransformPolicyType.Absolute; + _icon3.Position = new Position2D(5, 200); + _icon3.PositionPolicy = VisualTransformPolicyType.Absolute; + _icon3.Origin = Visual.AlignType.TopBegin; + _icon3.AnchorPoint = Visual.AlignType.TopBegin; + _icon3.MixColor = new Color(0, 1, 0, 0.5f); + _icon3.Opacity = 0.5f; + _contentView1.AddVisual("icon_visual3", _icon3); + + _icon4 = new ImageVisual(); + _icon4.URL = _resPath + "/images/application-icon-0.png"; + _icon4.DepthIndex = 1; + _icon4.Size = new Size2D(50, 50); + _icon4.SizePolicy = VisualTransformPolicyType.Absolute; + _icon4.Position = new Position2D(200, 200); + _icon4.PositionPolicy = VisualTransformPolicyType.Absolute; + _icon4.Origin = Visual.AlignType.TopBegin; + _icon4.AnchorPoint = Visual.AlignType.TopBegin; + _icon4.MixColor = new Color(0, 1, 0, 0.5f); + _icon4.Opacity = 0.5f; + _contentView1.AddVisual("icon_visual4", _icon4); + + contentLayout.AddChild(_contentView1, new TableView.CellPosition(0, 0)); + + _shadowButton1 = new PushButton(); + _shadowButton1.LabelText = "Toggle Transition Position"; + _shadowButton1.Name = ("ToggleTransition"); + _shadowButton1.ParentOrigin = ParentOrigin.Center; + _shadowButton1.PivotPoint = PivotPoint.Center; + _shadowButton1.Clicked += (obj, ev) => + { + _active1 = !_active1; + StartTransition(_contentView1, _active1); + return true; + }; + _shadowButton1.WidthResizePolicy = ResizePolicyType.FillToParent; + _shadowButton1.HeightResizePolicy = ResizePolicyType.UseNaturalSize; + contentLayout.AddChild(_shadowButton1, new TableView.CellPosition(1, 0)); + contentLayout.SetFitHeight(1); + } + + private void StartTransition(VisualView view, bool activate) + { + if (_animation) + { + _animation.Stop(); + _animation.Finished += OnTransitionFinished; + } + + if (activate) + { + view.AnimateVisualAdd(_icon, "Position", new Position2D(80, 80), 0, 2000, AlphaFunction.BuiltinFunctions.Linear, new Position2D(5, 5)); + view.AnimateVisualAdd(_icon2, "Opacity", 0.0f, 0, 2000, AlphaFunction.BuiltinFunctions.Linear); + view.AnimateVisualAdd(_icon3, "MixColor", Color.Green, 0, 2000, AlphaFunction.BuiltinFunctions.Linear); + view.AnimateVisualAdd(_icon4, "Size", new Size2D(150, 150), 0, 2000, AlphaFunction.BuiltinFunctions.Linear); + _animation = view.AnimateVisualAddFinish(); + } + else + { + view.AnimateVisualAdd(_icon, "Position", new Position2D(5, 5), 0, 2000, AlphaFunction.BuiltinFunctions.Linear, new Position2D(80, 80)); + view.AnimateVisualAdd(_icon2, "Opacity", 1.0f, 0, 2000); + view.AnimateVisualAdd(_icon3, "MixColor", Color.Red, 0, 2000); + view.AnimateVisualAdd(_icon4, "Size", new Size2D(50, 50), 0, 2000, AlphaFunction.BuiltinFunctions.Linear); + _animation = view.AnimateVisualAddFinish(); + } + + if (_animation) + { + _animation.Finished += OnTransitionFinished; + _animation.EndAction = Animation.EndActions.StopFinal; + _transitionInProgress = true; + _animation.Play(); + } + } + + private void OnTransitionFinished(object sender, EventArgs e) + { + _transitionInProgress = false; + if (_animation) + { + _animation.Finished += OnTransitionFinished; + _animation.Reset(); + } + } + + /// + /// The main entry point for the application. + /// + [STAThread] + static void _Main(string[] args) + { + Example3 example = new Example3(); + example.Run(args); + } + + + } +} diff --git a/test/NUITestSample/NUITestSample/examples/visual-view-test.cs b/test/NUITestSample/NUITestSample/examples/visual-view-test.cs new file mode 100755 index 000000000..6c199d3ab --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/visual-view-test.cs @@ -0,0 +1,297 @@ +/* + * Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; + +namespace VisualViewTest +{ + // An example of Visual View control. + class Example : NUIApplication + { + private VisualView _visualView = null; + private const string resources = "/home/owner/apps_rw/NUISamples.TizenTV/res"; + private Window _window; + + public Example() : base() + { + } + + public Example(string stylesheet) : base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + private ImageVisual imageVisualMap1; + private TextVisual textVisualMap1; + private NPatchVisual npatchImageVisualMap1; + private BorderVisual borderVisualMap1; + private int cnt; + + public void Initialize() + { + Window window = Window.Instance; + + /* Create a visual view. */ + _visualView = new VisualView(); + _visualView.ParentOrigin = ParentOrigin.TopLeft; + _visualView.PivotPoint = PivotPoint.TopLeft; + _visualView.Size2D = new Size2D((int)window.Size.Width, (int)window.Size.Height); + + /* color visual */ + ColorVisual colorVisualMap1 = new ColorVisual(); + colorVisualMap1.Color = Color.Green; + _visualView.Background = colorVisualMap1.OutputVisualMap; + + window.Add(_visualView); + + /* image visual 1. */ + imageVisualMap1 = new ImageVisual(); + imageVisualMap1.URL = resources + "/images/image-1.jpg"; + imageVisualMap1.Size = new Vector2(200.0f, 200.0f); + imageVisualMap1.Position = new Vector2(10.0f, 10.0f); + imageVisualMap1.PositionPolicy = VisualTransformPolicyType.Absolute; + Console.WriteLine("PositionPolicy:{0}",imageVisualMap1.PositionPolicy); + imageVisualMap1.SizePolicy = VisualTransformPolicyType.Absolute; + Console.WriteLine("SizePolicy:{0}",imageVisualMap1.SizePolicy); + imageVisualMap1.Origin = Visual.AlignType.TopBegin; + imageVisualMap1.AnchorPoint = Visual.AlignType.TopBegin; + _visualView.AddVisual("imageVisual1", imageVisualMap1); + imageVisualMap1.URL = resources + "/images/image-3.jpg"; + + /* image visual 2. */ + ImageVisual imageVisualMap2 = new ImageVisual(); + imageVisualMap2.URL = resources + "/images/image-2.jpg"; + imageVisualMap2.Size = new Vector2(250.0f, 200.0f); + imageVisualMap2.Position = new Vector2(220.0f, 10.0f); + imageVisualMap2.PositionPolicy = VisualTransformPolicyType.Absolute; + imageVisualMap2.SizePolicy = VisualTransformPolicyType.Absolute; + imageVisualMap2.Origin = Visual.AlignType.TopBegin; + imageVisualMap2.AnchorPoint = Visual.AlignType.TopBegin; + _visualView.AddVisual("imageVisual2", imageVisualMap2); + + /* text visual. */ + textVisualMap1 = new TextVisual(); + textVisualMap1.Text = "Hello Goodbye"; + textVisualMap1.PointSize = 20.0f; + + textVisualMap1.Size = new Vector2(900.0f, 250.0f); + textVisualMap1.Position = new Vector2(10.0f, 220.0f); + textVisualMap1.PositionPolicy = VisualTransformPolicyType.Absolute; + textVisualMap1.SizePolicy = VisualTransformPolicyType.Absolute; + textVisualMap1.Origin = Visual.AlignType.TopBegin; + textVisualMap1.AnchorPoint = Visual.AlignType.TopBegin; + _visualView.AddVisual("textVisual1", textVisualMap1); + + /* border visual */ + borderVisualMap1 = new BorderVisual(); + borderVisualMap1.Color = Color.Red; + borderVisualMap1.BorderSize = 5.0f; + + borderVisualMap1.Size = new Vector2(100.0f, 100.0f); + borderVisualMap1.Position = new Vector2(10.0f, 380.0f); + borderVisualMap1.PositionPolicy = VisualTransformPolicyType.Absolute; + borderVisualMap1.SizePolicy = VisualTransformPolicyType.Absolute; + borderVisualMap1.Origin = Visual.AlignType.TopBegin; + borderVisualMap1.AnchorPoint = Visual.AlignType.TopBegin; + _visualView.AddVisual("borderVisual1", borderVisualMap1); + + /* gradient visual */ + GradientVisual gradientVisualMap1 = new GradientVisual(); + PropertyArray stopPosition = new PropertyArray(); + stopPosition.Add(new PropertyValue(0.0f)); + stopPosition.Add(new PropertyValue(0.3f)); + stopPosition.Add(new PropertyValue(0.6f)); + stopPosition.Add(new PropertyValue(0.8f)); + stopPosition.Add(new PropertyValue(1.0f)); + gradientVisualMap1.StopOffset = stopPosition; + PropertyArray stopColor = new PropertyArray(); + stopColor.Add(new PropertyValue(new Vector4(129.0f, 198.0f, 193.0f, 255.0f) / 255.0f)); + stopColor.Add(new PropertyValue(new Vector4(196.0f, 198.0f, 71.0f, 122.0f) / 255.0f)); + stopColor.Add(new PropertyValue(new Vector4(214.0f, 37.0f, 139.0f, 191.0f) / 255.0f)); + stopColor.Add(new PropertyValue(new Vector4(129.0f, 198.0f, 193.0f, 150.0f) / 255.0f)); + stopColor.Add(new PropertyValue(Color.Yellow)); + gradientVisualMap1.StopColor = stopColor; + gradientVisualMap1.StartPosition = new Vector2(0.5f, 0.5f); + gradientVisualMap1.EndPosition = new Vector2(-0.5f, -0.5f); + gradientVisualMap1.Center = new Vector2(0.5f, 0.5f); + gradientVisualMap1.Radius = 1.414f; + + gradientVisualMap1.Size = new Vector2(100.0f, 100.0f); + gradientVisualMap1.Position = new Vector2(120.0f, 380.0f); + gradientVisualMap1.PositionPolicy = VisualTransformPolicyType.Absolute; + gradientVisualMap1.SizePolicy = VisualTransformPolicyType.Absolute; + gradientVisualMap1.Origin = Visual.AlignType.TopBegin; + gradientVisualMap1.AnchorPoint = Visual.AlignType.TopBegin; + _visualView.AddVisual("gradientVisual1", gradientVisualMap1); + + /* primitive visual: Cone */ + PrimitiveVisual primitiveVisualMap1 = new PrimitiveVisual(); + primitiveVisualMap1.Shape = PrimitiveVisualShapeType.Cone; + primitiveVisualMap1.BevelPercentage = 0.3f; + primitiveVisualMap1.BevelSmoothness = 0.0f; + primitiveVisualMap1.ScaleDimensions = new Vector3(1.0f, 1.0f, 0.3f); + primitiveVisualMap1.MixColor = new Vector4((245.0f / 255.0f), (188.0f / 255.0f), (73.0f / 255.0f), 1.0f); + + primitiveVisualMap1.Size = new Vector2(100.0f, 100.0f); + primitiveVisualMap1.Position = new Vector2(230.0f, 380.0f); + primitiveVisualMap1.PositionPolicy = VisualTransformPolicyType.Absolute; + primitiveVisualMap1.SizePolicy = VisualTransformPolicyType.Absolute; + primitiveVisualMap1.Origin = Visual.AlignType.TopBegin; + primitiveVisualMap1.AnchorPoint = Visual.AlignType.TopBegin; + _visualView.AddVisual("primitiveVisual1", primitiveVisualMap1); + + /* primitive visual: Sphere */ + PrimitiveVisual primitiveVisualMap2 = new PrimitiveVisual(); + primitiveVisualMap2.Shape = PrimitiveVisualShapeType.Sphere; + primitiveVisualMap2.BevelPercentage = 0.3f; + primitiveVisualMap2.BevelSmoothness = 0.0f; + primitiveVisualMap2.ScaleDimensions = new Vector3(1.0f, 1.0f, 0.3f); + primitiveVisualMap2.MixColor = new Vector4((245.0f / 255.0f), (188.0f / 255.0f), (73.0f / 255.0f), 1.0f); + + primitiveVisualMap2.Size = new Vector2(100.0f, 100.0f); + primitiveVisualMap2.Position = new Vector2(340.0f, 380.0f); + primitiveVisualMap2.PositionPolicy = VisualTransformPolicyType.Absolute; + primitiveVisualMap2.SizePolicy = VisualTransformPolicyType.Absolute; + primitiveVisualMap2.Origin = Visual.AlignType.TopBegin; + primitiveVisualMap2.AnchorPoint = Visual.AlignType.TopBegin; + _visualView.AddVisual("primitiveVisual2", primitiveVisualMap2); + + /* primitive visual: Cylinder */ + PrimitiveVisual primitiveVisualMap3 = new PrimitiveVisual(); + primitiveVisualMap3.Shape = PrimitiveVisualShapeType.Cylinder; + primitiveVisualMap3.BevelPercentage = 0.3f; + primitiveVisualMap3.BevelSmoothness = 0.0f; + primitiveVisualMap3.ScaleDimensions = new Vector3(1.0f, 1.0f, 0.3f); + primitiveVisualMap3.MixColor = new Vector4((245.0f / 255.0f), (188.0f / 255.0f), (73.0f / 255.0f), 1.0f); + + primitiveVisualMap3.Size = new Vector2(100.0f, 100.0f); + primitiveVisualMap3.Position = new Vector2(10.0f, 490.0f); + primitiveVisualMap3.PositionPolicy = VisualTransformPolicyType.Absolute; + primitiveVisualMap3.SizePolicy = VisualTransformPolicyType.Absolute; + primitiveVisualMap3.Origin = Visual.AlignType.TopBegin; + primitiveVisualMap3.AnchorPoint = Visual.AlignType.TopBegin; + _visualView.AddVisual("primitiveVisual3", primitiveVisualMap3); + + /* primitive visual: ConicalFrustrum */ + PrimitiveVisual primitiveVisualMap4 = new PrimitiveVisual(); + primitiveVisualMap4.Shape = PrimitiveVisualShapeType.ConicalFrustrum; + primitiveVisualMap4.BevelPercentage = 0.3f; + primitiveVisualMap4.BevelSmoothness = 0.0f; + primitiveVisualMap4.ScaleDimensions = new Vector3(1.0f, 1.0f, 0.3f); + primitiveVisualMap4.MixColor = new Vector4((245.0f / 255.0f), (188.0f / 255.0f), (73.0f / 255.0f), 1.0f); + + primitiveVisualMap4.Size = new Vector2(100.0f, 100.0f); + primitiveVisualMap4.Position = new Vector2(120.0f, 490.0f); + primitiveVisualMap4.PositionPolicy = VisualTransformPolicyType.Absolute; + primitiveVisualMap4.SizePolicy = VisualTransformPolicyType.Absolute; + primitiveVisualMap4.Origin = Visual.AlignType.TopBegin; + primitiveVisualMap4.AnchorPoint = Visual.AlignType.TopBegin; + _visualView.AddVisual("primitiveVisual4", primitiveVisualMap4); + + /* primitive visual: Cube */ + PrimitiveVisual primitiveVisualMap5 = new PrimitiveVisual(); + primitiveVisualMap5.Shape = PrimitiveVisualShapeType.Cube; + primitiveVisualMap5.BevelPercentage = 0.3f; + primitiveVisualMap5.BevelSmoothness = 0.0f; + primitiveVisualMap5.ScaleDimensions = new Vector3(1.0f, 1.0f, 0.3f); + primitiveVisualMap5.MixColor = new Vector4((245.0f / 255.0f), (188.0f / 255.0f), (73.0f / 255.0f), 1.0f); + + primitiveVisualMap5.Size = new Vector2(100.0f, 100.0f); + primitiveVisualMap5.Position = new Vector2(230.0f, 490.0f); + primitiveVisualMap5.PositionPolicy = VisualTransformPolicyType.Absolute; + primitiveVisualMap5.SizePolicy = VisualTransformPolicyType.Absolute; + primitiveVisualMap5.Origin = Visual.AlignType.TopBegin; + primitiveVisualMap5.AnchorPoint = Visual.AlignType.TopBegin; + _visualView.AddVisual("primitiveVisual5", primitiveVisualMap5); + + /* mesh visual nothing show. */ + MeshVisual meshVisualMap1 = new MeshVisual(); + meshVisualMap1.ObjectURL = resources + "/models/Dino.obj"; + meshVisualMap1.MaterialtURL = resources + "/models/Dino.mtl"; + meshVisualMap1.TexturesPath = resources + "/images/"; + meshVisualMap1.ShadingMode = MeshVisualShadingModeValue.TexturedWithSpecularLighting; + + meshVisualMap1.Size = new Size2D(400, 400); + meshVisualMap1.Position = new Position2D(-50, 600); + meshVisualMap1.PositionPolicy = VisualTransformPolicyType.Absolute; + meshVisualMap1.SizePolicy = VisualTransformPolicyType.Absolute; + meshVisualMap1.Origin = Visual.AlignType.TopBegin; + meshVisualMap1.AnchorPoint = Visual.AlignType.TopBegin; + _visualView.AddVisual("meshVisual1", meshVisualMap1); + + /* n-patch image visual 1. */ + npatchImageVisualMap1 = new NPatchVisual(); + npatchImageVisualMap1.URL = resources + "/images/gallery-4.jpg"; + npatchImageVisualMap1.Size = new Size2D(400, 400); + npatchImageVisualMap1.Position = new Position2D(300, 600); + npatchImageVisualMap1.PositionPolicyX = VisualTransformPolicyType.Absolute; + npatchImageVisualMap1.PositionPolicyY = VisualTransformPolicyType.Absolute; + npatchImageVisualMap1.SizePolicyWidth = VisualTransformPolicyType.Absolute; + npatchImageVisualMap1.SizePolicyHeight = VisualTransformPolicyType.Absolute; + npatchImageVisualMap1.Origin = Visual.AlignType.TopBegin; + npatchImageVisualMap1.AnchorPoint = Visual.AlignType.TopBegin; + npatchImageVisualMap1.Border = new Rectangle(100, 100, 100, 100); + _visualView.AddVisual("npatchImageVisual1", npatchImageVisualMap1); + + _window = Window.Instance; + _window.FocusChanged += (sender, ee) => + { + cnt++; + Tizen.Log.Debug("NUI", "[WindowFocusTest] WindowFocusChanged event comes! focus gained=" + ee.FocusGained); + imageVisualMap1.Size += new Size2D(50, 50); + imageVisualMap1.Position += new Vector2(20.0f, 20.0f); + + textVisualMap1.Text = "Hello Goodbye" + cnt; + textVisualMap1.PointSize = 10.0f + (float)(cnt); + + npatchImageVisualMap1.URL = resources + "/images/gallery-" + (cnt % 5) + ".jpg"; + + borderVisualMap1.BorderSize = 1.0f + (float)cnt; + }; + + Tizen.Log.Debug("NUI", "[WindowFocusTest] is focus acceptable=" + _window.IsFocusAcceptable()); + _window.SetAcceptFocus(false); + Tizen.Log.Debug("NUI", "[WindowFocusTest] set focus acceptable=false!!!"); + Tizen.Log.Debug("NUI", "[WindowFocusTest] is focus acceptable=" + _window.IsFocusAcceptable()); + _window.SetAcceptFocus(true); + Tizen.Log.Debug("NUI", "[WindowFocusTest] set focus acceptable=true!!!"); + Tizen.Log.Debug("NUI", "[WindowFocusTest] is focus acceptable=" + _window.IsFocusAcceptable()); + + + } + + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} \ No newline at end of file diff --git a/test/NUITestSample/NUITestSample/examples/visual-view-test2.cs b/test/NUITestSample/NUITestSample/examples/visual-view-test2.cs new file mode 100755 index 000000000..659e9ba0b --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/visual-view-test2.cs @@ -0,0 +1,289 @@ +using System; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; + +namespace VisualViewTest2 +{ + public class VisualSample : NUIApplication + { + const int num = 2; + VisualView[] view; + + TextLabel guide; + ImageVisual imageMap; + ImageVisual imageMap2; + + ImageVisual highlightImageMap; + ImageVisual dimImageMap; + + TextVisual textMap1; + TextVisual textMap2; + + Window _window; + + int imgIndex; + + readonly string resourcePath = "/home/owner/apps_rw/NUISamples.TizenTV/res/images/"; + + protected override void OnCreate() + { + base.OnCreate(); + + view = new VisualView[2]; + + for (int i = 0; i < num; i++) + { + view[i] = new VisualView(); + view[i].Size2D = new Size2D(600, 600); + view[i].BackgroundColor = Color.Blue; + view[i].Position = new Position(400 + i * 800, 600, 0); + view[i].Focusable = true; + view[i].Name = "MyView" + i; + Window.Instance.Add(view[i]); + view[i].FocusGained += VisualSample_FocusGained; + view[i].FocusLost += VisualSample_FocusLost; + view[i].KeyEvent += VisualSample_KeyEvent; + } + + view[0].RightFocusableView = view[1]; + view[1].LeftFocusableView = view[0]; + + imageMap = new ImageVisual(); + imageMap.URL = resourcePath + "gallery-" + imgIndex++ + ".jpg"; + imageMap.AnchorPoint = Visual.AlignType.TopBegin; + imageMap.Origin = Visual.AlignType.TopBegin; + imageMap.Position = new Vector2(0, 0); + imageMap.PositionPolicy = VisualTransformPolicyType.Absolute; + imageMap.Size = new Size2D(500, 500); + imageMap.SizePolicy = VisualTransformPolicyType.Absolute; + imageMap.DepthIndex = 0; + view[0].AddVisual("bgVisual", imageMap); + + + highlightImageMap = new ImageVisual(); + highlightImageMap.URL = resourcePath + "star-highlight.png"; + highlightImageMap.AnchorPoint = Visual.AlignType.TopBegin; + highlightImageMap.Origin = Visual.AlignType.TopBegin; + highlightImageMap.Size = new Vector2(40, 40); + highlightImageMap.SizePolicy = VisualTransformPolicyType.Absolute; + highlightImageMap.Position = new Vector2(10, 10); + highlightImageMap.PositionPolicy = VisualTransformPolicyType.Absolute; + highlightImageMap.DepthIndex = 1; + view[0].AddVisual("iconVisual", highlightImageMap); + + + textMap1 = new TextVisual(); + textMap1.Text = "Hello"; + textMap1.AnchorPoint = Visual.AlignType.TopBegin; + textMap1.Origin = Visual.AlignType.TopBegin; + textMap1.PointSize = 20; + textMap1.Position = new Vector2(60, 210); + textMap1.PositionPolicy = VisualTransformPolicyType.Absolute; + textMap1.Size = new Vector2(600, 200); + textMap1.SizePolicy = VisualTransformPolicyType.Absolute; + textMap1.TextColor = Color.Red; + textMap1.DepthIndex = 5; + view[0].AddVisual("textVisual", textMap1); + + + + imageMap2 = new ImageVisual(); + imageMap2.URL = resourcePath + "gallery-" + imgIndex + ".jpg"; + imageMap2.AnchorPoint = Visual.AlignType.TopBegin; + imageMap2.Origin = Visual.AlignType.TopBegin; + imageMap2.Position = new Vector2(0, 0); + imageMap2.PositionPolicy = VisualTransformPolicyType.Absolute; + imageMap2.Size = new Vector2(500, 500); + imageMap2.SizePolicy = VisualTransformPolicyType.Absolute; + imageMap2.DepthIndex = 0; + view[1].AddVisual("bgVisual", imageMap2); + + dimImageMap = new ImageVisual(); + dimImageMap.URL = resourcePath + "star-dim.png"; + dimImageMap.Size = new Vector2(40, 40); + dimImageMap.SizePolicy = VisualTransformPolicyType.Absolute; + dimImageMap.AnchorPoint = Visual.AlignType.TopBegin; + dimImageMap.Origin = Visual.AlignType.TopBegin; + dimImageMap.Position = new Vector2(10, 10); + dimImageMap.PositionPolicy = VisualTransformPolicyType.Absolute; + dimImageMap.DepthIndex = 1; + view[1].AddVisual("iconVisual", dimImageMap); + + textMap2 = new TextVisual(); + textMap2.Text = "I'm"; + textMap2.PointSize = 20; + textMap2.AnchorPoint = Visual.AlignType.TopBegin; + textMap2.Origin = Visual.AlignType.TopBegin; + textMap2.Position = new Vector2(60, 210); + textMap2.PositionPolicy = VisualTransformPolicyType.Absolute; + textMap2.Size = new Vector2(600, 200); + textMap2.SizePolicy = VisualTransformPolicyType.Absolute; + textMap2.TextColor = Color.Black; + textMap2.DepthIndex = 5; + view[1].AddVisual("textVisual", textMap2); + + + guide = new TextLabel(); + guide.PivotPoint = PivotPoint.TopLeft; + guide.Size2D = new Size2D(800, 200); + guide.Padding = new Vector4(50, 50, 50, 50); + guide.MultiLine = true; + guide.BackgroundColor = Color.Magenta; + guide.PointSize = 10; + guide.TextColor = Color.Black; + guide.Text = "Left/Right - Move focus\n" + + "Up/Down - Change Text\n" + + "Enter - Change BG image\n"; + Window.Instance.Add(guide); + + Window.Instance.KeyEvent += Instance_Key; + FocusManager.Instance.SetCurrentFocusView(view[0]); + Window.Instance.TouchEvent += Instance_Touch; + _window = Window.Instance; + _window.FocusChanged += _window_WindowFocusChanged; + + } + + private void _window_WindowFocusChanged(object sender, Window.FocusChangedEventArgs e) + { + Tizen.Log.Fatal("NUI", "window focus changed!() focus gained=" + e.FocusGained); + } + + private void Instance_Touch(object sender, Window.TouchEventArgs e) + { + FocusManager.Instance.SetCurrentFocusView(view[0]); + } + + private bool VisualSample_KeyEvent(object source, View.KeyEventArgs e) + { + Tizen.Log.Fatal("NUI", "View_KeyEvent" + e.Key.State.ToString() + ", Pressed-" + e.Key.KeyPressedName); + + if (e.Key.State == Key.StateType.Down) + { + if (source.Equals(view[0])) + { + if (e.Key.KeyPressedName == "Up") + { + textMap1.PointSize = 14; + textMap1.TextColor = Color.Red; + textMap1.Text = "Hello NY!"; + //this.VersionCheckTest(); + /* + DALI_KEY_VOLUME_UP = 200, ///< Volume up key @SINCE_1_0.0 + DALI_KEY_VOLUME_DOWN = 201, ///< Volume down key @SINCE_1_0.0 + */ + try + { + Tizen.Log.Fatal("NUI", "GrabKeyTopmost (200==vol up) ret=" + _window.GrabKeyTopmost(200)); + } + catch (Exception except) + { + Tizen.Log.Fatal("NUI", "Exception!!! GrabKeyTopmost (200==vol up) msg=" + except.Message); + } + + } + else if (e.Key.KeyPressedName == "Down") + { + textMap1.PointSize = 17; + textMap1.TextColor = Color.Blue; + textMap1.Text = "Goodbye NY."; + + Tizen.Log.Fatal("NUI", "UngrabKeyTopmost (200==vol up) ret=" + _window.UngrabKeyTopmost(200)); + + } + else if (e.Key.KeyPressedName == "Return") + { + imgIndex = (imgIndex + 1) % 6; + imageMap.URL = resourcePath + "gallery-" + imgIndex + ".jpg"; + //Tizen.Log.Fatal("NUI", "get native ecore wayland hander=" + _window.GetNativeWindowHandler()); + } + + } + else + { + if (e.Key.KeyPressedName == "Up") + { + textMap2.PointSize = 14; + textMap2.TextColor = Color.Red; + textMap2.Text = "I'm happy!"; + Tizen.Log.Fatal("NUI", "grab key (201==vol down) ret=" + _window.GrabKey(201, Window.KeyGrabMode.Topmost)); + } + + if (e.Key.KeyPressedName == "Down") + { + textMap2.PointSize = 17; + textMap2.TextColor = Color.Blue; + textMap2.Text = "I'm unhappy"; + Tizen.Log.Fatal("NUI", "ungrab key (201==vol down) ret=" + _window.UngrabKey(201)); + } + else if (e.Key.KeyPressedName == "Return") + { + imgIndex = (imgIndex + 1) % 6; + imageMap2.URL = resourcePath + "gallery-" + imgIndex + ".jpg"; + //Tizen.Log.Fatal("NUI", "get native ecore wayland hander=" + _window.GetNativeWindowHandler()); + } + } + } + return false; + } + + private void Instance_Key(object sender, Window.KeyEventArgs e) + { + View currentFocusView = FocusManager.Instance.GetCurrentFocusView(); + + Tizen.Log.Fatal("NUI", "Window_KeyEvent" + e.Key.State.ToString() + ", Pressed-" + e.Key.KeyPressedName); + //Tizen.Log.Fatal("NUI", " CurrentFocusView : " + currentFocusView.HasBody() + currentFocusView?.Name); + } + + private void VisualSample_FocusLost(object sender, EventArgs e) + { + VisualView view = sender as VisualView; + view.BackgroundColor = Color.Green; + view.Scale = new Vector3(1.0f, 1.0f, 1.0f); + + view.AddVisual("iconVisual", dimImageMap); + + if (view.Name == "MyView1") + { + imageMap2.MixColor = new Color(1, 0, 0, 0.5f); + imageMap2.Opacity = 0.5f; + } + else if (view.Name == "MyView0") + { + imageMap.MixColor = new Color(1, 0, 0, 0.5f); + imageMap.Opacity = 0.5f; + } + + Tizen.Log.Fatal("NUI", "FocusLost-" + view.Name); + } + + private void VisualSample_FocusGained(object sender, EventArgs e) + { + VisualView view = sender as VisualView; + view.BackgroundColor = Color.Yellow; + view.Scale = new Vector3(1.2f, 1.2f, 1.0f); + + view.AddVisual("iconVisual", highlightImageMap); + + if (view.Name == "MyView1") + { + imageMap2.MixColor = new Color(1, 1, 1, 1); + imageMap2.Opacity = 1.0f; + } + else if (view.Name == "MyView0") + { + imageMap.MixColor = new Color(1, 1, 1, 1); + imageMap.Opacity = 1.0f; + } + + Tizen.Log.Fatal("NUI", "FocusGained-" + view.Name); + } + + static void _Main(string[] args) + { + VisualSample sample = new VisualSample(); + sample.Run(args); + } + } +} \ No newline at end of file diff --git a/test/NUITestSample/NUITestSample/examples/visual-view-test3.cs b/test/NUITestSample/NUITestSample/examples/visual-view-test3.cs new file mode 100755 index 000000000..ea9205ab2 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/visual-view-test3.cs @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2017 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.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.Constants; +using Tizen.NUI.BaseComponents; + +namespace VisualViewTest3 +{ + // An example of Visual View control. + class Example : NUIApplication + { + private VisualView _visualView = null; + private const string resources = "/home/owner/apps_rw/NUISamples.TizenTV/res"; + private Window _window; + + public Example() : base() + { + } + + public Example(string stylesheet) : base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + private ImageVisual imageVisualMap1; + private ImageVisual imageVisualMap2; + private int cnt; + + public void Initialize() + { + Window window = Window.Instance; + + /* Create a visual view. */ + _visualView = new VisualView(); + _visualView.ParentOrigin = ParentOrigin.TopLeft; + _visualView.PivotPoint = PivotPoint.TopLeft; + _visualView.Size2D = new Size2D(window.Size.Width, window.Size.Height); + + /* color visual */ + ColorVisual colorVisualMap1 = new ColorVisual(); + colorVisualMap1.Color = Color.Green; + _visualView.Background = colorVisualMap1.OutputVisualMap; + + window.Add(_visualView); + + /* image visual 1. No transform setting case. */ + imageVisualMap1 = new ImageVisual(); + imageVisualMap1.URL = resources + "/images/image-1.jpg"; + imageVisualMap1.DepthIndex = 1; + //_visualView.AddVisual("imageVisual1", imageVisualMap1); + + /* image visual 2. Using RelativePosition and SizePolicyWidth setting case. */ + imageVisualMap2 = new ImageVisual(); + imageVisualMap2.URL = resources + "/images/image-2.jpg"; + /* Using Size, you can set SizePolicyWidth and SizePolicyHeight separately, default by relative. */ + imageVisualMap2.Size = new Vector2(400.0f, 0.3f); + /* Using RelativePosition, then PositionPolicyX and PositionPolicyY will be relative. */ + imageVisualMap2.RelativePosition = new Vector2(0.1f, 0.1f); + imageVisualMap2.SizePolicyWidth = VisualTransformPolicyType.Absolute; + imageVisualMap2.Origin = Visual.AlignType.TopBegin; + imageVisualMap2.AnchorPoint = Visual.AlignType.TopBegin; + /* Ensure imageVisual show */ + imageVisualMap2.DepthIndex = 9; + _visualView.AddVisual("imageVisual2", imageVisualMap2); + /* If imageVisual2 added first, the it will be covered by imageVisual1. + so, we need to set their depth index to ensure they all can be showed. + */ + _visualView.AddVisual("imageVisual1", imageVisualMap1); + + _window = Window.Instance; + _window.FocusChanged += (sender, ee) => + { + cnt++; + Tizen.Log.Debug("NUI", "[WindowFocusTest] WindowFocusChanged event comes! focus gained=" + ee.FocusGained); + }; + + Tizen.Log.Debug("NUI", "[WindowFocusTest] is focus acceptable=" + _window.IsFocusAcceptable()); + _window.SetAcceptFocus(false); + Tizen.Log.Debug("NUI", "[WindowFocusTest] set focus acceptable=false!!!"); + Tizen.Log.Debug("NUI", "[WindowFocusTest] is focus acceptable=" + _window.IsFocusAcceptable()); + _window.SetAcceptFocus(true); + Tizen.Log.Debug("NUI", "[WindowFocusTest] set focus acceptable=true!!!"); + Tizen.Log.Debug("NUI", "[WindowFocusTest] is focus acceptable=" + _window.IsFocusAcceptable()); + } + + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/visuals-example.cs b/test/NUITestSample/NUITestSample/examples/visuals-example.cs new file mode 100755 index 000000000..8c0a724ba --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/visuals-example.cs @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2017 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.Constants; +using Tizen.NUI.BaseComponents; + +namespace VisualsExampleTest +{ + class Example : NUIApplication + { + private TextLabel _title; + private const string resources = "/home/owner/apps_rw/NUISamples.TizenTV/res"; + + public Example() : base() + { + } + + public Example(string stylesheet) : base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + TableView contentLayout = new TableView(4, 1); + contentLayout.Name = ("ContentLayout"); + contentLayout.WidthResizePolicy = ResizePolicyType.FillToParent; + contentLayout.HeightResizePolicy = ResizePolicyType.FillToParent; + + contentLayout.SetCellPadding(new Size2D(0, 5)); + contentLayout.BackgroundColor = Color.Red;//new Color(0.949f, 0.949f, 0.949f, 1.0f); + + window.Add(contentLayout); + + _title = new TextLabel("Visuals Example"); + _title.Name = "Title"; + _title.StyleName = "Title"; + _title.WidthResizePolicy = ResizePolicyType.FillToParent; + _title.HeightResizePolicy = ResizePolicyType.UseNaturalSize; + _title.HorizontalAlignment = HorizontalAlignment.Center; + _title.BackgroundColor = Color.Yellow; + contentLayout.Add(_title); + contentLayout.SetFitHeight(0); + + // Color Visual example + ImageView colorView = new ImageView(); + //colorView.WidthResizePolicy = ResizePolicyType.SizeRelativeToParent; + //colorView.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent; + // PropertyMap colorVisual = new PropertyMap(); + // colorVisual.Add( Visual.Property.Type, new PropertyValue( (int)Visual.Type.Color )) + // .Add( ColorVisualProperty.MixColor, new PropertyValue( Color.Green )); + //colorView.Background = colorVisual; + colorView.Size2D = new Size2D(500, 200); + colorView.ResourceUrl = resources+"/images/00_popup_bg.9.png"; + colorView.Border = new Rectangle(100, 100, 100, 100); + // colorView. + // PropertyMap _map = new PropertyMap(); + // _map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch)); + // _map.Add(NpatchImageVisualProperty.URL, new PropertyValue(resources+"/images/00_popup_bg.9.png")); + // _map.Add(NpatchImageVisualProperty.Border, new PropertyValue(new Rectangle(100, 100, 100, 100))); + //_map.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue(true)); + //colorView.Background = _map; + contentLayout.Add(colorView); + + // Image Visual example + View imageView = new View(); + imageView.WidthResizePolicy = ResizePolicyType.UseNaturalSize; + imageView.HeightResizePolicy = ResizePolicyType.UseNaturalSize; + PropertyMap imageVisual = new PropertyMap(); + imageVisual.Add( Visual.Property.Type, new PropertyValue( (int)Visual.Type.Image )); + imageVisual.Add(ImageVisualProperty.URL, new PropertyValue( resources + "/images/gallery-0.jpg" )); + imageView.Background = imageVisual; + contentLayout.SetCellAlignment(new TableView.CellPosition(2, 0), HorizontalAlignmentType.Center, VerticalAlignmentType.Center); + contentLayout.Add(imageView); + for(int i =1; i<=5; i++) + { + PropertyMap imageVisual1 = new PropertyMap(); + imageVisual1.Add( Visual.Property.Type, new PropertyValue( (int)Visual.Type.Image )); + imageVisual1.Add(ImageVisualProperty.URL, new PropertyValue( resources + "/images/gallery-"+i+".jpg" )); + imageView.Background = imageVisual1; + } + + // Primitive Visual example + View primitiveView = new View(); + primitiveView.WidthResizePolicy = ResizePolicyType.SizeRelativeToParent; + primitiveView.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent; + PropertyMap primitiveVisual = new PropertyMap(); + primitiveVisual.Add( Visual.Property.Type, new PropertyValue( (int)Visual.Type.Primitive )) + .Add( PrimitiveVisualProperty.Shape, new PropertyValue((int)PrimitiveVisualShapeType.BevelledCube)) + .Add( PrimitiveVisualProperty.BevelPercentage, new PropertyValue(0.3f)) + .Add( PrimitiveVisualProperty.BevelSmoothness, new PropertyValue(0.0f)) + .Add( PrimitiveVisualProperty.ScaleDimensions, new PropertyValue(new Vector3(1.0f,1.0f,0.3f))) + .Add( PrimitiveVisualProperty.MixColor, new PropertyValue(new Vector4(0.7f, 0.5f, 0.05f, 1.0f))); + primitiveView.Background = primitiveVisual; + Radian rad = new Radian(new Degree(45.0f)); + primitiveView.Orientation = new Rotation(rad, Vector3.YAxis); + contentLayout.Add(primitiveView); + + // Text Visual example + View textView = new View(); + textView.WidthResizePolicy = ResizePolicyType.SizeRelativeToParent; + textView.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent; + PropertyMap textVisual = new PropertyMap(); + textVisual.Add( Visual.Property.Type, new PropertyValue( (int)Visual.Type.Text )) + .Add( TextVisualProperty.Text, new PropertyValue("I am text visual")) + .Add( TextVisualProperty.TextColor, new PropertyValue(Color.Blue)) + .Add( TextVisualProperty.PointSize, new PropertyValue(20)); + textView.Background = textVisual; + contentLayout.Add(textView); + } + + /// + /// The main entry point for the application. + /// + [STAThread] + static void _Main(string[] args) + { + Example example = new Example( resources + "/json/style-example-theme-one.json"); + example.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/visuals-using-custom-view/ContactData.cs b/test/NUITestSample/NUITestSample/examples/visuals-using-custom-view/ContactData.cs new file mode 100755 index 000000000..9a3b9a8c9 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/visuals-using-custom-view/ContactData.cs @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2017 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.Constants; + +namespace VisualsUsingCustomView +{ + // The collection of contacts + static class ContactsList + { + private const string resources = "/home/SERILOCAL/david.steele/Git/Tizen/nui/NUISamples/NUISamples/NUISamples.TizenTV/res"; + + public static readonly ContactItem[] s_contactData = new ContactItem[] + { + new ContactItem ("Emmett Yates", resources + "/images/gallery-small-43.jpg", + resources + "/images/mask.png", + new Color((73.0f/255.0f),(182.0f/255.0f), (245.0f/255.0f), 1.0f), + (int)PrimitiveVisualShapeType.Cone), + new ContactItem ("Leslie Wong", resources+ "/images/gallery-2.jpg", + resources + "/images/mask.png", + new Color((51.0f/255.0f), (51.0f/255.0f), (102.0f/255.0f), 1.0f), + (int)PrimitiveVisualShapeType.Sphere), + new ContactItem ("Walter Jensen", resources+ "/images/gallery-0.jpg", + resources + "/images/mask.png", + new Color((151.0f/255.0f), (214.0f/255.0f), (240.0f/255.0f), 1.0f), + (int)PrimitiveVisualShapeType.Cylinder), + new ContactItem ("Dan Haynes", resources+"/images/gallery-1.jpg", + resources + "/images/mask.png", + new Color((102.0f/255.0f), (251.0f/255.0f), (102.0f/255.0f), 1.0f), + (int)PrimitiveVisualShapeType.ConicalFrustrum), + new ContactItem ("Mable Hodges", resources+"/images/gallery-3.jpg", + resources + "/images/mask.png", + new Color((255.0f/255.0f), (102.0f/255.0f), (102.0f/255.0f), 1.0f), + (int)PrimitiveVisualShapeType.Cube) + }; + } + + // The information for an individual contact + class ContactItem + { + private string _name; + private string _imageURL; + private Color _color; + private int _shape; + private string _maskURL; + + public ContactItem(string name, string imageURL, string maskURL, Color color, int shape) + { + _name = name; + _imageURL = imageURL; + _maskURL = maskURL; + _color = color; + _shape = shape; + } + + public string ImageURL + { + get + { + return _imageURL; + } + set + { + _imageURL = value; + } + } + public string MaskURL + { + get + { + return _maskURL; + } + set + { + _maskURL = value; + } + } + + public string Name + { + get + { + return _name; + } + set + { + _name = value; + } + } + + public Color Color + { + get + { + return _color; + } + set + { + _color = value; + } + } + + public int Shape + { + get + { + return _shape; + } + set + { + _shape = value; + } + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/visuals-using-custom-view/ContactView.cs b/test/NUITestSample/NUITestSample/examples/visuals-using-custom-view/ContactView.cs new file mode 100755 index 000000000..52995a74f --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/visuals-using-custom-view/ContactView.cs @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2017 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.Constants; +using Tizen.NUI.BaseComponents; + +// A ContactView is a Custom View which consists of four visuals (Image, Primitive, Text and Color). +// All of these visuals can be configured via properties - ImageURL (Image), Shape (Primitive), Name (Text) and Color. +// Tap gesture is also enabled on the ContactView which changes the color visual to some random color when ContactView is tapped. + +namespace VisualsUsingCustomView +{ + public class ContactView : CustomView + { + private VisualBase _imageVisual; + private VisualBase _primitiveVisual; + private VisualBase _textVisual; + private int _shape; + private string _imageURL; + private string _maskURL; + private string _name; + private Color _color; + + static CustomView CreateInstance() + { + return new ContactView(); + } + + static ContactView() + { + CustomViewRegistry.Instance.Register( CreateInstance, typeof(ContactView)); + } + + public ContactView() : base( typeof(ContactView).FullName, CustomViewBehaviour.RequiresKeyboardNavigationSupport) + { + } + + public string MaskURL + { + get { return _maskURL; } + set { _maskURL=value; } + } + + [ScriptableProperty()] + public string ImageURL + { + get + { + return _imageURL; + } + set + { + _imageURL = value; + + ImageVisual imageVisual = new ImageVisual(); + imageVisual.URL = value; + imageVisual.AlphaMaskURL = _maskURL; + //imageVisual.MaskContentScale = 1.6f; + //imageVisual.CropToMask = true; + ImageVisual = imageVisual.OutputVisualMap; + } + } + + [ScriptableProperty()] + public PropertyMap ImageVisual + { + //get + //{ + // return _imageVisual.Creation; + //} + set + { + _imageVisual = VisualFactory.Instance.CreateVisual( value ); + RegisterVisual( GetPropertyIndex("ImageVisual"), _imageVisual ); + + // Set the depth index for Image visual + _imageVisual.DepthIndex = 30; + } + } + + [ScriptableProperty()] + public string NameField + { + get + { + return _name; + } + set + { + _name = value; + + // Create and Register Text Visual + TextVisual textVisual = new TextVisual(); + textVisual.Text = _name; + textVisual.TextColor = Color.Black; + textVisual.PointSize = 12; + textVisual.HorizontalAlignment = HorizontalAlignment.Center; + textVisual.VerticalAlignment = VerticalAlignment.Center; + NameVisual = textVisual.OutputVisualMap; + } + } + + [ScriptableProperty()] + public PropertyMap NameVisual + { + //get + //{ + // return _textVisual.Creation; + //} + set + { + _textVisual = VisualFactory.Instance.CreateVisual( value ); + RegisterVisual( GetPropertyIndex("NameVisual"), _textVisual ); + + // Set the depth index for Text visual + _textVisual.DepthIndex = 30; + } + } + + [ScriptableProperty()] + public Color Color + { + get + { + return _color; + } + set + { + _color = value; + BackgroundColor = value; + } + } + + [ScriptableProperty()] + public int Shape + { + get + { + return _shape; + } + set + { + _shape = value; + + // Create and Register Primitive Visual + var primitiveVisual = new PrimitiveVisual(); + primitiveVisual.Shape = (PrimitiveVisualShapeType)_shape; + primitiveVisual.BevelPercentage = 0.3f; + primitiveVisual.BevelSmoothness = 0.0f; + primitiveVisual.ScaleDimensions = new Vector3( 1.0f, 1.0f, 0.3f ); + primitiveVisual.MixColor = new Vector4( (245.0f/255.0f), (188.0f/255.0f), (73.0f/255.0f), 1.0f); + + ShapeVisual = primitiveVisual.OutputVisualMap; + } + } + + [ScriptableProperty()] + public PropertyMap ShapeVisual + { + //get + //{ + // return _primitiveVisual.Creation; + //} + set + { + _primitiveVisual = VisualFactory.Instance.CreateVisual( value ); + RegisterVisual( GetPropertyIndex("ShapeVisual"), _primitiveVisual ); + + // Set the depth index for Primitive visual + _primitiveVisual.DepthIndex = 30; + } + } + + public override void OnInitialize() + { + // Enable Tap gesture on ContactView + EnableGestureDetection(Gesture.GestureType.Tap); + } + + public override void OnTap(TapGesture tap) + { + // Change the Color visual of ContactView with some random color + Random random = new Random(); + float nextRed = (random.Next(0, 256) / 255.0f); + float nextGreen = (random.Next(0, 256) / 255.0f); + float nextBlue = (random.Next(0, 256) / 255.0f); + Animation anim = AnimateBackgroundColor( new Color( nextRed, nextGreen, nextBlue, 1.0f), 0, 2000 ); + if( anim ) + anim.Play(); + } + + public override void OnRelayout(Vector2 size, RelayoutContainer container) + { + // Configure the transform and size of Image visual. + PropertyMap imageVisualTransform = new PropertyMap(); + imageVisualTransform.Add((int)VisualTransformPropertyType.Offset, new PropertyValue(new Vector2(10.0f, 0.0f))) + .Add((int)VisualTransformPropertyType.OffsetPolicy, new PropertyValue(new Vector2((int)VisualTransformPolicyType.Absolute, (int)VisualTransformPolicyType.Absolute))) + .Add((int)VisualTransformPropertyType.SizePolicy, new PropertyValue(new Vector2((int)VisualTransformPolicyType.Absolute, (int)VisualTransformPolicyType.Absolute))) + .Add((int)VisualTransformPropertyType.Size, new PropertyValue(new Vector2(40.0f, 40.0f))) + .Add((int)VisualTransformPropertyType.Origin, new PropertyValue((int)Visual.AlignType.CenterBegin)) + .Add((int)VisualTransformPropertyType.AnchorPoint, new PropertyValue((int)Visual.AlignType.CenterBegin)); + _imageVisual.SetTransformAndSize(imageVisualTransform, size); + + // Configure the transform and size of Text visual. + PropertyMap textVisualTransform = new PropertyMap(); + textVisualTransform.Add((int)VisualTransformPropertyType.Offset, new PropertyValue(new Vector2(0.0f, 0.0f))) + .Add((int)VisualTransformPropertyType.OffsetPolicy, new PropertyValue(new Vector2((int)VisualTransformPolicyType.Relative, (int)VisualTransformPolicyType.Relative))) + .Add((int)VisualTransformPropertyType.SizePolicy, new PropertyValue(new Vector2((int)VisualTransformPolicyType.Absolute, (int)VisualTransformPolicyType.Absolute))) + .Add((int)VisualTransformPropertyType.Size, new PropertyValue(new Vector2(size.X - 100.0f, 50.0f))) + .Add((int)VisualTransformPropertyType.Origin, new PropertyValue((int)Visual.AlignType.Center)) + .Add((int)VisualTransformPropertyType.AnchorPoint, new PropertyValue((int)Visual.AlignType.Center)); + _textVisual.SetTransformAndSize(textVisualTransform, size); + + // Configure the transform and size of Primitive visual. + PropertyMap primitiveVisualTransform = new PropertyMap(); + primitiveVisualTransform.Add((int)VisualTransformPropertyType.Offset, new PropertyValue(new Vector2(size.X - 60.0f, 0.0f))) + .Add((int)VisualTransformPropertyType.OffsetPolicy, new PropertyValue(new Vector2((int)VisualTransformPolicyType.Absolute, (int)VisualTransformPolicyType.Absolute))) + .Add((int)VisualTransformPropertyType.SizePolicy, new PropertyValue(new Vector2((int)VisualTransformPolicyType.Absolute, (int)VisualTransformPolicyType.Absolute))) + .Add((int)VisualTransformPropertyType.Size, new PropertyValue(new Vector2(40.0f, 40.0f))) + .Add((int)VisualTransformPropertyType.Origin, new PropertyValue((int)Visual.AlignType.CenterBegin)) + .Add((int)VisualTransformPropertyType.AnchorPoint, new PropertyValue((int)Visual.AlignType.CenterBegin)); + _primitiveVisual.SetTransformAndSize(primitiveVisualTransform, size); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/visuals-using-custom-view/visuals-using-custom-view.cs b/test/NUITestSample/NUITestSample/examples/visuals-using-custom-view/visuals-using-custom-view.cs new file mode 100755 index 000000000..be327fe06 --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/visuals-using-custom-view/visuals-using-custom-view.cs @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2017 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.UIComponents; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; + +namespace VisualsUsingCustomView +{ + class VisualsExample : NUIApplication + { + public VisualsExample() : base() + { + } + + public VisualsExample(string stylesheet) : base(stylesheet) + { + } + + public VisualsExample(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + private void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + TableView contentLayout = new TableView(14, 1); + contentLayout.Name = "ContentLayout"; + //contentLayout.WidthResizePolicy = ResizePolicyType.FillToParent; + //contentLayout.HeightResizePolicy = ResizePolicyType.FillToParent; + contentLayout.PivotPoint = PivotPoint.TopLeft; + contentLayout.ParentOrigin = ParentOrigin.TopLeft; + contentLayout.Size2D = new Vector2(window.Size.Width, window.Size.Height); + contentLayout.SetCellPadding(new Size2D(5, 5)); + contentLayout.BackgroundColor = new Color(0.949f, 0.949f, 0.949f, 1.0f); + + window.Add(contentLayout); + + TextLabel title = new TextLabel("Contacts List with Visuals"); + title.Name = "Title"; + title.StyleName = "Title"; + title.WidthResizePolicy = ResizePolicyType.FillToParent; + title.HeightResizePolicy = ResizePolicyType.UseNaturalSize; + title.HorizontalAlignment = HorizontalAlignment.Center; + contentLayout.Add(title); + contentLayout.SetFitHeight(0); + + // Create ContactView(s) from ContactItem(s) in ContactsList and add them to TableView + ContactView contactView; + foreach (ContactItem contact in ContactsList.s_contactData) + { + contactView = new ContactView(); + contactView.WidthResizePolicy = ResizePolicyType.FillToParent; + contactView.HeightResizePolicy = ResizePolicyType.FillToParent; + + // Configure visuals of ContactView via properties + contactView.NameField = contact.Name; + contactView.MaskURL = contact.MaskURL; + contactView.ImageURL = contact.ImageURL; + contactView.Color = contact.Color; + contactView.Shape = contact.Shape; + contentLayout.Add(contactView); + } + } + + /// + /// The main entry point for the application. + /// + [STAThread] + static void _Main(string[] args) + { + VisualsExample visualsExample = new VisualsExample(); + visualsExample.Run(args); + } + } +} diff --git a/test/NUITestSample/NUITestSample/examples/widget-view-test.cs b/test/NUITestSample/NUITestSample/examples/widget-view-test.cs new file mode 100755 index 000000000..521e376ed --- /dev/null +++ b/test/NUITestSample/NUITestSample/examples/widget-view-test.cs @@ -0,0 +1,105 @@ +using System; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; + +namespace WidgetViewTest +{ + class Example : NUIApplication + { + private PushButton _widgetButton; + private PushButton _deletedButton; + private WidgetView _widgetView; + private WidgetViewManager _widgetViewManager; + private View _container; + private string _instanceID; + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + protected override void OnTerminate() + { + //This function is called when the app exit normally. + base.OnTerminate(); + } + + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + Tizen.Log.Debug("NUI", "### DP1"); + Layer layer = new Layer(); + layer.Behavior = Layer.LayerBehavior.Layer3D; + window.AddLayer(layer); + Tizen.Log.Debug("NUI", "### DP2"); + _container = new View(); + _container.ParentOrigin = ParentOrigin.Center; + _container.PivotPoint = PivotPoint.Center; + _container.Size2D = new Size2D(400, 400); + Tizen.Log.Debug("NUI", "### DP3"); + _widgetButton = new PushButton(); + _widgetButton.LabelText = "Widget"; + _widgetButton.ParentOrigin = ParentOrigin.BottomLeft; + _widgetButton.PivotPoint = PivotPoint.BottomLeft; + _widgetButton.PositionUsesAnchorPoint = true; + _widgetButton.Size2D = new Size2D(200, 100); + window.Add(_widgetButton); + _widgetButton.Clicked += (obj, e) => + { + _widgetView = _widgetViewManager.AddWidget("widget-efl.example", "", 450, 700, -1); + //_widgetView.PositionUsesPivotPoint = true; + //_widgetView.ParentOrigin = ParentOrigin.Center; + _widgetView.PivotPoint = PivotPoint.TopLeft; + _widgetView.PositionUsesAnchorPoint = true; + _widgetView.BackgroundColor = Color.Yellow; + _widgetView.WidgetAdded += (sender, eargs) => + { + _widgetButton.LabelText = "Quit"; + window.Add(_widgetView); + }; + _widgetView.WidgetDeleted += (sender, eargs) => + { + window.Remove(_widgetView); + _widgetButton.LabelText = "Button"; + }; + _instanceID = _widgetView.InstanceID; + return false; + }; + + _deletedButton = new PushButton(); + _deletedButton.LabelText = "Buton"; + _deletedButton.ParentOrigin = ParentOrigin.BottomRight; + _deletedButton.PivotPoint = PivotPoint.BottomRight; + _deletedButton.PositionUsesAnchorPoint = true; + _deletedButton.Size2D = new Size2D(200, 100); + window.Add(_deletedButton); + _deletedButton.Clicked += (obj, e) => + { + OnTerminate(); + return true; + }; + + layer.Add(_container); + Tizen.Log.Debug("NUI", "### widget view manager create start"); + _widgetViewManager = new WidgetViewManager(this, "org.tizen.example.NUISamples.TizenTV"); + if (!_widgetViewManager) + { + Tizen.Log.Fatal("NUI", "### Widget is not enabled!"); + } + + Tizen.Log.Debug("NUI", "### widget view manager create sucess"); + } + + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} + diff --git a/test/NUITestSample/NUITestSample/res/images/Dino-Painted_lambert2SG_color.png b/test/NUITestSample/NUITestSample/res/images/Dino-Painted_lambert2SG_color.png new file mode 100755 index 000000000..3930181f8 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/Dino-Painted_lambert2SG_color.png differ diff --git a/test/NUITestSample/NUITestSample/res/images/Dino-Painted_lambert2SG_gloss.png b/test/NUITestSample/NUITestSample/res/images/Dino-Painted_lambert2SG_gloss.png new file mode 100755 index 000000000..0e6c95838 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/Dino-Painted_lambert2SG_gloss.png differ diff --git a/test/NUITestSample/NUITestSample/res/images/Dino-Painted_lambert2SG_nmap.png b/test/NUITestSample/NUITestSample/res/images/Dino-Painted_lambert2SG_nmap.png new file mode 100755 index 000000000..c2d4bf4e9 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/Dino-Painted_lambert2SG_nmap.png differ diff --git a/test/NUITestSample/NUITestSample/res/images/Dino2_lambert2SG_color.png b/test/NUITestSample/NUITestSample/res/images/Dino2_lambert2SG_color.png new file mode 100755 index 000000000..5ee5d2c7b Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/Dino2_lambert2SG_color.png differ diff --git a/test/NUITestSample/NUITestSample/res/images/Dino2_lambert2SG_nmap.png b/test/NUITestSample/NUITestSample/res/images/Dino2_lambert2SG_nmap.png new file mode 100755 index 000000000..361603cfd Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/Dino2_lambert2SG_nmap.png differ diff --git a/test/NUITestSample/NUITestSample/res/images/Kid1.svg b/test/NUITestSample/NUITestSample/res/images/Kid1.svg new file mode 100755 index 000000000..b7d547678 --- /dev/null +++ b/test/NUITestSample/NUITestSample/res/images/Kid1.svg @@ -0,0 +1,491 @@ + + + +image/svg+xml diff --git a/test/NUITestSample/NUITestSample/res/images/Mail.svg b/test/NUITestSample/NUITestSample/res/images/Mail.svg new file mode 100755 index 000000000..63fdd1f5b --- /dev/null +++ b/test/NUITestSample/NUITestSample/res/images/Mail.svg @@ -0,0 +1,170 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/test/NUITestSample/NUITestSample/res/images/World.svg b/test/NUITestSample/NUITestSample/res/images/World.svg new file mode 100755 index 000000000..91aef1351 --- /dev/null +++ b/test/NUITestSample/NUITestSample/res/images/World.svg @@ -0,0 +1,284 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/test/NUITestSample/NUITestSample/res/images/application-icon-0.png b/test/NUITestSample/NUITestSample/res/images/application-icon-0.png new file mode 100755 index 000000000..339b19ca5 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/application-icon-0.png differ diff --git a/test/NUITestSample/NUITestSample/res/images/arrow.png b/test/NUITestSample/NUITestSample/res/images/arrow.png new file mode 100755 index 000000000..87abefddf Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/arrow.png differ diff --git a/test/NUITestSample/NUITestSample/res/images/background-blocks.jpg b/test/NUITestSample/NUITestSample/res/images/background-blocks.jpg new file mode 100755 index 000000000..d8fed652c Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/background-blocks.jpg differ diff --git a/test/NUITestSample/NUITestSample/res/images/dali-logo-anim.gif b/test/NUITestSample/NUITestSample/res/images/dali-logo-anim.gif new file mode 100755 index 000000000..9a085ba95 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/dali-logo-anim.gif differ diff --git a/test/NUITestSample/NUITestSample/res/images/dog-anim.gif b/test/NUITestSample/NUITestSample/res/images/dog-anim.gif new file mode 100755 index 000000000..ddc331286 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/dog-anim.gif differ diff --git a/test/NUITestSample/NUITestSample/res/images/echo.gif b/test/NUITestSample/NUITestSample/res/images/echo.gif new file mode 100755 index 000000000..31b8040cf Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/echo.gif differ diff --git a/test/NUITestSample/NUITestSample/res/images/gallery-0.jpg b/test/NUITestSample/NUITestSample/res/images/gallery-0.jpg new file mode 100755 index 000000000..e42dba762 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/gallery-0.jpg differ diff --git a/test/NUITestSample/NUITestSample/res/images/gallery-1.jpg b/test/NUITestSample/NUITestSample/res/images/gallery-1.jpg new file mode 100755 index 000000000..6a427adf6 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/gallery-1.jpg differ diff --git a/test/NUITestSample/NUITestSample/res/images/gallery-2.jpg b/test/NUITestSample/NUITestSample/res/images/gallery-2.jpg new file mode 100755 index 000000000..30b1a51ab Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/gallery-2.jpg differ diff --git a/test/NUITestSample/NUITestSample/res/images/gallery-3.jpg b/test/NUITestSample/NUITestSample/res/images/gallery-3.jpg new file mode 100755 index 000000000..2da2ceba5 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/gallery-3.jpg differ diff --git a/test/NUITestSample/NUITestSample/res/images/gallery-4.jpg b/test/NUITestSample/NUITestSample/res/images/gallery-4.jpg new file mode 100755 index 000000000..902b711cb Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/gallery-4.jpg differ diff --git a/test/NUITestSample/NUITestSample/res/images/gallery-5.jpg b/test/NUITestSample/NUITestSample/res/images/gallery-5.jpg new file mode 100755 index 000000000..490fb5669 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/gallery-5.jpg differ diff --git a/test/NUITestSample/NUITestSample/res/images/gallery-small-43.jpg b/test/NUITestSample/NUITestSample/res/images/gallery-small-43.jpg new file mode 100755 index 000000000..c59b841d1 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/gallery-small-43.jpg differ diff --git a/test/NUITestSample/NUITestSample/res/images/image-1.jpg b/test/NUITestSample/NUITestSample/res/images/image-1.jpg new file mode 100755 index 000000000..155ab30bc Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/image-1.jpg differ diff --git a/test/NUITestSample/NUITestSample/res/images/image-2.jpg b/test/NUITestSample/NUITestSample/res/images/image-2.jpg new file mode 100755 index 000000000..e855ecfdb Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/image-2.jpg differ diff --git a/test/NUITestSample/NUITestSample/res/images/image-3.jpg b/test/NUITestSample/NUITestSample/res/images/image-3.jpg new file mode 100755 index 000000000..8dee462e2 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/image-3.jpg differ diff --git a/test/NUITestSample/NUITestSample/res/images/mask.png b/test/NUITestSample/NUITestSample/res/images/mask.png new file mode 100755 index 000000000..b3e423c96 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/mask.png differ diff --git a/test/NUITestSample/NUITestSample/res/images/not_yet_sign.png b/test/NUITestSample/NUITestSample/res/images/not_yet_sign.png new file mode 100755 index 000000000..12b48c1d1 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/not_yet_sign.png differ diff --git a/test/NUITestSample/NUITestSample/res/images/star-dim.png b/test/NUITestSample/NUITestSample/res/images/star-dim.png new file mode 100755 index 000000000..38cc674e4 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/star-dim.png differ diff --git a/test/NUITestSample/NUITestSample/res/images/star-highlight.png b/test/NUITestSample/NUITestSample/res/images/star-highlight.png new file mode 100755 index 000000000..f99ee25bb Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/star-highlight.png differ diff --git a/test/NUITestSample/NUITestSample/res/images/star-mod.png b/test/NUITestSample/NUITestSample/res/images/star-mod.png new file mode 100755 index 000000000..2e3212e66 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/star-mod.png differ diff --git a/test/NUITestSample/NUITestSample/res/images/test-image.jpg b/test/NUITestSample/NUITestSample/res/images/test-image.jpg new file mode 100755 index 000000000..13a6086f8 Binary files /dev/null and b/test/NUITestSample/NUITestSample/res/images/test-image.jpg differ diff --git a/test/NUITestSample/NUITestSample/res/json/control-dashboard.json b/test/NUITestSample/NUITestSample/res/json/control-dashboard.json new file mode 100755 index 000000000..c2609c423 --- /dev/null +++ b/test/NUITestSample/NUITestSample/res/json/control-dashboard.json @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * This file is part of Dali Toolkit + * + * 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. + */ + +{ + "styles": + { + "ProgressBar": + { + } + } +} diff --git a/test/NUITestSample/NUITestSample/res/json/date-picker-template.json b/test/NUITestSample/NUITestSample/res/json/date-picker-template.json new file mode 100755 index 000000000..79ab9a2dd --- /dev/null +++ b/test/NUITestSample/NUITestSample/res/json/date-picker-template.json @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2017 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. + * + */ +{ + // Data picker loaded directly on to the stage + // + "templates": { + "date-picker": + { + "type":"FlexContainer", + "name":"exampleDatePicker", + "flexDirection":"ROW", + "size":[480.0, 150, 0 ], + "actors": [ + { + + "type": "Spin", + "name": "Year", + "Value":2017, + "MinValue":1900, + "MaxValue":2100, + "Step":1, + "TextColor":[0.0,0.0,1.0,1.0], + "properties": { // properties registered dynamically + "flex":0.3, + "flexMargin": [5.0,0.0,5.0,0.0] + } + }, + { + + "type": "Spin", + "name": "Month", + "Value":10, + "Step":1, + "MinValue":1, + "MaxValue":12, + "TextColor":[1.0,1.0,1.0,1.0], + "properties": { // properties registered dynamically + "flex":0.3, + "flexMargin": [5.0,0.0,5.0,0.0] + } + + }, + { + + "type": "Spin", + "name": "Day", + "Value":1, + "MinValue":1, + "MaxValue":31, + "TextColor":[1.0,0.0,0.0,1.0], + "properties": { // properties registered dynamically + "flex":0.3, + "flexMargin": [5.0,0.0,5.0,0.0] + } + }] + + } +} + +} + diff --git a/test/NUITestSample/NUITestSample/res/json/date-picker-theme.json b/test/NUITestSample/NUITestSample/res/json/date-picker-theme.json new file mode 100755 index 000000000..6424a38e2 --- /dev/null +++ b/test/NUITestSample/NUITestSample/res/json/date-picker-theme.json @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * This file is part of Dali Toolkit + * + * 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. + */ + +{ + "styles": { + "Spin": { + "MinValue": 0, + "MaxValue": 100, + "Value": 50, + "Step": 1, + "TextColor": [ 1.0, 0.0, 0.0, 1.0 ] + } + } +} diff --git a/test/NUITestSample/NUITestSample/res/json/date-picker.json b/test/NUITestSample/NUITestSample/res/json/date-picker.json new file mode 100755 index 000000000..3126aa39b --- /dev/null +++ b/test/NUITestSample/NUITestSample/res/json/date-picker.json @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2014 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. + * + */ +{ + // Data picker loaded directly on to the stage + // + "stage": [{ + + "type":"FlexContainer", + "name":"exampleDatePicker", + "parentOrigin": "CENTER", + "anchorPoint": "CENTER", + "flexDirection":"ROW", + "size":[480.0, 150, 0 ], + "actors": [ + { + + "type": "Spin", + "name": "Year", + "parentOrigin": "CENTER", + "anchorPoint": "CENTER", + "MinValue":1900, + "MaxValue":2100, + "Value":2017, + "Step":1, + "TextColor":[0.0,0.0,1.0,1.0], + "properties": { // properties registered dynamically + "flex":0.3, + "flexMargin": [5.0,0.0,5.0,0.0] + } + }, + { + + "type": "Spin", + "name": "Month", + "parentOrigin": "CENTER", + "anchorPoint": "CENTER", + "parentOrigin": "CENTER", + "Step":1, + "MinValue":1, + "MaxValue":12, + "Value":10, + "TextColor":[1.0,1.0,1.0,1.0], + "properties": { // properties registered dynamically + "flex":0.3, + "flexMargin": [5.0,0.0,5.0,0.0] + } + + }, + { + + "type": "Spin", + "name": "Day", + "parentOrigin": "CENTER", + "anchorPoint": "CENTER", + "MinValue":1, + "MaxValue":31, + "Value":1, + "TextColor":[1.0,0.0,0.0,1.0], + "properties": { // properties registered dynamically + "flex":0.3, + "flexMargin": [5.0,0.0,5.0,0.0] + } + }] + +}] + +} + diff --git a/test/NUITestSample/NUITestSample/res/json/spin.json b/test/NUITestSample/NUITestSample/res/json/spin.json new file mode 100755 index 000000000..df9b10caf --- /dev/null +++ b/test/NUITestSample/NUITestSample/res/json/spin.json @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2014 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. + * + */ +{ + // a tree of actors + "stage": [ + // You can add an array of Actors / Views here + // Lets add a spin to the stage + { + "type":"Spin", + "parentOrigin":"CENTER", + "size":[120,120,0] + // now lets use the C# app json-loader.exe to load it + } + + ] +} diff --git a/test/NUITestSample/NUITestSample/res/json/style-example-theme-one.json b/test/NUITestSample/NUITestSample/res/json/style-example-theme-one.json new file mode 100755 index 000000000..5f0ef9467 --- /dev/null +++ b/test/NUITestSample/NUITestSample/res/json/style-example-theme-one.json @@ -0,0 +1,407 @@ +{ + "constants": { + "STYLE_DIR": "{APPLICATION_RESOURCE_PATH}/style" + }, + "styles": { + "Title": { + "textColor": "#0000ff", + "background": { + "visualType": "COLOR", + "mixColor": [ 1.0, 1.0, 1.0, 1.0 ] + } + }, + "TableView": { + "background": { + "visualType": "COLOR", + "mixColor": [ 1.0, 1.0, 1.0, 0.03 ] + } + }, + "FlexContainer": { + "background": { + "visualType": "COLOR", + "mixColor": [ 1.0, 1.0, 1.0, 0.1 ] + } + }, + "RadioButton": { + "label": { + "textColor": [ 1, 1, 1, 1 ] + } + }, + "CheckBoxButton": { + "label": { + "textColor": [ 1, 1, 1, 1 ] + } + }, + "ColorLabel1": { + "textColor": [ 1, 0, 0, 1 ] + }, + "ColorLabel2": { + "textColor": [ 0, 1, 0, 1 ] + }, + "ColorLabel3": { + "textColor": [ 0.3, 0.3, 1, 1 ] + }, + "ThemeLabel": { + "textColor": [ 0, 1, 1, 1 ] + }, + "PopupTitle": { + "textColor": [ 1, 1, 1, 1 ] + }, + "PopupBody": { + "textColor": [ 1, 1, 0, 1 ] + }, + "TextLabel": { + "textColor": [ 0, 0, 0, 1 ] + }, + "ColorSlider1": { + "styles": [ "Slider" ] + }, + "ColorSlider2": { + "styles": [ "slider" ] + }, + "ColorSlider3": { + "styles": [ "slider" ] + }, + "ImageChannelControl": { + "enableVisibilityTransition": [ + { + "target": "imageVisual", + "property": "opacity", + "initialValue": 0, + "targetValue": 1, + "animator": { + "alphaFunction": "EASE_IN_OUT", + "timePeriod": { + "duration": 0.25, + "delay": 0 + } + } + }, + { + "target": "imageVisual", + "property": "size", + "targetValue": [ 1, 1 ] + } + ], + "disableVisibilityTransition": [ + { + "target": "imageVisual", + "property": "opacity", + "targetValue": 0, + "animator": { + "alphaFunction": "EASE_IN_OUT", + "timePeriod": { + "duration": 0.25, + "delay": 0 + } + } + }, + { + "target": "imageVisual", + "property": "size", + "targetValue": [ 1, 1, 1 ] + } + ] + }, + "ShadowButton": { + "backgroundVisual": { + "visualType": "IMAGE", + "url": "{STYLE_DIR}/images/shadowButtonBg.9.png", + "mixColor": [ 1, 1, 1, 0 ] + }, + "checkboxBgVisual": { + "visualType": "IMAGE", + "url": "{STYLE_DIR}/images/CheckBg.png", + "transform": { + "size": [ 0.09, 0.28 ], + "offset": [ 30, 0 ], + "offsetSizeMode": [ 1, 1, 0, 0 ], + "origin": "CENTER_BEGIN", + "anchorPoint": "CENTER_BEGIN" + } + }, + "checkboxFgVisual": { + "visualType": "IMAGE", + "url": "{STYLE_DIR}/images/Tick.png", + "transform": { + "size": [ 0.09, 0.28 ], + "offset": [ 30, 0 ], + "offsetSizeMode": [ 1, 1, 0, 0 ], + "origin": "CENTER_BEGIN", + "anchorPoint": "CENTER_BEGIN" + } + }, + "labelVisual": { + "visualType": "TEXT", + "text": "Don't show again", + "pointSize": 20, + "horizontalAlignment": "END", + "verticalAlignment": "CENTER", + "textColor": [ 1, 1, 1, 1 ], + "mixColor": [ 0.3, 0.3, 0.3, 1 ], + "transform": { + "size": [ 0.9, 0.9 ], + "offset": [ -30, 0 ], + "offsetSizeMode": [ 1, 1, 0, 0 ], + "origin": "CENTER_END", + "anchorPoint": "CENTER_END" + } + }, + "activeTransition": [ + { + "target": "checkboxBgVisual", + "property": "size", + "initialValue": [ 0.09, 0.28 ], + "targetValue": [ 0.12, 0.37 ], + "animator": { + "alphaFunction": "EASE_OUT_BACK", + "timePeriod": { + "duration": 0.8, + "delay": 0 + } + } + }, + { + "target": "backgroundVisual", + "property": "mixColor", + "initialValue": [ 1, 1, 1, 0 ], + "targetValue": [ 1, 1, 1, 1 ], + "animator": { + "alphaFunction": "EASE_OUT_BACK", + "timePeriod": { + "duration": 0.8, + "delay": 0 + } + } + }, + { + "target": "backgroundVisual", + "property": "size", + "initialValue": [ 0.9, 0.9 ], + "targetValue": [ 1, 1 ], + "animator": { + "alphaFunction": "EASE_OUT_BACK", + "timePeriod": { + "duration": 0.8, + "delay": 0 + } + } + }, + { + "target": "checkboxFgVisual", + "property": "size", + "initialValue": [ 0.09, 0.28 ], + "targetValue": [ 0.12, 0.37 ], + "animator": { + "alphaFunction": "EASE_OUT_BACK", + "timePeriod": { + "duration": 0.8, + "delay": 0 + } + } + }, + { + "target": "labelVisual", + "property": "mixColor", + "initialValue": [ 0.2, 0.2, 0.2, 1.0 ], + "targetValue": [ 0, 0, 0, 1 ], + "animator": { + "alphaFunction": "EASE_OUT_BACK", + "timePeriod": { + "duration": 0.8, + "delay": 0 + } + } + } + ], + "inactiveTransition": [ + { + "target": "checkboxBgVisual", + "property": "size", + "initialValue": [ 0.12, 0.37 ], + "targetValue": [ 0.09, 0.28 ], + "animator": { + "alphaFunction": "EASE_OUT_BACK", + "timePeriod": { + "duration": 0.8, + "delay": 0 + } + } + }, + { + "target": "backgroundVisual", + "property": "mixColor", + "targetValue": [ 1, 1, 1, 0 ], + "animator": { + "alphaFunction": "EASE_OUT_BACK", + "timePeriod": { + "duration": 0.8, + "delay": 0 + } + } + }, + { + "target": "checkboxFgVisual", + "property": "size", + "initialValue": [ 0.12, 0.37 ], + "targetValue": [ 0.09, 0.28 ], + "animator": { + "alphaFunction": "EASE_OUT_BACK", + "timePeriod": { + "duration": 0.8, + "delay": 0 + } + } + }, + { + "target": "labelVisual", + "property": "mixColor", + "targetValue": [ 0.4, 0.4, 0.4, 1.0 ], + "animator": { + "alphaFunction": "EASE_OUT_BACK", + "timePeriod": { + "duration": 0.8, + "delay": 0 + } + } + }, + { + "target": "backgroundVisual", + "property": "size", + "targetValue": [ 0.9, 0.9 ], + "animator": { + "alphaFunction": "EASE_OUT_BACK", + "timePeriod": { + "duration": 0.8, + "delay": 0 + } + } + } + ], + "checkTransition": [ + { + "target": "checkboxFgVisual", + "property": "pixelArea", + "initialValue": [ 0.0, 0.0, 0.0, 1.0 ], + "targetValue": [ 0.0, 0.0, 1.0, 1.0 ], + "animator": { + "alphaFunction": "EASE_IN", + "timePeriod": { + "duration": 0.4, + "delay": 0 + } + } + }, + { + "target": "checkboxFgVisual", + "property": "size", + "initialValue": [ 0.0, 0.37 ], + "targetValue": [ 0.12, 0.37 ], + "animator": { + "alphaFunction": "EASE_IN", + "timePeriod": { + "duration": 0.4, + "delay": 0 + } + } + } + ], + "uncheckTransition": [ + { + "target": "checkboxFgVisual", + "property": "pixelArea", + "initialValue": [ 0.0, 0.0, 1.0, 1.0 ], + "targetValue": [ 0.0, 0.0, 0.0, 1.0 ], + "animator": { + "alphaFunction": "EASE_OUT", + "timePeriod": { + "duration": 0.4, + "delay": 0 + } + } + }, + { + "target": "checkboxFgVisual", + "property": "size", + "targetValue": [ 0.0, 0.37 ], + "animator": { + "alphaFunction": "EASE_OUT", + "timePeriod": { + "duration": 0.4, + "delay": 0 + } + } + } + ] + }, + "BeatControl": { + "beatVisual": { + "visualType": "IMAGE", + "url": "{APPLICATION_RESOURCE_PATH}/images/Logo-for-demo.png" + }, + + "bounceTransition": [ + { + "target": "beatVisual", + "property": "size", + "initialValue": [ 0.5, 0.5 ], + "targetValue": [ 0.75, 0.75 ], + "animator": { + "alphaFunction": "BOUNCE", + "timePeriod": { + "duration": 0.5, + "delay": 0 + } + } + } + ], + + "leftTransition": [ + { + "target": "beatVisual", + "property": "offset", + "initialValue": [ 0, 0 ], + "targetValue": [ 0.25, 0 ], + "animator": { + "alphaFunction": "BOUNCE", + "timePeriod": { + "duration": 0.5, + "delay": 0 + } + } + } + ], + + "upTransition": [ + { + "target": "beatVisual", + "property": "offset", + "initialValue": [ 0, 0 ], + "targetValue": [ 0, 0.25 ], + "animator": { + "alphaFunction": "BOUNCE", + "timePeriod": { + "duration": 0.5, + "delay": 0 + } + } + } + ], + + "fadeTransition": [ + { + "target": "beatVisual", + "property": "opacity", + "targetValue": 0, + "animator": { + "alphaFunction": "BOUNCE", + "timePeriod": { + "duration": 0.8, + "delay": 0 + } + } + } + ] + } + } +} \ No newline at end of file diff --git a/test/NUITestSample/NUITestSample/res/models/Dino.mtl b/test/NUITestSample/NUITestSample/res/models/Dino.mtl new file mode 100755 index 000000000..049595a66 --- /dev/null +++ b/test/NUITestSample/NUITestSample/res/models/Dino.mtl @@ -0,0 +1,11 @@ +newmtl lambert2SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd Dino-Painted_lambert2SG_color.png +bump Dino-Painted_lambert2SG_nmap.png -bm 0.05 +Ni 1.00 +Ks 0.00 0.00 0.00 +map_Ks Dino-Painted_lambert2SG_gloss.png +Ns 100.00 diff --git a/test/NUITestSample/NUITestSample/shared/res/NUITestSample.png b/test/NUITestSample/NUITestSample/shared/res/NUITestSample.png new file mode 100755 index 000000000..9f3cb9860 Binary files /dev/null and b/test/NUITestSample/NUITestSample/shared/res/NUITestSample.png differ diff --git a/test/NUITestSample/NUITestSample/tizen-manifest.xml b/test/NUITestSample/NUITestSample/tizen-manifest.xml new file mode 100755 index 000000000..50a20a934 --- /dev/null +++ b/test/NUITestSample/NUITestSample/tizen-manifest.xml @@ -0,0 +1,15 @@ + + + + + + NUITestSample.png + + +