using System;
using System.Collections.Generic;
using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
using System.ComponentModel;
namespace Tizen.NUI.Components
/// <since_tizen> 6 </since_tizen>
public class Popup : Control
{
- private ImageView backgroundImage;
- private ImageView shadowImage;
- private TextLabel titleText;
- private List<Button> buttonList;
- private List<string> buttonTextList = new List<string>();
+ /// 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 ButtonCountProperty = BindableProperty.Create("ButtonCount", typeof(int), typeof(Popup), 0, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (Popup)bindable;
+ if ((int)newValue != instance.buttonCount)
+ {
+ instance.buttonCount = (int)newValue;
+ instance.UpdateButton();
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var instance = (Popup)bindable;
+ return instance.buttonCount;
+ });
- private PopupAttributes popupAttributes;
- private int buttonCount = 0;
+ /// 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 ShadowOffsetProperty = BindableProperty.Create("ShadowOffset", typeof(Vector4), typeof(Popup), new Vector4(0, 0, 0, 0), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (Popup)bindable;
+ if (newValue != null)
+ {
+ if (instance.Style.ShadowOffset == null)
+ {
+ instance.Style.ShadowOffset = new Vector4(0, 0, 0, 0);
+ }
+ instance.Style.ShadowOffset = (Vector4)newValue;
+ instance.UpdateShadow();
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var instance = (Popup)bindable;
+ return instance.Style.ShadowOffset;
+ });
- /// <summary>
- /// Creates a new instance of a Popup.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- public Popup() : base()
+ /// 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("ButtonHeight", typeof(int), typeof(Popup), default(int), propertyChanged: (bindable, oldValue, newValue) =>
{
- Initialize();
- }
+ var instance = (Popup)bindable;
+ if (newValue != null)
+ {
+ instance.Style.Buttons.Size.Height = (int)newValue;
+ instance.UpdateButton();
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var instance = (Popup)bindable;
+ return instance.Style.Buttons?.Size?.Height ?? 0;
+ });
- /// <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> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ /// 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 Popup(string style) : base(style)
+ public static readonly BindableProperty ButtonTextPointSizeProperty = BindableProperty.Create("ButtonTextPointSize", typeof(float), typeof(Popup), default(float), propertyChanged: (bindable, oldValue, newValue) =>
{
- Initialize();
- }
+ var instance = (Popup)bindable;
+ if (newValue != null)
+ {
+ if (instance.Style.Buttons.Text.PointSize == null)
+ {
+ instance.Style.Buttons.Text.PointSize = new Selector<float?>();
+ }
+ instance.Style.Buttons.Text.PointSize.All = (float)newValue;
+ instance.UpdateButton();
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var instance = (Popup)bindable;
+ return instance.Style.Buttons?.Text?.PointSize?.All ?? 0;
+ });
- /// <summary>
- /// Creates a new instance of a Popup with attributes.
- /// </summary>
- /// <param name="attributes">Create Popup by attributes customized by user.</param>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ /// 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 Popup(PopupAttributes attributes) : base(attributes)
+ public static readonly BindableProperty ButtonFontFamilyProperty = BindableProperty.Create("ButtonFontFamily", typeof(string), typeof(Popup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
{
- Initialize();
- }
+ var instance = (Popup)bindable;
+ if (newValue != null)
+ {
+ instance.Style.Buttons.Text.FontFamily = (string)newValue;
+ instance.UpdateButton();
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var instance = (Popup)bindable;
+ return instance.Style.Buttons?.Text?.FontFamily;
+ });
- /// <summary>
- /// 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>
- public event EventHandler<ButtonClickEventArgs> PopupButtonClickEvent;
+ /// 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 ButtonTextColorProperty = BindableProperty.Create("ButtonTextColor", typeof(Color), typeof(Popup), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (Popup)bindable;
+ if (newValue != null)
+ {
+ if (instance.Style.Buttons.Text.TextColor == null)
+ {
+ instance.Style.Buttons.Text.TextColor = new Selector<Color>();
+ }
+ instance.Style.Buttons.Text.TextColor.All = (Color)newValue;
+ //instance.UpdateButton();
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var instance = (Popup)bindable;
+ return instance.Style.Buttons?.Text?.TextColor?.All;
+ });
- /// <summary>
- /// Title text string in Popup.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- public string TitleText
+ /// 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 ButtonOverLayBackgroundColorSelectorProperty = BindableProperty.Create("ButtonOverLayBackgroundColorSelector", typeof(Selector<Color>), typeof(Popup), new Selector<Color>(), propertyChanged: (bindable, oldValue, newValue) =>
{
- get
+ var instance = (Popup)bindable;
+ if (newValue != null)
{
- return popupAttributes?.TitleTextAttributes?.Text?.All;
+ instance.Style.Buttons.Overlay.BackgroundColor = (Selector<Color>)newValue;
+ instance.UpdateButton();
}
- set
- {
- if (value != null)
- {
- CreateTitleTextAttributes();
- if (popupAttributes.TitleTextAttributes.Text == null)
- {
- popupAttributes.TitleTextAttributes.Text = new StringSelector();
- }
- popupAttributes.TitleTextAttributes.Text.All = value;
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var instance = (Popup)bindable;
+ return instance.Style.Buttons?.Overlay?.BackgroundColor;
+ });
- RelayoutRequest();
- }
+ /// 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 ButtonTextAlignmentProperty = BindableProperty.Create("ButtonTextAlignment", typeof(HorizontalAlignment), typeof(Popup), new HorizontalAlignment(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (Popup)bindable;
+ if (newValue != null)
+ {
+ instance.Style.Buttons.Text.HorizontalAlignment = (HorizontalAlignment)newValue;
+ instance.UpdateButton();
}
- }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var instance = (Popup)bindable;
+ return instance.Style.Buttons?.Text?.HorizontalAlignment ?? HorizontalAlignment.Center;
+ });
- /// <summary>
- /// Button count in Popup.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- public int ButtonCount
+ /// 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 ButtonBackgroundProperty = BindableProperty.Create("ButtonBackground", typeof(string), typeof(Popup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
{
- get
+ var instance = (Popup)bindable;
+ if (newValue != null)
{
- return buttonCount;
+ if (instance.Style.Buttons.Background.ResourceUrl == null)
+ {
+ instance.Style.Buttons.Background.ResourceUrl = new Selector<string>();
+ }
+ instance.Style.Buttons.Background.ResourceUrl.All = (string)newValue;
+ instance.UpdateButton();
}
- set
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var instance = (Popup)bindable;
+ return instance.Style.Buttons?.Background?.ResourceUrl?.All;
+ });
+
+ /// 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 ButtonBackgroundBorderProperty = BindableProperty.Create("ButtonBackgroundBorder", typeof(Rectangle), typeof(Popup), new Rectangle(0, 0, 0, 0), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (Popup)bindable;
+ if (newValue != null)
{
- if (buttonCount != value)
+ if (instance.Style.Buttons.Background.Border == null)
{
- buttonCount = value;
- RelayoutRequest();
+ instance.Style.Buttons.Background.Border = new Selector<Rectangle>();
}
+ instance.Style.Buttons.Background.Border.All = (Rectangle)newValue;
+ instance.UpdateButton();
}
- }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var instance = (Popup)bindable;
+ return instance.Style.Buttons?.Background?.Border?.All;
+ });
+
+ private TextLabel titleText;
+ private List<Button> buttonList;
+ private List<string> buttonTextList = new List<string>();
+
+ private int buttonCount = 0;
/// <summary>
- /// Content view in Popup, only can be gotten.
+ /// Creates a new instance of a Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
- public View ContentView
+ public Popup() : base()
{
- get;
- private set;
+ Initialize();
}
/// <summary>
- /// Shadow image's resource url in Popup.
+ /// Creates a new instance of a Popup with style.
/// </summary>
+ /// <param name="style">Create Popup by special style defined in UX.</param>
/// <since_tizen> 6 </since_tizen>
/// 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 string ShadowImageURL
+ public Popup(string style) : base(style)
{
- get
- {
- return popupAttributes?.ShadowImageAttributes?.ResourceURL?.All;
- }
- set
- {
- if (value != null)
- {
- CreateShadowAttributes();
- if (popupAttributes.ShadowImageAttributes.ResourceURL == null)
- {
- popupAttributes.ShadowImageAttributes.ResourceURL = new StringSelector();
- }
- popupAttributes.ShadowImageAttributes.ResourceURL.All = value;
- RelayoutRequest();
- }
- }
+ Initialize();
}
/// <summary>
- /// Shadow image's border in Popup.
+ /// Creates a new instance of a Popup with attributes.
/// </summary>
+ /// <param name="attributes">Create Popup by attributes customized by user.</param>
/// <since_tizen> 6 </since_tizen>
/// 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 Rectangle ShadowImageBorder
+ public Popup(PopupStyle attributes) : base(attributes)
{
- get
- {
- return popupAttributes?.ShadowImageAttributes?.Border?.All;
- }
- set
- {
- if (value != null)
- {
- CreateShadowAttributes();
- if (popupAttributes.ShadowImageAttributes.Border == null)
- {
- popupAttributes.ShadowImageAttributes.Border = new RectangleSelector();
- }
- popupAttributes.ShadowImageAttributes.Border.All = value;
- RelayoutRequest();
- }
- }
+ Initialize();
}
/// <summary>
- /// Background image's resource url in Popup.
+ /// 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>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ public event EventHandler<ButtonClickEventArgs> PopupButtonClickEvent;
+
+ /// 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 string BackgroundImageURL
+ public new PopupStyle Style => ViewStyle as PopupStyle;
+
+ /// <summary>
+ /// Title text string in Popup.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public string TitleText
{
get
{
- return popupAttributes?.BackgroundImageAttributes?.ResourceURL?.All;
+ return Style.Title?.Text?.All;
}
set
{
if (value != null)
{
- CreateBackgroundAttributes();
- if (popupAttributes.BackgroundImageAttributes.ResourceURL == null)
+ //CreateTitleTextAttributes();
+ if (Style.Title.Text == null)
{
- popupAttributes.BackgroundImageAttributes.ResourceURL = new StringSelector();
+ Style.Title.Text = new StringSelector();
}
- popupAttributes.BackgroundImageAttributes.ResourceURL.All = value;
- RelayoutRequest();
+ Style.Title.Text.All = value;
+
+ //RelayoutRequest();
}
}
}
/// <summary>
- /// Background image's border in Popup.
+ /// Title text point size in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
- /// 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 Rectangle BackgroundImageBorder
+ public float TitlePointSize
{
get
{
- return popupAttributes?.BackgroundImageAttributes?.Border?.All;
+ return Style.Title?.PointSize?.All ?? 0;
}
set
{
- if (value != null)
+ //CreateTitleTextAttributes();
+ if (Style.Title.PointSize == null)
{
- CreateBackgroundAttributes();
- if (popupAttributes.BackgroundImageAttributes.Border == null)
- {
- popupAttributes.BackgroundImageAttributes.Border = new RectangleSelector();
- }
- popupAttributes.BackgroundImageAttributes.Border.All = value;
- RelayoutRequest();
+ Style.Title.PointSize = new FloatSelector();
}
+ Style.Title.PointSize.All = value;
+ //RelayoutRequest();
}
}
/// <summary>
- /// Title text point size in Popup.
+ /// Title text color in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
- public float TitlePointSize
+ public Color TitleTextColor
{
get
{
- return popupAttributes?.TitleTextAttributes?.PointSize?.All ?? 0;
+ return Style.Title?.TextColor?.All;
}
set
{
- CreateTitleTextAttributes();
- if (popupAttributes.TitleTextAttributes.PointSize == null)
+ //CreateTitleTextAttributes();
+ if (Style.Title.TextColor == null)
{
- popupAttributes.TitleTextAttributes.PointSize = new FloatSelector();
+ Style.Title.TextColor = new ColorSelector();
}
- popupAttributes.TitleTextAttributes.PointSize.All = value;
- RelayoutRequest();
+ Style.Title.TextColor.All = value;
+ //RelayoutRequest();
}
}
/// <summary>
- /// Title text font family in Popup.
+ /// Title text horizontal alignment in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
- /// 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 string TitleFontFamily
+ public HorizontalAlignment TitleTextHorizontalAlignment
{
get
{
- return popupAttributes?.TitleTextAttributes?.FontFamily;
+ return Style.Title?.HorizontalAlignment ?? HorizontalAlignment.Center;
}
set
{
- CreateTitleTextAttributes();
- popupAttributes.TitleTextAttributes.FontFamily = value;
- RelayoutRequest();
+ //CreateTitleTextAttributes();
+ Style.Title.HorizontalAlignment = value;
+ //RelayoutRequest();
}
}
/// <summary>
- /// Title text color in Popup.
+ /// Title text's position in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
- public Color TitleTextColor
+ public Position TitleTextPosition
{
get
{
- return popupAttributes?.TitleTextAttributes?.TextColor?.All;
+ return Style.Title?.Position ?? new Position(0, 0, 0);
}
set
{
- CreateTitleTextAttributes();
- if (popupAttributes.TitleTextAttributes.TextColor == null)
- {
- popupAttributes.TitleTextAttributes.TextColor = new ColorSelector();
- }
- popupAttributes.TitleTextAttributes.TextColor.All = value;
- RelayoutRequest();
+ //CreateTitleTextAttributes();
+ Style.Title.Position = value;
+ //RelayoutRequest();
}
}
/// <summary>
- /// Title text horizontal alignment in Popup.
+ /// Title text's height in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
- public HorizontalAlignment TitleTextHorizontalAlignment
+ public int TitleHeight
{
get
{
- return popupAttributes?.TitleTextAttributes?.HorizontalAlignment ?? HorizontalAlignment.Center;
+ return (int)(Style.Title?.Size?.Height ?? 0);
}
set
{
- CreateTitleTextAttributes();
- popupAttributes.TitleTextAttributes.HorizontalAlignment = value;
- RelayoutRequest();
+ //CreateTitleTextAttributes();
+ Style.Title.Size.Height = value;
+ //RelayoutRequest();
}
}
/// <summary>
- /// Title text's position in Popup.
+ /// Content view in Popup, only can be gotten.
/// </summary>
/// <since_tizen> 6 </since_tizen>
- public Position TitleTextPosition
+ public View ContentView
{
- get
- {
- return popupAttributes?.TitleTextAttributes?.Position ?? new Position(0, 0, 0);
- }
- set
- {
- CreateTitleTextAttributes();
- popupAttributes.TitleTextAttributes.Position = value;
- RelayoutRequest();
- }
+ get;
+ private set;
}
/// <summary>
- /// Title text's height in Popup.
+ /// Button count in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
- public int TitleHeight
+ public int ButtonCount
{
get
{
- return (int)(popupAttributes?.TitleTextAttributes?.Size?.Height ?? 0);
+ return (int)GetValue(ButtonCountProperty);
}
set
{
- CreateTitleTextAttributes();
- popupAttributes.TitleTextAttributes.Size.Height = value;
- RelayoutRequest();
+ SetValue(ButtonCountProperty, value);
}
}
{
get
{
- return popupAttributes?.ShadowOffset;
+ return (Vector4)GetValue(ShadowOffsetProperty);
}
set
{
- if (value != null)
- {
- if (popupAttributes.ShadowOffset == null)
- {
- popupAttributes.ShadowOffset = new Vector4(0, 0, 0, 0);
- }
- popupAttributes.ShadowOffset = value;
- RelayoutRequest();
- }
+ SetValue(ShadowOffsetProperty, value);
}
}
{
get
{
- return (int)(popupAttributes?.ButtonAttributes?.Size?.Height ?? 0);
+ return (int)GetValue(ButtonHeightProperty);
}
set
{
- CreateButtonAttributes();
- popupAttributes.ButtonAttributes.Size.Height = value;
- RelayoutRequest();
+ SetValue(ButtonHeightProperty, value);
}
}
{
get
{
- return popupAttributes?.ButtonAttributes?.TextAttributes?.PointSize?.All ?? 0;
+ return (float)GetValue(ButtonTextPointSizeProperty);
}
set
{
- CreateButtonAttributes();
- if (popupAttributes.ButtonAttributes.TextAttributes.PointSize == null)
- {
- popupAttributes.ButtonAttributes.TextAttributes.PointSize = new FloatSelector();
- }
- popupAttributes.ButtonAttributes.TextAttributes.PointSize.All = value;
- RelayoutRequest();
+ SetValue(ButtonTextPointSizeProperty, value);
}
}
public string ButtonFontFamily
{
get
- {
- return popupAttributes?.ButtonAttributes?.TextAttributes?.FontFamily;
+ {
+ return (string)GetValue(ButtonFontFamilyProperty);
}
set
{
- CreateButtonAttributes();
- popupAttributes.ButtonAttributes.TextAttributes.FontFamily = value;
- RelayoutRequest();
+ SetValue(ButtonFontFamilyProperty, value);
}
}
{
get
{
- return popupAttributes?.ButtonAttributes?.TextAttributes?.TextColor?.All;
+ return (Color)GetValue(ButtonTextColorProperty);
}
set
{
- CreateButtonAttributes();
- if (popupAttributes.ButtonAttributes.TextAttributes.TextColor == null)
- {
- popupAttributes.ButtonAttributes.TextAttributes.TextColor = new ColorSelector();
- }
- popupAttributes.ButtonAttributes.TextAttributes.TextColor.All = value;
- RelayoutRequest();
+ SetValue(ButtonTextColorProperty, value);
}
}
/// <since_tizen> 6 </since_tizen>
/// 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 ColorSelector ButtonOverLayBackgroundColorSelector
+ public Selector<Color> ButtonOverLayBackgroundColorSelector
{
get
{
- return popupAttributes?.ButtonAttributes?.OverlayImageAttributes?.BackgroundColor;
+ return (Selector<Color>)GetValue(ButtonOverLayBackgroundColorSelectorProperty);
}
set
{
- if (value != null)
- {
- CreateButtonAttributes();
- popupAttributes.ButtonAttributes.OverlayImageAttributes.BackgroundColor = value.Clone() as ColorSelector;
- RelayoutRequest();
- }
+ SetValue(ButtonOverLayBackgroundColorSelectorProperty, value);
}
}
public HorizontalAlignment ButtonTextAlignment
{
get
- {
- return popupAttributes?.ButtonAttributes?.TextAttributes?.HorizontalAlignment ?? HorizontalAlignment.Center;
+ {
+ return (HorizontalAlignment)GetValue(ButtonTextAlignmentProperty);
}
set
{
- CreateButtonAttributes();
- popupAttributes.ButtonAttributes.TextAttributes.HorizontalAlignment = value;
- RelayoutRequest();
+ SetValue(ButtonTextAlignmentProperty, value);
}
}
public string ButtonBackgroundImageURL
{
get
- {
- return popupAttributes?.ButtonAttributes?.BackgroundImageAttributes?.ResourceURL?.All;
+ {
+ return (string)GetValue(ButtonBackgroundProperty);
}
set
{
- if (value != null)
- {
- CreateButtonAttributes();
- if (popupAttributes.ButtonAttributes.BackgroundImageAttributes.ResourceURL == null)
- {
- popupAttributes.ButtonAttributes.BackgroundImageAttributes.ResourceURL = new StringSelector();
- }
- popupAttributes.ButtonAttributes.BackgroundImageAttributes.ResourceURL.All = value;
- RelayoutRequest();
- }
+ SetValue(ButtonBackgroundProperty, value);
}
}
{
get
{
- return popupAttributes?.ButtonAttributes?.BackgroundImageAttributes?.Border?.All;
+
+ return (Rectangle)GetValue(ButtonBackgroundBorderProperty);
}
set
{
- if (value != null)
- {
- CreateButtonAttributes();
- if (popupAttributes.ButtonAttributes.BackgroundImageAttributes.Border == null)
- {
- popupAttributes.ButtonAttributes.BackgroundImageAttributes.Border = new RectangleSelector();
- }
- popupAttributes.ButtonAttributes.BackgroundImageAttributes.Border.All = value;
- RelayoutRequest();
- }
+ SetValue(ButtonBackgroundBorderProperty, value);
+ }
+ }
+
+ /// 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 new Size2D Size2D
+ {
+ get
+ {
+ return base.Size2D;
+ }
+ set
+ {
+ base.Size2D = value;
+ UpdateShadow();
}
}
}
}
buttonTextList[index] = text;
- RelayoutRequest();
+ UpdateButton();
}
/// <summary>
titleText.Dispose();
titleText = null;
}
- if (backgroundImage != null)
- {
- Remove(backgroundImage);
- backgroundImage.Dispose();
- backgroundImage = null;
- }
- if (shadowImage != null)
- {
- Remove(shadowImage);
- shadowImage.Dispose();
- shadowImage = null;
- }
if (ContentView != null)
{
Remove(ContentView);
base.OnFocusLost();
}
- /// <summary>
- /// Get Popup attribues.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected override Attributes GetAttributes()
- {
- return new PopupAttributes();
- }
-
- /// <summary>
- /// Update Popup by attributes.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- protected override void OnUpdate()
+ public override void ApplyStyle(ViewStyle viewStyle)
{
- int w = 0;
- int h = 0;
- int titleX = 0;
- int titleY = 0;
- int titleH = 0;
- int buttonH = 0;
+ base.ApplyStyle(viewStyle);
- if (popupAttributes.ShadowImageAttributes != null)
- {
- if (shadowImage == null)
- {
- shadowImage = new ImageView();
- Add(shadowImage);
- }
- ApplyAttributes(shadowImage, popupAttributes.ShadowImageAttributes);
- w = Size2D.Width;
- h = Size2D.Height;
- if (popupAttributes.ShadowOffset != null)
- {
- w = (int)(Size2D.Width + popupAttributes.ShadowOffset.W + popupAttributes.ShadowOffset.X);
- h = (int)(Size2D.Height + popupAttributes.ShadowOffset.Y + popupAttributes.ShadowOffset.Z);
- }
+ PopupStyle popupStyle = viewStyle as PopupStyle;
- shadowImage.Size2D = new Size2D(w, h);
- }
-
- if (popupAttributes.BackgroundImageAttributes != null)
+ if (null != popupStyle)
{
- if (backgroundImage == null)
- {
- backgroundImage = new ImageView()
- {
- WidthResizePolicy = ResizePolicyType.FillToParent,
- HeightResizePolicy = ResizePolicyType.FillToParent
- };
- Add(backgroundImage);
- }
- ApplyAttributes(backgroundImage, popupAttributes.BackgroundImageAttributes);
- }
-
- if (popupAttributes.TitleTextAttributes != null)
- {
- if (titleText == null)
+ if (null == titleText)
{
titleText = new TextLabel();
Add(titleText);
}
- ApplyAttributes(titleText, popupAttributes.TitleTextAttributes);
-
- if (titleText.Text != null && titleText.Text != "")
- {
- popupAttributes.TitleTextAttributes.Text = new StringSelector { All = titleText.Text };
- w = (int)(Size2D.Width - titleText.PositionX * 2);
-
- if (popupAttributes.TitleTextAttributes.Size != null)
- {
- titleH = (int)titleText.Size.Height;
- }
- titleText.Size2D = new Size2D(w, titleH);
-
- if (popupAttributes.TitleTextAttributes.Position != null)
- {
- titleX = (int)popupAttributes.TitleTextAttributes.Position.X;
- titleY = (int)popupAttributes.TitleTextAttributes.Position.Y;
- }
- }
- else
- {
- titleText.Size2D = new Size2D(0, 0);
- }
-
-
+ titleText.ApplyStyle(Style.Title);
}
- ContentView.RaiseToTop();
-
- if (popupAttributes.ButtonAttributes != null && popupAttributes.ButtonAttributes.Size != null)
- {
- UpdateButton(buttonCount);
-
- if (buttonList != null)
- {
- buttonH = (int)popupAttributes.ButtonAttributes.Size.Height;
- }
- }
-
- ContentView.Size2D = new Size2D(Size2D.Width - titleX * 2, Size2D.Height - titleY - titleH - buttonH);
- ContentView.Position2D = new Position2D(titleX, titleY + titleH);
-
- LayoutChild();
}
/// <summary>
- /// Layout child in Popup and it can be override by user.
+ /// Get Popup attribues.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- protected virtual void LayoutChild()
+ protected override ViewStyle GetViewStyle()
{
- if (popupAttributes == null)
- {
- return;
- }
-
- if(titleText != null)
- {
- if(LayoutDirection == ViewLayoutDirectionType.RTL)
- {
- if (popupAttributes.TitleTextAttributes != null)
- {
- popupAttributes.TitleTextAttributes.HorizontalAlignment = HorizontalAlignment.End;
- }
- titleText.HorizontalAlignment = HorizontalAlignment.End;
- }
- else if(LayoutDirection == ViewLayoutDirectionType.LTR)
- {
- if (popupAttributes.TitleTextAttributes != null)
- {
- popupAttributes.TitleTextAttributes.HorizontalAlignment = HorizontalAlignment.Begin;
- }
- titleText.HorizontalAlignment = HorizontalAlignment.Begin;
- }
- }
-
- if(buttonList != null && buttonList.Count > 0)
- {
- int pos = 0;
- if (LayoutDirection == ViewLayoutDirectionType.RTL)
- {
- for (int i = buttonList.Count - 1; i >= 0; i--)
- {
- buttonList[i].PositionX = pos;
- pos += buttonList[i].Size2D.Width;
- }
- }
- else
- {
- for (int i = 0; i < buttonList.Count; i++)
- {
- buttonList[i].PositionX = pos;
- pos += buttonList[i].Size2D.Width;
- }
- }
- }
+ return new PopupStyle();
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e)
{
- PopupAttributes tempAttributes = StyleManager.Instance.GetAttributes(style) as PopupAttributes;
+ PopupStyle tempAttributes = StyleManager.Instance.GetAttributes(style) as PopupStyle;
if (tempAttributes != null)
{
- attributes = popupAttributes = tempAttributes;
+ Style.CopyFrom(tempAttributes);
RelayoutRequest();
}
}
private void Initialize()
{
- popupAttributes = attributes as PopupAttributes;
- if (popupAttributes == null)
- {
- throw new Exception("Popup attribute parse error.");
- }
-
- ApplyAttributes(this, popupAttributes);
LeaveRequired = true;
+ // ContentView
ContentView = new View()
{
ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
};
Add(ContentView);
ContentView.RaiseToTop();
- }
-
- private void CreateShadowAttributes()
- {
- if (popupAttributes.ShadowImageAttributes == null)
- {
- popupAttributes.ShadowImageAttributes = new ImageAttributes()
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.Center,
- PivotPoint = Tizen.NUI.PivotPoint.Center,
- };
- }
- }
- private void CreateBackgroundAttributes()
- {
- if (popupAttributes.BackgroundImageAttributes == null)
+ // Title
+ if (null == titleText)
{
- popupAttributes.BackgroundImageAttributes = new ImageAttributes()
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.Center,
- PivotPoint = Tizen.NUI.PivotPoint.Center,
- WidthResizePolicy = ResizePolicyType.FillToParent,
- HeightResizePolicy = ResizePolicyType.FillToParent
- };
+ titleText = new TextLabel();
+ Add(titleText);
}
- }
- private void CreateTitleTextAttributes()
- {
- if (popupAttributes.TitleTextAttributes == null)
- {
- popupAttributes.TitleTextAttributes = new TextAttributes()
- {
- Size = new Size(0, 0),
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- HorizontalAlignment = HorizontalAlignment.Begin,
- VerticalAlignment = VerticalAlignment.Bottom
- };
- }
+ buttonList = new List<Button>();
}
- private void CreateButtonAttributes()
+ private void UpdateButton()
{
- if (popupAttributes.ButtonAttributes == null)
- {
- popupAttributes.ButtonAttributes = new ButtonAttributes()
- {
- Size = new Size(0, 0),
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft,
- PivotPoint = Tizen.NUI.PivotPoint.BottomLeft,
- TextAttributes = new TextAttributes
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.Center,
- PivotPoint = Tizen.NUI.PivotPoint.Center,
- HorizontalAlignment = HorizontalAlignment.Center,
- VerticalAlignment = VerticalAlignment.Center
- },
- BackgroundImageAttributes = new ImageAttributes
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.Center,
- PivotPoint = Tizen.NUI.PivotPoint.Center,
- WidthResizePolicy = ResizePolicyType.FillToParent,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- Border = new RectangleSelector { All = new Rectangle(0, 0, 0, 0) },
- },
- OverlayImageAttributes = new ImageAttributes
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.Center,
- PivotPoint = Tizen.NUI.PivotPoint.Center,
- WidthResizePolicy = ResizePolicyType.FillToParent,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- Border = new RectangleSelector { All = new Rectangle(0, 0, 0, 0) },
- },
- };
- }
- }
+ if (buttonCount <= 0) return;
+ if (buttonTextList.Count != buttonCount) return;
- private void UpdateButton(int count)
- {
- if(buttonList != null && buttonCount == buttonList.Count)
- {
- for (int i = 0; i < count; i++)
- {
- buttonList[i].TextColor = popupAttributes.ButtonAttributes.TextAttributes.TextColor.All;
- }
- return;
- }
-
if (buttonList != null)
{
foreach (Button btn in buttonList)
btn.Dispose();
}
buttonList.Clear();
- buttonList = null;
}
- if(count <= 0)
- {
- return;
+
+ int buttonWidth = Size2D.Width / buttonCount;
+ int buttonHeight = (int)Style.Buttons.Size.Height;
+ for (int i = 0; i < buttonCount; i++)
+ {
+ Button btn = new Button(Style.Buttons);
+ btn.Size2D = new Size2D(buttonWidth, buttonHeight);
+ btn.Style.Text.Text = buttonTextList[i];
+ btn.ClickEvent += ButtonClickEvent;
+
+ this.Add(btn);
+ buttonList.Add(btn);
}
- int buttonWidth = Size2D.Width / count;
- int buttonHeight = (int)popupAttributes.ButtonAttributes.Size.Height;
+
int pos = 0;
- buttonList = new List<Button>();
- for (int i = 0; i < count; i++)
+ if (buttonList != null && buttonList.Count > 0)
{
- Button btn = null;
- popupAttributes.ButtonAttributes.Size.Width = buttonWidth;
- btn = new Button(popupAttributes.ButtonAttributes);
- btn.Position2D = new Position2D(pos, 0);
-
- if (i >= buttonTextList.Count)
+ if (LayoutDirection == ViewLayoutDirectionType.RTL)
{
- buttonTextList.Add("");
+ for (int i = buttonList.Count - 1; i >= 0; i--)
+ {
+ buttonList[i].PositionX = pos;
+ pos += buttonList[i].Size2D.Width;
+ }
+ }
+ else
+ {
+ for (int i = 0; i < buttonList.Count; i++)
+ {
+ buttonList[i].PositionX = pos;
+ pos += buttonList[i].Size2D.Width;
+ }
}
- btn.Text = buttonTextList[i];
- btn.ClickEvent += ButtonClickEvent;
- pos += buttonWidth;
- this.Add(btn);
- buttonList.Add(btn);
}
+
+ UpdateContentView();
}
private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
}
}
}
+ private void UpdateShadow()
+ {
+ if (Style.ShadowOffset == null) return;
+ int w = 0;
+ int h = 0;
+ if (Style.Shadow != null)
+ {
+ w = (int)(Size2D.Width + Style.ShadowOffset.W + Style.ShadowOffset.X);
+ h = (int)(Size2D.Height + Style.ShadowOffset.Y + Style.ShadowOffset.Z);
+
+ shadowImage.Size2D = new Size2D(w, h);
+ }
+ }
+
+ private void UpdateTitle()
+ {
+ int w = 0;
+ int h = 0;
+ int titleX = 0;
+ int titleY = 0;
+ int titleH = 0;
+ int buttonH = 0;
+
+ if (Style.Title != null)
+ {
+ if (titleText.Text != null && titleText.Text != "")
+ {
+ Style.Title.Text = new Selector<string> { All = titleText.Text };
+ w = (int)(Size2D.Width - titleText.PositionX * 2);
+
+ if (Style.Title.Size != null)
+ {
+ titleH = (int)titleText.Size.Height;
+ }
+ titleText.Size2D = new Size2D(w, titleH);
+ }
+ else
+ {
+ titleText.Size2D = new Size2D(0, 0);
+ }
+ }
+
+ if (titleText != null)
+ {
+ if (LayoutDirection == ViewLayoutDirectionType.RTL)
+ {
+ if (Style.Title != null)
+ {
+ Style.Title.HorizontalAlignment = HorizontalAlignment.End;
+ }
+ titleText.HorizontalAlignment = HorizontalAlignment.End;
+ }
+ else if (LayoutDirection == ViewLayoutDirectionType.LTR)
+ {
+ if (Style.Title != null)
+ {
+ Style.Title.HorizontalAlignment = HorizontalAlignment.Begin;
+ }
+ titleText.HorizontalAlignment = HorizontalAlignment.Begin;
+ }
+ }
+
+ UpdateContentView();
+ }
+
+ private void UpdateContentView()
+ {
+ int titleX = 0;
+ int titleY = 0;
+ int titleH = 0;
+ if (Style.Title.Size != null)
+ {
+ titleH = (int)titleText.Size.Height;
+ }
+ if (Style.Title.Position != null)
+ {
+ titleX = (int)Style.Title.Position.X;
+ titleY = (int)Style.Title.Position.Y;
+ }
+ int buttonH = (int)Style.Buttons.Size.Height;
+
+ ContentView.Size2D = new Size2D(Size2D.Width - titleX * 2, Size2D.Height - titleY - titleH - buttonH);
+ ContentView.Position2D = new Position2D(titleX, titleY + titleH);
+ ContentView.RaiseToTop();
+ }
/// <summary>
/// ButtonClickEventArgs is a class to record button click event arguments which will sent to user.