If you return true after overriding CreateTopBorderView(), the border UI is displayed at the top.
If you return true after overriding CreateBottomBorderView(), the border UI is displayed at the bottom.
```c#
public override bool CreateTopBorderView(View topView)
{
// Decorate the top view
return true;
}
public override bool CreateBottomBorderView(View bottomView)
{
// Decorate the bottom view
return true;
}
```
if (borderEnabled)
{
GetDefaultWindow().EnableBorder(borderInterface);
+ GetDefaultWindow().EnableFloatingMode(false);
}
}
// for border area
private View rootView = null;
+ private View borderView = null;
+ private View topView = null;
+ private View contentsView = null;
+ private View bottomView = null;
+ private bool isTop = false;
+ private bool isBottom = false;
+ uint borderHeight = 0;
#endregion //Fields
#region Constructors
GetDefaultLayer().Name = "OriginalRootLayer";
- Resized += OnBorderWindowResized;
-
- isBorderWindow = true;
-
- // The current window is as below
- // *****
- // *****
- // Increase the window size as much as the border area.
- // +++++++
- // +*****+
- // +*****+
- // +=====+
- // +=====+
- // '+' is BorderLineThickness
- // '=' is BorderHeight
- WindowSize += new Size2D((int)borderInterface.BorderLineThickness * 2, (int)(borderInterface.BorderHeight + borderInterface.BorderLineThickness));
-
- if (CreateBorder() == false)
- {
- WindowSize -= new Size2D((int)borderInterface.BorderLineThickness * 2, (int)(borderInterface.BorderHeight + borderInterface.BorderLineThickness));
- Resized -= OnBorderWindowResized;
- isBorderWindow = false;
- this.borderInterface = null;
- return false;
- }
+ if (CreateBorder() == true)
+ {
+ isBorderWindow = true;
+ Resized += OnBorderWindowResized;
- SetTransparency(true);
- BackgroundColor = Color.Transparent;
- borderInterface.BorderWindow = this;
+ // Increase the window size as much as the border area.
+ if (isTop) borderHeight += borderInterface.BorderHeight;
+ if (isBottom) borderHeight += borderInterface.BorderHeight;
+ WindowSize += new Size2D((int)borderInterface.BorderLineThickness * 2, (int)(borderHeight + borderInterface.BorderLineThickness * 2));
- EnableFloatingMode(true);
+ if (borderInterface.OverlayMode == true)
+ {
+ rootView.InterceptTouchEvent += OverlayInterceptTouch;
+ }
- borderInterface.OnCreated(rootView);
+ // Add a view to the border layer.
+ GetBorderWindowBottomLayer().Add(rootView);
+
+ SetTransparency(true);
+ BackgroundColor = Color.Transparent;
+ borderInterface.BorderWindow = this;
+
+ EnableFloatingMode(true);
+
+ borderInterface.OnCreated(borderView);
- return true;
+
+ return true;
+ }
+ else
+ {
+ this.borderInterface.Dispose();
+ return false;
+ }
}
/// Create the border UI.
BackgroundColor = Color.Transparent,
};
- // Gets the Border's UI.
- borderInterface.CreateBorderView(rootView);
- if (rootView == null)
+ ushort padding = (ushort) borderInterface.BorderLineThickness;
+ borderView = new View()
{
- return false;
- }
- else
+ WidthResizePolicy = ResizePolicyType.FillToParent,
+ HeightResizePolicy = ResizePolicyType.FillToParent,
+ BackgroundColor = Color.Transparent,
+ Layout = new LinearLayout() {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ LinearAlignment = LinearLayout.Alignment.Top
+ },
+ Padding = new Extents(padding, padding, padding, padding),
+ };
+ borderInterface.CreateBorderView(borderView);
+
+ topView = new View()
{
- if (borderInterface.OverlayMode == true)
- {
- rootView.InterceptTouchEvent += OverlayInterceptTouch;
- }
- // Add a view to the border layer.
- GetBorderWindowBottomLayer().Add(rootView);
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ SizeHeight = borderInterface.BorderHeight,
+ BackgroundColor = Color.Transparent,
+ };
- return true;
+ contentsView = new View()
+ {
+ BackgroundColor = Color.Transparent,
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ };
+
+ bottomView = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ SizeHeight = borderInterface.BorderHeight,
+ BackgroundColor = Color.Transparent,
+ };
+
+ // // Gets the Border's UI.
+ if (borderInterface.CreateTopBorderView(topView) == true && topView != null)
+ {
+ borderView.Add(topView);
+ isTop = true;
+ }
+ borderView.Add(contentsView);
+ if (borderInterface.CreateBottomBorderView(bottomView) == true && bottomView != null)
+ {
+ borderView.Add(bottomView);
+ isBottom = true;
}
+ rootView.Add(borderView);
+
+ return isTop || isBottom;
}
/// <summary>
BorderDirection direction = BorderDirection.None;
// check bottom left corner
- if (xPosition < borderInterface.TouchThickness && yPosition > WindowSize.Height + borderInterface.BorderHeight - borderInterface.TouchThickness)
+ if (xPosition < borderInterface.TouchThickness && yPosition > WindowSize.Height + borderHeight - borderInterface.TouchThickness)
{
direction = BorderDirection.BottomLeft;
}
// check bottom right corner
- else if (xPosition > WindowSize.Width + borderInterface.BorderLineThickness * 2 - borderInterface.TouchThickness && yPosition > WindowSize.Height + borderInterface.BorderHeight - borderInterface.TouchThickness)
+ else if (xPosition > WindowSize.Width + borderInterface.BorderLineThickness * 2 - borderInterface.TouchThickness && yPosition > WindowSize.Height + borderHeight - borderInterface.TouchThickness)
{
direction = BorderDirection.BottomRight;
}
direction = BorderDirection.Right;
}
// check bottom side
- else if (yPosition > WindowSize.Height + borderInterface.BorderHeight + borderInterface.BorderLineThickness - borderInterface.TouchThickness)
+ else if (yPosition > WindowSize.Height + borderHeight + borderInterface.BorderLineThickness - borderInterface.TouchThickness)
{
direction = BorderDirection.Bottom;
}
direction = BorderDirection.Top;
}
// check move
- else if (yPosition > WindowSize.Height)
+ else if ((yPosition > WindowSize.Height) || (isTop == true && yPosition < borderInterface.BorderHeight))
{
direction = BorderDirection.Move;
}
private bool OnTick(object o, Timer.TickEventArgs e)
{
GetBorderWindowBottomLayer().LowerToBottom();
- if (rootView != null)
+ if (borderView != null)
{
- rootView.Hide();
+ borderView.Hide();
}
isInterceptTouch = false;
overlayTimer.Tick += OnTick;
overlayTimer.Start();
GetBorderWindowBottomLayer().RaiseToTop();
- if (rootView != null)
+ if (borderView != null)
{
- rootView.Show();
+ borderView.Show();
}
isInterceptTouch = true;
}
if (enable == true)
{
InterceptTouchEvent += OnWinInterceptTouch;
- if (rootView != null)
+ if (borderView != null)
{
- overlayBackgroundColor = new Color(rootView.BackgroundColor);
- rootView.BackgroundColor = new Color(1, 1, 1, 0.3f);
- rootView.Hide();
+ overlayBackgroundColor = new Color(borderView.BackgroundColor);
+ borderView.BackgroundColor = Color.Transparent;
+ borderView.Hide();
}
}
else
isInterceptTouch = false;
InterceptTouchEvent -= OnWinInterceptTouch;
GetBorderWindowBottomLayer().LowerToBottom();
- if (rootView != null)
+ if (borderView != null)
{
- rootView.BackgroundColor = overlayBackgroundColor;
- rootView.Show();
+ borderView.BackgroundColor = overlayBackgroundColor;
+ borderView.Show();
}
}
}
WindowSize = new Size2D(resizeWidth, resizeHeight);
}
+ borderInterface.OnResized(resizeWidth, resizeHeight);
+
if (borderInterface.OverlayMode == true && IsMaximized() == true)
{
Interop.ActorInternal.SetSize(GetBorderWindowRootLayer().SwigCPtr, resizeWidth, resizeHeight);
Interop.ActorInternal.SetSize(GetBorderWindowBottomLayer().SwigCPtr, resizeWidth, resizeHeight);
+ Interop.ActorInternal.SetPosition(GetBorderWindowRootLayer().SwigCPtr, 0, 0);
+ if (contentsView != null)
+ {
+ contentsView.SizeHeight = resizeHeight - borderHeight - borderInterface.BorderLineThickness * 2;
+ }
OverlayMode(true);
}
else
{
+ uint height = (isTop == true) ? borderInterface.BorderHeight : 0;
Interop.ActorInternal.SetSize(GetBorderWindowRootLayer().SwigCPtr, resizeWidth, resizeHeight);
- Interop.ActorInternal.SetSize(GetBorderWindowBottomLayer().SwigCPtr, resizeWidth + borderInterface.BorderLineThickness * 2, resizeHeight+borderInterface.BorderHeight + borderInterface.BorderLineThickness);
+ Interop.ActorInternal.SetSize(GetBorderWindowBottomLayer().SwigCPtr, resizeWidth + borderInterface.BorderLineThickness * 2, resizeHeight + borderHeight + borderInterface.BorderLineThickness * 2);
+ Interop.ActorInternal.SetPosition(GetBorderWindowRootLayer().SwigCPtr, 0, height + borderInterface.BorderLineThickness);
+ if (contentsView != null)
+ {
+ contentsView.SizeHeight = resizeHeight;
+ }
OverlayMode(false);
}
- borderInterface.OnResized(resizeWidth, resizeHeight);
-
if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); }
}
Interop.ActorInternal.SetParentOrigin(borderWindowBottomLayer.SwigCPtr, topCentor.SwigCPtr);
Interop.Actor.SetAnchorPoint(borderWindowBottomLayer.SwigCPtr, topCentor.SwigCPtr);
Interop.Actor.Add(rootLayer.SwigCPtr, borderWindowBottomLayer.SwigCPtr);
- Interop.ActorInternal.SetSize(borderWindowBottomLayer.SwigCPtr, WindowSize.Width+borderInterface.BorderLineThickness * 2, WindowSize.Height + borderInterface.BorderLineThickness);
+ Interop.ActorInternal.SetSize(borderWindowBottomLayer.SwigCPtr, WindowSize.Width + borderInterface.BorderLineThickness * 2, WindowSize.Height + borderInterface.BorderLineThickness * 2);
borderWindowBottomLayer.SetWindow(this);
borderWindowBottomLayer.LowerToBottom();
Interop.ActorInternal.SetParentOrigin(borderWindowRootLayer.SwigCPtr, topCentor.SwigCPtr);
Interop.Actor.SetAnchorPoint(borderWindowRootLayer.SwigCPtr, topCentor.SwigCPtr);
Interop.Actor.Add(rootLayer.SwigCPtr, borderWindowRootLayer.SwigCPtr);
- Interop.ActorInternal.SetSize(borderWindowRootLayer.SwigCPtr, WindowSize.Width, WindowSize.Height-borderInterface.BorderHeight - borderInterface.BorderLineThickness);
- Interop.ActorInternal.SetPosition(borderWindowRootLayer.SwigCPtr, 0, borderInterface.BorderLineThickness);
- Tizen.NUI.Object.SetProperty(borderWindowRootLayer.SwigCPtr, Tizen.NUI.BaseComponents.View.Property.ClippingMode, new Tizen.NUI.PropertyValue((int)Tizen.NUI.ClippingModeType.ClipToBoundingBox));
+ Interop.ActorInternal.SetSize(borderWindowRootLayer.SwigCPtr, WindowSize.Width, WindowSize.Height - borderHeight - borderInterface.BorderLineThickness * 2);
+ uint height = (isTop == true) ? borderInterface.BorderHeight : 0;
+ Interop.ActorInternal.SetPosition(borderWindowRootLayer.SwigCPtr, 0, height + borderInterface.BorderLineThickness);
+ using PropertyValue propertyValue = new Tizen.NUI.PropertyValue((int)Tizen.NUI.ClippingModeType.ClipToBoundingBox);
+ Tizen.NUI.Object.SetProperty(borderWindowRootLayer.SwigCPtr, Tizen.NUI.BaseComponents.View.Property.ClippingMode, propertyValue);
if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); }
}
internal void DisposeBorder()
{
Resized -= OnBorderWindowResized;
- if (borderInterface.OverlayMode == true && rootView != null)
+ if (borderInterface.OverlayMode == true)
{
- rootView.InterceptTouchEvent -= OverlayInterceptTouch;
+ OverlayMode(false);
}
borderInterface.Dispose();
GetBorderWindowBottomLayer().Dispose();
{
if (isBorderWindow == true)
{
- var height = (ushort)(size.GetHeight() + borderInterface.BorderHeight + borderInterface.BorderLineThickness);
+ var height = (ushort)(size.GetHeight() + borderHeight + borderInterface.BorderLineThickness * 2);
var width = (ushort)(size.GetWidth() + borderInterface.BorderLineThickness * 2);
size.SetHeight(height);
size.SetWidth(width);
{
if (isBorderWindow == true && !(borderInterface.OverlayMode == true && IsMaximized() == true))
{
- var height = (ushort)(size.GetHeight() - borderInterface.BorderHeight - borderInterface.BorderLineThickness);
+ var height = (ushort)(size.GetHeight() - borderHeight - borderInterface.BorderLineThickness * 2);
var width = (ushort)(size.GetWidth() - borderInterface.BorderLineThickness * 2);
size.SetHeight(height);
size.SetWidth(width);
#region Fields
private Color backgroundColor;
- private View rootView;
private View borderView;
private ImageView minimalizeIcon;
[EditorBrowsable(EditorBrowsableState.Never)]
public bool OverlayMode {get; set;}
+
+ /// <summary>
+ /// Creates a default border
+ /// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public DefaultBorder()
{
OverlayMode = false;
}
+ /// <summary>
+ /// Create top border UI. User can override this method to draw top border UI.
+ /// </summary>
+ /// <param name="topView">The top view on which the border.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual bool CreateTopBorderView(View topView)
+ {
+ return false;
+ }
/// <summary>
- /// Create border UI. Users can override this method to draw border UI.
+ /// Create bottom border UI. User can override this method to draw bottom border UI.
/// </summary>
+ /// <param name="bottomView">The bottom view on which the border.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
- public virtual void CreateBorderView(View rootView)
+ public virtual bool CreateBottomBorderView(View bottomView)
{
- if (rootView == null)
+ if (bottomView == null)
{
- return;
+ return false;
}
- this.rootView = rootView;
- rootView.BackgroundColor = DefaultBackgroundColor;
- rootView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
- rootView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
-
- borderView = new View()
- {
- Layout = new LinearLayout()
- {
- LinearAlignment = LinearLayout.Alignment.End,
- LinearOrientation = LinearLayout.Orientation.Horizontal,
- },
- WidthSpecification = LayoutParamPolicies.MatchParent,
- HeightSpecification = LayoutParamPolicies.MatchParent,
- };
+ bottomView.Layout = new RelativeLayout();
minimalizeIcon = new ImageView()
{
ResourceUrl = MinimalizeIcon,
- PositionUsesPivotPoint = true,
- PivotPoint = PivotPoint.BottomLeft,
- ParentOrigin = ParentOrigin.BottomLeft,
};
maximalizeIcon = new ImageView()
{
ResourceUrl = MaximalizeIcon,
- PositionUsesPivotPoint = true,
- PivotPoint = PivotPoint.BottomLeft,
- ParentOrigin = ParentOrigin.BottomLeft,
};
closeIcon = new ImageView()
{
ResourceUrl = CloseIcon,
- PositionUsesPivotPoint = true,
- PivotPoint = PivotPoint.BottomLeft,
- ParentOrigin = ParentOrigin.BottomLeft,
};
leftCornerIcon = new ImageView()
{
ResourceUrl = LeftCornerIcon,
- PositionUsesPivotPoint = true,
- PivotPoint = PivotPoint.BottomLeft,
- ParentOrigin = ParentOrigin.BottomLeft,
};
rightCornerIcon = new ImageView()
{
ResourceUrl = RightCornerIcon,
- PositionUsesPivotPoint = true,
- PivotPoint = PivotPoint.BottomLeft,
- ParentOrigin = ParentOrigin.BottomLeft,
};
- rootView.Add(leftCornerIcon);
- borderView.Add(minimalizeIcon);
- borderView.Add(maximalizeIcon);
- borderView.Add(closeIcon);
- borderView.Add(rightCornerIcon);
- rootView.Add(borderView);
+ RelativeLayout.SetRightTarget(minimalizeIcon, maximalizeIcon);
+ RelativeLayout.SetRightRelativeOffset(minimalizeIcon, 0.0f);
+ RelativeLayout.SetHorizontalAlignment(minimalizeIcon, RelativeLayout.Alignment.End);
+ RelativeLayout.SetRightTarget(maximalizeIcon, closeIcon);
+ RelativeLayout.SetRightRelativeOffset(maximalizeIcon, 0.0f);
+ RelativeLayout.SetHorizontalAlignment(maximalizeIcon, RelativeLayout.Alignment.End);
+ RelativeLayout.SetRightTarget(closeIcon, rightCornerIcon);
+ RelativeLayout.SetRightRelativeOffset(closeIcon, 0.0f);
+ RelativeLayout.SetHorizontalAlignment(closeIcon, RelativeLayout.Alignment.End);
+ RelativeLayout.SetRightRelativeOffset(rightCornerIcon, 1.0f);
+ RelativeLayout.SetHorizontalAlignment(rightCornerIcon, RelativeLayout.Alignment.End);
+ bottomView.Add(leftCornerIcon);
+ bottomView.Add(minimalizeIcon);
+ bottomView.Add(maximalizeIcon);
+ bottomView.Add(closeIcon);
+ bottomView.Add(rightCornerIcon);
+
minimalizeIcon.TouchEvent += OnMinimizeIconTouched;
maximalizeIcon.TouchEvent += OnMaximizeIconTouched;
closeIcon.TouchEvent += OnCloseIconTouched;
- leftCornerIcon.TouchEvent += OnLeftCornerIconTouched;
- rightCornerIcon.TouchEvent += OnRightCornerIconTouched;
+ leftCornerIcon.TouchEvent += OnLeftBottomCornerIconTouched;
+ rightCornerIcon.TouchEvent += OnRightBottomCornerIconTouched;
+ return true;
+ }
+
+
+ /// <summary>
+ /// Create border UI. User can override this method to draw border UI.
+ /// A top border and a bottom border are added to this view.
+ /// </summary>
+ /// <param name="borderView">The root view on which the border.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual void CreateBorderView(View borderView)
+ {
+ if (borderView == null)
+ {
+ return;
+ }
+ this.borderView = borderView;
+ borderView.BackgroundColor = DefaultBackgroundColor;
+ borderView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
+ borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
}
/// Determines the behavior of pinch gesture.
if (panGesture.State == Gesture.StateType.Started && panGesture.Position != null)
{
direction = BorderWindow.GetDirection(panGesture.Position.X, panGesture.Position.Y);
+
if (direction == Window.BorderDirection.Move)
{
if (BorderWindow.IsMaximized() == true)
BorderWindow.RequestResizeToServer((Window.ResizeDirection)direction);
}
}
- else if (panGesture.State == Gesture.StateType.Continuing)
- {
- if (direction == Window.BorderDirection.BottomLeft || direction == Window.BorderDirection.BottomRight || direction == Window.BorderDirection.TopLeft || direction == Window.BorderDirection.TopRight)
- {
- BorderWindow.WindowSize += new Size2D((int)panGesture.ScreenDisplacement.X, (int)panGesture.ScreenDisplacement.Y);
- }
- else if (direction == Window.BorderDirection.Left || direction == Window.BorderDirection.Right)
- {
- BorderWindow.WindowSize += new Size2D((int)panGesture.ScreenDisplacement.X, 0);
- }
- else if (direction == Window.BorderDirection.Bottom || direction == Window.BorderDirection.Top)
- {
- BorderWindow.WindowSize += new Size2D(0, (int)panGesture.ScreenDisplacement.Y);
- }
- else if (direction == Window.BorderDirection.Move)
- {
- BorderWindow.WindowPosition += new Position2D((int)panGesture.ScreenDisplacement.X, (int)panGesture.ScreenDisplacement.Y);
- }
- }
else if (panGesture.State == Gesture.StateType.Finished || panGesture.State == Gesture.StateType.Cancelled)
{
direction = Window.BorderDirection.None;
}
}
+ /// <summary>
+ /// This is an event callback when the left top corner icon is touched.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual bool OnLeftTopCornerIconTouched(object sender, View.TouchEventArgs e)
+ {
+ if (e == null)
+ {
+ return false;
+ }
+ if (e.Touch.GetState(0) == PointStateType.Down)
+ {
+ ClearWindowGesture();
+ OnRequestResize();
+ BorderWindow.RequestResizeToServer(Window.ResizeDirection.TopLeft);
+ }
+ return true;
+ }
/// <summary>
- /// This is an event callback when the left corner icon is touched.
+ ///This is an event callback when the right bottom corner icon is touched.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public virtual bool OnLeftCornerIconTouched(object sender, View.TouchEventArgs e)
+ public virtual bool OnRightTopCornerIconTouched(object sender, View.TouchEventArgs e)
+ {
+ if (e == null)
+ {
+ return false;
+ }
+ if (e.Touch.GetState(0) == PointStateType.Down)
+ {
+ ClearWindowGesture();
+ OnRequestResize();
+ BorderWindow.RequestResizeToServer(Window.ResizeDirection.TopRight);
+ }
+ return true;
+ }
+
+
+ /// <summary>
+ /// This is an event callback when the left bottom corner icon is touched.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public virtual bool OnLeftBottomCornerIconTouched(object sender, View.TouchEventArgs e)
{
if (e == null)
{
}
/// <summary>
- ///This is an event callback when the right corner icon is touched.
+ ///This is an event callback when the right bottom corner icon is touched.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public virtual bool OnRightCornerIconTouched(object sender, View.TouchEventArgs e)
+ public virtual bool OnRightBottomCornerIconTouched(object sender, View.TouchEventArgs e)
{
if (e == null)
{
/// <summary>
- /// This is an event callback when the minimize button is touched.
+ /// This is an event callback when the minimize icon is touched.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual bool OnMinimizeIconTouched(object sender, View.TouchEventArgs e)
}
/// <summary>
- /// This is an event callback when the maximum button is touched.
+ /// This is an event callback when the maximum icon is touched.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual bool OnMaximizeIconTouched(object sender, View.TouchEventArgs e)
}
/// <summary>
- /// This is an event callback when the close button is touched.
+ /// This is an event callback when the close icon is touched.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual bool OnCloseIconTouched(object sender, View.TouchEventArgs e)
private void UpdateIcons()
{
- if (BorderWindow != null && rootView != null)
+ if (BorderWindow != null && borderView != null)
{
if (BorderWindow.IsMaximized() == true)
{
{
rightCornerIcon.ResourceUrl = DarkRightCornerIcon;
}
- rootView.CornerRadius = new Vector4(0, 0, 0, 0);
- rootView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
+ borderView.CornerRadius = new Vector4(0, 0, 0, 0);
+ borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
BorderWindow.SetTransparency(false);
}
else
{
rightCornerIcon.ResourceUrl = RightCornerIcon;
}
- rootView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
- rootView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
+ 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>
- /// <param name="rootView">The root view on which the border.</param>
+ /// <param name="borderView">The border view on which the border.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
- public virtual void OnCreated(View rootView)
+ public virtual void OnCreated(View borderView)
{
- if (rootView == null)
+ if (borderView == null)
{
return;
}
// Register to resize and move through pan gestures.
borderPanGestureDetector = new PanGestureDetector();
- borderPanGestureDetector.Attach(rootView);
+ borderPanGestureDetector.Attach(borderView);
borderPanGestureDetector.Detected += OnPanGestureDetected;
// Register touch event for effect when border is touched.
- rootView.LeaveRequired = true;
- rootView.TouchEvent += (s, e) =>
+ borderView.LeaveRequired = true;
+ borderView.TouchEvent += (s, e) =>
{
if (e.Touch.GetState(0) == PointStateType.Started)
{
- backgroundColor = new Color(rootView.BackgroundColor);
- rootView.BackgroundColor = DefaultClickedBackgroundColor;
+ 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)
{
- rootView.BackgroundColor = backgroundColor;
+ borderView.BackgroundColor = backgroundColor;
}
return true;
};
borderPinchGestureDetector = new PinchGestureDetector();
- borderPinchGestureDetector.Attach(rootView);
+ borderPinchGestureDetector.Attach(borderView);
borderPinchGestureDetector.Detected += OnPinchGestureDetected;
AddInterceptGesture();
/// Called when requesting a resize
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public virtual void OnRequestResize()
- {
- }
+ public virtual void OnRequestResize() {}
/// <summary>
/// Called when the window is resized.
{
ClearWindowGesture();
- BorderWindow.InterceptTouchEvent -= OnWinInterceptedTouch;
+ if (BorderWindow != null)
+ {
+ BorderWindow.InterceptTouchEvent -= OnWinInterceptedTouch;
+ }
borderPanGestureDetector?.Dispose();
borderPinchGestureDetector?.Dispose();
timer?.Dispose();
windowView?.Dispose();
borderView?.Dispose();
- rootView?.Dispose();
}
disposed = true;
}
[EditorBrowsable(EditorBrowsableState.Never)]
public bool OverlayMode {get;}
+ /// <summary>
+ /// Create top border UI. User can override this method to draw top border UI.
+ /// </summary>
+ /// <param name="topView">The top view on which the border.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool CreateTopBorderView(View topView);
+
+ /// <summary>
+ /// Create bottom border UI. User can override this method to draw bottom border UI.
+ /// </summary>
+ /// <param name="bottomView">The bottom view on which the border.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool CreateBottomBorderView(View bottomView);
/// <summary>
/// Create border UI. User can override this method to draw border UI.
+ /// A top border and a bottom border are added to this view.
/// </summary>
- /// <param name="rootView">The root view on which the border.</param>
+ /// <param name="borderView">The border view on which the border.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
- public void CreateBorderView(View rootView);
+ public void CreateBorderView(View borderView);
/// <summary>
/// Called after the border UI is created.
/// </summary>
- /// <param name="rootView">The root view on which the border.</param>
+ /// <param name="borderView">The border view on which the border.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
- public void OnCreated(View rootView);
+ public void OnCreated(View borderView);
/// <summary>
/// Called when requesting a resize
"hbo", "linkedin", "youtube"
};
- class TestWindow : DefaultBorder
- {
- public override void CreateBorderView(View rootView)
- {
- rootView.BackgroundColor = Color.Red;
- rootView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
- rootView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
-
-
- View borderView = new View()
- {
- Layout = new LinearLayout()
- {
- LinearOrientation = LinearLayout.Orientation.Horizontal,
- },
- WidthSpecification = LayoutParamPolicies.MatchParent,
- HeightSpecification = LayoutParamPolicies.MatchParent,
- };
-
- var minimalizeIcon = new Button()
- {
- Text = "min",
- PositionUsesPivotPoint = true,
- PivotPoint = PivotPoint.BottomLeft,
- ParentOrigin = ParentOrigin.BottomLeft,
- };
-
- var maximalizeIcon = new Button()
- {
- Text = "Max",
- PositionUsesPivotPoint = true,
- PivotPoint = PivotPoint.BottomLeft,
- ParentOrigin = ParentOrigin.BottomLeft,
- };
-
- var closeIcon = new Button()
- {
- Text = "Close",
- PositionUsesPivotPoint = true,
- PivotPoint = PivotPoint.BottomLeft,
- ParentOrigin = ParentOrigin.BottomLeft,
- };
-
- borderView.Add(minimalizeIcon);
- borderView.Add(maximalizeIcon);
- borderView.Add(closeIcon);
- rootView.Add(borderView);
-
- minimalizeIcon.TouchEvent += OnMinimizeIconTouched;
- maximalizeIcon.TouchEvent += OnMaximizeIconTouched;
- closeIcon.TouchEvent += OnCloseIconTouched;
- }
- }
-
View CreateItem(string file, string name)
{
var itemView = new View()
class CustomBorder : DefaultBorder
{
+ private static readonly string ResourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
+ private static readonly string MinimalizeIcon = ResourcePath + "/images/minimalize.png";
+ private static readonly string MaximalizeIcon = ResourcePath + "/images/maximalize.png";
+ private static readonly string RestoreIcon = ResourcePath + "/images/smallwindow.png";
+ private static readonly string CloseIcon = ResourcePath + "/images/close.png";
+ private static readonly string LeftCornerIcon = ResourcePath + "/images/leftCorner.png";
+ private static readonly string RightCornerIcon = ResourcePath + "/images/rightCorner.png";
+
private int width = 500;
private bool hide = false;
- private View rootView;
private View borderView;
private TextLabel title;
+ private ImageView minimalizeIcon;
+ private ImageView maximalizeIcon;
+ private ImageView closeIcon;
+ private ImageView leftCornerIcon;
+ private ImageView rightCornerIcon;
+
+ private Rectangle preWinPositonSize;
+
public CustomBorder() : base()
{
- BorderHeight = 60;
+ BorderHeight = 50;
+ OverlayMode = true;
+ BorderLineThickness = 0;
}
- public override void CreateBorderView(View rootView)
+ public override bool CreateTopBorderView(View topView)
{
- this.rootView = rootView;
- rootView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
- rootView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
+ if (topView == null)
+ {
+ return false;
+ }
+ title = new TextLabel()
+ {
+ Text = "CustomBorder",
+ Position = new Position(20, 0),
+ };
+ topView.Add(title);
+ return true;
+ }
- borderView = new View()
- {
- Layout = new LinearLayout()
- {
- LinearAlignment = LinearLayout.Alignment.End,
- LinearOrientation = LinearLayout.Orientation.Horizontal,
- },
- WidthSpecification = LayoutParamPolicies.MatchParent,
- HeightSpecification = LayoutParamPolicies.MatchParent,
- };
- title = new TextLabel()
- {
- Text = "CustomBorder",
- Size = new Size(300, 50),
- Position = new Position(60, 0),
- PositionUsesPivotPoint = true,
- PivotPoint = PivotPoint.BottomLeft,
- ParentOrigin = ParentOrigin.BottomLeft,
- };
-
- var minimalizeIcon = new Button()
- {
- Text = "m",
- PositionUsesPivotPoint = true,
- PivotPoint = PivotPoint.BottomLeft,
- ParentOrigin = ParentOrigin.BottomLeft,
- Size = new Size(50, 50),
- };
-
- var maximalizeIcon = new Button()
- {
- Text = "M",
- PositionUsesPivotPoint = true,
- PivotPoint = PivotPoint.BottomLeft,
- ParentOrigin = ParentOrigin.BottomLeft,
- Size = new Size(50, 50),
- };
-
- var closeIcon = new Button()
- {
- Text = "C",
- PositionUsesPivotPoint = true,
- PivotPoint = PivotPoint.BottomLeft,
- ParentOrigin = ParentOrigin.BottomLeft,
- Size = new Size(50, 50),
- };
+ public override bool CreateBottomBorderView(View bottomView)
+ {
+ if (bottomView == null)
+ {
+ return false;
+ }
+ bottomView.Layout = new RelativeLayout();
+ minimalizeIcon = new ImageView()
+ {
+ ResourceUrl = MinimalizeIcon,
+ };
- var leftPadding = new View()
- {
- PositionUsesPivotPoint = true,
- PivotPoint = PivotPoint.BottomLeft,
- ParentOrigin = ParentOrigin.BottomLeft,
- Size = new Size(50, 50),
- };
+ maximalizeIcon = new ImageView()
+ {
+ ResourceUrl = MaximalizeIcon,
+ };
- var rightPadding = new View()
- {
- PositionUsesPivotPoint = true,
- PivotPoint = PivotPoint.BottomLeft,
- ParentOrigin = ParentOrigin.BottomLeft,
- Size = new Size(50, 50),
- };
-
- rootView.Add(leftPadding);
- rootView.Add(title);
- borderView.Add(minimalizeIcon);
- borderView.Add(maximalizeIcon);
- borderView.Add(closeIcon);
- borderView.Add(rightPadding);
- rootView.Add(borderView);
-
- minimalizeIcon.TouchEvent += OnMinimizeIconTouched;
- maximalizeIcon.TouchEvent += OnMaximizeIconTouched;
- closeIcon.TouchEvent += OnCloseIconTouched;
- leftPadding.TouchEvent += OnLeftCornerIconTouched;
- rightPadding.TouchEvent += OnRightCornerIconTouched;
+ closeIcon = new ImageView()
+ {
+ ResourceUrl = CloseIcon,
+ };
+
+ leftCornerIcon = new ImageView()
+ {
+ ResourceUrl = LeftCornerIcon,
+ };
+
+ rightCornerIcon = new ImageView()
+ {
+ ResourceUrl = RightCornerIcon,
+ };
+
+ RelativeLayout.SetRightTarget(minimalizeIcon, maximalizeIcon);
+ RelativeLayout.SetRightRelativeOffset(minimalizeIcon, 0.0f);
+ RelativeLayout.SetHorizontalAlignment(minimalizeIcon, RelativeLayout.Alignment.End);
+ RelativeLayout.SetRightTarget(maximalizeIcon, closeIcon);
+ RelativeLayout.SetRightRelativeOffset(maximalizeIcon, 0.0f);
+ RelativeLayout.SetHorizontalAlignment(maximalizeIcon, RelativeLayout.Alignment.End);
+ RelativeLayout.SetRightTarget(closeIcon, rightCornerIcon);
+ RelativeLayout.SetRightRelativeOffset(closeIcon, 0.0f);
+ RelativeLayout.SetHorizontalAlignment(closeIcon, RelativeLayout.Alignment.End);
+ RelativeLayout.SetRightRelativeOffset(rightCornerIcon, 1.0f);
+ RelativeLayout.SetHorizontalAlignment(rightCornerIcon, RelativeLayout.Alignment.End);
+ bottomView.Add(leftCornerIcon);
+ bottomView.Add(minimalizeIcon);
+ bottomView.Add(maximalizeIcon);
+ bottomView.Add(closeIcon);
+ bottomView.Add(rightCornerIcon);
+
+
+ minimalizeIcon.TouchEvent += OnMinimizeIconTouched;
+ maximalizeIcon.TouchEvent += OnMaximizeIconTouched;
+ closeIcon.TouchEvent += OnCloseIconTouched;
+ leftCornerIcon.TouchEvent += OnLeftBottomCornerIconTouched;
+ rightCornerIcon.TouchEvent += OnRightBottomCornerIconTouched;
+ return true;
+ }
+
+ public override void CreateBorderView(View borderView)
+ {
+ this.borderView = borderView;
+ borderView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
+ borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
+ borderView.BackgroundColor = new Color(1, 1, 1, 0.3f);
}
- public override void OnCreated(View rootView)
+ public override void OnCreated(View borderView)
{
- base.OnCreated(rootView);
+ base.OnCreated(borderView);
}
- public override bool OnCloseIconTouched(object sender, View.TouchEventArgs e)
+ public override bool OnCloseIconTouched(object sender, View.TouchEventArgs e)
{
base.OnCloseIconTouched(sender, e);
return true;
}
- public override bool OnMinimizeIconTouched(object sender, View.TouchEventArgs e)
+ public override bool OnMinimizeIconTouched(object sender, View.TouchEventArgs e)
{
- base.OnMinimizeIconTouched(sender, e);
+ if (e.Touch.GetState(0) == PointStateType.Up)
+ {
+ if (BorderWindow.IsMaximized() == true)
+ {
+ BorderWindow.Maximize(false);
+ }
+ preWinPositonSize = BorderWindow.WindowPositionSize;
+ BorderWindow.WindowPositionSize = new Rectangle(preWinPositonSize.X, preWinPositonSize.Y, 500, 0);
+ }
return true;
}
+ public override void OnRequestResize()
+ {
+ if (borderView != null)
+ {
+ borderView.BackgroundColor = new Color(0, 1, 0, 0.3f); // 보더의 배경을 변경할 수 있습니다.
+ }
+ }
+
public override void OnResized(int width, int height)
{
- if (rootView != null)
+ if (borderView != null)
{
if (this.width > width && hide == false)
{
title.Show();
hide = false;
}
+ borderView.BackgroundColor = new Color(1, 1, 1, 0.3f); // 리사이즈가 끝나면 보더의 색깔은 원래대로 돌려놓습니다.
base.OnResized(width, height);
+ UpdateIcons();
+ }
+ }
+
+ private void UpdateIcons()
+ {
+ if (BorderWindow != null && borderView != null)
+ {
+ if (BorderWindow.IsMaximized() == true)
+ {
+ if (maximalizeIcon != null)
+ {
+ maximalizeIcon.ResourceUrl = RestoreIcon;
+ }
+ }
+ else
+ {
+ if (maximalizeIcon != null)
+ {
+ maximalizeIcon.ResourceUrl = MaximalizeIcon;
+ }
+ }
}
}
IBorderInterface customBorder = new CustomBorder();
subWindowTwo = new Window("subwin1", customBorder, new Rectangle(60, 20, 800, 800), false);
- subWindowTwo.BackgroundColor = Color.Red;
-
var root = new View(){
Layout = new LinearLayout()
{
},
WidthResizePolicy = ResizePolicyType.FillToParent,
HeightResizePolicy = ResizePolicyType.FillToParent,
- BackgroundColor = Color.Yellow,
+ BackgroundColor = Color.Brown,
};
var image = new ImageView()
void Initialize()
{
win = NUIApplication.GetDefaultWindow();
+
var root = new ImageView()
{
WidthResizePolicy = ResizePolicyType.FillToParent,
LinearOrientation = LinearLayout.Orientation.Horizontal,
CellPadding = new Size(10, 10),
}
-
-
};
win.Add(root);
- var imageViewA = new ImageView()
+
+ var appFunctionList = new View()
{
PositionUsesPivotPoint = true,
PivotPoint = PivotPoint.BottomLeft,
ParentOrigin = ParentOrigin.BottomLeft,
+ BackgroundColor = new Color(0, 1, 1, 0.5f),
+ Size = new Size(500, 200),
+ CornerRadius = 0.3f,
+ CornerRadiusPolicy = VisualTransformPolicyType.Relative,
+ Layout = new LinearLayout()
+ {
+ LinearAlignment = LinearLayout.Alignment.CenterHorizontal,
+ LinearOrientation = LinearLayout.Orientation.Horizontal,
+ CellPadding = new Size(10, 10),
+ Padding = new Extents(10, 10, 10 , 10),
+ }
+ };
+ root.Add(appFunctionList);
+
+ var defaultBorder = new View()
+ {
+ Size = new Size(150, 180),
+ Layout = new LinearLayout()
+ {
+ LinearAlignment = LinearLayout.Alignment.Center,
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ }
+ };
+
+ var imageViewA = new ImageView()
+ {
Size = new Size(150, 150),
ResourceUrl = imagePath + "gallery-large-9.jpg",
CornerRadius = 0.3f,
CornerRadiusPolicy = VisualTransformPolicyType.Relative,
};
- root.Add(imageViewA);
- imageViewA.TouchEvent += (s, e) =>
+
+ var textViewA = new TextLabel()
+ {
+ Text = "Default",
+ };
+
+ defaultBorder.Add(imageViewA);
+ defaultBorder.Add(textViewA);
+ appFunctionList.Add(defaultBorder);
+ defaultBorder.TouchEvent += (s, e) =>
{
if (e.Touch.GetState(0) == PointStateType.Up)
{
return true;
};
+ var customBorder = new View()
+ {
+ Size = new Size(150, 180),
+ Layout = new LinearLayout()
+ {
+ LinearAlignment = LinearLayout.Alignment.Center,
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ }
+ };
+
var imageViewB = new ImageView()
{
- PositionUsesPivotPoint = true,
- PivotPoint = PivotPoint.BottomLeft,
- ParentOrigin = ParentOrigin.BottomLeft,
Size = new Size(150, 150),
ResourceUrl = imagePath + "gallery-large-5.jpg",
CornerRadius = 0.3f,
CornerRadiusPolicy = VisualTransformPolicyType.Relative,
};
- root.Add(imageViewB);
- imageViewB.TouchEvent += (s, e) =>
+ var textViewB = new TextLabel()
+ {
+ Text = "Custom",
+ };
+
+ customBorder.Add(imageViewB);
+ customBorder.Add(textViewB);
+ appFunctionList.Add(customBorder);
+ customBorder.TouchEvent += (s, e) =>
{
if (e.Touch.GetState(0) == PointStateType.Up)
{