43c7d1e96ac78852bce2497fec42618757a2c2ab
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / Style / ImageViewStyle.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;
18 using System.ComponentModel;
19 using Tizen.NUI.Binding;
20
21 namespace Tizen.NUI.BaseComponents
22 {
23     /// <summary>
24     /// The base class for Children attributes in Components.
25     /// </summary>
26     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
27     [EditorBrowsable(EditorBrowsableState.Never)]
28     public class ImageViewStyle : ViewStyle
29     {
30         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
31         [EditorBrowsable(EditorBrowsableState.Never)]
32         public static readonly BindableProperty ResourceUrlSelectorProperty = BindableProperty.Create("ResourceUrlSelector", typeof(Selector<string>), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
33         {
34             var imageViewStyle = (ImageViewStyle)bindable;
35             imageViewStyle.resourceUrlSelector = ((Selector<string>)newValue)?.Clone();
36         },
37         defaultValueCreator: (bindable) =>
38         {
39             var imageViewStyle = (ImageViewStyle)bindable;
40             return imageViewStyle.resourceUrlSelector;
41         });
42         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
43         [EditorBrowsable(EditorBrowsableState.Never)]
44         public static readonly BindableProperty PreMultipliedAlphaProperty = BindableProperty.Create(nameof(PreMultipliedAlpha), typeof(bool?), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
45         {
46             var imageViewStyle = (ImageViewStyle)bindable;
47             imageViewStyle.preMultipliedAlpha = (bool?)newValue;
48         },
49         defaultValueCreator: (bindable) =>
50         {
51             var imageViewStyle = (ImageViewStyle)bindable;
52             return imageViewStyle.preMultipliedAlpha;
53         });
54         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
55         [EditorBrowsable(EditorBrowsableState.Never)]
56         public static readonly BindableProperty PixelAreaProperty = BindableProperty.Create(nameof(PixelArea), typeof(RelativeVector4), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
57         {
58             var imageViewStyle = (ImageViewStyle)bindable;
59             imageViewStyle.pixelArea = (RelativeVector4)newValue;
60         },
61         defaultValueCreator: (bindable) =>
62         {
63             var imageViewStyle = (ImageViewStyle)bindable;
64             return imageViewStyle.pixelArea;
65         });
66         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
67         [EditorBrowsable(EditorBrowsableState.Never)]
68         public static readonly BindableProperty BorderSelectorProperty = BindableProperty.Create("BorderSelector", typeof(Selector<Rectangle>), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
69         {
70             var imageViewStyle = (ImageViewStyle)bindable;
71             imageViewStyle.borderSelector = ((Selector<Rectangle>)newValue)?.Clone();
72         },
73         defaultValueCreator: (bindable) =>
74         {
75             var imageViewStyle = (ImageViewStyle)bindable;
76             return imageViewStyle.borderSelector;
77         });
78         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
79         [EditorBrowsable(EditorBrowsableState.Never)]
80         public static readonly BindableProperty BorderOnlyProperty = BindableProperty.Create(nameof(BorderOnly), typeof(bool?), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
81         {
82             var imageViewStyle = (ImageViewStyle)bindable;
83             imageViewStyle.borderOnly = (bool?)newValue;
84         },
85         defaultValueCreator: (bindable) =>
86         {
87             var imageViewStyle = (ImageViewStyle)bindable;
88             return imageViewStyle.borderOnly;
89         });
90         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
91         [EditorBrowsable(EditorBrowsableState.Never)]
92         public static readonly BindableProperty SynchronosLoadingProperty = BindableProperty.Create(nameof(SynchronosLoading), typeof(bool?), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
93         {
94             var imageViewStyle = (ImageViewStyle)bindable;
95             imageViewStyle.synchronosLoading = (bool?)newValue;
96         },
97         defaultValueCreator: (bindable) =>
98         {
99             var imageViewStyle = (ImageViewStyle)bindable;
100             return imageViewStyle.synchronosLoading;
101         });
102         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
103         [EditorBrowsable(EditorBrowsableState.Never)]
104         public static readonly BindableProperty OrientationCorrectionProperty = BindableProperty.Create(nameof(OrientationCorrection), typeof(bool?), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
105         {
106             var imageViewStyle = (ImageViewStyle)bindable;
107             imageViewStyle.orientationCorrection = (bool?)newValue;
108         },
109         defaultValueCreator: (bindable) =>
110         {
111             var imageViewStyle = (ImageViewStyle)bindable;
112             return imageViewStyle.orientationCorrection;
113         });
114
115         private bool? preMultipliedAlpha;
116         private RelativeVector4 pixelArea;
117         private bool? borderOnly;
118         private bool? synchronosLoading;
119         private bool? orientationCorrection;
120         private Selector<string> resourceUrlSelector;
121         private Selector<Rectangle> borderSelector;
122
123         static ImageViewStyle() { }
124
125         /// <summary>
126         /// Create an empty instance.
127         /// </summary>
128         [EditorBrowsable(EditorBrowsableState.Never)]
129         public ImageViewStyle() : base()
130         {
131         }
132
133         /// <summary>
134         /// Create an instance and set properties from the given ImageView.
135         /// </summary>
136         /// <param name="imageView">The ImageView instance that includes property data.</param>
137         [EditorBrowsable(EditorBrowsableState.Never)]
138         public ImageViewStyle(ImageView imageView) : base(imageView)
139         {
140         }
141
142         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
143         [EditorBrowsable(EditorBrowsableState.Never)]
144         public bool? PreMultipliedAlpha
145         {
146             get => (bool?)GetValue(PreMultipliedAlphaProperty);
147             set => SetValue(PreMultipliedAlphaProperty, value);
148         }
149
150         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
151         [EditorBrowsable(EditorBrowsableState.Never)]
152         public RelativeVector4 PixelArea
153         {
154             get => (RelativeVector4)GetValue(PixelAreaProperty);
155             set => SetValue(PixelAreaProperty, value);
156         }
157
158         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
159         [EditorBrowsable(EditorBrowsableState.Never)]
160         public bool? BorderOnly
161         {
162             get => (bool?)GetValue(BorderOnlyProperty);
163             set => SetValue(BorderOnlyProperty, value);
164         }
165
166         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
167         [EditorBrowsable(EditorBrowsableState.Never)]
168         public bool? SynchronosLoading
169         {
170             get => (bool?)GetValue(SynchronosLoadingProperty);
171             set => SetValue(SynchronosLoadingProperty, value);
172         }
173
174         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
175         [EditorBrowsable(EditorBrowsableState.Never)]
176         public bool? OrientationCorrection
177         {
178             get => (bool?)GetValue(OrientationCorrectionProperty);
179             set => SetValue(OrientationCorrectionProperty, value);
180         }
181
182         /// <summary>
183         /// Image URL.
184         /// </summary>
185         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
186         [EditorBrowsable(EditorBrowsableState.Never)]
187         public Selector<string> ResourceUrl
188         {
189             get
190             {
191                 Selector<string> tmp = (Selector<string>)GetValue(ResourceUrlSelectorProperty);
192                 return (null != tmp) ? tmp : resourceUrlSelector = new Selector<string>();
193             }
194             set => SetValue(ResourceUrlSelectorProperty, value);
195         }
196
197         /// <summary>
198         /// Image border.
199         /// </summary>
200         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
201         [EditorBrowsable(EditorBrowsableState.Never)]
202         public Selector<Rectangle> Border
203         {
204             get
205             {
206                 Selector<Rectangle> tmp = (Selector<Rectangle>)GetValue(BorderSelectorProperty);
207                 return (null != tmp) ? tmp : borderSelector = new Selector<Rectangle>();
208             }
209             set => SetValue(BorderSelectorProperty, value);
210         }
211     }
212 }