From deeba7fdb41b56f713da646b5b14df952ab8c871 Mon Sep 17 00:00:00 2001 From: Lynettejin90 <33114201+Lynettejin90@users.noreply.github.com> Date: Tue, 23 Jul 2019 10:19:49 +0800 Subject: [PATCH] [NUI] Update CommonUI (#937) * [NUI.CommonUI] Update CommonUI (1)Fix issues (2)Add style change event for FlexibleView Signed-off-by: Feng Jin * Add api to get the recycler in FlexibleView --- .../Attributes/PopupAttributes.cs | 6 ++- .../Controls/FlexibleView/FlexibleView.cs | 53 +++++++++++++++++++ src/Tizen.NUI.CommonUI/Controls/Switch.cs | 16 ++++++ src/Tizen.NUI.CommonUI/Utils/Selector.cs | 3 ++ 4 files changed, 77 insertions(+), 1 deletion(-) diff --git a/src/Tizen.NUI.CommonUI/Attributes/PopupAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/PopupAttributes.cs index 10f6e84ed..99547884f 100755 --- a/src/Tizen.NUI.CommonUI/Attributes/PopupAttributes.cs +++ b/src/Tizen.NUI.CommonUI/Attributes/PopupAttributes.cs @@ -62,7 +62,11 @@ namespace Tizen.NUI.CommonUI ButtonAttributes = attributes.ButtonAttributes.Clone() as ButtonAttributes; } - ShadowOffset = new Vector4(attributes.ShadowOffset.W, attributes.ShadowOffset.X, attributes.ShadowOffset.Y, attributes.ShadowOffset.Z); + if(attributes.ShadowOffset != null) + { + ShadowOffset = new Vector4(attributes.ShadowOffset.W, attributes.ShadowOffset.X, attributes.ShadowOffset.Y, attributes.ShadowOffset.Z); + } + } /// diff --git a/src/Tizen.NUI.CommonUI/Controls/FlexibleView/FlexibleView.cs b/src/Tizen.NUI.CommonUI/Controls/FlexibleView/FlexibleView.cs index 6a705b904..9d7a5928b 100755 --- a/src/Tizen.NUI.CommonUI/Controls/FlexibleView/FlexibleView.cs +++ b/src/Tizen.NUI.CommonUI/Controls/FlexibleView/FlexibleView.cs @@ -61,6 +61,7 @@ namespace Tizen.NUI.CommonUI private EventHandler clickEventHandlers; private EventHandler touchEventHandlers; + private EventHandler styleChangedEventHandlers; /// /// Creates a FlexibleView instance. @@ -125,6 +126,25 @@ namespace Tizen.NUI.CommonUI } } + /// + /// Style changed, for example default font size. + /// + /// 6 + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler StyleChanged + { + add + { + styleChangedEventHandlers += value; + } + + remove + { + styleChangedEventHandlers -= value; + } + } + /// /// overwrite the Padding. /// @@ -349,6 +369,17 @@ namespace Tizen.NUI.CommonUI return null; } + /// + /// Return the recycler instance. + /// + /// 6 + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public Recycler GetRecycler() + { + return mRecycler; + } + /// /// you can override it to clean-up your own resources. /// @@ -365,6 +396,8 @@ namespace Tizen.NUI.CommonUI if (type == DisposeTypes.Explicit) { + mLayout.StopScroll(); + if (mAdapter != null) { mAdapter.ItemEvent -= OnItemEvent; @@ -436,6 +469,26 @@ namespace Tizen.NUI.CommonUI RemoveAndRecycleScrapInt(); } + /// + /// you can override it to do something for style change. + /// + /// 6 + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public override void OnStyleChange(NUI.StyleManager styleManager, StyleChangeType change) + { + if (change == StyleChangeType.DefaultFontSizeChange) + { + NUI.StyleManager.StyleChangedEventArgs args = new NUI.StyleManager.StyleChangedEventArgs(); + args.StyleManager = styleManager; + args.StyleChange = change; + + styleChangedEventHandlers?.Invoke(this, args); + + RelayoutRequest(); + } + } + private void DispatchLayoutStep1() { ProcessAdapterUpdates(); diff --git a/src/Tizen.NUI.CommonUI/Controls/Switch.cs b/src/Tizen.NUI.CommonUI/Controls/Switch.cs index 11e1bcfde..1a5e81712 100755 --- a/src/Tizen.NUI.CommonUI/Controls/Switch.cs +++ b/src/Tizen.NUI.CommonUI/Controls/Switch.cs @@ -357,6 +357,22 @@ namespace Tizen.NUI.CommonUI CreateHandlerAnimation(); } + /// + /// Theme change callback when theme is changed, this callback will be trigger. + /// + /// 6 + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) + { + SwitchAttributes tempAttributes = StyleManager.Instance.GetAttributes(style) as SwitchAttributes; + if (tempAttributes != null) + { + attributes = switchAttributes = tempAttributes; + RelayoutRequest(); + } + } + private void CreateSwitchBackgroundImageAttributes() { if (switchAttributes.SwitchBackgroundImageAttributes == null) diff --git a/src/Tizen.NUI.CommonUI/Utils/Selector.cs b/src/Tizen.NUI.CommonUI/Utils/Selector.cs index cb611a578..761e2fa53 100755 --- a/src/Tizen.NUI.CommonUI/Utils/Selector.cs +++ b/src/Tizen.NUI.CommonUI/Utils/Selector.cs @@ -164,6 +164,8 @@ namespace Tizen.NUI.CommonUI return DisabledFocused != null? DisabledFocused : Other; case ControlStates.DisabledSelected: return DisabledSelected != null? DisabledSelected : Other; + case ControlStates.SelectedFocused: + return SelectedFocused != null ? SelectedFocused : Other; default: return Other; } @@ -184,6 +186,7 @@ namespace Tizen.NUI.CommonUI Selected = selector.Selected; DisabledSelected = selector.DisabledSelected; DisabledFocused = selector.DisabledFocused; + SelectedFocused = selector.SelectedFocused; Other = selector.Other; } -- 2.34.1