2 * Copyright(c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.ComponentModel;
20 using Tizen.NUI.BaseComponents;
21 using Tizen.NUI.Binding;
26 /// This class creates a border UI.
28 [EditorBrowsable(EditorBrowsableState.Never)]
29 public class DefaultBorder : BindableObject, IDisposable, IBorderInterface
31 #region Constant Fields
32 private static readonly string ResourcePath = FrameworkInformation.ResourcePath;
33 private static readonly string MinimalizeIcon = ResourcePath + "minimalize.png";
34 private static readonly string MaximalizeIcon = ResourcePath + "maximalize.png";
35 private static readonly string CloseIcon = ResourcePath + "close.png";
36 private static readonly string LeftCornerIcon = ResourcePath + "leftCorner.png";
37 private static readonly string RightCornerIcon = ResourcePath + "rightCorner.png";
39 private static readonly string DarkMinimalizeIcon = ResourcePath + "dark_minimalize.png";
40 private static readonly string DarkPreviousIcon = ResourcePath + "dark_smallwindow.png";
41 private static readonly string DarkCloseIcon = ResourcePath + "dark_close.png";
42 private static readonly string DarkLeftCornerIcon = ResourcePath + "dark_leftCorner.png";
43 private static readonly string DarkRightCornerIcon = ResourcePath + "dark_rightCorner.png";
46 private const float DefaultHeight = 50;
47 private const uint DefaultLineThickness = 5;
48 private const uint DefaultTouchThickness = 0;
49 private static readonly Color DefaultBackgroundColor = new Color(1, 1, 1, 0.3f);
50 private static readonly Color DefaultClickedBackgroundColor = new Color(1, 1, 1, 0.4f);
51 private static readonly Size2D DefaultMinSize = new Size2D(100, 0);
52 #endregion //Constant Fields
56 private bool disposed = false;
57 private Color backgroundColor;
58 private View borderView;
60 private ImageView minimalizeIcon;
61 private ImageView maximalizeIcon;
62 private ImageView closeIcon;
63 private ImageView leftCornerIcon;
64 private ImageView rightCornerIcon;
66 private Window.BorderDirection direction = Window.BorderDirection.None;
67 private float preScale = 0;
69 private View windowView = null;
70 private bool isWinGestures = false;
72 private Timer overlayTimer;
74 private CurrentGesture currentGesture = CurrentGesture.None;
76 private uint borderLineThickness;
77 private Size2D minSize;
78 private Size2D maxSize;
79 private Window.BorderResizePolicyType resizePolicy;
84 private PanGestureDetector borderPanGestureDetector;
85 private PinchGestureDetector borderPinchGestureDetector;
86 private PanGestureDetector winPanGestureDetector;
87 private TapGestureDetector winTapGestureDetector;
91 private enum CurrentGesture
102 [EditorBrowsable(EditorBrowsableState.Never)]
103 public static readonly BindableProperty BorderLineThicknessProperty = BindableProperty.Create(nameof(BorderLineThickness), typeof(uint), typeof(DefaultBorder), default(uint), propertyChanged: (bindable, oldValue, newValue) =>
105 var instance = (DefaultBorder)bindable;
106 if (newValue != null)
108 instance.borderLineThickness = (uint)newValue;
109 instance.UpdateProperty();
112 defaultValueCreator: (bindable) =>
114 var instance = (DefaultBorder)bindable;
115 return instance.borderLineThickness;
118 [EditorBrowsable(EditorBrowsableState.Never)]
119 public static readonly BindableProperty MinSizeProperty = BindableProperty.Create(nameof(MinSize), typeof(Size2D), typeof(DefaultBorder), default(Size2D), propertyChanged: (bindable, oldValue, newValue) =>
121 var instance = (DefaultBorder)bindable;
122 if (newValue != null)
124 instance.minSize = (Size2D)newValue;
125 instance.UpdateProperty();
128 defaultValueCreator: (bindable) =>
130 var instance = (DefaultBorder)bindable;
131 return instance.minSize;
134 [EditorBrowsable(EditorBrowsableState.Never)]
135 public static readonly BindableProperty MaxSizeProperty = BindableProperty.Create(nameof(MaxSize), typeof(Size2D), typeof(DefaultBorder), default(Size2D), propertyChanged: (bindable, oldValue, newValue) =>
137 var instance = (DefaultBorder)bindable;
138 if (newValue != null)
140 instance.maxSize = (Size2D)newValue;
141 instance.UpdateProperty();
144 defaultValueCreator: (bindable) =>
146 var instance = (DefaultBorder)bindable;
147 return instance.maxSize;
150 [EditorBrowsable(EditorBrowsableState.Never)]
151 public static readonly BindableProperty ResizePolicyProperty = BindableProperty.Create(nameof(ResizePolicy), typeof(Window.BorderResizePolicyType), typeof(DefaultBorder), default(Window.BorderResizePolicyType), propertyChanged: (bindable, oldValue, newValue) =>
153 var instance = (DefaultBorder)bindable;
154 if (newValue != null)
156 instance.resizePolicy = (Window.BorderResizePolicyType)newValue;
157 instance.UpdateProperty();
160 defaultValueCreator: (bindable) =>
162 var instance = (DefaultBorder)bindable;
163 return instance.resizePolicy;
168 /// The thickness of the border.
170 [EditorBrowsable(EditorBrowsableState.Never)]
171 public uint BorderLineThickness
175 return (uint)GetValue(BorderLineThicknessProperty);
179 SetValue(BorderLineThicknessProperty, value);
184 /// The thickness of the border's touch area.
186 [EditorBrowsable(EditorBrowsableState.Never)]
187 public uint TouchThickness {get; set;}
190 /// The height of the border.
191 /// This value is the initial value used when creating borders.
193 [EditorBrowsable(EditorBrowsableState.Never)]
194 public float BorderHeight {get; set;}
197 /// The minimum size by which the window will small.
199 [EditorBrowsable(EditorBrowsableState.Never)]
200 public Size2D MinSize
204 return (Size2D)GetValue(MinSizeProperty);
208 SetValue(MinSizeProperty, value);
213 /// The maximum size by which the window will big.
215 [EditorBrowsable(EditorBrowsableState.Never)]
216 public Size2D MaxSize
220 return (Size2D)GetValue(MaxSizeProperty);
224 SetValue(MaxSizeProperty, value);
229 /// The window with borders added.
231 [EditorBrowsable(EditorBrowsableState.Never)]
232 public Window BorderWindow {get; set;}
235 /// Whether overlay mode.
236 /// If overlay mode is true, the border area is hidden when the window is maximized.
237 /// And if you touched at screen, the border area is shown on the screen.
238 /// Default value is false;
240 [EditorBrowsable(EditorBrowsableState.Never)]
241 public bool OverlayMode {get; set;}
244 /// Set the window resizing policy.
245 /// Default value is BorderResizePolicyType.Free;
247 [EditorBrowsable(EditorBrowsableState.Never)]
248 public Window.BorderResizePolicyType ResizePolicy
252 return (Window.BorderResizePolicyType)GetValue(ResizePolicyProperty);
256 SetValue(ResizePolicyProperty, value);
261 /// Update properties
263 [EditorBrowsable(EditorBrowsableState.Never)]
264 public void UpdateProperty()
266 BorderWindow?.UpdateProperty();
270 /// Creates a default border
272 [EditorBrowsable(EditorBrowsableState.Never)]
273 public DefaultBorder() : base()
275 BorderLineThickness = DefaultLineThickness;
276 TouchThickness = DefaultTouchThickness;
277 BorderHeight = DefaultHeight;
278 MinSize = DefaultMinSize;
280 ResizePolicy = Window.BorderResizePolicyType.Free;
284 /// Create top border UI. User can override this method to draw top border UI.
286 /// <param name="topView">The top view on which the border.</param>
287 [EditorBrowsable(EditorBrowsableState.Never)]
288 public virtual bool CreateTopBorderView(View topView)
294 /// Create bottom border UI. User can override this method to draw bottom border UI.
296 /// <param name="bottomView">The bottom view on which the border.</param>
297 [EditorBrowsable(EditorBrowsableState.Never)]
298 public virtual bool CreateBottomBorderView(View bottomView)
300 if (bottomView == null)
304 bottomView.Layout = new RelativeLayout();
306 minimalizeIcon = new ImageView()
309 ResourceUrl = MinimalizeIcon,
310 AccessibilityHighlightable = true,
313 maximalizeIcon = new ImageView()
316 ResourceUrl = MaximalizeIcon,
317 AccessibilityHighlightable = true,
320 closeIcon = new ImageView()
323 ResourceUrl = CloseIcon,
324 AccessibilityHighlightable = true,
327 leftCornerIcon = new ImageView()
330 ResourceUrl = LeftCornerIcon,
331 AccessibilityHighlightable = true,
334 rightCornerIcon = new ImageView()
337 ResourceUrl = RightCornerIcon,
338 AccessibilityHighlightable = true,
341 RelativeLayout.SetRightTarget(minimalizeIcon, maximalizeIcon);
342 RelativeLayout.SetRightRelativeOffset(minimalizeIcon, 0.0f);
343 RelativeLayout.SetHorizontalAlignment(minimalizeIcon, RelativeLayout.Alignment.End);
344 RelativeLayout.SetRightTarget(maximalizeIcon, closeIcon);
345 RelativeLayout.SetRightRelativeOffset(maximalizeIcon, 0.0f);
346 RelativeLayout.SetHorizontalAlignment(maximalizeIcon, RelativeLayout.Alignment.End);
347 RelativeLayout.SetRightTarget(closeIcon, rightCornerIcon);
348 RelativeLayout.SetRightRelativeOffset(closeIcon, 0.0f);
349 RelativeLayout.SetHorizontalAlignment(closeIcon, RelativeLayout.Alignment.End);
350 RelativeLayout.SetRightRelativeOffset(rightCornerIcon, 1.0f);
351 RelativeLayout.SetHorizontalAlignment(rightCornerIcon, RelativeLayout.Alignment.End);
352 bottomView.Add(leftCornerIcon);
353 bottomView.Add(minimalizeIcon);
354 bottomView.Add(maximalizeIcon);
355 bottomView.Add(closeIcon);
356 bottomView.Add(rightCornerIcon);
359 minimalizeIcon.TouchEvent += OnMinimizeIconTouched;
360 maximalizeIcon.TouchEvent += OnMaximizeIconTouched;
361 closeIcon.TouchEvent += OnCloseIconTouched;
362 leftCornerIcon.TouchEvent += OnLeftBottomCornerIconTouched;
363 rightCornerIcon.TouchEvent += OnRightBottomCornerIconTouched;
365 minimalizeIcon.AccessibilityActivated += (s, e) =>
367 MinimizeBorderWindow();
369 maximalizeIcon.AccessibilityActivated += (s, e) =>
371 MaximizeBorderWindow();
373 closeIcon.AccessibilityActivated += (s, e) =>
378 minimalizeIcon.AccessibilityNameRequested += (s, e) =>
382 maximalizeIcon.AccessibilityNameRequested += (s, e) =>
386 closeIcon.AccessibilityNameRequested += (s, e) =>
390 leftCornerIcon.AccessibilityNameRequested += (s, e) =>
394 rightCornerIcon.AccessibilityNameRequested += (s, e) =>
399 minimalizeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
400 maximalizeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
401 closeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
402 leftCornerIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
403 rightCornerIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
410 /// Create border UI. User can override this method to draw border UI.
411 /// A top border and a bottom border are added to this view.
413 /// <param name="borderView">The root view on which the border.</param>
414 [EditorBrowsable(EditorBrowsableState.Never)]
415 public virtual void CreateBorderView(View borderView)
417 if (borderView == null)
422 if (string.IsNullOrEmpty(borderView.BackgroundImage))
424 borderView.BackgroundColor = DefaultBackgroundColor;
426 borderView.BorderlineColor = new Color(0.5f, 0.5f, 0.5f, 0.3f);
427 borderView.BorderlineWidth = 1.0f;
428 borderView.BorderlineOffset = -1f;
429 borderView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
430 borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
432 // Register touch event for effect when border is touched.
433 borderView.LeaveRequired = true;
434 borderView.TouchEvent += OnBorderViewTouched;
435 this.borderView = borderView;
438 private bool OnBorderViewTouched(object sender, View.TouchEventArgs e)
440 if (string.IsNullOrEmpty(borderView.BackgroundImage))
442 if (e.Touch.GetState(0) == PointStateType.Started)
444 backgroundColor = new Color(borderView.BackgroundColor);
445 borderView.BackgroundColor = DefaultClickedBackgroundColor;
447 else if (e.Touch.GetState(0) == PointStateType.Finished ||
448 e.Touch.GetState(0) == PointStateType.Leave ||
449 e.Touch.GetState(0) == PointStateType.Interrupted)
451 borderView.BackgroundColor = backgroundColor;
457 /// Determines the behavior of pinch gesture.
458 private void OnPinchGestureDetected(object source, PinchGestureDetector.DetectedEventArgs e)
464 if (e.PinchGesture.State == Gesture.StateType.Started)
466 preScale = e.PinchGesture.Scale;
468 else if (e.PinchGesture.State == Gesture.StateType.Finished || e.PinchGesture.State == Gesture.StateType.Cancelled)
470 if (preScale > e.PinchGesture.Scale)
472 if (BorderWindow.IsMaximized())
474 BorderWindow.Maximize(false);
478 BorderWindow.Minimize(true);
484 BorderWindow.Maximize(true);
489 /// Determines the behavior of borders.
490 private void OnPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e)
496 PanGesture panGesture = e.PanGesture;
498 if (panGesture.State == Gesture.StateType.Started && panGesture.Position != null)
500 direction = BorderWindow.GetDirection(panGesture.Position.X, panGesture.Position.Y);
502 if (direction == Window.BorderDirection.Move)
504 if (BorderWindow.IsMaximized() == true)
506 BorderWindow.Maximize(false);
511 BorderWindow.RequestMoveToServer();
514 else if (direction != Window.BorderDirection.None && ResizePolicy != Window.BorderResizePolicyType.Fixed)
517 BorderWindow.RequestResizeToServer((Window.ResizeDirection)direction);
520 else if (panGesture.State == Gesture.StateType.Finished || panGesture.State == Gesture.StateType.Cancelled)
522 direction = Window.BorderDirection.None;
523 ClearWindowGesture();
528 /// This is an event callback when the left top corner icon is touched.
530 [EditorBrowsable(EditorBrowsableState.Never)]
531 public virtual bool OnLeftTopCornerIconTouched(object sender, View.TouchEventArgs e)
533 SetDispatchParentGestureEvents(sender as View, false);
534 if (e != null && e.Touch.GetState(0) == PointStateType.Down)
536 ClearWindowGesture();
537 if (ResizePolicy != Window.BorderResizePolicyType.Fixed)
540 BorderWindow.RequestResizeToServer(Window.ResizeDirection.TopLeft);
547 ///This is an event callback when the right bottom corner icon is touched.
549 [EditorBrowsable(EditorBrowsableState.Never)]
550 public virtual bool OnRightTopCornerIconTouched(object sender, View.TouchEventArgs e)
552 SetDispatchParentGestureEvents(sender as View, false);
553 if (e != null && e.Touch.GetState(0) == PointStateType.Down)
555 ClearWindowGesture();
556 if (ResizePolicy != Window.BorderResizePolicyType.Fixed)
559 BorderWindow.RequestResizeToServer(Window.ResizeDirection.TopRight);
567 /// This is an event callback when the left bottom corner icon is touched.
569 [EditorBrowsable(EditorBrowsableState.Never)]
570 public virtual bool OnLeftBottomCornerIconTouched(object sender, View.TouchEventArgs e)
572 SetDispatchParentGestureEvents(sender as View, false);
573 if (e != null && e.Touch.GetState(0) == PointStateType.Down)
575 ClearWindowGesture();
576 if (ResizePolicy != Window.BorderResizePolicyType.Fixed)
579 BorderWindow.RequestResizeToServer(Window.ResizeDirection.BottomLeft);
586 ///This is an event callback when the right bottom corner icon is touched.
588 [EditorBrowsable(EditorBrowsableState.Never)]
589 public virtual bool OnRightBottomCornerIconTouched(object sender, View.TouchEventArgs e)
591 SetDispatchParentGestureEvents(sender as View, false);
592 if (e != null && e.Touch.GetState(0) == PointStateType.Down)
594 ClearWindowGesture();
595 if (ResizePolicy != Window.BorderResizePolicyType.Fixed)
598 BorderWindow.RequestResizeToServer(Window.ResizeDirection.BottomRight);
606 /// Minimize border window.
608 [EditorBrowsable(EditorBrowsableState.Never)]
609 protected void MinimizeBorderWindow()
611 ClearWindowGesture();
612 BorderWindow.Minimize(true);
617 /// This is an event callback when the minimize icon is touched.
619 [EditorBrowsable(EditorBrowsableState.Never)]
620 public virtual bool OnMinimizeIconTouched(object sender, View.TouchEventArgs e)
622 SetDispatchParentGestureEvents(sender as View, false);
623 if (e != null && e.Touch.GetState(0) == PointStateType.Up)
625 MinimizeBorderWindow();
631 /// Maximize border window.
633 [EditorBrowsable(EditorBrowsableState.Never)]
634 protected void MaximizeBorderWindow()
636 ClearWindowGesture();
637 if (BorderWindow.IsMaximized())
639 BorderWindow.Maximize(false);
643 BorderWindow.Maximize(true);
648 /// This is an event callback when the maximum icon is touched.
650 [EditorBrowsable(EditorBrowsableState.Never)]
651 public virtual bool OnMaximizeIconTouched(object sender, View.TouchEventArgs e)
653 SetDispatchParentGestureEvents(sender as View, false);
654 if (e != null && e.Touch.GetState(0) == PointStateType.Up)
656 MaximizeBorderWindow();
662 /// Close border window.
664 [EditorBrowsable(EditorBrowsableState.Never)]
665 protected void CloseBorderWindow()
668 BorderWindow.BorderDestroy();
672 /// This is an event callback when the close icon is touched.
674 [EditorBrowsable(EditorBrowsableState.Never)]
675 public virtual bool OnCloseIconTouched(object sender, View.TouchEventArgs e)
677 SetDispatchParentGestureEvents(sender as View, false);
678 if (e != null && e.Touch.GetState(0) == PointStateType.Up)
685 private void SetDispatchParentGestureEvents(View view, bool dispatch)
689 // If this is set, my parents will not receive gesture events.
690 // This is to prevent the move action by PanGesture when the icon is touched.
691 view.DispatchParentGestureEvents = dispatch;
696 private void UpdateIcons()
698 if (BorderWindow != null && borderView != null)
700 if (BorderWindow.IsMaximized() == true)
702 if (maximalizeIcon != null)
704 maximalizeIcon.ResourceUrl = DarkPreviousIcon;
706 if (minimalizeIcon != null)
708 minimalizeIcon.ResourceUrl = DarkMinimalizeIcon;
710 if (closeIcon != null)
712 closeIcon.ResourceUrl = DarkCloseIcon;
714 if (leftCornerIcon != null)
716 leftCornerIcon.ResourceUrl = DarkLeftCornerIcon;
718 if (rightCornerIcon != null)
720 rightCornerIcon.ResourceUrl = DarkRightCornerIcon;
722 borderView.CornerRadius = new Vector4(0, 0, 0, 0);
723 borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
727 if (maximalizeIcon != null)
729 maximalizeIcon.ResourceUrl = MaximalizeIcon;
731 if (minimalizeIcon != null)
733 minimalizeIcon.ResourceUrl = MinimalizeIcon;
735 if (closeIcon != null)
737 closeIcon.ResourceUrl = CloseIcon;
739 if (leftCornerIcon != null)
741 leftCornerIcon.ResourceUrl = LeftCornerIcon;
743 if (rightCornerIcon != null)
745 rightCornerIcon.ResourceUrl = RightCornerIcon;
747 borderView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
748 borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
754 /// Called after the border UI is created.
756 /// <param name="borderView">The border view on which the border.</param>
757 [EditorBrowsable(EditorBrowsableState.Never)]
758 public virtual void OnCreated(View borderView)
760 if (borderView == null)
764 this.borderView = borderView;
766 BorderWindow.BackgroundColor = Color.Transparent;
768 // Register to resize and move through pan gestures.
769 borderPanGestureDetector = new PanGestureDetector();
770 borderPanGestureDetector.Attach(borderView);
771 borderPanGestureDetector.Detected += OnPanGestureDetected;
773 borderPinchGestureDetector = new PinchGestureDetector();
774 borderPinchGestureDetector.Attach(borderView);
775 borderPinchGestureDetector.Detected += OnPinchGestureDetected;
778 AddInterceptGesture();
784 // Register an intercept touch event on the window.
785 private void AddInterceptGesture()
787 isWinGestures = false;
788 BorderWindow.InterceptTouchEvent += OnWinInterceptedTouch;
791 // Intercept touch on window.
792 private bool OnWinInterceptedTouch(object sender, Window.TouchEventArgs e)
794 if (e.Touch.GetState(0) == PointStateType.Stationary && e.Touch.GetPointCount() == 2)
796 if (isWinGestures == false && timer == null)
798 timer = new Timer(300);
799 timer.Tick += OnTick;
805 currentGesture = CurrentGesture.None;
816 // If two finger long press is done, create a windowView.
817 // then, Register a gesture on the windowView to do a resize or move.
818 private bool OnTick(object o, Timer.TickEventArgs e)
820 windowView = new View()
822 WidthResizePolicy = ResizePolicyType.FillToParent,
823 HeightResizePolicy = ResizePolicyType.FillToParent,
824 BackgroundColor = new Color(1, 1, 1, 0.5f),
826 windowView.TouchEvent += (s, e) =>
830 BorderWindow.Add(windowView);
832 winTapGestureDetector = new TapGestureDetector();
833 winTapGestureDetector.Attach(windowView);
834 winTapGestureDetector.SetMaximumTapsRequired(3);
835 winTapGestureDetector.Detected += OnWinTapGestureDetected;
837 winPanGestureDetector = new PanGestureDetector();
838 winPanGestureDetector.Attach(windowView);
839 winPanGestureDetector.Detected += OnWinPanGestureDetected;
841 BorderWindow.InterceptTouchEvent -= OnWinInterceptedTouch;
842 isWinGestures = true;
846 // Behavior when the window is tapped.
847 private void OnWinTapGestureDetected(object source, TapGestureDetector.DetectedEventArgs e)
849 if (currentGesture <= CurrentGesture.TapGesture)
851 currentGesture = CurrentGesture.TapGesture;
852 if (e.TapGesture.NumberOfTaps == 2)
854 if (BorderWindow.IsMaximized() == false)
856 BorderWindow.Maximize(true);
860 BorderWindow.Maximize(false);
865 ClearWindowGesture();
870 // Window moves through pan gestures.
871 private void OnWinPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e)
873 if (currentGesture <= CurrentGesture.PanGesture /*&& panGesture.NumberOfTouches == 1*/)
875 PanGesture panGesture = e.PanGesture;
877 if (panGesture.State == Gesture.StateType.Started)
879 currentGesture = CurrentGesture.PanGesture;
880 if (BorderWindow.IsMaximized() == true)
882 BorderWindow.Maximize(false);
887 BorderWindow.RequestMoveToServer();
890 else if (panGesture.State == Gesture.StateType.Finished || panGesture.State == Gesture.StateType.Cancelled)
892 currentGesture = CurrentGesture.None;
893 ClearWindowGesture();
898 private void ClearWindowGesture()
902 winPanGestureDetector.Dispose();
903 winTapGestureDetector.Dispose();
905 isWinGestures = false;
906 if (BorderWindow != null)
908 BorderWindow.Remove(windowView);
909 BorderWindow.InterceptTouchEvent += OnWinInterceptedTouch;
915 /// Called when requesting a resize
917 [EditorBrowsable(EditorBrowsableState.Never)]
918 public virtual void OnRequestResize() {}
921 /// Called when the window is resized.
923 /// <param name="width">The width of the resized window</param>
924 /// <param name="height">The height of the resized window</param>
925 [EditorBrowsable(EditorBrowsableState.Never)]
926 public virtual void OnResized(int width, int height)
928 if (overlayTimer != null)
931 overlayTimer.Dispose();
938 /// Called when requesting a move
940 [EditorBrowsable(EditorBrowsableState.Never)]
941 public virtual void OnRequestMove() {}
944 /// Called when the window is moved.
946 /// <param name="x">The x of the moved window</param>
947 /// <param name="y">The y of the moved window</param>
948 [EditorBrowsable(EditorBrowsableState.Never)]
949 public virtual void OnMoved(int x, int y) {}
952 /// Called when the window is maximized.
954 /// <param name="isMaximized">If window is maximized or unmaximized.</param>
955 [EditorBrowsable(EditorBrowsableState.Never)]
956 public virtual void OnMaximize(bool isMaximized)
958 Tizen.Log.Info("NUI", $"OnMaximize {isMaximized}\n");
959 if (BorderWindow.IsMaximized() == true)
961 BorderWindow.SetTransparency(false);
965 BorderWindow.SetTransparency(true);
971 /// Called when the window is minimized.
973 /// <param name="isMinimized">If window is mnimized or unminimized.</param>
974 [EditorBrowsable(EditorBrowsableState.Never)]
975 public virtual void OnMinimize(bool isMinimized)
981 /// Called when there is a change in overlay mode.
983 /// <param name="enabled">If true, borderView has entered overlayMode.</param>
984 [EditorBrowsable(EditorBrowsableState.Never)]
985 public virtual void OnOverlayMode(bool enabled)
987 if (borderView != null && OverlayMode == true)
989 Tizen.Log.Info("NUI", $"OnOverlayMode {enabled}\n");
992 backgroundColor = new Color(borderView.BackgroundColor);
993 if (string.IsNullOrEmpty(borderView.BackgroundImage))
995 borderView.BackgroundColor = Color.Transparent;
1001 if (string.IsNullOrEmpty(borderView.BackgroundImage))
1003 borderView.BackgroundColor = backgroundColor;
1011 /// Show the border when OverlayMode is true and the window is now Maximize.
1013 /// <param name="time">Time(ms) for borders to disappear again</param>
1014 /// <returns>True if border became show, false otherwise</returns>
1015 [EditorBrowsable(EditorBrowsableState.Never)]
1016 public virtual bool OverlayBorderShow(uint time = 3000)
1018 if (BorderWindow != null && BorderWindow.IsMaximized())
1020 if (overlayTimer == null)
1022 overlayTimer = new Timer(time);
1023 overlayTimer.Tick += (s, e) =>
1026 overlayTimer?.Stop();
1027 overlayTimer?.Dispose();
1028 overlayTimer = null;
1031 overlayTimer.Start();
1036 overlayTimer.Start();
1044 /// Hide the border when OverlayMode is true and the window is now Maximize.
1046 /// <returns>True if border became hide, false otherwise</returns>
1047 [EditorBrowsable(EditorBrowsableState.Never)]
1048 public virtual bool OverlayBorderHide()
1050 if (BorderWindow != null && BorderWindow.IsMaximized())
1053 overlayTimer?.Stop();
1054 overlayTimer?.Dispose();
1055 overlayTimer = null;
1061 [EditorBrowsable(EditorBrowsableState.Never)]
1062 public void Dispose()
1065 global::System.GC.SuppressFinalize(this);
1068 protected virtual void Dispose(bool disposing)
1077 ClearWindowGesture();
1079 if (BorderWindow != null)
1081 BorderWindow.InterceptTouchEvent -= OnWinInterceptedTouch;
1084 borderView?.Dispose();
1085 windowView?.Dispose();
1086 borderPanGestureDetector?.Dispose();
1087 borderPinchGestureDetector?.Dispose();
1088 backgroundColor?.Dispose();
1089 minimalizeIcon?.Dispose();
1090 maximalizeIcon?.Dispose();
1091 closeIcon?.Dispose();
1092 leftCornerIcon?.Dispose();
1093 rightCornerIcon?.Dispose();
1095 overlayTimer?.Dispose();
1100 #endregion //Methods