manual binding for FocusManager and Window 90/134890/2
authorxb.teng <xb.teng@samsung.com>
Tue, 20 Jun 2017 08:04:08 +0000 (16:04 +0800)
committerxb.teng <xb.teng@samsung.com>
Tue, 20 Jun 2017 08:20:41 +0000 (16:20 +0800)
There are some changes:
1. Add MoveFocusBackward api for FocusManager;
2. Add Resized event for Window.

Change-Id: I9c16790f9b0073e6706ea56436e79e9c5176717f
Signed-off-by: xb.teng <xb.teng@samsung.com>
NUISamples/NUISamples/NUISamples.TizenTV/examples/dali-test.cs
NUISamples/NUISamples/NUISamples.TizenTV/examples/hello-world.cs
Tizen.NUI/Tizen.NUI.csproj
Tizen.NUI/src/internal/ManualPINVOKE.cs
Tizen.NUI/src/internal/ResizedSignal.cs [new file with mode: 0755]
Tizen.NUI/src/public/FocusManager.cs
Tizen.NUI/src/public/Window.cs

index c5c42fa..6a43310 100755 (executable)
@@ -131,6 +131,9 @@ namespace DaliTest
             VisibilityChangeTest();
 
             ResourceReadyTest();
+
+            ViewFocusTest();
+
             WindowDevelPropertyTest();
 
             Animatable handle = new Animatable();
@@ -587,6 +590,46 @@ namespace DaliTest
             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.Add(view1);
+            Window.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.Add(button);
+        }
+
         public void WindowDevelPropertyTest()
         {
             Window window = Window.Instance;
index 71f2a62..ea3a59e 100755 (executable)
@@ -55,6 +55,11 @@ namespace HelloWorldTest
             window.BackgroundColor = Color.White;
             window.Touched += OnWindowTouched;
             window.KeyPressed += OnWindowKeyEvent;
+            window.Resized += (obj, e) =>
+            {
+                Tizen.Log.Debug("NUI", "Height: " + e.Height);
+                Tizen.Log.Debug("NUI", "Width: " + e.Width);
+            };
 
             TextLabel pixelLabel = new TextLabel("Test Pixel Size 32.0f");
             pixelLabel.Position2D = new Position2D(10, 10);
index 760a221..37d690b 100755 (executable)
     <Compile Include="src\internal\RenderTask.cs" />\r
     <Compile Include="src\internal\RenderTaskList.cs" />\r
     <Compile Include="src\internal\RenderTaskSignal.cs" />\r
+    <Compile Include="src\internal\ResizedSignal.cs" />\r
     <Compile Include="src\internal\ResourceImage.cs" />\r
     <Compile Include="src\internal\ResourceImageSignal.cs" />\r
     <Compile Include="src\internal\Ruler.cs" />\r
index 239784b..7b257e1 100755 (executable)
@@ -61,6 +61,9 @@ namespace Tizen.NUI
         [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_KeyboardFocusManager_GetFocusIndicatorActor")]
         public static extern global::System.IntPtr FocusManager_GetFocusIndicatorActor(global::System.Runtime.InteropServices.HandleRef jarg1);
 
+        [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_KeyboardFocusManager_MoveFocusBackward")]
+        public static extern void FocusManager_MoveFocusBackward(global::System.Runtime.InteropServices.HandleRef jarg1);
+
         [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_KeyboardFocusManager_PreFocusChangeSignal")]
         public static extern global::System.IntPtr FocusManager_PreFocusChangeSignal(global::System.Runtime.InteropServices.HandleRef jarg1);
 
@@ -692,5 +695,29 @@ namespace Tizen.NUI
         [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_delete_ScrollStateChangedSignal")]
         public static extern void delete_ScrollStateChangedSignal(global::System.Runtime.InteropServices.HandleRef jarg1);
 
+        // For windows resized signal
+        [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_Window_ResizedSignal")]
+        public static extern global::System.IntPtr Window_ResizedSignal(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+        [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_ResizedSignal_Empty")]
+        public static extern bool ResizedSignal_Empty(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+        [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_ResizedSignal_GetConnectionCount")]
+        public static extern uint ResizedSignal_GetConnectionCount(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+        [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_ResizedSignal_Connect")]
+        public static extern void ResizedSignal_Connect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+        [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_ResizedSignal_Disconnect")]
+        public static extern void ResizedSignal_Disconnect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+        [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_ResizedSignal_Emit")]
+        public static extern void ResizedSignal_Emit(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3);
+
+        [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_new_ResizedSignal")]
+        public static extern global::System.IntPtr new_ResizedSignal();
+
+        [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_delete_ResizedSignal")]
+        public static extern void delete_ResizedSignal(global::System.Runtime.InteropServices.HandleRef jarg1);
     }
 }
diff --git a/Tizen.NUI/src/internal/ResizedSignal.cs b/Tizen.NUI/src/internal/ResizedSignal.cs
new file mode 100755 (executable)
index 0000000..0c8a61b
--- /dev/null
@@ -0,0 +1,140 @@
+//------------------------------------------------------------------------------
+// <auto-generated />
+//
+// This file was automatically generated by SWIG (http://www.swig.org).
+// Version 3.0.12
+//
+// Do not make changes to this file unless you know what you are doing--modify
+// the SWIG interface file instead.
+//------------------------------------------------------------------------------
+
+namespace Tizen.NUI
+{
+
+    internal class ResizedSignal : global::System.IDisposable
+    {
+        private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+        protected bool swigCMemOwn;
+
+        internal ResizedSignal(global::System.IntPtr cPtr, bool cMemoryOwn)
+        {
+            swigCMemOwn = cMemoryOwn;
+            swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+        }
+
+        internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ResizedSignal obj)
+        {
+            return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+        }
+
+        //A Flag to check who called Dispose(). (By User or DisposeQueue)
+        private bool isDisposeQueued = false;
+        //A Flat to check if it is already disposed.
+        protected bool disposed = false;
+
+        ~ResizedSignal()
+        {
+            if (!isDisposeQueued)
+            {
+                isDisposeQueued = true;
+                DisposeQueue.Instance.Add(this);
+            }
+        }
+
+        public void Dispose()
+        {
+            //Throw excpetion if Dispose() is called in separate thread.
+            if (!Window.IsInstalled())
+            {
+                throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
+            }
+
+            if (isDisposeQueued)
+            {
+                Dispose(DisposeTypes.Implicit);
+            }
+            else
+            {
+                Dispose(DisposeTypes.Explicit);
+                System.GC.SuppressFinalize(this);
+            }
+        }
+
+        protected virtual void Dispose(DisposeTypes type)
+        {
+            if (disposed)
+            {
+                return;
+            }
+
+            if (type == DisposeTypes.Explicit)
+            {
+                //Called by User
+                //Release your own managed resources here.
+                //You should release all of your own disposable objects here.
+            }
+
+            //Release your own unmanaged resources here.
+            //You should not access any managed member here except static instance.
+            //because the execution order of Finalizes is non-deterministic.
+
+            if (swigCPtr.Handle != global::System.IntPtr.Zero)
+            {
+                if (swigCMemOwn)
+                {
+                    swigCMemOwn = false;
+                    NDalicManualPINVOKE.delete_ResizedSignal(swigCPtr);
+                }
+                swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+            }
+
+            disposed = true;
+        }
+
+
+        public bool Empty()
+        {
+            bool ret = NDalicManualPINVOKE.ResizedSignal_Empty(swigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        public uint GetConnectionCount()
+        {
+            uint ret = NDalicManualPINVOKE.ResizedSignal_GetConnectionCount(swigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        public void Connect(System.Delegate func)
+        {
+            System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
+            {
+                NDalicManualPINVOKE.ResizedSignal_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            }
+        }
+
+        public void Disconnect(System.Delegate func)
+        {
+            System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
+            {
+                NDalicManualPINVOKE.ResizedSignal_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            }
+        }
+
+        public void Emit(int arg1, int arg2)
+        {
+            NDalicManualPINVOKE.ResizedSignal_Emit(swigCPtr, arg1, arg2);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        public ResizedSignal() : this(NDalicManualPINVOKE.new_ResizedSignal(), true)
+        {
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+    }
+
+}
index b1cfcbc..4ebae95 100755 (executable)
@@ -487,6 +487,15 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Move the focus to prev focused view.
+        /// </summary>
+        public void MoveFocusBackward()
+        {
+            NDalicManualPINVOKE.FocusManager_MoveFocusBackward(swigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
         /// Sets/Gets the status of whether the focus movement should be looped within the same focus group.<br>
         /// The focus movement is not looped by default.<br>
         /// </summary>
index 68585f2..9718abd 100755 (executable)
@@ -677,6 +677,13 @@ namespace Tizen.NUI
             return ret;
         }
 
+        internal ResizedSignal ResizedSignal()
+        {
+            ResizedSignal ret = new ResizedSignal(NDalicManualPINVOKE.Window_ResizedSignal(stageCPtr), false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
         internal static Vector4 DEFAULT_BACKGROUND_COLOR
         {
             get
@@ -1171,6 +1178,76 @@ namespace Tizen.NUI
             }
         }
 
+        public class ResizedEventArgs : EventArgs
+        {
+            int _width;
+            int _height;
+
+            public int Width
+            {
+                get
+                {
+                    return _width;
+                }
+                set
+                {
+                    _width = value;
+                }
+            }
+
+            public int Height
+            {
+                get
+                {
+                    return _height;
+                }
+                set
+                {
+                    _height = value;
+                }
+            }
+        }
+
+        private WindowResizedEventCallbackType _windowResizedEventCallback;
+        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        private delegate void WindowResizedEventCallbackType(int width, int height);
+        private event EventHandler<ResizedEventArgs> _windowResizedEventHandler;
+
+        public event EventHandler<ResizedEventArgs> Resized
+        {
+            add
+            {
+                if (_windowResizedEventHandler == null)
+                {
+                    _windowResizedEventCallback = OnResized;
+                    ResizedSignal().Connect(_windowResizedEventCallback);
+                }
+
+                _windowResizedEventHandler += value;
+            }
+            remove
+            {
+                _windowResizedEventHandler -= value;
+
+                if (_windowResizedEventHandler == null && ResizedSignal().Empty() == false && _windowResizedEventCallback != null)
+                {
+                    ResizedSignal().Disconnect(_windowResizedEventCallback);
+                }
+            }
+        }
+
+        private void OnResized(int width, int height)
+        {
+            ResizedEventArgs e = new ResizedEventArgs();
+            e.Width = width;
+            e.Height = height;
+
+            if (_windowResizedEventHandler != null)
+            {
+                _windowResizedEventHandler(this, e);
+            }
+        }
+
         /// <summary>
         /// Window size property (read-only).
         /// </summary>