defaultValueCreator: (bindable) => ((Button)bindable).isEnabled);
/// 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 IsSelectedProperty = BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
+ public static readonly BindableProperty IsSelectedProperty = BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Button)bindable;
if (newValue != null)
instance.UpdateState();
}
- if (instance.IsHighlighted)
+ if (Accessibility.Accessibility.IsEnabled && instance.IsHighlighted)
{
- instance.EmitAccessibilityStateChangedEvent(AccessibilityState.Checked, newSelected);
+ instance.EmitAccessibilityStatesChangedEvent(AccessibilityStates.Checked, newSelected);
}
}
}
internal static readonly BindableProperty ItemAlignmentProperty = BindableProperty.Create(nameof(ItemAlignment), typeof(LinearLayout.Alignment), typeof(Button), LinearLayout.Alignment.Center, propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Button)bindable;
- instance.itemAlignment = (LinearLayout.Alignment)newValue;
- instance.LayoutItems();
+ var newAlignment = (LinearLayout.Alignment)newValue;
+
+ if (instance.itemAlignment != newAlignment)
+ {
+ instance.itemAlignment = newAlignment;
+ instance.LayoutItems();
+ }
},
defaultValueCreator: (bindable) => ((Button)bindable).itemAlignment);
private bool isSelectable = false;
private bool isEnabled = true;
private Size2D itemSpacing;
- private LinearLayout.Alignment itemAlignment;
+ private LinearLayout.Alignment itemAlignment = LinearLayout.Alignment.Center;
static Button() { }
/// Calculates current states for the button<br />
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- protected override AccessibilityStates AccessibilityCalculateStates()
+ protected override AccessibilityStates AccessibilityCalculateStates(ulong states)
{
- var states = base.AccessibilityCalculateStates();
- states.Set(AccessibilityState.Checked, this.IsSelected);
- states.Set(AccessibilityState.Enabled, this.IsEnabled);
- return states;
+ var accessibilityStates = base.AccessibilityCalculateStates(states);
+ FlagSetter(ref accessibilityStates, AccessibilityStates.Checked, this.IsSelected);
+ FlagSetter(ref accessibilityStates, AccessibilityStates.Enabled, this.IsEnabled);
+ return accessibilityStates;
}
/// <summary>
}
/// <summary>
- /// Return currently applied style.
+ /// The last applied style object copy.
/// </summary>
/// <remarks>
/// Modifying contents in style may cause unexpected behaviour.
{
get
{
+ return GetValue(TextProperty) as string;
+ }
+ set
+ {
+ SetValue(TextProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private string InternalText
+ {
+ get
+ {
return TextLabel.Text;
}
set
{
TextLabel.Text = value;
- if (IsHighlighted && String.IsNullOrEmpty(AccessibilityName) && GetAccessibilityNameSignal().Empty())
+ if (Accessibility.Accessibility.IsEnabled && IsHighlighted && String.IsNullOrEmpty(AccessibilityName) && GetAccessibilityNameSignal().Empty())
{
- EmitAccessibilityEvent(ObjectPropertyChangeEvent.Name);
+ EmitAccessibilityEvent(AccessibilityPropertyChangeEvent.Name);
}
}
}
{
get
{
+ return GetValue(TranslatableTextProperty) as string;
+ }
+ set
+ {
+ SetValue(TranslatableTextProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private string InternalTranslatableText
+ {
+ get
+ {
return TextLabel.TranslatableText;
}
set
{
get
{
+ return (float)GetValue(PointSizeProperty);
+ }
+ set
+ {
+ SetValue(PointSizeProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private float InternalPointSize
+ {
+ get
+ {
return TextLabel.PointSize;
}
set
{
get
{
+ return GetValue(FontFamilyProperty) as string;
+ }
+ set
+ {
+ SetValue(FontFamilyProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private string InternalFontFamily
+ {
+ get
+ {
return TextLabel.FontFamily;
}
set
{
get
{
+ return GetValue(TextColorProperty) as Color;
+ }
+ set
+ {
+ SetValue(TextColorProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private Color InternalTextColor
+ {
+ get
+ {
return TextLabel.TextColor;
}
set
{
get
{
+ return (HorizontalAlignment)GetValue(TextAlignmentProperty);
+ }
+ set
+ {
+ SetValue(TextAlignmentProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private HorizontalAlignment InternalTextAlignment
+ {
+ get
+ {
return TextLabel.HorizontalAlignment;
}
set
{
get
{
+ return GetValue(IconURLProperty) as string;
+ }
+ set
+ {
+ SetValue(IconURLProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private string InternalIconURL
+ {
+ get
+ {
return Icon.ResourceUrl;
}
set
}
/// <summary>
+ /// Icon image's size in Button.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Size IconSize
+ {
+ get
+ {
+ return GetValue(IconSizeProperty) as Size;
+ }
+ set
+ {
+ SetValue(IconSizeProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private Size InternalIconSize
+ {
+ get => Icon.Size;
+ set => Icon.Size = value;
+ }
+
+ /// <summary>
/// Text string selector in Button.
/// Getter returns copied selector value if exist, null otherwise.
/// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
/// <since_tizen> 6 </since_tizen>
public StringSelector TextSelector
{
- get => buttonText == null ? null : new StringSelector((Selector<string>)buttonText.GetValue(TextLabel.TextSelectorProperty));
+ get
+ {
+ return GetValue(TextSelectorProperty) as StringSelector;
+ }
+ set
+ {
+ SetValue(TextSelectorProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private StringSelector InternalTextSelector
+ {
+ get => buttonText?.TextSelector == null ? null : new StringSelector(buttonText.TextSelector);
set
{
if (value == null || buttonText == null)
}
else
{
- buttonText.SetValue(TextLabel.TextSelectorProperty, value);
+ buttonText.TextSelector = value;
}
}
}
/// <since_tizen> 6 </since_tizen>
public StringSelector TranslatableTextSelector
{
- get => buttonText == null ? null : new StringSelector((Selector<string>)buttonText.GetValue(TextLabel.TranslatableTextSelectorProperty));
+ get
+ {
+ return GetValue(TranslatableTextSelectorProperty) as StringSelector;
+ }
+ set
+ {
+ SetValue(TranslatableTextSelectorProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private StringSelector InternalTranslatableTextSelector
+ {
+ get => (buttonText?.TranslatableTextSelector == null) ? null : new StringSelector(buttonText.TranslatableTextSelector);
set
{
if (value == null || buttonText == null)
}
else
{
- buttonText.SetValue(TextLabel.TranslatableTextSelectorProperty, value);
+ buttonText.TranslatableTextSelector = value;
}
}
}
/// <since_tizen> 6 </since_tizen>
public ColorSelector TextColorSelector
{
- get => buttonText == null ? null : new ColorSelector((Selector<Color>)buttonText.GetValue(TextLabel.TextColorSelectorProperty));
+ get
+ {
+ return GetValue(TextColorSelectorProperty) as ColorSelector;
+ }
+ set
+ {
+ SetValue(TextColorSelectorProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private ColorSelector InternalTextColorSelector
+ {
+ get => buttonText?.TextColorSelector == null ? null : new ColorSelector(buttonText.TextColorSelector);
set
{
if (value == null || buttonText == null)
}
else
{
- buttonText.SetValue(TextLabel.TextColorSelectorProperty, value);
+ buttonText.TextColorSelector = value;
}
}
}
/// <since_tizen> 6 </since_tizen>
public FloatSelector PointSizeSelector
{
- get => buttonText == null ? null : new FloatSelector((Selector<float?>)buttonText.GetValue(TextLabel.PointSizeSelectorProperty));
+ get
+ {
+ return GetValue(PointSizeSelectorProperty) as FloatSelector;
+ }
+ set
+ {
+ SetValue(PointSizeSelectorProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private FloatSelector InternalPointSizeSelector
+ {
+ get => buttonText?.PointSizeSelector == null ? null : new FloatSelector(buttonText.PointSizeSelector);
set
{
if (value == null || buttonText == null)
}
else
{
- buttonText.SetValue(TextLabel.PointSizeSelectorProperty, value);
+ buttonText.PointSizeSelector = value;
}
}
}
/// <since_tizen> 6 </since_tizen>
public StringSelector IconURLSelector
{
- get => buttonIcon == null ? null : new StringSelector((Selector<string>)buttonIcon.GetValue(ImageView.ResourceUrlSelectorProperty));
+ get
+ {
+ return GetValue(IconURLSelectorProperty) as StringSelector;
+ }
+ set
+ {
+ SetValue(IconURLSelectorProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private StringSelector InternalIconURLSelector
+ {
+ get => buttonIcon?.ResourceUrlSelector == null ? null : new StringSelector(buttonIcon.ResourceUrlSelector);
set
{
if (value == null || buttonIcon == null)
}
else
{
- buttonIcon.SetValue(ImageView.ResourceUrlSelectorProperty, value);
+ buttonIcon.ResourceUrlSelector = value;
}
}
}
/// <summary>
/// The item (text or icon or both) alignment.
/// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
+ /// <since_tizen> 9 </since_tizen>
public LinearLayout.Alignment ItemAlignment
{
get => (LinearLayout.Alignment)GetValue(ItemAlignmentProperty);
/// The value is applied when there exist icon and text both.
/// The width value is used when the items are arranged horizontally. Otherwise, the height value is used.
/// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
+ /// <since_tizen> 9 </since_tizen>
public Size2D ItemSpacing
{
get => (Size2D)GetValue(ItemSpacingProperty);
Extension = buttonStyle.CreateExtension();
if (buttonStyle.Overlay != null)
- {
+ {
OverlayImage?.ApplyStyle(buttonStyle.Overlay);
}
if (buttonStyle.Text != null)
{
+ buttonText.ThemeChangeSensitive = false;
buttonText.ApplyStyle(buttonStyle.Text);
}