Merge remote-tracking branch 'origin/master' into tizen
[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         /// </summary>
470         /// <since_tizen> 6 </since_tizen>
471         public StringSelector TextSelector
472         {
473             get => buttonText == null ? null : new StringSelector((Selector<string>)buttonText.GetValue(TextLabel.TextSelectorProperty));
474             set => buttonText?.SetValue(TextLabel.TextSelectorProperty, value);
475         }
476
477         /// <summary>
478         /// Translateable text string selector in Button.
479         /// Getter returns copied selector value if exist, null otherwise.
480         /// </summary>
481         /// <since_tizen> 6 </since_tizen>
482         public StringSelector TranslatableTextSelector
483         {
484             get => buttonText == null ? null : new StringSelector((Selector<string>)buttonText.GetValue(TextLabel.TranslatableTextSelectorProperty));
485             set => buttonText?.SetValue(TextLabel.TranslatableTextSelectorProperty, value);
486         }
487
488         /// <summary>
489         /// Text color selector in Button.
490         /// Getter returns copied selector value if exist, null otherwise.
491         /// </summary>
492         /// <since_tizen> 6 </since_tizen>
493         public ColorSelector TextColorSelector
494         {
495             get => buttonText == null ? null : new ColorSelector((Selector<Color>)buttonText.GetValue(TextLabel.TextColorSelectorProperty));
496             set => buttonText?.SetValue(TextLabel.TextColorSelectorProperty, value);
497         }
498
499         /// <summary>
500         /// Text font size selector in Button.
501         /// Getter returns copied selector value if exist, null otherwise.
502         /// </summary>
503         /// <since_tizen> 6 </since_tizen>
504         public FloatSelector PointSizeSelector
505         {
506             get => buttonText == null ? null : new FloatSelector((Selector<float?>)buttonText.GetValue(TextLabel.PointSizeSelectorProperty));
507             set => buttonText?.SetValue(TextLabel.PointSizeSelectorProperty, value);
508         }
509
510         /// <summary>
511         /// Icon image's resource url selector in Button.
512         /// Getter returns copied selector value if exist, null otherwise.
513         /// </summary>
514         /// <since_tizen> 6 </since_tizen>
515         public StringSelector IconURLSelector
516         {
517             get => buttonIcon == null ? null : new StringSelector((Selector<string>)buttonText.GetValue(ImageView.ResourceUrlSelectorProperty));
518             set => buttonIcon?.SetValue(ImageView.ResourceUrlSelectorProperty, value);
519         }
520
521         /// <summary>
522         /// Flag to decide selected state in Button.
523         /// </summary>
524         /// <since_tizen> 6 </since_tizen>
525         public bool IsSelected
526         {
527             get
528             {
529                 return (bool)GetValue(IsSelectedProperty);
530             }
531             set
532             {
533                 SetValue(IsSelectedProperty, value);
534             }
535         }
536
537         /// <summary>
538         /// Flag to decide enable or disable in Button.
539         /// </summary>
540         /// <since_tizen> 6 </since_tizen>
541         public bool IsEnabled
542         {
543             get
544             {
545                 return (bool)GetValue(IsEnabledProperty);
546             }
547             set
548             {
549                 SetValue(IsEnabledProperty, value);
550             }
551         }
552
553         /// <summary>
554         /// Icon relative orientation in Button, work only when show icon and text.
555         /// </summary>
556         /// <since_tizen> 8 </since_tizen>
557         public IconOrientation? IconRelativeOrientation
558         {
559             get
560             {
561                 return (IconOrientation?)GetValue(IconRelativeOrientationProperty);
562             }
563             set
564             {
565                 SetValue(IconRelativeOrientationProperty, value);
566             }
567         }
568
569         /// <summary>
570         /// Icon padding in Button, work only when show icon and text.
571         /// </summary>
572         /// <since_tizen> 6 </since_tizen>
573         public Extents IconPadding
574         {
575             get => (Extents)GetValue(IconPaddingProperty);
576             set => SetValue(IconPaddingProperty, value);
577         }
578
579         /// <summary>
580         /// Text padding in Button, work only when show icon and text.
581         /// </summary>
582         /// <since_tizen> 6 </since_tizen>
583         public Extents TextPadding
584         {
585             get => (Extents)GetValue(TextPaddingProperty);
586             set => SetValue(TextPaddingProperty, value);
587         }
588
589         private ButtonStyle buttonStyle => ViewStyle as ButtonStyle;
590
591         /// <summary>
592         /// Called after a key event is received by the view that has had its focus set.
593         /// </summary>
594         /// <param name="key">The key event.</param>
595         /// <returns>True if the key event should be consumed.</returns>
596         /// <since_tizen> 6 </since_tizen>
597         public override bool OnKey(Key key)
598         {
599             if (!IsEnabled || null == key)
600             {
601                 return false;
602             }
603
604             if (key.State == Key.StateType.Down)
605             {
606                 if (key.KeyPressedName == "Return")
607                 {
608                     isPressed = true;
609                     UpdateState();
610                 }
611             }
612             else if (key.State == Key.StateType.Up)
613             {
614                 if (key.KeyPressedName == "Return")
615                 {
616                     bool clicked = isPressed && IsEnabled;
617
618                     isPressed = false;
619
620                     if (IsSelectable)
621                     {
622                         IsSelected = !IsSelected;
623                     }
624                     else
625                     {
626                         UpdateState();
627                     }
628
629                     if (clicked)
630                     {
631                         ClickedEventArgs eventArgs = new ClickedEventArgs();
632                         OnClickedInternal(eventArgs);
633                     }
634                 }
635             }
636             return base.OnKey(key);
637         }
638
639         /// <summary>
640         /// 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.
641         /// </summary>
642         /// <since_tizen> 8 </since_tizen>
643         public override void OnFocusGained()
644         {
645             base.OnFocusGained();
646             UpdateState();
647         }
648
649         /// <summary>
650         /// 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.
651         /// </summary>
652         /// <since_tizen> 8 </since_tizen>
653         public override void OnFocusLost()
654         {
655             base.OnFocusLost();
656             UpdateState();
657         }
658
659         /// <summary>
660         /// Called after a touch event is received by the owning view.<br />
661         /// CustomViewBehaviour.REQUIRES_TOUCH_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
662         /// </summary>
663         /// <param name="touch">The touch event.</param>
664         /// <returns>True if the event should be consumed.</returns>
665         /// <since_tizen> 8 </since_tizen>
666         public override bool OnTouch(Touch touch)
667         {
668             if (!IsEnabled || null == touch)
669             {
670                 return false;
671             }
672
673             PointStateType state = touch.GetState(0);
674
675             switch (state)
676             {
677                 case PointStateType.Down:
678                     isPressed = true;
679                     Extension?.SetTouchInfo(touch);
680                     UpdateState();
681                     return true;
682                 case PointStateType.Interrupted:
683                     isPressed = false;
684                     UpdateState();
685                     return true;
686                 case PointStateType.Up:
687                     {
688                         bool clicked = isPressed && IsEnabled;
689
690                         isPressed = false;
691
692                         if (IsSelectable)
693                         {
694                             Extension?.SetTouchInfo(touch);
695                             IsSelected = !IsSelected;
696                         }
697                         else
698                         {
699                             Extension?.SetTouchInfo(touch);
700                             UpdateState();
701                         }
702
703                         if (clicked)
704                         {
705                             ClickedEventArgs eventArgs = new ClickedEventArgs();
706                             OnClickedInternal(eventArgs);
707                         }
708
709                         return true;
710                     }
711                 default:
712                     break;
713             }
714             return base.OnTouch(touch);
715         }
716
717         /// <summary>
718         /// Apply style to button.
719         /// </summary>
720         /// <param name="viewStyle">The style to apply.</param>
721         /// <since_tizen> 8 </since_tizen>
722         public override void ApplyStyle(ViewStyle viewStyle)
723         {
724             styleApplied = false;
725
726             base.ApplyStyle(viewStyle);
727
728             if (null != buttonStyle)
729             {
730                 Extension = buttonStyle.CreateExtension();
731                 if (buttonStyle.Overlay != null)
732                 {
733                     OverlayImage?.ApplyStyle(buttonStyle.Overlay);
734                 }
735
736                 if (buttonStyle.Text != null)
737                 {
738                     TextLabel?.ApplyStyle(buttonStyle.Text);
739                 }
740
741                 if (buttonStyle.Icon != null)
742                 {
743                     Icon?.ApplyStyle(buttonStyle.Icon);
744                 }
745             }
746
747             styleApplied = true;
748         }
749
750         /// <summary>
751         /// ClickEventArgs is a class to record button click event arguments which will sent to user.
752         /// </summary>
753         /// <since_tizen> 6 </since_tizen>
754         [Obsolete("Deprecated in API8; Will be removed in API10. Please use ClickedEventArgs instead.")]
755         public class ClickEventArgs : EventArgs
756         {
757         }
758
759         /// <summary>
760         /// StateChangeEventArgs is a class to record button state change 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 View.ControlStateChangedEventArgs")]
764         public class StateChangedEventArgs : EventArgs
765         {
766             /// <summary> previous state of Button </summary>
767             /// <since_tizen> 6 </since_tizen>
768             [Obsolete("Deprecated in API8; Will be removed in API10")]
769             public ControlStates PreviousState;
770             /// <summary> current state of Button </summary>
771             /// <since_tizen> 6 </since_tizen>
772             [Obsolete("Deprecated in API8; Will be removed in API10")]
773             public ControlStates CurrentState;
774         }
775
776         /// <summary>
777         /// Get current text part to the attached ButtonExtension.
778         /// </summary>
779         /// <remarks>
780         /// It returns null if the passed extension is invalid.
781         /// </remarks>
782         /// <param name="extension">The extension instance that is currently attached to this Button.</param>
783         /// <return>The button's text part.</return>
784         [EditorBrowsable(EditorBrowsableState.Never)]
785         public TextLabel GetCurrentText(ButtonExtension extension)
786         {
787             return (extension == Extension) ? TextLabel : null;
788         }
789
790         /// <summary>
791         /// Get current icon part to the attached ButtonExtension.
792         /// </summary>
793         /// <remarks>
794         /// It returns null if the passed extension is invalid.
795         /// </remarks>
796         /// <param name="extension">The extension instance that is currently attached to this Button.</param>
797         /// <return>The button's icon part.</return>
798         [EditorBrowsable(EditorBrowsableState.Never)]
799         public ImageView GetCurrentIcon(ButtonExtension extension)
800         {
801             return (extension == Extension) ? Icon : null;
802         }
803
804         /// <summary>
805         /// Get current overlay image part to the attached ButtonExtension.
806         /// </summary>
807         /// <remarks>
808         /// It returns null if the passed extension is invalid.
809         /// </remarks>
810         /// <param name="extension">The extension instance that is currently attached to this Button.</param>
811         /// <return>The button's overlay image part.</return>
812         [EditorBrowsable(EditorBrowsableState.Never)]
813         public ImageView GetCurrentOverlayImage(ButtonExtension extension)
814         {
815             return (extension == Extension) ? OverlayImage : null;
816         }
817     }
818 }