2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.ComponentModel;
19 using Tizen.NUI.BaseComponents;
20 using Tizen.NUI.Binding;
22 namespace Tizen.NUI.Components
25 /// Button is one kind of common component, a button clearly describes what action will occur when the user selects it.
26 /// Button may contain text or an icon.
28 /// <since_tizen> 6 </since_tizen>
29 public class Button : Control
31 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
32 [EditorBrowsable(EditorBrowsableState.Never)]
33 public static readonly BindableProperty IconRelativeOrientationProperty = BindableProperty.Create(nameof(IconRelativeOrientation), typeof(IconOrientation?), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
35 var instance = (Button)bindable;
38 instance.privateIconRelativeOrientation = (IconOrientation?)newValue;
41 defaultValueCreator: (bindable) =>
43 var instance = (Button)bindable;
44 return instance.privateIconRelativeOrientation;
46 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
47 [EditorBrowsable(EditorBrowsableState.Never)]
48 public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
50 var instance = (Button)bindable;
53 instance.privateIsEnabled = (bool)newValue;
56 defaultValueCreator: (bindable) =>
58 var instance = (Button)bindable;
59 return instance.privateIsEnabled;
61 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
62 [EditorBrowsable(EditorBrowsableState.Never)]
63 public static readonly BindableProperty IsSelectedProperty = BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
65 var instance = (Button)bindable;
68 instance.privateIsSelected = (bool)newValue;
71 defaultValueCreator: (bindable) =>
73 var instance = (Button)bindable;
74 return instance.privateIsSelected;
76 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
77 [EditorBrowsable(EditorBrowsableState.Never)]
78 public static readonly BindableProperty IsSelectableProperty = BindableProperty.Create(nameof(IsSelectable), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
80 var instance = (Button)bindable;
83 instance.privateIsSelectable = (bool)newValue;
86 defaultValueCreator: (bindable) =>
88 var instance = (Button)bindable;
89 return instance.privateIsSelectable;
91 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
92 [EditorBrowsable(EditorBrowsableState.Never)]
93 public static readonly BindableProperty IconPaddingProperty = BindableProperty.Create(nameof(IconPadding), typeof(Extents), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
95 var instance = (Button)bindable;
96 if (null != newValue && null != instance.Style?.IconPadding)
98 instance.Style.IconPadding.CopyFrom((Extents)newValue);
99 instance.UpdateUIContent();
102 defaultValueCreator: (bindable) =>
104 var instance = (Button)bindable;
105 return instance.Style?.IconPadding;
107 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
108 [EditorBrowsable(EditorBrowsableState.Never)]
109 public static readonly BindableProperty TextPaddingProperty = BindableProperty.Create(nameof(TextPadding), typeof(Extents), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
111 var instance = (Button)bindable;
112 if (null != newValue && null != instance.Style?.TextPadding)
114 instance.Style.TextPadding.CopyFrom((Extents)newValue);
115 instance.UpdateUIContent();
118 defaultValueCreator: (bindable) =>
120 var instance = (Button)bindable;
121 return instance.Style?.TextPadding;
124 private ImageView overlayImage;
126 private TextLabel buttonText;
127 private ImageView buttonIcon;
129 private EventHandler<StateChangedEventArgs> stateChangeHander;
131 private bool isSelected = false;
132 private bool isEnabled = true;
133 private bool isPressed = false;
138 /// Creates a new instance of a Button.
140 /// <since_tizen> 6 </since_tizen>
141 public Button() : base()
147 /// Creates a new instance of a Button with style.
149 /// <param name="style">Create Button by special style defined in UX.</param>
150 /// <since_tizen> 6 </since_tizen>
151 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
152 [EditorBrowsable(EditorBrowsableState.Never)]
153 public Button(string style) : base(style)
159 /// Creates a new instance of a Button with attributes.
161 /// <param name="controlStyle">Create Button by attributes customized by user.</param>
162 /// <since_tizen> 6 </since_tizen>
163 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
164 [EditorBrowsable(EditorBrowsableState.Never)]
165 public Button(ButtonStyle controlStyle) : base(controlStyle)
171 /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
173 /// <since_tizen> 6 </since_tizen>
174 public event EventHandler<ClickEventArgs> ClickEvent;
176 /// An event for the button state changed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
178 /// <since_tizen> 6 </since_tizen>
179 public event EventHandler<StateChangedEventArgs> StateChangedEvent
183 stateChangeHander += value;
187 stateChangeHander -= value;
191 /// Icon orientation.
193 /// <since_tizen> 6 </since_tizen>
194 public enum IconOrientation
199 /// <since_tizen> 6 </since_tizen>
204 /// <since_tizen> 6 </since_tizen>
209 /// <since_tizen> 6 </since_tizen>
214 /// <since_tizen> 6 </since_tizen>
218 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
219 [EditorBrowsable(EditorBrowsableState.Never)]
220 public new ButtonStyle Style => ViewStyle as ButtonStyle;
223 /// The text of Button.
225 /// <since_tizen> 6 </since_tizen>
230 return Style?.Text?.Text?.GetValue(ControlState);
234 if (null != Style?.Text)
236 Style.Text.Text = value;
242 /// Flag to decide Button can be selected or not.
244 /// <since_tizen> 6 </since_tizen>
245 public bool IsSelectable
249 return (bool)GetValue(IsSelectableProperty);
253 SetValue(IsSelectableProperty, value);
257 private bool privateIsSelectable
261 return Style?.IsSelectable ?? false;
265 Style.IsSelectable = value;
270 /// Translate text string in Button.
272 /// <since_tizen> 6 </since_tizen>
273 public string TranslatableText
277 return Style?.Text?.TranslatableText?.All;
281 if (null != Style?.Text)
283 Style.Text.TranslatableText = value;
289 /// Text point size in Button.
291 /// <since_tizen> 6 </since_tizen>
292 public float PointSize
296 return Style?.Text?.PointSize?.All ?? 0;
300 if (null != Style?.Text)
302 Style.Text.PointSize = value;
308 /// Text font family in Button.
310 /// <since_tizen> 6 </since_tizen>
311 public string FontFamily
315 return Style?.Text?.FontFamily.All;
319 if (null != Style?.Text)
321 Style.Text.FontFamily = value;
326 /// Text color in Button.
328 /// <since_tizen> 6 </since_tizen>
329 public Color TextColor
333 return Style?.Text?.TextColor?.All;
337 if (null != Style?.Text)
339 Style.Text.TextColor = value;
344 /// Text horizontal alignment in Button.
346 /// <since_tizen> 6 </since_tizen>
347 public HorizontalAlignment TextAlignment
351 return Style?.Text?.HorizontalAlignment ?? HorizontalAlignment.Center;
355 if (null != Style?.Text)
357 Style.Text.HorizontalAlignment = value;
362 /// Icon image's resource url in Button.
364 /// <since_tizen> 6 </since_tizen>
365 public string IconURL
369 return Style?.Icon?.ResourceUrl?.All;
373 if (null != Style?.Icon)
375 Style.Icon.ResourceUrl = value;
380 private StringSelector textSelector = new StringSelector();
382 /// Text string selector in Button.
384 /// <since_tizen> 6 </since_tizen>
385 public StringSelector TextSelector
393 textSelector.Clone(value);
397 private StringSelector translatableTextSelector = new StringSelector();
399 /// Translateable text string selector in Button.
401 /// <since_tizen> 6 </since_tizen>
402 public StringSelector TranslatableTextSelector
406 return translatableTextSelector;
410 translatableTextSelector.Clone(value);
414 private ColorSelector textColorSelector = new ColorSelector();
416 /// Text color selector in Button.
418 /// <since_tizen> 6 </since_tizen>
419 public ColorSelector TextColorSelector
423 return textColorSelector;
427 textColorSelector.Clone(value);
431 private FloatSelector pointSizeSelector = new FloatSelector();
433 /// Text font size selector in Button.
435 /// <since_tizen> 6 </since_tizen>
436 public FloatSelector PointSizeSelector
440 return pointSizeSelector;
444 pointSizeSelector.Clone(value);
448 private StringSelector iconURLSelector = new StringSelector();
450 /// Icon image's resource url selector in Button.
452 /// <since_tizen> 6 </since_tizen>
453 public StringSelector IconURLSelector
457 return iconURLSelector;
461 iconURLSelector.Clone(value);
466 /// Flag to decide selected state in Button.
468 /// <since_tizen> 6 </since_tizen>
469 public bool IsSelected
473 return (bool)GetValue(IsSelectedProperty);
477 SetValue(IsSelectedProperty, value);
480 private bool privateIsSelected
493 /// Flag to decide enable or disable in Button.
495 /// <since_tizen> 6 </since_tizen>
496 public bool IsEnabled
500 return (bool)GetValue(IsEnabledProperty);
504 SetValue(IsEnabledProperty, value);
507 private bool privateIsEnabled
521 /// Icon relative orientation in Button, work only when show icon and text.
523 /// <since_tizen> 6 </since_tizen>
524 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
525 [EditorBrowsable(EditorBrowsableState.Never)]
526 public IconOrientation? IconRelativeOrientation
530 return (IconOrientation?)GetValue(IconRelativeOrientationProperty);
534 SetValue(IconRelativeOrientationProperty, value);
537 private IconOrientation? privateIconRelativeOrientation
541 return Style?.IconRelativeOrientation;
545 if(Style != null && Style.IconRelativeOrientation != value)
547 Style.IconRelativeOrientation = value;
554 /// Icon padding in Button, work only when show icon and text.
556 /// <since_tizen> 6 </since_tizen>
557 public Extents IconPadding
559 get => (Extents)GetValue(IconPaddingProperty);
560 set => SetValue(IconPaddingProperty, value);
564 /// Text padding in Button, work only when show icon and text.
566 /// <since_tizen> 6 </since_tizen>
567 public Extents TextPadding
569 get => (Extents) GetValue(TextPaddingProperty);
570 set => SetValue(TextPaddingProperty, value);
574 /// Dispose Button and all children on it.
576 /// <param name="type">Dispose type.</param>
577 /// <since_tizen> 6 </since_tizen>
578 protected override void Dispose(DisposeTypes type)
585 if (type == DisposeTypes.Explicit)
587 if (buttonIcon != null)
589 Utility.Dispose(buttonIcon);
591 if (buttonText != null)
593 Utility.Dispose(buttonText);
595 if (overlayImage != null)
597 Utility.Dispose(overlayImage);
604 /// Called after a key event is received by the view that has had its focus set.
606 /// <param name="key">The key event.</param>
607 /// <returns>True if the key event should be consumed.</returns>
608 /// <since_tizen> 6 </since_tizen>
609 public override bool OnKey(Key key)
611 if (null == key) return false;
612 if (key.State == Key.StateType.Down)
614 if (key.KeyPressedName == "Return")
620 ClickEventArgs eventArgs = new ClickEventArgs();
625 else if (key.State == Key.StateType.Up)
627 if (key.KeyPressedName == "Return")
630 if (Style.IsSelectable != null && Style.IsSelectable == true)
632 isSelected = !isSelected;
637 return base.OnKey(key);
641 /// Called when the control gain key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is gained.
643 /// <since_tizen> 6 </since_tizen>
644 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
645 [EditorBrowsable(EditorBrowsableState.Never)]
646 public override void OnFocusGained()
648 base.OnFocusGained();
653 /// Called when the control loses key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is lost.
655 /// <since_tizen> 6 </since_tizen>
656 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
657 [EditorBrowsable(EditorBrowsableState.Never)]
658 public override void OnFocusLost()
665 /// Tap gesture event callback.
667 /// <param name="source">Source which recieved touch event.</param>
668 /// <param name="e">Tap gesture event argument.</param>
669 /// <since_tizen> 6 </since_tizen>
670 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
671 [EditorBrowsable(EditorBrowsableState.Never)]
672 protected override void OnTapGestureDetected(object source, TapGestureDetector.DetectedEventArgs e)
676 ClickEventArgs eventArgs = new ClickEventArgs();
678 base.OnTapGestureDetected(source, e);
682 /// Called after a touch event is received by the owning view.<br />
683 /// CustomViewBehaviour.REQUIRES_TOUCH_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
685 /// <param name="touch">The touch event.</param>
686 /// <returns>True if the event should be consumed.</returns>
687 /// <since_tizen> 6 </since_tizen>
688 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
689 [EditorBrowsable(EditorBrowsableState.Never)]
690 public override bool OnTouch(Touch touch)
692 if (null == touch) return false;
693 PointStateType state = touch.GetState(0);
697 case PointStateType.Down:
701 case PointStateType.Interrupted:
705 case PointStateType.Up:
707 if (Style.IsSelectable != null && Style.IsSelectable == true)
709 isSelected = !isSelected;
716 return base.OnTouch(touch);
719 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
720 [EditorBrowsable(EditorBrowsableState.Never)]
721 public override void ApplyStyle(ViewStyle viewStyle)
723 base.ApplyStyle(viewStyle);
725 ButtonStyle buttonStyle = viewStyle as ButtonStyle;
727 if (null != buttonStyle)
729 if (null == overlayImage)
731 overlayImage = new ImageView()
733 WidthResizePolicy = ResizePolicyType.FillToParent,
734 HeightResizePolicy = ResizePolicyType.FillToParent
736 this.Add(overlayImage);
739 if (null == buttonText)
741 buttonText = new TextLabel();
742 this.Add(buttonText);
745 if (null == buttonIcon)
747 buttonIcon = new ImageView();
748 this.Add(buttonIcon);
751 overlayImage.ApplyStyle(buttonStyle.Overlay);
752 buttonText.ApplyStyle(buttonStyle.Text);
753 buttonIcon.ApplyStyle(buttonStyle.Icon);
758 /// Get Button attribues.
760 /// <since_tizen> 6 </since_tizen>
761 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
762 [EditorBrowsable(EditorBrowsableState.Never)]
763 protected override ViewStyle GetViewStyle()
765 return new ButtonStyle();
768 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
769 [EditorBrowsable(EditorBrowsableState.Never)]
770 protected override void OnUpdate()
777 /// Update Button State.
779 /// <since_tizen> 6 </since_tizen>
780 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
781 [EditorBrowsable(EditorBrowsableState.Never)]
782 protected void UpdateState()
784 ControlStates sourceState = ControlState;
785 ControlStates targetState;
789 targetState = isPressed ? ControlStates.Pressed : (IsFocused ? (IsSelected ? ControlStates.SelectedFocused : ControlStates.Focused) : (IsSelected ? ControlStates.Selected : ControlStates.Normal));
793 targetState = IsSelected ? ControlStates.DisabledSelected : (IsFocused ? ControlStates.DisabledFocused : ControlStates.Disabled);
796 if(sourceState != targetState)
798 ControlState = targetState;
802 StateChangedEventArgs e = new StateChangedEventArgs
804 PreviousState = sourceState,
805 CurrentState = targetState
807 stateChangeHander?.Invoke(this, e);
812 /// It is hijack by using protected, attributes copy problem when class inherited from Button.
814 /// <since_tizen> 6 </since_tizen>
815 private void Initialize()
817 if (null == Style.IconRelativeOrientation) Style.IconRelativeOrientation = IconOrientation.Left;
819 LayoutDirectionChanged += OnLayoutDirectionChanged;
823 /// Measure text, it can be override.
825 /// <since_tizen> 6 </since_tizen>
826 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
827 [EditorBrowsable(EditorBrowsableState.Never)]
828 protected virtual void MeasureText()
830 if (Style.IconRelativeOrientation == null || buttonIcon == null || buttonText == null)
834 buttonText.WidthResizePolicy = ResizePolicyType.Fixed;
835 buttonText.HeightResizePolicy = ResizePolicyType.Fixed;
836 int textPaddingStart = Style.TextPadding.Start;
837 int textPaddingEnd = Style.TextPadding.End;
838 int textPaddingTop = Style.TextPadding.Top;
839 int textPaddingBottom = Style.TextPadding.Bottom;
841 int iconPaddingStart = Style.IconPadding.Start;
842 int iconPaddingEnd = Style.IconPadding.End;
843 int iconPaddingTop = Style.IconPadding.Top;
844 int iconPaddingBottom = Style.IconPadding.Bottom;
846 if (IconRelativeOrientation == IconOrientation.Top || IconRelativeOrientation == IconOrientation.Bottom)
848 buttonText.SizeWidth = SizeWidth - textPaddingStart - textPaddingEnd;
849 buttonText.SizeHeight = SizeHeight - textPaddingTop - textPaddingBottom - iconPaddingTop - iconPaddingBottom - buttonIcon.SizeHeight;
853 buttonText.SizeWidth = SizeWidth - textPaddingStart - textPaddingEnd - iconPaddingStart - iconPaddingEnd - buttonIcon.SizeWidth;
854 buttonText.SizeHeight = SizeHeight - textPaddingTop - textPaddingBottom;
858 /// Layout child, it can be override.
860 /// <since_tizen> 6 </since_tizen>
861 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
862 [EditorBrowsable(EditorBrowsableState.Never)]
863 protected virtual void LayoutChild()
865 if (Style.IconRelativeOrientation == null || buttonIcon == null || buttonText == null)
870 int textPaddingStart = Style.TextPadding.Start;
871 int textPaddingEnd = Style.TextPadding.End;
872 int textPaddingTop = Style.TextPadding.Top;
873 int textPaddingBottom = Style.TextPadding.Bottom;
875 int iconPaddingStart = Style.IconPadding.Start;
876 int iconPaddingEnd = Style.IconPadding.End;
877 int iconPaddingTop = Style.IconPadding.Top;
878 int iconPaddingBottom = Style.IconPadding.Bottom;
880 switch (IconRelativeOrientation)
882 case IconOrientation.Top:
883 buttonIcon.PositionUsesPivotPoint = true;
884 buttonIcon.ParentOrigin = NUI.ParentOrigin.TopCenter;
885 buttonIcon.PivotPoint = NUI.PivotPoint.TopCenter;
886 buttonIcon.Position2D = new Position2D(0, iconPaddingTop);
888 buttonText.PositionUsesPivotPoint = true;
889 buttonText.ParentOrigin = NUI.ParentOrigin.BottomCenter;
890 buttonText.PivotPoint = NUI.PivotPoint.BottomCenter;
891 buttonText.Position2D = new Position2D(0, -textPaddingBottom);
893 case IconOrientation.Bottom:
894 buttonIcon.PositionUsesPivotPoint = true;
895 buttonIcon.ParentOrigin = NUI.ParentOrigin.BottomCenter;
896 buttonIcon.PivotPoint = NUI.PivotPoint.BottomCenter;
897 buttonIcon.Position2D = new Position2D(0, -iconPaddingBottom);
899 buttonText.PositionUsesPivotPoint = true;
900 buttonText.ParentOrigin = NUI.ParentOrigin.TopCenter;
901 buttonText.PivotPoint = NUI.PivotPoint.TopCenter;
902 buttonText.Position2D = new Position2D(0, textPaddingTop);
904 case IconOrientation.Left:
905 if (LayoutDirection == ViewLayoutDirectionType.LTR)
907 buttonIcon.PositionUsesPivotPoint = true;
908 buttonIcon.ParentOrigin = NUI.ParentOrigin.CenterLeft;
909 buttonIcon.PivotPoint = NUI.PivotPoint.CenterLeft;
910 buttonIcon.Position2D = new Position2D(iconPaddingStart, 0);
912 buttonText.PositionUsesPivotPoint = true;
913 buttonText.ParentOrigin = NUI.ParentOrigin.CenterRight;
914 buttonText.PivotPoint = NUI.PivotPoint.CenterRight;
915 buttonText.Position2D = new Position2D(-textPaddingEnd, 0);
919 buttonIcon.PositionUsesPivotPoint = true;
920 buttonIcon.ParentOrigin = NUI.ParentOrigin.CenterRight;
921 buttonIcon.PivotPoint = NUI.PivotPoint.CenterRight;
922 buttonIcon.Position2D = new Position2D(-iconPaddingStart, 0);
924 buttonText.PositionUsesPivotPoint = true;
925 buttonText.ParentOrigin = NUI.ParentOrigin.CenterLeft;
926 buttonText.PivotPoint = NUI.PivotPoint.CenterLeft;
927 buttonText.Position2D = new Position2D(textPaddingEnd, 0);
931 case IconOrientation.Right:
932 if (LayoutDirection == ViewLayoutDirectionType.RTL)
934 buttonIcon.PositionUsesPivotPoint = true;
935 buttonIcon.ParentOrigin = NUI.ParentOrigin.CenterLeft;
936 buttonIcon.PivotPoint = NUI.PivotPoint.CenterLeft;
937 buttonIcon.Position2D = new Position2D(iconPaddingEnd, 0);
939 buttonText.PositionUsesPivotPoint = true;
940 buttonText.ParentOrigin = NUI.ParentOrigin.CenterRight;
941 buttonText.PivotPoint = NUI.PivotPoint.CenterRight;
942 buttonText.Position2D = new Position2D(-textPaddingStart, 0);
946 buttonIcon.PositionUsesPivotPoint = true;
947 buttonIcon.ParentOrigin = NUI.ParentOrigin.CenterRight;
948 buttonIcon.PivotPoint = NUI.PivotPoint.CenterRight;
949 buttonIcon.Position2D = new Position2D(-iconPaddingEnd, 0);
951 buttonText.PositionUsesPivotPoint = true;
952 buttonText.ParentOrigin = NUI.ParentOrigin.CenterLeft;
953 buttonText.PivotPoint = NUI.PivotPoint.CenterLeft;
954 buttonText.Position2D = new Position2D(textPaddingStart, 0);
960 if (string.IsNullOrEmpty(buttonText.Text))
962 buttonIcon.ParentOrigin = NUI.ParentOrigin.Center;
963 buttonIcon.PivotPoint = NUI.PivotPoint.Center;
967 /// Theme change callback when theme is changed, this callback will be trigger.
969 /// <since_tizen> 6 </since_tizen>
970 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
971 [EditorBrowsable(EditorBrowsableState.Never)]
972 protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e)
974 ButtonStyle tempAttributes = StyleManager.Instance.GetViewStyle(style) as ButtonStyle;
975 if (tempAttributes != null)
977 Style.CopyFrom(tempAttributes);
982 private void UpdateUIContent()
987 Sensitive = isEnabled;
990 private void OnLayoutDirectionChanged(object sender, LayoutDirectionChangedEventArgs e)
996 private void OnClick(ClickEventArgs eventArgs)
998 ClickEvent?.Invoke(this, eventArgs);
1001 private void OnIconRelayout(object sender, EventArgs e)
1008 /// ClickEventArgs is a class to record button click event arguments which will sent to user.
1010 /// <since_tizen> 6 </since_tizen>
1011 public class ClickEventArgs : EventArgs
1015 /// StateChangeEventArgs is a class to record button state change event arguments which will sent to user.
1017 /// <since_tizen> 6 </since_tizen>
1018 public class StateChangedEventArgs : EventArgs
1020 /// <summary> previous state of Button </summary>
1021 /// <since_tizen> 6 </since_tizen>
1022 public ControlStates PreviousState;
1023 /// <summary> current state of Button </summary>
1024 /// <since_tizen> 6 </since_tizen>
1025 public ControlStates CurrentState;