// for config
private Size2D minSize = null;
private Size2D maxSize = null;
+ private uint borderLineThickness;
private BorderResizePolicyType borderResizePolicy = BorderResizePolicyType.Free;
#endregion //Fields
AddAuxiliaryHint("wm.policy.win.resize_aspect_ratio", "1");
}
}
+ if (borderLineThickness != borderInterface.BorderLineThickness)
+ {
+ int diffBorderLine = (int)(borderInterface.BorderLineThickness - borderLineThickness);
+ borderLineThickness = borderInterface.BorderLineThickness;
+
+ if (borderView != null)
+ {
+ Extents extents = borderView.Padding;
+ ushort start = (extents.Start + diffBorderLine) > 0 ? (ushort)(extents.Start + diffBorderLine) : (ushort)0;
+ ushort end = (extents.End + diffBorderLine) > 0 ? (ushort)(extents.End + diffBorderLine) : (ushort)0;
+ ushort top = (extents.Top + diffBorderLine) > 0 ? (ushort)(extents.Top + diffBorderLine) : (ushort)0;
+ ushort bottom = (extents.Bottom + diffBorderLine) > 0 ? (ushort)(extents.Bottom + diffBorderLine) : (ushort)0;
+ borderView.Padding = new Extents(start, end, top, bottom);
+ if (IsMaximized() == true)
+ {
+ borderView.OnMaximize(true);
+ }
+ }
+
+ ResizedEventArgs e = new ResizedEventArgs();
+ e.WindowSize = WindowSize;
+ windowResizeEventHandler?.Invoke(this, e);
+ }
}
}
/// <summary>
}
this.borderInterface = borderInterface;
this.borderCloseDelegate = borderCloseDelegate;
+ borderLineThickness = borderInterface.BorderLineThickness;
GetDefaultLayer().Name = "OriginalRootLayer";
- SetTransparency(true);
- BackgroundColor = Color.Transparent;
borderInterface.BorderWindow = this;
if (CreateBorder() == true)
borderInterface.OnMaximize(true);
ResizedEventArgs e = new ResizedEventArgs();
e.WindowSize = WindowSize;
- OnBorderWindowResized(this, e);
+ windowResizeEventHandler?.Invoke(this, e);
}
else
{
{
if (isBorderWindow == true && !(borderInterface.OverlayMode == true && IsMaximized() == true))
{
- var height = (ushort)(size.GetHeight() - borderHeight - borderInterface.BorderLineThickness * 2);
- var width = (ushort)(size.GetWidth() - borderInterface.BorderLineThickness * 2);
+ var borderLine = IsMaximized() == true ? 0 : borderInterface.BorderLineThickness * 2;
+ var height = (ushort)(size.GetHeight() - borderHeight - borderLine);
+ var width = (ushort)(size.GetWidth() - borderLine);
size.SetHeight(height);
size.SetWidth(width);
}
using System;
using System.ComponentModel;
using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
namespace Tizen.NUI
{
/// This class creates a border UI.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public class DefaultBorder : IBorderInterface
+ public class DefaultBorder : BaseHandle, IBorderInterface
{
#region Constant Fields
private static readonly string ResourcePath = FrameworkInformation.ResourcePath;
private Timer overlayTimer;
private CurrentGesture currentGesture = CurrentGesture.None;
- private bool disposed = false;
+ private uint borderLineThickness;
private Size2D minSize;
private Size2D maxSize;
private Window.BorderResizePolicyType resizePolicy;
#region Methods
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty BorderLineThicknessProperty = BindableProperty.Create(nameof(BorderLineThickness), typeof(uint), typeof(DefaultBorder), default(uint), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (DefaultBorder)bindable;
+ if (newValue != null)
+ {
+ instance.borderLineThickness = (uint)newValue;
+ instance.UpdateProperty();
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var instance = (DefaultBorder)bindable;
+ return instance.borderLineThickness;
+ });
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty MinSizeProperty = BindableProperty.Create(nameof(MinSize), typeof(Size2D), typeof(DefaultBorder), default(Size2D), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (DefaultBorder)bindable;
+ if (newValue != null)
+ {
+ instance.minSize = (Size2D)newValue;
+ instance.UpdateProperty();
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var instance = (DefaultBorder)bindable;
+ return instance.minSize;
+ });
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty MaxSizeProperty = BindableProperty.Create(nameof(MaxSize), typeof(Size2D), typeof(DefaultBorder), default(Size2D), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (DefaultBorder)bindable;
+ if (newValue != null)
+ {
+ instance.maxSize = (Size2D)newValue;
+ instance.UpdateProperty();
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var instance = (DefaultBorder)bindable;
+ return instance.maxSize;
+ });
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty ResizePolicyProperty = BindableProperty.Create(nameof(ResizePolicy), typeof(Window.BorderResizePolicyType), typeof(DefaultBorder), default(Window.BorderResizePolicyType), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (DefaultBorder)bindable;
+ if (newValue != null)
+ {
+ instance.resizePolicy = (Window.BorderResizePolicyType)newValue;
+ instance.UpdateProperty();
+ }
+ },
+ defaultValueCreator: (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
+ {
+ return (uint)GetValue(BorderLineThicknessProperty);
+ }
+ set
+ {
+ SetValue(BorderLineThicknessProperty, value);
+ }
+ }
/// <summary>
/// The thickness of the border's touch area.
{
get
{
- return minSize;
+ return (Size2D)GetValue(MinSizeProperty);
}
set
{
- minSize = value;
- UpdateProperty();
+ SetValue(MinSizeProperty, value);
}
}
{
get
{
- return maxSize;
+ return (Size2D)GetValue(MaxSizeProperty);
}
set
{
- maxSize = value;
- UpdateProperty();
+ SetValue(MaxSizeProperty, value);
}
}
{
get
{
- return resizePolicy;
+ return (Window.BorderResizePolicyType)GetValue(ResizePolicyProperty);
}
set
{
- resizePolicy = value;
- UpdateProperty();
+ SetValue(ResizePolicyProperty, value);
}
}
BorderWindow?.UpdateProperty();
}
-
/// <summary>
/// Creates a default border
/// </summary>
{
return;
}
- 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;
private bool OnBorderViewTouched(object sender, View.TouchEventArgs e)
{
- if (e.Touch.GetState(0) == PointStateType.Started)
+ if (string.IsNullOrEmpty(borderView.BackgroundImage))
{
- 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;
+ 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;
}
}
borderView.CornerRadius = new Vector4(0, 0, 0, 0);
borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
- BorderWindow.SetTransparency(false);
}
else
{
}
borderView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
- BorderWindow.SetTransparency(true);
}
}
}
return;
}
this.borderView = borderView;
+
+ BorderWindow.BackgroundColor = Color.Transparent;
+
// Register to resize and move through pan gestures.
borderPanGestureDetector = new PanGestureDetector();
borderPanGestureDetector.Attach(borderView);
borderPinchGestureDetector.Attach(borderView);
borderPinchGestureDetector.Detected += OnPinchGestureDetected;
+
AddInterceptGesture();
UpdateIcons();
public virtual void OnMaximize(bool isMaximized)
{
Tizen.Log.Info("NUI", $"OnMaximize {isMaximized}\n");
- UpdateIcons();
+ if (BorderWindow.IsMaximized() == true)
+ {
+ BorderWindow.SetTransparency(false);
+ }
+ else
+ {
+ BorderWindow.SetTransparency(true);
+ }
+
}
/// <summary>
if (enabled == true)
{
backgroundColor = new Color(borderView.BackgroundColor);
- borderView.BackgroundColor = Color.Transparent;
+ if (string.IsNullOrEmpty(borderView.BackgroundImage))
+ {
+ borderView.BackgroundColor = Color.Transparent;
+ }
borderView.Hide();
}
else
{
- borderView.BackgroundColor = backgroundColor;
+ if (string.IsNullOrEmpty(borderView.BackgroundImage))
+ {
+ borderView.BackgroundColor = backgroundColor;
+ }
borderView.Show();
}
}
return false;
}
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected virtual void Dispose(bool disposing)
+ protected override void Dispose(DisposeTypes type)
{
if (disposed)
{
return;
}
- if (disposing)
+
+ if (type == DisposeTypes.Explicit)
{
ClearWindowGesture();
timer?.Dispose();
overlayTimer?.Dispose();
}
- disposed = true;
- }
- /// <summary>
- /// Dispose
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void Dispose()
- {
- Dispose(true);
- global::System.GC.SuppressFinalize(this);
+ //You must call base.Dispose(type) just before exit.
+ base.Dispose(type);
}
+
#endregion //Methods
}