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