2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
19 using System.Runtime.InteropServices;
\r
20 using System.Collections.Generic;
\r
26 public class ImageVisual : VisualBase
\r
28 private VisualBase _imageVisual;
\r
29 private Property.Map _imageProperty;
\r
30 private string _imageUrl;
\r
31 private string _fittingMode;
\r
32 private string _samplingMode;
\r
33 private int _desiredWidth;
\r
34 private int _desiredHeight;
\r
35 private bool _synchronousLoading;
\r
36 private bool _borderOnly;
\r
37 private Vector4 _pixelArea;
\r
38 private string _wrapModeU;
\r
39 private string _wrapModeV;
\r
41 private Vector2 _imageVisualSize;
\r
42 private Vector2 _imageVisualPosition;
\r
43 private Vector4 _offsetSizeMode;
\r
44 private Vector2 _parentSize;
\r
45 private Tizen.NUI.AlignType _origin;
\r
46 private Tizen.NUI.AlignType _anchorPoint;
\r
48 public ImageVisual() : base()
\r
50 //Initial the default transform map.
\r
51 _offsetSizeMode = new Vector4( 1.0f, 1.0f, 1.0f, 1.0f ); //absolute
\r
52 _origin = AlignType.TOP_BEGIN;
\r
53 _anchorPoint = AlignType.TOP_BEGIN;
\r
55 //Initial the image property map.
\r
56 _imageProperty = new Property.Map();
\r
57 _imageProperty.Insert( NDalic.VISUAL_PROPERTY_TYPE, new Property.Value( (int)VisualType.IMAGE ) );
\r
60 public ImageVisual(string imageUrl)
\r
62 //Initial the default transform map.
\r
63 _offsetSizeMode = new Vector4( 1.0f, 1.0f, 1.0f, 1.0f ); //absolute
\r
64 _origin = AlignType.TOP_BEGIN;
\r
65 _anchorPoint = AlignType.TOP_BEGIN;
\r
67 //Initial the image property map.
\r
68 _imageUrl = imageUrl;
\r
69 _imageProperty = new Property.Map();
\r
70 _imageProperty.Insert( NDalic.VISUAL_PROPERTY_TYPE, new Property.Value( (int)VisualType.IMAGE ) );
\r
71 _imageProperty.Insert( NDalic.IMAGE_VISUAL_URL, new Property.Value( _imageUrl ) );
\r
83 _imageProperty.Insert( NDalic.IMAGE_VISUAL_URL, new Property.Value( _imageUrl ) );
\r
87 public string FittingMode
\r
91 return _fittingMode;
\r
95 _fittingMode = value;
\r
96 _imageProperty.Insert( NDalic.IMAGE_VISUAL_FITTING_MODE, new Property.Value( _fittingMode ) );
\r
100 public string SamplingMode
\r
104 return _samplingMode;
\r
108 _samplingMode = value;
\r
109 _imageProperty.Insert( NDalic.IMAGE_VISUAL_SAMPLING_MODE, new Property.Value( _samplingMode ) );
\r
113 public int DesiredWidth
\r
117 return _desiredWidth;
\r
121 _desiredWidth = value;
\r
122 _imageProperty.Insert( NDalic.IMAGE_VISUAL_DESIRED_WIDTH, new Property.Value( _desiredWidth ) );
\r
126 public int DesiredHeight
\r
130 return _desiredHeight;
\r
134 _desiredHeight = value;
\r
135 _imageProperty.Insert( NDalic.IMAGE_VISUAL_DESIRED_HEIGHT, new Property.Value( _desiredHeight ) );
\r
139 public bool SynchronousLoading
\r
143 return _synchronousLoading;
\r
147 _synchronousLoading = value;
\r
148 _imageProperty.Insert( NDalic.IMAGE_VISUAL_SYNCHRONOUS_LOADING, new Property.Value( _synchronousLoading ) );
\r
152 public bool BorderOnly
\r
156 return _borderOnly;
\r
160 _borderOnly = value;
\r
161 _imageProperty.Insert( NDalic.IMAGE_VISUAL_BORDER_ONLY, new Property.Value( _borderOnly ) );
\r
165 public Vector4 PixelArea
\r
173 _pixelArea = value;
\r
174 _imageProperty.Insert( NDalic.IMAGE_VISUAL_PIXEL_AREA, new Property.Value( _pixelArea ) );
\r
178 public string WrapModeU
\r
186 _wrapModeU = value;
\r
187 _imageProperty.Insert( NDalic.IMAGE_VISUAL_WRAP_MODE_U, new Property.Value( _wrapModeU ) );
\r
191 public string WrapModeV
\r
199 _wrapModeV = value;
\r
200 _imageProperty.Insert( NDalic.IMAGE_VISUAL_WRAP_MODE_V, new Property.Value( _wrapModeV ) );
\r
204 public Vector2 Size
\r
208 return _imageVisualSize;
\r
212 _imageVisualSize = value;
\r
216 public Vector2 Position
\r
220 return _imageVisualPosition;
\r
224 _imageVisualPosition = value;
\r
228 public Vector4 OffsetSizeMode
\r
232 return _offsetSizeMode;
\r
236 _offsetSizeMode = value;
\r
240 public Vector2 ParentSize
\r
244 return _parentSize;
\r
248 _parentSize = value;
\r
252 public AlignType Origin
\r
264 public AlignType AnchorPoint
\r
268 return _anchorPoint;
\r
272 _anchorPoint = value;
\r
276 public void Instantiate()
\r
279 _imageVisual = VisualFactory.Get().CreateVisual( _imageProperty );
\r
281 Property.Map imageVisualTransform = new Property.Map();
\r
282 imageVisualTransform.Add( (int)VisualTransformPropertyType.SIZE, new Property.Value(_imageVisualSize) );
\r
283 imageVisualTransform.Add( (int)VisualTransformPropertyType.OFFSET, new Property.Value(_imageVisualPosition) );
\r
284 imageVisualTransform.Add( (int)VisualTransformPropertyType.OFFSET_SIZE_MODE, new Property.Value(_offsetSizeMode) );
\r
285 imageVisualTransform.Add( (int)VisualTransformPropertyType.ORIGIN, new Property.Value((int)_origin) );
\r
286 imageVisualTransform.Add( (int)VisualTransformPropertyType.ANCHOR_POINT, new Property.Value((int)_anchorPoint) );
\r
287 _imageVisual.SetTransformAndSize( imageVisualTransform, _parentSize );
\r