2 * Copyright(c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 extern alias TizenSystemSettings;
19 using TizenSystemSettings.Tizen.System;
21 using System.Globalization;
22 using System.ComponentModel;
23 using Tizen.NUI.Binding;
25 namespace Tizen.NUI.BaseComponents
29 /// A control which renders a short text string.<br />
30 /// Text labels are lightweight, non-editable, and do not respond to the user input.<br />
32 /// <since_tizen> 3 </since_tizen>
33 public partial class TextLabel : View
35 static TextLabel() { }
37 private string textLabelSid = null;
38 private bool systemlangTextFlag = false;
40 private CloneableViewSelector<TextShadow> textShadow;
42 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
43 [EditorBrowsable(EditorBrowsableState.Never)]
44 public TextLabelStyle Style => ViewStyle as TextLabelStyle;
47 /// Creates the TextLabel control.
49 /// <since_tizen> 3 </since_tizen>
50 public TextLabel() : this(Interop.TextLabel.TextLabel_New__SWIG_0(), true)
52 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
55 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
56 [EditorBrowsable(EditorBrowsableState.Never)]
57 public TextLabel(TextLabelStyle viewStyle) : this(Interop.TextLabel.TextLabel_New__SWIG_0(), true, viewStyle)
62 /// Creates the TextLabel with setting the status of shown or hidden.
64 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
65 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
66 [EditorBrowsable(EditorBrowsableState.Never)]
67 public TextLabel(bool shown) : this(Interop.TextLabel.TextLabel_New__SWIG_0(), true)
69 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
74 /// Creates the TextLabel control.
76 /// <param name="text">The text to display</param>
77 /// <since_tizen> 3 </since_tizen>
78 public TextLabel(string text) : this(Interop.TextLabel.TextLabel_New__SWIG_1(text), true)
80 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
84 /// Creates the TextLabel with setting the status of shown or hidden.
86 /// <param name="text">The text to display</param>
87 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
88 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
89 [EditorBrowsable(EditorBrowsableState.Never)]
90 public TextLabel(string text, bool shown) : this(Interop.TextLabel.TextLabel_New__SWIG_1(text), true)
92 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
96 internal TextLabel(TextLabel handle, bool shown = true) : this(Interop.TextLabel.new_TextLabel__SWIG_1(TextLabel.getCPtr(handle)), true)
98 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
106 internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : base(Interop.TextLabel.TextLabel_SWIGUpcast(cPtr), cMemoryOwn, viewStyle)
114 internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(Interop.TextLabel.TextLabel_SWIGUpcast(cPtr), cMemoryOwn)
123 /// The TranslatableText property.<br />
124 /// The text can set the SID value.<br />
126 /// <exception cref='ArgumentNullException'>
127 /// ResourceManager about multilingual is null.
129 /// <since_tizen> 4 </since_tizen>
130 public string TranslatableText
134 return (string)GetValue(TranslatableTextProperty);
138 SetValue(TranslatableTextProperty, value);
141 private string translatableText
145 string temp = (string)GetValue(TranslatableTextProperty);
150 if (NUIApplication.MultilingualResourceManager == null)
152 throw new ArgumentNullException("ResourceManager about multilingual is null");
154 string translatableText = null;
155 textLabelSid = value;
156 translatableText = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(SystemSettings.LocaleLanguage.Replace("_", "-")));
157 if (translatableText != null)
159 Text = translatableText;
160 if (systemlangTextFlag == false)
162 SystemSettings.LocaleLanguageChanged += new WeakEventHandler<LocaleLanguageChangedEventArgs>(SystemSettings_LocaleLanguageChanged).Handler;
163 systemlangTextFlag = true;
170 NotifyPropertyChanged();
175 /// The Text property.<br />
176 /// The text to display in the UTF-8 format.<br />
178 /// <since_tizen> 3 </since_tizen>
183 return (string)GetValue(TextProperty);
187 SetValue(TextProperty, value);
188 NotifyPropertyChangedAndRequestLayout();
193 /// The FontFamily property.<br />
194 /// The requested font family to use.<br />
196 /// <since_tizen> 3 </since_tizen>
197 public string FontFamily
201 return (string)GetValue(FontFamilyProperty);
205 SetValue(FontFamilyProperty, value);
206 NotifyPropertyChangedAndRequestLayout();
211 /// The FontStyle property.<br />
212 /// The requested font style to use.<br />
214 /// <since_tizen> 3 </since_tizen>
215 public PropertyMap FontStyle
219 return (PropertyMap)GetValue(FontStyleProperty);
223 SetValue(FontStyleProperty, value);
224 NotifyPropertyChangedAndRequestLayout();
229 /// The PointSize property.<br />
230 /// The size of font in points.<br />
232 /// <since_tizen> 3 </since_tizen>
233 public float PointSize
237 return (float)GetValue(PointSizeProperty);
241 SetValue(PointSizeProperty, value);
242 NotifyPropertyChangedAndRequestLayout();
247 /// The MultiLine property.<br />
248 /// The single-line or multi-line layout option.<br />
250 /// <since_tizen> 3 </since_tizen>
251 public bool MultiLine
255 return (bool)GetValue(MultiLineProperty);
259 SetValue(MultiLineProperty, value);
260 NotifyPropertyChangedAndRequestLayout();
265 /// The HorizontalAlignment property.<br />
266 /// The line horizontal alignment.<br />
268 /// <since_tizen> 3 </since_tizen>
269 public HorizontalAlignment HorizontalAlignment
273 return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
277 SetValue(HorizontalAlignmentProperty, value);
278 NotifyPropertyChanged();
283 /// The VerticalAlignment property.<br />
284 /// The line vertical alignment.<br />
286 /// <since_tizen> 3 </since_tizen>
287 public VerticalAlignment VerticalAlignment
291 return (VerticalAlignment)GetValue(VerticalAlignmentProperty);
295 SetValue(VerticalAlignmentProperty, value);
296 NotifyPropertyChanged();
301 /// The TextColor property.<br />
302 /// The color of the text.<br />
303 /// Animation framework can be used to change the color of the text when not using mark up.<br />
304 /// Cannot animate the color when text is auto scrolling.<br />
307 /// The property cascade chaining set is possible. For example, this (textLabel.TextColor.X = 0.1f;) is possible.
309 /// <since_tizen> 3 </since_tizen>
310 public Color TextColor
314 Color temp = (Color)GetValue(TextColorProperty);
315 return new Color(OnTextColorChanged, temp.R, temp.G, temp.B, temp.A);
319 SetValue(TextColorProperty, value);
320 NotifyPropertyChanged();
325 /// The ShadowOffset property.<br />
326 /// The drop shadow offset 0 indicates no shadow.<br />
328 /// <since_tizen> 3 </since_tizen>
330 /// Deprecated.(API Level 6) Use Shadow instead.
331 /// The property cascade chaining set is possible. For example, this (textLabel.ShadowOffset.X = 0.1f;) is possible.
333 [Obsolete("Please do not use this ShadowOffset(Deprecated). Please use Shadow instead.")]
334 public Vector2 ShadowOffset
338 Vector2 shadowOffset = new Vector2();
339 Shadow.Find(TextLabel.Property.SHADOW, "offset")?.Get(shadowOffset);
340 return new Vector2(OnShadowOffsetChanged, shadowOffset.X, shadowOffset.Y);
344 PropertyMap temp = new PropertyMap();
345 temp.Insert("offset", new PropertyValue(value));
347 PropertyMap shadowMap = Shadow;
348 shadowMap.Merge(temp);
350 SetValue(ShadowProperty, shadowMap);
351 NotifyPropertyChanged();
356 /// The ShadowColor property.<br />
357 /// The color of a drop shadow.<br />
359 /// <since_tizen> 3 </since_tizen>
361 /// Deprecated.(API Level 6) Use Shadow instead.
362 /// The property cascade chaining set is possible. For example, this (textLabel.ShadowColor.X = 0.1f;) is possible.
364 [Obsolete("Please do not use this ShadowColor(Deprecated). Please use Shadow instead.")]
365 public Vector4 ShadowColor
369 Vector4 shadowColor = new Vector4();
370 Shadow.Find(TextLabel.Property.SHADOW, "color")?.Get(shadowColor);
371 return new Vector4(OnShadowColorChanged, shadowColor.X, shadowColor.Y, shadowColor.Z, shadowColor.W);
375 PropertyMap temp = new PropertyMap();
376 temp.Insert("color", new PropertyValue(value));
378 PropertyMap shadowMap = Shadow;
379 shadowMap.Merge(temp);
381 SetValue(ShadowProperty, shadowMap);
382 NotifyPropertyChanged();
387 /// The UnderlineEnabled property.<br />
388 /// The underline enabled flag.<br />
390 /// <since_tizen> 3 </since_tizen>
392 /// Deprecated.(API Level 6) Use Underline instead.
394 [Obsolete("Please do not use this UnderlineEnabled(Deprecated). Please use Underline instead.")]
395 public bool UnderlineEnabled
399 bool underlineEnabled = false;
400 Underline.Find(TextLabel.Property.UNDERLINE, "enable")?.Get(out underlineEnabled);
401 return underlineEnabled;
405 PropertyMap temp = new PropertyMap();
406 temp.Add("enable", new PropertyValue(value));
408 PropertyMap undelineMap = Underline;
409 undelineMap.Merge(temp);
411 SetValue(UnderlineProperty, undelineMap);
412 NotifyPropertyChanged();
418 /// The UnderlineColor property.<br />
419 /// Overrides the underline height from font metrics.<br />
421 /// <since_tizen> 3 </since_tizen>
423 /// Deprecated.(API Level 6) Use Underline instead.
424 /// The property cascade chaining set is possible. For example, this (textLabel.UnderlineColor.X = 0.1f;) is possible.
426 [Obsolete("Please do not use this UnderlineColor(Deprecated). Please use Underline instead.")]
427 public Vector4 UnderlineColor
431 Vector4 underlineColor = new Vector4();
432 Underline.Find(TextLabel.Property.UNDERLINE, "color")?.Get(underlineColor);
433 return new Vector4(OnUnderlineColorChanged, underlineColor.X, underlineColor.Y, underlineColor.Z, underlineColor.W);
437 PropertyMap temp = new PropertyMap();
438 temp.Insert("color", new PropertyValue(value));
440 PropertyMap undelineMap = Underline;
441 undelineMap.Merge(temp);
443 SetValue(UnderlineProperty, undelineMap);
444 NotifyPropertyChanged();
449 /// The UnderlineHeight property.<br />
450 /// Overrides the underline height from font metrics.<br />
452 /// <since_tizen> 3 </since_tizen>
454 /// Deprecated.(API Level 6) Use Underline instead.
456 [Obsolete("Please do not use this UnderlineHeight(Deprecated). Please use Underline instead.")]
457 public float UnderlineHeight
461 float underlineHeight = 0.0f;
462 Underline.Find(TextLabel.Property.UNDERLINE, "height")?.Get(out underlineHeight);
463 return underlineHeight;
467 PropertyMap temp = new PropertyMap();
468 temp.Insert("height", new PropertyValue(value));
470 PropertyMap undelineMap = Underline;
471 undelineMap.Merge(temp);
473 SetValue(UnderlineProperty, undelineMap);
474 NotifyPropertyChanged();
479 /// The EnableMarkup property.<br />
480 /// Whether the mark-up processing is enabled.<br />
482 /// <since_tizen> 3 </since_tizen>
483 public bool EnableMarkup
487 return (bool)GetValue(EnableMarkupProperty);
491 SetValue(EnableMarkupProperty, value);
492 NotifyPropertyChanged();
497 /// The EnableAutoScroll property.<br />
498 /// Starts or stops auto scrolling.<br />
500 /// <since_tizen> 3 </since_tizen>
501 public bool EnableAutoScroll
505 return (bool)GetValue(EnableAutoScrollProperty);
509 SetValue(EnableAutoScrollProperty, value);
510 NotifyPropertyChanged();
515 /// The AutoScrollSpeed property.<br />
516 /// Sets the speed of scrolling in pixels per second.<br />
518 /// <since_tizen> 3 </since_tizen>
519 public int AutoScrollSpeed
523 return (int)GetValue(AutoScrollSpeedProperty);
527 SetValue(AutoScrollSpeedProperty, value);
528 NotifyPropertyChanged();
533 /// The AutoScrollLoopCount property.<br />
534 /// Number of complete loops when scrolling enabled.<br />
536 /// <since_tizen> 3 </since_tizen>
537 public int AutoScrollLoopCount
541 return (int)GetValue(AutoScrollLoopCountProperty);
545 SetValue(AutoScrollLoopCountProperty, value);
546 NotifyPropertyChanged();
551 /// The AutoScrollGap property.<br />
552 /// Gap before scrolling wraps.<br />
554 /// <since_tizen> 3 </since_tizen>
555 public float AutoScrollGap
559 return (float)GetValue(AutoScrollGapProperty);
563 SetValue(AutoScrollGapProperty, value);
564 NotifyPropertyChanged();
569 /// The LineSpacing property.<br />
570 /// The default extra space between lines in points.<br />
572 /// <since_tizen> 3 </since_tizen>
573 public float LineSpacing
577 return (float)GetValue(LineSpacingProperty);
581 SetValue(LineSpacingProperty, value);
582 NotifyPropertyChangedAndRequestLayout();
587 /// The Underline property.<br />
588 /// The default underline parameters.<br />
590 /// <since_tizen> 3 </since_tizen>
591 public PropertyMap Underline
595 return (PropertyMap)GetValue(UnderlineProperty);
599 SetValue(UnderlineProperty, value);
600 NotifyPropertyChanged();
605 /// The Shadow property.<br />
606 /// The default shadow parameters.<br />
608 /// <since_tizen> 3 </since_tizen>
609 public PropertyMap Shadow
613 return (PropertyMap)GetValue(ShadowProperty);
617 SetValue(ShadowProperty, value);
618 NotifyPropertyChanged();
623 /// Describes a text shadow for a TextLabel.
624 /// It is null by default.
626 [EditorBrowsable(EditorBrowsableState.Never)]
627 public TextShadow TextShadow
631 var value = (TextShadow)GetValue(TextShadowProperty);
632 return value == null ? null : new TextShadow(value, OnTextShadowChanged);
636 SetValue(TextShadowProperty, value);
637 NotifyPropertyChanged();
642 /// The Emboss property.<br />
643 /// The default emboss parameters.<br />
645 /// <since_tizen> 3 </since_tizen>
650 return (string)GetValue(EmbossProperty);
654 SetValue(EmbossProperty, value);
655 NotifyPropertyChanged();
660 /// The Outline property.<br />
661 /// The default outline parameters.<br />
663 /// <since_tizen> 3 </since_tizen>
664 public PropertyMap Outline
668 return (PropertyMap)GetValue(OutlineProperty);
672 SetValue(OutlineProperty, value);
673 NotifyPropertyChanged();
678 /// The PixelSize property.<br />
679 /// The size of font in pixels.<br />
681 /// <since_tizen> 3 </since_tizen>
682 public float PixelSize
686 return (float)GetValue(PixelSizeProperty);
690 SetValue(PixelSizeProperty, value);
691 NotifyPropertyChangedAndRequestLayout();
696 /// The Ellipsis property.<br />
697 /// Enable or disable the ellipsis.<br />
699 /// <since_tizen> 3 </since_tizen>
704 return (bool)GetValue(EllipsisProperty);
708 SetValue(EllipsisProperty, value);
709 NotifyPropertyChanged();
714 /// The AutoScrollLoopDelay property.<br />
715 /// Do something.<br />
717 /// <since_tizen> 3 </since_tizen>
718 public float AutoScrollLoopDelay
722 return (float)GetValue(AutoScrollLoopDelayProperty);
726 SetValue(AutoScrollLoopDelayProperty, value);
727 NotifyPropertyChanged();
732 /// The AutoScrollStopMode property.<br />
733 /// Do something.<br />
735 /// <since_tizen> 3 </since_tizen>
736 public AutoScrollStopMode AutoScrollStopMode
740 return (AutoScrollStopMode)GetValue(AutoScrollStopModeProperty);
744 SetValue(AutoScrollStopModeProperty, value);
745 NotifyPropertyChanged();
750 /// The line count of the text.
752 /// <since_tizen> 3 </since_tizen>
758 GetProperty(TextLabel.Property.LINE_COUNT).Get(out temp);
764 /// The LineWrapMode property.<br />
765 /// line wrap mode when the text lines over layout width.<br />
767 /// <since_tizen> 4 </since_tizen>
768 public LineWrapMode LineWrapMode
772 return (LineWrapMode)GetValue(LineWrapModeProperty);
776 SetValue(LineWrapModeProperty, value);
777 NotifyPropertyChanged();
782 /// The direction of the text such as left to right or right to left.
784 /// <since_tizen> 5 </since_tizen>
785 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
786 [EditorBrowsable(EditorBrowsableState.Never)]
787 public TextDirection TextDirection
792 GetProperty(TextLabel.Property.TEXT_DIRECTION).Get(out temp);
793 return (TextDirection)temp;
798 /// The vertical line alignment of the text.
800 /// <since_tizen> 5 </since_tizen>
801 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
802 [EditorBrowsable(EditorBrowsableState.Never)]
803 public VerticalLineAlignment VerticalLineAlignment
807 return (VerticalLineAlignment)GetValue(VerticalLineAlignmentProperty);
811 SetValue(VerticalLineAlignmentProperty, value);
812 NotifyPropertyChanged();
817 /// The text alignment to match the direction of the system language.
819 /// <since_tizen> 6 </since_tizen>
820 public bool MatchSystemLanguageDirection
824 return (bool)GetValue(MatchSystemLanguageDirectionProperty);
828 SetValue(MatchSystemLanguageDirectionProperty, value);
829 NotifyPropertyChanged();
834 /// The text fit parameters.<br />
835 /// The textFit map contains the following keys :<br />
836 /// - enable (bool type) : True to enable the text fit or false to disable(the default value is false)<br />
837 /// - minSize (float type) : Minimum Size for text fit(the default value is 10.f)<br />
838 /// - maxSize (float type) : Maximum Size for text fit(the default value is 100.f)<br />
839 /// - stepSize (float type) : Step Size for font increase(the default value is 1.f)<br />
840 /// - fontSize (string type) : The size type of font, You can choose between "pointSize" or "pixelSize". (the default value is "pointSize")<br />
842 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
843 [EditorBrowsable(EditorBrowsableState.Never)]
844 public PropertyMap TextFit
848 return (PropertyMap)GetValue(TextFitProperty);
852 SetValue(TextFitProperty, value);
853 NotifyPropertyChanged();
858 /// The MinLineSize property.<br />
860 /// <since_tizen> 8 </since_tizen>
861 [EditorBrowsable(EditorBrowsableState.Never)]
862 public float MinLineSize
866 return (float)GetValue(MinLineSizeProperty);
870 SetValue(MinLineSizeProperty, value);
871 NotifyPropertyChangedAndRequestLayout();
876 /// Downcasts a handle to textLabel handle
878 /// <param name="handle"></param>
879 /// <returns></returns>
880 /// <since_tizen> 3 </since_tizen>
881 /// Please do not use! this will be deprecated!
882 /// Instead please use as keyword.
883 [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
885 "BaseHandle handle = new TextLabel(\"Hello World!\"); " +
886 "TextLabel label = handle as TextLabel")]
887 [EditorBrowsable(EditorBrowsableState.Never)]
888 public static TextLabel DownCast(BaseHandle handle)
890 TextLabel ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TextLabel;
892 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
896 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextLabel obj)
898 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
901 /// This will not be public opened.
902 [EditorBrowsable(EditorBrowsableState.Never)]
903 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
905 Interop.TextLabel.delete_TextLabel(swigCPtr);
909 /// Get attribues, it is abstract function and must be override.
911 /// <since_tizen> 6 </since_tizen>
912 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
913 [EditorBrowsable(EditorBrowsableState.Never)]
914 protected override ViewStyle GetViewStyle()
916 return new TextLabelStyle();
919 internal static readonly BindableProperty TranslatableTextSelectorProperty = BindableProperty.Create("TranslatableTextSelector", typeof(Selector<string>), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) =>
921 var textLabel = (TextLabel)bindable;
922 textLabel.TranslatableTextSelector.Clone((Selector<string>)newValue);
924 defaultValueCreator: (bindable) =>
926 var textLabel = (TextLabel)bindable;
927 return textLabel.TranslatableTextSelector;
929 internal static readonly BindableProperty TextSelectorProperty = BindableProperty.Create("TextSelector", typeof(Selector<string>), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) =>
931 var textLabel = (TextLabel)bindable;
932 textLabel.textSelector.Clone((Selector<string>)newValue);
934 defaultValueCreator: (bindable) =>
936 var textLabel = (TextLabel)bindable;
937 return textLabel.textSelector;
939 internal static readonly BindableProperty FontFamilySelectorProperty = BindableProperty.Create("FontFamilySelector", typeof(Selector<string>), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) =>
941 var textLabel = (TextLabel)bindable;
942 textLabel.fontFamilySelector.Clone((Selector<string>)newValue);
944 defaultValueCreator: (bindable) =>
946 var textLabel = (TextLabel)bindable;
947 return textLabel.fontFamilySelector;
949 internal static readonly BindableProperty PointSizeSelectorProperty = BindableProperty.Create("PointSizeSelector", typeof(Selector<float?>), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) =>
951 var textLabel = (TextLabel)bindable;
952 textLabel.pointSizeSelector.Clone((Selector<float?>)newValue);
954 defaultValueCreator: (bindable) =>
956 var textLabel = (TextLabel)bindable;
957 return textLabel.pointSizeSelector;
959 internal static readonly BindableProperty TextColorSelectorProperty = BindableProperty.Create("TextColorSelector", typeof(Selector<Color>), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) =>
961 var textLabel = (TextLabel)bindable;
962 textLabel.textColorSelector.Clone((Selector<Color>)newValue);
964 defaultValueCreator: (bindable) =>
966 var textLabel = (TextLabel)bindable;
967 return textLabel.textColorSelector;
970 private TriggerableSelector<string> translatableTextSelector;
971 private TriggerableSelector<string> TranslatableTextSelector
975 if (null == translatableTextSelector)
977 translatableTextSelector = new TriggerableSelector<string>(this, TranslatableTextProperty);
979 return translatableTextSelector;
983 private TriggerableSelector<string> _textSelector;
984 private TriggerableSelector<string> textSelector
988 if (null == _textSelector)
990 _textSelector = new TriggerableSelector<string>(this, TextProperty);
992 return _textSelector;
996 private TriggerableSelector<string> _fontFamilySelector;
997 private TriggerableSelector<string> fontFamilySelector
1001 if (null == _fontFamilySelector)
1003 _fontFamilySelector = new TriggerableSelector<string>(this, FontFamilyProperty);
1005 return _fontFamilySelector;
1009 private TriggerableSelector<Color> _textColorSelector;
1010 private TriggerableSelector<Color> textColorSelector
1014 if (null == _textColorSelector)
1016 _textColorSelector = new TriggerableSelector<Color>(this, TextColorProperty);
1018 return _textColorSelector;
1022 private TriggerableSelector<float?> _pointSizeSelector;
1023 private TriggerableSelector<float?> pointSizeSelector
1027 if (null == _pointSizeSelector)
1029 _pointSizeSelector = new TriggerableSelector<float?>(this, PointSizeProperty);
1031 return _pointSizeSelector;
1036 /// Invoked whenever the binding context of the textlabel changes. Implement this method to add class handling for this event.
1038 protected override void OnBindingContextChanged()
1040 base.OnBindingContextChanged();
1043 private void SystemSettings_LocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
1045 Text = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(e.Value.Replace("_", "-")));
1048 private void NotifyPropertyChangedAndRequestLayout()
1050 NotifyPropertyChanged();
1051 Layout?.RequestLayout();
1054 internal new class Property
1056 internal static readonly int RENDERING_BACKEND = Interop.TextLabel.TextLabel_Property_RENDERING_BACKEND_get();
1057 internal static readonly int TEXT = Interop.TextLabel.TextLabel_Property_TEXT_get();
1058 internal static readonly int FONT_FAMILY = Interop.TextLabel.TextLabel_Property_FONT_FAMILY_get();
1059 internal static readonly int FONT_STYLE = Interop.TextLabel.TextLabel_Property_FONT_STYLE_get();
1060 internal static readonly int POINT_SIZE = Interop.TextLabel.TextLabel_Property_POINT_SIZE_get();
1061 internal static readonly int MULTI_LINE = Interop.TextLabel.TextLabel_Property_MULTI_LINE_get();
1062 internal static readonly int HORIZONTAL_ALIGNMENT = Interop.TextLabel.TextLabel_Property_HORIZONTAL_ALIGNMENT_get();
1063 internal static readonly int VERTICAL_ALIGNMENT = Interop.TextLabel.TextLabel_Property_VERTICAL_ALIGNMENT_get();
1064 internal static readonly int TEXT_COLOR = Interop.TextLabel.TextLabel_Property_TEXT_COLOR_get();
1065 internal static readonly int ENABLE_MARKUP = Interop.TextLabel.TextLabel_Property_ENABLE_MARKUP_get();
1066 internal static readonly int ENABLE_AUTO_SCROLL = Interop.TextLabel.TextLabel_Property_ENABLE_AUTO_SCROLL_get();
1067 internal static readonly int AUTO_SCROLL_SPEED = Interop.TextLabel.TextLabel_Property_AUTO_SCROLL_SPEED_get();
1068 internal static readonly int AUTO_SCROLL_LOOP_COUNT = Interop.TextLabel.TextLabel_Property_AUTO_SCROLL_LOOP_COUNT_get();
1069 internal static readonly int AUTO_SCROLL_GAP = Interop.TextLabel.TextLabel_Property_AUTO_SCROLL_GAP_get();
1070 internal static readonly int LINE_SPACING = Interop.TextLabel.TextLabel_Property_LINE_SPACING_get();
1071 internal static readonly int UNDERLINE = Interop.TextLabel.TextLabel_Property_UNDERLINE_get();
1072 internal static readonly int SHADOW = Interop.TextLabel.TextLabel_Property_SHADOW_get();
1073 internal static readonly int EMBOSS = Interop.TextLabel.TextLabel_Property_EMBOSS_get();
1074 internal static readonly int OUTLINE = Interop.TextLabel.TextLabel_Property_OUTLINE_get();
1075 internal static readonly int PIXEL_SIZE = Interop.TextLabel.TextLabel_Property_PIXEL_SIZE_get();
1076 internal static readonly int ELLIPSIS = Interop.TextLabel.TextLabel_Property_ELLIPSIS_get();
1077 internal static readonly int AUTO_SCROLL_STOP_MODE = Interop.TextLabel.TextLabel_Property_AUTO_SCROLL_STOP_MODE_get();
1078 internal static readonly int AUTO_SCROLL_LOOP_DELAY = Interop.TextLabel.TextLabel_Property_AUTO_SCROLL_LOOP_DELAY_get();
1079 internal static readonly int LINE_COUNT = Interop.TextLabel.TextLabel_Property_LINE_COUNT_get();
1080 internal static readonly int LINE_WRAP_MODE = Interop.TextLabel.TextLabel_Property_LINE_WRAP_MODE_get();
1081 internal static readonly int TEXT_DIRECTION = Interop.TextLabel.TextLabel_Property_TEXT_DIRECTION_get();
1082 internal static readonly int VERTICAL_LINE_ALIGNMENT = Interop.TextLabel.TextLabel_Property_VERTICAL_LINE_ALIGNMENT_get();
1083 internal static readonly int MATCH_SYSTEM_LANGUAGE_DIRECTION = Interop.TextLabel.TextLabel_Property_MATCH_SYSTEM_LANGUAGE_DIRECTION_get();
1084 internal static readonly int TEXT_FIT = Interop.TextLabel.TextLabel_Property_TEXT_FIT_get();
1085 internal static readonly int MIN_LINE_SIZE = Interop.TextLabel.TextLabel_Property_MIN_LINE_SIZE_get();
1088 private void OnShadowColorChanged(float x, float y, float z, float w)
1090 ShadowColor = new Vector4(x, y, z, w);
1092 private void OnShadowOffsetChanged(float x, float y)
1094 ShadowOffset = new Vector2(x, y);
1096 private void OnTextColorChanged(float r, float g, float b, float a)
1098 TextColor = new Color(r, g, b, a);
1100 private void OnUnderlineColorChanged(float x, float y, float z, float w)
1102 UnderlineColor = new Vector4(x, y, z, w);
1105 private void OnTextShadowChanged(TextShadow instance)
1107 TextShadow = instance;
1110 private void OnControlStateChangedForShadow(object obj, ControlStateChangedEventArgs controlStateChangedInfo)
1112 UpdateTextShadowVisual();
1115 private void UpdateTextShadowVisual()
1117 TextShadow shadow = (textShadow != null && !textShadow.IsEmpty()) ? textShadow.GetValue() : textShadow?.GetValue();
1118 Object.SetProperty(swigCPtr, Property.SHADOW, TextShadow.ToPropertyValue(shadow));