Fix components issue 1216 (#1194) (#1201)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Style / ScrollbarStyle.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 using System.ComponentModel;
18 using Tizen.NUI.BaseComponents;
19 using Tizen.NUI.Binding;
20
21 namespace Tizen.NUI.Components
22 {
23     /// <summary>
24     /// ScrollBarStyle is a class which saves Scrollbar's ux data.
25     /// </summary>
26     /// <since_tizen> 6 </since_tizen>
27     /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
28     [EditorBrowsable(EditorBrowsableState.Never)]
29     public class ScrollBarStyle : ControlStyle
30     {
31         /// <summary>
32         /// Creates a new instance of a ScrollBarStyle.
33         /// </summary>
34         /// <since_tizen> 6 </since_tizen>
35         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
36         [EditorBrowsable(EditorBrowsableState.Never)]
37         public ScrollBarStyle() : base()
38         {
39             InitSubStyle();
40             Direction = ScrollBar.DirectionType.Horizontal;
41         }
42
43         /// <summary>
44         /// Creates a new instance of a ScrollBarStyle with style.
45         /// </summary>
46         /// <param name="style">Create ScrollBarStyle by style customized by user.</param>
47         /// <since_tizen> 6 </since_tizen>
48         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
49         [EditorBrowsable(EditorBrowsableState.Never)]
50         public ScrollBarStyle(ScrollBarStyle style) : base(style)
51         {
52             if (null == style) return;
53
54             InitSubStyle();
55
56             this.CopyFrom(style);
57         }
58
59         /// <summary>
60         /// Get or set track image style
61         /// </summary>
62         /// <since_tizen> 6 </since_tizen>
63         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
64         [EditorBrowsable(EditorBrowsableState.Never)]
65         public ImageViewStyle Track
66         {
67             get;
68             set;
69         }
70
71         /// <summary>
72         /// Get or set thumb image style
73         /// </summary>
74         /// <since_tizen> 6 </since_tizen>
75         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
76         [EditorBrowsable(EditorBrowsableState.Never)]
77         public ImageViewStyle Thumb
78         {
79             get;
80             set;
81         }
82
83         /// <summary>
84         /// Get or set direction type
85         /// </summary>
86         /// <since_tizen> 6 </since_tizen>
87         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
88         [EditorBrowsable(EditorBrowsableState.Never)]
89         public ScrollBar.DirectionType? Direction
90         {
91             get;
92             set;
93         }
94
95         /// <summary>
96         /// Get or set duration
97         /// </summary>
98         /// <since_tizen> 6 </since_tizen>
99         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
100         [EditorBrowsable(EditorBrowsableState.Never)]
101         public uint Duration
102         {
103             get;
104             set;
105         }
106
107         /// <summary>
108         /// Attributes's clone function.
109         /// </summary>
110         /// <since_tizen> 6 </since_tizen>
111         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
112         [EditorBrowsable(EditorBrowsableState.Never)]
113         public override void CopyFrom(BindableObject bindableObject)
114         {
115             base.CopyFrom(bindableObject);
116
117             ScrollBarStyle scrollBarStyle = bindableObject as ScrollBarStyle;
118
119             if (null != scrollBarStyle)
120             {
121                 if (null != scrollBarStyle.Track)
122                 {
123                     Track.CopyFrom(scrollBarStyle.Track);
124                 }
125
126                 if (null != scrollBarStyle.Thumb)
127                 {
128                     Thumb.CopyFrom(scrollBarStyle.Thumb);
129                 }
130
131                 Direction = scrollBarStyle.Direction;
132                 Duration = scrollBarStyle.Duration;
133             }
134         }
135
136         private void InitSubStyle()
137         {
138             Track = new ImageViewStyle()
139             {
140                 PositionUsesPivotPoint = true,
141                 ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft,
142                 PivotPoint = Tizen.NUI.PivotPoint.CenterLeft,
143                 WidthResizePolicy = ResizePolicyType.FillToParent,
144                 HeightResizePolicy = ResizePolicyType.FillToParent
145             };
146
147             Thumb = new ImageViewStyle()
148             {
149                 PositionUsesPivotPoint = true,
150                 ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft,
151                 PivotPoint = Tizen.NUI.PivotPoint.CenterLeft,
152                 WidthResizePolicy = ResizePolicyType.Fixed,
153                 HeightResizePolicy = ResizePolicyType.Fixed
154             };
155         }
156     }
157 }