From: Jaehyun Cho Date: Fri, 28 Oct 2022 02:59:06 +0000 (+0900) Subject: [NUI] Add constructor with style instance X-Git-Tag: accepted/tizen/7.0/unified/20221103.165518~1^2~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=de80d0a07edfe60d18108b7855b6442a77e85bb2;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Add constructor with style instance To customize and apply app's own style instance, constructor with style instance should be added. For now, ApplyStyle() modifies the given properties only based on the default style unlike applying style in constructor. e.g. Let default style contain properties A, B, C. Let custom style contain properties B, C. Then ApplyStyle(custom style) contain default style's A and custom style's B and C. Consequently, to apply custom style without applying default style, constructor with style instance is required. --- diff --git a/src/Tizen.NUI.Components/Controls/Dialog.cs b/src/Tizen.NUI.Components/Controls/Dialog.cs index ec86fc2..dc54404 100755 --- a/src/Tizen.NUI.Components/Controls/Dialog.cs +++ b/src/Tizen.NUI.Components/Controls/Dialog.cs @@ -48,15 +48,30 @@ namespace Tizen.NUI.Components private View content = null; + private void Initialize() + { + Layout = new AbsoluteLayout(); + + this.Relayout += OnRelayout; + } + /// /// Creates a new instance of Dialog. /// /// 9 public Dialog() : base() { - Layout = new AbsoluteLayout(); + Initialize(); + } - this.Relayout += OnRelayout; + /// + /// Creates a new instance of a Dialog with style. + /// + /// A style applied to the newly created Dialog. + [EditorBrowsable(EditorBrowsableState.Never)] + public Dialog(ControlStyle style) : base(style) + { + Initialize(); } /// diff --git a/src/Tizen.NUI.Components/Controls/Menu.cs b/src/Tizen.NUI.Components/Controls/Menu.cs index d6ee226..bb16aca 100755 --- a/src/Tizen.NUI.Components/Controls/Menu.cs +++ b/src/Tizen.NUI.Components/Controls/Menu.cs @@ -58,6 +58,16 @@ namespace Tizen.NUI.Components Initialize(); } + /// + /// Creates a new instance of a Menu with style. + /// + /// A style applied to the newly created Menu. + [EditorBrowsable(EditorBrowsableState.Never)] + public Menu(MenuStyle style) : base(style) + { + Initialize(); + } + /// [EditorBrowsable(EditorBrowsableState.Never)] protected override void Dispose(DisposeTypes type) @@ -468,8 +478,6 @@ namespace Tizen.NUI.Components WidthSpecification = LayoutParamPolicies.WrapContent; HeightSpecification = LayoutParamPolicies.WrapContent; - BackgroundColor = Color.Transparent; - // Menu is added to Anchor so Menu should exclude layouting because // if Anchor has Layout, then Menu is displayed at an incorrect position. ExcludeLayouting = true; diff --git a/src/Tizen.NUI.Components/Controls/MenuItem.cs b/src/Tizen.NUI.Components/Controls/MenuItem.cs index b41e2e9..203e2af 100755 --- a/src/Tizen.NUI.Components/Controls/MenuItem.cs +++ b/src/Tizen.NUI.Components/Controls/MenuItem.cs @@ -48,6 +48,16 @@ namespace Tizen.NUI.Components Initialize(); } + /// + /// Creates a new instance of a MenuItem with style. + /// + /// A style applied to the newly created MenuItem. + [EditorBrowsable(EditorBrowsableState.Never)] + public MenuItem(ButtonStyle style) : base(style) + { + Initialize(); + } + /// [EditorBrowsable(EditorBrowsableState.Never)] protected override void Dispose(DisposeTypes type) diff --git a/src/Tizen.NUI.Components/Controls/Navigation/ContentPage.cs b/src/Tizen.NUI.Components/Controls/Navigation/ContentPage.cs index b92f9d3..2e54a70 100755 --- a/src/Tizen.NUI.Components/Controls/Navigation/ContentPage.cs +++ b/src/Tizen.NUI.Components/Controls/Navigation/ContentPage.cs @@ -29,17 +29,32 @@ namespace Tizen.NUI.Components private AppBar appBar = null; private View content = null; + private void Initialize() + { + Layout = new ContentPageLayout(); + + // ContentPage matches to parent by default. + WidthSpecification = LayoutParamPolicies.MatchParent; + HeightSpecification = LayoutParamPolicies.MatchParent; + } + /// /// Creates a new instance of a ContentPage. /// /// 9 public ContentPage() : base() { - Layout = new ContentPageLayout(); + Initialize(); + } - // ContentPage matches to parent by default. - WidthSpecification = LayoutParamPolicies.MatchParent; - HeightSpecification = LayoutParamPolicies.MatchParent; + /// + /// Creates a new instance of a ContentPage with style. + /// + /// A style applied to the newly created ContentPage. + [EditorBrowsable(EditorBrowsableState.Never)] + public ContentPage(ControlStyle style) : base(style) + { + Initialize(); } /// diff --git a/src/Tizen.NUI.Components/Controls/Navigation/DialogPage.cs b/src/Tizen.NUI.Components/Controls/Navigation/DialogPage.cs index 5a22f23..5cb7903 100755 --- a/src/Tizen.NUI.Components/Controls/Navigation/DialogPage.cs +++ b/src/Tizen.NUI.Components/Controls/Navigation/DialogPage.cs @@ -32,11 +32,7 @@ namespace Tizen.NUI.Components private View scrim = null; private bool enableScrim = true; - /// - /// Creates a new instance of a DialogPage. - /// - /// 9 - public DialogPage() : base() + private void Initialize() { Layout = new AbsoluteLayout(); @@ -52,6 +48,25 @@ namespace Tizen.NUI.Components } /// + /// Creates a new instance of a DialogPage. + /// + /// 9 + public DialogPage() : base() + { + Initialize(); + } + + /// + /// Creates a new instance of a DialogPage with style. + /// + /// A style applied to the newly created DialogPage. + [EditorBrowsable(EditorBrowsableState.Never)] + public DialogPage(ControlStyle style) : base(style) + { + Initialize(); + } + + /// /// Dispose DialogPage and all children on it. /// /// Dispose type. diff --git a/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs b/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs index daad00e..77b5ac4 100755 --- a/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs +++ b/src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs @@ -117,13 +117,28 @@ namespace Tizen.NUI.Components private List navigationPages = new List(); + private void Initialize() + { + Layout = new AbsoluteLayout(); + } + /// /// Creates a new instance of a Navigator. /// /// 9 public Navigator() : base() { - Layout = new AbsoluteLayout(); + Initialize(); + } + + /// + /// Creates a new instance of a Navigator with style. + /// + /// A style applied to the newly created Navigator. + [EditorBrowsable(EditorBrowsableState.Never)] + public Navigator(ControlStyle style) : base(style) + { + Initialize(); } /// diff --git a/src/Tizen.NUI.Components/Controls/Navigation/Page.cs b/src/Tizen.NUI.Components/Controls/Navigation/Page.cs index 0b56633..e2227c4 100755 --- a/src/Tizen.NUI.Components/Controls/Navigation/Page.cs +++ b/src/Tizen.NUI.Components/Controls/Navigation/Page.cs @@ -114,6 +114,15 @@ namespace Tizen.NUI.Components } /// + /// Creates a new instance of a Page with style. + /// + /// A style applied to the newly created Page. + [EditorBrowsable(EditorBrowsableState.Never)] + public Page(ControlStyle style) : base(style) + { + } + + /// /// Navigator which has pushed the Page into its stack. /// If this Page has not been pushed into any Navigator, then Navigator is null. /// diff --git a/src/Tizen.NUI.Components/Controls/RecyclerView/CollectionView.cs b/src/Tizen.NUI.Components/Controls/RecyclerView/CollectionView.cs index c010e48..d505f0a 100755 --- a/src/Tizen.NUI.Components/Controls/RecyclerView/CollectionView.cs +++ b/src/Tizen.NUI.Components/Controls/RecyclerView/CollectionView.cs @@ -164,14 +164,19 @@ namespace Tizen.NUI.Components private bool delayedIndexScrollTo; private (int index, bool anim, ItemScrollTo scrollTo) delayedIndexScrollToParam; + private void Initialize() + { + FocusGroup = true; + SetKeyboardNavigationSupport(true); + } + /// /// Base constructor. /// /// 9 public CollectionView() : base() { - FocusGroup = true; - SetKeyboardNavigationSupport(true); + Initialize(); } /// @@ -199,6 +204,16 @@ namespace Tizen.NUI.Components } /// + /// Creates a new instance of a CollectionView with style. + /// + /// A style applied to the newly created CollectionView. + [EditorBrowsable(EditorBrowsableState.Never)] + public CollectionView(ControlStyle style) : base(style) + { + Initialize(); + } + + /// /// Event of Selection changed. /// previous selection list and current selection will be provided. /// diff --git a/src/Tizen.NUI.Components/Controls/RecyclerView/RecyclerView.cs b/src/Tizen.NUI.Components/Controls/RecyclerView/RecyclerView.cs index f9682a2..8666960 100755 --- a/src/Tizen.NUI.Components/Controls/RecyclerView/RecyclerView.cs +++ b/src/Tizen.NUI.Components/Controls/RecyclerView/RecyclerView.cs @@ -79,13 +79,28 @@ namespace Tizen.NUI.Components return instance.InternalItemTemplate; }); + private void Initialize() + { + Scrolling += OnScrolling; + } + /// /// Base Constructor /// /// 9 public RecyclerView() : base() { - Scrolling += OnScrolling; + Initialize(); + } + + /// + /// Creates a new instance of a RecyclerView with style. + /// + /// A style applied to the newly created RecyclerView. + [EditorBrowsable(EditorBrowsableState.Never)] + public RecyclerView(ControlStyle style) : base(style) + { + Initialize(); } /// diff --git a/src/Tizen.NUI.Components/Controls/ScrollableBase.cs b/src/Tizen.NUI.Components/Controls/ScrollableBase.cs index 0f2f477..398cfad 100755 --- a/src/Tizen.NUI.Components/Controls/ScrollableBase.cs +++ b/src/Tizen.NUI.Components/Controls/ScrollableBase.cs @@ -873,11 +873,7 @@ namespace Tizen.NUI.Components private bool isOverShootingShadowShown = false; private float startShowShadowDisplacement; - /// - /// Default Constructor - /// - /// 8 - public ScrollableBase() : base() + private void Initialize() { DecelerationRate = 0.998f; @@ -951,6 +947,25 @@ namespace Tizen.NUI.Components SetKeyboardNavigationSupport(true); } + /// + /// Default Constructor + /// + /// 8 + public ScrollableBase() : base() + { + Initialize(); + } + + /// + /// Creates a new instance of a ScrollableBase with style. + /// + /// A style applied to the newly created ScrollableBase. + [EditorBrowsable(EditorBrowsableState.Never)] + public ScrollableBase(ControlStyle style) : base(style) + { + Initialize(); + } + private bool OnInterruptTouchingChildTouched(object source, View.TouchEventArgs args) { if (args.Touch.GetState(0) == PointStateType.Down) diff --git a/src/Tizen.NUI.Components/Controls/TabBar.cs b/src/Tizen.NUI.Components/Controls/TabBar.cs index e40ddb2..606c6ad 100755 --- a/src/Tizen.NUI.Components/Controls/TabBar.cs +++ b/src/Tizen.NUI.Components/Controls/TabBar.cs @@ -57,11 +57,7 @@ namespace Tizen.NUI.Components private TabButtonGroup tabButtonGroup; - /// - /// Creates a new instance of TabBar. - /// - /// 9 - public TabBar() + private void Initialize() { Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal }; @@ -73,6 +69,25 @@ namespace Tizen.NUI.Components } /// + /// Creates a new instance of TabBar. + /// + /// 9 + public TabBar() + { + Initialize(); + } + + /// + /// Creates a new instance of a TabBar with style. + /// + /// A style applied to the newly created TabBar. + [EditorBrowsable(EditorBrowsableState.Never)] + public TabBar(ControlStyle style) : base(style) + { + Initialize(); + } + + /// /// An event for the tab button selected signal which can be used to /// subscribe or unsubscribe the event handler provided by a user. /// diff --git a/src/Tizen.NUI.Components/Controls/TabContent.cs b/src/Tizen.NUI.Components/Controls/TabContent.cs index 72dd4c1..989ca0d 100755 --- a/src/Tizen.NUI.Components/Controls/TabContent.cs +++ b/src/Tizen.NUI.Components/Controls/TabContent.cs @@ -29,14 +29,29 @@ namespace Tizen.NUI.Components { private IList views; + private void Initialize() + { + SelectedIndex = -1; + views = new List(); + } + /// /// Creates a new instance of TabContent. /// /// 9 public TabContent() { - SelectedIndex = -1; - views = new List(); + Initialize(); + } + + /// + /// Creates a new instance of a TabContent with style. + /// + /// A style applied to the newly created TabContent. + [EditorBrowsable(EditorBrowsableState.Never)] + public TabContent(ControlStyle style) : base(style) + { + Initialize(); } /// diff --git a/src/Tizen.NUI.Components/Controls/TabView.cs b/src/Tizen.NUI.Components/Controls/TabView.cs index 87fdcdf..8e25d19 100755 --- a/src/Tizen.NUI.Components/Controls/TabView.cs +++ b/src/Tizen.NUI.Components/Controls/TabView.cs @@ -85,11 +85,7 @@ namespace Tizen.NUI.Components private TabContent content = null; - /// - /// Creates a new instance of TabView. - /// - /// 9 - public TabView() + private void Initialize() { Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical }; WidthSpecification = LayoutParamPolicies.MatchParent; @@ -102,6 +98,25 @@ namespace Tizen.NUI.Components TabBar.RaiseAbove(Content); } + /// + /// Creates a new instance of TabView. + /// + /// 9 + public TabView() + { + Initialize(); + } + + /// + /// Creates a new instance of a TabView with style. + /// + /// A style applied to the newly created TabView. + [EditorBrowsable(EditorBrowsableState.Never)] + public TabView(ControlStyle style) : base(style) + { + Initialize(); + } + /// [EditorBrowsable(EditorBrowsableState.Never)] public override void OnInitialize() diff --git a/src/Tizen.NUI.Components/Theme/DefaultThemeCommon.cs b/src/Tizen.NUI.Components/Theme/DefaultThemeCommon.cs index 2439f9e..fcb72f2 100755 --- a/src/Tizen.NUI.Components/Theme/DefaultThemeCommon.cs +++ b/src/Tizen.NUI.Components/Theme/DefaultThemeCommon.cs @@ -777,6 +777,7 @@ namespace Tizen.NUI.Components // Menu base style theme.AddStyleWithoutClone("Tizen.NUI.Components.Menu", new MenuStyle() { + BackgroundColor = Color.Transparent, Content = new ViewStyle() { BackgroundColor = new Color("#FFFEFE"),