[NUI.Components] Fix Background Image not works issue (#1246)
[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         static ScrollBarStyle() { }
32
33         /// <summary>
34         /// Creates a new instance of a ScrollBarStyle.
35         /// </summary>
36         /// <since_tizen> 6 </since_tizen>
37         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
38         [EditorBrowsable(EditorBrowsableState.Never)]
39         public ScrollBarStyle() : base()
40         {
41             InitSubStyle();
42             Direction = ScrollBar.DirectionType.Horizontal;
43         }
44
45         /// <summary>
46         /// Creates a new instance of a ScrollBarStyle with style.
47         /// </summary>
48         /// <param name="style">Create ScrollBarStyle by style customized by user.</param>
49         /// <since_tizen> 6 </since_tizen>
50         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
51         [EditorBrowsable(EditorBrowsableState.Never)]
52         public ScrollBarStyle(ScrollBarStyle style) : base(style)
53         {
54             if (null == style) return;
55
56             InitSubStyle();
57
58             this.CopyFrom(style);
59         }
60
61         /// <summary>
62         /// Get or set track image style
63         /// </summary>
64         /// <since_tizen> 6 </since_tizen>
65         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
66         [EditorBrowsable(EditorBrowsableState.Never)]
67         public ImageViewStyle Track
68         {
69             get;
70             set;
71         }
72
73         /// <summary>
74         /// Get or set thumb image style
75         /// </summary>
76         /// <since_tizen> 6 </since_tizen>
77         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
78         [EditorBrowsable(EditorBrowsableState.Never)]
79         public ImageViewStyle Thumb
80         {
81             get;
82             set;
83         }
84
85         /// <summary>
86         /// Get or set direction type
87         /// </summary>
88         /// <since_tizen> 6 </since_tizen>
89         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
90         [EditorBrowsable(EditorBrowsableState.Never)]
91         public ScrollBar.DirectionType? Direction
92         {
93             get;
94             set;
95         }
96
97         /// <summary>
98         /// Get or set duration
99         /// </summary>
100         /// <since_tizen> 6 </since_tizen>
101         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
102         [EditorBrowsable(EditorBrowsableState.Never)]
103         public uint Duration
104         {
105             get;
106             set;
107         }
108
109         /// <summary>
110         /// Attributes's clone function.
111         /// </summary>
112         /// <since_tizen> 6 </since_tizen>
113         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
114         [EditorBrowsable(EditorBrowsableState.Never)]
115         public override void CopyFrom(BindableObject bindableObject)
116         {
117             base.CopyFrom(bindableObject);
118
119             ScrollBarStyle scrollBarStyle = bindableObject as ScrollBarStyle;
120
121             if (null != scrollBarStyle)
122             {
123                 if (null != scrollBarStyle.Track)
124                 {
125                     Track.CopyFrom(scrollBarStyle.Track);
126                 }
127
128                 if (null != scrollBarStyle.Thumb)
129                 {
130                     Thumb.CopyFrom(scrollBarStyle.Thumb);
131                 }
132
133                 Direction = scrollBarStyle.Direction;
134                 Duration = scrollBarStyle.Duration;
135             }
136         }
137
138         private void InitSubStyle()
139         {
140             Track = new ImageViewStyle()
141             {
142                 PositionUsesPivotPoint = true,
143                 ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft,
144                 PivotPoint = Tizen.NUI.PivotPoint.CenterLeft,
145                 WidthResizePolicy = ResizePolicyType.FillToParent,
146                 HeightResizePolicy = ResizePolicyType.FillToParent
147             };
148
149             Thumb = new ImageViewStyle()
150             {
151                 PositionUsesPivotPoint = true,
152                 ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft,
153                 PivotPoint = Tizen.NUI.PivotPoint.CenterLeft,
154                 WidthResizePolicy = ResizePolicyType.Fixed,
155                 HeightResizePolicy = ResizePolicyType.Fixed
156             };
157         }
158     }
159 }