[NUI] Change DefaultBorder property (#6099)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Window / DefaultBorder.cs
index d50c96b..9fed5bb 100755 (executable)
@@ -18,6 +18,8 @@
 using System;
 using System.ComponentModel;
 using Tizen.NUI.BaseComponents;
+using Tizen.NUI;
+using Tizen.NUI.Binding;
 
 namespace Tizen.NUI
 {
@@ -25,8 +27,21 @@ namespace Tizen.NUI
     /// This class creates a border UI.
     /// </summary>
     [EditorBrowsable(EditorBrowsableState.Never)]
-    public class DefaultBorder : IBorderInterface
+    public class DefaultBorder : BindableObject, IDisposable, IBorderInterface
     {
+        static DefaultBorder()
+        {
+            if(NUIApplication.IsUsingXaml)
+            {
+                BorderLineThicknessProperty = BindableProperty.Create(nameof(BorderLineThickness), typeof(uint), typeof(DefaultBorder), default(uint), propertyChanged: SetInternalBorderLineThicknessProperty, defaultValueCreator: GetInternalBorderLineThicknessProperty);
+                
+                MinSizeProperty = BindableProperty.Create(nameof(MinSize), typeof(Size2D), typeof(DefaultBorder), default(Size2D), propertyChanged: SetInternalMinSizeProperty, defaultValueCreator: GetInternalMinSizeProperty);
+                
+                MaxSizeProperty = BindableProperty.Create(nameof(MaxSize), typeof(Size2D), typeof(DefaultBorder), default(Size2D), propertyChanged: SetInternalMaxSizeProperty, defaultValueCreator: GetInternalMaxSizeProperty);
+                
+                ResizePolicyProperty = BindableProperty.Create(nameof(ResizePolicy), typeof(Window.BorderResizePolicyType), typeof(DefaultBorder), default(Window.BorderResizePolicyType), propertyChanged: SetInternalResizePolicyProperty, defaultValueCreator: GetInternalResizePolicyProperty);
+            }
+        }
         #region Constant Fields
         private static readonly string ResourcePath = FrameworkInformation.ResourcePath;
         private static readonly string MinimalizeIcon = ResourcePath + "minimalize.png";
@@ -42,16 +57,17 @@ namespace Tizen.NUI
         private static readonly string DarkRightCornerIcon = ResourcePath + "dark_rightCorner.png";
 
 
-        private const uint DefaultHeight = 50;
+        private const float DefaultHeight = 50;
         private const uint DefaultLineThickness = 5;
-        private const uint DefaultTouchThickness = 20;
-        private static readonly Color DefaultBackgroundColor = new Color(1, 1, 1, 0.3f);
-        private static readonly Color DefaultClickedBackgroundColor = new Color(1, 1, 1, 0.4f);
+        private const uint DefaultTouchThickness = 0;
+        private static readonly Color DefaultBackgroundColor = new Color(0.7f, 0.7f, 0.7f, 0.6f);
+        private static readonly Color DefaultClickedBackgroundColor = new Color(0.7f, 0.7f, 0.7f, 0.7f);
         private static readonly Size2D DefaultMinSize = new Size2D(100, 0);
         #endregion //Constant Fields
 
 
         #region Fields
+        private bool disposed = false;
         private Color backgroundColor;
         private View borderView;
 
@@ -65,37 +81,130 @@ namespace Tizen.NUI
         private float preScale = 0;
 
         private View windowView = null;
-        private bool isWinGestures = false;
-        private Timer timer;
+        private Timer overlayTimer;
+
+        private uint borderLineThickness;
+        private Size2D minSize;
+        private Size2D maxSize;
+        private Window.BorderResizePolicyType resizePolicy;
 
-        private CurrentGesture currentGesture = CurrentGesture.None;
-        private bool disposed = false;
         #endregion //Fields
 
         #region Events
         private PanGestureDetector borderPanGestureDetector;
-        private PinchGestureDetector borderPinchGestureDetector;
-        private PanGestureDetector winPanGestureDetector;
-        private TapGestureDetector winTapGestureDetector;
         #endregion //Events
 
         #region Enums
-        private enum CurrentGesture
-        {
-          None = 0,
-          TapGesture = 1,
-          PanGesture = 2,
-          PinchGesture = 3,
-        }
         #endregion //Enums
 
         #region Methods
 
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty BorderLineThicknessProperty = null;
+        
+        internal static void SetInternalBorderLineThicknessProperty(BindableObject bindable, object oldValue, object newValue)
+        {
+            var instance = (DefaultBorder)bindable;
+            if (newValue != null)
+            {
+                instance.borderLineThickness = (uint)newValue;
+                instance.UpdateProperty();
+            }
+        }
+        
+        internal static object GetInternalBorderLineThicknessProperty(BindableObject bindable)
+        {
+            var instance = (DefaultBorder)bindable;
+            return instance.borderLineThickness;
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty MinSizeProperty = null;
+        
+        internal static void SetInternalMinSizeProperty(BindableObject bindable, object oldValue, object newValue)
+        {
+            var instance = (DefaultBorder)bindable;
+            if (newValue != null)
+            {
+                instance.minSize = (Size2D)newValue;
+                instance.UpdateProperty();
+            }
+        }
+        
+        internal static object GetInternalMinSizeProperty(BindableObject bindable)
+        {
+            var instance = (DefaultBorder)bindable;
+            return instance.minSize;
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty MaxSizeProperty = null;
+        
+        internal static void SetInternalMaxSizeProperty(BindableObject bindable, object oldValue, object newValue)
+        {
+            var instance = (DefaultBorder)bindable;
+            if (newValue != null)
+            {
+                instance.maxSize = (Size2D)newValue;
+                instance.UpdateProperty();
+            }
+        }
+        
+        internal static object GetInternalMaxSizeProperty(BindableObject bindable)
+        {
+            var instance = (DefaultBorder)bindable;
+            return instance.maxSize;
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty ResizePolicyProperty = null;
+        
+        internal static void SetInternalResizePolicyProperty(BindableObject bindable, object oldValue, object newValue)
+        {
+            var instance = (DefaultBorder)bindable;
+            if (newValue != null)
+            {
+                instance.resizePolicy = (Window.BorderResizePolicyType)newValue;
+                instance.UpdateProperty();
+            }
+        }
+        
+        internal static object GetInternalResizePolicyProperty(BindableObject bindable)
+        {
+            var instance = (DefaultBorder)bindable;
+            return instance.resizePolicy;
+        }
+
+
         /// <summary>
         /// The thickness of the border.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public uint BorderLineThickness {get; set;}
+        public uint BorderLineThickness
+        {
+            get
+            {
+                if (NUIApplication.IsUsingXaml)
+                {
+                    return (uint)GetValue(BorderLineThicknessProperty);
+                }
+                else
+                {
+                    return (uint)GetInternalBorderLineThicknessProperty(this);
+                }
+            }
+            set
+            {
+                if (NUIApplication.IsUsingXaml)
+                {
+                    SetValue(BorderLineThicknessProperty, value);
+                }
+                else
+                {
+                    SetInternalBorderLineThicknessProperty(this, null, value);
+                }
+            }
+        }
 
         /// <summary>
         /// The thickness of the border's touch area.
@@ -105,21 +214,70 @@ namespace Tizen.NUI
 
         /// <summary>
         /// The height of the border.
+        /// This value is the initial value used when creating borders.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public uint BorderHeight {get; set;}
+        public float BorderHeight {get; set;}
 
         /// <summary>
         /// The minimum size by which the window will small.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public Size2D MinSize {get; set;}
+        public Size2D MinSize
+        {
+            get
+            {
+                if (NUIApplication.IsUsingXaml)
+                {
+                    return (Size2D)GetValue(MinSizeProperty);
+                }
+                else
+                {
+                    return (Size2D)GetInternalMinSizeProperty(this);
+                }
+            }
+            set
+            {
+                if (NUIApplication.IsUsingXaml)
+                {
+                    SetValue(MinSizeProperty, value);
+                }
+                else
+                {
+                    SetInternalMinSizeProperty(this, null, value);
+                }
+            }
+        }
 
         /// <summary>
         /// The maximum size by which the window will big.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public Size2D MaxSize {get; set;}
+        public Size2D MaxSize
+        {
+            get
+            {
+                if (NUIApplication.IsUsingXaml)
+                {
+                    return (Size2D)GetValue(MaxSizeProperty);
+                }
+                else
+                {
+                    return (Size2D)GetInternalMaxSizeProperty(this);
+                }
+            }
+            set
+            {
+                if (NUIApplication.IsUsingXaml)
+                {
+                    SetValue(MaxSizeProperty, value);
+                }
+                else
+                {
+                    SetInternalMaxSizeProperty(this, null, value); 
+                }
+            }
+        }
 
         /// <summary>
         /// The window with borders added.
@@ -136,18 +294,58 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public bool OverlayMode {get; set;}
 
+        /// <summary>
+        /// Set the window resizing policy.
+        /// Default value is BorderResizePolicyType.Free;
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Window.BorderResizePolicyType ResizePolicy
+        {
+            get
+            {
+                if (NUIApplication.IsUsingXaml)
+                {
+                    return (Window.BorderResizePolicyType)GetValue(ResizePolicyProperty);
+                }
+                else
+                {
+                    return (Window.BorderResizePolicyType)GetInternalResizePolicyProperty(this);
+                }
+            }
+            set
+            {
+                if (NUIApplication.IsUsingXaml)
+                {
+                    SetValue(ResizePolicyProperty, value);
+                }
+                else
+                {
+                    SetInternalResizePolicyProperty(this, null, value);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Update properties
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void UpdateProperty()
+        {
+            BorderWindow?.UpdateProperty();
+        }
 
         /// <summary>
         /// Creates a default border
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public DefaultBorder()
+        public DefaultBorder() : base()
         {
             BorderLineThickness = DefaultLineThickness;
             TouchThickness = DefaultTouchThickness;
             BorderHeight = DefaultHeight;
             MinSize = DefaultMinSize;
             OverlayMode = false;
+            ResizePolicy = Window.BorderResizePolicyType.Free;
         }
 
         /// <summary>
@@ -175,27 +373,37 @@ namespace Tizen.NUI
 
             minimalizeIcon = new ImageView()
             {
+                Focusable = true,
                 ResourceUrl = MinimalizeIcon,
+                AccessibilityHighlightable = true,
             };
 
             maximalizeIcon = new ImageView()
             {
+                Focusable = true,
                 ResourceUrl = MaximalizeIcon,
+                AccessibilityHighlightable = true,
             };
 
             closeIcon = new ImageView()
             {
+                Focusable = true,
                 ResourceUrl = CloseIcon,
+                AccessibilityHighlightable = true,
             };
 
             leftCornerIcon = new ImageView()
             {
+                Focusable = true,
                 ResourceUrl = LeftCornerIcon,
+                AccessibilityHighlightable = true,
             };
 
             rightCornerIcon = new ImageView()
             {
-              ResourceUrl = RightCornerIcon,
+                Focusable = true,
+                ResourceUrl = RightCornerIcon,
+                AccessibilityHighlightable = true,
             };
 
             RelativeLayout.SetRightTarget(minimalizeIcon, maximalizeIcon);
@@ -221,6 +429,47 @@ namespace Tizen.NUI
             closeIcon.TouchEvent += OnCloseIconTouched;
             leftCornerIcon.TouchEvent += OnLeftBottomCornerIconTouched;
             rightCornerIcon.TouchEvent += OnRightBottomCornerIconTouched;
+
+            minimalizeIcon.AccessibilityActivated += (s, e) =>
+            {
+                MinimizeBorderWindow();
+            };
+            maximalizeIcon.AccessibilityActivated += (s, e) =>
+            {
+                MaximizeBorderWindow();
+            };
+            closeIcon.AccessibilityActivated += (s, e) =>
+            {
+                CloseBorderWindow();
+            };
+
+            minimalizeIcon.AccessibilityNameRequested += (s, e) =>
+            {
+                e.Name = "Minimize";
+            };
+            maximalizeIcon.AccessibilityNameRequested += (s, e) =>
+            {
+                e.Name = "Maximize";
+            };
+            closeIcon.AccessibilityNameRequested += (s, e) =>
+            {
+                e.Name = "Close";
+            };
+            leftCornerIcon.AccessibilityNameRequested += (s, e) =>
+            {
+                e.Name = "Resize";
+            };
+            rightCornerIcon.AccessibilityNameRequested += (s, e) =>
+            {
+                e.Name = "Resize";
+            };
+
+            minimalizeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
+            maximalizeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
+            closeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
+            leftCornerIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
+            rightCornerIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
+
             return true;
         }
 
@@ -237,10 +486,40 @@ namespace Tizen.NUI
             {
                 return;
             }
-            this.borderView = borderView;
-            borderView.BackgroundColor = DefaultBackgroundColor;
+
+            if (string.IsNullOrEmpty(borderView.BackgroundImage))
+            {
+                borderView.BackgroundColor = DefaultBackgroundColor;
+            }
+            borderView.BorderlineColor = new Color(0.5f, 0.5f, 0.5f, 0.3f);
+            borderView.BorderlineWidth = 1.0f;
+            borderView.BorderlineOffset = -1f;
             borderView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
             borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
+
+            // Register touch event for effect when border is touched.
+            borderView.LeaveRequired = true;
+            borderView.TouchEvent += OnBorderViewTouched;
+            this.borderView = borderView;
+        }
+
+        private bool OnBorderViewTouched(object sender, View.TouchEventArgs e)
+        {
+            if (string.IsNullOrEmpty(borderView.BackgroundImage))
+            {
+                if (e.Touch.GetState(0) == PointStateType.Started)
+                {
+                    backgroundColor = new Color(borderView.BackgroundColor);
+                    borderView.BackgroundColor = DefaultClickedBackgroundColor;
+                }
+                else if (e.Touch.GetState(0) == PointStateType.Finished ||
+                        e.Touch.GetState(0) == PointStateType.Leave ||
+                        e.Touch.GetState(0) == PointStateType.Interrupted)
+                {
+                    borderView.BackgroundColor = backgroundColor;
+                }
+            }
+            return true;
         }
 
         /// Determines the behavior of pinch gesture.
@@ -265,6 +544,7 @@ namespace Tizen.NUI
                     else
                     {
                         BorderWindow.Minimize(true);
+                        OnMinimize(true);
                     }
                 }
                 else
@@ -295,10 +575,11 @@ namespace Tizen.NUI
                     }
                     else
                     {
+                        OnRequestMove();
                         BorderWindow.RequestMoveToServer();
                     }
                 }
-                else if (direction != Window.BorderDirection.None)
+                else if (direction != Window.BorderDirection.None && ResizePolicy != Window.BorderResizePolicyType.Fixed)
                 {
                     OnRequestResize();
                     BorderWindow.RequestResizeToServer((Window.ResizeDirection)direction);
@@ -307,7 +588,6 @@ namespace Tizen.NUI
             else if (panGesture.State == Gesture.StateType.Finished || panGesture.State == Gesture.StateType.Cancelled)
             {
                 direction = Window.BorderDirection.None;
-                ClearWindowGesture();
             }
         }
 
@@ -317,15 +597,14 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual bool OnLeftTopCornerIconTouched(object sender, View.TouchEventArgs e)
         {
-            if (e == null)
-            {
-                return false;
-            }
-            if (e.Touch.GetState(0) == PointStateType.Down)
+            SetDispatchParentGestureEvents(sender as View, false);
+            if (e != null && e.Touch.GetState(0) == PointStateType.Down)
             {
-              ClearWindowGesture();
-              OnRequestResize();
-              BorderWindow.RequestResizeToServer(Window.ResizeDirection.TopLeft);
+              if (ResizePolicy != Window.BorderResizePolicyType.Fixed)
+              {
+                OnRequestResize();
+                BorderWindow.RequestResizeToServer(Window.ResizeDirection.TopLeft);
+              }
             }
             return true;
         }
@@ -336,15 +615,14 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual bool OnRightTopCornerIconTouched(object sender, View.TouchEventArgs e)
         {
-            if (e == null)
-            {
-                return false;
-            }
-            if (e.Touch.GetState(0) == PointStateType.Down)
+            SetDispatchParentGestureEvents(sender as View, false);
+            if (e != null && e.Touch.GetState(0) == PointStateType.Down)
             {
-              ClearWindowGesture();
-              OnRequestResize();
-              BorderWindow.RequestResizeToServer(Window.ResizeDirection.TopRight);
+              if (ResizePolicy != Window.BorderResizePolicyType.Fixed)
+              {
+                OnRequestResize();
+                BorderWindow.RequestResizeToServer(Window.ResizeDirection.TopRight);
+              }
             }
             return true;
         }
@@ -356,15 +634,14 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual bool OnLeftBottomCornerIconTouched(object sender, View.TouchEventArgs e)
         {
-            if (e == null)
-            {
-                return false;
-            }
-            if (e.Touch.GetState(0) == PointStateType.Down)
+            SetDispatchParentGestureEvents(sender as View, false);
+            if (e != null && e.Touch.GetState(0) == PointStateType.Down)
             {
-              ClearWindowGesture();
-              OnRequestResize();
-              BorderWindow.RequestResizeToServer(Window.ResizeDirection.BottomLeft);
+              if (ResizePolicy != Window.BorderResizePolicyType.Fixed)
+              {
+                OnRequestResize();
+                BorderWindow.RequestResizeToServer(Window.ResizeDirection.BottomLeft);
+              }
             }
             return true;
         }
@@ -375,36 +652,57 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual bool OnRightBottomCornerIconTouched(object sender, View.TouchEventArgs e)
         {
-            if (e == null)
-            {
-                return false;
-            }
-            if (e.Touch.GetState(0) == PointStateType.Down)
+            SetDispatchParentGestureEvents(sender as View, false);
+            if (e != null && e.Touch.GetState(0) == PointStateType.Down)
             {
-              ClearWindowGesture();
-              OnRequestResize();
-              BorderWindow.RequestResizeToServer(Window.ResizeDirection.BottomRight);
+              if (ResizePolicy != Window.BorderResizePolicyType.Fixed)
+              {
+                OnRequestResize();
+                BorderWindow.RequestResizeToServer(Window.ResizeDirection.BottomRight);
+              }
             }
             return true;
         }
 
 
         /// <summary>
+        /// Minimize border window.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected void MinimizeBorderWindow()
+        {
+            BorderWindow.Minimize(true);
+            OnMinimize(true);
+        }
+
+        /// <summary>
         /// This is an event callback when the minimize icon is touched.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual bool OnMinimizeIconTouched(object sender, View.TouchEventArgs e)
         {
-            if (e == null)
+            SetDispatchParentGestureEvents(sender as View, false);
+            if (e != null && e.Touch.GetState(0) == PointStateType.Up)
             {
-                return false;
+                MinimizeBorderWindow();
             }
-            if (e.Touch.GetState(0) == PointStateType.Up)
+            return true;
+        }
+
+        /// <summary>
+        /// Maximize border window.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected void MaximizeBorderWindow()
+        {
+            if (BorderWindow.IsMaximized())
             {
-                ClearWindowGesture();
-                BorderWindow.Minimize(true);
+              BorderWindow.Maximize(false);
+            }
+            else
+            {
+              BorderWindow.Maximize(true);
             }
-            return true;
         }
 
         /// <summary>
@@ -413,41 +711,45 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual bool OnMaximizeIconTouched(object sender, View.TouchEventArgs e)
         {
-            if (e == null)
+            SetDispatchParentGestureEvents(sender as View, false);
+            if (e != null && e.Touch.GetState(0) == PointStateType.Up)
             {
-                return false;
-            }
-            if (e.Touch.GetState(0) == PointStateType.Up)
-            {
-                ClearWindowGesture();
-                if (BorderWindow.IsMaximized())
-                {
-                  BorderWindow.Maximize(false);
-                }
-                else
-                {
-                  BorderWindow.Maximize(true);
-                }
+                MaximizeBorderWindow();
             }
             return true;
         }
 
         /// <summary>
+        /// Close border window.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected void CloseBorderWindow()
+        {
+            BorderWindow.BorderDestroy();
+        }
+
+        /// <summary>
         /// This is an event callback when the close icon is touched.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual bool OnCloseIconTouched(object sender, View.TouchEventArgs e)
         {
-            if (e == null)
+            SetDispatchParentGestureEvents(sender as View, false);
+            if (e != null && e.Touch.GetState(0) == PointStateType.Up)
             {
-                return false;
+                CloseBorderWindow();
             }
-            if (e.Touch.GetState(0) == PointStateType.Up)
+            return true;
+        }
+
+        private void SetDispatchParentGestureEvents(View view, bool dispatch)
+        {
+            if (view != null)
             {
-                BorderWindow.Destroy();
-                BorderWindow = null;
+                // If this is set, my parents will not receive gesture events.
+                // This is to prevent the move action by PanGesture when the icon is touched.
+                view.DispatchParentGestureEvents = dispatch;
             }
-            return true;
         }
 
 
@@ -479,7 +781,6 @@ namespace Tizen.NUI
                     }
                     borderView.CornerRadius = new Vector4(0, 0, 0, 0);
                     borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
-                    BorderWindow.SetTransparency(false);
                 }
                 else
                 {
@@ -505,12 +806,10 @@ namespace Tizen.NUI
                     }
                     borderView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
                     borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
-                    BorderWindow.SetTransparency(true);
                 }
             }
         }
 
-
         /// <summary>
         /// Called after the border UI is created.
         /// </summary>
@@ -522,226 +821,211 @@ namespace Tizen.NUI
             {
                 return;
             }
+            this.borderView = borderView;
+
+            BorderWindow.BackgroundColor = Color.Transparent;
+
             // Register to resize and move through pan gestures.
             borderPanGestureDetector = new PanGestureDetector();
             borderPanGestureDetector.Attach(borderView);
             borderPanGestureDetector.Detected += OnPanGestureDetected;
 
-            // Register touch event for effect when border is touched.
-            borderView.LeaveRequired = true;
-            borderView.TouchEvent += (s, e) =>
-            {
-                if (e.Touch.GetState(0) == PointStateType.Started)
-                {
-                    if (BorderWindow.IsMaximized() == false)
-                    {
-                        BorderWindow.Raise();
-                    }
-                    backgroundColor = new Color(borderView.BackgroundColor);
-                    borderView.BackgroundColor = DefaultClickedBackgroundColor;
-                }
-                else if (e.Touch.GetState(0) == PointStateType.Finished ||
-                         e.Touch.GetState(0) == PointStateType.Leave ||
-                         e.Touch.GetState(0) == PointStateType.Interrupted)
-                {
-                    borderView.BackgroundColor = backgroundColor;
-                }
-                return true;
-            };
-
-            borderPinchGestureDetector = new PinchGestureDetector();
-            borderPinchGestureDetector.Attach(borderView);
-            borderPinchGestureDetector.Detected += OnPinchGestureDetected;
-
-            AddInterceptGesture();
-
             UpdateIcons();
         }
 
+        /// <summary>
+        /// Called when requesting a resize
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual void OnRequestResize() {}
 
-        // Register an intercept touch event on the window.
-        private void AddInterceptGesture()
+        /// <summary>
+        /// Called when the window is resized.
+        /// </summary>
+        /// <param name="width">The width of the resized window</param>
+        /// <param name="height">The height of the resized window</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual void OnResized(int width, int height)
         {
-            isWinGestures = false;
-            BorderWindow.InterceptTouchEvent += OnWinInterceptedTouch;
+            if (overlayTimer != null)
+            {
+                overlayTimer.Stop();
+                overlayTimer.Dispose();
+                overlayTimer = null;
+            }
+            UpdateIcons();
         }
 
-        // Intercept touch on window.
-        private bool OnWinInterceptedTouch(object sender, Window.TouchEventArgs e)
+        /// <summary>
+        /// Called when requesting a move
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual void OnRequestMove() {}
+
+        /// <summary>
+        /// Called when the window is moved.
+        /// </summary>
+        /// <param name="x">The x of the moved window</param>
+        /// <param name="y">The y of the moved window</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual void OnMoved(int x, int y) {}
+
+        /// <summary>
+        /// Called when window has been moved the display server.
+        /// </summary>
+        /// <param name="x">The x of the has been moved window</param>
+        /// <param name="y">The y of the has been moved window</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual void OnMoveCompleted(int x, int y) {}
+
+        /// <summary>
+        /// Called when window has been resized the display server.
+        /// </summary>
+        /// <param name="width">The width of the resized window</param>
+        /// <param name="height">The height of the resized window</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual void OnResizeCompleted(int width, int height) {}
+
+        /// <summary>
+        /// Called when the window is maximized.
+        /// </summary>
+        /// <param name="isMaximized">If window is maximized or unmaximized.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual void OnMaximize(bool isMaximized)
         {
-            if (e.Touch.GetState(0) == PointStateType.Stationary && e.Touch.GetPointCount() == 2)
+            Tizen.Log.Info("NUI", $"OnMaximize {isMaximized}\n");
+            if (BorderWindow.IsMaximized() == true)
             {
-                if (isWinGestures == false && timer == null)
-                {
-                    timer = new Timer(300);
-                    timer.Tick += OnTick;
-                    timer.Start();
-                }
+                BorderWindow.SetTransparency(false);
             }
             else
             {
-                currentGesture = CurrentGesture.None;
-                if (timer != null)
-                {
-                    timer.Stop();
-                    timer.Dispose();
-                    timer = null;
-                }
+                BorderWindow.SetTransparency(true);
             }
-            return false;
-        }
 
-        // If two finger long press is done, create a windowView.
-        // then, Register a gesture on the windowView to do a resize or move.
-        private bool OnTick(object o, Timer.TickEventArgs e)
-        {
-            windowView = new View()
-            {
-                WidthResizePolicy = ResizePolicyType.FillToParent,
-                HeightResizePolicy = ResizePolicyType.FillToParent,
-                BackgroundColor = new Color(1, 1, 1, 0.5f),
-            };
-            windowView.TouchEvent += (s, e) =>
-            {
-                return true;
-            };
-            BorderWindow.Add(windowView);
-
-            winTapGestureDetector = new TapGestureDetector();
-            winTapGestureDetector.Attach(windowView);
-            winTapGestureDetector.SetMaximumTapsRequired(3);
-            winTapGestureDetector.Detected += OnWinTapGestureDetected;
-
-            winPanGestureDetector = new PanGestureDetector();
-            winPanGestureDetector.Attach(windowView);
-            winPanGestureDetector.Detected += OnWinPanGestureDetected;
-
-            BorderWindow.InterceptTouchEvent -= OnWinInterceptedTouch;
-            isWinGestures = true;
-            return false;
         }
 
-        // Behavior when the window is tapped.
-        private void OnWinTapGestureDetected(object source, TapGestureDetector.DetectedEventArgs e)
+        /// <summary>
+        /// Called when the window is minimized.
+        /// </summary>
+        /// <param name="isMinimized">If window is mnimized or unminimized.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual void OnMinimize(bool isMinimized)
         {
-          if (currentGesture <= CurrentGesture.TapGesture)
-          {
-              currentGesture = CurrentGesture.TapGesture;
-              if (e.TapGesture.NumberOfTaps == 2)
-              {
-                  if (BorderWindow.IsMaximized() == false)
-                  {
-                    BorderWindow.Maximize(true);
-                  }
-                  else
-                  {
-                    BorderWindow.Maximize(false);
-                  }
-              }
-              else
-              {
-                  ClearWindowGesture();
-              }
-          }
+            UpdateIcons();
         }
 
-        // Window moves through pan gestures.
-        private void OnWinPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e)
+        /// <summary>
+        /// Called when there is a change in overlay mode.
+        /// </summary>
+        /// <param name="enabled">If true, borderView has entered overlayMode.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual void OnOverlayMode(bool enabled)
         {
-            if (currentGesture <= CurrentGesture.PanGesture /*&& panGesture.NumberOfTouches == 1*/)
+            if (borderView != null && OverlayMode == true)
             {
-                PanGesture panGesture = e.PanGesture;
-
-                if (panGesture.State == Gesture.StateType.Started)
+                Tizen.Log.Info("NUI", $"OnOverlayMode {enabled}\n");
+                if (enabled == true)
                 {
-                    currentGesture = CurrentGesture.PanGesture;
-                    if (BorderWindow.IsMaximized() == true)
-                    {
-                        BorderWindow.Maximize(false);
-                    }
-                    else
+                    backgroundColor = new Color(borderView.BackgroundColor);
+                    if (string.IsNullOrEmpty(borderView.BackgroundImage))
                     {
-                        BorderWindow.RequestMoveToServer();
+                        borderView.BackgroundColor = Color.Transparent;
                     }
+                    borderView.Hide();
                 }
-                else if (panGesture.State == Gesture.StateType.Finished || panGesture.State == Gesture.StateType.Cancelled)
+                else
                 {
-                    currentGesture = CurrentGesture.None;
-                    ClearWindowGesture();
+                    if (string.IsNullOrEmpty(borderView.BackgroundImage))
+                    {
+                        borderView.BackgroundColor = backgroundColor;
+                    }
+                    borderView.Show();
                 }
             }
         }
 
-        private void ClearWindowGesture()
+        /// <summary>
+        /// Show the border when OverlayMode is true and the window is now Maximize.
+        /// </summary>
+        /// <param name="time">Time(ms) for borders to disappear again</param>
+        /// <returns>True if border became show, false otherwise</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public virtual bool OverlayBorderShow(uint time = 3000)
         {
-            if (isWinGestures)
+            if (BorderWindow != null && BorderWindow.IsMaximized())
             {
-                winPanGestureDetector.Dispose();
-                winTapGestureDetector.Dispose();
-
-                isWinGestures = false;
-                BorderWindow.Remove(windowView);
-                BorderWindow.InterceptTouchEvent += OnWinInterceptedTouch;
+                if (overlayTimer == null)
+                {
+                    overlayTimer = new Timer(time);
+                    overlayTimer.Tick += (s, e) =>
+                    {
+                        borderView?.Hide();
+                        overlayTimer?.Stop();
+                        overlayTimer?.Dispose();
+                        overlayTimer = null;
+                        return false;
+                    };
+                    overlayTimer.Start();
+                    borderView?.Show();
+                }
+                else
+                {
+                    overlayTimer.Start();
+                }
+                return true;
             }
+            return false;
         }
 
         /// <summary>
-        /// Called when requesting a resize
+        /// Hide the border when OverlayMode is true and the window is now Maximize.
         /// </summary>
+        /// <returns>True if border became hide, false otherwise</returns>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public virtual void OnRequestResize() {}
+        public virtual bool OverlayBorderHide()
+        {
+            if (BorderWindow != null && BorderWindow.IsMaximized())
+            {
+                borderView?.Hide();
+                overlayTimer?.Stop();
+                overlayTimer?.Dispose();
+                overlayTimer = null;
+                return true;
+            }
+            return false;
+        }
 
-        /// <summary>
-        /// Called when the window is resized.
-        /// </summary>
-        /// <param name="width">The width of the resized window</param>
-        /// <param name="height">The height of the resized window</param>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public virtual void OnResized(int width, int height)
+        public void Dispose()
         {
-            UpdateIcons();
+            Dispose(true);
+            global::System.GC.SuppressFinalize(this);
         }
 
-        [EditorBrowsable(EditorBrowsableState.Never)]
         protected virtual void Dispose(bool disposing)
         {
             if (disposed)
             {
                 return;
             }
+
             if (disposing)
             {
-                ClearWindowGesture();
-
-                if (BorderWindow != null)
-                {
-                    BorderWindow.InterceptTouchEvent -= OnWinInterceptedTouch;
-                }
-
+                borderView?.Dispose();
+                windowView?.Dispose();
                 borderPanGestureDetector?.Dispose();
-                borderPinchGestureDetector?.Dispose();
                 backgroundColor?.Dispose();
                 minimalizeIcon?.Dispose();
                 maximalizeIcon?.Dispose();
                 closeIcon?.Dispose();
                 leftCornerIcon?.Dispose();
                 rightCornerIcon?.Dispose();
-                timer?.Dispose();
-                windowView?.Dispose();
-                borderView?.Dispose();
+                overlayTimer?.Dispose();
             }
             disposed = true;
         }
 
-        /// <summary>
-        /// Dispose
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public void Dispose()
-        {
-            Dispose(true);
-            global::System.GC.SuppressFinalize(this);
-        }
         #endregion //Methods
 
     }