From 6cf2734b14acff5f063592620e31e3676cbe6fe5 Mon Sep 17 00:00:00 2001 From: Lynettejin90 <33114201+Lynettejin90@users.noreply.github.com> Date: Fri, 21 Jun 2019 12:04:06 +0800 Subject: [PATCH] [NUI] Add Tizen.NUI.CommonUI project (#883) * Add Tizen.NUI.CommonUI project * Fix warnings * Update Progress and Slider * Add Cache for FlexibleView and Fix some issues * Change ResourceURL to ResourceUrl --- .../Attributes/Attributes.cs | 36 + .../Attributes/ButtonAttributes.cs | 166 ++ .../Attributes/DropDownAttributes.cs | 343 +++ .../Attributes/ImageAttributes.cs | 89 + .../Attributes/InputFieldAttributes.cs | 111 + .../Attributes/LoadingAttributes.cs | 112 + .../Attributes/PaginationAttributes.cs | 125 + .../Attributes/PopupAttributes.cs | 139 + .../Attributes/ProgressAttributes.cs | 131 + .../Attributes/ScrollbarAttributes.cs | 128 + .../Attributes/SelectButtonAttributes.cs | 112 + .../Attributes/SliderAttributes.cs | 239 ++ .../Attributes/SwitchAttributes.cs | 95 + .../Attributes/TabAttributes.cs | 149 + .../Attributes/TextAttributes.cs | 355 +++ .../Attributes/TextFieldAttributes.cs | 319 +++ .../Attributes/ToastAttributes.cs | 134 + .../Attributes/ViewAttributes.cs | 268 ++ src/Tizen.NUI.CommonUI/Controls/Button.cs | 1503 ++++++++++ src/Tizen.NUI.CommonUI/Controls/CheckBox.cs | 66 + .../Controls/CheckBoxGroup.cs | 165 ++ src/Tizen.NUI.CommonUI/Controls/Control.cs | 497 ++++ src/Tizen.NUI.CommonUI/Controls/DropDown.cs | 2066 ++++++++++++++ .../Controls/FlexibleView/FlexibleView.cs | 2526 +++++++++++++++++ .../FlexibleView/GridLayoutManager.cs | 217 ++ .../FlexibleView/LinearLayoutManager.cs | 1182 ++++++++ .../FlexibleView/OrientationHelper.cs | 342 +++ src/Tizen.NUI.CommonUI/Controls/InputField.cs | 703 +++++ src/Tizen.NUI.CommonUI/Controls/Loading.cs | 229 ++ src/Tizen.NUI.CommonUI/Controls/Pagination.cs | 407 +++ src/Tizen.NUI.CommonUI/Controls/Popup.cs | 1054 +++++++ src/Tizen.NUI.CommonUI/Controls/Progress.cs | 619 ++++ .../Controls/RadioButton.cs | 91 + .../Controls/RadioButtonGroup.cs | 113 + src/Tizen.NUI.CommonUI/Controls/Scrollbar.cs | 690 +++++ .../Controls/SelectButton.cs | 858 ++++++ .../Controls/SelectGroup.cs | 183 ++ src/Tizen.NUI.CommonUI/Controls/Slider.cs | 1685 +++++++++++ src/Tizen.NUI.CommonUI/Controls/Switch.cs | 433 +++ src/Tizen.NUI.CommonUI/Controls/Tab.cs | 879 ++++++ src/Tizen.NUI.CommonUI/Controls/Toast.cs | 584 ++++ src/Tizen.NUI.CommonUI/FriendAssembly.cs | 7 + .../Tizen.NUI.CommonUI.csproj | 25 + src/Tizen.NUI.CommonUI/Utils/Constants.cs | 94 + src/Tizen.NUI.CommonUI/Utils/Selector.cs | 500 ++++ src/Tizen.NUI.CommonUI/Utils/StyleBase.cs | 62 + src/Tizen.NUI.CommonUI/Utils/StyleManager.cs | 171 ++ src/Tizen.NUI.CommonUI/Utils/Utility.cs | 41 + 48 files changed, 21043 insertions(+) create mode 100755 src/Tizen.NUI.CommonUI/Attributes/Attributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/ButtonAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/DropDownAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/ImageAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/InputFieldAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/LoadingAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/PaginationAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/PopupAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/ProgressAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/ScrollbarAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/SelectButtonAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/SliderAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/SwitchAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/TabAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/TextAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/TextFieldAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/ToastAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Attributes/ViewAttributes.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/Button.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/CheckBox.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/CheckBoxGroup.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/Control.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/DropDown.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/FlexibleView/FlexibleView.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/FlexibleView/GridLayoutManager.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/FlexibleView/LinearLayoutManager.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/FlexibleView/OrientationHelper.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/InputField.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/Loading.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/Pagination.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/Popup.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/Progress.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/RadioButton.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/RadioButtonGroup.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/Scrollbar.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/SelectButton.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/SelectGroup.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/Slider.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/Switch.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/Tab.cs create mode 100755 src/Tizen.NUI.CommonUI/Controls/Toast.cs create mode 100755 src/Tizen.NUI.CommonUI/FriendAssembly.cs create mode 100755 src/Tizen.NUI.CommonUI/Tizen.NUI.CommonUI.csproj create mode 100755 src/Tizen.NUI.CommonUI/Utils/Constants.cs create mode 100755 src/Tizen.NUI.CommonUI/Utils/Selector.cs create mode 100755 src/Tizen.NUI.CommonUI/Utils/StyleBase.cs create mode 100755 src/Tizen.NUI.CommonUI/Utils/StyleManager.cs create mode 100755 src/Tizen.NUI.CommonUI/Utils/Utility.cs diff --git a/src/Tizen.NUI.CommonUI/Attributes/Attributes.cs b/src/Tizen.NUI.CommonUI/Attributes/Attributes.cs new file mode 100755 index 000000000..d19f0569e --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/Attributes.cs @@ -0,0 +1,36 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// Base attributes. + /// + /// 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 abstract class Attributes + { + /// + /// Clone the Attributes, each derived class need to override this method. + /// + /// Return the attributes clone. + /// 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 abstract Attributes Clone(); + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/ButtonAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/ButtonAttributes.cs new file mode 100755 index 000000000..17fa1e77e --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/ButtonAttributes.cs @@ -0,0 +1,166 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// ButtonAttributes is a class which saves Button's ux data. + /// + /// 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 class ButtonAttributes : ViewAttributes + { + /// + /// Creates a new instance of a ButtonAttributes. + /// + /// 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 ButtonAttributes() : base() { } + /// + /// Creates a new instance of a ButtonAttributes with attributes. + /// + /// Create ButtonAttributes by attributes customized by user. + /// 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 ButtonAttributes(ButtonAttributes attributes) : base(attributes) + { + if(attributes == null) + { + return; + } + + IsSelectable = attributes.IsSelectable; + IconRelativeOrientation = attributes.IconRelativeOrientation; + + if (attributes.ShadowImageAttributes != null) + { + ShadowImageAttributes = attributes.ShadowImageAttributes.Clone() as ImageAttributes; + } + + if (attributes.BackgroundImageAttributes != null) + { + BackgroundImageAttributes = attributes.BackgroundImageAttributes.Clone() as ImageAttributes; + } + + if (attributes.OverlayImageAttributes != null) + { + OverlayImageAttributes = attributes.OverlayImageAttributes.Clone() as ImageAttributes; + } + + if (attributes.TextAttributes != null) + { + TextAttributes = attributes.TextAttributes.Clone() as TextAttributes; + } + + if (attributes.IconAttributes != null) + { + IconAttributes = attributes.IconAttributes.Clone() as ImageAttributes; + } + } + /// + /// Shadow image's attributes. + /// + /// 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 ImageAttributes ShadowImageAttributes + { + get; + set; + } + /// + /// Background image's attributes. + /// + /// 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 ImageAttributes BackgroundImageAttributes + { + get; + set; + } + /// + /// Overlay image's attributes. + /// + /// 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 ImageAttributes OverlayImageAttributes + { + get; + set; + } + /// + /// Text's attributes. + /// + /// 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 TextAttributes TextAttributes + { + get; + set; + } + /// + /// Icon's attributes. + /// + /// 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 ImageAttributes IconAttributes + { + get; + set; + } + /// + /// Flag to decide button can be selected or not. + /// + /// 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 bool? IsSelectable + { + get; + set; + } + /// + /// Icon relative orientation. + /// + /// 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 Button.IconOrientation? IconRelativeOrientation + { + get; + set; + } + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new ButtonAttributes(this); + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/DropDownAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/DropDownAttributes.cs new file mode 100755 index 000000000..b0f20dcbd --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/DropDownAttributes.cs @@ -0,0 +1,343 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// DropDownAttributes is a class which saves DropDown's ux data. + /// + /// 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 class DropDownAttributes : ViewAttributes + { + /// + /// Creates a new instance of a DropDownAttributes. + /// + /// 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 DropDownAttributes() : base() + { + SpaceBetweenButtonTextAndIcon = 0; + Space = new Vector4(0, 0, 0, 0); + ListRelativeOrientation = DropDown.ListOrientation.Left; + ListMargin = new Vector4(0, 0, 0, 0); + FocusedItemIndex = 0; + } + /// + /// Creates a new instance of a DropDownAttributes with attributes. + /// + /// Create DropDownAttributes by attributes customized by user. + /// 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 DropDownAttributes(DropDownAttributes attributes) : base(attributes) + { + if(attributes == null) + { + return; + } + + if (attributes.ButtonAttributes != null) + { + ButtonAttributes = attributes.ButtonAttributes.Clone() as ButtonAttributes; + } + + if (attributes.HeaderTextAttributes != null) + { + HeaderTextAttributes = attributes.HeaderTextAttributes.Clone() as TextAttributes; + } + + if (attributes.ListBackgroundImageAttributes != null) + { + ListBackgroundImageAttributes = attributes.ListBackgroundImageAttributes.Clone() as ImageAttributes; + } + + if (attributes.Space != null) + { + Space = new Vector4(attributes.Space.X, attributes.Space.Y, attributes.Space.Z, attributes.Space.W); + } + + if (attributes.ListMargin != null) + { + ListMargin = new Vector4(attributes.ListMargin.X, attributes.ListMargin.Y, attributes.ListMargin.Z, attributes.ListMargin.W); + } + + if (attributes.ListSize2D != null) + { + ListSize2D = new Size2D(attributes.ListSize2D.Width, attributes.ListSize2D.Height); + } + + if (attributes.ListPadding != null) + { + ListPadding = attributes.ListPadding; + } + + SpaceBetweenButtonTextAndIcon = attributes.SpaceBetweenButtonTextAndIcon; + ListRelativeOrientation = attributes.ListRelativeOrientation; + FocusedItemIndex = attributes.FocusedItemIndex; + } + + /// + /// DropDown button's attributes. + /// + /// 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 ButtonAttributes ButtonAttributes + { + get; + set; + } + + /// + /// Header text's attributes. + /// + /// 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 TextAttributes HeaderTextAttributes + { + get; + set; + } + + /// + /// Space between button text and button icon. + /// + /// 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 int SpaceBetweenButtonTextAndIcon + { + get; + set; + } + + /// + /// List background image's attributes. + /// + /// 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 ImageAttributes ListBackgroundImageAttributes + { + get; + set; + } + + /// + /// Space in DropDown. + /// + /// 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 Vector4 Space + { + get; + set; + } + + /// + /// List relative orientation. + /// + /// 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 DropDown.ListOrientation ListRelativeOrientation + { + get; + set; + } + + /// + /// List margin. + /// + /// 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 Vector4 ListMargin + { + get; + set; + } + + /// + /// Focused item index. + /// + /// 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 int FocusedItemIndex + { + get; + set; + } + + /// + /// List 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 Size2D ListSize2D + { + get; + set; + } + + /// + /// List padding. + /// + /// 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 Extents ListPadding + { + get; + set; + } + + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new DropDownAttributes(this); + } + } + + /// + /// DropDownItemAttributes is a class which saves DropDownItem's ux data. + /// + /// 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 class DropDownItemAttributes : ViewAttributes + { + /// + /// Creates a new instance of a DropDownItemAttributes. + /// + /// 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 DropDownItemAttributes() : base() { } + /// + /// Creates a new instance of a DropDownItemAttributes with attributes. + /// + /// Create DropDownItemAttributes by attributes customized by user. + /// 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 DropDownItemAttributes(DropDownItemAttributes attributes) : base(attributes) + { + if (attributes.TextAttributes != null) + { + TextAttributes = attributes.TextAttributes.Clone() as TextAttributes; + } + + if (attributes.IconAttributes != null) + { + IconAttributes = attributes.IconAttributes.Clone() as ImageAttributes; + } + + if (attributes.CheckImageAttributes != null) + { + CheckImageAttributes = attributes.CheckImageAttributes.Clone() as ImageAttributes; + } + + CheckImageRightSpace = attributes.CheckImageRightSpace; + IsSelected = attributes.IsSelected; + } + + /// + /// Text's attributes. + /// + /// 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 TextAttributes TextAttributes + { + get; + set; + } + + /// + /// Icon's attributes. + /// + /// 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 ImageAttributes IconAttributes + { + get; + set; + } + + /// + /// Check image's attributes. + /// + /// 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 ImageAttributes CheckImageAttributes + { + get; + set; + } + + /// + /// Right space from check image. + /// + /// 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 int CheckImageRightSpace + { + get; + set; + } + + /// + /// Flag to decide item is selected or not. + /// + /// 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 bool IsSelected + { + get; + set; + } + + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new DropDownItemAttributes(this); + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/ImageAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/ImageAttributes.cs new file mode 100755 index 000000000..43048ea1b --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/ImageAttributes.cs @@ -0,0 +1,89 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// The image view attributes class. + /// + /// 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 class ImageAttributes : ViewAttributes + { + /// + /// Construct ImageAttributes. + /// + /// 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 ImageAttributes() : base() { } + /// + /// Construct with specified attribute. + /// + /// The specified ImageAttributes. + /// 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 ImageAttributes(ImageAttributes attributes) : base(attributes) + { + if (attributes == null) + { + return; + } + + if (attributes.ResourceUrl != null) + { + ResourceUrl = attributes.ResourceUrl.Clone() as StringSelector; + } + + if (attributes.Border != null) + { + Border = attributes.Border.Clone() as RectangleSelector; + } + } + /// + /// Image URL. + /// + /// 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 StringSelector ResourceUrl + { + get; + set; + } + /// + /// Image border. + /// + /// 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 RectangleSelector Border + { + get; + set; + } + /// + /// Attributes's clone function. + /// + /// Return the attributes clone. + /// 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 Attributes Clone() + { + return new ImageAttributes(this); + } + + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/InputFieldAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/InputFieldAttributes.cs new file mode 100755 index 000000000..6e8e2e0ef --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/InputFieldAttributes.cs @@ -0,0 +1,111 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// InputFieldAttributes is a class which saves InputField's ux data. + /// + /// 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 class InputFieldAttributes : ViewAttributes + { + /// + /// Creates a new instance of a InputFieldAttributes. + /// + /// 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 InputFieldAttributes() : base() { } + + /// + /// Creates a new instance of a InputFieldAttributes with attributes. + /// + /// Create InputFieldAttributes by attributes customized by user. + /// 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 InputFieldAttributes(InputFieldAttributes attrs) : base(attrs) + { + if (null == attrs) + { + return; + } + if (null != attrs.BackgroundImageAttributes) + { + BackgroundImageAttributes = attrs.BackgroundImageAttributes.Clone() as ImageAttributes; + } + if (null != attrs.InputBoxAttributes) + { + InputBoxAttributes = attrs.InputBoxAttributes.Clone() as TextFieldAttributes; + } + if (null != attrs.Space) + { + Space = attrs.Space; + } + } + + /// + /// Gets or sets background image attributes of input field. + /// + /// 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 ImageAttributes BackgroundImageAttributes + { + get; + set; + } + + /// + /// Gets or sets input box attributes of input field. + /// + /// 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 TextFieldAttributes InputBoxAttributes + { + get; + set; + } + + /// + /// Gets or sets space. + /// + /// 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 int? Space + { + get; + set; + } + + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new InputFieldAttributes(this); + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/LoadingAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/LoadingAttributes.cs new file mode 100755 index 000000000..31998e25c --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/LoadingAttributes.cs @@ -0,0 +1,112 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// LoadingAttributes is a class which saves Loading's ux data. + /// + /// 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 class LoadingAttributes : ViewAttributes + { + /// + /// Creates a new instance of a LoadingAttributes. + /// + /// 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 LoadingAttributes() : base() { } + + /// + /// Creates a new instance of a LoadingAttributes with attributes. + /// + /// Create LoadingAttributes by attributes customized by user. + /// 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 LoadingAttributes(LoadingAttributes attributes) : base(attributes) + { + if(null == attributes) + { + return; + } + + if (null != attributes.FPS) + { + FPS = attributes.FPS.Clone() as IntSelector; + } + if (null != attributes.LoadingSize) + { + LoadingSize = attributes.LoadingSize; + } + if (null != attributes.ImageArray) + { + ImageArray = attributes.ImageArray; + } + } + + /// + /// Gets or sets loading image resource array. + /// + /// 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 string[] ImageArray + { + get; + set; + } + + /// + /// Gets or sets loading image 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 Size2D LoadingSize + { + get; + set; + } + + /// + /// Gets or sets loading frame per second. + /// + /// 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 IntSelector FPS + { + get; + set; + } + + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new LoadingAttributes(this); + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/PaginationAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/PaginationAttributes.cs new file mode 100755 index 000000000..b329e03c5 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/PaginationAttributes.cs @@ -0,0 +1,125 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// PaginationAttributes used to config the pagination represent. + /// + /// 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 class PaginationAttributes : ViewAttributes + { + /// + /// Creates a new instance of a PaginationAttributes. + /// + /// 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 PaginationAttributes() : base() { } + /// + /// Creates a new instance of a PaginationAttributes using attributes. + /// + /// 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 PaginationAttributes(PaginationAttributes attributes) : base(attributes) + { + if (attributes == null) + { + return; + } + + if (attributes.IndicatorSize != null) + { + IndicatorSize = new Size2D(attributes.IndicatorSize.Width, attributes.IndicatorSize.Height); + } + if (attributes.IndicatorBackgroundURL != null) + { + IndicatorBackgroundURL = attributes.IndicatorBackgroundURL.Clone() as string; + } + if (attributes.IndicatorSelectURL != null) + { + IndicatorSelectURL = attributes.IndicatorSelectURL.Clone() as string; + } + IndicatorSpacing = attributes.IndicatorSpacing; + } + + /// + /// Gets or sets the size of the indicator. + /// + /// 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 Size2D IndicatorSize + { + get; + set; + } + + /// + /// Gets or sets the background resource of indicator. + /// + /// 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 string IndicatorBackgroundURL + { + get; + set; + } + + /// + /// Gets or sets the resource of the select indicator. + /// + /// 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 string IndicatorSelectURL + { + get; + set; + } + + /// + /// Gets or sets the space of the indicator. + /// + /// 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 int IndicatorSpacing + { + get; + set; + } + + + /// + /// Retrieves a copy of PaginationAttributes. + /// + /// 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 Attributes Clone() + { + return new PaginationAttributes(this); + } + + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/PopupAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/PopupAttributes.cs new file mode 100755 index 000000000..10f6e84ed --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/PopupAttributes.cs @@ -0,0 +1,139 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// PopupAttributes is a class which saves Popup's ux data. + /// + /// 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 class PopupAttributes : ViewAttributes + { + /// + /// Creates a new instance of a PopupAttributes. + /// + /// 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 PopupAttributes() : base() { } + /// + /// Creates a new instance of a PopupAttributes with attributes. + /// + /// Create PopupAttributes by attributes customized by user. + /// 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 PopupAttributes(PopupAttributes attributes) : base(attributes) + { + if (attributes.ShadowImageAttributes != null) + { + ShadowImageAttributes = attributes.ShadowImageAttributes.Clone() as ImageAttributes; + } + + if (attributes.BackgroundImageAttributes != null) + { + BackgroundImageAttributes = attributes.BackgroundImageAttributes.Clone() as ImageAttributes; + } + + if (attributes.TitleTextAttributes != null) + { + TitleTextAttributes = attributes.TitleTextAttributes.Clone() as TextAttributes; + } + + if (attributes.ButtonAttributes != null) + { + ButtonAttributes = attributes.ButtonAttributes.Clone() as ButtonAttributes; + } + + ShadowOffset = new Vector4(attributes.ShadowOffset.W, attributes.ShadowOffset.X, attributes.ShadowOffset.Y, attributes.ShadowOffset.Z); + } + + /// + /// Shadow image's attributes. + /// + /// 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 ImageAttributes ShadowImageAttributes + { + get; + set; + } + + /// + /// Background image's attributes. + /// + /// 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 ImageAttributes BackgroundImageAttributes + { + get; + set; + } + + /// + /// Title Text's attributes. + /// + /// 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 TextAttributes TitleTextAttributes + { + get; + set; + } + + /// + /// Shadow offset. + /// + /// 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 Vector4 ShadowOffset + { + get; + set; + } + + /// + /// Popup button's attributes. + /// + /// 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 ButtonAttributes ButtonAttributes + { + get; + set; + } + + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new PopupAttributes(this); + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/ProgressAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/ProgressAttributes.cs new file mode 100755 index 000000000..908e743e4 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/ProgressAttributes.cs @@ -0,0 +1,131 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// ProgressAttributes is a class which saves Progress's ux data. + /// + /// 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 class ProgressAttributes : ViewAttributes + { + /// + /// Creates a new instance of a ProgressAttributes. + /// + /// 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 ProgressAttributes() : base() { } + + /// + /// Creates a new instance of a ProgressAttributes with attributes. + /// + /// Create ProgressAttributes by attributes customized by user. + /// 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 ProgressAttributes(ProgressAttributes attributes) : base(attributes) + { + if (null == attributes) + { + return; + } + + if (null != attributes.TrackImageAttributes) + { + TrackImageAttributes = attributes.TrackImageAttributes.Clone() as ImageAttributes; + } + + if (null != attributes.ProgressImageAttributes) + { + ProgressImageAttributes = attributes.ProgressImageAttributes.Clone() as ImageAttributes; + } + + if (null != attributes.BufferImageAttributes) + { + BufferImageAttributes = attributes.BufferImageAttributes.Clone() as ImageAttributes; + } + + if (null != attributes.LoadingImageAttributes) + { + LoadingImageAttributes = attributes.LoadingImageAttributes.Clone() as ImageAttributes; + } + } + + /// + /// Get or set Track Image Attributes. + /// + /// 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 ImageAttributes TrackImageAttributes + { + get; + set; + } + + /// + /// Get or set Progress Image Attributes. + /// + /// 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 ImageAttributes ProgressImageAttributes + { + get; + set; + } + + /// + /// Get or set Buffer Image Attributes. + /// + /// 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 ImageAttributes BufferImageAttributes + { + get; + set; + } + + /// + /// Get or set LoadingImageAttributes. + /// + /// 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 ImageAttributes LoadingImageAttributes + { + get; + set; + } + + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new ProgressAttributes(this); + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/ScrollbarAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/ScrollbarAttributes.cs new file mode 100755 index 000000000..2094c5e59 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/ScrollbarAttributes.cs @@ -0,0 +1,128 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// ScrollBarAttributes is a class which saves Scrollbar's ux data. + /// + /// 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 class ScrollBarAttributes : ViewAttributes + { + /// + /// Creates a new instance of a ScrollBarAttributes. + /// + /// 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 ScrollBarAttributes() : base() + { + Direction = ScrollBar.DirectionType.Horizontal; + } + + /// + /// Creates a new instance of a ScrollBarAttributes with attributes. + /// + /// Create ScrollBarAttributes by attributes customized by user. + /// 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 ScrollBarAttributes(ScrollBarAttributes attributes) : base(attributes) + { + if(attributes == null) + { + return; + } + + if (attributes.TrackImageAttributes != null) + { + TrackImageAttributes = attributes.TrackImageAttributes.Clone() as ImageAttributes; + } + + if (attributes.ThumbImageAttributes != null) + { + ThumbImageAttributes = attributes.ThumbImageAttributes.Clone() as ImageAttributes; + } + + Direction = attributes.Direction; + Duration = attributes.Duration; + } + + /// + /// Get or set track image attributes + /// + /// 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 ImageAttributes TrackImageAttributes + { + get; + set; + } + + /// + /// Get or set thumb image attributes + /// + /// 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 ImageAttributes ThumbImageAttributes + { + get; + set; + } + + /// + /// Get or set direction type + /// + /// 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 ScrollBar.DirectionType? Direction + { + get; + set; + } + + /// + /// Get or set duration + /// + /// 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 uint Duration + { + get; + set; + } + + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new ScrollBarAttributes(this); + } + + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/SelectButtonAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/SelectButtonAttributes.cs new file mode 100755 index 000000000..432489fdd --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/SelectButtonAttributes.cs @@ -0,0 +1,112 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// SelectButtonAttributes is a class which saves SelectButton's ux data. + /// + /// 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 class SelectButtonAttributes : ButtonAttributes + { + /// + /// Creates a new instance of a SelectButtonAttributes. + /// + /// 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 SelectButtonAttributes() : base() { } + /// + /// Creates a new instance of a SelectButtonAttributes with attributes. + /// + /// Create SelectButtonAttributes by attributes customized by user. + /// 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 SelectButtonAttributes(SelectButtonAttributes attributes) : base(attributes) + { + if(attributes == null) + { + return; + } + if (attributes.CheckImageAttributes != null) + { + CheckImageAttributes = attributes.CheckImageAttributes.Clone() as ImageAttributes; + } + + if (attributes.CheckBackgroundImageAttributes != null) + { + CheckBackgroundImageAttributes = attributes.CheckBackgroundImageAttributes.Clone() as ImageAttributes; + } + + if (attributes.CheckShadowImageAttributes != null) + { + CheckShadowImageAttributes = attributes.CheckShadowImageAttributes.Clone() as ImageAttributes; + } + } + + /// + /// Check image's attributes. + /// + /// 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 ImageAttributes CheckImageAttributes + { + get; + set; + } + + /// + /// Background image's attributes. + /// + /// 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 ImageAttributes CheckBackgroundImageAttributes + { + get; + set; + } + + /// + /// Shadow image's attributes. + /// + /// 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 ImageAttributes CheckShadowImageAttributes + { + get; + set; + } + + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new SelectButtonAttributes(this); + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/SliderAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/SliderAttributes.cs new file mode 100755 index 000000000..e282968fa --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/SliderAttributes.cs @@ -0,0 +1,239 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// SliderAttributes is a class which saves Slider's ux data. + /// + /// 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 class SliderAttributes : ViewAttributes + { + /// + /// Creates a new instance of a SliderAttributes. + /// + /// 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 SliderAttributes() : base() + { + IndicatorType = Slider.IndicatorType.None; + } + + /// + /// Creates a new instance of a SliderAttributes with attributes. + /// + /// Create SliderAttributes by attributes customized by user. + /// 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 SliderAttributes(SliderAttributes attributes) : base(attributes) + { + if(attributes == null) + { + return; + } + if (attributes.BackgroundTrackAttributes != null) + { + BackgroundTrackAttributes = attributes.BackgroundTrackAttributes.Clone() as ImageAttributes; + } + if (attributes.SlidedTrackAttributes != null) + { + SlidedTrackAttributes = attributes.SlidedTrackAttributes.Clone() as ImageAttributes; + } + if (attributes.ThumbBackgroundAttributes != null) + { + ThumbBackgroundAttributes = attributes.ThumbBackgroundAttributes.Clone() as ImageAttributes; + } + if (attributes.ThumbAttributes != null) + { + ThumbAttributes = attributes.ThumbAttributes.Clone() as ImageAttributes; + } + if (attributes.LowIndicatorImageAttributes != null) + { + LowIndicatorImageAttributes = attributes.LowIndicatorImageAttributes.Clone() as ImageAttributes; + } + if (attributes.HighIndicatorImageAttributes != null) + { + HighIndicatorImageAttributes = attributes.HighIndicatorImageAttributes.Clone() as ImageAttributes; + } + if (attributes.LowIndicatorTextAttributes != null) + { + LowIndicatorTextAttributes = attributes.LowIndicatorTextAttributes.Clone() as TextAttributes; + } + if (attributes.HighIndicatorTextAttributes != null) + { + HighIndicatorTextAttributes = attributes.HighIndicatorTextAttributes.Clone() as TextAttributes; + } + if (attributes.TrackThickness != null) + { + TrackThickness = attributes.TrackThickness; + } + if (attributes.SpaceBetweenTrackAndIndicator != null) + { + SpaceBetweenTrackAndIndicator = attributes.SpaceBetweenTrackAndIndicator; + } + IndicatorType = attributes.IndicatorType; + } + + /// + /// Get or set background track attributes + /// + /// 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 ImageAttributes BackgroundTrackAttributes + { + get; + set; + } + + /// + /// Get or set slided track attributes + /// + /// 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 ImageAttributes SlidedTrackAttributes + { + get; + set; + } + + /// + /// Get or set thumb attributes + /// + /// 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 ImageAttributes ThumbAttributes + { + get; + set; + } + + /// + /// Get or set thumb background attributes + /// + /// 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 ImageAttributes ThumbBackgroundAttributes + { + get; + set; + } + + /// + /// Get or set low indicator image attributes + /// + /// 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 ImageAttributes LowIndicatorImageAttributes + { + get; + set; + } + + /// + /// Get or set high indicator image attributes + /// + /// 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 ImageAttributes HighIndicatorImageAttributes + { + get; + set; + } + + /// + /// Get or low indicator text attributes + /// + /// 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 TextAttributes LowIndicatorTextAttributes + { + get; + set; + } + + /// + /// Get or set high indicator text attributes + /// + /// 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 TextAttributes HighIndicatorTextAttributes + { + get; + set; + } + + /// + /// Get or set track thickness + /// + /// 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 uint? TrackThickness + { + get; + set; + } + + /// + /// Get or set space between track and indicator + /// + /// 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 uint? SpaceBetweenTrackAndIndicator + { + get; + set; + } + + /// + /// Get or set Indicator type + /// + /// 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 Slider.IndicatorType IndicatorType + { + get; + set; + } + + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new SliderAttributes(this); + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/SwitchAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/SwitchAttributes.cs new file mode 100755 index 000000000..2090f25f8 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/SwitchAttributes.cs @@ -0,0 +1,95 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// SwitchAttributes is a class which saves Switch's ux data. + /// + /// 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 class SwitchAttributes : ButtonAttributes + { + /// + /// Creates a new instance of a SwitchAttributes. + /// + /// 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 SwitchAttributes() : base() { } + /// + /// Creates a new instance of a SwitchAttributes with attributes. + /// + /// Create SwitchAttributes by attributes customized by user. + /// 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 SwitchAttributes(SwitchAttributes attributes) : base(attributes) + { + if(attributes == null) + { + return; + } + if (attributes.SwitchHandlerImageAttributes != null) + { + SwitchHandlerImageAttributes = attributes.SwitchHandlerImageAttributes.Clone() as ImageAttributes; + } + + if (attributes.SwitchBackgroundImageAttributes != null) + { + SwitchBackgroundImageAttributes = attributes.SwitchBackgroundImageAttributes.Clone() as ImageAttributes; + } + } + + /// + /// Handler image's attributes. + /// + /// 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 ImageAttributes SwitchHandlerImageAttributes + { + get; + set; + } + + /// + /// Background image's attributes. + /// + /// 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 ImageAttributes SwitchBackgroundImageAttributes + { + get; + set; + } + + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new SwitchAttributes(this); + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/TabAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/TabAttributes.cs new file mode 100755 index 000000000..57f3b82d6 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/TabAttributes.cs @@ -0,0 +1,149 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// TabAttributes is a class which saves Tab's ux data. + /// + /// 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 class TabAttributes : ViewAttributes + { + /// + /// Creates a new instance of a TabAttributes. + /// + /// 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 TabAttributes() : base() + { + Space = new Vector4(0, 0, 0, 0); + IsNatureTextWidth = false; + ItemGap = 0; + } + + /// + /// Creates a new instance of a TabAttributes with attributes. + /// + /// Create TabAttributes by attributes customized by user. + /// 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 TabAttributes(TabAttributes attributes) : base(attributes) + { + if (null == attributes) + { + return; + } + + if (attributes.UnderLineAttributes != null) + { + UnderLineAttributes = attributes.UnderLineAttributes.Clone() as ViewAttributes; + } + + if (attributes.TextAttributes != null) + { + TextAttributes = attributes.TextAttributes.Clone() as TextAttributes; + } + + if (attributes.Space != null) + { + Space = new Vector4(attributes.Space.X, attributes.Space.Y, attributes.Space.Z, attributes.Space.W); + } + else + { + Space = new Vector4(0, 0, 0, 0); + } + ItemGap = attributes.ItemGap; + IsNatureTextWidth = attributes.IsNatureTextWidth; + } + + /// + /// UnderLine's attributes. + /// + /// 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 ViewAttributes UnderLineAttributes + { + get; + set; + } + + /// + /// Text's attributes. + /// + /// 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 TextAttributes TextAttributes + { + get; + set; + } + + /// + /// Flag to decide if item is fill with item text's natural width. + /// + /// 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 bool IsNatureTextWidth + { + get; + set; + } + + /// + /// Gap between items. + /// + /// 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 int ItemGap + { + get; + set; + } + + /// + /// Space in Tab. + /// + /// 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 Vector4 Space + { + get; + set; + } + + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new TabAttributes(this); + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/TextAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/TextAttributes.cs new file mode 100755 index 000000000..bf083fabd --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/TextAttributes.cs @@ -0,0 +1,355 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// The Text Attributes class. + /// + /// 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 class TextAttributes : ViewAttributes + { + /// + /// Construct TextAttributes. + /// + /// 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 TextAttributes() : base() { } + /// + /// Construct with specified attribute. + /// + /// The specified TextAttributes. + /// 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 TextAttributes(TextAttributes attributes) : base(attributes) + { + if(attributes == null) + { + return; + } + if (attributes.Text != null) + { + Text = attributes.Text.Clone() as StringSelector; + } + + if (attributes.TranslatableText != null) + { + TranslatableText = attributes.TranslatableText.Clone() as StringSelector; + } + + if (attributes.MultiLine != null) + { + MultiLine = attributes.MultiLine; + } + + if (attributes.HorizontalAlignment != null) + { + HorizontalAlignment = attributes.HorizontalAlignment; + } + + if (attributes.VerticalAlignment != null) + { + VerticalAlignment = attributes.VerticalAlignment; + } + + if (attributes.EnableMarkup != null) + { + EnableMarkup = attributes.EnableMarkup; + } + + if (attributes.EnableAutoScroll != null) + { + EnableAutoScroll = attributes.EnableAutoScroll; + } + + if (attributes.AutoScrollSpeed != null) + { + AutoScrollSpeed = attributes.AutoScrollSpeed; + } + + if (attributes.AutoScrollLoopCount != null) + { + AutoScrollLoopCount = attributes.AutoScrollLoopCount; + } + + if (attributes.AutoScrollGap != null) + { + AutoScrollGap = attributes.AutoScrollGap; + } + + if (attributes.AutoScrollLoopDelay != null) + { + AutoScrollLoopDelay = attributes.AutoScrollLoopDelay; + } + + if (attributes.AutoScrollStopMode != null) + { + AutoScrollStopMode = attributes.AutoScrollStopMode; + } + + if (attributes.LineSpacing != null) + { + LineSpacing = attributes.LineSpacing; + } + + if (attributes.TextColor != null) + { + TextColor = attributes.TextColor.Clone() as ColorSelector; + } + + if (attributes.FontFamily != null) + { + FontFamily = attributes.FontFamily; + } + + if (attributes.PointSize != null) + { + PointSize = attributes.PointSize.Clone() as FloatSelector; + } + + if (attributes.ShadowOffset != null) + { + ShadowOffset = attributes.ShadowOffset.Clone() as Vector2Selector; + } + + if (attributes.ShadowColor != null) + { + ShadowColor = attributes.ShadowColor.Clone() as ColorSelector; + } + + if (attributes.OutstrokeColor != null) + { + OutstrokeColor = attributes.OutstrokeColor.Clone() as ColorSelector; + } + if (attributes.OutstrokeThickness != null) + { + OutstrokeThickness = attributes.OutstrokeThickness.Clone() as IntSelector; + } + } + /// + /// TextLabel Text + /// + /// 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 StringSelector Text + { + get; + set; + } + /// + /// The TranslatableText property + /// + /// 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 StringSelector TranslatableText + { + get; + set; + } + /// + /// TextLabel MultiLine + /// + /// 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 bool? MultiLine + { + get; + set; + } + /// + /// TextLabel HorizontalAlignment + /// + /// 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 HorizontalAlignment? HorizontalAlignment + { + get; + set; + } + /// + /// TextLabel VerticalAlignment + /// + /// 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 VerticalAlignment? VerticalAlignment + { + get; + set; + } + /// + /// TextLabel EnableMarkup + /// + /// 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 bool? EnableMarkup + { + get; + set; + } + /// + /// TextLabel EnableAutoScroll + /// + /// 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 bool? EnableAutoScroll + { + get; + set; + } + /// + /// TextLabel AutoScrollSpeed + /// + /// 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 int? AutoScrollSpeed + { + get; + set; + } + /// + /// TextLabel AutoScrollLoopCount + /// + /// 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 int? AutoScrollLoopCount +{ + get; + set; + } + /// + /// TextLabel AutoScrollGap + /// + /// 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 float? AutoScrollGap + { + get; + set; + } + /// + /// TextLabel AutoScrollLoopDelay + /// + /// 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 float? AutoScrollLoopDelay + { + get; + set; + } + /// + /// TextLabel AutoScrollStopMode + /// + /// 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 AutoScrollStopMode? AutoScrollStopMode + { + get; + set; + } + /// + /// TextLabel LineSpacing + /// + /// 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 float? LineSpacing + { + get; + set; + } + /// + /// TextLabel TextColor + /// + /// 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 ColorSelector TextColor + { + get; + set; + } + /// + /// TextLabel FontFamily + /// + /// 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 string FontFamily + { + get; + set; + } + /// + /// TextLabel PointSize + /// + /// 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 FloatSelector PointSize + { + get; + set; + } + /// + /// TextLabel ShadowOffset + /// + /// 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 Vector2Selector ShadowOffset + { + get; + set; + } + /// + /// TextLabel ShadowColor + /// + /// 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 ColorSelector ShadowColor + { + get; + set; + } + /// + /// TextLabel OutstrokeColor + /// + /// 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 ColorSelector OutstrokeColor + { + get; + set; + } + /// + /// TextLabel OutstrokeThickness + /// + /// 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 IntSelector OutstrokeThickness + { + get; + set; + } + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new TextAttributes(this); + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/TextFieldAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/TextFieldAttributes.cs new file mode 100755 index 000000000..6e775b619 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/TextFieldAttributes.cs @@ -0,0 +1,319 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// TextFieldAttributes is a class which saves TextField's ux data. + /// + /// 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 class TextFieldAttributes : ViewAttributes + { + /// + /// Creates a new instance of a TextField. + /// + /// 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 TextFieldAttributes() : base() { } + + /// + /// Creates a new instance of a TextField with style. + /// + /// Create TextField by special style defined in UX. + /// 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 TextFieldAttributes(TextFieldAttributes attributes) : base(attributes) + { + if(null == attributes) + { + return; + } + if (null != attributes.Text) + { + Text = attributes.Text.Clone() as StringSelector; + } + if (null != attributes.PlaceholderText) + { + PlaceholderText = attributes.PlaceholderText.Clone() as StringSelector; + } + if (null != attributes.TranslatablePlaceholderText) + { + TranslatablePlaceholderText = attributes.TranslatablePlaceholderText.Clone() as StringSelector; + } + if (null != attributes.HorizontalAlignment) + { + HorizontalAlignment = attributes.HorizontalAlignment; + } + if (null != attributes.VerticalAlignment) + { + VerticalAlignment = attributes.VerticalAlignment; + } + if (null != attributes.EnableMarkup) + { + EnableMarkup = attributes.EnableMarkup; + } + if (null != attributes.TextColor) + { + TextColor = attributes.TextColor.Clone() as ColorSelector; + } + if (null != attributes.PlaceholderTextColor) + { + PlaceholderTextColor = attributes.PlaceholderTextColor.Clone() as ColorSelector; + } + if (null != attributes.PrimaryCursorColor) + { + PrimaryCursorColor = attributes.PrimaryCursorColor.Clone() as ColorSelector; + } + if (null != attributes.SecondaryCursorColor) + { + SecondaryCursorColor = attributes.SecondaryCursorColor.Clone() as ColorSelector; + } + if (null != attributes.FontFamily) + { + FontFamily = attributes.FontFamily; + } + if (null != attributes.PointSize) + { + PointSize = attributes.PointSize.Clone() as FloatSelector; + } + if (null != attributes.EnableCursorBlink) + { + EnableCursorBlink = attributes.EnableCursorBlink; + } + if (null != attributes.EnableSelection) + { + EnableSelection = attributes.EnableSelection; + } + if (null != attributes.CursorWidth) + { + CursorWidth = attributes.CursorWidth; + } + if (null != attributes.EnableEllipsis) + { + EnableEllipsis = attributes.EnableEllipsis; + } + } + + /// + /// Gets or sets text. + /// + /// 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 StringSelector Text + { + get; + set; + } + + /// + /// Gets or sets place holder text. + /// + /// 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 StringSelector PlaceholderText + { + get; + set; + } + + /// + /// Gets or sets translatable place holder text. + /// + /// 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 StringSelector TranslatablePlaceholderText + { + get; + set; + } + + /// + /// Gets or sets horizontal alignment of text. + /// + /// 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 HorizontalAlignment? HorizontalAlignment + { + get; + set; + } + + /// + /// Gets or sets vertical alignment of text. + /// + /// 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 VerticalAlignment? VerticalAlignment + { + get; + set; + } + + /// + /// Gets or sets enable mark up. + /// + /// 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 bool? EnableMarkup + { + get; + set; + } + + /// + /// Gets or sets text color. + /// + /// 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 ColorSelector TextColor + { + get; + set; + } + + /// + /// Gets or sets place holder text color. + /// + /// 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 ColorSelector PlaceholderTextColor + { + get; + set; + } + + /// + /// Gets or sets primary cursor color. + /// + /// 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 ColorSelector PrimaryCursorColor + { + get; + set; + } + + /// + /// Gets or sets secondary cursor color. + /// + /// 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 ColorSelector SecondaryCursorColor + { + get; + set; + } + + /// + /// Gets or sets font family of text. + /// + /// 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 string FontFamily + { + get; + set; + } + + /// + /// Gets or sets point size of text. + /// + /// 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 FloatSelector PointSize + { + get; + set; + } + + /// + /// Gets or sets enable cursor blink. + /// + /// 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 bool? EnableCursorBlink + { + get; + set; + } + + /// + /// Gets or sets enable selection. + /// + /// 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 bool? EnableSelection + { + get; + set; + } + + /// + /// Gets or sets cursor width. + /// + /// 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 int? CursorWidth + { + get; + set; + } + + /// + /// Gets or sets if enable ellipsis. + /// + /// 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 bool? EnableEllipsis + { + get; + set; + } + + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new TextFieldAttributes(this); + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/ToastAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/ToastAttributes.cs new file mode 100755 index 000000000..a9880f199 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/ToastAttributes.cs @@ -0,0 +1,134 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// ToastAttributes is a class which saves Toast's ux data. + /// + /// 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 class ToastAttributes : ViewAttributes + { + /// + /// Creates a new instance of a ToastAttributes. + /// + /// 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 ToastAttributes() : base() { } + + /// + /// Creates a new instance of a ToastAttributes with attributes. + /// + /// Create ToastAttributes by attributes customized by user. + /// 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 ToastAttributes(ToastAttributes attributes) : base(attributes) + { + if(null == attributes) + { + return; + } + if(null != attributes.BackgroundImageAttributes) + { + BackgroundImageAttributes = attributes.BackgroundImageAttributes.Clone() as ImageAttributes; + } + if(null != attributes.TextAttributes) + { + TextAttributes = attributes.TextAttributes.Clone() as TextAttributes; + } + TextLineHeight = attributes.TextLineHeight; + TextLineSpace = attributes.TextLineSpace; + Duration = attributes.Duration; + } + + /// + /// Gets or sets background image attributes. + /// + /// 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 ImageAttributes BackgroundImageAttributes + { + get; + set; + } + + /// + /// Gets or sets text attributes. + /// + /// 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 TextAttributes TextAttributes + { + get; + set; + } + + /// + /// Gets or sets toast text line height. + /// + /// 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 uint? TextLineHeight + { + get; + set; + } + + /// + /// Gets or sets toast text line space. + /// + /// 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 uint? TextLineSpace + { + get; + set; + } + + /// + /// Gets or sets toast show duration time. + /// + /// 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 uint? Duration + { + get; + set; + } + + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new ToastAttributes(this); + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Attributes/ViewAttributes.cs b/src/Tizen.NUI.CommonUI/Attributes/ViewAttributes.cs new file mode 100755 index 000000000..c73e86bd0 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Attributes/ViewAttributes.cs @@ -0,0 +1,268 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// The base class for Children attributes in Components. + /// + /// 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 class ViewAttributes : Attributes + { + /// + /// Construct ViewAttributes. + /// + /// 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 ViewAttributes() : base() { } + /// + /// Constructs a ViewAttributes that is a copy of attrs. + /// + /// Construct Attributes + /// 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 ViewAttributes(ViewAttributes attributes) + { + if (attributes == null) + { + return; + } + + if (attributes.Position2D != null) + { + Position2D = new Position2D(attributes.Position2D.X, attributes.Position2D.Y); + } + + if (attributes.Size2D != null) + { + Size2D = new Size2D(attributes.Size2D.Width, attributes.Size2D.Height); + } + + if (attributes.BackgroundColor != null) + { + BackgroundColor = attributes.BackgroundColor.Clone() as ColorSelector; + } + + if (attributes.PositionUsesPivotPoint != null) + { + PositionUsesPivotPoint = attributes.PositionUsesPivotPoint; + } + + if (attributes.ParentOrigin != null) + { + ParentOrigin = new Position(attributes.ParentOrigin.X, attributes.ParentOrigin.Y, attributes.ParentOrigin.Z); + } + + if (attributes.PivotPoint != null) + { + PivotPoint = new Position(attributes.PivotPoint.X, attributes.PivotPoint.Y, attributes.PivotPoint.Z); + } + + if (attributes.WidthResizePolicy != null) + { + WidthResizePolicy = attributes.WidthResizePolicy; + } + + if (attributes.HeightResizePolicy != null) + { + HeightResizePolicy = attributes.HeightResizePolicy; + } + + if (attributes.MinimumSize != null) + { + MinimumSize = new Size2D(attributes.MinimumSize.Width, attributes.MinimumSize.Height); + } + + if (attributes.SizeModeFactor != null) + { + SizeModeFactor = new Vector3(attributes.SizeModeFactor.X, attributes.SizeModeFactor.Y, attributes.SizeModeFactor.Z); + } + + if (attributes.Opacity != null) + { + Opacity = attributes.Opacity.Clone() as FloatSelector; + } + + PaddingLeft = attributes.PaddingLeft; + PaddingRight = attributes.PaddingRight; + PaddingTop = attributes.PaddingTop; + PaddingBottom = attributes.PaddingBottom; + } + /// + /// View Position + /// + /// 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 Position2D Position2D + { + get; + set; + } + /// + /// View Size + /// + /// 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 Size2D Size2D + { + get; + set; + } + /// + /// View BackgroundColor + /// + /// 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 ColorSelector BackgroundColor + { + get; + set; + } + /// + /// View PositionUsesPivotPoint + /// + /// 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 bool? PositionUsesPivotPoint + { + get; + set; + } + /// + /// View ParentOrigin + /// + /// 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 Position ParentOrigin + { + get; + set; + } + /// + /// View PivotPoint + /// + /// 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 Position PivotPoint + { + get; + set; + } + /// + /// View WidthResizePolicy + /// + /// 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 ResizePolicyType? WidthResizePolicy + { + get; + set; + } + /// + /// View HeightResizePolicy + /// + /// 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 ResizePolicyType? HeightResizePolicy + { + get; + set; + } + /// + /// View MinimumSize + /// + /// 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 Size2D MinimumSize + { + get; + set; + } + /// + /// View SizeModeFactor + /// + /// 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 Vector3 SizeModeFactor + { + get; + set; + } + /// + /// View Opacity + /// + /// 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 FloatSelector Opacity + { + get; + set; + } + /// + /// View left padding + /// + /// 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 int PaddingLeft + { + get; + set; + } + /// + /// View right padding + /// + /// 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 int PaddingRight + { + get; + set; + } + /// + /// View top padding + /// + /// 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 int PaddingTop + { + get; + set; + } + /// + /// View bottom padding + /// + /// 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 int PaddingBottom + { + get; + set; + } + /// + /// Attributes's clone function. + /// + /// 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 Attributes Clone() + { + return new ViewAttributes(this); + } + + } +} diff --git a/src/Tizen.NUI.CommonUI/Controls/Button.cs b/src/Tizen.NUI.CommonUI/Controls/Button.cs new file mode 100755 index 000000000..7015bc094 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Controls/Button.cs @@ -0,0 +1,1503 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System; +using System.ComponentModel; +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI.CommonUI +{ + /// + /// Button is one kind of common component, a button clearly describes what action will occur when the user selects it. + /// Button may contain text or an icon. + /// + /// 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 class Button : Control + { + private ImageView backgroundImage; + private ImageView shadowImage; + private ImageView overlayImage; + + private TextLabel buttonText; + private ImageView buttonIcon; + + private ButtonAttributes buttonAttributes; + private EventHandler stateChangeHander; + + private bool isSelected = false; + private bool isEnabled = true; + private bool isPressed = false; + /// + /// Creates a new instance of a Button. + /// + /// 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 Button() : base() + { + Initialize(); + } + /// + /// Creates a new instance of a Button with style. + /// + /// Create Button by special style defined in UX. + /// 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 Button(string style) : base(style) + { + Initialize(); + } + /// + /// Creates a new instance of a Button with attributes. + /// + /// Create Button by attributes customized by user. + /// 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 Button(ButtonAttributes attributes) : base(attributes) + { + Initialize(); + } + /// + /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.
+ ///
+ /// 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 ClickEvent; + /// + /// An event for the button state changed signal which can be used to subscribe or unsubscribe the event handler provided by the user.
+ ///
+ /// 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 StateChangedEvent + { + add + { + stateChangeHander += value; + } + remove + { + stateChangeHander -= value; + } + } + /// + /// Icon orientation. + /// + /// 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 enum IconOrientation + { + /// + /// Top. + /// + /// 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)] + Top, + /// + /// Bottom. + /// + /// 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)] + Bottom, + /// + /// Left. + /// + /// 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)] + Left, + /// + /// Right. + /// + /// 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)] + Right, + } + /// + /// Flag to decide Button can be selected or not. + /// + /// 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 bool IsSelectable + { + get + { + return buttonAttributes?.IsSelectable ?? false; + } + set + { + buttonAttributes.IsSelectable = value; + } + } + /// + /// Background image's resource url in Button. + /// + /// 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 string BackgroundImageURL + { + get + { + return buttonAttributes?.BackgroundImageAttributes?.ResourceUrl?.All; + } + set + { + if (value != null) + { + CreateBackgroundAttributes(); + if (buttonAttributes.BackgroundImageAttributes.ResourceUrl == null) + { + buttonAttributes.BackgroundImageAttributes.ResourceUrl = new StringSelector(); + } + buttonAttributes.BackgroundImageAttributes.ResourceUrl.All = value; + RelayoutRequest(); + } + } + } + /// + /// Background image's border in Button. + /// + /// 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 Rectangle BackgroundImageBorder + { + get + { + return buttonAttributes?.BackgroundImageAttributes?.Border?.All; + } + set + { + if (value != null) + { + CreateBackgroundAttributes(); + if (buttonAttributes.BackgroundImageAttributes.Border == null) + { + buttonAttributes.BackgroundImageAttributes.Border = new RectangleSelector(); + } + buttonAttributes.BackgroundImageAttributes.Border.All = value; + RelayoutRequest(); + } + } + } + /// + /// Shadow image's resource url in Button. + /// + /// 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 string ShadowImageURL + { + get + { + return buttonAttributes?.ShadowImageAttributes?.ResourceUrl?.All; + } + set + { + if (value != null) + { + CreateShadowAttributes(); + if (buttonAttributes.ShadowImageAttributes.ResourceUrl == null) + { + buttonAttributes.ShadowImageAttributes.ResourceUrl = new StringSelector(); + } + buttonAttributes.ShadowImageAttributes.ResourceUrl.All = value; + RelayoutRequest(); + } + } + } + /// + /// Shadow image's border in Button. + /// + /// 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 Rectangle ShadowImageBorder + { + get + { + return buttonAttributes?.ShadowImageAttributes?.Border?.All; + } + set + { + if (value != null) + { + CreateShadowAttributes(); + if (buttonAttributes.ShadowImageAttributes.Border == null) + { + buttonAttributes.ShadowImageAttributes.Border = new RectangleSelector(); + } + buttonAttributes.ShadowImageAttributes.Border.All = value; + RelayoutRequest(); + } + } + } + /// + /// Overlay image's resource url in Button. + /// + /// 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 string OverlayImageURL + { + get + { + return buttonAttributes?.OverlayImageAttributes?.ResourceUrl?.All; + } + set + { + if (value != null) + { + CreateOverlayAttributes(); + if (buttonAttributes.OverlayImageAttributes.ResourceUrl == null) + { + buttonAttributes.OverlayImageAttributes.ResourceUrl = new StringSelector(); + } + buttonAttributes.OverlayImageAttributes.ResourceUrl.All = value; + RelayoutRequest(); + } + } + } + /// + /// Overlay image's border in Button. + /// + /// 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 Rectangle OverlayImageBorder + { + get + { + return buttonAttributes?.OverlayImageAttributes?.Border?.All; + } + set + { + if (value != null) + { + CreateOverlayAttributes(); + if (buttonAttributes.OverlayImageAttributes.Border == null) + { + buttonAttributes.OverlayImageAttributes.Border = new RectangleSelector(); + } + buttonAttributes.OverlayImageAttributes.Border.All = value; + RelayoutRequest(); + } + } + } + /// + /// Text string in Button. + /// + /// 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 string Text + { + get + { + return buttonAttributes?.TextAttributes?.Text?.All; + } + set + { + if (value != null) + { + CreateTextAttributes(); + if(buttonAttributes.TextAttributes.Text == null) + { + buttonAttributes.TextAttributes.Text = new StringSelector(); + } + buttonAttributes.TextAttributes.Text.All = value; + + RelayoutRequest(); + } + } + } + /// + /// Translate text string in Button. + /// + /// 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 string TranslatableText + { + get + { + return buttonAttributes?.TextAttributes?.TranslatableText?.All; + } + set + { + if (value != null) + { + CreateTextAttributes(); + if (buttonAttributes.TextAttributes.TranslatableText == null) + { + buttonAttributes.TextAttributes.TranslatableText = new StringSelector(); + } + buttonAttributes.TextAttributes.TranslatableText.All = value; + + RelayoutRequest(); + } + } + } + /// + /// Text point size in Button. + /// + /// 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 float PointSize + { + get + { + return buttonAttributes?.TextAttributes?.PointSize?.All ?? 0; + } + set + { + CreateTextAttributes(); + if (buttonAttributes.TextAttributes.PointSize == null) + { + buttonAttributes.TextAttributes.PointSize = new FloatSelector(); + } + buttonAttributes.TextAttributes.PointSize.All = value; + RelayoutRequest(); + } + } + /// + /// Text font family in Button. + /// + /// 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 string FontFamily + { + get + { + return buttonAttributes?.TextAttributes?.FontFamily; + } + set + { + CreateTextAttributes(); + buttonAttributes.TextAttributes.FontFamily = value; + RelayoutRequest(); + } + } + /// + /// Text color in Button. + /// + /// 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 Color TextColor + { + get + { + return buttonAttributes?.TextAttributes?.TextColor?.All; + } + set + { + CreateTextAttributes(); + if (buttonAttributes.TextAttributes.TextColor == null) + { + buttonAttributes.TextAttributes.TextColor = new ColorSelector(); + } + buttonAttributes.TextAttributes.TextColor.All = value; + RelayoutRequest(); + } + } + /// + /// Text horizontal alignment in Button. + /// + /// 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 HorizontalAlignment TextAlignment + { + get + { + return buttonAttributes?.TextAttributes?.HorizontalAlignment ?? HorizontalAlignment.Center; + } + set + { + CreateTextAttributes(); + buttonAttributes.TextAttributes.HorizontalAlignment = value; + RelayoutRequest(); + } + } + /// + /// Icon image's resource url in Button. + /// + /// 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 string IconURL + { + get + { + return buttonAttributes?.IconAttributes?.ResourceUrl?.All; + } + set + { + if (value != null) + { + CreateIconAttributes(); + if (buttonAttributes.IconAttributes.ResourceUrl == null) + { + buttonAttributes.IconAttributes.ResourceUrl = new StringSelector(); + } + buttonAttributes.IconAttributes.ResourceUrl.All = value; + RelayoutRequest(); + } + } + } + /// + /// Text string selector in Button. + /// + /// 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 StringSelector TextSelector + { + get + { + return buttonAttributes?.TextAttributes?.Text; + } + set + { + if (value != null) + { + CreateTextAttributes(); + buttonAttributes.TextAttributes.Text = value.Clone() as StringSelector; + RelayoutRequest(); + } + } + } + /// + /// Translateable text string selector in Button. + /// + /// 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 StringSelector TranslatableTextSelector + { + get + { + return buttonAttributes?.TextAttributes?.TranslatableText; + } + set + { + if (value != null) + { + CreateTextAttributes(); + buttonAttributes.TextAttributes.TranslatableText = value.Clone() as StringSelector; + RelayoutRequest(); + } + } + } + /// + /// Text color selector in Button. + /// + /// 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 ColorSelector TextColorSelector + { + get + { + return buttonAttributes?.TextAttributes?.TextColor; + } + set + { + if(value != null) + { + CreateTextAttributes(); + buttonAttributes.TextAttributes.TextColor = value.Clone() as ColorSelector; + RelayoutRequest(); + } + } + } + /// + /// Text font size selector in Button. + /// + /// 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 FloatSelector PointSizeSelector + { + get + { + return buttonAttributes?.TextAttributes?.PointSize; + } + set + { + if (value != null) + { + CreateTextAttributes(); + buttonAttributes.TextAttributes.PointSize = value.Clone() as FloatSelector; + RelayoutRequest(); + } + } + } + /// + /// Icon image's resource url selector in Button. + /// + /// 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 StringSelector IconURLSelector + { + get + { + return buttonAttributes?.IconAttributes?.ResourceUrl; + } + set + { + if (value != null) + { + CreateIconAttributes(); + buttonAttributes.IconAttributes.ResourceUrl = value.Clone() as StringSelector; + RelayoutRequest(); + } + } + } + /// + /// Background image's resource url selector in Button. + /// + /// 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 StringSelector BackgroundImageURLSelector + { + get + { + return buttonAttributes?.BackgroundImageAttributes?.ResourceUrl; + } + set + { + if (value != null) + { + CreateBackgroundAttributes(); + buttonAttributes.BackgroundImageAttributes.ResourceUrl = value.Clone() as StringSelector; + RelayoutRequest(); + } + } + } + /// + /// Background image's border selector in Button. + /// + /// 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 RectangleSelector BackgroundImageBorderSelector + { + get + { + return buttonAttributes?.BackgroundImageAttributes?.Border; + } + set + { + if (value != null) + { + CreateBackgroundAttributes(); + buttonAttributes.BackgroundImageAttributes.Border = value.Clone() as RectangleSelector; + RelayoutRequest(); + } + } + } + /// + /// Shadow image's resource url selector in Button. + /// + /// 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 StringSelector ShadowImageURLSelector + { + get + { + return buttonAttributes?.ShadowImageAttributes?.ResourceUrl; + } + set + { + if (value != null) + { + CreateShadowAttributes(); + buttonAttributes.ShadowImageAttributes.ResourceUrl = value.Clone() as StringSelector; + RelayoutRequest(); + } + } + } + /// + /// Shadow image's border selector in Button. + /// + /// 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 RectangleSelector ShadowImageBorderSelector + { + get + { + return buttonAttributes?.ShadowImageAttributes?.Border; + } + set + { + if (value != null) + { + CreateShadowAttributes(); + buttonAttributes.ShadowImageAttributes.Border = value.Clone() as RectangleSelector; + RelayoutRequest(); + } + } + } + /// + /// Overlay image's resource url selector in Button. + /// + /// 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 StringSelector OverlayImageURLSelector + { + get + { + return buttonAttributes?.OverlayImageAttributes?.ResourceUrl; + } + set + { + if (value != null) + { + CreateOverlayAttributes(); + buttonAttributes.OverlayImageAttributes.ResourceUrl = value.Clone() as StringSelector; + RelayoutRequest(); + } + } + } + /// + /// Overlay image's border selector in Button. + /// + /// 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 RectangleSelector OverlayImageBorderSelector + { + get + { + return buttonAttributes?.OverlayImageAttributes?.Border; + } + set + { + if (value != null) + { + CreateOverlayAttributes(); + buttonAttributes.OverlayImageAttributes.Border = value.Clone() as RectangleSelector; + RelayoutRequest(); + } + } + } + /// + /// Flag to decide selected state in Button. + /// + /// 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 bool IsSelected + { + get + { + return isSelected; + } + set + { + isSelected = value; + UpdateState(); + } + } + /// + /// Flag to decide enable or disable in Button. + /// + /// 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 bool IsEnabled + { + get + { + return isEnabled; + } + set + { + isEnabled = value; + UpdateState(); + } + } + + /// + /// Icon relative orientation in Button, work only when show icon and text. + /// + /// 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 IconOrientation? IconRelativeOrientation + { + get + { + return buttonAttributes?.IconRelativeOrientation; + } + set + { + if(buttonAttributes != null && buttonAttributes.IconRelativeOrientation != value) + { + buttonAttributes.IconRelativeOrientation = value; + RelayoutRequest(); + } + } + } + + /// + /// Icon left padding in Button, work only when show icon and text. + /// + /// 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 int IconPaddingLeft + { + get + { + return buttonAttributes?.IconAttributes?.PaddingLeft ?? 0; + } + set + { + CreateIconAttributes(); + buttonAttributes.IconAttributes.PaddingLeft = value; + RelayoutRequest(); + } + } + + /// + /// Icon right padding in Button, work only when show icon and text. + /// + /// 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 int IconPaddingRight + { + get + { + return buttonAttributes?.IconAttributes?.PaddingRight ?? 0; + } + set + { + CreateIconAttributes(); + buttonAttributes.IconAttributes.PaddingRight = value; + RelayoutRequest(); + } + } + + /// + /// Icon top padding in Button, work only when show icon and text. + /// + /// 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 int IconPaddingTop + { + get + { + return buttonAttributes?.IconAttributes?.PaddingTop ?? 0; + } + set + { + CreateIconAttributes(); + buttonAttributes.IconAttributes.PaddingTop = value; + RelayoutRequest(); + } + } + + /// + /// Icon bottom padding in Button, work only when show icon and text. + /// + /// 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 int IconPaddingBottom + { + get + { + return buttonAttributes?.IconAttributes?.PaddingBottom ?? 0; + } + set + { + CreateIconAttributes(); + buttonAttributes.IconAttributes.PaddingBottom = value; + RelayoutRequest(); + } + } + + /// + /// Text left padding in Button, work only when show icon and text. + /// + /// 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 int TextPaddingLeft + { + get + { + return buttonAttributes?.TextAttributes?.PaddingLeft ?? 0; + } + set + { + CreateTextAttributes(); + buttonAttributes.TextAttributes.PaddingLeft = value; + RelayoutRequest(); + } + } + + /// + /// Text right padding in Button, work only when show icon and text. + /// + /// 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 int TextPaddingRight + { + get + { + return buttonAttributes?.TextAttributes?.PaddingRight ?? 0; + } + set + { + CreateTextAttributes(); + buttonAttributes.TextAttributes.PaddingRight = value; + RelayoutRequest(); + } + } + + /// + /// Text top padding in Button, work only when show icon and text. + /// + /// 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 int TextPaddingTop + { + get + { + return buttonAttributes?.TextAttributes?.PaddingTop ?? 0; + } + set + { + CreateTextAttributes(); + buttonAttributes.TextAttributes.PaddingTop = value; + RelayoutRequest(); + } + } + + /// + /// Text bottom padding in Button, work only when show icon and text. + /// + /// 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 int TextPaddingBottom + { + get + { + return buttonAttributes?.TextAttributes?.PaddingBottom ?? 0; + } + set + { + CreateTextAttributes(); + buttonAttributes.TextAttributes.PaddingBottom = value; + RelayoutRequest(); + } + } + /// + /// Dispose Button and all children on it. + /// + /// Dispose type. + /// 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 Dispose(DisposeTypes type) + { + if (disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) + { + if (buttonIcon != null) + { + buttonIcon.Relayout -= OnIconRelayout; + Utility.Dispose(buttonIcon); + } + if (buttonText != null) + { + Utility.Dispose(buttonText); + } + if (overlayImage != null) + { + Utility.Dispose(overlayImage); + } + if (backgroundImage != null) + { + Utility.Dispose(backgroundImage); + } + if (shadowImage != null) + { + Utility.Dispose(shadowImage); + } + } + + base.Dispose(type); + } + /// + /// Called after a key event is received by the view that has had its focus set. + /// + /// The key event. + /// True if the key event should be consumed. + /// 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 bool OnKey(Key key) + { + if (key.State == Key.StateType.Down) + { + if (key.KeyPressedName == "Return") + { + isPressed = true; + UpdateState(); + if(isEnabled) + { + ClickEventArgs eventArgs = new ClickEventArgs(); + OnClick(eventArgs); + } + } + } + else if (key.State == Key.StateType.Up) + { + if (key.KeyPressedName == "Return") + { + isPressed = false; + if (buttonAttributes.IsSelectable != null && buttonAttributes.IsSelectable == true) + { + isSelected = !isSelected; + } + UpdateState(); + } + } + return base.OnKey(key); + } + /// + /// Called when the control gain key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is gained. + /// + /// 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 OnFocusGained() + { + base.OnFocusGained(); + UpdateState(); + } + /// + /// Called when the control loses key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is lost. + /// + /// 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 OnFocusLost() + { + base.OnFocusLost(); + UpdateState(); + } + /// + /// Tap gesture event callback. + /// + /// Source which recieved touch event. + /// Tap gesture event argument. + /// 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 OnTapGestureDetected(object source, TapGestureDetector.DetectedEventArgs e) + { + if (isEnabled) + { + ClickEventArgs eventArgs = new ClickEventArgs(); + OnClick(eventArgs); + base.OnTapGestureDetected(source, e); + } + } + + /// + /// Called after a touch event is received by the owning view.
+ /// CustomViewBehaviour.REQUIRES_TOUCH_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).
+ ///
+ /// The touch event. + /// True if the event should be consumed. + /// 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 bool OnTouch(Touch touch) + { + PointStateType state = touch.GetState(0); + + switch(state) + { + case PointStateType.Down: + isPressed = true; + UpdateState(); + return true; + case PointStateType.Interrupted: + isPressed = false; + UpdateState(); + return true; + case PointStateType.Up: + isPressed = false; + if (buttonAttributes.IsSelectable != null && buttonAttributes.IsSelectable == true) + { + isSelected = !isSelected; + } + UpdateState(); + return true; + default: + break; + } + return base.OnTouch(touch); + } + /// + /// Get Button attribues. + /// + /// 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 Attributes GetAttributes() + { + return new ButtonAttributes(); + } + /// + /// Update Button by attributes. + /// + /// 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 OnUpdate() + { + if (buttonAttributes.ShadowImageAttributes != null) + { + if(shadowImage == null) + { + shadowImage = new ImageView() + { + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent + }; + this.Add(shadowImage); + } + ApplyAttributes(shadowImage, buttonAttributes.ShadowImageAttributes); + } + + if (buttonAttributes.BackgroundImageAttributes != null) + { + if(backgroundImage == null) + { + backgroundImage = new ImageView() + { + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent + }; + this.Add(backgroundImage); + } + ApplyAttributes(backgroundImage, buttonAttributes.BackgroundImageAttributes); + } + + if (buttonAttributes.OverlayImageAttributes != null) + { + if(overlayImage == null) + { + overlayImage = new ImageView() + { + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent + }; + this.Add(overlayImage); + } + ApplyAttributes(overlayImage, buttonAttributes.OverlayImageAttributes); + } + + if (buttonAttributes.TextAttributes != null) + { + if(buttonText == null) + { + buttonText = new TextLabel(); + this.Add(buttonText); + } + ApplyAttributes(buttonText, buttonAttributes.TextAttributes); + } + + if (buttonAttributes.IconAttributes != null) + { + if(buttonIcon == null) + { + buttonIcon = new ImageView(); + buttonIcon.Relayout += OnIconRelayout; + this.Add(buttonIcon); + } + ApplyAttributes(buttonIcon, buttonAttributes.IconAttributes); + } + + MeasureText(); + LayoutChild(); + + Sensitive = isEnabled ? true : false; + } + + /// + /// Update Button State. + /// + /// 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 void UpdateState() + { + ControlStates sourceState = State; + ControlStates targetState; + + if(isEnabled) + { + targetState = isPressed ? ControlStates.Pressed : (IsFocused ? (IsSelected ? ControlStates.SelectedFocused : ControlStates.Focused) : (IsSelected ? ControlStates.Selected : ControlStates.Normal)); + } + else + { + targetState = IsSelected ? ControlStates.DisabledSelected : (IsFocused ? ControlStates.DisabledFocused : ControlStates.Disabled); + } + if(sourceState != targetState) + { + State = targetState; + + OnUpdate(); + + StateChangeEventArgs e = new StateChangeEventArgs + { + PreviousState = sourceState, + CurrentState = targetState + }; + stateChangeHander?.Invoke(this, e); + } + } + /// + /// It is hijack by using protected, attributes copy problem when class inherited from Button. + /// + /// 6 + private void Initialize() + { + buttonAttributes = attributes as ButtonAttributes; + if (buttonAttributes == null) + { + throw new Exception("Button attribute parse error."); + } + + ApplyAttributes(this, buttonAttributes); + LayoutDirectionChanged += OnLayoutDirectionChanged; + } + + /// + /// Measure text, it can be override. + /// + /// 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 virtual void MeasureText() + { + if (buttonAttributes.IconRelativeOrientation == null || buttonIcon == null || buttonText == null) + { + return; + } + buttonText.WidthResizePolicy = ResizePolicyType.Fixed; + buttonText.HeightResizePolicy = ResizePolicyType.Fixed; + int textPaddingLeft = buttonAttributes.TextAttributes.PaddingLeft; + int textPaddingRight = buttonAttributes.TextAttributes.PaddingRight; + int textPaddingTop = buttonAttributes.TextAttributes.PaddingTop; + int textPaddingBottom = buttonAttributes.TextAttributes.PaddingBottom; + + int iconPaddingLeft = buttonAttributes.IconAttributes.PaddingLeft; + int iconPaddingRight = buttonAttributes.IconAttributes.PaddingRight; + int iconPaddingTop = buttonAttributes.IconAttributes.PaddingTop; + int iconPaddingBottom = buttonAttributes.IconAttributes.PaddingBottom; + + if (IconRelativeOrientation == IconOrientation.Top || IconRelativeOrientation == IconOrientation.Bottom) + { + buttonText.SizeWidth = SizeWidth - textPaddingLeft - textPaddingRight; + buttonText.SizeHeight = SizeHeight - textPaddingTop - textPaddingBottom - iconPaddingTop - iconPaddingBottom - buttonIcon.SizeHeight; + } + else + { + buttonText.SizeWidth = SizeWidth - textPaddingLeft - textPaddingRight - iconPaddingLeft - iconPaddingRight - buttonIcon.SizeWidth; + buttonText.SizeHeight = SizeHeight - textPaddingTop - textPaddingBottom; + } + } + /// + /// Layout child, it can be override. + /// + /// 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 virtual void LayoutChild() + { + if (buttonAttributes.IconRelativeOrientation == null || buttonIcon == null || buttonText == null) + { + return; + } + + int textPaddingLeft = buttonAttributes.TextAttributes.PaddingLeft; + int textPaddingRight = buttonAttributes.TextAttributes.PaddingRight; + int textPaddingTop = buttonAttributes.TextAttributes.PaddingTop; + int textPaddingBottom = buttonAttributes.TextAttributes.PaddingBottom; + + int iconPaddingLeft = buttonAttributes.IconAttributes.PaddingLeft; + int iconPaddingRight = buttonAttributes.IconAttributes.PaddingRight; + int iconPaddingTop = buttonAttributes.IconAttributes.PaddingTop; + int iconPaddingBottom = buttonAttributes.IconAttributes.PaddingBottom; + + switch (IconRelativeOrientation) + { + case IconOrientation.Top: + buttonIcon.PositionUsesPivotPoint = true; + buttonIcon.ParentOrigin = NUI.ParentOrigin.TopCenter; + buttonIcon.PivotPoint = NUI.PivotPoint.TopCenter; + buttonIcon.Position2D = new Position2D(0, iconPaddingTop); + + buttonText.PositionUsesPivotPoint = true; + buttonText.ParentOrigin = NUI.ParentOrigin.BottomCenter; + buttonText.PivotPoint = NUI.PivotPoint.BottomCenter; + buttonText.Position2D = new Position2D(0, -textPaddingBottom); + break; + case IconOrientation.Bottom: + buttonIcon.PositionUsesPivotPoint = true; + buttonIcon.ParentOrigin = NUI.ParentOrigin.BottomCenter; + buttonIcon.PivotPoint = NUI.PivotPoint.BottomCenter; + buttonIcon.Position2D = new Position2D(0, -iconPaddingBottom); + + buttonText.PositionUsesPivotPoint = true; + buttonText.ParentOrigin = NUI.ParentOrigin.TopCenter; + buttonText.PivotPoint = NUI.PivotPoint.TopCenter; + buttonText.Position2D = new Position2D(0, textPaddingTop); + break; + case IconOrientation.Left: + if (LayoutDirection == ViewLayoutDirectionType.LTR) + { + buttonIcon.PositionUsesPivotPoint = true; + buttonIcon.ParentOrigin = NUI.ParentOrigin.CenterLeft; + buttonIcon.PivotPoint = NUI.PivotPoint.CenterLeft; + buttonIcon.Position2D = new Position2D(iconPaddingLeft, 0); + + buttonText.PositionUsesPivotPoint = true; + buttonText.ParentOrigin = NUI.ParentOrigin.CenterRight; + buttonText.PivotPoint = NUI.PivotPoint.CenterRight; + buttonText.Position2D = new Position2D(-textPaddingRight, 0); + } + else + { + buttonIcon.PositionUsesPivotPoint = true; + buttonIcon.ParentOrigin = NUI.ParentOrigin.CenterRight; + buttonIcon.PivotPoint = NUI.PivotPoint.CenterRight; + buttonIcon.Position2D = new Position2D(-iconPaddingLeft, 0); + + buttonText.PositionUsesPivotPoint = true; + buttonText.ParentOrigin = NUI.ParentOrigin.CenterLeft; + buttonText.PivotPoint = NUI.PivotPoint.CenterLeft; + buttonText.Position2D = new Position2D(textPaddingRight, 0); + } + + break; + case IconOrientation.Right: + if (LayoutDirection == ViewLayoutDirectionType.RTL) + { + buttonIcon.PositionUsesPivotPoint = true; + buttonIcon.ParentOrigin = NUI.ParentOrigin.CenterLeft; + buttonIcon.PivotPoint = NUI.PivotPoint.CenterLeft; + buttonIcon.Position2D = new Position2D(iconPaddingRight, 0); + + buttonText.PositionUsesPivotPoint = true; + buttonText.ParentOrigin = NUI.ParentOrigin.CenterRight; + buttonText.PivotPoint = NUI.PivotPoint.CenterRight; + buttonText.Position2D = new Position2D(-textPaddingLeft, 0); + } + else + { + buttonIcon.PositionUsesPivotPoint = true; + buttonIcon.ParentOrigin = NUI.ParentOrigin.CenterRight; + buttonIcon.PivotPoint = NUI.PivotPoint.CenterRight; + buttonIcon.Position2D = new Position2D(-iconPaddingRight, 0); + + buttonText.PositionUsesPivotPoint = true; + buttonText.ParentOrigin = NUI.ParentOrigin.CenterLeft; + buttonText.PivotPoint = NUI.PivotPoint.CenterLeft; + buttonText.Position2D = new Position2D(textPaddingLeft, 0); + } + break; + default: + break; + } + } + /// + /// 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) + { + ButtonAttributes tempAttributes = StyleManager.Instance.GetAttributes(style) as ButtonAttributes; + if(tempAttributes != null) + { + attributes = buttonAttributes = tempAttributes; + RelayoutRequest(); + } + } + + private void OnLayoutDirectionChanged(object sender, LayoutDirectionChangedEventArgs e) + { + MeasureText(); + LayoutChild(); + } + + private void OnClick(ClickEventArgs eventArgs) + { + ClickEvent?.Invoke(this, eventArgs); + } + + private void OnIconRelayout(object sender, EventArgs e) + { + MeasureText(); + LayoutChild(); + } + + private void CreateBackgroundAttributes() + { + if (buttonAttributes.BackgroundImageAttributes == null) + { + buttonAttributes.BackgroundImageAttributes = new ImageAttributes() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.Center, + PivotPoint = Tizen.NUI.PivotPoint.Center, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent + }; + } + } + + private void CreateShadowAttributes() + { + if (buttonAttributes.ShadowImageAttributes == null) + { + buttonAttributes.ShadowImageAttributes = new ImageAttributes() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.Center, + PivotPoint = Tizen.NUI.PivotPoint.Center, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent + }; + } + } + + private void CreateOverlayAttributes() + { + if (buttonAttributes.OverlayImageAttributes == null) + { + buttonAttributes.OverlayImageAttributes = new ImageAttributes() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.Center, + PivotPoint = Tizen.NUI.PivotPoint.Center, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent + }; + } + } + + private void CreateTextAttributes() + { + if (buttonAttributes.TextAttributes == null) + { + buttonAttributes.TextAttributes = new TextAttributes() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.Center, + PivotPoint = Tizen.NUI.PivotPoint.Center, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center + }; + } + } + + private void CreateIconAttributes() + { + if (buttonAttributes.IconAttributes == null) + { + buttonAttributes.IconAttributes = new ImageAttributes() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.Center, + PivotPoint = Tizen.NUI.PivotPoint.Center, + WidthResizePolicy = ResizePolicyType.UseNaturalSize, + HeightResizePolicy = ResizePolicyType.UseNaturalSize, + }; + } + } + /// + /// ClickEventArgs is a class to record button click event arguments which will sent to user. + /// + /// 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 class ClickEventArgs : EventArgs + { + } + /// + /// StateChangeEventArgs is a class to record button state change event arguments which will sent to user. + /// + /// 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 class StateChangeEventArgs : EventArgs + { + /// previous state of Button + /// 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 ControlStates PreviousState; + /// current state of Button + /// 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 ControlStates CurrentState; + } + + } +} diff --git a/src/Tizen.NUI.CommonUI/Controls/CheckBox.cs b/src/Tizen.NUI.CommonUI/Controls/CheckBox.cs new file mode 100755 index 000000000..1b1b10887 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Controls/CheckBox.cs @@ -0,0 +1,66 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// 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 class CheckBox : SelectButton + { + /// + /// Creates a new instance of a CheckBox. + /// + /// 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 CheckBox() : base() { } + /// + /// Creates a new instance of a CheckBox with style. + /// + /// + /// 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 CheckBox(string style) : base(style) { } + /// + /// Creates a new instance of a CheckBox with attributes. + /// + /// + /// 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 CheckBox(SelectButtonAttributes attrs) : base(attrs) { } + + /// + /// Get CheckBoxGroup to which this CheckBox belong. + /// + /// 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 CheckBoxGroup ItemGroup + { + get + { + return itemGroup as CheckBoxGroup; + } + internal set + { + itemGroup = value; + } + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Controls/CheckBoxGroup.cs b/src/Tizen.NUI.CommonUI/Controls/CheckBoxGroup.cs new file mode 100755 index 000000000..f9b5cf739 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Controls/CheckBoxGroup.cs @@ -0,0 +1,165 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; +using System.Collections.Generic; + +namespace Tizen.NUI.CommonUI +{ + /// + /// The CheckboxGroup class is used to group together a set of CheckBox control + /// + /// + /// CheckBoxGroup checkGroup = new CheckBoxGroup(); + /// CheckBox check1 = new CheckBox(); + /// CheckBox check2 = new CheckBox(); + /// checkGroup.Add(check1); + /// checkGroup.Add(check2); + /// + /// 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 class CheckBoxGroup : SelectGroup + { + /// + /// Construct CheckBoxGroup + /// + /// 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 CheckBoxGroup() : base() + { + + } + + /// + /// Add CheckBox to the end of CheckBoxGroup. + /// + /// The CheckBox to be added to the CheckBoxGroup + /// 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 void Add(CheckBox check) + { + base.AddSelection(check); + check.ItemGroup = this; + } + + /// + /// Remove CheckBox from the CheckBoxGroup. + /// + /// The CheckBox to remove from the CheckBoxGroup + /// 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 void Remove(CheckBox check) + { + base.RemoveSelection(check); + check.ItemGroup = null; + } + + /// + /// Get the CheckBox object at the specified index. + /// + /// The item index + /// CheckBox + /// 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 CheckBox GetItemByIndex(int index) + { + return itemGroup[index] as CheckBox; + } + + /// + /// Get the index array of checked items. + /// + /// The array of index + /// 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 int[] GetCheckedIndexArray() + { + List selectedItemsList = new List(); + for (int i = 0; i < itemGroup.Count; i++) + { + if (itemGroup[i].IsSelected) + { + selectedItemsList.Add(i); + } + } + + return selectedItemsList.ToArray(); + } + + + /// + /// Get the CheckBox array of checked items. + /// + /// The array of CheckBox + /// 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 CheckBox[] GetCheckedItemArray() + { + List selectedList = new List(); + + foreach (CheckBox check in itemGroup) + { + if (check.IsSelected) + { + selectedList.Add(check); + } + } + + return selectedList.ToArray(); + } + + /// + /// Determines whether every checkboxes in the CheckBoxGroup are checked + /// + /// If all of CheckBoxes are checked, return true. otherwise false + /// 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 bool IsCheckedAll() + { + foreach (CheckBox cb in itemGroup) + { + if (!cb.IsSelected) + { + return false; + } + } + return true; + } + + /// + /// Check or Uncheck all of child checkboxes by the specified value + /// + /// The boolean state of the check box + /// 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 void CheckingAll(bool state) + { + foreach (CheckBox cb in itemGroup) + { + cb.IsSelected = state; + } + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Controls/Control.cs b/src/Tizen.NUI.CommonUI/Controls/Control.cs new file mode 100755 index 000000000..6ef08ab7f --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Controls/Control.cs @@ -0,0 +1,497 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI.CommonUI +{ + /// + /// The control component is base class of tv nui components. It's abstract class, so cann't instantiate and can only be inherited. + /// + /// 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 abstract class Control : VisualView + { + /// + /// Control style. + /// + /// 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 string style; + /// + /// Control attributes. + /// + /// 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 Attributes attributes; + + private TapGestureDetector tapGestureDetector = new TapGestureDetector(); + private bool isFocused = false; + + /// + /// Construct an empty Control. + /// + /// 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 Control() : base() + { + Initialize(null); + } + + /// + /// Construct with attributes + /// + /// Create attributes customized by user + /// 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 Control(Attributes attributes) : base() + { + Initialize(null); + this.attributes = attributes.Clone(); + } + + /// + /// Construct with style + /// + /// Style to be applied + /// 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 Control(string style) : base() + { + Initialize(style); + } + + /// + /// Get/Set the control state. + /// + /// 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 new ControlStates State + { + get; + set; + } + /// + /// Whether focusable when touch + /// + /// 6 + internal bool StateFocusableOnTouchMode + { + get; + set; + } + + internal bool IsFocused + { + get + { + return isFocused || HasFocus(); + } + } + /// + /// Apply attributes for View, Image or TextLabel. + /// + /// View which will be applied attrs + /// Attributes for View, Image or TextLabel + /// 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 void ApplyAttributes(View view, ViewAttributes attrs) + { + if (view == null || attrs == null) + { + return; + } + + if (attrs.Position2D != null) + { + view.Position2D = attrs.Position2D; + } + if (attrs.Size2D != null) + { + view.Size2D = attrs.Size2D; + } + if (attrs.MinimumSize != null) + { + view.MinimumSize = attrs.MinimumSize; + } + if (attrs.BackgroundColor?.GetValue(State) != null) + { + view.BackgroundColor = attrs.BackgroundColor.GetValue(State); + } + if (attrs.PositionUsesPivotPoint != null) + { + view.PositionUsesPivotPoint = attrs.PositionUsesPivotPoint.Value; + } + if (attrs.ParentOrigin != null) + { + view.ParentOrigin = attrs.ParentOrigin; + } + if (attrs.PivotPoint != null) + { + view.PivotPoint = attrs.PivotPoint; + } + if (attrs.WidthResizePolicy!= null) + { + view.WidthResizePolicy = attrs.WidthResizePolicy.Value; + } + if (attrs.HeightResizePolicy != null) + { + view.HeightResizePolicy = attrs.HeightResizePolicy.Value; + } + if (attrs.SizeModeFactor != null) + { + view.SizeModeFactor = attrs.SizeModeFactor; + } + if (attrs.Opacity?.GetValue(State) != null) + { + view.Opacity = attrs.Opacity.GetValue(State).Value; + } + + ImageView image = view as ImageView; + ImageAttributes imageAttrs = attrs as ImageAttributes; + if (image != null && imageAttrs != null) + { + if (imageAttrs.ResourceUrl?.GetValue(State) != null) + { + image.ResourceUrl = imageAttrs.ResourceUrl.GetValue(State); + } + if (imageAttrs.Border?.GetValue(State) != null) + { + image.Border = imageAttrs.Border.GetValue(State); + } + + } + + TextLabel text = view as TextLabel; + TextAttributes textAttrs = attrs as TextAttributes; + if (text != null && textAttrs != null) + { + if (textAttrs.Text?.GetValue(State) != null ) + { + text.Text = textAttrs.Text.GetValue(State); + } + if (textAttrs.TranslatableText?.GetValue(State) != null) + { + text.TranslatableText = textAttrs.TranslatableText.GetValue(State); + } + if (textAttrs.MultiLine != null) + { + text.MultiLine = textAttrs.MultiLine.Value; + } + if (textAttrs.HorizontalAlignment != null) + { + text.HorizontalAlignment = textAttrs.HorizontalAlignment.Value; + } + if (textAttrs.VerticalAlignment != null) + { + text.VerticalAlignment = textAttrs.VerticalAlignment.Value; + } + if (textAttrs.EnableMarkup != null) + { + text.EnableMarkup = textAttrs.EnableMarkup.Value; + } + if (textAttrs.AutoScrollLoopCount != null) + { + text.AutoScrollLoopCount = textAttrs.AutoScrollLoopCount.Value; + } + if (textAttrs.AutoScrollSpeed != null) + { + text.AutoScrollSpeed = textAttrs.AutoScrollSpeed.Value; + } + if (textAttrs.AutoScrollGap != null) + { + text.AutoScrollGap = textAttrs.AutoScrollGap.Value; + } + if (textAttrs.AutoScrollLoopDelay != null) + { + text.AutoScrollLoopDelay = textAttrs.AutoScrollLoopDelay.Value; + } + if (textAttrs.AutoScrollStopMode != null) + { + text.AutoScrollStopMode = textAttrs.AutoScrollStopMode.Value; + } + if (textAttrs.LineSpacing != null) + { + text.LineSpacing = textAttrs.LineSpacing.Value; + } + if (textAttrs.TextColor?.GetValue(State) != null) + { + text.TextColor = textAttrs.TextColor.GetValue(State); + } + if (textAttrs.FontFamily != null) + { + text.FontFamily = textAttrs.FontFamily; + } + if (textAttrs.PointSize?.GetValue(State) != null) + { + text.PointSize = textAttrs.PointSize.GetValue(State).Value; + } + + int thickness = 0; + + if (textAttrs.OutstrokeThickness?.GetValue(State) != null) + { + thickness = textAttrs.OutstrokeThickness.GetValue(State).Value; + } + if (textAttrs.OutstrokeColor?.GetValue(State) != null) + { + Color outstrokeColor = textAttrs.OutstrokeColor.GetValue(State); + PropertyMap outlineMap = new PropertyMap(); + outlineMap.Add("color", new PropertyValue(new Color(outstrokeColor.R, outstrokeColor.G, outstrokeColor.B, outstrokeColor.A))); + outlineMap.Add("width", new PropertyValue(thickness)); + text.Outline = outlineMap; + } + else + { + text.Outline = new PropertyMap(); + } + } + + TextField textField = view as TextField; + TextFieldAttributes textFieldAttrs = attrs as TextFieldAttributes; + if (textField != null && textFieldAttrs != null) + { + if (textFieldAttrs.Text?.GetValue(State) != null) + { + textField.Text = textFieldAttrs.Text.GetValue(State); + } + if (textFieldAttrs.PlaceholderText?.GetValue(State) != null) + { + textField.PlaceholderText = textFieldAttrs.PlaceholderText.GetValue(State); + } + if (textFieldAttrs.TranslatablePlaceholderText?.GetValue(State) != null) + { + textField.TranslatablePlaceholderText = textFieldAttrs.TranslatablePlaceholderText.GetValue(State); + } + if (textFieldAttrs.HorizontalAlignment != null) + { + textField.HorizontalAlignment = textFieldAttrs.HorizontalAlignment.Value; + } + if (textFieldAttrs.VerticalAlignment != null) + { + textField.VerticalAlignment = textFieldAttrs.VerticalAlignment.Value; + } + if (textFieldAttrs.EnableMarkup != null) + { + textField.EnableMarkup = textFieldAttrs.EnableMarkup.Value; + } + if (textFieldAttrs.TextColor?.GetValue(State) != null) + { + textField.TextColor = textFieldAttrs.TextColor.GetValue(State); + } + if (textFieldAttrs.PlaceholderTextColor?.GetValue(State) != null) + { + textField.PlaceholderTextColor = textFieldAttrs.PlaceholderTextColor.GetValue(State); + } + if (textFieldAttrs.PrimaryCursorColor?.GetValue(State) != null) + { + textField.PrimaryCursorColor = textFieldAttrs.PrimaryCursorColor.GetValue(State); + } + if (textFieldAttrs.SecondaryCursorColor?.GetValue(State) != null) + { + textField.SecondaryCursorColor = textFieldAttrs.SecondaryCursorColor.GetValue(State); + } + if (textFieldAttrs.FontFamily != null) + { + textField.FontFamily = textFieldAttrs.FontFamily; + } + if (textFieldAttrs.PointSize?.GetValue(State) != null) + { + textField.PointSize = textFieldAttrs.PointSize.GetValue(State).Value; + } + if (textFieldAttrs.EnableCursorBlink != null) + { + textField.EnableCursorBlink = textFieldAttrs.EnableCursorBlink.Value; + } + if (textFieldAttrs.EnableSelection != null) + { + textField.EnableSelection = textFieldAttrs.EnableSelection.Value; + } + if (textFieldAttrs.CursorWidth != null) + { + textField.CursorWidth = textFieldAttrs.CursorWidth.Value; + } + if (textFieldAttrs.EnableEllipsis != null) + { + textField.Ellipsis = textFieldAttrs.EnableEllipsis.Value; + } + } + } + /// + /// Dispose Control and all children on it. + /// + /// Dispose type. + /// 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 Dispose(DisposeTypes type) + { + if (disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) + { + StyleManager.Instance.ThemeChangedEvent -= OnThemeChangedEvent; + tapGestureDetector.Detected -= OnTapGestureDetected; + tapGestureDetector.Detach(this); + } + base.Dispose(type); + } + /// + /// Get attribues, it is abstract function and must be override. + /// + /// 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 abstract Attributes GetAttributes(); + /// + /// Called after a key event is received by the view that has had its focus set. + /// + /// The key event. + /// True if the key event should be consumed. + /// 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 bool OnKey(Key key) + { + return false; + } + + /// + /// Called after the size negotiation has been finished for this control.
+ /// The control is expected to assign this given size to itself or its children.
+ /// Should be overridden by derived classes if they need to layout views differently after certain operations like add or remove views, resize, or after changing specific properties.
+ /// As this function is called from inside the size negotiation algorithm, you cannot call RequestRelayout (the call would just be ignored).
+ ///
+ /// The allocated size. + /// The control should add views to this container that it is not able to allocate a size for. + /// 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 OnRelayout(Vector2 size, RelayoutContainer container) + { + OnUpdate(); + } + + /// + /// Called when the control gain key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is gained. + /// + /// 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 OnFocusGained() + { + isFocused = true; + } + + /// + /// Called when the control loses key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is lost. + /// + /// 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 OnFocusLost() + { + isFocused = false; + } + + /// + /// Tap gesture callback. + /// + /// The sender + /// The tap gesture event data + /// 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 virtual void OnTapGestureDetected(object source, TapGestureDetector.DetectedEventArgs e) + { + } + /// + /// Called after a touch event is received by the owning view.
+ /// CustomViewBehaviour.REQUIRES_TOUCH_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).
+ ///
+ /// The touch event. + /// True if the event should be consumed. + /// 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 bool OnTouch(Touch touch) + { + return false; + } + + /// + /// Update by attributes. + /// + /// 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 virtual void OnUpdate() + { + } + /// + /// Theme change callback when theme is changed, this callback will be trigger. + /// + /// The sender + /// The event data + /// 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 virtual void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) + { + } + + private void Initialize(string style) + { + attributes = (style == null) ? GetAttributes() : GetAttributes(style); + State = ControlStates.Normal; + + LeaveRequired = true; + + StateFocusableOnTouchMode = false; + + tapGestureDetector.Attach(this); + tapGestureDetector.Detected += OnTapGestureDetected; + + StyleManager.Instance.ThemeChangedEvent += OnThemeChangedEvent; + } + + private Attributes GetAttributes(string style) + { + Attributes attributes = StyleManager.Instance.GetAttributes(style); + if(attributes == null) + { + throw new InvalidOperationException($"There is no style {style}"); + } + this.style = style; + return attributes; + } + + } +} diff --git a/src/Tizen.NUI.CommonUI/Controls/DropDown.cs b/src/Tizen.NUI.CommonUI/Controls/DropDown.cs new file mode 100755 index 000000000..561289e67 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Controls/DropDown.cs @@ -0,0 +1,2066 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System; +using System.Collections.Generic; +using Tizen.NUI.BaseComponents; +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// DropDown is one kind of common component, a dropdown allows the user click dropdown button to choose one value from a list. + /// + /// 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 class DropDown : Control + { + #region DropDown + private Button button = null; + private TextLabel headerText = null; + private TextLabel buttonText = null; + private ImageView listBackgroundImage = null; + private FlexibleView list = null; + private DropDownListBridge adapter = new DropDownListBridge(); + private DropDownAttributes dropDownAttributes = null; + private DropDownItemView touchedView = null; + private int selectedItemIndex = -1; + + /// + /// Creates a new instance of a DropDown. + /// + /// 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 DropDown() : base() + { + Initialize(); + } + /// + /// Creates a new instance of a DropDown with style. + /// + /// Create DropDown by special style defined in UX. + /// 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 DropDown(string style) : base(style) + { + Initialize(); + } + /// + /// Creates a new instance of a DropDown with attributes. + /// + /// Create DropDown by attributes customized by user. + /// 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 DropDown(DropDownAttributes attributes) : base(attributes) + { + Initialize(); + } + + /// + /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.
+ ///
+ /// 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 delegate void ClickEventHandler(object sender, ClickEventArgs e); + + /// + /// An event for the item clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.
+ ///
+ /// 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 ClickEventHandler ItemClickEvent; + + /// + /// List orientation. + /// + /// 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 enum ListOrientation + { + /// + /// Left. + /// + /// 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)] + Left, + /// + /// Right. + /// + /// 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)] + Right, + } + + /// + /// Header text string in DropDown. + /// + /// 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 string HeaderText + { + get + { + return dropDownAttributes.HeaderTextAttributes?.Text.All; + } + set + { + if (value != null) + { + CreateHeaderTextAttributes(); + if (dropDownAttributes.HeaderTextAttributes.Text == null) + { + dropDownAttributes.HeaderTextAttributes.Text = new StringSelector(); + } + dropDownAttributes.HeaderTextAttributes.Text.All = value; + RelayoutRequest(); + } + } + } + + /// + /// Header text point size in DropDown. + /// + /// 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 float HeaderTextPointSize + { + get + { + return dropDownAttributes.HeaderTextAttributes?.PointSize?.All ?? 0; + } + set + { + CreateHeaderTextAttributes(); + if (dropDownAttributes.HeaderTextAttributes.PointSize == null) + { + dropDownAttributes.HeaderTextAttributes.PointSize = new FloatSelector(); + } + dropDownAttributes.HeaderTextAttributes.PointSize.All = value; + RelayoutRequest(); + } + } + + /// + /// Header text font family in DropDown. + /// + /// 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 string HeaderTextFontFamily + { + get + { + return dropDownAttributes.HeaderTextAttributes?.FontFamily; + } + set + { + CreateHeaderTextAttributes(); + dropDownAttributes.HeaderTextAttributes.FontFamily = value; + RelayoutRequest(); + } + } + + /// + /// Header text color in DropDown. + /// + /// 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 Color HeaderTextColor + { + get + { + return dropDownAttributes.HeaderTextAttributes?.TextColor?.All; + } + set + { + CreateHeaderTextAttributes(); + if (dropDownAttributes.HeaderTextAttributes.TextColor == null) + { + dropDownAttributes.HeaderTextAttributes.TextColor = new ColorSelector(); + } + dropDownAttributes.HeaderTextAttributes.TextColor.All = value; + RelayoutRequest(); + } + } + + /// + /// Header text color selector in DropDown. + /// + /// 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 ColorSelector HeaderTextColorSelector + { + get + { + return dropDownAttributes.HeaderTextAttributes?.TextColor; + } + set + { + CreateHeaderTextAttributes(); + if (value != null) + { + dropDownAttributes.HeaderTextAttributes.TextColor = value.Clone() as ColorSelector; + RelayoutRequest(); + } + } + } + + /// + /// Button text string in DropDown. + /// + /// 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 string ButtonText + { + get + { + return dropDownAttributes.ButtonAttributes?.TextAttributes?.Text.All; + } + set + { + if (value != null) + { + CreateButtonTextAttributes(); + if (dropDownAttributes.ButtonAttributes.TextAttributes.Text == null) + { + dropDownAttributes.ButtonAttributes.TextAttributes.Text = new StringSelector(); + } + dropDownAttributes.ButtonAttributes.TextAttributes.Text.All = value; + RelayoutRequest(); + } + } + } + + /// + /// Button text point size in DropDown. + /// + /// 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 float ButtonTextPointSize + { + get + { + return dropDownAttributes.ButtonAttributes?.TextAttributes?.PointSize?.All ?? 0; + } + set + { + CreateButtonTextAttributes(); + if (dropDownAttributes.ButtonAttributes.TextAttributes.PointSize == null) + { + dropDownAttributes.ButtonAttributes.TextAttributes.PointSize = new FloatSelector(); + } + dropDownAttributes.ButtonAttributes.TextAttributes.PointSize.All = value; + RelayoutRequest(); + } + } + + /// + /// Button text font family in DropDown. + /// + /// 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 string ButtonTextFontFamily + { + get + { + return dropDownAttributes.ButtonAttributes?.TextAttributes?.FontFamily; + } + set + { + CreateButtonTextAttributes(); + dropDownAttributes.ButtonAttributes.TextAttributes.FontFamily = value; + RelayoutRequest(); + } + } + + /// + /// Button text color in DropDown. + /// + /// 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 Color ButtonTextColor + { + get + { + return dropDownAttributes.ButtonAttributes?.TextAttributes?.TextColor?.All; + } + set + { + CreateButtonTextAttributes(); + if (dropDownAttributes.ButtonAttributes.TextAttributes.TextColor == null) + { + dropDownAttributes.ButtonAttributes.TextAttributes.TextColor = new ColorSelector(); + } + dropDownAttributes.ButtonAttributes.TextAttributes.TextColor.All = value; + RelayoutRequest(); + } + } + + /// + /// Button text color selector in DropDown. + /// + /// 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 ColorSelector ButtonTextColorSelector + { + get + { + return dropDownAttributes.ButtonAttributes?.TextAttributes?.TextColor; + } + set + { + CreateButtonTextAttributes(); + if (value != null) + { + dropDownAttributes.ButtonAttributes.TextAttributes.TextColor = value.Clone() as ColorSelector; + RelayoutRequest(); + } + } + } + + /// + /// Button icon image's resource url in DropDown. + /// + /// 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 string ButtonIconImageURL + { + get + { + return dropDownAttributes.ButtonAttributes?.IconAttributes?.ResourceUrl.All; + } + set + { + if (value != null) + { + CreateButtonIconAttributes(); + if (dropDownAttributes.ButtonAttributes.IconAttributes.ResourceUrl == null) + { + dropDownAttributes.ButtonAttributes.IconAttributes.ResourceUrl = new StringSelector(); + } + dropDownAttributes.ButtonAttributes.IconAttributes.ResourceUrl.All = value; + RelayoutRequest(); + } + } + } + + /// + /// Button icon image's size in DropDown. + /// + /// 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 Size2D ButtonIconSize2D + { + get + { + return dropDownAttributes.ButtonAttributes?.IconAttributes?.Size2D; + } + set + { + if (value != null) + { + CreateButtonIconAttributes(); + dropDownAttributes.ButtonAttributes.IconAttributes.Size2D = value; + RelayoutRequest(); + } + } + } + + /// + /// Space between button text and button icon in DropDown. + /// + /// 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 int SpaceBetweenButtonTextAndIcon + { + get + { + return dropDownAttributes.SpaceBetweenButtonTextAndIcon; + } + set + { + dropDownAttributes.SpaceBetweenButtonTextAndIcon = value; + RelayoutRequest(); + } + } + + /// + /// Left space in DropDown. + /// + /// 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 int LeftSpace + { + get + { + return (int)dropDownAttributes.Space.X; + } + set + { + dropDownAttributes.Space.X = value; + RelayoutRequest(); + } + } + + /// + /// Right space in DropDown. + /// + /// 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 int RightSpace + { + get + { + return (int)dropDownAttributes.Space.Y; + } + set + { + dropDownAttributes.Space.Y = value; + RelayoutRequest(); + } + } + + /// + /// List background image's resource url in DropDown. + /// + /// 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 string ListBackgroundImageURL + { + get + { + return dropDownAttributes.ListBackgroundImageAttributes?.ResourceUrl?.All; + } + set + { + if (value != null) + { + CreateListBackgroundAttributes(); + if (dropDownAttributes.ListBackgroundImageAttributes.ResourceUrl == null) + { + dropDownAttributes.ListBackgroundImageAttributes.ResourceUrl = new StringSelector(); + } + dropDownAttributes.ListBackgroundImageAttributes.ResourceUrl.All = value; + RelayoutRequest(); + } + } + } + + /// + /// List background image's border in DropDown. + /// + /// 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 Rectangle ListBackgroundImageBorder + { + get + { + return dropDownAttributes.ListBackgroundImageAttributes?.Border?.All; + } + set + { + if (value != null) + { + CreateListBackgroundAttributes(); + if (dropDownAttributes.ListBackgroundImageAttributes.Border == null) + { + dropDownAttributes.ListBackgroundImageAttributes.Border = new RectangleSelector(); + } + dropDownAttributes.ListBackgroundImageAttributes.Border.All = value; + RelayoutRequest(); + } + } + } + + /// + /// List relative orientation in DropDown. + /// + /// 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 ListOrientation ListRelativeOrientation + { + get + { + return dropDownAttributes.ListRelativeOrientation; + } + set + { + dropDownAttributes.ListRelativeOrientation = value; + RelayoutRequest(); + } + } + + /// + /// Left space in list. + /// + /// 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 int ListLeftMargin + { + get + { + return (int)dropDownAttributes.ListMargin.X; + } + set + { + dropDownAttributes.ListMargin.X = value; + RelayoutRequest(); + } + } + + /// + /// Right space in list. + /// + /// 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 int ListRigthMargin + { + get + { + return (int)dropDownAttributes.ListMargin.Y; + } + set + { + dropDownAttributes.ListMargin.Y = value; + RelayoutRequest(); + } + } + + /// + /// Top space in list. + /// + /// 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 int ListTopMargin + { + get + { + return (int)dropDownAttributes.ListMargin.Z; + } + set + { + dropDownAttributes.ListMargin.Z = value; + RelayoutRequest(); + } + } + + /// + /// Focused item index in list. + /// + /// 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 int FocusedItemIndex + { + get + { + return dropDownAttributes.FocusedItemIndex; + } + set + { + dropDownAttributes.FocusedItemIndex = value; + RelayoutRequest(); + } + } + + /// + /// Selected item index in list. + /// + /// 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 int SelectedItemIndex + { + get + { + return selectedItemIndex; + } + set + { + if (value == selectedItemIndex || adapter == null || value >= adapter.GetItemCount()) + { + return; + } + UpdateSelectedItem(value); + } + } + + /// + /// List size in DropDown. + /// + /// 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 Size2D ListSize2D + { + get + { + return dropDownAttributes.ListSize2D; + } + set + { + dropDownAttributes.ListSize2D = value; + RelayoutRequest(); + } + } + + /// + /// List padding in DropDown. + /// + /// 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 Extents ListPadding + { + get + { + return dropDownAttributes.ListPadding; + } + set + { + dropDownAttributes.ListPadding = value; + RelayoutRequest(); + } + } + + /// + /// Add list item by item data. The added item will be added to end of all items automatically. + /// + /// Item data which will apply to tab item view. + /// 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 void AddItem(DropDownItemData itemData) + { + adapter.InsertData(-1, itemData); + } + + /// + /// Delete list item by index. + /// + /// Position index where will be deleted. + /// 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 void DeleteItem(int index) + { + if(index < 0 || index >= adapter.GetItemCount()) + { + return; + } + + if (selectedItemIndex == index) + { + selectedItemIndex = -1; + } + else if(selectedItemIndex > index) + { + selectedItemIndex--; + } + + adapter.RemoveData(index); + } + + /// + /// Insert list item by item data. The inserted item will be added to the special position by index automatically. + /// + /// Item data which will apply to tab item view. + /// Position index where will be inserted. + /// 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 void InsertItem(DropDownItemData item, int index) + { + if (index < 0 || index >= adapter.GetItemCount()) + { + return; + } + + if (selectedItemIndex >= index) + { + selectedItemIndex++; + } + + adapter.InsertData(index, item); + } + + /// + /// Add scroll bar to list. + /// + /// Scroll bar defined by user which will be added to list. + /// 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 void AttachScrollBar(ScrollBar scrollBar) + { + if (list == null) + { + return; + } + list.AttachScrollBar(scrollBar); + } + + /// + /// Detach scroll bar to list. + /// + /// 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 void DetachScrollBar() + { + if (list == null) + { + return; + } + list.DetachScrollBar(); + } + + /// + /// Update DropDown by attributes. + /// + /// 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 OnUpdate() + { + if (dropDownAttributes.HeaderTextAttributes != null) + { + if (headerText == null) + { + CreateHeaderText(); + } + ApplyAttributes(headerText, dropDownAttributes.HeaderTextAttributes); + } + + + if (dropDownAttributes.ButtonAttributes != null) + { + if (button == null) + { + CreateButton(); + } + if (dropDownAttributes.Space != null) + { + button.Position2D.X = (int)dropDownAttributes.Space.X; + } + + if (dropDownAttributes.ButtonAttributes.TextAttributes != null) + { + ApplyAttributes(buttonText, dropDownAttributes.ButtonAttributes.TextAttributes); + button.TextSelector = dropDownAttributes.ButtonAttributes.TextAttributes.Text; + if (dropDownAttributes.ButtonAttributes.TextAttributes.PointSize != null) + { + button.PointSize = dropDownAttributes.ButtonAttributes.TextAttributes.PointSize.All.Value; + } + button.FontFamily = dropDownAttributes.ButtonAttributes.TextAttributes.FontFamily; + button.TextColorSelector = dropDownAttributes.ButtonAttributes.TextAttributes.TextColor; + } + if (dropDownAttributes.ButtonAttributes.IconAttributes != null) + { + button.IconURLSelector = dropDownAttributes.ButtonAttributes.IconAttributes.ResourceUrl; + int iconWidth = 0; + int buttonTextWidth = 0; + if (dropDownAttributes.ButtonAttributes.IconAttributes.Size2D != null) + { + iconWidth = dropDownAttributes.ButtonAttributes.IconAttributes.Size2D.Width; + } + if (buttonText.NaturalSize2D != null) + { + buttonTextWidth = buttonText.NaturalSize2D.Width; + } + button.SizeWidth = iconWidth + dropDownAttributes.SpaceBetweenButtonTextAndIcon + buttonTextWidth; + } + } + + if (dropDownAttributes.ListBackgroundImageAttributes != null) + { + if (listBackgroundImage == null) + { + CreateListBackgroundImage(); + CreateList(); + } + ApplyAttributes(listBackgroundImage, dropDownAttributes.ListBackgroundImageAttributes); + list.FocusedItemIndex = dropDownAttributes.FocusedItemIndex; + list.Size2D = dropDownAttributes.ListSize2D; + list.Padding = dropDownAttributes.ListPadding; + + int listBackgroundImageX = 0; + int listBackgroundImageY = 0; + if (dropDownAttributes.ListRelativeOrientation == ListOrientation.Left) + { + if (dropDownAttributes.ListMargin != null) + { + listBackgroundImageX = (int)dropDownAttributes.ListMargin.X; + listBackgroundImageY = (int)dropDownAttributes.ListMargin.Z; + } + } + else if (dropDownAttributes.ListRelativeOrientation == ListOrientation.Right) + { + if (dropDownAttributes.ListMargin != null) + { + int listWidth = 0; + if (list.Size2D != null) + { + listWidth = list.Size2D.Width; + } + listBackgroundImageX = Size2D.Width - listWidth - (int)dropDownAttributes.ListMargin.Y; + listBackgroundImageY = (int)dropDownAttributes.ListMargin.Z; + } + } + listBackgroundImage.Position2D = new Position2D(listBackgroundImageX, listBackgroundImageY); + } + } + + /// + /// Dispose DropDown and all children on it. + /// + /// Dispose type. + /// 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 Dispose(DisposeTypes type) + { + if (disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) + { + if (headerText != null) + { + Utility.Dispose(headerText); + } + + if (buttonText != null) + { + Utility.Dispose(buttonText); + } + + if (button != null) + { + Utility.Dispose(button); + } + + if (list != null) + { + if (listBackgroundImage != null) + { + Utility.Dispose(listBackgroundImage); + } + + Utility.Dispose(list); + } + } + + base.Dispose(type); + } + + /// + /// Get DropDown attribues. + /// + /// 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 Attributes GetAttributes() + { + return new DropDownAttributes(); + } + + private void Initialize() + { + dropDownAttributes = attributes as DropDownAttributes; + if (dropDownAttributes == null) + { + throw new Exception("DropDown attribute parse error."); + } + ApplyAttributes(this, dropDownAttributes); + } + + private void OnClickEvent(object sender, ItemClickEventArgs e) + { + ItemClickEvent?.Invoke(sender, e); + } + + private void CreateHeaderText() + { + headerText = new TextLabel(); + headerText.Name = "DropDownHeaderText"; + Add(headerText); + } + + private void CreateButton() + { + button = new Button() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft, + HeightResizePolicy = ResizePolicyType.FillToParent, + IconRelativeOrientation = Button.IconOrientation.Right, + }; + button.Name = "DropDownButton"; + button.ClickEvent += ButtonClickEvent; + Add(button); + + buttonText = new TextLabel() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft, + WidthResizePolicy = ResizePolicyType.UseNaturalSize, + HeightResizePolicy = ResizePolicyType.FillToParent, + }; + buttonText.Name = "DropDownButtonText"; + Add(buttonText); + buttonText.Hide(); + } + + private void CreateList() + { + list = new FlexibleView(); + list.Name = "DropDownList"; + LinearLayoutManager layoutManager = new LinearLayoutManager(LinearLayoutManager.VERTICAL); + list.SetLayoutManager(layoutManager); + list.SetAdapter(adapter); + list.Focusable = true; + list.ItemTouchEvent += ListItemTouchEvent; + list.ItemClickEvent += ListItemClickEvent; + listBackgroundImage.Add(list); + listBackgroundImage.Hide(); + } + + private void ListItemClickEvent(object sender, FlexibleView.ItemClickEventArgs e) + { + if (e.ClickedView != null) + { + UpdateSelectedItem(e.ClickedView.AdapterPosition); + + ItemClickEventArgs args = new ItemClickEventArgs(); + args.Index = e.ClickedView.AdapterPosition; + args.Text = (e.ClickedView.ItemView as DropDownItemView)?.Text; + OnClickEvent(this, args); + } + + listBackgroundImage.Hide(); + } + + private void ListItemTouchEvent(object sender, FlexibleView.ItemTouchEventArgs e) + { + PointStateType state = e.Touch.GetState(0); + switch (state) + { + case PointStateType.Down: + if (e.TouchedView != null) + { + touchedView = e.TouchedView.ItemView as DropDownItemView; + if (touchedView != null && touchedView.BackgroundColorSelector != null) + { + touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Pressed); + } + } + break; + case PointStateType.Motion: + if (touchedView != null && touchedView.BackgroundColorSelector != null) + { + touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Normal); + } + break; + case PointStateType.Up: + if (touchedView != null && touchedView.BackgroundColorSelector != null) + { + touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Selected); + } + break; + default: + break; + } + } + + private void UpdateSelectedItem(int index) + { + if (selectedItemIndex != -1) + { + DropDownItemData data = adapter.GetData(selectedItemIndex); + if(data != null) + { + data.IsSelected = false; + } + DropDownItemView view = list?.FindViewHolderForAdapterPosition(selectedItemIndex)?.ItemView as DropDownItemView; + if (view != null) + { + view.IsSelected = false; + } + } + + if (index != -1) + { + DropDownItemData data = adapter.GetData(index); + if (data != null) + { + data.IsSelected = true; + } + DropDownItemView view = list?.FindViewHolderForAdapterPosition(index)?.ItemView as DropDownItemView; + if (view != null) + { + view.IsSelected = true; + button.Text = view.Text; + } + } + + selectedItemIndex = index; + } + + private void CreateListBackgroundImage() + { + listBackgroundImage = new ImageView + { + Name = "ListBackgroundImage", + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft, + WidthResizePolicy = ResizePolicyType.FitToChildren, + HeightResizePolicy = ResizePolicyType.FitToChildren, + }; + Add(listBackgroundImage); + } + + private void ButtonClickEvent(object sender, Button.ClickEventArgs e) + { + listBackgroundImage.Show(); + } + + private void CreateHeaderTextAttributes() + { + if (dropDownAttributes.HeaderTextAttributes == null) + { + dropDownAttributes.HeaderTextAttributes = new TextAttributes() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + }; + } + } + + private void CreateButtonAttributes() + { + if (dropDownAttributes.ButtonAttributes == null) + { + dropDownAttributes.ButtonAttributes = new ButtonAttributes(); + } + } + + private void CreateButtonTextAttributes() + { + CreateButtonAttributes(); + + if (dropDownAttributes.ButtonAttributes.TextAttributes == null) + { + dropDownAttributes.ButtonAttributes.TextAttributes = new TextAttributes + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft, + WidthResizePolicy = ResizePolicyType.UseNaturalSize, + HeightResizePolicy = ResizePolicyType.FillToParent, + Position2D = new Position2D(0, 0), + HorizontalAlignment = HorizontalAlignment.Begin, + VerticalAlignment = VerticalAlignment.Center, + }; + } + } + + private void CreateButtonIconAttributes() + { + CreateButtonAttributes(); + + if (dropDownAttributes.ButtonAttributes.IconAttributes == null) + { + dropDownAttributes.ButtonAttributes.IconAttributes = new ImageAttributes + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.CenterRight, + PivotPoint = Tizen.NUI.PivotPoint.CenterRight, + }; + } + } + + private void CreateListBackgroundAttributes() + { + if (dropDownAttributes.ListBackgroundImageAttributes == null) + { + dropDownAttributes.ListBackgroundImageAttributes = new ImageAttributes + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft, + }; + } + } + #endregion + + #region ItemClickEventArgs + /// + /// ItemClickEventArgs is a class to record item click event arguments which will sent to user. + /// + /// 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 class ItemClickEventArgs : EventArgs + { + /// Clicked item index of DropDown's list + /// 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 int Index; + /// Clicked item text string of DropDown's list + /// 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 string Text; + } + #endregion + + #region DropDownItemData + /// + /// DropDownItemData is a class to record all data which will be applied to DropDown item. + /// + /// 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 class DropDownItemData + { + private DropDownItemAttributes itemDataAttributes = new DropDownItemAttributes(); + + /// + /// Creates a new instance of a DropDownItemData. + /// + /// 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 DropDownItemData() + { + Initalize(); + } + + /// + /// Creates a new instance of a DropDownItemData with style. + /// + /// Create DropDownItemData by special style defined in UX. + /// 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 DropDownItemData(string style) + { + if(style != null) + { + Attributes attributes = StyleManager.Instance.GetAttributes(style); + if(attributes == null) + { + throw new InvalidOperationException($"There is no style {style}"); + } + itemDataAttributes = attributes as DropDownItemAttributes; + } + Initalize(); + } + + /// + /// Creates a new instance of a DropDownItemData with attributes. + /// + /// Create DropDownItemData by attributes customized by user. + /// 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 DropDownItemData(DropDownItemAttributes attributes) + { + itemDataAttributes = attributes.Clone() as DropDownItemAttributes; + Initalize(); + } + + /// + /// DropDown item 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 Size2D Size2D + { + get + { + return itemDataAttributes.Size2D; + } + set + { + itemDataAttributes.Size2D = value; + } + } + + /// + /// DropDown item background color selector. + /// + /// 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 ColorSelector BackgroundColorSelector + { + get + { + return itemDataAttributes.BackgroundColor; + } + set + { + if (itemDataAttributes.BackgroundColor == null) + { + itemDataAttributes.BackgroundColor = value.Clone() as ColorSelector; + } + else + { + itemDataAttributes.BackgroundColor = value.Clone(); + } + + } + } + + /// + /// DropDown item text string. + /// + /// 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 string Text + { + get + { + return itemDataAttributes.TextAttributes?.Text?.All; + } + set + { + CreateTextAttributes(); + if (itemDataAttributes.TextAttributes.Text == null) + { + itemDataAttributes.TextAttributes.Text = new StringSelector { All = value }; + } + else + { + itemDataAttributes.TextAttributes.Text.All = value; + } + } + } + + /// + /// DropDown item text's point 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 float PointSize + { + get + { + return itemDataAttributes.TextAttributes?.PointSize?.All ?? 0; + } + set + { + CreateTextAttributes(); + if (itemDataAttributes.TextAttributes.PointSize == null) + { + itemDataAttributes.TextAttributes.PointSize = new FloatSelector { All = value }; + } + else + { + itemDataAttributes.TextAttributes.PointSize.All = value; + } + } + } + + /// + /// DropDown item text's font family. + /// + /// 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 string FontFamily + { + get + { + return itemDataAttributes.TextAttributes?.FontFamily; + } + set + { + CreateTextAttributes(); + itemDataAttributes.TextAttributes.FontFamily = value; + } + } + + /// + /// DropDown item text's position. + /// + /// 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 Position2D TextPosition2D + { + get + { + return itemDataAttributes.TextAttributes?.Position2D; + } + set + { + CreateTextAttributes(); + itemDataAttributes.TextAttributes.Position2D = value; + } + } + + /// + /// DropDown item's icon's resource url. + /// + /// 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 string IconResourceUrl + { + get + { + return itemDataAttributes.IconAttributes?.ResourceUrl?.All; + } + set + { + CreateIconAttributes(); + if (itemDataAttributes.IconAttributes.ResourceUrl == null) + { + itemDataAttributes.IconAttributes.ResourceUrl = new StringSelector { All = value }; + } + else + { + itemDataAttributes.IconAttributes.ResourceUrl.All = value; + } + } + } + + /// + /// DropDown item's icon's 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 Size2D IconSize2D + { + get + { + return itemDataAttributes.IconAttributes?.Size2D; + } + set + { + CreateIconAttributes(); + itemDataAttributes.IconAttributes.Size2D = value; + } + } + + /// + /// DropDown item's icon's position. + /// + /// 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 Position2D IconPosition2D + { + get + { + return itemDataAttributes.IconAttributes.Position2D; + } + set + { + CreateIconAttributes(); + itemDataAttributes.IconAttributes.Position2D = value; + } + } + + /// + /// DropDown item's check image's resource url. + /// + /// 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 string CheckImageResourceUrl + { + get + { + return itemDataAttributes.CheckImageAttributes?.ResourceUrl?.All; + } + set + { + CreateCheckImageAttributes(); + if (itemDataAttributes.CheckImageAttributes.ResourceUrl == null) + { + itemDataAttributes.CheckImageAttributes.ResourceUrl = new StringSelector { All = value }; + } + else + { + itemDataAttributes.CheckImageAttributes.ResourceUrl.All = value; + } + } + } + + /// + /// DropDown item's check image's 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 Size2D CheckImageSize2D + { + get + { + return itemDataAttributes.CheckImageAttributes?.Size2D; + } + set + { + CreateCheckImageAttributes(); + itemDataAttributes.CheckImageAttributes.Size2D = value; + } + } + + /// + /// DropDown item's check image's right space. + /// + /// 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 int CheckImageRightSpace + { + get + { + return itemDataAttributes.CheckImageRightSpace; + } + set + { + itemDataAttributes.CheckImageRightSpace = value; + } + } + + /// + /// Flag to decide DropDown item is selected or not. + /// + /// 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 bool IsSelected + { + get + { + return itemDataAttributes.IsSelected; + } + set + { + itemDataAttributes.IsSelected = value; + } + } + + private void Initalize() + { + if (itemDataAttributes == null) + { + throw new Exception("Button attribute parse error."); + } + } + + private void CreateTextAttributes() + { + if(itemDataAttributes.TextAttributes == null) + { + itemDataAttributes.TextAttributes = new TextAttributes + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft, + WidthResizePolicy = ResizePolicyType.UseNaturalSize, + HeightResizePolicy = ResizePolicyType.FillToParent, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Begin, + }; + } + } + + private void CreateIconAttributes() + { + if (itemDataAttributes.IconAttributes == null) + { + itemDataAttributes.IconAttributes = new ImageAttributes + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft, + }; + } + } + + private void CreateCheckImageAttributes() + { + if (itemDataAttributes.CheckImageAttributes == null) + { + itemDataAttributes.CheckImageAttributes = new ImageAttributes + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft, + }; + } + } + } + #endregion + + #region DropDownItemView + /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + internal class DropDownItemView : Control + { + private TextLabel mText = null; + private ImageView mIcon = null; + private ImageView mCheck = null; + + /// 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 DropDownItemView() : base() + { + } + + /// 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 ColorSelector BackgroundColorSelector + { + get; + set; + } + + /// 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 string Text + { + get + { + if(mText == null) + { + return null; + } + return mText.Text; + } + set + { + CreateText(); + mText.Text = value; + } + } + + /// 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 string FontFamily + { + get + { + if (mText == null) + { + return null; + } + return mText.FontFamily; + } + set + { + CreateText(); + mText.FontFamily = value; + } + } + + /// 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 float PointSize + { + get + { + if (mText == null) + { + return 0; + } + return mText.PointSize; + } + set + { + CreateText(); + mText.PointSize = value; + } + } + + /// 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 Color TextColor + { + get + { + if (mText == null) + { + return null; + } + return mText.TextColor; + } + set + { + CreateText(); + mText.TextColor = value; + } + } + + /// 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 Position2D TextPosition2D + { + get + { + if (mText == null) + { + return null; + } + return mText.Position2D; + } + set + { + CreateText(); + mText.Position2D = value; + } + } + + /// 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 string IconResourceUrl + { + get + { + if (mIcon == null) + { + return null; + } + return mIcon.ResourceUrl; + } + set + { + CreateIcon(); + mIcon.ResourceUrl = value; + } + } + + /// 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 Size2D IconSize2D + { + get + { + if (mIcon == null) + { + return null; + } + return mIcon.Size2D; + } + set + { + CreateIcon(); + mIcon.Size2D = value; + } + } + + /// 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 Position2D IconPosition2D + { + get + { + if (mIcon == null) + { + return null; + } + return mIcon.Position2D; + } + set + { + CreateIcon(); + mIcon.Position2D = value; + } + } + + /// 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 string CheckResourceUrl + { + get + { + if (mCheck == null) + { + return null; + } + return mCheck.ResourceUrl; + } + set + { + CreateCheckImage(); + mCheck.ResourceUrl = value; + } + } + + /// 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 Position2D CheckPosition2D + { + get + { + if (mCheck == null) + { + return null; + } + return mCheck.Position2D; + } + set + { + CreateCheckImage(); + mCheck.Position2D = value; + } + } + + /// 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 Size2D CheckImageSize2D + { + get + { + if (mCheck == null) + { + return null; + } + return mCheck.Size2D; + } + set + { + CreateCheckImage(); + mCheck.Size2D = value; + } + } + + /// 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 bool IsSelected + { + get + { + if (mCheck == null) + { + return false; + } + return mCheck.Visibility; + } + set + { + CreateCheckImage(); + if(value) + { + mCheck.Show(); + } + else + { + mCheck.Hide(); + } + } + } + + /// 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 Dispose(DisposeTypes type) + { + if (disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) + { + if (mText != null) + { + Remove(mText); + mText.Dispose(); + mText = null; + } + + if (mIcon != null) + { + Remove(mIcon); + mIcon.Dispose(); + mIcon = null; + } + + if (mCheck != null) + { + Remove(mCheck); + mCheck.Dispose(); + mCheck = null; + } + } + base.Dispose(type); + } + + /// 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 Attributes GetAttributes() + { + return null; + } + + private void CreateIcon() + { + if(mIcon == null) + { + mIcon = new ImageView() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft, + }; + Add(mIcon); + } + } + + private void CreateText() + { + if (mText == null) + { + mText = new TextLabel() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft, + WidthResizePolicy = ResizePolicyType.UseNaturalSize, + HeightResizePolicy = ResizePolicyType.FillToParent, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Begin, + }; + Add(mText); + } + } + + private void CreateCheckImage() + { + if (mCheck == null) + { + mCheck = new ImageView() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft, + }; + Add(mCheck); + } + mCheck.Hide(); + } + } + #endregion + + #region DropDownListBridge + + /// + /// DropDownListBridge is bridge to contact item data and item view. + /// + /// 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 class DropDownListBridge : FlexibleView.Adapter + { + private List mDatas = new List(); + + /// + /// Creates a new instance of a DropDownListBridge. + /// + /// 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 DropDownListBridge() + { + } + + /// + /// Insert data. The inserted data will be added to the special position by index automatically. + /// + /// Position index where will be inserted. + /// Item data which will apply to tab item view. + /// 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 void InsertData(int position, DropDownItemData data) + { + if(position == -1) + { + position = mDatas.Count; + } + mDatas.Insert(position, data); + NotifyItemInserted(position); + } + + /// + /// Remove data by position. + /// + /// Position index where will be removed. + /// 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 void RemoveData(int position) + { + mDatas.RemoveAt(position); + NotifyItemRemoved(position); + } + + /// + /// Get data by position. + /// + /// Position index where will be gotten. + /// 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 DropDownItemData GetData(int position) + { + return mDatas[position]; + } + + /// + /// Get view holder by view type. + /// + /// Create item view. + /// 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 FlexibleView.ViewHolder OnCreateViewHolder(int viewType) + { + FlexibleView.ViewHolder viewHolder = new FlexibleView.ViewHolder(new DropDownItemView()); + + return viewHolder; + } + + /// + /// Binder view holder, it can be override. + /// + /// View holder. + /// Position index where will be gotten. + /// 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 OnBindViewHolder(FlexibleView.ViewHolder holder, int position) + { + DropDownItemData listItemData = mDatas[position]; + if(listItemData == null) + { + return; + } + DropDownItemView listItemView = holder.ItemView as DropDownItemView; + listItemView.Name = "Item" + position; + if (listItemData.Size2D != null) + { + holder.ItemView.Size2D = listItemData.Size2D; + } + + if (listItemView != null) + { + listItemView.BackgroundColorSelector = listItemData.BackgroundColorSelector; + if (listItemData.Text != null) + { + listItemView.Text = listItemData.Text; + listItemView.PointSize = listItemData.PointSize; + listItemView.FontFamily = listItemData.FontFamily; + listItemView.TextPosition2D = listItemData.TextPosition2D; + } + + if (listItemData.IconResourceUrl != null) + { + listItemView.IconResourceUrl = listItemData.IconResourceUrl; + listItemView.IconSize2D = listItemData.IconSize2D; + listItemView.IconPosition2D = new Position2D(listItemData.IconPosition2D.X, (listItemView.Size2D.Height - listItemView.IconSize2D.Height) / 2); + } + + if (listItemData.CheckImageResourceUrl != null) + { + listItemView.CheckResourceUrl = listItemData.CheckImageResourceUrl; + listItemView.CheckImageSize2D = listItemData.CheckImageSize2D; + listItemView.CheckPosition2D = new Position2D(listItemView.Size2D.Width - listItemData.CheckImageRightSpace - listItemView.CheckImageSize2D.Width, (listItemView.Size2D.Height - listItemView.CheckImageSize2D.Height) / 2); + } + + listItemView.IsSelected = listItemData.IsSelected; + } + } + + /// + /// Destroy view holder, it can be override. + /// + /// View holder. + /// 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 OnDestroyViewHolder(FlexibleView.ViewHolder holder) + { + if (holder.ItemView != null) + { + holder.ItemView.Dispose(); + } + } + + /// + /// Get item count, it can be override. + /// + /// 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 int GetItemCount() + { + return mDatas.Count; + } + } + #endregion + } +} diff --git a/src/Tizen.NUI.CommonUI/Controls/FlexibleView/FlexibleView.cs b/src/Tizen.NUI.CommonUI/Controls/FlexibleView/FlexibleView.cs new file mode 100755 index 000000000..6a705b904 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Controls/FlexibleView/FlexibleView.cs @@ -0,0 +1,2526 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI.CommonUI +{ + /// + /// A flexible view for providing a limited window into a large data set. + /// + /// 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 class FlexibleView : Control + { + /// + /// Constant value: -1. + /// + /// 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 static readonly int NO_POSITION = -1; + /// + /// Constant value: -1. + /// + /// 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 static readonly int INVALID_TYPE = -1; + + private Adapter mAdapter; + private LayoutManager mLayout; + private Recycler mRecycler; + private RecycledViewPool mRecyclerPool; + private ChildHelper mChildHelper; + + private PanGestureDetector mPanGestureDetector; + + private int mFocusedItemIndex = NO_POSITION; + + private AdapterHelper mAdapteHelper; + + private ScrollBar mScrollBar = null; + private Timer mScrollBarShowTimer = null; + + private EventHandler clickEventHandlers; + private EventHandler touchEventHandlers; + + /// + /// Creates a FlexibleView 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 FlexibleView() + { + mRecyclerPool = new RecycledViewPool(this); + + mRecycler = new Recycler(this); + mRecycler.SetRecycledViewPool(mRecyclerPool); + + mChildHelper = new ChildHelper(this); + + mPanGestureDetector = new PanGestureDetector(); + mPanGestureDetector.Attach(this); + mPanGestureDetector.Detected += OnPanGestureDetected; + + mAdapteHelper = new AdapterHelper(this); + + ClippingMode = ClippingModeType.ClipToBoundingBox; + } + + /// + /// Item click event. + /// + /// 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 ItemClickEvent + { + add + { + clickEventHandlers += value; + } + + remove + { + clickEventHandlers -= value; + } + } + + + /// + /// Item touch event. + /// + /// 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 ItemTouchEvent + { + add + { + touchEventHandlers += value; + } + + remove + { + touchEventHandlers -= value; + } + } + + /// + /// overwrite the Padding. + /// + /// 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 new Extents Padding + { + get; + set; + } + + /// + /// Gets or sets the focused item index(adapter position). + /// + /// 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 int FocusedItemIndex + { + get + { + return mFocusedItemIndex; + } + set + { + if (value == mFocusedItemIndex) + { + return; + } + + if (mAdapter == null) + { + return; + } + + if (mLayout == null) + { + return; + } + + ViewHolder nextFocusView = FindViewHolderForAdapterPosition(value); + if (nextFocusView == null) + { + mLayout.ScrollToPosition(value); + } + else + { + mLayout.RequestChildRectangleOnScreen(this, nextFocusView, mRecycler, true); + DispatchFocusChanged(value); + } + } + } + + /// + /// Set a new adapter to provide child views on demand. + /// + /// 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 void SetAdapter(Adapter adapter) + { + if (adapter == null) + { + return; + } + mAdapter = adapter; + + mAdapter.ItemEvent += OnItemEvent; + } + + /// + /// Retrieves the previously set adapter or null if no adapter is set. + /// + /// 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 Adapter GetAdapter() + { + return mAdapter; + } + + /// + /// Set the FlexibleView.LayoutManager that this FlexibleView will use. + /// + /// 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 void SetLayoutManager(LayoutManager layoutManager) + { + mLayout = layoutManager; + + mLayout.SetRecyclerView(this); + + if (mLayout.CanScrollHorizontally()) + { + mPanGestureDetector.AddDirection(PanGestureDetector.DirectionHorizontal); + } + else if (mLayout.CanScrollVertically()) + { + mPanGestureDetector.AddDirection(PanGestureDetector.DirectionVertical); + } + } + + /// + /// Return the FlexibleView.LayoutManager currently responsible for layout policy for this FlexibleView. + /// + /// 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 LayoutManager GetLayoutManager() + { + return mLayout; + } + + + /// + /// Convenience method to scroll to a certain position + /// + /// Adapter position + /// The distance (in pixels) between the start edge of the item view and start edge of the FlexibleView. + /// 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 void ScrollToPositionWithOffset(int position, int offset) + { + mLayout.ScrollToPositionWithOffset(position, offset); + } + + /// + /// Move focus by direction. + /// + /// Direction. Should be "Left", "Right", "Up" or "Down" + /// 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 void MoveFocus(FlexibleView.LayoutManager.Direction direction) + { + mLayout.MoveFocus(direction, mRecycler); + } + + /// + /// Attach a scrollbar to this FlexibleView. + /// + /// ScrollBar + /// 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 void AttachScrollBar(ScrollBar scrollBar) + { + if (scrollBar == null) + { + return; + } + mScrollBar = scrollBar; + Add(mScrollBar); + } + + /// + /// Detach the scrollbar from this FlexibleView. + /// + /// 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 void DetachScrollBar() + { + if (mScrollBar == null) + { + return; + } + Remove(mScrollBar); + mScrollBar = null; + } + + /// + /// Return the ViewHolder for the item in the given position of the data set as of the latest layout pass. + /// This method checks only the children of RecyclerView. If the item at the given position is not laid out, it will not create a new one. + /// + /// The position of the item in the data set of the adapter + /// 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 ViewHolder FindViewHolderForLayoutPosition(int position) + { + int childCount = mChildHelper.GetChildCount(); + for (int i = 0; i < childCount; i++) + { + if (mChildHelper.GetChildAt(i) is ViewHolder holder) + { + if (holder.LayoutPosition == position) + { + return holder; + } + } + } + + return null; + } + + /// + /// Return the ViewHolder for the item in the given position of the data set. + /// This method checks only the children of RecyclerView. If the item at the given position is not laid out, it will not create a new one. + /// + /// The position of the item in the data set of the adapter + /// 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 ViewHolder FindViewHolderForAdapterPosition(int position) + { + int childCount = mChildHelper.GetChildCount(); + for (int i = 0; i < childCount; i++) + { + if (mChildHelper.GetChildAt(i) is ViewHolder holder) + { + if (holder.AdapterPosition == position) + { + return holder; + } + } + } + + return null; + } + + /// + /// you can override it to clean-up your own resources. + /// + /// DisposeTypes + /// 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 Dispose(DisposeTypes type) + { + if (disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) + { + if (mAdapter != null) + { + mAdapter.ItemEvent -= OnItemEvent; + } + + if (mPanGestureDetector != null) + { + mPanGestureDetector.Detected -= OnPanGestureDetected; + mPanGestureDetector.Dispose(); + mPanGestureDetector = null; + } + + if (mScrollBarShowTimer != null) + { + mScrollBarShowTimer.Tick -= OnShowTimerTick; + mScrollBarShowTimer.Stop(); + mScrollBarShowTimer.Dispose(); + mScrollBarShowTimer = null; + } + + if (mRecyclerPool != null) + { + mRecyclerPool.Clear(); + mRecyclerPool = null; + } + + if (mChildHelper != null) + { + mChildHelper.Clear(); + mChildHelper = null; + } + } + base.Dispose(type); + } + + /// + /// you can override it to create your own default attributes. + /// + /// 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 Attributes GetAttributes() + { + return null; + } + + /// + /// you can override it to relayout elements. + /// + /// 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 OnRelayout(Vector2 size, RelayoutContainer container) + { + if (mAdapter == null) + { + return; + } + + if (mLayout == null) + { + return; + } + + DispatchLayoutStep1(); + + mLayout.OnLayoutChildren(mRecycler); + + RemoveAndRecycleScrapInt(); + } + + private void DispatchLayoutStep1() + { + ProcessAdapterUpdates(); + SaveOldPositions(); + ClearOldPositions(); + } + + private void ProcessAdapterUpdates() + { + mAdapteHelper.PreProcess(); + } + + private void OffsetPositionRecordsForInsert(int positionStart, int itemCount) + { + int childCount = mChildHelper.GetChildCount(); + for (int i = 0; i < childCount; i++) + { + ViewHolder holder = mChildHelper.GetChildAt(i); + if (holder != null && holder.AdapterPosition >= positionStart) + { + holder.OffsetPosition(itemCount, false); + } + } + + if (positionStart <= mFocusedItemIndex) + { + mFocusedItemIndex += itemCount; + } + } + + private void OffsetPositionRecordsForRemove(int positionStart, int itemCount, bool applyToPreLayout) + { + int positionEnd = positionStart + itemCount; + int childCount = mChildHelper.GetChildCount(); + for (int i = 0; i < childCount; i++) + { + ViewHolder holder = mChildHelper.GetChildAt(i); + if (holder != null) + { + if (holder.AdapterPosition >= positionEnd) + { + holder.OffsetPosition(-itemCount, applyToPreLayout); + } + else if (holder.AdapterPosition >= positionStart) + { + holder.FlagRemovedAndOffsetPosition(positionStart - 1, -itemCount, applyToPreLayout); + } + } + } + + if (positionEnd <= mFocusedItemIndex) + { + mFocusedItemIndex -= itemCount; + } + else if (positionStart <= mFocusedItemIndex) + { + mFocusedItemIndex = positionStart; + if (mFocusedItemIndex >= mAdapter.GetItemCount()) + { + mFocusedItemIndex = mAdapter.GetItemCount() - 1; + } + } + } + + private void SaveOldPositions() + { + int childCount = mChildHelper.GetChildCount(); + for (int i = 0; i < childCount; i++) + { + ViewHolder holder = mChildHelper.GetChildAt(i); + holder.SaveOldPosition(); + } + } + + private void ClearOldPositions() + { + int childCount = mChildHelper.GetChildCount(); + for (int i = 0; i < childCount; i++) + { + ViewHolder holder = mChildHelper.GetChildAt(i); + holder.ClearOldPosition(); + } + } + + private void RemoveAndRecycleScrapInt() + { + int scrapCount = mRecycler.GetScrapCount(); + for (int i = 0; i < scrapCount; i++) + { + ViewHolder scrap = mRecycler.GetScrapViewAt(i); + mChildHelper.RemoveView(scrap); + mRecycler.RecycleView(scrap); + } + mRecycler.Clear(); + } + + private void ShowScrollBar(uint millisecond = 700, bool flagAni = false) + { + if (mScrollBar == null || mLayout == null) + { + return; + } + + float extent = mLayout.ComputeScrollExtent(); + float range = mLayout.ComputeScrollRange(); + if(range == 0) + { + return; + } + float offset = mLayout.ComputeScrollOffset(); + + float size = mScrollBar.Direction == ScrollBar.DirectionType.Vertical ? mScrollBar.SizeHeight : mScrollBar.SizeWidth; + float thickness = mScrollBar.Direction == ScrollBar.DirectionType.Vertical ? mScrollBar.SizeWidth : mScrollBar.SizeHeight; + float length = (float)Math.Round(size * extent / range); + + // avoid the tiny thumb + float minLength = thickness * 2; + if (length < minLength) + { + length = minLength; + } + // avoid the too-big thumb + if (offset > range - extent) + { + offset = range - extent; + } + if (mScrollBar.Direction == ScrollBar.DirectionType.Vertical) + { + mScrollBar.ThumbSize = new Size2D((int)thickness, (int)length); + } + else + { + mScrollBar.ThumbSize = new Size2D((int)length, (int)thickness); + } + mScrollBar.MinValue = 0; + mScrollBar.MaxValue = (int)(range - extent); + mScrollBar.SetCurrentValue((int)offset, flagAni); + mScrollBar.Show(); + if (mScrollBarShowTimer == null) + { + mScrollBarShowTimer = new Timer(millisecond); + mScrollBarShowTimer.Tick += OnShowTimerTick; + } + else + { + mScrollBarShowTimer.Interval = millisecond; + } + mScrollBarShowTimer.Start(); + } + + private bool OnShowTimerTick(object source, EventArgs e) + { + if (mScrollBar != null) + { + mScrollBar.Hide(); + } + + return false; + } + + private void DispatchFocusChanged(int nextFocusPosition) + { + mAdapter.OnFocusChange(this, mFocusedItemIndex, nextFocusPosition); + + mFocusedItemIndex = nextFocusPosition; + + ShowScrollBar(); + } + + private void DispatchChildAttached(ViewHolder holder) + { + if (mAdapter != null && holder != null) + { + mAdapter.OnViewAttachedToWindow(holder); + } + } + + private void DispatchChildDetached(ViewHolder holder) + { + if (mAdapter != null && holder != null) + { + mAdapter.OnViewDetachedFromWindow(holder); + } + } + + private void DispatchChildDestroyed(ViewHolder holder) + { + if (mAdapter != null && holder != null) + { + mAdapter.OnDestroyViewHolder(holder); + } + } + + private void DispatchItemClicked(ViewHolder clickedHolder) + { + ItemClickEventArgs args = new ItemClickEventArgs(); + args.ClickedView = clickedHolder; + OnClickEvent(this, args); + } + + private void DispatchItemTouched(ViewHolder touchedHolder, Touch touchEvent) + { + ItemTouchEventArgs args = new ItemTouchEventArgs(); + args.TouchedView = touchedHolder; + args.Touch = touchEvent; + OnTouchEvent(this, args); + } + + private void OnPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e) + { + if (e.PanGesture.State == Gesture.StateType.Started) + { + mLayout.StopScroll(); + } + else if (e.PanGesture.State == Gesture.StateType.Continuing) + { + if (mLayout.CanScrollVertically()) + { + mLayout.ScrollVerticallyBy(e.PanGesture.Displacement.Y, mRecycler, true); + } + else if (mLayout.CanScrollHorizontally()) + { + mLayout.ScrollHorizontallyBy(e.PanGesture.Displacement.X, mRecycler, true); + } + + ShowScrollBar(); + } + else if (e.PanGesture.State == Gesture.StateType.Finished) + { + if (mLayout.CanScrollVertically()) + { + mLayout.ScrollVerticallyBy(e.PanGesture.Velocity.Y * 600, mRecycler, false); + } + else if (mLayout.CanScrollHorizontally()) + { + mLayout.ScrollHorizontallyBy(e.PanGesture.Velocity.X * 600, mRecycler, false); + } + ShowScrollBar(1200, true); + } + } + + + private void OnItemEvent(object sender, Adapter.ItemEventArgs e) + { + switch (e.EventType) + { + case Adapter.ItemEventType.Insert: + mAdapteHelper.OnItemRangeInserted(e.param[0], e.param[1]); + ShowScrollBar(); + break; + case Adapter.ItemEventType.Remove: + mAdapteHelper.OnItemRangeRemoved(e.param[0], e.param[1]); + ShowScrollBar(); + break; + case Adapter.ItemEventType.Move: + break; + case Adapter.ItemEventType.Change: + break; + default: + return; + } + RelayoutRequest(); + } + + + private void OnClickEvent(object sender, ItemClickEventArgs e) + { + clickEventHandlers?.Invoke(sender, e); + } + + private void OnTouchEvent(object sender, ItemTouchEventArgs e) + { + touchEventHandlers?.Invoke(sender, e); + } + + /// + /// ItemClick Event Arguments. + /// + /// 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 class ItemClickEventArgs : EventArgs + { + /// + /// The clicked ViewHolder. + /// + /// 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 ViewHolder ClickedView; + } + + /// + /// ItemTouch Event Arguments. + /// + /// 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 class ItemTouchEventArgs : TouchEventArgs + { + /// + /// The touched ViewHolder. + /// + /// 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 ViewHolder TouchedView; + } + + /// + /// Adapters provide a binding from an app-specific data set to views that are displayed within a FlexibleView. + /// + /// 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 abstract class Adapter + { + private EventHandler itemEventHandlers; + + internal event EventHandler ItemEvent + { + add + { + itemEventHandlers += value; + } + + remove + { + itemEventHandlers -= value; + } + } + + internal enum ItemEventType + { + Insert = 0, + Remove, + Move, + Change + } + + /// + /// Called when FlexibleView needs a new FlexibleView.ViewHolder of the given type to represent an item. + /// + /// The view type of the new View + /// 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 abstract ViewHolder OnCreateViewHolder(int viewType); + + /// + /// Called by FlexibleView to display the data at the specified position. + /// + /// The ViewHolder which should be updated to represent the contents of the item at the given position in the data set. + /// The position of the item within the adapter's data set. + /// 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 abstract void OnBindViewHolder(ViewHolder holder, int position); + + /// + /// Called when a ViewHolder is never used. + /// + /// The ViewHolder which need to be disposed + /// 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 abstract void OnDestroyViewHolder(ViewHolder holder); + + /// + /// Returns the total number of items in the data set held by the adapter. + /// + /// 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 abstract int GetItemCount(); + + /// + /// Return the view type of the item at position for the purposes of view recycling. + /// + /// The position of the item within the adapter's data set. + /// 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 virtual int GetItemViewType(int position) + { + return 0; + } + + /// + /// Called by FlexibleView when it starts observing this Adapter. + /// Keep in mind that same adapter may be observed by multiple FlexibleView. + /// + /// The FlexibleView instance which started observing this adapter. + /// 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 virtual void OnAttachedToRecyclerView(FlexibleView flexibleView) + { + } + + /// + /// Called by FlexibleView when it stops observing this Adapter. + /// + /// The FlexibleView instance which stopped observing this adapter. + /// 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 virtual void OnDetachedFromRecyclerView(FlexibleView flexibleView) + { + } + + /// + /// Called when FlexibleView focus changed. + /// + /// The FlexibleView into which the focus ViewHolder changed. + /// The position of previous focus + /// The position of current focus + /// 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 virtual void OnFocusChange(FlexibleView flexibleView, int previousFocus, int currentFocus) + { + } + + /// + /// Called when a view created by this adapter has been recycled. + /// If an item view has large or expensive data bound to it such as large bitmaps, this may be a good place to release those resources + /// + /// The ViewHolder will be recycled. + /// 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 virtual void OnViewRecycled(ViewHolder holder) + { + } + + /// + /// Called when a view created by this adapter has been attached to a window. + /// This can be used as a reasonable signal that the view is about to be seen by the user. + /// + /// Holder of the view being attached. + /// 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 virtual void OnViewAttachedToWindow(ViewHolder holder) + { + } + + /// + /// Called when a view created by this adapter has been detached from its window. + /// + /// Holder of the view being detached. + /// 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 virtual void OnViewDetachedFromWindow(ViewHolder holder) + { + } + + /// + /// Notify any registered observers that the data set has changed. + /// + /// 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 void NotifyDataSetChanged() + { + } + + /// + /// Notify any registered observers that the data set has changed. + /// It indicates that any reflection of the data at position is out of date and should be updated. + /// + /// Position of the item that has changed + /// 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 void NotifyItemChanged(int position) + { + ItemEventArgs args = new ItemEventArgs + { + EventType = ItemEventType.Change, + }; + args.param[0] = position; + args.param[1] = 1; + OnItemEvent(this, args); + } + + /// + /// Notify any registered observers that the itemCount items starting at position positionStart have changed. + /// An optional payload can be passed to each changed item. + /// + /// Position of the first item that has changed + /// Number of items that have changed + /// 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 void NotifyItemRangeChanged(int positionStart, int itemCount) + { + } + + /// + /// Notify any registered observers that the data set has been newly inserted. + /// It indicates that any reflection of the data at position is out of date and should be updated. + /// + /// Position of the item that has been newly inserted + /// 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 void NotifyItemInserted(int position) + { + NotifyItemRangeInserted(position, 1); + } + + /// + /// Notify any registered observers that the itemCount items starting at position positionStart have been newly inserted. + /// + /// Position of the first item that was inserted + /// Number of items inserted + /// 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 void NotifyItemRangeInserted(int positionStart, int itemCount) + { + ItemEventArgs args = new ItemEventArgs + { + EventType = ItemEventType.Insert, + }; + args.param[0] = positionStart; + args.param[1] = itemCount; + OnItemEvent(this, args); + } + + /// + /// Notify any registered observers that the item previously located at position has been removed from the data set. + /// + /// Previous position of the first item that was removed + /// 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 void NotifyItemRemoved(int position) + { + NotifyItemRangeRemoved(position, 1); + } + + /// + /// Notify any registered observers that the itemCount items previously located at positionStart have been removed from the data set. + /// + /// Previous position of the first item that was removed + /// Number of items removed from the data set + /// 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 void NotifyItemRangeRemoved(int positionStart, int itemCount) + { + ItemEventArgs args = new ItemEventArgs + { + EventType = ItemEventType.Remove, + }; + args.param[0] = positionStart; + args.param[1] = itemCount; + OnItemEvent(this, args); + } + + /// + /// Notify any registered observers that the item reflected at fromPosition has been moved to toPosition. + /// + /// Previous position of the item + /// New position of the item. + /// 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 void NotifyItemMoved(int fromPosition, int toPosition) + { + + } + + private void OnItemEvent(object sender, ItemEventArgs e) + { + itemEventHandlers?.Invoke(sender, e); + } + + internal class ItemEventArgs : EventArgs + { + + /// + /// Data change event parameters. + /// + public int[] param = new int[4]; + + /// + /// Data changed event type. + /// + public ItemEventType EventType + { + get; + set; + } + } + } + + /// + /// A LayoutManager is responsible for measuring and positioning item views within a FlexibleView + /// as well as determining the policy for when to recycle item views that are no longer visible to the user. + /// + /// 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 abstract class LayoutManager + { + /// + /// Direction + /// + public enum Direction + { + /// + /// Left + /// + Left, + + /// + /// Right + /// + Right, + + /// + /// Up + /// + Up, + + /// + /// Down + /// + Down + } + + private FlexibleView mFlexibleView; + private ChildHelper mChildHelper; + + private List mPendingRecycleViews = new List(); + + private Animation mScrollAni; + + /// + /// Layout all relevant child views from the given adapter. + /// + /// Recycler to use for fetching potentially cached views for a position + /// 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 abstract void OnLayoutChildren(Recycler recycler); + + /// + /// Called after a full layout calculation is finished. + /// + /// 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 virtual void OnLayoutCompleted() + { + } + + + /// + /// Gets the current focus position in adapter. + /// + /// 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 int FocusPosition + { + get + { + return mFlexibleView.mFocusedItemIndex; + } + } + + /// + /// Gets the datas count in data sets. + /// + /// 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 int ItemCount + { + get + { + Adapter b = mFlexibleView != null ? mFlexibleView.mAdapter : null; + + return b != null ? b.GetItemCount() : 0; + } + } + + /// + /// Query if horizontal scrolling is currently supported. The default implementation returns false. + /// + /// 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 virtual bool CanScrollHorizontally() + { + return false; + } + + /// + /// Query if vertical scrolling is currently supported. The default implementation returns false. + /// + /// 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 virtual bool CanScrollVertically() + { + return false; + } + + /// + /// Scroll horizontally by dy pixels in screen coordinates. + /// + /// distance to scroll in pixels. Y increases as scroll position approaches the top. + /// Recycler to use for fetching potentially cached views for a position + /// Specify if the scroll need animation + /// 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 virtual float ScrollHorizontallyBy(float dy, Recycler recycler, bool immediate) + { + return 0; + } + + /// + /// Scroll vertically by dy pixels in screen coordinates. + /// + /// distance to scroll in pixels. Y increases as scroll position approaches the top. + /// Recycler to use for fetching potentially cached views for a position + /// Specify if the scroll need animation + /// 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 virtual float ScrollVerticallyBy(float dy, Recycler recycler, bool immediate) + { + return 0; + } + + /// + /// Compute the extent of the scrollbar's thumb within the range. + /// + /// 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 virtual float ComputeScrollExtent() + { + return 0; + } + + /// + /// Compute the offset of the scrollbar's thumb within the range. + /// + /// 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 virtual float ComputeScrollOffset() + { + return 0; + } + + /// + /// Compute the range that the scrollbar represents. + /// + /// 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 virtual float ComputeScrollRange() + { + return 0; + } + + /// + /// Scroll the FlexibleView to make the position visible. + /// + /// Scroll to this adapter position + /// 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 virtual void ScrollToPosition(int position) + { + + } + + /// + /// Scroll to the specified adapter position with the given offset from resolved layout start. + /// + /// Scroll to this adapter position + /// The distance (in pixels) between the start edge of the item view and start edge of the FlexibleView. + /// 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 virtual void ScrollToPositionWithOffset(int position, int offset) + { + + } + + internal void MoveFocus(FlexibleView.LayoutManager.Direction direction, Recycler recycler) + { + int prevFocusPosition = FocusPosition; + int nextFocusPosition = GetNextPosition(FocusPosition, direction); + if (nextFocusPosition == NO_POSITION) + { + return; + } + + FlexibleView.ViewHolder nextFocusChild = FindItemViewByPosition(nextFocusPosition); + if (nextFocusChild == null) + { + nextFocusChild = OnFocusSearchFailed(null, direction, recycler); + } + + if (nextFocusChild != null) + { + RequestChildRectangleOnScreen(mFlexibleView, nextFocusChild, recycler, false); + + ChangeFocus(nextFocusPosition); + } + } + + /** + * Requests that the given child of the RecyclerView be positioned onto the screen. This + * method can be called for both unfocusable and focusable child views. For unfocusable + * child views, focusedChildVisible is typically true in which case, layout manager + * makes the child view visible only if the currently focused child stays in-bounds of RV. + * @param parent The parent RecyclerView. + * @param child The direct child making the request. + * @param rect The rectangle in the child's coordinates the child + * wishes to be on the screen. + * @param immediate True to forbid animated or delayed scrolling, + * false otherwise + * @param focusedChildVisible Whether the currently focused view must stay visible. + * @return Whether the group scrolled to handle the operation + */ + internal bool RequestChildRectangleOnScreen(FlexibleView parent, FlexibleView.ViewHolder child, Recycler recycler, bool immediate) + { + Vector2 scrollAmount = GetChildRectangleOnScreenScrollAmount(parent, child); + float dx = scrollAmount[0]; + float dy = scrollAmount[1]; + if (dx != 0 || dy != 0) + { + if (dx != 0 && CanScrollHorizontally()) + { + ScrollHorizontallyBy(dx, recycler, immediate); + } + else if (dy != 0 && CanScrollVertically()) + { + ScrollVerticallyBy(dy, recycler, immediate); + } + return true; + } + return false; + } + + /// + /// Calls {@code FlexibleView#RelayoutRequest} on the underlying FlexibleView. + /// + /// 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 void RelayoutRequest() + { + if (mFlexibleView != null) + { + mFlexibleView.RelayoutRequest(); + } + } + + /// + /// Lay out the given child view within the FlexibleView using coordinates that include view margins. + /// + /// Child to lay out + /// Left edge, with item view left margin included + /// Top edge, with item view top margin included + /// Width, with item view left and right margin included + /// Height, with item view top and bottom margin included + /// 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 void LayoutChild(ViewHolder child, float left, float top, float width, float height) + { + View itemView = child.ItemView; + itemView.SizeWidth = width - itemView.Margin.Start - itemView.Margin.End; + itemView.SizeHeight = height - itemView.Margin.Top - itemView.Margin.Bottom; + itemView.PositionX = left + itemView.Margin.Start; + itemView.PositionY = top + itemView.Margin.Top; + } + + /// + /// Change the ViewHolder with focusPosition to focus. + /// + /// the newly focus position + /// 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 void ChangeFocus(int focusPosition) + { + if (mFlexibleView != null) + { + mFlexibleView.DispatchFocusChanged(focusPosition); + } + } + + /// + /// Return the current number of child views attached to the parent FlexibleView. + /// + /// 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 int GetChildCount() + { + return mChildHelper != null ? mChildHelper.GetChildCount() : 0; + } + + /// + /// Return the child view at the given index. + /// + /// child index + /// 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 ViewHolder GetChildAt(int index) + { + return mChildHelper != null ? mChildHelper.GetChildAt(index) : null; + } + + /// + /// Finds the view which represents the given adapter position. + /// + /// adapter position + /// 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 ViewHolder FindItemViewByPosition(int position) + { + return mFlexibleView.FindViewHolderForLayoutPosition(position); + } + + /// + /// Offset all child views attached to the parent FlexibleView by dx pixels along the horizontal axis. + /// + /// Pixels to offset by + /// specify if the offset need animation + /// 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 void OffsetChildrenHorizontal(float dx, bool immediate) + { + if (mChildHelper == null) + { + return; + } + + if (mScrollAni == null) + { + mScrollAni = new Animation(); + mScrollAni.Finished += OnScrollAnimationFinished; + } + else if (mScrollAni.State == Animation.States.Playing) + { + //StopScroll(); + mScrollAni.Stop(); + } + mScrollAni.Duration = 2000; + mScrollAni.DefaultAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSquare); + + mScrollAni.Clear(); + + int childCount = mChildHelper.GetChildCount(); + if (immediate == true) + { + for (int i = childCount - 1; i >= 0; i--) + { + ViewHolder v = mChildHelper.GetChildAt(i); + v.ItemView.PositionX += dx; + } + } + else + { + for (int i = childCount - 1; i >= 0; i--) + { + ViewHolder v = mChildHelper.GetChildAt(i); + mScrollAni.AnimateTo(v.ItemView, "PositionX", v.ItemView.PositionX + dx); + } + mScrollAni.Play(); + } + } + + /// + /// Offset all child views attached to the parent FlexibleView by dy pixels along the vertical axis. + /// + /// Pixels to offset by + /// specify if the offset need animation + /// 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 void OffsetChildrenVertical(float dy, bool immediate) + { + if (mChildHelper == null) + { + return; + } + + if (mScrollAni == null) + { + mScrollAni = new Animation(); + mScrollAni.Finished += OnScrollAnimationFinished; + } + else if (mScrollAni.State == Animation.States.Playing) + { + //StopScroll(); + mScrollAni.Stop(); + } + mScrollAni.Duration = 2000; + mScrollAni.DefaultAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSquare); + + mScrollAni.Clear(); + + int childCount = mChildHelper.GetChildCount(); + if (immediate == true) + { + for (int i = childCount - 1; i >= 0; i--) + { + ViewHolder v = mChildHelper.GetChildAt(i); + v.ItemView.PositionY += dy; + } + } + else + { + for (int i = childCount - 1; i >= 0; i--) + { + ViewHolder v = mChildHelper.GetChildAt(i); + mScrollAni.AnimateTo(v.ItemView, "PositionY", v.ItemView.PositionY + dy); + } + mScrollAni.Play(); + } + } + + /// + /// Return the width of the parent FlexibleView. + /// + /// 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 float GetWidth() + { + return mFlexibleView != null ? mFlexibleView.SizeWidth : 0; + } + + /// + /// Return the height of the parent FlexibleView. + /// + /// 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 float GetHeight() + { + return mFlexibleView != null ? mFlexibleView.SizeHeight : 0; + } + + /// + /// Return the left padding of the parent FlexibleView. + /// + /// 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 int GetPaddingLeft() + { + return mFlexibleView != null ? mFlexibleView.Padding.Start : 0; + } + + /// + /// Return the top padding of the parent FlexibleView. + /// + /// 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 int GetPaddingTop() + { + return mFlexibleView != null ? mFlexibleView.Padding.Top : 0; + } + + /// + /// Return the right padding of the parent FlexibleView. + /// + /// 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 int GetPaddingRight() + { + return mFlexibleView != null ? mFlexibleView.Padding.End : 0; + } + + /// + /// Return the bottom padding of the parent FlexibleView. + /// + /// 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 int GetPaddingBottom() + { + return mFlexibleView != null ? mFlexibleView.Padding.Bottom : 0; + } + + /// + /// Add a view to the currently attached FlexibleView if needed.
+ /// LayoutManagers should use this method to add views obtained from a FlexibleView.Recycler using getViewForPosition(int).
+ ///
+ /// view to add + /// 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 void AddView(ViewHolder holder) + { + AddView(holder, -1); + } + + /// + /// Add a view to the currently attached FlexibleView if needed.
+ /// LayoutManagers should use this method to add views obtained from a FlexibleView.Recycler using getViewForPosition(int).
+ ///
+ /// view to add + /// index to add child at + /// 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 void AddView(ViewHolder holder, int index) + { + AddViewInternal(holder, index, false); + } + + /// + /// Temporarily detach and scrap all currently attached child views. + /// Views will be scrapped into the given Recycler. + /// The Recycler may prefer to reuse scrap views before other views that were previously recycled. + /// + /// Recycler to scrap views into + /// 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 void ScrapAttachedViews(Recycler recycler) + { + if (mChildHelper == null) + { + return; + } + + recycler.Clear(); + + mChildHelper.ScrapViews(recycler); + } + + /** + * Remove a child view and recycle it using the given Recycler. + * + * @param index Index of child to remove and recycle + * @param recycler Recycler to use to recycle child + */ + /// 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 void RemoveAndRecycleViewAt(int index, Recycler recycler) + { + ViewHolder v = mChildHelper.GetChildAt(index); + mChildHelper.RemoveViewAt(index); + recycler.RecycleView(v); + } + + /// + /// ecycles children between given indices.. + /// + /// Recycler to recycle views into + /// inclusive + /// exclusive + /// recycle immediately or add to pending list and recycle later. + /// 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 void RecycleChildren(FlexibleView.Recycler recycler, int startIndex, int endIndex, bool immediate) + { + if (startIndex == endIndex) + { + return; + } + if (endIndex > startIndex) + { + for (int i = startIndex; i < endIndex; i++) + { + ViewHolder v = mChildHelper.GetChildAt(i); + if (v.PendingRecycle == false) + { + v.PendingRecycle = true; + mPendingRecycleViews.Add(v); + } + } + } + else + { + for (int i = startIndex; i > endIndex; i--) + { + ViewHolder v = mChildHelper.GetChildAt(i); + if (v.PendingRecycle == false) + { + v.PendingRecycle = true; + mPendingRecycleViews.Add(v); + } + } + } + if (immediate == true) + { + RecycleChildrenInt(recycler); + } + } + + /// + /// Retrieves a position that neighbor to current position by direction. + /// + /// The anchor adapter position + /// The direction. + /// 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 abstract int GetNextPosition(int position, FlexibleView.LayoutManager.Direction direction); + + internal virtual ViewHolder OnFocusSearchFailed(FlexibleView.ViewHolder focused, LayoutManager.Direction direction, Recycler recycler) + { + return null; + } + + internal void SetRecyclerView(FlexibleView recyclerView) + { + mFlexibleView = recyclerView; + mChildHelper = recyclerView.mChildHelper; + } + + internal void StopScroll() + { + if (mScrollAni != null && mScrollAni.State == Animation.States.Playing) + { + mScrollAni.Stop(); + mScrollAni.Clear(); + OnScrollAnimationFinished(mScrollAni, null); + } + } + + /** + * Returns the scroll amount that brings the given rect in child's coordinate system within + * the padded area of RecyclerView. + * @param parent The parent RecyclerView. + * @param child The direct child making the request. + * @param rect The rectangle in the child's coordinates the child + * wishes to be on the screen. + * @param immediate True to forbid animated or delayed scrolling, + * false otherwise + * @return The array containing the scroll amount in x and y directions that brings the + * given rect into RV's padded area. + */ + private Vector2 GetChildRectangleOnScreenScrollAmount(FlexibleView parent, FlexibleView.ViewHolder child) + { + Vector2 ret = new Vector2(0, 0); + int parentLeft = GetPaddingLeft(); + int parentTop = GetPaddingTop(); + int parentRight = (int)GetWidth() - GetPaddingRight(); + int parentBottom = (int)GetHeight() - GetPaddingBottom(); + int childLeft = (int)child.Left; + int childTop = (int)child.Top; + int childRight = (int)child.Right; + int childBottom = (int)child.Bottom; + + int offScreenLeft = Math.Min(0, childLeft - parentLeft); + int offScreenTop = Math.Min(0, childTop - parentTop); + int offScreenRight = Math.Max(0, childRight - parentRight); + int offScreenBottom = Math.Max(0, childBottom - parentBottom); + + // Favor the "start" layout direction over the end when bringing one side or the other + // of a large rect into view. If we decide to bring in end because start is already + // visible, limit the scroll such that start won't go out of bounds. + int dx= offScreenLeft != 0 ? offScreenLeft + : Math.Min(childLeft - parentLeft, offScreenRight); + + // Favor bringing the top into view over the bottom. If top is already visible and + // we should scroll to make bottom visible, make sure top does not go out of bounds. + int dy = offScreenTop != 0 ? offScreenTop + : Math.Min(childTop - parentTop, offScreenBottom); + + ret.X = -dx; + ret.Y = -dy; + + return ret; + } + + private void OnScrollAnimationFinished(object sender, EventArgs e) + { + RecycleChildrenInt(mFlexibleView.mRecycler); + } + + private void AddViewInternal(ViewHolder holder, int index, bool disappearing) + { + if (holder.IsScrap()) + { + holder.Unscrap(); + mChildHelper.AttachView(holder, index); + } + else + { + mChildHelper.AddView(holder, index); + } + } + + private void RecycleChildrenInt(FlexibleView.Recycler recycler) + { + foreach(ViewHolder holder in mPendingRecycleViews) + { + holder.PendingRecycle = false; + recycler.RecycleView(holder); + mChildHelper.RemoveView(holder); + } + mPendingRecycleViews.Clear(); + } + + private void ScrapOrRecycleView(Recycler recycler, ViewHolder itemView) + { + recycler.ScrapView(itemView); + } + + } + + /// + /// A ViewHolder describes an item view and metadata about its place within the FlexibleView. + /// + /// 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 class ViewHolder + { + /** + * This ViewHolder has been bound to a position; AdapterPosition, mItemId and mItemViewType + * are all valid. + */ + //static readonly int FLAG_BOUND = 1 << 0; + + /** + * The data this ViewHolder's view reflects is stale and needs to be rebound + * by the adapter. AdapterPosition and mItemId are consistent. + */ + //static readonly int FLAG_UPDATE = 1 << 1; + + /** + * This ViewHolder's data is invalid. The identity implied by AdapterPosition and mItemId + * are not to be trusted and may no longer match the item view type. + * This ViewHolder must be fully rebound to different data. + */ + //static readonly int FLAG_INVALID = 1 << 2; + + /** + * This ViewHolder points at data that represents an item previously removed from the + * data set. Its view may still be used for things like outgoing animations. + */ + //static readonly int FLAG_REMOVED = 1 << 3; + + /** + * This ViewHolder should not be recycled. This flag is set via setIsRecyclable() + * and is intended to keep views around during animations. + */ + //static readonly int FLAG_NOT_RECYCLABLE = 1 << 4; + + /** + * This ViewHolder is returned from scrap which means we are expecting an addView call + * for this itemView. When returned from scrap, ViewHolder stays in the scrap list until + * the end of the layout pass and then recycled by RecyclerView if it is not added back to + * the RecyclerView. + */ + //static readonly int FLAG_RETURNED_FROM_SCRAP = 1 << 5; + + /** + * This ViewHolder is fully managed by the LayoutManager. We do not scrap, recycle or remove + * it unless LayoutManager is replaced. + * It is still fully visible to the LayoutManager. + */ + //static readonly int FLAG_IGNORE = 1 << 7; + + private int mFlags; + private int mPreLayoutPosition = NO_POSITION; + + /// + /// ViewHolder constructor. + /// + /// View + /// 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 ViewHolder(View itemView) + { + if (itemView == null) + { + throw new ArgumentNullException("itemView may not be null"); + } + this.ItemView = itemView; + } + + /// + /// Returns the view. + /// + /// 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 View ItemView { get; } + + /// + /// Returns the left edge includes the view left margin. + /// + /// 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 float Left + { + get + { + return ItemView.PositionX - ItemView.Margin.Start; + } + } + + /// + /// Returns the right edge includes the view right margin. + /// + /// 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 float Right + { + get + { + return ItemView.PositionX + ItemView.SizeWidth + ItemView.Margin.End; + } + } + + /// + /// Returns the top edge includes the view top margin. + /// + /// 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 float Top + { + get + { + return ItemView.PositionY - ItemView.Margin.Top; + } + } + + /// + /// Returns the bottom edge includes the view bottom margin. + /// + /// 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 float Bottom + { + get + { + return ItemView.PositionY + ItemView.SizeHeight + ItemView.Margin.Bottom; + } + } + + /// + /// Returns the position of the ViewHolder in terms of the latest layout pass. + /// + /// 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 int LayoutPosition + { + get + { + return mPreLayoutPosition == NO_POSITION ? AdapterPosition : mPreLayoutPosition; + } + } + + /// + /// Returns the Adapter position of the item represented by this ViewHolder. + /// + /// 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 int AdapterPosition { get; internal set; } = NO_POSITION; + + /// + /// Get old position of item view. + /// + /// 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 int OldPosition { get; private set; } = NO_POSITION; + + /// + /// Gets or sets item view type. + /// + /// 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 int ItemViewType { get; set; } = INVALID_TYPE; + + internal bool IsBound + { + get; + set; + } + + internal Recycler ScrapContainer { get; set; } + + internal bool PendingRecycle + { + get; + set; + } = false; + + + internal bool IsScrap() + { + return ScrapContainer != null; + } + + internal void Unscrap() + { + ScrapContainer.UnscrapView(this); + } + + + internal void FlagRemovedAndOffsetPosition(int mNewPosition, int offset, bool applyToPreLayout) + { + //AddFlags(ViewHolder.FLAG_REMOVED); + OffsetPosition(offset, applyToPreLayout); + AdapterPosition = mNewPosition; + } + + internal void OffsetPosition(int offset, bool applyToPreLayout) + { + if (OldPosition == NO_POSITION) + { + OldPosition = AdapterPosition; + } + if (mPreLayoutPosition == NO_POSITION) + { + mPreLayoutPosition = AdapterPosition; + } + if (applyToPreLayout) + { + mPreLayoutPosition += offset; + } + AdapterPosition += offset; + } + + internal void ClearOldPosition() + { + OldPosition = NO_POSITION; + mPreLayoutPosition = NO_POSITION; + } + + internal void SaveOldPosition() + { + if (OldPosition == NO_POSITION) + { + OldPosition = AdapterPosition; + } + } + + private void SetFlags(int flags, int mask) + { + mFlags = (mFlags & ~mask) | (flags & mask); + } + + private void AddFlags(int flags) + { + mFlags |= flags; + } + + } + + /// + /// A Recycler is responsible for managing scrapped or detached item views for reuse. + /// A "scrapped" view is a view that is still attached to its parent FlexibleView but that has been marked for removal or reuse. + /// + /// 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 class Recycler + { + private FlexibleView mFlexibleView; + private RecycledViewPool mRecyclerPool; + + private List mAttachedScrap = new List(); + private List mChangedScrap = null; + //private List mCachedViews = new List(); + + //private List mUnmodifiableAttachedScrap; + + private int mCacheSizeMax = 2; + + /// + /// Recycler constructor. + /// + /// 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(FlexibleView recyclerView) + { + mFlexibleView = recyclerView; + } + + /// 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 void SetViewCacheSize(int viewCount) + { + mCacheSizeMax = viewCount; + } + + /// + /// Obtain a view initialized for the given position. + /// + /// Position to obtain a view for + /// 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 ViewHolder GetViewForPosition(int position) + { + Adapter b = mFlexibleView != null ? mFlexibleView.mAdapter : null; + if (b == null) + { + return null; + } + if (position < 0 || position >= b.GetItemCount()) + { + return null; + } + + int type = b.GetItemViewType(position); + ViewHolder itemView = null; + for (int i = 0; i < mAttachedScrap.Count; i++) + { + if (mAttachedScrap[i].LayoutPosition == position && mAttachedScrap[i].ItemViewType == type) + { + itemView = mAttachedScrap[i]; + break; + } + } + if (itemView == null) + { + itemView = mRecyclerPool.GetRecycledView(type); + if (itemView == null) + { + itemView = b.OnCreateViewHolder(type); + } + + if (!itemView.IsBound) + { + b.OnBindViewHolder(itemView, position); + itemView.IsBound = true; + } + + itemView.AdapterPosition = position; + itemView.ItemViewType = type; + } + + return itemView; + } + + /// + /// Recycle a detached view. + /// + /// Removed holder for recycling + /// 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 void RecycleView(ViewHolder itemView) + { + itemView.ScrapContainer = null; + mRecyclerPool.PutRecycledView(itemView); + } + + /// + /// Returns the count in scrap list. + /// + /// 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 int GetScrapCount() + { + return mAttachedScrap.Count; + } + + /// + /// Gets the scrap view at index. + /// + /// index + /// 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 ViewHolder GetScrapViewAt(int index) + { + return mAttachedScrap[index]; + } + + /// + /// Clear scrap views out of this recycler. Detached views contained within a recycled view pool will remain. + /// + /// 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 void Clear() + { + mAttachedScrap.Clear(); + if (mChangedScrap != null) + { + mChangedScrap.Clear(); + } + } + + internal void ScrapView(ViewHolder itemView) + { + mAttachedScrap.Add(itemView); + itemView.ScrapContainer = this; + } + + internal void UnscrapView(ViewHolder itemView) + { + mAttachedScrap.Remove(itemView); + itemView.ScrapContainer = null; + } + + internal void SetRecycledViewPool(RecycledViewPool pool) + { + mRecyclerPool = pool; + } + } + + internal class RecycledViewPool + { + private FlexibleView mFlexibleView; + + private int mMaxTypeCount = 10; + private List[] mScrap; + + public RecycledViewPool(FlexibleView flexibleView) + { + mFlexibleView = flexibleView; + mScrap = new List[mMaxTypeCount]; + } + + //public void SetViewTypeCount(int typeCount) + //{ + //} + + public ViewHolder GetRecycledView(int viewType) + { + if (viewType >= mMaxTypeCount || mScrap[viewType] == null) + { + return null; + } + + int index = mScrap[viewType].Count - 1; + if (index < 0) + { + return null; + } + ViewHolder recycledView = mScrap[viewType][index]; + mScrap[viewType].RemoveAt(index); + + return recycledView; + } + + public void PutRecycledView(ViewHolder view) + { + int viewType = view.ItemViewType; + if (mScrap[viewType] == null) + { + mScrap[viewType] = new List(); + } + view.IsBound = false; + mScrap[viewType].Add(view); + } + + public void Clear() + { + for (int i = 0; i < mMaxTypeCount; i++) + { + if (mScrap[i] == null) + { + continue; + } + for (int j = 0; j < mScrap[i].Count; j++) + { + mFlexibleView.DispatchChildDestroyed(mScrap[i][j]); + } + mScrap[i].Clear(); + } + } + } + + private class ChildHelper + { + private FlexibleView mFlexibleView; + + private List mViewList = new List(); + + //private List mRemovePendingViews; + + private Dictionary itemViewTable = new Dictionary(); + private TapGestureDetector mTapGestureDetector; + + public ChildHelper(FlexibleView owner) + { + mFlexibleView = owner; + + mTapGestureDetector = new TapGestureDetector(); + mTapGestureDetector.Detected += OnTapGestureDetected; + } + + public void Clear() + { + foreach(ViewHolder holder in mViewList) + { + mFlexibleView.Remove(holder.ItemView); + + mFlexibleView.DispatchChildDestroyed(holder); + } + mViewList.Clear(); + } + + public void ScrapViews(Recycler recycler) + { + recycler.Clear(); + foreach (ViewHolder itemView in mViewList) + { + recycler.ScrapView(itemView); + } + + mViewList.Clear(); + } + + public void AttachView(ViewHolder holder, int index) + { + if (index == -1) + { + index = mViewList.Count; + } + mViewList.Insert(index, holder); + + if (!itemViewTable.ContainsKey(holder.ItemView.ID)) + { + mTapGestureDetector.Attach(holder.ItemView); + holder.ItemView.TouchEvent += OnTouchEvent; + } + + itemViewTable[holder.ItemView.ID] = holder; + } + + public void AddView(ViewHolder holder, int index) + { + mFlexibleView.Add(holder.ItemView); + + mFlexibleView.DispatchChildAttached(holder); + + AttachView(holder, index); + } + + public bool RemoveView(ViewHolder holder) + { + mFlexibleView.Remove(holder.ItemView); + + mFlexibleView.DispatchChildDetached(holder); + + return mViewList.Remove(holder); + } + + public bool RemoveViewAt(int index) + { + ViewHolder itemView = mViewList[index]; + return RemoveView(itemView); + } + + public bool RemoveViewsRange(int index, int count) + { + for (int i = index; i < index + count; i++) + { + ViewHolder holder = mViewList[i]; + mFlexibleView.Remove(holder.ItemView); + } + mViewList.RemoveRange(index, count); + return false; + } + + public int GetChildCount() + { + return mViewList.Count; + } + + public ViewHolder GetChildAt(int index) + { + if (index < 0 || index >= mViewList.Count) + { + return null; + } + return mViewList[index]; + } + + private void OnTapGestureDetected(object source, TapGestureDetector.DetectedEventArgs e) + { + View itemView = e.View as View; + if (itemView == null) + { + return; + } + if (itemViewTable.ContainsKey(itemView.ID)) + { + ViewHolder holder = itemViewTable[itemView.ID]; + mFlexibleView.FocusedItemIndex = holder.AdapterPosition; + + mFlexibleView.DispatchItemClicked(holder); + } + } + + private bool OnTouchEvent(object source, TouchEventArgs e) + { + View itemView = source as View; + if (itemView != null && itemViewTable.ContainsKey(itemView.ID)) + { + ViewHolder holder = itemViewTable[itemView.ID]; + + mFlexibleView.DispatchItemTouched(holder, e.Touch); + return true; + } + return false; + } + } + + private class AdapterHelper + { + private FlexibleView mFlexibleView; + + private List mPendingUpdates = new List(); + + private int mExistingUpdateTypes = 0; + + public AdapterHelper(FlexibleView flexibleView) + { + mFlexibleView = flexibleView; + } + + /** + * @return True if updates should be processed. + */ + public bool OnItemRangeInserted(int positionStart, int itemCount) + { + if (itemCount < 1) + { + return false; + } + mPendingUpdates.Add(new UpdateOp(UpdateOp.ADD, positionStart, itemCount)); + mExistingUpdateTypes |= UpdateOp.ADD; + return mPendingUpdates.Count == 1; + } + + /** + * @return True if updates should be processed. + */ + public bool OnItemRangeRemoved(int positionStart, int itemCount) + { + if (itemCount < 1) + { + return false; + } + mPendingUpdates.Add(new UpdateOp(UpdateOp.REMOVE, positionStart, itemCount)); + mExistingUpdateTypes |= UpdateOp.REMOVE; + return mPendingUpdates.Count == 1; + } + + public void PreProcess() + { + int count = mPendingUpdates.Count; + for (int i = 0; i < count; i++) + { + UpdateOp op = mPendingUpdates[i]; + switch (op.cmd) + { + case UpdateOp.ADD: + mFlexibleView.OffsetPositionRecordsForInsert(op.positionStart, op.itemCount); + break; + case UpdateOp.REMOVE: + mFlexibleView.OffsetPositionRecordsForRemove(op.positionStart, op.itemCount, false); + break; + case UpdateOp.UPDATE: + break; + case UpdateOp.MOVE: + break; + } + } + mPendingUpdates.Clear(); + } + + } + + /** + * Queued operation to happen when child views are updated. + */ + private class UpdateOp + { + + public const int ADD = 1; + + public const int REMOVE = 1 << 1; + + public const int UPDATE = 1 << 2; + + public const int MOVE = 1 << 3; + + public const int POOL_SIZE = 30; + + public int cmd; + + public int positionStart; + + // holds the target position if this is a MOVE + public int itemCount; + + public UpdateOp(int cmd, int positionStart, int itemCount) + { + this.cmd = cmd; + this.positionStart = positionStart; + this.itemCount = itemCount; + } + + public bool Equals(UpdateOp op) + { + if (cmd != op.cmd) + { + return false; + } + if (cmd == MOVE && Math.Abs(itemCount - positionStart) == 1) + { + // reverse of this is also true + if (itemCount == op.positionStart && positionStart == op.itemCount) + { + return true; + } + } + if (itemCount != op.itemCount) + { + return false; + } + if (positionStart != op.positionStart) + { + return false; + } + + return true; + } + + } + + private class ItemViewInfo + { + public float Left + { + get; + set; + } + public float Top + { + get; + set; + } + public float Right + { + get; + set; + } + public float Bottom + { + get; + set; + } + } + + } +} diff --git a/src/Tizen.NUI.CommonUI/Controls/FlexibleView/GridLayoutManager.cs b/src/Tizen.NUI.CommonUI/Controls/FlexibleView/GridLayoutManager.cs new file mode 100755 index 000000000..210b8b1c2 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Controls/FlexibleView/GridLayoutManager.cs @@ -0,0 +1,217 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// Layout collection of views in a grid. + /// + /// 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 class GridLayoutManager : LinearLayoutManager + { + private static readonly int DEFAULT_SPAN_COUNT = -1; + + private int mSpanCount = DEFAULT_SPAN_COUNT; + + /// + /// Creates a GridLayoutManager with orientation. + /// + /// The number of columns or rows in the grid + /// Layout orientation.Should be HORIZONTAL or VERTICAL + /// 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 GridLayoutManager(int spanCount, int orientation) : base(orientation) + { + mSpanCount = spanCount; + } + + internal override void EnsureAnchorReady(FlexibleView.Recycler recycler, AnchorInfo anchorInfo, int itemDirection) + { + bool layingOutInPrimaryDirection = (itemDirection == LayoutState.ITEM_DIRECTION_TAIL); + int span = anchorInfo.Position; + if (layingOutInPrimaryDirection) + { + // choose span 0 + while (span > 0 && anchorInfo.Position > 0) + { + anchorInfo.Position--; + span = anchorInfo.Position; + } + } + else + { + // choose the max span we can get. hopefully last one + int indexLimit = GetChildCount() - 1; + int pos = anchorInfo.Position; + int bestSpan = span; + while (pos < indexLimit) + { + int next = (pos + 1); + if (next > bestSpan) + { + pos += 1; + bestSpan = next; + } + else + { + break; + } + } + anchorInfo.Position = pos; + } + } + + /// + /// Retrieves a position that neighbor to current position by direction. + /// + /// The anchor adapter position + /// The direction. + /// 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 int GetNextPosition(int position, FlexibleView.LayoutManager.Direction direction) + { + if (mOrientation == HORIZONTAL) + { + switch (direction) + { + case FlexibleView.LayoutManager.Direction.Left: + if (position >= mSpanCount) + { + return position - mSpanCount; + } + break; + case FlexibleView.LayoutManager.Direction.Right: + if (position < ItemCount - mSpanCount) + { + return position + mSpanCount; + } + break; + case FlexibleView.LayoutManager.Direction.Up: + if (position % mSpanCount > 0) + { + return position - 1; + } + break; + case FlexibleView.LayoutManager.Direction.Down: + if (position < ItemCount - 1 && (position % mSpanCount < mSpanCount - 1)) + { + return position + 1; + } + break; + } + } + else + { + switch (direction) + { + case FlexibleView.LayoutManager.Direction.Left: + if (position % mSpanCount > 0) + { + return position - 1; + } + break; + case FlexibleView.LayoutManager.Direction.Right: + if (position < ItemCount - 1 && (position % mSpanCount < mSpanCount - 1)) + { + return position + 1; + } + break; + case FlexibleView.LayoutManager.Direction.Up: + if (position >= mSpanCount) + { + return position - mSpanCount; + } + break; + case FlexibleView.LayoutManager.Direction.Down: + if (position < ItemCount - mSpanCount) + { + return position + mSpanCount; + } + break; + } + } + + return NO_POSITION; + } + + internal override void LayoutChunk(FlexibleView.Recycler recycler, + LayoutState layoutState, LayoutChunkResult result) + { + bool layingOutInPrimaryDirection = + layoutState.ItemDirection == LayoutState.ITEM_DIRECTION_TAIL; + + int count = mSpanCount; + for (int i = 0; i < count; i++) + { + FlexibleView.ViewHolder holder = layoutState.Next(recycler); + if (holder == null) + { + result.Finished = true; + return; + } + + if (layingOutInPrimaryDirection) + AddView(holder); + else + AddView(holder, 0); + + result.Consumed = mOrientationHelper.GetViewHolderMeasurement(holder); + + float left, top, width, height; + if (mOrientation == VERTICAL) + { + width = (GetWidth() - GetPaddingLeft() - GetPaddingRight()) / count; + height = result.Consumed; + if (layoutState.LayoutDirection == LayoutState.LAYOUT_END) + { + left = GetPaddingLeft() + width * i; + top = layoutState.Offset; + } + else + { + left = GetPaddingLeft() + width * (count - 1 - i); + top = layoutState.Offset - height; + } + LayoutChild(holder, left, top, width, height); + } + else + { + width = result.Consumed; + height = (GetHeight() - GetPaddingTop() - GetPaddingBottom()) / count; + if (layoutState.LayoutDirection == LayoutState.LAYOUT_END) + { + top = GetPaddingTop() + height * i; + left = layoutState.Offset; + } + else + { + top = GetPaddingTop() + height * (count - 1 - i); + left = layoutState.Offset - width; + } + LayoutChild(holder, left, top, width, height); + } + } + } + + + } +} diff --git a/src/Tizen.NUI.CommonUI/Controls/FlexibleView/LinearLayoutManager.cs b/src/Tizen.NUI.CommonUI/Controls/FlexibleView/LinearLayoutManager.cs new file mode 100755 index 000000000..b9700edc9 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Controls/FlexibleView/LinearLayoutManager.cs @@ -0,0 +1,1182 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System; +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// Layout collection of views horizontally/vertically. + /// + /// 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 class LinearLayoutManager : FlexibleView.LayoutManager + { + /// + /// Constant value: 0. + /// + /// 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 static readonly int HORIZONTAL = OrientationHelper.HORIZONTAL; + /// + /// Constant value: 1. + /// + /// 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 static readonly int VERTICAL = OrientationHelper.VERTICAL; + /// + /// Constant value: -1. + /// + /// 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 static readonly int NO_POSITION = FlexibleView.NO_POSITION; + /// + /// Constant value: -2^31. + /// + /// 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 static readonly int INVALID_OFFSET = -2147483648; + + private static readonly float MAX_SCROLL_FACTOR = 1 / 3f; + + /// + /// Current orientation. + /// + /// 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 int mOrientation; + + internal OrientationHelper mOrientationHelper; + + private LayoutState mLayoutState; + private AnchorInfo mAnchorInfo = new AnchorInfo(); + + /** + * Stashed to avoid allocation, currently only used in #fill() + */ + private LayoutChunkResult mLayoutChunkResult = new LayoutChunkResult(); + + private bool mShouldReverseLayout = false; + + /** + * When LayoutManager needs to scroll to a position, it sets this variable and requests a + * layout which will check this variable and re-layout accordingly. + */ + private int mPendingScrollPosition = NO_POSITION; + + /** + * Used to keep the offset value when {@link #scrollToPositionWithOffset(int, int)} is + * called. + */ + private int mPendingScrollPositionOffset = INVALID_OFFSET; + + /// + /// Creates a LinearLayoutManager with orientation. + /// + /// Layout orientation.Should be HORIZONTAL or VERTICAL + /// 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 LinearLayoutManager(int orientation) + { + mOrientation = orientation; + mOrientationHelper = OrientationHelper.CreateOrientationHelper(this, mOrientation); + + mLayoutState = new LayoutState(); + mLayoutState.Offset = mOrientationHelper.GetStartAfterPadding(); + } + + /// + /// Retrieves the first visible item position. + /// + /// 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 int FirstVisibleItemPosition + { + get + { + FlexibleView.ViewHolder child = FindFirstVisibleItemView(); + return child == null ? NO_POSITION : child.LayoutPosition; + } + } + + /// + /// Retrieves the first complete visible item position. + /// + /// 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 int FirstCompleteVisibleItemPosition + { + get + { + FlexibleView.ViewHolder child = FindFirstCompleteVisibleItemView(); + return child == null ? NO_POSITION : child.LayoutPosition; + } + } + + /// + /// Retrieves the last visible item position. + /// + /// 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 int LastVisibleItemPosition + { + get + { + FlexibleView.ViewHolder child = FindLastVisibleItemView(); + return child == null ? NO_POSITION : child.LayoutPosition; + } + } + + /// + /// Retrieves the last complete visible item position. + /// + /// 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 int LastCompleteVisibleItemPosition + { + get + { + FlexibleView.ViewHolder child = FindLastCompleteVisibleItemView(); + return child == null ? NO_POSITION : child.LayoutPosition; + } + } + + /// + /// Query if horizontal scrolling is currently supported. The default implementation returns false. + /// + /// 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 bool CanScrollHorizontally() + { + return mOrientation == HORIZONTAL; + } + + /// + /// Query if vertical scrolling is currently supported. The default implementation returns false. + /// + /// 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 bool CanScrollVertically() + { + return mOrientation == VERTICAL; + } + + /// + /// Lay out all relevant child views from the given adapter. + /// + /// Recycler to use for fetching potentially cached views for a position + /// 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 OnLayoutChildren(FlexibleView.Recycler recycler) + { + mLayoutState.Recycle = false; + if (!mAnchorInfo.Valid || mPendingScrollPosition != NO_POSITION) + { + mAnchorInfo.Reset(); + mAnchorInfo.LayoutFromEnd = mShouldReverseLayout; + // calculate anchor position and coordinate + UpdateAnchorInfoForLayout(recycler, mAnchorInfo); + mAnchorInfo.Valid = true; + } + + int firstLayoutDirection; + if (mAnchorInfo.LayoutFromEnd) + { + firstLayoutDirection = mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_TAIL + : LayoutState.ITEM_DIRECTION_HEAD; + } + else + { + firstLayoutDirection = mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_HEAD + : LayoutState.ITEM_DIRECTION_TAIL; + } + EnsureAnchorReady(recycler, mAnchorInfo, firstLayoutDirection); + ScrapAttachedViews(recycler); + + if (mAnchorInfo.LayoutFromEnd == true) + { + UpdateLayoutStateToFillStart(mAnchorInfo.Position, mAnchorInfo.Coordinate); + Fill(recycler, mLayoutState, false, true); + Cache(recycler, mLayoutState, true); + + UpdateLayoutStateToFillEnd(mAnchorInfo.Position, mAnchorInfo.Coordinate); + mLayoutState.CurrentPosition += mLayoutState.ItemDirection; + Fill(recycler, mLayoutState, false, true); + Cache(recycler, mLayoutState, true); + } + else + { + UpdateLayoutStateToFillEnd(mAnchorInfo.Position, mAnchorInfo.Coordinate); + Fill(recycler, mLayoutState, false, true); + Cache(recycler, mLayoutState, true); + + UpdateLayoutStateToFillStart(mAnchorInfo.Position, mAnchorInfo.Coordinate); + mLayoutState.CurrentPosition += mLayoutState.ItemDirection; + Fill(recycler, mLayoutState, false, true); + Cache(recycler, mLayoutState, true); + } + + OnLayoutCompleted(); + } + + /// + /// Scroll horizontally by dy pixels in screen coordinates. + /// + /// distance to scroll in pixels. Y increases as scroll position approaches the top. + /// Recycler to use for fetching potentially cached views for a position + /// Specify if the scroll need animation + /// 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 float ScrollHorizontallyBy(float dx, FlexibleView.Recycler recycler, bool immediate) + { + if (mOrientation == VERTICAL) + { + return 0; + } + return ScrollBy(dx, recycler, immediate); + } + + /// + /// Scroll vertically by dy pixels in screen coordinates. + /// + /// distance to scroll in pixels. Y increases as scroll position approaches the top. + /// Recycler to use for fetching potentially cached views for a position + /// Specify if the scroll need animation + /// 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 float ScrollVerticallyBy(float dy, FlexibleView.Recycler recycler, bool immediate) + { + if (mOrientation == HORIZONTAL) + { + return 0; + } + return ScrollBy(dy, recycler, immediate); ; + } + + /// + /// Compute the offset of the scrollbar's thumb within the range. + /// + /// 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 float ComputeScrollOffset() + { + FlexibleView.ViewHolder startChild = FindFirstVisibleItemView(); + FlexibleView.ViewHolder endChild = FindLastVisibleItemView(); + if (GetChildCount() == 0 || startChild == null || endChild == null) + { + return 0; + } + int minPosition = Math.Min(startChild.LayoutPosition, endChild.LayoutPosition); + int maxPosition = Math.Max(startChild.LayoutPosition, endChild.LayoutPosition); + int itemsBefore = mShouldReverseLayout + ? Math.Max(0, ItemCount - maxPosition - 1) + : Math.Max(0, minPosition); + + float laidOutArea = Math.Abs(mOrientationHelper.GetViewHolderEnd(endChild) + - mOrientationHelper.GetViewHolderStart(startChild)); + int itemRange = Math.Abs(startChild.LayoutPosition - endChild.LayoutPosition) + 1; + float avgSizePerRow = laidOutArea / itemRange; + + return (float)Math.Round(itemsBefore * avgSizePerRow + (mOrientationHelper.GetStartAfterPadding() + - mOrientationHelper.GetViewHolderStart(startChild))); + } + + /// + /// Compute the extent of the scrollbar's thumb within the range. + /// + /// 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 float ComputeScrollExtent() + { + FlexibleView.ViewHolder startChild = FindFirstVisibleItemView(); + FlexibleView.ViewHolder endChild = FindLastVisibleItemView(); + if (GetChildCount() == 0 || startChild == null || endChild == null) + { + return 0; + } + float extend = mOrientationHelper.GetViewHolderEnd(endChild) + - mOrientationHelper.GetViewHolderStart(startChild); + return Math.Min(mOrientationHelper.GetTotalSpace(), extend); + } + + /// + /// Compute the range that the scrollbar represents. + /// + /// 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 float ComputeScrollRange() + { + FlexibleView.ViewHolder startChild = FindFirstVisibleItemView(); + FlexibleView.ViewHolder endChild = FindLastVisibleItemView(); + if (GetChildCount() == 0 || startChild == null || endChild == null) + { + return 0; + } + float laidOutArea = mOrientationHelper.GetViewHolderEnd(endChild) + - mOrientationHelper.GetViewHolderStart(startChild); + int laidOutRange = Math.Abs(startChild.LayoutPosition - endChild.LayoutPosition) + 1; + // estimate a size for full list. + return laidOutArea / laidOutRange * ItemCount; + } + + /// + /// Scroll the FlexibleView to make the position visible. + /// + /// Scroll to this adapter position + /// 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 ScrollToPosition(int position) + { + mPendingScrollPosition = position; + mPendingScrollPositionOffset = INVALID_OFFSET; + + RelayoutRequest(); + } + + /// + /// Scroll to the specified adapter position with the given offset from resolved layout start. + /// + /// Scroll to this adapter position + /// The distance (in pixels) between the start edge of the item view and start edge of the FlexibleView. + /// 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 ScrollToPositionWithOffset(int position, int offset) + { + mPendingScrollPosition = position; + mPendingScrollPositionOffset = offset; + + RelayoutRequest(); + } + + /// + /// Called after a full layout calculation is finished. + /// + /// 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 OnLayoutCompleted() + { + if (mPendingScrollPosition != NO_POSITION) + { + ChangeFocus(mPendingScrollPosition); + } + mPendingScrollPosition = NO_POSITION; + mPendingScrollPositionOffset = INVALID_OFFSET; + + mAnchorInfo.Reset(); + } + + internal virtual void EnsureAnchorReady(FlexibleView.Recycler recycler, AnchorInfo anchorInfo, int itemDirection) + { + + } + + + /// + /// Retrieves a position that neighbor to current position by direction. + /// + /// The anchor adapter position + /// The direction. + /// 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 int GetNextPosition(int position, FlexibleView.LayoutManager.Direction direction) + { + if (mOrientation == HORIZONTAL) + { + switch (direction) + { + case FlexibleView.LayoutManager.Direction.Left: + if (position > 0) + { + return position - 1; + } + break; + case FlexibleView.LayoutManager.Direction.Right: + if (position < ItemCount - 1) + { + return position + 1; + } + break; + } + } + else + { + switch (direction) + { + case FlexibleView.LayoutManager.Direction.Up: + if (position > 0) + { + return position - 1; + } + break; + case FlexibleView.LayoutManager.Direction.Down: + if (position < ItemCount - 1) + { + return position + 1; + } + break; + } + } + + return NO_POSITION; + } + + internal virtual void LayoutChunk(FlexibleView.Recycler recycler, + LayoutState layoutState, LayoutChunkResult result) + { + FlexibleView.ViewHolder holder = layoutState.Next(recycler); + if (holder == null) + { + // if we are laying out views in scrap, this may return null which means there is + // no more items to layout. + result.Finished = true; + return; + } + + if (mShouldReverseLayout == (layoutState.LayoutDirection == LayoutState.LAYOUT_START)) + AddView(holder); + else + AddView(holder, 0); + + result.Consumed = mOrientationHelper.GetViewHolderMeasurement(holder); + + float left, top, width, height; + if (mOrientation == VERTICAL) + { + width = GetWidth() - GetPaddingLeft() - GetPaddingRight(); + height = result.Consumed; + left = GetPaddingLeft(); + if (layoutState.LayoutDirection == LayoutState.LAYOUT_END) + { + top = layoutState.Offset; + } + else + { + top = layoutState.Offset - height; + } + LayoutChild(holder, left, top, width, height); + } + else + { + width = result.Consumed; + height = GetHeight() - GetPaddingTop() - GetPaddingBottom(); + top = GetPaddingTop(); + if (layoutState.LayoutDirection == LayoutState.LAYOUT_END) + { + left = layoutState.Offset; + } + else + { + left = layoutState.Offset - width; + } + LayoutChild(holder, left, top, width, height); + } + + result.Focusable = true; + } + + internal override FlexibleView.ViewHolder OnFocusSearchFailed(FlexibleView.ViewHolder focused, FlexibleView.LayoutManager.Direction direction, FlexibleView.Recycler recycler) + { + if (GetChildCount() == 0) + { + return null; + } + int layoutDir = ConvertFocusDirectionToLayoutDirection(direction); + if (layoutDir == LayoutState.INVALID_LAYOUT) + { + return null; + } + int maxScroll = (int)(MAX_SCROLL_FACTOR * mOrientationHelper.GetTotalSpace()); + UpdateLayoutState(layoutDir, maxScroll, false); + mLayoutState.ScrollingOffset = LayoutState.SCROLLING_OFFSET_NaN; + mLayoutState.Recycle = false; + Fill(recycler, mLayoutState, true, true); + + FlexibleView.ViewHolder nextFocus; + if (layoutDir == LayoutState.LAYOUT_START) + { + nextFocus = GetChildAt(0); + } + else + { + nextFocus = GetChildAt(GetChildCount() - 1); + } + return nextFocus; + } + + + private void UpdateAnchorInfoForLayout(FlexibleView.Recycler recycler, AnchorInfo anchorInfo) + { + if (UpdateAnchorFromPendingData(anchorInfo)) + { + return; + } + + if (UpdateAnchorFromChildren(recycler, anchorInfo)) + { + return; + } + + anchorInfo.Position = FocusPosition != NO_POSITION ? FocusPosition : 0; + anchorInfo.Coordinate = anchorInfo.LayoutFromEnd ? mOrientationHelper.GetEndAfterPadding() : mOrientationHelper.GetStartAfterPadding(); + } + + /** + * If there is a pending scroll position or saved states, updates the anchor info from that + * data and returns true + */ + private bool UpdateAnchorFromPendingData(AnchorInfo anchorInfo) + { + if (mPendingScrollPosition == NO_POSITION) + { + return false; + } + // validate scroll position + if (mPendingScrollPosition < 0 || mPendingScrollPosition >= ItemCount) + { + mPendingScrollPosition = NO_POSITION; + mPendingScrollPositionOffset = INVALID_OFFSET; + return false; + } + + anchorInfo.Position = mPendingScrollPosition; + + if (mPendingScrollPositionOffset == INVALID_OFFSET) + { + anchorInfo.Coordinate = anchorInfo.LayoutFromEnd ? mOrientationHelper.GetEndAfterPadding() : mOrientationHelper.GetStartAfterPadding(); + } + else + { + if (mShouldReverseLayout) + { + anchorInfo.Coordinate = mOrientationHelper.GetEndAfterPadding() + - mPendingScrollPositionOffset; + } + else + { + anchorInfo.Coordinate = mOrientationHelper.GetStartAfterPadding() + + mPendingScrollPositionOffset; + } + } + return true; + } + + /** + * Finds an anchor child from existing Views. Most of the time, this is the view closest to + * start or end that has a valid position (e.g. not removed). + * If a child has focus, it is given priority. + */ + private bool UpdateAnchorFromChildren(FlexibleView.Recycler recycler, AnchorInfo anchorInfo) + { + if (GetChildCount() == 0) + { + return false; + } + + FlexibleView.ViewHolder anchorChild = FindFirstCompleteVisibleItemView(); + anchorInfo.Position = anchorChild.LayoutPosition; + anchorInfo.Coordinate = mOrientationHelper.GetViewHolderStart(anchorChild); + + return true; + } + + /** + * Converts a focusDirection to orientation. + * + * @param focusDirection One of {@link View#FOCUS_UP}, {@link View#FOCUS_DOWN}, + * {@link View#FOCUS_LEFT}, {@link View#FOCUS_RIGHT}, + * {@link View#FOCUS_BACKWARD}, {@link View#FOCUS_FORWARD} + * or 0 for not applicable + * @return {@link LayoutState#LAYOUT_START} or {@link LayoutState#LAYOUT_END} if focus direction + * is applicable to current state, {@link LayoutState#INVALID_LAYOUT} otherwise. + */ + private int ConvertFocusDirectionToLayoutDirection(FlexibleView.LayoutManager.Direction focusDirection) + { + switch (focusDirection) + { + case FlexibleView.LayoutManager.Direction.Up: + return mOrientation == VERTICAL ? LayoutState.LAYOUT_START + : LayoutState.INVALID_LAYOUT; + case FlexibleView.LayoutManager.Direction.Down: + return mOrientation == VERTICAL ? LayoutState.LAYOUT_END + : LayoutState.INVALID_LAYOUT; + case FlexibleView.LayoutManager.Direction.Left: + return mOrientation == HORIZONTAL ? LayoutState.LAYOUT_START + : LayoutState.INVALID_LAYOUT; + case FlexibleView.LayoutManager.Direction.Right: + return mOrientation == HORIZONTAL ? LayoutState.LAYOUT_END + : LayoutState.INVALID_LAYOUT; + default: + return LayoutState.INVALID_LAYOUT; + } + + } + + + private float Fill(FlexibleView.Recycler recycler, LayoutState layoutState, bool stopOnFocusable, bool immediate) + { + float start = layoutState.Available; + if (layoutState.ScrollingOffset != LayoutState.SCROLLING_OFFSET_NaN) + { + // TODO ugly bug fix. should not happen + if (layoutState.Available < 0) + { + layoutState.ScrollingOffset += layoutState.Available; + } + if (immediate == true) + { + RecycleByLayoutState(recycler, layoutState, true); + } + } + float remainingSpace = layoutState.Available + layoutState.Extra; + LayoutChunkResult layoutChunkResult = mLayoutChunkResult; + while ((remainingSpace > 0) && layoutState.HasMore(ItemCount)) + { + layoutChunkResult.ResetInternal(); + LayoutChunk(recycler, layoutState, layoutChunkResult); + if (layoutChunkResult.Finished) + { + break; + } + layoutState.Offset += layoutChunkResult.Consumed * layoutState.LayoutDirection; + /** + * Consume the available space if: + * layoutChunk did not request to be ignored + * OR we are laying out scrap children + * OR we are not doing pre-layout + */ + if (!layoutChunkResult.IgnoreConsumed) + { + layoutState.Available -= layoutChunkResult.Consumed; + // we keep a separate remaining space because mAvailable is important for recycling + remainingSpace -= layoutChunkResult.Consumed; + } + + if (layoutState.ScrollingOffset != LayoutState.SCROLLING_OFFSET_NaN) + { + layoutState.ScrollingOffset += layoutChunkResult.Consumed; + if (layoutState.Available < 0) + { + layoutState.ScrollingOffset += layoutState.Available; + } + if (immediate == true) + { + RecycleByLayoutState(recycler, layoutState, true); + } + } + if (stopOnFocusable && layoutChunkResult.Focusable) + { + break; + } + } + if (immediate == false) + { + RecycleByLayoutState(recycler, layoutState, false); + } + + return start - layoutState.Available; + } + + private void Cache(FlexibleView.Recycler recycler, LayoutState layoutState, bool immediate, float scrolled = 0) + { + if (layoutState.LayoutDirection == LayoutState.LAYOUT_END) + { + // get the first child in the direction we are going + FlexibleView.ViewHolder child = GetChildClosestToEnd(); + //Log.Fatal("TV.FLUX.Component", $"==========> child:{child.LayoutGroupIndex}-{child.LayoutItemIndex} childEnd:{orientationHelper.GetItemEnd(child)} # {orientationHelper.GetEnd()}"); + + if (child.ItemView.Focusable == false || mOrientationHelper.GetViewHolderEnd(child) + scrolled < mOrientationHelper.GetEnd()) + { + layoutState.Available = MAX_SCROLL_FACTOR * mOrientationHelper.GetTotalSpace(); + layoutState.Extra = 0; + layoutState.ScrollingOffset = LayoutState.SCROLLING_OFFSET_NaN; + layoutState.Recycle = false; + Fill(recycler, layoutState, true, immediate); + } + } + else + { + FlexibleView.ViewHolder child = GetChildClosestToStart(); + + if (child.ItemView.Focusable == false || mOrientationHelper.GetViewHolderStart(child) + scrolled > 0) + { + layoutState.Available = MAX_SCROLL_FACTOR * mOrientationHelper.GetTotalSpace(); + layoutState.Extra = 0; + layoutState.ScrollingOffset = LayoutState.SCROLLING_OFFSET_NaN; + layoutState.Recycle = false; + Fill(recycler, layoutState, true, immediate); + } + } + } + + private void RecycleByLayoutState(FlexibleView.Recycler recycler, LayoutState layoutState, bool immediate) + { + if (!layoutState.Recycle) + { + return; + } + if (layoutState.LayoutDirection == LayoutState.LAYOUT_START) + { + RecycleViewsFromEnd(recycler, layoutState.ScrollingOffset, immediate); + } + else + { + RecycleViewsFromStart(recycler, layoutState.ScrollingOffset, immediate); + } + } + + private void RecycleViewsFromStart(FlexibleView.Recycler recycler, float dt, bool immediate) + { + if (dt < 0) + { + return; + } + // ignore padding, ViewGroup may not clip children. + float limit = dt; + int childCount = GetChildCount(); + if (mShouldReverseLayout) + { + for (int i = childCount - 1; i >= 0; i--) + { + FlexibleView.ViewHolder child = GetChildAt(i); + if (mOrientationHelper.GetViewHolderEnd(child) > limit) + { + // stop here + RecycleChildren(recycler, childCount - 1, i, immediate); + return; + } + } + } + else + { + for (int i = 0; i < childCount; i++) + { + FlexibleView.ViewHolder child = GetChildAt(i); + if (mOrientationHelper.GetViewHolderEnd(child) > limit) + { + // stop here + RecycleChildren(recycler, 0, i, immediate); + return; + } + } + } + } + + private void RecycleViewsFromEnd(FlexibleView.Recycler recycler, float dt, bool immediate) + { + int childCount = GetChildCount(); + if (dt < 0) + { + return; + } + float limit = mOrientationHelper.GetEnd() - dt; + if (mShouldReverseLayout) + { + for (int i = 0; i < childCount; i++) + { + FlexibleView.ViewHolder child = GetChildAt(i); + if (mOrientationHelper.GetViewHolderStart(child) < limit) + { + // stop here + RecycleChildren(recycler, 0, i, immediate); + return; + } + } + } + else + { + for (int i = childCount - 1; i >= 0; i--) + { + FlexibleView.ViewHolder child = GetChildAt(i); + if (mOrientationHelper.GetViewHolderStart(child) < limit) + { + // stop here + RecycleChildren(recycler, childCount - 1, i, immediate); + return; + } + } + } + } + + private float ScrollBy(float dy, FlexibleView.Recycler recycler, bool immediate) + { + if (GetChildCount() == 0 || dy == 0) + { + return 0; + } + mLayoutState.Recycle = true; + int layoutDirection = dy < 0 ? LayoutState.LAYOUT_END : LayoutState.LAYOUT_START; + float absDy = Math.Abs(dy); + UpdateLayoutState(layoutDirection, absDy, true); + float consumed = mLayoutState.ScrollingOffset + + Fill(recycler, mLayoutState, false, immediate); + + if (consumed < 0) + { + return 0; + } + + float scrolled = absDy > consumed ? -layoutDirection * consumed : dy; + + Cache(recycler, mLayoutState, immediate, scrolled); + + mOrientationHelper.OffsetChildren(scrolled, immediate); + + + return scrolled; + } + + private void UpdateLayoutState(int layoutDirection, float requiredSpace, bool canUseExistingSpace) + { + mLayoutState.Extra = 0; + mLayoutState.LayoutDirection = layoutDirection; + float scrollingOffset; + if (layoutDirection == LayoutState.LAYOUT_END) + { + mLayoutState.Extra += mOrientationHelper.GetEndPadding(); + // get the first child in the direction we are going + FlexibleView.ViewHolder child = GetChildClosestToEnd(); + // the direction in which we are traversing children + mLayoutState.ItemDirection = mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_HEAD + : LayoutState.ITEM_DIRECTION_TAIL; + mLayoutState.CurrentPosition = child.LayoutPosition + mLayoutState.ItemDirection; + mLayoutState.Offset = mOrientationHelper.GetViewHolderEnd(child); + // calculate how much we can scroll without adding new children (independent of layout) + scrollingOffset = mOrientationHelper.GetViewHolderEnd(child) + - mOrientationHelper.GetEndAfterPadding(); + + } + else + { + mLayoutState.Extra += mOrientationHelper.GetStartAfterPadding(); + FlexibleView.ViewHolder child = GetChildClosestToStart(); + mLayoutState.ItemDirection = mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_TAIL + : LayoutState.ITEM_DIRECTION_HEAD; + mLayoutState.CurrentPosition = child.LayoutPosition + mLayoutState.ItemDirection; + mLayoutState.Offset = mOrientationHelper.GetViewHolderStart(child); + scrollingOffset = -mOrientationHelper.GetViewHolderStart(child) + + mOrientationHelper.GetStartAfterPadding(); + } + mLayoutState.Available = requiredSpace; + if (canUseExistingSpace) + { + mLayoutState.Available -= scrollingOffset; + } + mLayoutState.ScrollingOffset = scrollingOffset; + + } + /** + * Convenience method to find the child closes to start. Caller should check it has enough + * children. + * + * @return The child closes to start of the layout from user's perspective. + */ + private FlexibleView.ViewHolder GetChildClosestToStart() + { + return GetChildAt(mShouldReverseLayout ? GetChildCount() - 1 : 0); + } + + /** + * Convenience method to find the child closes to end. Caller should check it has enough + * children. + * + * @return The child closes to end of the layout from user's perspective. + */ + private FlexibleView.ViewHolder GetChildClosestToEnd() + { + return GetChildAt(mShouldReverseLayout ? 0 : GetChildCount() - 1); + } + + private void UpdateLayoutStateToFillEnd(int itemPosition, float offset) + { + mLayoutState.Available = mOrientationHelper.GetEndAfterPadding() - offset; + mLayoutState.ItemDirection = mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_HEAD : + LayoutState.ITEM_DIRECTION_TAIL; + mLayoutState.CurrentPosition = itemPosition; + mLayoutState.LayoutDirection = LayoutState.LAYOUT_END; + mLayoutState.Offset = offset; + mLayoutState.ScrollingOffset = LayoutState.SCROLLING_OFFSET_NaN; + mLayoutState.Extra = mOrientationHelper.GetEndPadding(); + } + + private void UpdateLayoutStateToFillStart(int itemPosition, float offset) + { + mLayoutState.Available = offset - mOrientationHelper.GetStartAfterPadding(); + mLayoutState.CurrentPosition = itemPosition; + mLayoutState.ItemDirection = mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_TAIL : + LayoutState.ITEM_DIRECTION_HEAD; + mLayoutState.LayoutDirection = LayoutState.LAYOUT_START; + mLayoutState.Offset = offset; + mLayoutState.ScrollingOffset = LayoutState.SCROLLING_OFFSET_NaN; + mLayoutState.Extra = mOrientationHelper.GetStartAfterPadding(); + } + + private FlexibleView.ViewHolder FindFirstVisibleItemView() + { + int childCount = GetChildCount(); + if (mShouldReverseLayout == false) + { + for (int i = 0; i < childCount; i++) + { + FlexibleView.ViewHolder child = GetChildAt(i); + if ((int)mOrientationHelper.GetViewHolderEnd(child) > 0) + { + return child; + } + } + } + else + { + for (int i = childCount - 1; i >= 0; i--) + { + FlexibleView.ViewHolder child = GetChildAt(i); + if ((int)mOrientationHelper.GetViewHolderEnd(child) > 0) + { + return child; + } + } + } + return null; + } + + private FlexibleView.ViewHolder FindFirstCompleteVisibleItemView() + { + int childCount = GetChildCount(); + if (mShouldReverseLayout == false) + { + for (int i = 0; i < childCount; i++) + { + FlexibleView.ViewHolder child = GetChildAt(i); + if ((int)mOrientationHelper.GetViewHolderStart(child) > 0) + { + return child; + } + } + } + else + { + for (int i = childCount - 1; i >= 0; i--) + { + FlexibleView.ViewHolder child = GetChildAt(i); + if ((int)mOrientationHelper.GetViewHolderStart(child) > 0) + { + return child; + } + } + } + return null; + } + + private FlexibleView.ViewHolder FindLastVisibleItemView() + { + int childCount = GetChildCount(); + if (mShouldReverseLayout == false) + { + for (int i = childCount - 1; i >= 0; i--) + { + FlexibleView.ViewHolder child = GetChildAt(i); + if ((int)mOrientationHelper.GetViewHolderStart(child) < (int)mOrientationHelper.GetEnd()) + { + return child; + } + } + } + else + { + for (int i = 0; i < childCount; i++) + { + FlexibleView.ViewHolder child = GetChildAt(i); + if ((int)mOrientationHelper.GetViewHolderStart(child) < (int)mOrientationHelper.GetEnd()) + { + return child; + } + } + } + return null; + } + + private FlexibleView.ViewHolder FindLastCompleteVisibleItemView() + { + int childCount = GetChildCount(); + if (mShouldReverseLayout == false) + { + for (int i = childCount - 1; i >= 0; i--) + { + FlexibleView.ViewHolder child = GetChildAt(i); + if ((int)mOrientationHelper.GetViewHolderEnd(child) < (int)mOrientationHelper.GetEnd()) + { + return child; + } + } + } + else + { + for (int i = 0; i < childCount; i++) + { + FlexibleView.ViewHolder child = GetChildAt(i); + if ((int)mOrientationHelper.GetViewHolderEnd(child) < (int)mOrientationHelper.GetEnd()) + { + return child; + } + } + } + return null; + } + + + /** + * Helper class that keeps temporary state while {LayoutManager} is filling out the empty space. + **/ + internal class LayoutState + { + public static readonly int LAYOUT_START = -1; + + public static readonly int LAYOUT_END = 1; + + public static readonly int INVALID_LAYOUT = -1000; + + public static readonly int ITEM_DIRECTION_HEAD = -1; + + public static readonly int ITEM_DIRECTION_TAIL = 1; + + public static readonly int SCROLLING_OFFSET_NaN = -10000; + + /** + * We may not want to recycle children in some cases (e.g. layout) + */ + public bool Recycle = true; + + /** + * Pixel offset where layout should start + */ + public float Offset; + + /** + * Number of pixels that we should fill, in the layout direction. + */ + public float Available; + + /** + * Current position on the adapter to get the next item. + */ + public int CurrentPosition; + + /** + * Defines the direction in which the data adapter is traversed. + * Should be {@link #ITEM_DIRECTION_HEAD} or {@link #ITEM_DIRECTION_TAIL} + */ + public int ItemDirection; + + /** + * Defines the direction in which the layout is filled. + * Should be {@link #LAYOUT_START} or {@link #LAYOUT_END} + */ + public int LayoutDirection; + + /** + * Used when LayoutState is constructed in a scrolling state. + * It should be set the amount of scrolling we can make without creating a new view. + * Settings this is required for efficient view recycling. + */ + public float ScrollingOffset; + + /** + * Used if you want to pre-layout items that are not yet visible. + * The difference with {@link #mAvailable} is that, when recycling, distance laid out for + * {@link #mExtra} is not considered to avoid recycling visible children. + */ + public float Extra = 0; + + + /** + * @return true if there are more items in the data adapter + */ + public bool HasMore(int itemCount) + { + return CurrentPosition >= 0 && CurrentPosition < itemCount; + } + + /** + * Gets the view for the next element that we should layout. + * Also updates current item index to the next item, based on {@link #mItemDirection} + * + * @return The next element that we should layout. + */ + public FlexibleView.ViewHolder Next(FlexibleView.Recycler recycler) + { + FlexibleView.ViewHolder itemView = recycler.GetViewForPosition(CurrentPosition); + CurrentPosition += ItemDirection; + return itemView; + } + } + + internal class LayoutChunkResult + { + public float Consumed; + public bool Finished; + public bool IgnoreConsumed; + public bool Focusable; + + public void ResetInternal() + { + Consumed = 0; + Finished = false; + IgnoreConsumed = false; + Focusable = false; + } + } + + internal class AnchorInfo + { + public int Position; + public float Coordinate; + public bool LayoutFromEnd; + public bool Valid; + + public void Reset() + { + Position = NO_POSITION; + Coordinate = INVALID_OFFSET; + LayoutFromEnd = false; + Valid = false; + } + + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Controls/FlexibleView/OrientationHelper.cs b/src/Tizen.NUI.CommonUI/Controls/FlexibleView/OrientationHelper.cs new file mode 100755 index 000000000..779d2b8e3 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Controls/FlexibleView/OrientationHelper.cs @@ -0,0 +1,342 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System; + +namespace Tizen.NUI.CommonUI +{ + /** + * Helper class for LayoutManagers to abstract measurements depending on the View's orientation. + * It is developed to easily support vertical and horizontal orientations in a LayoutManager but + * can also be used to abstract calls around view bounds and child measurements with margins and + * decorations. + * + * @see #createHorizontalHelper(RecyclerView.LayoutManager) + * @see #createVerticalHelper(RecyclerView.LayoutManager) + */ + internal abstract class OrientationHelper + { + public static readonly int HORIZONTAL = 0; + public static readonly int VERTICAL = 1; + + private static readonly int INVALID_SIZE = -1; + + protected FlexibleView.LayoutManager mLayoutManager; + + private float mLastTotalSpace = INVALID_SIZE; + + public OrientationHelper(FlexibleView.LayoutManager layoutManager) + { + mLayoutManager = layoutManager; + } + + /** + * Call this method after onLayout method is complete if state is NOT pre-layout. + * This method records information like layout bounds that might be useful in the next layout + * calculations. + */ + public void OnLayoutComplete() + { + mLastTotalSpace = GetTotalSpace(); + } + + /** + * Returns the layout space change between the previous layout pass and current layout pass. + * Make sure you call {@link #onLayoutComplete()} at the end of your LayoutManager's + * {@link RecyclerView.LayoutManager#onLayoutChildren(RecyclerView.Recycler, + * RecyclerView.State)} method. + * + * @return The difference between the current total space and previous layout's total space. + * @see #onLayoutComplete() + */ + public float GetTotalSpaceChange() + { + return INVALID_SIZE == mLastTotalSpace ? 0 : GetTotalSpace() - mLastTotalSpace; + } + + /** + * Returns the start of the view including its decoration and margin. + * For example, for the horizontal helper, if a View's left is at pixel 20, has 2px left + * decoration and 3px left margin, returned value will be 15px. + * + * @param view The view element to check + * @return The first pixel of the element + * @see #getDecoratedEnd(android.view.View) + */ + public abstract float GetViewHolderStart(FlexibleView.ViewHolder holder); + + /** + * Returns the end of the view including its decoration and margin. + * For example, for the horizontal helper, if a View's right is at pixel 200, has 2px right + * decoration and 3px right margin, returned value will be 205. + * + * @param view The view element to check + * @return The last pixel of the element + * @see #getDecoratedStart(android.view.View) + */ + public abstract float GetViewHolderEnd(FlexibleView.ViewHolder holder); + + /** + * Returns the space occupied by this View in the current orientation including decorations and + * margins. + * + * @param view The view element to check + * @return Total space occupied by this view + * @see #getDecoratedMeasurementInOther(View) + */ + public abstract float GetViewHolderMeasurement(FlexibleView.ViewHolder holder); + + /** + * Returns the space occupied by this View in the perpendicular orientation including + * decorations and margins. + * + * @param view The view element to check + * @return Total space occupied by this view in the perpendicular orientation to current one + * @see #getDecoratedMeasurement(View) + */ + public abstract float GetViewHolderMeasurementInOther(FlexibleView.ViewHolder holder); + + /** + * Returns the start position of the layout after the start padding is added. + * + * @return The very first pixel we can draw. + */ + public abstract float GetStartAfterPadding(); + + /** + * Returns the end position of the layout after the end padding is removed. + * + * @return The end boundary for this layout. + */ + public abstract float GetEndAfterPadding(); + + /** + * Returns the end position of the layout without taking padding into account. + * + * @return The end boundary for this layout without considering padding. + */ + public abstract float GetEnd(); + + /** + * Offsets all children's positions by the given amount. + * + * @param amount Value to add to each child's layout parameters + */ + public abstract void OffsetChildren(float amount, bool immediate); + + /** + * Returns the total space to layout. This number is the difference between + * {@link #getEndAfterPadding()} and {@link #getStartAfterPadding()}. + * + * @return Total space to layout children + */ + public abstract float GetTotalSpace(); + + /** + * Offsets the child in this orientation. + * + * @param view View to offset + * @param offset offset amount + */ + internal abstract void OffsetChild(FlexibleView.ViewHolder holder, int offset); + + /** + * Returns the padding at the end of the layout. For horizontal helper, this is the right + * padding and for vertical helper, this is the bottom padding. This method does not check + * whether the layout is RTL or not. + * + * @return The padding at the end of the layout. + */ + public abstract float GetEndPadding(); + + /** + * Creates an OrientationHelper for the given LayoutManager and orientation. + * + * @param layoutManager LayoutManager to attach to + * @param orientation Desired orientation. Should be {@link #HORIZONTAL} or {@link #VERTICAL} + * @return A new OrientationHelper + */ + public static OrientationHelper CreateOrientationHelper( + FlexibleView.LayoutManager layoutManager, int orientation) + { + if (orientation == HORIZONTAL) + { + return CreateHorizontalHelper(layoutManager); + } + else if (orientation == VERTICAL) + { + return CreateVerticalHelper(layoutManager); + } + + throw new ArgumentException("invalid orientation"); + } + + + /** + * Creates a horizontal OrientationHelper for the given LayoutManager. + * + * @param layoutManager The LayoutManager to attach to. + * @return A new OrientationHelper + */ + public static OrientationHelper CreateHorizontalHelper(FlexibleView.LayoutManager layoutManager) + { + return new HorizontalHelper(layoutManager); + + } + /** + * Creates a vertical OrientationHelper for the given LayoutManager. + * + * @param layoutManager The LayoutManager to attach to. + * @return A new OrientationHelper + */ + public static OrientationHelper CreateVerticalHelper(FlexibleView.LayoutManager layoutManager) + { + return new VerticalHelper(layoutManager); + } + } + + internal class HorizontalHelper : OrientationHelper + { + public HorizontalHelper(FlexibleView.LayoutManager layoutManager): base(layoutManager) + { + + } + + public override float GetEndAfterPadding() + { + return mLayoutManager.GetWidth() - mLayoutManager.GetPaddingRight(); + } + + public override float GetEnd() + { + return mLayoutManager.GetWidth(); + } + + public override void OffsetChildren(float amount, bool immediate) + { + mLayoutManager.OffsetChildrenHorizontal(amount, immediate); + } + + + public override float GetStartAfterPadding() + { + return mLayoutManager.GetPaddingLeft(); + } + + public override float GetViewHolderMeasurement(FlexibleView.ViewHolder holder) + { + return holder.Right - holder.Left; + } + + public override float GetViewHolderMeasurementInOther(FlexibleView.ViewHolder holder) + { + return holder.Bottom - holder.Top; + } + + public override float GetViewHolderEnd(FlexibleView.ViewHolder holder) + { + return holder.Right; + } + + public override float GetViewHolderStart(FlexibleView.ViewHolder holder) + { + return holder.Left; + } + + public override float GetTotalSpace() + { + return mLayoutManager.GetWidth() - mLayoutManager.GetPaddingLeft() + - mLayoutManager.GetPaddingRight(); + } + + internal override void OffsetChild(FlexibleView.ViewHolder holder, int offset) + { + //holder.offsetLeftAndRight(offset); + } + + public override float GetEndPadding() + { + return mLayoutManager.GetPaddingRight(); + } + + } + + internal class VerticalHelper : OrientationHelper + { + public VerticalHelper(FlexibleView.LayoutManager layoutManager) : base(layoutManager) + { + + } + + public override float GetEndAfterPadding() + { + return mLayoutManager.GetHeight() - mLayoutManager.GetPaddingBottom(); + } + + public override float GetEnd() + { + return mLayoutManager.GetHeight(); + } + + public override void OffsetChildren(float amount, bool immediate) + { + mLayoutManager.OffsetChildrenVertical(amount, immediate); + } + + public override float GetStartAfterPadding() + { + return mLayoutManager.GetPaddingTop(); + } + + public override float GetViewHolderMeasurement(FlexibleView.ViewHolder holder) + { + return holder.Bottom - holder.Top; + } + + public override float GetViewHolderMeasurementInOther(FlexibleView.ViewHolder holder) + { + return holder.Right - holder.Left; + } + + public override float GetViewHolderEnd(FlexibleView.ViewHolder holder) + { + return holder.Bottom; + } + + public override float GetViewHolderStart(FlexibleView.ViewHolder holder) + { + return holder.Top; + } + + public override float GetTotalSpace() + { + return mLayoutManager.GetHeight() - mLayoutManager.GetPaddingTop() + - mLayoutManager.GetPaddingBottom(); + } + + internal override void OffsetChild(FlexibleView.ViewHolder holder, int offset) + { + //holder.offsetTopAndBottom(offset); + } + + public override float GetEndPadding() + { + return mLayoutManager.GetPaddingBottom(); + } + + } + +} diff --git a/src/Tizen.NUI.CommonUI/Controls/InputField.cs b/src/Tizen.NUI.CommonUI/Controls/InputField.cs new file mode 100755 index 000000000..4cc26b911 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Controls/InputField.cs @@ -0,0 +1,703 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System; +using Tizen.NUI.BaseComponents; +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// InputField is a editable input compoment + /// + /// 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 class InputField : Control + { + // the background image + private ImageView bgImage = null; + // the textField + private TextField textField = null; + // the attributes of the inputField + private InputFieldAttributes inputFieldAttrs = null; + // the flag indicate should relayout the textField in base class + private bool relayoutTextField = true; + + /// + /// Initializes a new instance of the InputField class. + /// + /// 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 InputField() : base() + { + Initialize(); + } + + /// 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 InputField(string style) : base(style) + { + Initialize(); + } + + /// + /// Initializes a new instance of the InputField class. + /// + /// Create Header by attributes customized by user. + /// 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 InputField(InputFieldAttributes attributes) : base(attributes) + { + Initialize(); + } + + /// + /// Gets or sets the property for the enabled state. + /// + /// 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 bool StateEnabled + { + get + { + return Sensitive; + } + set + { + Sensitive = value; + } + } + + /// + /// Gets or sets the property for the text content. + /// + /// 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 string Text + { + get + { + return textField.Text; + } + set + { + textField.Text = value; + } + } + + /// + /// Gets or sets the property for the hint text. + /// + /// 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 string HintText + { + get + { + return textField.PlaceholderText; + } + set + { + textField.PlaceholderText = value; + } + } + + /// + /// Gets or sets the property for the color of the input text. + /// + /// 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 Color TextColor + { + get + { + return textField.TextColor; + } + set + { + CreateTextFieldAttributes(); + if (null == inputFieldAttrs.InputBoxAttributes.TextColor) + { + inputFieldAttrs.InputBoxAttributes.TextColor = new ColorSelector(); + } + inputFieldAttrs.InputBoxAttributes.TextColor.All = value; + textField.TextColor = value; + } + } + + /// + /// Gets or sets text color. + /// + /// 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 Color HintTextColor + { + get + { + return textField.PlaceholderTextColor; + } + set + { + CreateTextFieldAttributes(); + if (null == inputFieldAttrs.InputBoxAttributes.PlaceholderTextColor) + { + inputFieldAttrs.InputBoxAttributes.PlaceholderTextColor = new ColorSelector(); + } + inputFieldAttrs.InputBoxAttributes.PlaceholderTextColor.All = value; + textField.PlaceholderTextColor = value; + } + } + + /// + /// Gets or sets primary cursor color. + /// + /// 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 Color PrimaryCursorColor + { + get + { + return textField.PrimaryCursorColor; + } + set + { + CreateTextFieldAttributes(); + if (null == inputFieldAttrs.InputBoxAttributes.PrimaryCursorColor) + { + inputFieldAttrs.InputBoxAttributes.PrimaryCursorColor = new ColorSelector(); + } + inputFieldAttrs.InputBoxAttributes.PrimaryCursorColor.All = value; + textField.PrimaryCursorColor = value; + } + } + + /// + /// Gets or sets secondary cursor color. + /// + /// 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 Color SecondaryCursorColor + { + get + { + return textField.SecondaryCursorColor; + } + set + { + CreateTextFieldAttributes(); + if (null == inputFieldAttrs.InputBoxAttributes.SecondaryCursorColor) + { + inputFieldAttrs.InputBoxAttributes.SecondaryCursorColor = new ColorSelector(); + } + inputFieldAttrs.InputBoxAttributes.SecondaryCursorColor.All = value; + textField.SecondaryCursorColor = value; + } + } + + /// + /// Gets or sets font family of text. + /// + /// 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 string FontFamily + { + get + { + return textField.FontFamily; + } + set + { + CreateTextFieldAttributes(); + inputFieldAttrs.InputBoxAttributes.FontFamily = value; + textField.FontFamily = value; + } + } + + /// + /// Gets or sets point size of text. + /// + /// 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 float PointSize + { + get + { + return textField.PointSize; + } + set + { + CreateTextFieldAttributes(); + if (null == inputFieldAttrs.InputBoxAttributes.PointSize) + { + inputFieldAttrs.InputBoxAttributes.PointSize = new FloatSelector(); + } + inputFieldAttrs.InputBoxAttributes.PointSize.All = value; + textField.PointSize = value; + } + } + + /// + /// Gets or sets enable cursor blink. + /// + /// 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 bool EnableCursorBlink + { + get + { + return textField.EnableCursorBlink; + } + set + { + CreateTextFieldAttributes(); + inputFieldAttrs.InputBoxAttributes.EnableCursorBlink = value; + textField.EnableCursorBlink = value; + } + } + + /// + /// Gets or sets enable selection. + /// + /// 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 bool EnableSelection + { + get + { + return textField.EnableSelection; + } + set + { + CreateTextFieldAttributes(); + inputFieldAttrs.InputBoxAttributes.EnableSelection = value; + textField.EnableSelection = value; + } + } + + /// + /// Gets or sets cursor width. + /// + /// 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 int CursorWidth + { + get + { + return textField.CursorWidth; + } + set + { + CreateTextFieldAttributes(); + inputFieldAttrs.InputBoxAttributes.CursorWidth = value; + textField.CursorWidth = value; + } + } + + /// + /// Gets or sets if enable ellipsis. + /// + /// 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 bool EnableEllipsis + { + get + { + return textField.Ellipsis; + } + set + { + CreateTextFieldAttributes(); + inputFieldAttrs.InputBoxAttributes.EnableEllipsis = value; + textField.Ellipsis = value; + } + } + + /// + /// Gets or sets background image's resource url of input field. + /// + /// 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 string BackgroundImageURL + { + get + { + return inputFieldAttrs.BackgroundImageAttributes?.ResourceUrl?.All; + } + set + { + if (value != null) + { + CreateBackgroundAttributes(); + if (inputFieldAttrs.BackgroundImageAttributes.ResourceUrl == null) + { + inputFieldAttrs.BackgroundImageAttributes.ResourceUrl = new StringSelector(); + } + inputFieldAttrs.BackgroundImageAttributes.ResourceUrl.All = value; + RelayoutRequest(); + } + } + } + + /// + /// Background image's border in Button. + /// + /// 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 Rectangle BackgroundImageBorder + { + get + { + return inputFieldAttrs.BackgroundImageAttributes?.Border?.All; + } + set + { + if (value != null) + { + CreateBackgroundAttributes(); + if (inputFieldAttrs.BackgroundImageAttributes.Border == null) + { + inputFieldAttrs.BackgroundImageAttributes.Border = new RectangleSelector(); + } + inputFieldAttrs.BackgroundImageAttributes.Border.All = value; + RelayoutRequest(); + } + } + } + + /// + /// Gets and Sets Space. + /// + public int Space + { + get + { + return inputFieldAttrs.Space ?? 0; + } + set + { + inputFieldAttrs.Space = value; + RelayoutRequest(); + } + } + + /// + /// Get Input Field attribues. + /// + /// 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 Attributes GetAttributes() + { + return new InputFieldAttributes(); + } + + /// + /// Dispose Input Field and all children on it. + /// + /// Dispose type. + /// 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 Dispose(DisposeTypes type) + { + if (disposed) + { + return; + } + if (type == DisposeTypes.Explicit) + { + if (bgImage != null) + { + this.Remove(bgImage); + bgImage.Dispose(); + bgImage = null; + } + if (null != textField) + { + textField.FocusGained -= OnTextFieldFocusGained; + textField.FocusLost -= OnTextFieldFocusLost; + textField.TextChanged -= OnTextFieldTextChanged; + textField.KeyEvent -= OnTextFieldKeyEvent; + this.Remove(textField); + textField.Dispose(); + textField = null; + } + } + + base.Dispose(type); + } + + /// + /// Update Input Field by attributes. + /// + /// 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 OnUpdate() + { + ApplyAttributes(this, inputFieldAttrs); + ApplyAttributes(bgImage, inputFieldAttrs.BackgroundImageAttributes); + ApplyAttributes(textField, inputFieldAttrs.InputBoxAttributes); + RelayoutComponent(); + OnLayoutDirectionChanged(); + } + + /// + /// 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) + { + InputFieldAttributes tempAttributes = StyleManager.Instance.GetAttributes(style) as InputFieldAttributes; + if (tempAttributes != null) + { + attributes = inputFieldAttrs = tempAttributes; + RelayoutRequest(); + } + } + + /// + /// Theme change callback when text field focus is gained, 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 virtual void OnTextFieldFocusGained(object source, EventArgs e) + { + } + + /// + /// Theme change callback when text field is lost, 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 virtual void OnTextFieldFocusLost(object source, EventArgs e) + { + } + + /// + /// Theme change callback when text field's text 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 virtual void OnTextFieldTextChanged(object sender, TextField.TextChangedEventArgs e) + { + } + + /// + /// Theme change callback when text field have a key event, 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 virtual bool OnTextFieldKeyEvent(object source, KeyEventArgs e) + { + return false; + } + + /// + /// Set the text field 2D size + /// + /// Input Field' width. + /// Input Field' height. + /// 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 void SetTextFieldSize2D(int w, int h) + { + if (textField != null) + { + textField.Size2D = new Size2D(w, h); + } + } + + /// + /// Set the text field X pose + /// + /// Input Field' X. + /// 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 void SetTextFieldPosX(int x) + { + if (textField != null) + { + textField.PositionX = x; + } + } + + /// + /// Set the text field text color + /// + /// Input Field' color. + /// 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 void SetTextFieldTextColor(Color color) + { + if (textField != null) + { + textField.TextColor = color; + } + } + + /// + /// Set the text field relayout flag + /// + /// relayout text field' value. + /// 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 void RelayoutTextField(bool value) + { + relayoutTextField = value; + } + + private void Initialize() + { + inputFieldAttrs = attributes as InputFieldAttributes; + if (null == inputFieldAttrs) + { + throw new Exception("Fail to get the InputField attributes."); + } + + bgImage = new ImageView(); + if (null == bgImage) + { + throw new Exception("Fail to create background image."); + } + + textField = new TextField(); + if (null == textField) + { + throw new Exception("Fail to create text field."); + } + + if (null != inputFieldAttrs.BackgroundImageAttributes) + { + bgImage.WidthResizePolicy = ResizePolicyType.FillToParent; + bgImage.HeightResizePolicy = ResizePolicyType.FillToParent; + bgImage.ParentOrigin = Tizen.NUI.ParentOrigin.Center; + bgImage.PivotPoint = Tizen.NUI.PivotPoint.Center; + bgImage.PositionUsesPivotPoint = true; + this.Add(bgImage); + } + + if (null != inputFieldAttrs.InputBoxAttributes) + { + textField.WidthResizePolicy = ResizePolicyType.Fixed; + textField.HeightResizePolicy = ResizePolicyType.Fixed; + textField.ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft; + textField.PivotPoint = Tizen.NUI.PivotPoint.CenterLeft; + textField.PositionUsesPivotPoint = true; + this.Add(textField); + + textField.FocusGained += OnTextFieldFocusGained; + textField.FocusLost += OnTextFieldFocusLost; + textField.TextChanged += OnTextFieldTextChanged; + textField.KeyEvent += OnTextFieldKeyEvent; + } + } + + private void OnLayoutDirectionChanged() + { + if (inputFieldAttrs == null) return; + if (textField != null) + { + if (LayoutDirection == ViewLayoutDirectionType.LTR) + { + if(inputFieldAttrs.InputBoxAttributes != null) + { + inputFieldAttrs.InputBoxAttributes.HorizontalAlignment = HorizontalAlignment.Begin; + inputFieldAttrs.InputBoxAttributes.ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft; + inputFieldAttrs.InputBoxAttributes.PivotPoint = Tizen.NUI.PivotPoint.CenterLeft; + inputFieldAttrs.InputBoxAttributes.PositionUsesPivotPoint = true; + } + textField.HorizontalAlignment = HorizontalAlignment.Begin; + textField.ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft; + textField.PivotPoint = Tizen.NUI.PivotPoint.CenterLeft; + textField.PositionUsesPivotPoint = true; + } + else //ViewLayoutDirectionType.RTL + { + if (inputFieldAttrs.InputBoxAttributes != null) + { + inputFieldAttrs.InputBoxAttributes.HorizontalAlignment = HorizontalAlignment.End; + inputFieldAttrs.InputBoxAttributes.ParentOrigin = Tizen.NUI.ParentOrigin.CenterRight; + inputFieldAttrs.InputBoxAttributes.PivotPoint = Tizen.NUI.PivotPoint.CenterRight; + } + textField.HorizontalAlignment = HorizontalAlignment.End; + textField.ParentOrigin = Tizen.NUI.ParentOrigin.CenterRight; + textField.PivotPoint = Tizen.NUI.PivotPoint.CenterRight; + textField.PositionUsesPivotPoint = true; + } + } + } + + private void RelayoutComponent() + { + if (!relayoutTextField) + { + return; + } + int space = inputFieldAttrs.Space ?? 0; + + if (textField != null) + { + textField.Size2D = new Size2D(this.Size2D.Width - space * 2, this.Size2D.Height); + textField.PositionX = space; + } + } + + private void CreateBackgroundAttributes() + { + if (null == inputFieldAttrs.BackgroundImageAttributes) + { + inputFieldAttrs.BackgroundImageAttributes = new ImageAttributes(); + } + } + + private void CreateTextFieldAttributes() + { + if (null == inputFieldAttrs.InputBoxAttributes) + { + inputFieldAttrs.InputBoxAttributes = new TextFieldAttributes(); + } + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Controls/Loading.cs b/src/Tizen.NUI.CommonUI/Controls/Loading.cs new file mode 100755 index 000000000..4b3595f59 --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Controls/Loading.cs @@ -0,0 +1,229 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System; +using System.Collections.Generic; +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// The Loading class of nui component. It's used to indicate informs users of the ongoing operation. + /// + /// 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 class Loading : Control + { + private LoadingAttributes loadingAttrs = null; // Loading Attributes + private AnimatedImageVisual imageVisual = null; + + /// + /// The constructor of Loading + /// + /// 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 Loading() : base() + { + Initialize(); + } + + /// + /// Constructor of the Loading class with special style. + /// + /// The string to initialize the Loading. + /// 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 Loading(string style) : base(style) + { + Initialize(); + } + + /// + /// The constructor of the Loading class with specific Attributes. + /// + /// The Attributes object to initialize the Loading. + /// 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 Loading(LoadingAttributes attributes) : base(attributes) + { + Initialize(); + } + + /// + /// Gets or sets loading image resource array. + /// + /// 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 string[] ImageArray + { + get + { + return loadingAttrs.ImageArray; + } + set + { + if (null != value) + { + loadingAttrs.ImageArray = value; + imageVisual.URLS = new List(value); + } + } + } + + /// + /// Gets or sets loading 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 Size2D LoadingSize + { + get + { + return loadingAttrs.LoadingSize ?? new Size2D(100, 100); + } + set + { + loadingAttrs.LoadingSize = value; + imageVisual.Size = value; + } + } + + /// + /// Gets or sets FPS of loading. + /// + /// 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 int FPS + { + get + { + return loadingAttrs?.FPS?.All ?? (int)(1000.0f / 16.6f); + } + set + { + if (value != 0) //It will crash if 0 + { + if (null == loadingAttrs.FPS) + { + loadingAttrs.FPS = new IntSelector(); + } + loadingAttrs.FPS.All = value; + imageVisual.FrameDelay = 1000.0f / value; + } + } + } + + /// + /// Get Loading attribues. + /// + /// 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 Attributes GetAttributes() + { + return new LoadingAttributes(); + } + + /// + /// Dispose Loading. + /// + /// Dispose type. + /// 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 Dispose(DisposeTypes type) + { + if (disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) + { + //Called by User + //Release your own managed resources here. + //You should release all of your own disposable objects here. + RemoveVisual("loadingImageVisual"); + } + + //Release your own unmanaged resources here. + //You should not access any managed member here except static instance. + //because the execution order of Finalizes is non-deterministic. + //Unreference this from if a static instance refer to this. + + //You must call base.Dispose(type) just before exit. + base.Dispose(type); + } + + /// + /// Update Loading by attributes. + /// + /// 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 OnUpdate() + { + } + + private void Initialize() + { + loadingAttrs = attributes as LoadingAttributes; + if (null == loadingAttrs) + { + throw new Exception("Loading attribute parse error."); + } + ApplyAttributes(this, loadingAttrs); + + imageVisual = new AnimatedImageVisual() + { + URLS = new List(), + FrameDelay = 16.6f, + LoopCount = -1, + Size = new Size2D(100, 100), + Position = new Vector2(0, 0), + Origin = Visual.AlignType.Center, + AnchorPoint = Visual.AlignType.Center + }; + + UpdateVisual(); + + this.AddVisual("loadingImageVisual", imageVisual); + } + + private void UpdateVisual() + { + if (null != loadingAttrs.ImageArray) + { + imageVisual.URLS = new List(loadingAttrs.ImageArray); + } + if (null != loadingAttrs.FPS) + { + imageVisual.FrameDelay = 1000.0f / (float)loadingAttrs.FPS.All; + } + if (null != loadingAttrs.LoadingSize) + { + imageVisual.Size = loadingAttrs.LoadingSize; + } + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Controls/Pagination.cs b/src/Tizen.NUI.CommonUI/Controls/Pagination.cs new file mode 100755 index 000000000..e9ddfa54b --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Controls/Pagination.cs @@ -0,0 +1,407 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI.CommonUI +{ + /// + /// Pagination shows the number of pages available and the currently active page. + /// + /// 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 class Pagination: Control + { + private PaginationAttributes paginationAttributes; + + private VisualView container; + + private List indicatorList = new List(); + private ImageVisual selectIndicator; + + private int indicatorCount = 0; + private int selectedIndex = -1; + + /// + /// Creates a new instance of a Pagination. + /// + /// 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 Pagination() : base() + { + Initialize(); + } + + /// + /// Creates a new instance of a Pagination using style. + /// + /// 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 Pagination(string style) : base(style) + { + Initialize(); + } + + /// + /// Creates a new instance of a Pagination using attributes. + /// + /// 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 Pagination(PaginationAttributes attributes) : base(attributes) + { + Initialize(); + } + + /// + /// Gets or sets the size of the indicator. + /// + /// 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 Size2D IndicatorSize + { + get + { + return paginationAttributes?.IndicatorSize; + } + set + { + if (value == null || paginationAttributes == null) + { + return; + } + paginationAttributes.IndicatorSize = value; + RelayoutRequest(); + } + } + + /// + /// Gets or sets the background resource of indicator. + /// + /// 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 string IndicatorBackgroundURL + { + get + { + return paginationAttributes?.IndicatorBackgroundURL; + } + set + { + if (value == null || paginationAttributes == null) + { + return; + } + paginationAttributes.IndicatorBackgroundURL = value; + RelayoutRequest(); + } + } + + /// + /// Gets or sets the resource of the select indicator. + /// + /// 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 string IndicatorSelectURL + { + get + { + return paginationAttributes?.IndicatorSelectURL; + } + set + { + if (value == null || paginationAttributes == null) + { + return; + } + paginationAttributes.IndicatorSelectURL = value; + RelayoutRequest(); + } + } + + /// + /// Gets or sets the space of the indicator. + /// + /// 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 int IndicatorSpacing + { + get + { + return (int)paginationAttributes?.IndicatorSpacing; + } + set + { + if (paginationAttributes == null) + { + return; + } + paginationAttributes.IndicatorSpacing = value; + RelayoutRequest(); + } + } + + + /// + /// Gets or sets the count of the pages/indicators. + /// + /// 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 int IndicatorCount + { + get + { + return indicatorCount; + } + set + { + if (indicatorCount == value || indicatorCount < 0) + { + return; + } + if (indicatorCount < value) + { + for (int i = indicatorCount; i < value; i++) + { + CreateIndicator(); + } + } + else + { + for (int i = value; i < indicatorCount; i++) + { + ImageVisual indicator = indicatorList[i]; + container.RemoveVisual("Indicator" + i); + } + indicatorList.RemoveRange(value, indicatorCount - value); + if(value <= 0) + { + container.RemoveVisual("SelectIndicator"); + } + else if(selectedIndex >= value) + { + selectedIndex = 0; + SelectIn(indicatorList[selectedIndex]); + } + } + indicatorCount = value; + + UpdateContainer(); + } + } + + /// + /// Gets or sets the index of the select indicator. + /// + /// 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 int SelectedIndex + { + get + { + return selectedIndex; + } + set + { + if (selectedIndex == value) + { + return; + } + if (selectedIndex >= 0 && selectedIndex < indicatorCount) + { + SelectOut(indicatorList[selectedIndex]); + } + selectedIndex = value; + if (selectedIndex >= 0 && selectedIndex < indicatorCount) + { + SelectIn(indicatorList[selectedIndex]); + } + } + } + + /// + /// Retrieves the position of a indicator by index. + /// + /// Indicator index + /// 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 Position2D GetIndicatorPosition(int index) + { + if (index < 0 || index >= indicatorList.Count) + { + return null; + } + return new Vector2(indicatorList[index].Position.X + container.PositionX, indicatorList[index].Position.Y + container.PositionY); + } + + /// + /// You can override it to do your select out operation. + /// + /// The indicator will be selected out + /// 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 virtual void SelectOut(VisualMap selectOutIndicator) + { + + } + + /// + /// You can override it to do your select in operation. + /// + /// The indicator will be selected in + /// 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 virtual void SelectIn(VisualMap selectInIndicator) + { + selectIndicator.Position = selectInIndicator.Position; + } + + /// + /// you can override it to create your own default attributes. + /// + /// 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 Attributes GetAttributes() + { + return new PaginationAttributes(); + } + + /// + /// you can override it to clean-up your own resources. + /// + /// DisposeTypes + /// 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 Dispose(DisposeTypes type) + { + if (disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) + { + container.RemoveAll(); + indicatorList.Clear(); + + this.Remove(container); + container.Dispose(); + container = null; + } + + base.Dispose(type); + } + + /// + /// you can override it to update your own resources. + /// + /// 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 OnUpdate() + { + + for (int i = 0; i < indicatorList.Count; i++) + { + ImageVisual indicator = indicatorList[i]; + indicator.URL = paginationAttributes.IndicatorBackgroundURL; + indicator.Size = paginationAttributes.IndicatorSize; + indicator.Position = new Position2D((int)(paginationAttributes.IndicatorSize.Width + paginationAttributes.IndicatorSpacing) * i, 0); + } + + selectIndicator.URL = paginationAttributes.IndicatorSelectURL; + selectIndicator.Size = paginationAttributes.IndicatorSize; + + //UpdateContainer(); + } + + private void Initialize() + { + paginationAttributes = attributes as PaginationAttributes; + if (paginationAttributes == null) + { + throw new Exception("Pagination attributes is null."); + } + + container = new VisualView() + { + Name = "Container", + ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft, + PivotPoint = Tizen.NUI.PivotPoint.CenterLeft, + PositionUsesPivotPoint = true, + //BackgroundColor = Color.Yellow + }; + this.Add(container); + + selectIndicator = new ImageVisual() + { + URL = " " + }; + container.AddVisual("SelectIndicator", selectIndicator); + } + + private void CreateIndicator() + { + if (paginationAttributes == null) + { + return; + } + ImageVisual indicator = new ImageVisual + { + URL = paginationAttributes.IndicatorBackgroundURL, + Size = paginationAttributes.IndicatorSize + }; + indicator.Position = new Position2D((int)(paginationAttributes.IndicatorSize.Width + paginationAttributes.IndicatorSpacing) * indicatorList.Count, 0); + container.AddVisual("Indicator" + indicatorList.Count, indicator); + indicatorList.Add(indicator); + } + + private void UpdateContainer() + { + if (paginationAttributes == null) + { + return; + } + if (indicatorList.Count > 0) + { + container.SizeWidth = (paginationAttributes.IndicatorSize.Width + paginationAttributes.IndicatorSpacing) * indicatorList.Count - paginationAttributes.IndicatorSpacing; + } + else + { + container.SizeWidth = 0; + } + container.SizeHeight = paginationAttributes.IndicatorSize.Height; + container.PositionX = (int)((this.SizeWidth - container.SizeWidth) / 2); + } + } +} diff --git a/src/Tizen.NUI.CommonUI/Controls/Popup.cs b/src/Tizen.NUI.CommonUI/Controls/Popup.cs new file mode 100755 index 000000000..699b6f2be --- /dev/null +++ b/src/Tizen.NUI.CommonUI/Controls/Popup.cs @@ -0,0 +1,1054 @@ +/* + * Copyright(c) 2019 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. + * + */ +using System; +using System.Collections.Generic; +using Tizen.NUI.BaseComponents; +using System.ComponentModel; + +namespace Tizen.NUI.CommonUI +{ + /// + /// Popup is one kind of common component, it can be used as popup window. + /// User can handle Popup button count, head title and content area. + /// + /// 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 class Popup : Control + { + private ImageView backgroundImage; + private ImageView shadowImage; + private TextLabel titleText; + private List