[NUI] Enable selectors work in View : EnableControlState (#1851)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / Button.cs
1 /*
2  * Copyright(c) 2020 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using System;
18 using System.ComponentModel;
19 using Tizen.NUI.BaseComponents;
20 using Tizen.NUI.Binding;
21 using Tizen.NUI.Components.Extension;
22
23 namespace Tizen.NUI.Components
24 {
25     /// <summary>
26     /// ClickedEventArgs is a class to record button click event arguments which will sent to user.
27     /// </summary>
28     /// <since_tizen> 8 </since_tizen>
29     public class ClickedEventArgs : EventArgs
30     {
31     }
32
33     /// <summary>
34     /// Button is one kind of common component, a button clearly describes what action will occur when the user selects it.
35     /// Button may contain text or an icon.
36     /// </summary>
37     /// <since_tizen> 6 </since_tizen>
38     public partial class Button : Control
39     {
40         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
41         [EditorBrowsable(EditorBrowsableState.Never)]
42         public static readonly BindableProperty IconRelativeOrientationProperty = BindableProperty.Create(nameof(IconRelativeOrientation), typeof(IconOrientation?), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
43         {
44             var instance = (Button)bindable;
45             if (newValue != null)
46             {
47                 if (instance.buttonStyle != null && instance.buttonStyle.IconRelativeOrientation != (IconOrientation?)newValue)
48                 {
49                     instance.buttonStyle.IconRelativeOrientation = (IconOrientation?)newValue;
50                     instance.UpdateUIContent();
51                 }
52             }
53         },
54         defaultValueCreator: (bindable) =>
55         {
56             var instance = (Button)bindable;
57             return instance.buttonStyle?.IconRelativeOrientation;
58         });
59         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
60         [EditorBrowsable(EditorBrowsableState.Never)]
61         public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
62         {
63             var instance = (Button)bindable;
64             if (newValue != null)
65             {
66                 if (instance.buttonStyle != null && (!instance.styleApplied || instance.buttonStyle.IsEnabled != (bool)newValue))
67                 {
68                     instance.buttonStyle.IsEnabled = (bool)newValue;
69                     instance.UpdateState();
70                 }
71             }
72         },
73         defaultValueCreator: (bindable) =>
74         {
75             var instance = (Button)bindable;
76             return instance.buttonStyle?.IsEnabled ?? true;
77         });
78         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
79         [EditorBrowsable(EditorBrowsableState.Never)]
80         public static readonly BindableProperty IsSelectedProperty = BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
81         {
82             var instance = (Button)bindable;
83             if (newValue != null)
84             {
85                 if (instance.buttonStyle != null && instance.IsSelectable && (!instance.styleApplied || instance.buttonStyle.IsSelected != (bool)newValue))
86                 {
87                     instance.buttonStyle.IsSelected = (bool)newValue;
88                     instance.UpdateState();
89                 }
90             }
91         },
92         defaultValueCreator: (bindable) =>
93         {
94             var instance = (Button)bindable;
95             return instance.IsSelectable && (instance.buttonStyle.IsSelected ?? false);
96         });
97         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
98         [EditorBrowsable(EditorBrowsableState.Never)]
99         public static readonly BindableProperty IsSelectableProperty = BindableProperty.Create(nameof(IsSelectable), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
100         {
101             var instance = (Button)bindable;
102             if (newValue != null)
103             {
104                 if (instance.buttonStyle != null && (!instance.styleApplied || instance.buttonStyle.IsSelectable != (bool)newValue))
105                 {
106                     instance.buttonStyle.IsSelectable = (bool)newValue;
107                 }
108             }
109         },
110         defaultValueCreator: (bindable) =>
111         {
112             var instance = (Button)bindable;
113             return instance.buttonStyle?.IsSelectable ?? false;
114         });
115         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
116         [EditorBrowsable(EditorBrowsableState.Never)]
117         public static readonly BindableProperty IconPaddingProperty = BindableProperty.Create(nameof(IconPadding), typeof(Extents), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
118         {
119             var instance = (Button)bindable;
120             if (null != newValue && null != instance.buttonStyle?.IconPadding)
121             {
122                 instance.buttonStyle.IconPadding.CopyFrom((Extents)newValue);
123                 instance.UpdateUIContent();
124             }
125         },
126         defaultValueCreator: (bindable) =>
127         {
128             var instance = (Button)bindable;
129             return instance.buttonStyle?.IconPadding;
130         });
131         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
132         [EditorBrowsable(EditorBrowsableState.Never)]
133         public static readonly BindableProperty TextPaddingProperty = BindableProperty.Create(nameof(TextPadding), typeof(Extents), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
134         {
135             var instance = (Button)bindable;
136             if (null != newValue && null != instance.buttonStyle?.TextPadding)
137             {
138                 instance.buttonStyle.TextPadding.CopyFrom((Extents)newValue);
139                 instance.UpdateUIContent();
140             }
141         },
142         defaultValueCreator: (bindable) =>
143         {
144             var instance = (Button)bindable;
145             return instance.buttonStyle?.TextPadding;
146         });
147
148         static Button() { }
149
150         /// <summary>
151         /// Creates a new instance of a Button.
152         /// </summary>
153         /// <since_tizen> 6 </since_tizen>
154         public Button() : base()
155         {
156             Initialize();
157         }
158
159         /// <summary>
160         /// Creates a new instance of a Button with style.
161         /// </summary>
162         /// <param name="style">Create Button by special style defined in UX.</param>
163         /// <since_tizen> 8 </since_tizen>
164         public Button(string style) : base(style)
165         {
166             Initialize();
167         }
168
169         /// <summary>
170         /// Creates a new instance of a Button with style.
171         /// </summary>
172         /// <param name="buttonStyle">Create Button by style customized by user.</param>
173         /// <since_tizen> 8 </since_tizen>
174         public Button(ButtonStyle buttonStyle) : base(buttonStyle)
175         {
176             Initialize();
177         }
178
179         /// <summary>
180         /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
181         /// </summary>
182         /// <since_tizen> 6 </since_tizen>
183         [Obsolete("Deprecated in API8; Will be removed in API10. Please use Clicked event instead.")]
184         public event EventHandler<ClickEventArgs> ClickEvent;
185
186         /// <summary>
187         /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.
188         /// </summary>
189         /// <since_tizen> 8 </since_tizen>
190         public event EventHandler<ClickedEventArgs> Clicked;
191
192         /// <summary>
193         /// An event for the button state changed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
194         /// </summary>
195         /// <since_tizen> 6 </since_tizen>
196         [Obsolete("Deprecated in API8; Will be removed in API10. Please use View.ControlStateChangedEvent")]
197         public event EventHandler<StateChangedEventArgs> StateChangedEvent
198         {
199             add
200             {
201                 stateChangeHandler += value;
202             }
203             remove
204             {
205                 stateChangeHandler -= value;
206             }
207         }
208
209         /// <summary>
210         /// Icon orientation.
211         /// </summary>
212         /// <since_tizen> 6 </since_tizen>
213         public enum IconOrientation
214         {
215             /// <summary>
216             /// Top.
217             /// </summary>
218             /// <since_tizen> 6 </since_tizen>
219             Top,
220             /// <summary>
221             /// Bottom.
222             /// </summary>
223             /// <since_tizen> 6 </since_tizen>
224             Bottom,
225             /// <summary>
226             /// Left.
227             /// </summary>
228             /// <since_tizen> 6 </since_tizen>
229             Left,
230             /// <summary>
231             /// Right.
232             /// </summary>
233             /// <since_tizen> 6 </since_tizen>
234             Right,
235         }
236
237         /// <summary>
238         /// Button's icon part.
239         /// </summary>
240         /// <since_tizen> 8 </since_tizen>
241         public ImageView Icon
242         {
243             get
244             {
245                 if (null == buttonIcon)
246                 {
247                     buttonIcon = CreateIcon();
248                     if (null != Extension)
249                     {
250                         buttonIcon = Extension.OnCreateIcon(this, buttonIcon);
251                     }
252                     Add(buttonIcon);
253                     buttonIcon.Relayout += OnIconRelayout;
254                 }
255                 return buttonIcon;
256             }
257             internal set
258             {
259                 buttonIcon = value;
260             }
261         }
262
263         /// <summary>
264         /// Button's overlay image part.
265         /// </summary>
266         /// <since_tizen> 8 </since_tizen>
267         public ImageView OverlayImage
268         {
269             get
270             {
271                 if (null == overlayImage)
272                 {
273                     overlayImage = CreateOverlayImage();
274                     if (null != Extension)
275                     {
276                         overlayImage = Extension.OnCreateOverlayImage(this, overlayImage);
277                     }
278                     overlayImage.WidthResizePolicy = ResizePolicyType.FillToParent;
279                     overlayImage.HeightResizePolicy = ResizePolicyType.FillToParent;
280                     Add(overlayImage);
281                 }
282                 return overlayImage;
283             }
284             internal set
285             {
286                 overlayImage = value;
287             }
288         }
289
290         /// <summary>
291         /// Button's text part.
292         /// </summary>
293         /// <since_tizen> 8 </since_tizen>
294         public TextLabel TextLabel
295         {
296             get
297             {
298                 if (null == buttonText)
299                 {
300                     buttonText = CreateText();
301                     if (null != Extension)
302                     {
303                         buttonText = Extension.OnCreateText(this, buttonText);
304                     }
305                     buttonText.HorizontalAlignment = HorizontalAlignment.Center;
306                     buttonText.VerticalAlignment = VerticalAlignment.Center;
307                     Add(buttonText);
308                 }
309                 return buttonText;
310             }
311             internal set
312             {
313                 buttonText = value;
314             }
315         }
316
317         /// <summary>
318         /// Return a copied Style instance of Button
319         /// </summary>
320         /// <remarks>
321         /// It returns copied Style instance and changing it does not effect to the Button.
322         /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
323         /// </remarks>
324         /// <since_tizen> 8 </since_tizen>
325         public new ButtonStyle Style
326         {
327             get
328             {
329                 var result = (ButtonStyle)ViewStyle.Clone();
330                 result.CopyPropertiesFromView(this);
331                 result.Text.CopyPropertiesFromView(TextLabel);
332                 result.Icon.CopyPropertiesFromView(Icon);
333                 result.Overlay.CopyPropertiesFromView(OverlayImage);
334                 return result;
335             }
336         }
337
338         /// <summary>
339         /// The text of Button.
340         /// </summary>
341         /// <since_tizen> 6 </since_tizen>
342         public string Text
343         {
344             get
345             {
346                 return TextLabel.Text;
347             }
348             set
349             {
350                 TextLabel.Text = value;
351             }
352         }
353
354         /// <summary>
355         /// Flag to decide Button can be selected or not.
356         /// </summary>
357         /// <since_tizen> 6 </since_tizen>
358         public bool IsSelectable
359         {
360             get
361             {
362                 return (bool)GetValue(IsSelectableProperty);
363             }
364             set
365             {
366                 SetValue(IsSelectableProperty, value);
367             }
368         }
369
370         /// <summary>
371         /// Translate text string in Button.
372         /// </summary>
373         /// <since_tizen> 6 </since_tizen>
374         public string TranslatableText
375         {
376             get
377             {
378                 return TextLabel.TranslatableText;
379             }
380             set
381             {
382                 TextLabel.TranslatableText = value;
383             }
384         }
385
386         /// <summary>
387         /// Text point size in Button.
388         /// </summary>
389         /// <since_tizen> 6 </since_tizen>
390         public float PointSize
391         {
392             get
393             {
394                 return TextLabel.PointSize;
395             }
396             set
397             {
398                 TextLabel.PointSize = value;
399             }
400         }
401
402         /// <summary>
403         /// Text font family in Button.
404         /// </summary>
405         /// <since_tizen> 6 </since_tizen>
406         public string FontFamily
407         {
408             get
409             {
410                 return TextLabel.FontFamily;
411             }
412             set
413             {
414                 TextLabel.FontFamily = value;
415             }
416         }
417
418         /// <summary>
419         /// Text color in Button.
420         /// </summary>
421         /// <since_tizen> 6 </since_tizen>
422         public Color TextColor
423         {
424             get
425             {
426                 return TextLabel.TextColor;
427             }
428             set
429             {
430                 TextLabel.TextColor = value;
431             }
432         }
433
434         /// <summary>
435         /// Text horizontal alignment in Button.
436         /// </summary>
437         /// <since_tizen> 6 </since_tizen>
438         public HorizontalAlignment TextAlignment
439         {
440             get
441             {
442                 return TextLabel.HorizontalAlignment;
443             }
444             set
445             {
446                 TextLabel.HorizontalAlignment = value;
447             }
448         }
449
450         /// <summary>
451         /// Icon image's resource url in Button.
452         /// </summary>
453         /// <since_tizen> 6 </since_tizen>
454         public string IconURL
455         {
456             get
457             {
458                 return Icon.ResourceUrl;
459             }
460             set
461             {
462                 Icon.ResourceUrl = value;
463             }
464         }
465
466         /// <summary>
467         /// Text string selector in Button.
468         /// Getter returns copied selector value if exist, null otherwise.
469         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
470         /// </summary>
471         /// <since_tizen> 6 </since_tizen>
472         public StringSelector TextSelector
473         {
474             get => buttonText == null ? null : new StringSelector((Selector<string>)buttonText.GetValue(TextLabel.TextSelectorProperty));
475             set
476             {
477                 if (value == null || buttonText == null)
478                 {
479                     throw new NullReferenceException("Button.TextSelector is null");
480                 }
481                 else
482                 {
483                     buttonText.SetValue(TextLabel.TextSelectorProperty, value);
484                 }
485             }
486         }
487
488         /// <summary>
489         /// Translateable text string selector in Button.
490         /// Getter returns copied selector value if exist, null otherwise.
491         /// </summary>
492         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
493         /// <since_tizen> 6 </since_tizen>
494         public StringSelector TranslatableTextSelector
495         {
496             get => buttonText == null ? null : new StringSelector((Selector<string>)buttonText.GetValue(TextLabel.TranslatableTextSelectorProperty));
497             set
498             {
499                 if (value == null || buttonText == null)
500                 {
501                     throw new NullReferenceException("Button.TranslatableTextSelector is null");
502                 }
503                 else
504                 {
505                     buttonText.SetValue(TextLabel.TranslatableTextSelectorProperty, value);
506                 }
507             }
508         }
509
510         /// <summary>
511         /// Text color selector in Button.
512         /// Getter returns copied selector value if exist, null otherwise.
513         /// </summary>
514         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
515         /// <since_tizen> 6 </since_tizen>
516         public ColorSelector TextColorSelector
517         {
518             get => buttonText == null ? null : new ColorSelector((Selector<Color>)buttonText.GetValue(TextLabel.TextColorSelectorProperty));
519             set
520             {
521                 if (value == null || buttonText == null)
522                 {
523                     throw new NullReferenceException("Button.TextColorSelectorProperty is null");
524                 }
525                 else
526                 {
527                     buttonText.SetValue(TextLabel.TextColorSelectorProperty, value);
528                 }
529             }
530         }
531
532         /// <summary>
533         /// Text font size selector in Button.
534         /// Getter returns copied selector value if exist, null otherwise.
535         /// </summary>
536         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
537         /// <since_tizen> 6 </since_tizen>
538         public FloatSelector PointSizeSelector
539         {
540             get => buttonText == null ? null : new FloatSelector((Selector<float?>)buttonText.GetValue(TextLabel.PointSizeSelectorProperty));
541             set
542             {
543                 if (value == null || buttonText == null)
544                 {
545                     throw new NullReferenceException("Button.PointSizeSelector is null");
546                 }
547                 else
548                 {
549                     buttonText.SetValue(TextLabel.PointSizeSelectorProperty, value);
550                 }
551             }
552         }
553
554         /// <summary>
555         /// Icon image's resource url selector in Button.
556         /// Getter returns copied selector value if exist, null otherwise.
557         /// </summary>
558         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
559         /// <since_tizen> 6 </since_tizen>
560         public StringSelector IconURLSelector
561         {
562             get => buttonIcon == null ? null : new StringSelector((Selector<string>)buttonIcon.GetValue(ImageView.ResourceUrlSelectorProperty));
563             set
564             {
565                 if (value == null || buttonIcon == null)
566                 {
567                     throw new NullReferenceException("Button.IconURLSelector is null");
568                 }
569                 else
570                 {
571                     buttonIcon.SetValue(ImageView.ResourceUrlSelectorProperty, value);
572                 }
573             }
574         }
575
576         /// <summary>
577         /// Flag to decide selected state in Button.
578         /// </summary>
579         /// <since_tizen> 6 </since_tizen>
580         public bool IsSelected
581         {
582             get
583             {
584                 return (bool)GetValue(IsSelectedProperty);
585             }
586             set
587             {
588                 SetValue(IsSelectedProperty, value);
589             }
590         }
591
592         /// <summary>
593         /// Flag to decide enable or disable in Button.
594         /// </summary>
595         /// <since_tizen> 6 </since_tizen>
596         public bool IsEnabled
597         {
598             get
599             {
600                 return (bool)GetValue(IsEnabledProperty);
601             }
602             set
603             {
604                 SetValue(IsEnabledProperty, value);
605             }
606         }
607
608         /// <summary>
609         /// Icon relative orientation in Button, work only when show icon and text.
610         /// </summary>
611         /// <since_tizen> 8 </since_tizen>
612         public IconOrientation? IconRelativeOrientation
613         {
614             get
615             {
616                 return (IconOrientation?)GetValue(IconRelativeOrientationProperty);
617             }
618             set
619             {
620                 SetValue(IconRelativeOrientationProperty, value);
621             }
622         }
623
624         /// <summary>
625         /// Icon padding in Button, work only when show icon and text.
626         /// </summary>
627         /// <since_tizen> 6 </since_tizen>
628         public Extents IconPadding
629         {
630             get => (Extents)GetValue(IconPaddingProperty);
631             set => SetValue(IconPaddingProperty, value);
632         }
633
634         /// <summary>
635         /// Text padding in Button, work only when show icon and text.
636         /// </summary>
637         /// <since_tizen> 6 </since_tizen>
638         public Extents TextPadding
639         {
640             get => (Extents)GetValue(TextPaddingProperty);
641             set => SetValue(TextPaddingProperty, value);
642         }
643
644         private ButtonStyle buttonStyle => ViewStyle as ButtonStyle;
645
646         /// <summary>
647         /// Called after a key event is received by the view that has had its focus set.
648         /// </summary>
649         /// <param name="key">The key event.</param>
650         /// <returns>True if the key event should be consumed.</returns>
651         /// <since_tizen> 6 </since_tizen>
652         public override bool OnKey(Key key)
653         {
654             if (!IsEnabled || null == key)
655             {
656                 return false;
657             }
658
659             if (key.State == Key.StateType.Down)
660             {
661                 if (key.KeyPressedName == "Return")
662                 {
663                     isPressed = true;
664                     UpdateState();
665                 }
666             }
667             else if (key.State == Key.StateType.Up)
668             {
669                 if (key.KeyPressedName == "Return")
670                 {
671                     bool clicked = isPressed && IsEnabled;
672
673                     isPressed = false;
674
675                     if (IsSelectable)
676                     {
677                         IsSelected = !IsSelected;
678                     }
679                     else
680                     {
681                         UpdateState();
682                     }
683
684                     if (clicked)
685                     {
686                         ClickedEventArgs eventArgs = new ClickedEventArgs();
687                         OnClickedInternal(eventArgs);
688                     }
689                 }
690             }
691             return base.OnKey(key);
692         }
693
694         /// <summary>
695         /// 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.
696         /// </summary>
697         /// <since_tizen> 8 </since_tizen>
698         public override void OnFocusGained()
699         {
700             base.OnFocusGained();
701             UpdateState();
702         }
703
704         /// <summary>
705         /// 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.
706         /// </summary>
707         /// <since_tizen> 8 </since_tizen>
708         public override void OnFocusLost()
709         {
710             base.OnFocusLost();
711             UpdateState();
712         }
713
714         /// <summary>
715         /// Called after a touch event is received by the owning view.<br />
716         /// CustomViewBehaviour.REQUIRES_TOUCH_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
717         /// </summary>
718         /// <param name="touch">The touch event.</param>
719         /// <returns>True if the event should be consumed.</returns>
720         /// <since_tizen> 8 </since_tizen>
721         public override bool OnTouch(Touch touch)
722         {
723             return base.OnTouch(touch);
724         }
725
726         /// <summary>
727         /// Apply style to button.
728         /// </summary>
729         /// <param name="viewStyle">The style to apply.</param>
730         /// <since_tizen> 8 </since_tizen>
731         public override void ApplyStyle(ViewStyle viewStyle)
732         {
733             styleApplied = false;
734
735             base.ApplyStyle(viewStyle);
736
737             if (null != buttonStyle)
738             {
739                 Extension = buttonStyle.CreateExtension();
740                 if (buttonStyle.Overlay != null)
741                 {
742                     OverlayImage?.ApplyStyle(buttonStyle.Overlay);
743                 }
744
745                 if (buttonStyle.Text != null)
746                 {
747                     TextLabel?.ApplyStyle(buttonStyle.Text);
748                 }
749
750                 if (buttonStyle.Icon != null)
751                 {
752                     Icon?.ApplyStyle(buttonStyle.Icon);
753                 }
754             }
755
756             styleApplied = true;
757         }
758
759         /// <summary>
760         /// ClickEventArgs is a class to record button click event arguments which will sent to user.
761         /// </summary>
762         /// <since_tizen> 6 </since_tizen>
763         [Obsolete("Deprecated in API8; Will be removed in API10. Please use ClickedEventArgs instead.")]
764         public class ClickEventArgs : EventArgs
765         {
766         }
767
768         /// <summary>
769         /// StateChangeEventArgs is a class to record button state change event arguments which will sent to user.
770         /// </summary>
771         /// <since_tizen> 6 </since_tizen>
772         [Obsolete("Deprecated in API8; Will be removed in API10. Please use View.ControlStateChangedEventArgs")]
773         public class StateChangedEventArgs : EventArgs
774         {
775             /// <summary> previous state of Button </summary>
776             /// <since_tizen> 6 </since_tizen>
777             [Obsolete("Deprecated in API8; Will be removed in API10")]
778             public ControlStates PreviousState;
779             /// <summary> current state of Button </summary>
780             /// <since_tizen> 6 </since_tizen>
781             [Obsolete("Deprecated in API8; Will be removed in API10")]
782             public ControlStates CurrentState;
783         }
784
785         /// <summary>
786         /// Get current text part to the attached ButtonExtension.
787         /// </summary>
788         /// <remarks>
789         /// It returns null if the passed extension is invalid.
790         /// </remarks>
791         /// <param name="extension">The extension instance that is currently attached to this Button.</param>
792         /// <return>The button's text part.</return>
793         [EditorBrowsable(EditorBrowsableState.Never)]
794         public TextLabel GetCurrentText(ButtonExtension extension)
795         {
796             return (extension == Extension) ? TextLabel : null;
797         }
798
799         /// <summary>
800         /// Get current icon part to the attached ButtonExtension.
801         /// </summary>
802         /// <remarks>
803         /// It returns null if the passed extension is invalid.
804         /// </remarks>
805         /// <param name="extension">The extension instance that is currently attached to this Button.</param>
806         /// <return>The button's icon part.</return>
807         [EditorBrowsable(EditorBrowsableState.Never)]
808         public ImageView GetCurrentIcon(ButtonExtension extension)
809         {
810             return (extension == Extension) ? Icon : null;
811         }
812
813         /// <summary>
814         /// Get current overlay image part to the attached ButtonExtension.
815         /// </summary>
816         /// <remarks>
817         /// It returns null if the passed extension is invalid.
818         /// </remarks>
819         /// <param name="extension">The extension instance that is currently attached to this Button.</param>
820         /// <return>The button's overlay image part.</return>
821         [EditorBrowsable(EditorBrowsableState.Never)]
822         public ImageView GetCurrentOverlayImage(ButtonExtension extension)
823         {
824             return (extension == Extension) ? OverlayImage : null;
825         }
826     }
827 }