/*
- * Copyright(c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
using System;
-using System.Collections.Generic;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Binding;
using System.ComponentModel;
/// User can handle Popup button count, head title and content area.
/// </summary>
/// <since_tizen> 6 </since_tizen>
- public class Popup : Control
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
+ public partial class Popup : Control
{
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ButtonHeightProperty = BindableProperty.Create(nameof(ButtonHeight), typeof(int), typeof(Popup), default(int), propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Popup)bindable;
- if (newValue != null && instance?.Style?.Buttons?.Size != null )
+ if (newValue != null)
{
- instance.Style.Buttons.Size.Height = (int)newValue;
instance.btGroup.Itemheight = (int)newValue;
instance.UpdateView();
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return (int)(instance.Style?.Buttons?.Size?.Height ?? 0);
+ return (int)((Popup)bindable).btGroup.Itemheight;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var instance = (Popup)bindable;
if (newValue != null)
{
- if (instance.Style?.Buttons?.Text != null)
- {
- instance.Style.Buttons.Text.PointSize = (float)newValue;
- }
instance.btGroup.ItemPointSize = (float)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.Style?.Buttons?.Text?.PointSize?.All ?? 0;
+ return ((Popup)bindable).btGroup.ItemPointSize;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var instance = (Popup)bindable;
if (newValue != null)
{
- instance.Style.Buttons.Text.FontFamily = (string)newValue;
instance.btGroup.ItemFontFamily = (string)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.Style?.Buttons?.Text?.FontFamily.All;
+ return ((Popup)bindable).btGroup.ItemFontFamily;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
{
var instance = (Popup)bindable;
if (newValue != null)
- {
- if (instance.Style?.Buttons?.Text != null)
- {
- instance.Style.Buttons.Text.TextColor = (Color)newValue;
- }
+ {
instance.btGroup.ItemTextColor = (Color)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.Style?.Buttons?.Text?.TextColor?.All;
+ return ((Popup)bindable).btGroup.ItemTextColor;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var instance = (Popup)bindable;
if (newValue != null)
{
- instance.Style.Buttons.Overlay.BackgroundColor = (Selector<Color>)newValue;
instance.btGroup.OverLayBackgroundColorSelector = (Selector<Color>)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.Style?.Buttons?.Overlay?.BackgroundColor;
+ return ((Popup)bindable).btGroup.OverLayBackgroundColorSelector;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var instance = (Popup)bindable;
if (newValue != null)
{
- instance.Style.Buttons.Text.HorizontalAlignment = (HorizontalAlignment)newValue;
instance.btGroup.ItemTextAlignment = (HorizontalAlignment)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.Style?.Buttons?.Text?.HorizontalAlignment ?? HorizontalAlignment.Center;
+ return ((Popup)bindable).btGroup.ItemTextAlignment;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var instance = (Popup)bindable;
if (newValue != null)
{
- if (instance.Style.Buttons.BackgroundImage == null)
- {
- instance.Style.Buttons.BackgroundImage = new Selector<string>();
- }
instance.btGroup.ItemBackgroundImageUrl = (string)newValue;
- instance.Style.Buttons.BackgroundImage = (string)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.Style?.Buttons?.BackgroundImage?.All;
+ return ((Popup)bindable).btGroup.ItemBackgroundImageUrl;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var instance = (Popup)bindable;
if (newValue != null)
{
- if (instance.Style.Buttons.BackgroundImageBorder == null)
- {
- instance.Style.Buttons.BackgroundImageBorder = new Selector<Rectangle>();
- }
- instance.Style.Buttons.BackgroundImageBorder = (Rectangle)newValue;
instance.btGroup.ItemBackgroundBorder = (Rectangle)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.Style?.Buttons?.BackgroundImageBorder?.All;
+ return ((Popup)bindable).btGroup.ItemBackgroundBorder;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var instance = (Popup)bindable;
ImageShadow shadow = (ImageShadow)newValue;
instance.btGroup.ItemImageShadow = new ImageShadow(shadow);
- instance.Style.Buttons.ImageShadow = new ImageShadow(shadow);
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.Style?.Buttons?.ImageShadow?.All;
+ return ((Popup)bindable).btGroup.ItemImageShadow;
});
-
private TextLabel titleText;
private ButtonGroup btGroup = null;
private Window window = null;
private Layer container = new Layer();
+ private ButtonStyle buttonStyle = new ButtonStyle();
+
static Popup() { }
/// <summary>
/// Creates a new instance of a Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public Popup() : base()
{
- Initialize();
}
/// <summary>
/// Creates a new instance of a Popup with style.
/// </summary>
/// <param name="style">Create Popup by special style defined in UX.</param>
- /// <since_tizen> 8 </since_tizen>
+ [EditorBrowsable(EditorBrowsableState.Never)]
public Popup(string style) : base(style)
{
- Initialize();
}
/// <summary>
/// Creates a new instance of a Popup with style.
/// </summary>
/// <param name="popupStyle">Create Popup by style customized by user.</param>
- /// <since_tizen> 8 </since_tizen>
+ [EditorBrowsable(EditorBrowsableState.Never)]
public Popup(PopupStyle popupStyle) : base(popupStyle)
{
- Initialize();
}
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void AddButton(string buttonText)
{
- if (Style.Buttons != null)
- {
- Button btn = new Button(Style.Buttons);
- btn.Style.Text.Text = buttonText;
- btn.ClickEvent += ButtonClickEvent;
- btGroup.AddItem(btn);
- UpdateView();
- }
+ Button btn = new Button(buttonStyle);
+ btn.Text = buttonText;
+ btn.ClickEvent += ButtonClickEvent;
+ btGroup.AddItem(btn);
+ UpdateView();
}
/// <summary>
/// Add button by style's name.
/// </summary>
- /// <since_tizen> 8 </since_tizen>
+ [EditorBrowsable(EditorBrowsableState.Never)]
public void AddButton(string buttonText, string style)
{
AddButton(buttonText);
/// <summary>
/// Add button by style.
/// </summary>
- /// <since_tizen> 8 </since_tizen>
+ [EditorBrowsable(EditorBrowsableState.Never)]
public void AddButton(string buttonText, ButtonStyle style)
{
- if (Style.Buttons != null && style != null)
- {
- Style.Buttons.CopyFrom(style);
- AddButton(buttonText);
- }
+ Button btn = new Button(style);
+ btn.Text = buttonText;
+ btn.ClickEvent += ButtonClickEvent;
+ btGroup.AddItem(btn);
+ UpdateView();
}
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
/// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public event EventHandler<ButtonClickEventArgs> PopupButtonClickEvent;
/// <summary>
- /// Get style of popup.
- /// </summary>
- /// <since_tizen> 8 </since_tizen>
- public new PopupStyle Style => ViewStyle as PopupStyle;
-
- /// <summary>
/// Popup Title.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
{
if (null == titleText)
{
- titleText = new TextLabel();
+ titleText = new TextLabel
+ {
+ PositionUsesPivotPoint = true,
+ ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
+ PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ VerticalAlignment = VerticalAlignment.Bottom,
+ Text = "Title"
+ };
Add(titleText);
}
return titleText;
/// Title text string in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public string TitleText
{
get
{
- return Style?.Title?.Text?.All;
+ return GetValue(TitleTextProperty) as string;
}
set
{
- if (value != null)
- {
- if (Style?.Title != null)
- {
- Style.Title.Text = value;
- }
- }
+ SetValue(TitleTextProperty, value);
+ NotifyPropertyChanged();
}
}
+ private string InternalTitleText
+ {
+ get => Title.Text;
+ set => Title.Text = value;
+ }
/// <summary>
/// Title text point size in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public float TitlePointSize
{
get
{
- return Style?.Title?.PointSize?.All ?? 0;
+ return (float)GetValue(TitlePointSizeProperty);
}
set
{
- if (Style?.Title != null)
- {
- Style.Title.PointSize = value;
- }
+ SetValue(TitlePointSizeProperty, value);
+ NotifyPropertyChanged();
}
}
+ private float InternalTitlePointSize
+ {
+ get => Title.PointSize;
+ set => Title.PointSize = value;
+ }
/// <summary>
/// Title text color in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public Color TitleTextColor
{
get
{
- return Style?.Title?.TextColor?.All;
+ return GetValue(TitleTextColorProperty) as Color;
}
set
{
- if (Style?.Title != null)
- {
- Style.Title.TextColor = value;
- }
+ SetValue(TitleTextColorProperty, value);
+ NotifyPropertyChanged();
}
}
+ private Color InternalTitleTextColor
+ {
+ get => Title.TextColor;
+ set => Title.TextColor = value;
+ }
/// <summary>
/// Title text horizontal alignment in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public HorizontalAlignment TitleTextHorizontalAlignment
{
get
{
- return Style?.Title?.HorizontalAlignment ?? HorizontalAlignment.Center;
+ return (HorizontalAlignment)GetValue(TitleTextHorizontalAlignmentProperty);
}
set
{
- Style.Title.HorizontalAlignment = value;
+ SetValue(TitleTextHorizontalAlignmentProperty, value);
+ NotifyPropertyChanged();
}
}
+ private HorizontalAlignment InternalTitleTextHorizontalAlignment
+ {
+ get => Title.HorizontalAlignment;
+ set => Title.HorizontalAlignment = value;
+ }
/// <summary>
/// Title text's position in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public Position TitleTextPosition
{
get
{
- return Style?.Title?.Position ?? new Position(0, 0, 0);
+ return GetValue(TitleTextPositionProperty) as Position;
}
set
{
- Style.Title.Position = value;
+ SetValue(TitleTextPositionProperty, value);
+ NotifyPropertyChanged();
}
}
+ private Position InternalTitleTextPosition
+ {
+ get => Title.Position;
+ set => Title.Position = value;
+ }
/// <summary>
/// Title text's height in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public int TitleHeight
{
get
{
- return (int)(Style?.Title?.Size?.Height ?? 0);
+ return (int)GetValue(TitleHeightProperty);
}
set
{
- if (Style?.Title?.Size != null)
- {
- Style.Title.Size.Height = value;
- }
+ SetValue(TitleHeightProperty, value);
+ NotifyPropertyChanged();
}
}
+ private int InternalTitleHeight
+ {
+ get => (int)Title.SizeHeight;
+ set => Title.SizeHeight = (int)value;
+ }
/// <summary>
/// Content view in Popup, only can be gotten.
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public View ContentView
{
get;
/// Button count in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public int ButtonCount
{
+ get
+ {
+ return (int)GetValue(ButtonCountProperty);
+ }
+ set
+ {
+ SetValue(ButtonCountProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private int InternalButtonCount
+ {
get;
set;
}
/// Button height in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public int ButtonHeight
{
get
/// Button text point size in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public float ButtonTextPointSize
{
get
/// Button text font family in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public string ButtonFontFamily
{
get
- {
+ {
return (string)GetValue(ButtonFontFamilyProperty);
}
set
/// Button text color in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public Color ButtonTextColor
{
get
/// Button text horizontal alignment in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public HorizontalAlignment ButtonTextAlignment
{
get
- {
+ {
return (HorizontalAlignment)GetValue(ButtonTextAlignmentProperty);
}
set
public string ButtonBackground
{
get
- {
+ {
return (string)GetValue(ButtonBackgroundProperty);
}
set
{
get
{
-
+
return (Rectangle)GetValue(ButtonBackgroundBorderProperty);
}
set
/// <param name="index">Button index.</param>
/// <param name="text">Button text string.</param>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public void SetButtonText(int index, string text)
{
AddButton(text);
/// </summary>
/// <param name="type">Dispose type.</param>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
+#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member, It will be removed in API10
protected override void Dispose(DisposeTypes type)
+#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member, It will be removed in API10
{
if (disposed)
{
btGroup.Dispose();
btGroup = null;
}
+
+ buttonStyle?.Dispose();
}
base.Dispose(type);
/// Apply style to popup.
/// </summary>
/// <param name="viewStyle">The style to apply.</param>
- /// <since_tizen> 8 </since_tizen>
+ [EditorBrowsable(EditorBrowsableState.Never)]
public override void ApplyStyle(ViewStyle viewStyle)
{
base.ApplyStyle(viewStyle);
- PopupStyle ppStyle = viewStyle as PopupStyle;
- if (null != ppStyle)
+
+ if (viewStyle is PopupStyle ppStyle)
{
+ if (ppStyle.Buttons?.SizeHeight != null)
+ {
+ ButtonHeight = (int)ppStyle.Buttons.SizeHeight;
+ }
+
+ buttonStyle = (ButtonStyle)ppStyle.Buttons?.Clone();
+ if (buttonStyle.PositionUsesPivotPoint == null) buttonStyle.PositionUsesPivotPoint = true;
+ if (buttonStyle.ParentOrigin == null) buttonStyle.ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft;
+ if (buttonStyle.PivotPoint == null) buttonStyle.PivotPoint = Tizen.NUI.PivotPoint.BottomLeft;
+
+ if (btGroup != null)
+ {
+ for (int i = 0; i < btGroup.Count; i++)
+ {
+ var button = GetButton(i);
+ button.ApplyStyle(buttonStyle);
+ }
+ }
+
Title.ApplyStyle(ppStyle.Title);
Title.RaiseToTop();
}
/// Get Popup style.
/// </summary>
/// <returns>The default popup style.</returns>
- /// <since_tizen> 8 </since_tizen>
+ [EditorBrowsable(EditorBrowsableState.Never)]
protected override ViewStyle CreateViewStyle()
{
return new PopupStyle();
}
- /// <summary>
- /// Theme change callback when theme is changed, this callback will be trigger.
- /// </summary>
- /// <param name="sender">The sender</param>
- /// <param name="e">The event data</param>
- /// <since_tizen> 8 </since_tizen>
- protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e)
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void OnUpdate()
{
- PopupStyle popupStyle = StyleManager.Instance.GetViewStyle(StyleName) as PopupStyle;
- if (popupStyle != null)
- {
- string strSaveTitleText = TitleText;
- Style.CopyFrom(popupStyle);
- Style.Title.Text = strSaveTitleText;
- UpdateView();
- }
+ base.OnUpdate();
+ UpdateView();
}
- private void Initialize()
+ /// <summary>
+ /// Initialize AT-SPI object.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnInitialize()
{
+ base.OnInitialize();
+ AccessibilityRole = Role.Dialog;
+
container.Add(this);
container.SetTouchConsumed(true);
container.SetHoverConsumed(true);
btGroup = new ButtonGroup(this);
}
+ /// <summary>
+ /// Informs AT-SPI bridge about the set of AT-SPI states associated with this object.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override AccessibilityStates AccessibilityCalculateStates()
+ {
+ var states = base.AccessibilityCalculateStates();
+
+ states[AccessibilityState.Modal] = true;
+
+ return states;
+ }
+
private void UpdateView()
{
- btGroup.UpdateButton(Style.Buttons);
+ btGroup.UpdateButton(buttonStyle);
UpdateContentView();
UpdateTitle();
}
private void PopupStylePropertyChanged(object sender, PropertyChangedEventArgs e)
{
- if (e.PropertyName.Equals("LayoutDirection"))
+ if (e.PropertyName is var propName && propName != null && propName.Equals("LayoutDirection"))
{
- btGroup.UpdateButton(Style.Buttons);
+ btGroup.UpdateButton(buttonStyle);
}
}
int titleY = 0;
int titleH = 0;
int buttonH = 0;
- string strText = Style.Title.Text.All;
- if (!string.IsNullOrEmpty(strText) && Style.Title.Size != null)
+ string strText = Title.Text;
+ if (!string.IsNullOrEmpty(strText) && Title.Size != null)
{
titleH = (int)titleText.Size.Height;
}
- if (!string.IsNullOrEmpty(strText) && Style.Title.Position != null)
+ if (!string.IsNullOrEmpty(strText) && Title.Position != null)
{
- titleX = (int)Style.Title.Position.X;
- titleY = (int)Style.Title.Position.Y;
+ titleX = (int)Title.Position.X;
+ titleY = (int)Title.Position.Y;
}
- if (btGroup.Count != 0 && Style?.Buttons?.Size != null )
+ if (btGroup.Count != 0)
{
- buttonH = (int)Style.Buttons.Size.Height;
+ buttonH = ButtonHeight;
}
ContentView.Size = new Size(Size.Width - titleX * 2, Size.Height - titleY - titleH - buttonH);
ContentView.Position = new Position(titleX, titleY + titleH);
private void UpdateTitle()
{
- if (titleText != null && string.IsNullOrEmpty(Style.Title.Text.All) && Style.Title.Size != null)
+ if (titleText != null && string.IsNullOrEmpty(Title.Text) && Title.Size != null)
{
titleText.RaiseToTop();
}
/// ButtonClickEventArgs is a class to record button click event arguments which will sent to user.
/// </summary>
/// <since_tizen> 6 </since_tizen>
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
public class ButtonClickEventArgs : EventArgs
{
/// <summary> Button index which is clicked in Popup </summary>
/// <since_tizen> 6 </since_tizen>
+ /// It will be removed in API10
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:Do not declare visible instance fields")]
+ [Obsolete("Deprecated in API8; Will be removed in API10")]
public int ButtonIndex;
}
}