From: Jaehyun Cho Date: Mon, 28 Aug 2023 11:02:39 +0000 (+0900) Subject: [NUI] Add SystemFontSizeChangedManager class X-Git-Tag: accepted/tizen/unified/20231205.024657~168 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4154ae280c05e5132e270ead3d7808ac9c6980f9;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Add SystemFontSizeChangedManager class SystemFontSizeChangedManager is a static class which adds user handlers to the SystemSettings.FontSizeChanged event. It is similar to SystemFontSizeChanged class but it is a static class and it also provides Finished event handler invoked last after all handlers added to the SystemSettings.FontSizeChanged event are invoked. --- diff --git a/src/Tizen.NUI/src/internal/Common/SystemFontSizeChangedManager.cs b/src/Tizen.NUI/src/internal/Common/SystemFontSizeChangedManager.cs new file mode 100644 index 0000000..52db736 --- /dev/null +++ b/src/Tizen.NUI/src/internal/Common/SystemFontSizeChangedManager.cs @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +extern alias TizenSystemSettings; +using TizenSystemSettings.Tizen.System; + +using System; + +namespace Tizen.NUI +{ + /// + /// A static class which adds user handler to the SystemSettings.FontSizeChanged event. + /// This class also adds user handler to the last of the SystemSettings.FontSizeChanged event. + /// + internal static class SystemFontSizeChangedManager + { + static SystemFontSizeChangedManager() + { + SystemSettings.FontSizeChanged += SystemFontSizeChanged; + } + + /// + /// The handler invoked last after all handlers added to the SystemSettings.FontSizeChanged event are invoked. + /// + public static event EventHandler Finished; + + /// + /// Adds the given handler to the SystemSettings.FontSizeChanged event. + /// + /// A handler to be added to the event + public static void Add(EventHandler handler) + { + proxy.Add(handler); + } + + /// + /// Removes the given handler from the SystemSettings.FontSizeChanged event. + /// + /// A handler to be added to the event + public static void Remove(EventHandler handler) + { + proxy.Remove(handler); + } + + private static void SystemFontSizeChanged(object sender, FontSizeChangedEventArgs args) + { + proxy.Invoke(sender, args); + Finished?.Invoke(sender, args); + } + + private static WeakEvent> proxy = new WeakEvent>(); + } +} \ No newline at end of file diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs index 0ba45ac..85f6d98 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs @@ -35,7 +35,6 @@ namespace Tizen.NUI.BaseComponents static private string defaultStyleName = "Tizen.NUI.BaseComponents.TextEditor"; static private string defaultFontFamily = "TizenSans"; private static SystemFontTypeChanged systemFontTypeChanged = new SystemFontTypeChanged(); - private static SystemFontSizeChanged systemFontSizeChanged = new SystemFontSizeChanged(); private static SystemLocaleLanguageChanged systemLocaleLanguageChanged = new SystemLocaleLanguageChanged(); private string textEditorTextSid = null; private string textEditorPlaceHolderTextSid = null; @@ -2615,7 +2614,7 @@ namespace Tizen.NUI.BaseComponents { try { - systemFontSizeChanged.Add(SystemSettingsFontSizeChanged); + SystemFontSizeChangedManager.Add(SystemSettingsFontSizeChanged); hasSystemFontSizeChanged = true; } catch (Exception e) @@ -2632,7 +2631,7 @@ namespace Tizen.NUI.BaseComponents { try { - systemFontSizeChanged.Remove(SystemSettingsFontSizeChanged); + SystemFontSizeChangedManager.Remove(SystemSettingsFontSizeChanged); hasSystemFontSizeChanged = false; } catch (Exception e) diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index cc4871c..36f50b0 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -34,7 +34,6 @@ namespace Tizen.NUI.BaseComponents static private string defaultStyleName = "Tizen.NUI.BaseComponents.TextField"; static private string defaultFontFamily = "TizenSans"; private static SystemFontTypeChanged systemFontTypeChanged = new SystemFontTypeChanged(); - private static SystemFontSizeChanged systemFontSizeChanged = new SystemFontSizeChanged(); private static SystemLocaleLanguageChanged systemLocaleLanguageChanged = new SystemLocaleLanguageChanged(); private string textFieldTextSid = null; private string textFieldPlaceHolderTextSid = null; @@ -2623,7 +2622,7 @@ namespace Tizen.NUI.BaseComponents { try { - systemFontSizeChanged.Add(SystemSettingsFontSizeChanged); + SystemFontSizeChangedManager.Add(SystemSettingsFontSizeChanged); hasSystemFontSizeChanged = true; } catch (Exception e) @@ -2640,7 +2639,7 @@ namespace Tizen.NUI.BaseComponents { try { - systemFontSizeChanged.Remove(SystemSettingsFontSizeChanged); + SystemFontSizeChangedManager.Remove(SystemSettingsFontSizeChanged); hasSystemFontSizeChanged = false; } catch (Exception e) diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs index 59b1b4f..91e3659 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs @@ -85,7 +85,6 @@ namespace Tizen.NUI.BaseComponents static TextLabel() { } private static SystemFontTypeChanged systemFontTypeChanged = new SystemFontTypeChanged(); - private static SystemFontSizeChanged systemFontSizeChanged = new SystemFontSizeChanged(); private static SystemLocaleLanguageChanged systemLocaleLanguageChanged = new SystemLocaleLanguageChanged(); static private string defaultStyleName = "Tizen.NUI.BaseComponents.TextLabel"; static private string defaultFontFamily = "BreezeSans"; @@ -1640,7 +1639,7 @@ namespace Tizen.NUI.BaseComponents { try { - systemFontSizeChanged.Add(SystemSettingsFontSizeChanged); + SystemFontSizeChangedManager.Add(SystemSettingsFontSizeChanged); hasSystemFontSizeChanged = true; } catch (Exception e) @@ -1657,7 +1656,7 @@ namespace Tizen.NUI.BaseComponents { try { - systemFontSizeChanged.Remove(SystemSettingsFontSizeChanged); + SystemFontSizeChangedManager.Remove(SystemSettingsFontSizeChanged); hasSystemFontSizeChanged = false; } catch (Exception e)