From 53231c9d0189e1dd419ca92eef1ca8569d17c440 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Fri, 11 Nov 2022 18:26:16 +0900 Subject: [PATCH] [NUI] Add FontSizeScale in TextStyle Setting FontSizeScale to UseSystemSetting in Theme, the default font scale follows the properties of system. - Added new argument to New(bool hasStlye) - If true, DALi's json is no longer used in Text components - If false, use DALi's json. - Fixed previous incorrect bindable property structure. - This must be sync merged with patches below. https://review.tizen.org/gerrit/#/c/platform/core/uifw/dali-toolkit/+/284113/ https://review.tizen.org/gerrit/#/c/platform/core/uifw/dali-csharp-binder/+/284127/ Signed-off-by: Bowon Ryu --- .../src/internal/Interop/Interop.TextEditor.cs | 3 ++ .../src/internal/Interop/Interop.TextField.cs | 3 ++ .../src/internal/Interop/Interop.TextLabel.cs | 8 ++++- .../public/BaseComponents/Style/TextEditorStyle.cs | 20 +++++++++++ .../public/BaseComponents/Style/TextFieldStyle.cs | 19 ++++++++++ .../public/BaseComponents/Style/TextLabelStyle.cs | 19 ++++++++++ .../src/public/BaseComponents/TextEditor.cs | 38 ++++++++++++++++---- .../BaseComponents/TextEditorBindableProperty.cs | 17 ++------- .../src/public/BaseComponents/TextField.cs | 36 +++++++++++++++---- .../BaseComponents/TextFieldBindableProperty.cs | 17 ++------- .../src/public/BaseComponents/TextLabel.cs | 42 +++++++++++++++++----- .../BaseComponents/TextLabelBindableProperty.cs | 19 ++-------- .../src/public/Theme/DefaultThemeCommon.cs | 3 ++ 13 files changed, 175 insertions(+), 69 deletions(-) diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.TextEditor.cs b/src/Tizen.NUI/src/internal/Interop/Interop.TextEditor.cs index 9d7a4e7..f8090e9 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.TextEditor.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.TextEditor.cs @@ -162,6 +162,9 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextEditor_New")] public static extern global::System.IntPtr New(); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextEditor_New_With_Style")] + public static extern global::System.IntPtr New(bool hasStyle); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_TextEditor__SWIG_0")] public static extern global::System.IntPtr NewTextEditor(); diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.TextField.cs b/src/Tizen.NUI/src/internal/Interop/Interop.TextField.cs index 86ad919..81b3f0c 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.TextField.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.TextField.cs @@ -171,6 +171,9 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextField_New")] public static extern global::System.IntPtr New(); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextField_New_With_Style")] + public static extern global::System.IntPtr New(bool hasStyle); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_TextField__SWIG_0")] public static extern global::System.IntPtr NewTextField(); diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.TextLabel.cs b/src/Tizen.NUI/src/internal/Interop/Interop.TextLabel.cs index 787ff65..23ebfe0 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.TextLabel.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.TextLabel.cs @@ -88,7 +88,13 @@ namespace Tizen.NUI public static extern global::System.IntPtr New(); [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_New__SWIG_1")] - public static extern global::System.IntPtr New(string jarg1); + public static extern global::System.IntPtr New(string text); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_New_With_Style")] + public static extern global::System.IntPtr New(bool hasStyle); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_New_With_String_Style")] + public static extern global::System.IntPtr New(string text, bool hasStyle); [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_TextLabel__SWIG_0")] public static extern global::System.IntPtr NewTextLabel(); diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/TextEditorStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/TextEditorStyle.cs index ddceba5..a1d046d 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/TextEditorStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/TextEditorStyle.cs @@ -277,6 +277,18 @@ namespace Tizen.NUI.BaseComponents }); [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty FontSizeScaleProperty = BindableProperty.Create(nameof(FontSizeScale), typeof(float?), typeof(TextEditorStyle), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textEditorStyle = (TextEditorStyle)bindable; + textEditorStyle.fontSizeScale = (float?)newValue; + }, + defaultValueCreator: (bindable) => + { + var textEditorStyle = (TextEditorStyle)bindable; + return textEditorStyle.fontSizeScale; + }); + + [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty SelectionPopupStyleProperty = BindableProperty.Create(nameof(SelectionPopupStyle), typeof(PropertyMap), typeof(TextEditorStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var textEditorStyle = (TextEditorStyle)bindable; @@ -326,6 +338,7 @@ namespace Tizen.NUI.BaseComponents private float? lineSpacing; private float? minLineSize; private float? relativeLineHeight; + private float? fontSizeScale; static TextEditorStyle() { } @@ -713,6 +726,13 @@ namespace Tizen.NUI.BaseComponents } [EditorBrowsable(EditorBrowsableState.Never)] + public float? FontSizeScale + { + get => (float?)GetValue(FontSizeScaleProperty); + set => SetValue(FontSizeScaleProperty, value); + } + + [EditorBrowsable(EditorBrowsableState.Never)] public PropertyMap SelectionPopupStyle { get => (PropertyMap)GetValue(SelectionPopupStyleProperty); diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs index 965aaab..a370f46 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs @@ -50,6 +50,17 @@ namespace Tizen.NUI.BaseComponents var textFieldStyle = (TextFieldStyle)bindable; return textFieldStyle.pointSize; }); + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty FontSizeScaleProperty = BindableProperty.Create(nameof(FontSizeScale), typeof(float?), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textFieldStyle = (TextFieldStyle)bindable; + textFieldStyle.fontSizeScale = (float?)newValue; + }, + defaultValueCreator: (bindable) => + { + var textFieldStyle = (TextFieldStyle)bindable; + return textFieldStyle.fontSizeScale; + }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TextColorProperty = BindableProperty.Create(nameof(TextColor), typeof(Color), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) => @@ -545,6 +556,7 @@ namespace Tizen.NUI.BaseComponents private string fontFamily; private Color textColor; private float? pointSize; + private float? fontSizeScale; private Vector4 placeholderTextColor; private Vector4 primaryCursorColor; private PropertyMap fontStyle; @@ -845,6 +857,13 @@ namespace Tizen.NUI.BaseComponents set => SetValue(PointSizeProperty, value); } + [EditorBrowsable(EditorBrowsableState.Never)] + public float? FontSizeScale + { + get => (float?)GetValue(FontSizeScaleProperty); + set => SetValue(FontSizeScaleProperty, value); + } + /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public Vector4 PlaceholderTextColor diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs index e24271a..e86a49e 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs @@ -303,6 +303,17 @@ namespace Tizen.NUI.BaseComponents var textLabelStyle = (TextLabelStyle)bindable; return textLabelStyle.characterSpacing; }); + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty FontSizeScaleProperty = BindableProperty.Create(nameof(FontSizeScale), typeof(float?), typeof(TextLabelStyle), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textLabelStyle = (TextLabelStyle)bindable; + textLabelStyle.fontSizeScale = (float?)newValue; + }, + defaultValueCreator: (bindable) => + { + var textLabelStyle = (TextLabelStyle)bindable; + return textLabelStyle.fontSizeScale; + }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty MatchSystemLanguageDirectionProperty = BindableProperty.Create(nameof(MatchSystemLanguageDirection), typeof(bool?), typeof(TextLabelStyle), null, propertyChanged: (bindable, oldValue, newValue) => @@ -365,6 +376,7 @@ namespace Tizen.NUI.BaseComponents private Selector textShadow; private PropertyMap fontStyle; private float? characterSpacing; + private float? fontSizeScale; static TextLabelStyle() { } @@ -554,6 +566,13 @@ namespace Tizen.NUI.BaseComponents set => SetValue(CharacterSpacingProperty, value); } + [EditorBrowsable(EditorBrowsableState.Never)] + public float? FontSizeScale + { + get => (float?)GetValue(FontSizeScaleProperty); + set => SetValue(FontSizeScaleProperty, value); + } + /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public bool? MatchSystemLanguageDirection diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs index 0fb26cf..39b0d74 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs @@ -39,6 +39,7 @@ namespace Tizen.NUI.BaseComponents private float fontSizeScale = 1.0f; private bool hasFontSizeChangedCallback = false; private bool isSettingTextInCSharp = false; + static private string defaultStyleName = "Tizen.NUI.BaseComponents.TextEditor"; private Color internalPlaceholderTextColor = null; private Vector4 internalPrimaryCursorColor = null; @@ -55,7 +56,7 @@ namespace Tizen.NUI.BaseComponents /// Creates the TextEditor control. /// /// 3 - public TextEditor() : this(Interop.TextEditor.New(), true) + public TextEditor() : this(Interop.TextEditor.New(ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -64,7 +65,7 @@ namespace Tizen.NUI.BaseComponents /// Creates the TextEditor with specified style. /// [EditorBrowsable(EditorBrowsableState.Never)] - public TextEditor(TextEditorStyle style) : this(Interop.TextLabel.New(), true, style: style) + public TextEditor(TextEditorStyle style) : this(Interop.TextEditor.New(ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true, style: style) { } @@ -74,7 +75,7 @@ namespace Tizen.NUI.BaseComponents /// false : Not displayed (hidden), true : displayed (shown) /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI). [EditorBrowsable(EditorBrowsableState.Never)] - public TextEditor(bool shown) : this(Interop.TextEditor.New(), true) + public TextEditor(bool shown) : this(Interop.TextEditor.New(ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); SetVisible(shown); @@ -2168,6 +2169,19 @@ namespace Tizen.NUI.BaseComponents { get { + return (float)GetValue(FontSizeScaleProperty); + } + set + { + SetValue(FontSizeScaleProperty, value); + NotifyPropertyChanged(); + } + } + + private float InternalFontSizeScale + { + get + { return fontSizeScale; } set @@ -2199,9 +2213,20 @@ namespace Tizen.NUI.BaseComponents removeFontSizeChangedCallback(); } - SetValue(FontSizeScaleProperty, newFontSizeScale); - NotifyPropertyChanged(); + SetInternalFontSizeScale(newFontSizeScale); + } + } + + private void SetInternalFontSizeScale(float fontSizeScale) + { +#if NUI_PROPERTY_CHANGE_2 + Object.InternalSetPropertyFloat(this.SwigCPtr, TextEditor.Property.FontSizeScale, (float)fontSizeScale); +#else + using (var property = new Tizen.NUI.PropertyValue((float)fontSizeScale)) + { + Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)this.SwigCPtr, TextEditor.Property.FontSizeScale, property); } +#endif } /// @@ -2531,8 +2556,7 @@ namespace Tizen.NUI.BaseComponents private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e) { float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value); - SetValue(FontSizeScaleProperty, newFontSizeScale); - NotifyPropertyChanged(); + SetInternalFontSizeScale(newFontSizeScale); } private void addFontSizeChangedCallback() diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextEditorBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/TextEditorBindableProperty.cs index d9bd88a..2875cb2 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextEditorBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextEditorBindableProperty.cs @@ -1022,26 +1022,13 @@ namespace Tizen.NUI.BaseComponents var textEditor = (TextEditor)bindable; if (newValue != null) { -#if NUI_PROPERTY_CHANGE_2 - Object.InternalSetPropertyFloat(textEditor.SwigCPtr, TextEditor.Property.FontSizeScale, (float)newValue); -#else - using (var property = new Tizen.NUI.PropertyValue((float)newValue)) - { - Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)textEditor.SwigCPtr, TextEditor.Property.FontSizeScale, property); - } -#endif + textEditor.InternalFontSizeScale = (float)newValue; } }), defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) => { var textEditor = (TextEditor)bindable; -#if NUI_PROPERTY_CHANGE_2 - return Object.InternalGetPropertyFloat(textEditor.SwigCPtr, TextEditor.Property.FontSizeScale); -#else - float temp; - Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)textEditor.SwigCPtr, TextEditor.Property.FontSizeScale).Get(out temp); - return temp; -#endif + return textEditor.InternalFontSizeScale; })); [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index efe7f72..c2bf3d5 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -39,6 +39,7 @@ namespace Tizen.NUI.BaseComponents private float fontSizeScale = 1.0f; private bool hasFontSizeChangedCallback = false; private bool isSettingTextInCSharp = false; + static private string defaultStyleName = "Tizen.NUI.BaseComponents.TextField"; private Vector4 internalPlaceholderTextColor = null; @@ -56,7 +57,7 @@ namespace Tizen.NUI.BaseComponents /// Creates the TextField control. /// /// 3 - public TextField() : this(Interop.TextField.New(), true) + public TextField() : this(Interop.TextField.New(ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -67,7 +68,7 @@ namespace Tizen.NUI.BaseComponents /// false : Not displayed (hidden), true : displayed (shown) /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI). [EditorBrowsable(EditorBrowsableState.Never)] - public TextField(bool shown) : this(Interop.TextField.New(), true) + public TextField(bool shown) : this(Interop.TextField.New(ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); SetVisible(shown); @@ -2288,6 +2289,19 @@ namespace Tizen.NUI.BaseComponents { get { + return (float)GetValue(FontSizeScaleProperty); + } + set + { + SetValue(FontSizeScaleProperty, value); + NotifyPropertyChanged(); + } + } + + private float InternalFontSizeScale + { + get + { return fontSizeScale; } set @@ -2319,9 +2333,20 @@ namespace Tizen.NUI.BaseComponents removeFontSizeChangedCallback(); } - SetValue(FontSizeScaleProperty, newFontSizeScale); - NotifyPropertyChanged(); + SetInternalFontSizeScale(newFontSizeScale); + } + } + + private void SetInternalFontSizeScale(float fontSizeScale) + { +#if NUI_PROPERTY_CHANGE_2 + Object.InternalSetPropertyFloat(this.SwigCPtr, TextField.Property.FontSizeScale, (float)fontSizeScale); +#else + using (var property = new Tizen.NUI.PropertyValue((float)fontSizeScale)) + { + Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)this.SwigCPtr, TextField.Property.FontSizeScale, property); } +#endif } /// @@ -2543,8 +2568,7 @@ namespace Tizen.NUI.BaseComponents private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e) { float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value); - SetValue(FontSizeScaleProperty, newFontSizeScale); - NotifyPropertyChanged(); + SetInternalFontSizeScale(newFontSizeScale); } private void addFontSizeChangedCallback() diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs index 39bfe47..566ab43 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs @@ -1058,26 +1058,13 @@ namespace Tizen.NUI.BaseComponents var textField = (TextField)bindable; if (newValue != null) { -#if NUI_PROPERTY_CHANGE_2 - Object.InternalSetPropertyFloat(textField.SwigCPtr, TextField.Property.FontSizeScale, (float)newValue); -#else - using (var property = new Tizen.NUI.PropertyValue((float)newValue)) - { - Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)textField.SwigCPtr, TextField.Property.FontSizeScale, property); - } -#endif + textField.InternalFontSizeScale = (float)newValue; } }), defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) => { var textField = (TextField)bindable; -#if NUI_PROPERTY_CHANGE_2 - return Object.InternalGetPropertyFloat(textField.SwigCPtr, TextField.Property.FontSizeScale); -#else - float temp; - Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)textField.SwigCPtr, TextField.Property.FontSizeScale).Get(out temp); - return temp; -#endif + return textField.InternalFontSizeScale; })); [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs index fad7f84..a4bfe7e 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs @@ -86,6 +86,7 @@ namespace Tizen.NUI.BaseComponents private TextLabelSelectorData selectorData; private float fontSizeScale = 1.0f; private bool hasFontSizeChangedCallback = false; + static private string defaultStyleName = "Tizen.NUI.BaseComponents.TextLabel"; private Color internalTextColor; @@ -93,14 +94,14 @@ namespace Tizen.NUI.BaseComponents /// Creates the TextLabel control. /// /// 3 - public TextLabel() : this(Interop.TextLabel.New(), true) + public TextLabel() : this(Interop.TextLabel.New(ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI). [EditorBrowsable(EditorBrowsableState.Never)] - public TextLabel(TextLabelStyle viewStyle) : this(Interop.TextLabel.New(), true, viewStyle) + public TextLabel(TextLabelStyle viewStyle) : this(Interop.TextLabel.New(ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true, viewStyle) { } @@ -110,7 +111,7 @@ namespace Tizen.NUI.BaseComponents /// false : Not displayed (hidden), true : displayed (shown) /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI). [EditorBrowsable(EditorBrowsableState.Never)] - public TextLabel(bool shown) : this(Interop.TextLabel.New(), true) + public TextLabel(bool shown) : this(Interop.TextLabel.New(ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); SetVisible(shown); @@ -121,7 +122,7 @@ namespace Tizen.NUI.BaseComponents /// /// The text to display /// 3 - public TextLabel(string text) : this(Interop.TextLabel.New(text), true) + public TextLabel(string text) : this(Interop.TextLabel.New(text, ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -133,7 +134,7 @@ namespace Tizen.NUI.BaseComponents /// false : Not displayed (hidden), true : displayed (shown) /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI). [EditorBrowsable(EditorBrowsableState.Never)] - public TextLabel(string text, bool shown) : this(Interop.TextLabel.New(text), true) + public TextLabel(string text, bool shown) : this(Interop.TextLabel.New(text, ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); SetVisible(shown); @@ -1397,6 +1398,19 @@ namespace Tizen.NUI.BaseComponents { get { + return (float)GetValue(FontSizeScaleProperty); + } + set + { + SetValue(FontSizeScaleProperty, value); + NotifyPropertyChanged(); + } + } + + private float InternalFontSizeScale + { + get + { return fontSizeScale; } set @@ -1428,9 +1442,21 @@ namespace Tizen.NUI.BaseComponents removeFontSizeChangedCallback(); } - SetValue(FontSizeScaleProperty, newFontSizeScale); - NotifyPropertyChanged(); + SetInternalFontSizeScale(newFontSizeScale); + } + } + + private void SetInternalFontSizeScale(float fontSizeScale) + { +#if NUI_PROPERTY_CHANGE_2 + Object.InternalSetPropertyFloat(this.SwigCPtr, TextLabel.Property.FontSizeScale, (float)fontSizeScale); +#else + using (var property = new Tizen.NUI.PropertyValue((float)fontSizeScale)) + { + Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)this.SwigCPtr, TextLabel.Property.FontSizeScale, property); } +#endif + RequestLayout(); } /// @@ -1551,7 +1577,7 @@ namespace Tizen.NUI.BaseComponents private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e) { float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value); - SetValue(FontSizeScaleProperty, newFontSizeScale); + SetInternalFontSizeScale(newFontSizeScale); } private void addFontSizeChangedCallback() diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs index c0df7e8..82e06aa 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs @@ -665,28 +665,13 @@ namespace Tizen.NUI.BaseComponents var textLabel = (TextLabel)bindable; if (newValue != null) { -#if NUI_PROPERTY_CHANGE_2 - Object.InternalSetPropertyFloat(textLabel.SwigCPtr, TextLabel.Property.FontSizeScale, (float)newValue); - textLabel.RequestLayout(); -#else - using (var property = new Tizen.NUI.PropertyValue((float)newValue)) - { - Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)textLabel.SwigCPtr, TextLabel.Property.FontSizeScale, property); - textLabel.RequestLayout(); - } -#endif + textLabel.InternalFontSizeScale = (float)newValue; } }), defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) => { var textLabel = (TextLabel)bindable; -#if NUI_PROPERTY_CHANGE_2 - return Object.InternalGetPropertyFloat(textLabel.SwigCPtr, TextLabel.Property.FontSizeScale); -#else - float temp; - Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)textLabel.SwigCPtr, TextLabel.Property.FontSizeScale).Get(out temp); - return temp; -#endif + return textLabel.InternalFontSizeScale; })); [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/src/Tizen.NUI/src/public/Theme/DefaultThemeCommon.cs b/src/Tizen.NUI/src/public/Theme/DefaultThemeCommon.cs index b8392d4..5510be5 100644 --- a/src/Tizen.NUI/src/public/Theme/DefaultThemeCommon.cs +++ b/src/Tizen.NUI/src/public/Theme/DefaultThemeCommon.cs @@ -44,6 +44,7 @@ namespace Tizen.NUI AutoScrollLoopCount = 2, AutoScrollGap = 50.0f, AutoScrollSpeed = 80, + FontSizeScale = Tizen.NUI.FontSizeScale.UseSystemSetting, }); // TextField style. @@ -57,6 +58,7 @@ namespace Tizen.NUI PrimaryCursorColor = new Vector4(0.04f, 0.05f, 0.13f, 1), SecondaryCursorColor = new Vector4(0.04f, 0.05f, 0.13f, 1), CursorWidth = 2, + FontSizeScale = Tizen.NUI.FontSizeScale.UseSystemSetting, SelectionHighlightColor = new Vector4(1.00f, 0.38f, 0.00f, 0.30f), GrabHandleColor = new Color(1.00f, 1.00f, 1.00f, 1), GrabHandleImage = FrameworkInformation.ResourcePath + "IoT_handler_center_downW.png", @@ -93,6 +95,7 @@ namespace Tizen.NUI PrimaryCursorColor = new Vector4(0.04f, 0.05f, 0.13f, 1), SecondaryCursorColor = new Vector4(0.04f, 0.05f, 0.13f, 1), CursorWidth = 2, + FontSizeScale = Tizen.NUI.FontSizeScale.UseSystemSetting, SelectionHighlightColor = new Vector4(1.00f, 0.38f, 0.00f, 0.30f), GrabHandleColor = new Color(1.00f, 1.00f, 1.00f, 1), GrabHandleImage = FrameworkInformation.ResourcePath + "IoT_handler_center_downW.png", -- 2.7.4