Merge remote-tracking branch 'origin/API9' into tizen_6.5
authorTizenAPI-Bot <tizenapi@samsung.com>
Fri, 11 Feb 2022 04:13:08 +0000 (04:13 +0000)
committerTizenAPI-Bot <tizenapi@samsung.com>
Fri, 11 Feb 2022 04:13:08 +0000 (04:13 +0000)
src/Tizen.NUI/src/internal/Interop/Interop.Window.cs
src/Tizen.NUI/src/public/Window/Window.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/KeyFrameAnimationTest.cs [new file with mode: 0755]

index e2b9124..3b30f7e 100755 (executable)
@@ -182,6 +182,12 @@ namespace Tizen.NUI
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_FeedKeyEvent")]
             public static extern void FeedKeyEvent(global::System.Runtime.InteropServices.HandleRef jarg1);
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_FeedTouchPoint")]
+            public static extern void FeedTouchPoint(global::System.Runtime.InteropServices.HandleRef touchPoint, int timeStamp);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_FeedWheelEvent")]
+            public static extern void FeedWheelEvent(global::System.Runtime.InteropServices.HandleRef wheelEvent);
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Adaptor_RenderOnce")]
             public static extern void RenderOnce(global::System.Runtime.InteropServices.HandleRef jarg1);
 
index c5ca31c..398910a 100644 (file)
@@ -1081,6 +1081,29 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Feeds a touch point into the window.
+        /// </summary>
+        /// <param name="touchPoint">The touch point to feed.</param>
+        /// <param name="timeStamp">The timeStamp.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        internal void FeedTouch(TouchPoint touchPoint, int timeStamp)
+        {
+            Interop.Window.FeedTouchPoint(TouchPoint.getCPtr(touchPoint), timeStamp);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Feeds a wheel event into the window.
+        /// </summary>
+        /// <param name="wheelEvent">The wheel event to feed.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        internal void FeedWheel(Wheel wheelEvent)
+        {
+            Interop.Window.FeedWheelEvent(Wheel.getCPtr(wheelEvent));
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
         /// Allows at least one more render, even when paused.
         /// The window should be shown, not minimised.
         /// </summary>
diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/KeyFrameAnimationTest.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/KeyFrameAnimationTest.cs
new file mode 100755 (executable)
index 0000000..f1856e1
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+* Copyright (c) 2022 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.Components;
+using Tizen.NUI.BaseComponents;
+
+namespace Tizen.NUI.Samples
+{
+    public class KeyFrameAnimationTest : IExample
+    {
+        private static string resourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
+        private Animation animation;
+        private ImageView imageView;
+        private bool isAniFinised = true;
+        private Button button;
+        private Window window;
+        private const int testPosition = 100;
+        private const int testSize = 100;
+
+        public void Activate()
+        {
+            Initialize();
+        }
+        public void Deactivate()
+        {
+            FocusManager.Instance.ClearFocus();
+            imageView.Unparent();
+            imageView.Dispose();
+
+            button.Unparent();
+            button.Dispose();
+        }
+
+        public void Initialize()
+        {
+            window = NUIApplication.GetDefaultWindow();
+            imageView = new ImageView();
+            imageView.ResourceUrl = resourcePath + "/images/Dali/DaliDemo/application-icon-1.png";
+            imageView.Position = new Position2D(testPosition, testPosition);
+            imageView.Size = new Size2D(testSize, testSize);
+            window.Add(imageView);
+
+            button = new Button()
+            {
+                Position = new Position2D(0, 0),
+                Text = "click or Return key",
+                BackgroundColor = Color.DarkGreen,
+                Focusable = true,
+            };
+            button.Clicked += OnButtonClicked;
+            window.Add(button);
+            FocusManager.Instance.SetCurrentFocusView(button);
+
+        }
+
+        private void OnButtonClicked(object sender, ClickedEventArgs e)
+        {
+            if (!isAniFinised) return;
+            isAniFinised = false;
+
+            // Create a new animation
+            if (animation)
+            {
+                //animation.Stop(Tizen.NUI.Constants.Animation.EndAction.Stop);
+                animation.Reset();
+            }
+
+            animation = new Animation();
+
+            KeyFrames pixelkeyFrames = new KeyFrames();
+            pixelkeyFrames.Add(0.25f, new Vector4(0.5f, 0.0f, 0.5f, 0.5f));
+            pixelkeyFrames.Add(0.5f, new Vector4(0.5f, 0.5f, 0.5f, 0.5f));
+            pixelkeyFrames.Add(0.75f, new Vector4(0.0f, 0.0f, 1.0f, 1.0f));
+            pixelkeyFrames.Add(1.0f, new Vector4(0.5f, 0.5f, 0.5f, 0.5f));
+            animation.AnimateBetween(imageView, "PixelArea", pixelkeyFrames, 0, 8000, Animation.Interpolation.Cubic);
+
+            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.3f, window.Size.Height * 0.3f, 0));
+            keyFrames.Add(1.0f, new Size(window.Size.Width * 0.5f, window.Size.Height * 0.5f, 0));
+            animation.AnimateBetween(imageView, "Size", keyFrames, 2000, 6000, Animation.Interpolation.Linear);
+
+            KeyFrames positionkeyFrames = new KeyFrames();
+            positionkeyFrames.Add(0.0f, new Position(testPosition * 1.5f, testPosition * 1.5f, 0));
+            positionkeyFrames.Add(0.2f, new Position(window.Size.Width * 0.5f, window.Size.Height * 0.1f, 0));
+            positionkeyFrames.Add(0.4f, new Position(window.Size.Width * 0.6f, window.Size.Height * 0.5f, 0));
+            positionkeyFrames.Add(0.8f, new Position(window.Size.Width * 0.1f, window.Size.Height * 0.6f, 0));
+            positionkeyFrames.Add(1.0f, new Position(window.Size.Width * 0.6f, window.Size.Height * 0.7f, 0));
+            animation.AnimateBetween(imageView, "Position", positionkeyFrames, 0, 9000, Animation.Interpolation.Cubic);
+
+            animation.EndAction = Animation.EndActions.Discard;
+
+            // Connect the signal callback for animaiton finished signal
+            animation.Finished += AnimationFinished;
+            animation.Finished += AnimationFinishedSecond;
+
+            // Play the animation
+            animation.Play();
+        }
+
+        // Callback for animation finished signal handling
+        public void AnimationFinished(object sender, EventArgs e)
+        {
+            Tizen.Log.Debug("NUITEST", $"animation finished");
+        }
+
+        // Callback for second animation finished signal handling
+        public void AnimationFinishedSecond(object sender, EventArgs e)
+        {
+            if (animation)
+            {
+                isAniFinised = true;
+            }
+        }
+    }
+}