[NUI] Fix extents issue and unified style format (#1286)
[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             if (null == imageViewStyle.resourceUrlSelector) imageViewStyle.resourceUrlSelector = new Selector<string>();
36             imageViewStyle.resourceUrlSelector.Clone(null == newValue ? new Selector<string>() : (Selector<string>)newValue);
37         },
38         defaultValueCreator: (bindable) =>
39         {
40             var imageViewStyle = (ImageViewStyle)bindable;
41             return imageViewStyle.resourceUrlSelector;
42         });
43         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
44         [EditorBrowsable(EditorBrowsableState.Never)]
45         public static readonly BindableProperty PreMultipliedAlphaProperty = BindableProperty.Create(nameof(PreMultipliedAlpha), typeof(bool?), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
46         {
47             var imageViewStyle = (ImageViewStyle)bindable;
48             imageViewStyle.preMultipliedAlpha = (bool?)newValue;
49         },
50         defaultValueCreator: (bindable) =>
51         {
52             var imageViewStyle = (ImageViewStyle)bindable;
53             return imageViewStyle.preMultipliedAlpha;
54         });
55         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
56         [EditorBrowsable(EditorBrowsableState.Never)]
57         public static readonly BindableProperty PixelAreaProperty = BindableProperty.Create(nameof(PixelArea), typeof(RelativeVector4), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
58         {
59             var imageViewStyle = (ImageViewStyle)bindable;
60             imageViewStyle.pixelArea = (RelativeVector4)newValue;
61         },
62         defaultValueCreator: (bindable) =>
63         {
64             var imageViewStyle = (ImageViewStyle)bindable;
65             return imageViewStyle.pixelArea;
66         });
67         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
68         [EditorBrowsable(EditorBrowsableState.Never)]
69         public static readonly BindableProperty BorderSelectorProperty = BindableProperty.Create("BorderSelector", typeof(Selector<Rectangle>), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
70         {
71             var imageViewStyle = (ImageViewStyle)bindable;
72             if (null == imageViewStyle.borderSelector) imageViewStyle.borderSelector = new Selector<Rectangle>();
73             imageViewStyle.borderSelector.Clone(null == newValue ? new Selector<Rectangle>() : (Selector<Rectangle>)newValue);
74         },
75         defaultValueCreator: (bindable) =>
76         {
77             var imageViewStyle = (ImageViewStyle)bindable;
78             return imageViewStyle.borderSelector;
79         });
80         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
81         [EditorBrowsable(EditorBrowsableState.Never)]
82         public static readonly BindableProperty BorderOnlyProperty = BindableProperty.Create(nameof(BorderOnly), typeof(bool?), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
83         {
84             var imageViewStyle = (ImageViewStyle)bindable;
85             imageViewStyle.borderOnly = (bool?)newValue;
86         },
87         defaultValueCreator: (bindable) =>
88         {
89             var imageViewStyle = (ImageViewStyle)bindable;
90             return imageViewStyle.borderOnly;
91         });
92         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
93         [EditorBrowsable(EditorBrowsableState.Never)]
94         public static readonly BindableProperty SynchronosLoadingProperty = BindableProperty.Create(nameof(SynchronosLoading), typeof(bool?), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
95         {
96             var imageViewStyle = (ImageViewStyle)bindable;
97             imageViewStyle.synchronosLoading = (bool?)newValue;
98         },
99         defaultValueCreator: (bindable) =>
100         {
101             var imageViewStyle = (ImageViewStyle)bindable;
102             return imageViewStyle.synchronosLoading;
103         });
104         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
105         [EditorBrowsable(EditorBrowsableState.Never)]
106         public static readonly BindableProperty OrientationCorrectionProperty = BindableProperty.Create(nameof(OrientationCorrection), typeof(bool?), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
107         {
108             var imageViewStyle = (ImageViewStyle)bindable;
109             imageViewStyle.orientationCorrection = (bool?)newValue;
110         },
111         defaultValueCreator: (bindable) =>
112         {
113             var imageViewStyle = (ImageViewStyle)bindable;
114             return imageViewStyle.orientationCorrection;
115         });
116
117         private bool? preMultipliedAlpha;
118         private RelativeVector4 pixelArea;
119         private bool? borderOnly;
120         private bool? synchronosLoading;
121         private bool? orientationCorrection;
122         private Selector<string> resourceUrlSelector;
123         private Selector<Rectangle> borderSelector;
124
125         static ImageViewStyle() { }
126
127         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
128         [EditorBrowsable(EditorBrowsableState.Never)]
129         public bool? PreMultipliedAlpha
130         {
131             get => (bool?)GetValue(PreMultipliedAlphaProperty);
132             set => SetValue(PreMultipliedAlphaProperty, value);
133         }
134
135         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
136         [EditorBrowsable(EditorBrowsableState.Never)]
137         public RelativeVector4 PixelArea
138         {
139             get => (RelativeVector4)GetValue(PixelAreaProperty);
140             set => SetValue(PixelAreaProperty, value);
141         }
142
143         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
144         [EditorBrowsable(EditorBrowsableState.Never)]
145         public bool? BorderOnly
146         {
147             get => (bool?)GetValue(BorderOnlyProperty);
148             set => SetValue(BorderOnlyProperty, value);
149         }
150
151         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
152         [EditorBrowsable(EditorBrowsableState.Never)]
153         public bool? SynchronosLoading
154         {
155             get => (bool?)GetValue(SynchronosLoadingProperty);
156             set => SetValue(SynchronosLoadingProperty, value);
157         }
158
159         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
160         [EditorBrowsable(EditorBrowsableState.Never)]
161         public bool? OrientationCorrection
162         {
163             get => (bool?)GetValue(OrientationCorrectionProperty);
164             set => SetValue(OrientationCorrectionProperty, value);
165         }
166
167         /// <summary>
168         /// Image URL.
169         /// </summary>
170         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
171         [EditorBrowsable(EditorBrowsableState.Never)]
172         public Selector<string> ResourceUrl
173         {
174             get
175             {
176                 Selector<string> tmp = (Selector<string>)GetValue(ResourceUrlSelectorProperty);
177                 return (null != tmp) ? tmp : resourceUrlSelector = new Selector<string>();
178             }
179             set => SetValue(ResourceUrlSelectorProperty, value);
180         }
181
182         /// <summary>
183         /// Image border.
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<Rectangle> Border
188         {
189             get
190             {
191                 Selector<Rectangle> tmp = (Selector<Rectangle>)GetValue(BorderSelectorProperty);
192                 return (null != tmp) ? tmp : borderSelector = new Selector<Rectangle>();
193             }
194             set => SetValue(BorderSelectorProperty, value);
195         }
196     }
197 }