2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Runtime.InteropServices;
19 using System.ComponentModel;
20 using Tizen.NUI.Binding;
22 namespace Tizen.NUI.BaseComponents
26 /// ImageView is a class for displaying an image resource.<br />
27 /// An instance of ImageView can be created using a URL or an image instance.<br />
29 /// <since_tizen> 3 </since_tizen>
30 public class ImageView : View
32 static ImageView() { }
34 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
35 [EditorBrowsable(EditorBrowsableState.Never)]
36 public static readonly BindableProperty ResourceUrlProperty = BindableProperty.Create(nameof(ImageView.ResourceUrl), typeof(string), typeof(ImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
38 var imageView = (ImageView)bindable;
39 string url = (string)newValue;
40 url = (url == null ? "" : url);
41 if (imageView.IsCreateByXaml && url.Contains("*Resource*"))
43 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
44 url = url.Replace("*Resource*", resource);
46 imageView._resourceUrl = url;
47 imageView.UpdateImage(ImageVisualProperty.URL, new PropertyValue(url));
49 defaultValueCreator: (bindable) =>
51 var imageView = (ImageView)bindable;
54 PropertyMap imageMap = new PropertyMap();
55 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
56 imageMap.Find(ImageVisualProperty.URL)?.Get(out ret);
60 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
61 [EditorBrowsable(EditorBrowsableState.Never)]
62 public static readonly BindableProperty ImageProperty = BindableProperty.Create(nameof(ImageView.Image), typeof(PropertyMap), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
64 var imageView = (ImageView)bindable;
67 PropertyMap map = (PropertyMap)newValue;
68 if (imageView.IsCreateByXaml)
70 string url = "", alphaMaskURL = "", auxiliaryImageURL = "";
71 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
72 PropertyValue urlValue = map.Find(NDalic.IMAGE_VISUAL_URL);
74 if (urlValue != null) ret = urlValue.Get(out url);
75 PropertyMap mmap = new PropertyMap();
76 if (ret && url.Contains("*Resource*"))
78 url = url.Replace("*Resource*", resource);
79 mmap.Insert(NDalic.IMAGE_VISUAL_URL, new PropertyValue(url));
83 PropertyValue alphaMaskUrlValue = map.Find(NDalic.IMAGE_VISUAL_ALPHA_MASK_URL);
84 if (alphaMaskUrlValue != null) ret = alphaMaskUrlValue.Get(out alphaMaskURL);
85 if (ret && alphaMaskURL.Contains("*Resource*"))
87 alphaMaskURL = alphaMaskURL.Replace("*Resource*", resource);
88 mmap.Insert(NDalic.IMAGE_VISUAL_URL, new PropertyValue(alphaMaskURL));
92 PropertyValue auxiliaryImageURLValue = map.Find(NDalic.IMAGE_VISUAL_AUXILIARY_IMAGE_URL);
93 if (auxiliaryImageURLValue != null) ret = auxiliaryImageURLValue.Get(out auxiliaryImageURL);
94 if (ret && auxiliaryImageURL.Contains("*Resource*"))
96 auxiliaryImageURL = auxiliaryImageURL.Replace("*Resource*", resource);
97 mmap.Insert(NDalic.IMAGE_VISUAL_AUXILIARY_IMAGE_URL, new PropertyValue(auxiliaryImageURL));
102 if (imageView._border == null)
104 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(map));
108 defaultValueCreator: (bindable) =>
110 var imageView = (ImageView)bindable;
111 if (imageView._border == null)
113 PropertyMap temp = new PropertyMap();
114 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(temp);
123 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
124 [EditorBrowsable(EditorBrowsableState.Never)]
125 public static readonly BindableProperty PreMultipliedAlphaProperty = BindableProperty.Create("PreMultipliedAlpha", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
127 var imageView = (ImageView)bindable;
128 if (newValue != null)
130 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA, new Tizen.NUI.PropertyValue((bool)newValue));
133 defaultValueCreator: (bindable) =>
135 var imageView = (ImageView)bindable;
137 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA).Get(out temp);
141 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
142 [EditorBrowsable(EditorBrowsableState.Never)]
143 public static readonly BindableProperty PixelAreaProperty = BindableProperty.Create("PixelArea", typeof(RelativeVector4), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
145 var imageView = (ImageView)bindable;
146 if (newValue != null)
148 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA, new Tizen.NUI.PropertyValue((RelativeVector4)newValue));
151 defaultValueCreator: (bindable) =>
153 var imageView = (ImageView)bindable;
154 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
155 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA).Get(temp);
156 RelativeVector4 relativeTemp = new RelativeVector4(temp.X, temp.Y, temp.Z, temp.W);
160 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
161 [EditorBrowsable(EditorBrowsableState.Never)]
162 public static readonly BindableProperty BorderProperty = BindableProperty.Create("Border", typeof(Rectangle), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
164 var imageView = (ImageView)bindable;
167 imageView._border = (Rectangle)newValue;
168 imageView.UpdateImage(NpatchImageVisualProperty.Border, new PropertyValue(imageView._border));
171 defaultValueCreator: (bindable) =>
173 var imageView = (ImageView)bindable;
174 return imageView._border;
177 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
178 [EditorBrowsable(EditorBrowsableState.Never)]
179 public static readonly BindableProperty BorderOnlyProperty = BindableProperty.Create("BorderOnly", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
181 var imageView = (ImageView)bindable;
182 if (newValue != null)
184 imageView.UpdateImage(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)newValue));
187 defaultValueCreator: (bindable) =>
189 var imageView = (ImageView)bindable;
191 PropertyMap imageMap = new PropertyMap();
192 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
193 imageMap.Find(ImageVisualProperty.BorderOnly)?.Get(out ret);
197 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
198 [EditorBrowsable(EditorBrowsableState.Never)]
199 public static readonly BindableProperty SynchronosLoadingProperty = BindableProperty.Create("SynchronosLoading", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
201 var imageView = (ImageView)bindable;
202 if (newValue != null)
204 imageView._synchronosLoading = (bool) newValue;
205 imageView.UpdateImage(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)newValue));
208 defaultValueCreator: (bindable) =>
210 var imageView = (ImageView)bindable;
211 return imageView._synchronosLoading;
214 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
215 [EditorBrowsable(EditorBrowsableState.Never)]
216 public static readonly BindableProperty OrientationCorrectionProperty = BindableProperty.Create("OrientationCorrection", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
218 var imageView = (ImageView)bindable;
219 if (newValue != null)
221 imageView.UpdateImage(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)newValue));
224 defaultValueCreator: (bindable) =>
226 var imageView = (ImageView)bindable;
229 PropertyMap imageMap = new PropertyMap();
230 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
231 imageMap?.Find(ImageVisualProperty.OrientationCorrection)?.Get(out ret);
236 internal static readonly BindableProperty ResourceUrlSelectorProperty = BindableProperty.Create("ResourceUrlSelector", typeof(Selector<string>), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
238 var imageView = (ImageView)bindable;
239 imageView.resourceUrlSelector.Update(imageView, (Selector<string>)newValue, true);
241 defaultValueCreator: (bindable) =>
243 var imageView = (ImageView)bindable;
244 return imageView.resourceUrlSelector.Get(imageView);
247 internal static readonly BindableProperty BorderSelectorProperty = BindableProperty.Create("BorderSelector", typeof(Selector<Rectangle>), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
249 var imageView = (ImageView)bindable;
250 imageView.borderSelector.Update(imageView, (Selector<Rectangle>)newValue, true);
252 defaultValueCreator: (bindable) =>
254 var imageView = (ImageView)bindable;
255 return imageView.borderSelector.Get(imageView);
258 private EventHandler<ResourceReadyEventArgs> _resourceReadyEventHandler;
259 private ResourceReadyEventCallbackType _resourceReadyEventCallback;
260 private EventHandler<ResourceLoadedEventArgs> _resourceLoadedEventHandler;
261 private _resourceLoadedCallbackType _resourceLoadedCallback;
263 private Rectangle _border;
264 private string _resourceUrl = "";
265 private bool _synchronosLoading = false;
266 private string _alphaMaskUrl = null;
267 private int _desired_width = -1;
268 private int _desired_height = -1;
269 private readonly TriggerableSelector<string> resourceUrlSelector = new TriggerableSelector<string>(ResourceUrlProperty);
270 private readonly TriggerableSelector<Rectangle> borderSelector = new TriggerableSelector<Rectangle>(BorderProperty);
272 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
273 [EditorBrowsable(EditorBrowsableState.Never)]
274 public ImageViewStyle Style => new ImageViewStyle(this);
277 /// Creates an initialized ImageView.
279 /// <since_tizen> 3 </since_tizen>
280 public ImageView() : this(Interop.ImageView.ImageView_New__SWIG_0(), true)
282 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
285 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
286 [EditorBrowsable(EditorBrowsableState.Never)]
287 public ImageView(ViewStyle viewStyle) : this(Interop.ImageView.ImageView_New__SWIG_0(), true, viewStyle)
292 /// Creates an initialized ImageView with setting the status of shown or hidden.
294 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
295 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
296 [EditorBrowsable(EditorBrowsableState.Never)]
297 public ImageView(bool shown) : this(Interop.ImageView.ImageView_New__SWIG_0(), true)
299 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304 /// Creates an initialized ImageView from a URL to an image resource.<br />
305 /// If the string is empty, ImageView will not display anything.<br />
307 /// <param name="url">The URL of the image resource to display.</param>
308 /// <since_tizen> 3 </since_tizen>
309 public ImageView(string url) : this(Interop.ImageView.ImageView_New__SWIG_2(url), true)
312 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
317 /// Creates an initialized ImageView from a URL to an image resource with setting shown or hidden.
319 /// <param name="url">The URL of the image resource to display.</param>
320 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
321 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
322 [EditorBrowsable(EditorBrowsableState.Never)]
323 public ImageView(string url, bool shown) : this(Interop.ImageView.ImageView_New__SWIG_2(url), true)
326 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
330 internal ImageView(string url, Uint16Pair size, bool shown = true) : this(Interop.ImageView.ImageView_New__SWIG_3(url, Uint16Pair.getCPtr(size)), true)
333 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341 internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : base(Interop.ImageView.ImageView_SWIGUpcast(cPtr), cMemoryOwn, viewStyle)
349 internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(Interop.ImageView.ImageView_SWIGUpcast(cPtr), cMemoryOwn)
357 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
358 private delegate void ResourceReadyEventCallbackType(IntPtr data);
359 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
360 private delegate void _resourceLoadedCallbackType(IntPtr view);
363 /// An event for ResourceReady signal which can be used to subscribe or unsubscribe the event handler.<br />
364 /// This signal is emitted after all resources required by a control are loaded and ready.<br />
365 /// Most resources are only loaded when the control is placed on the stage.<br />
367 /// <since_tizen> 3 </since_tizen>
368 public event EventHandler<ResourceReadyEventArgs> ResourceReady
372 if (_resourceReadyEventHandler == null)
374 _resourceReadyEventCallback = OnResourceReady;
375 ResourceReadySignal(this).Connect(_resourceReadyEventCallback);
378 _resourceReadyEventHandler += value;
383 _resourceReadyEventHandler -= value;
385 if (_resourceReadyEventHandler == null && ResourceReadySignal(this).Empty() == false)
387 ResourceReadySignal(this).Disconnect(_resourceReadyEventCallback);
392 internal event EventHandler<ResourceLoadedEventArgs> ResourceLoaded
396 if (_resourceLoadedEventHandler == null)
398 _resourceLoadedCallback = OnResourceLoaded;
399 this.ResourceReadySignal(this).Connect(_resourceLoadedCallback);
402 _resourceLoadedEventHandler += value;
406 _resourceLoadedEventHandler -= value;
408 if (_resourceLoadedEventHandler == null && this.ResourceReadySignal(this).Empty() == false)
410 this.ResourceReadySignal(this).Disconnect(_resourceLoadedCallback);
416 /// Enumeration for LoadingStatus of image.
418 /// <since_tizen> 5 </since_tizen>
419 public enum LoadingStatusType
422 /// Loading preparing status.
424 /// <since_tizen> 5 </since_tizen>
427 /// Loading ready status.
429 /// <since_tizen> 5 </since_tizen>
432 /// Loading failed status.
434 /// <since_tizen> 5 </since_tizen>
439 /// ImageView ResourceUrl, type string.
440 /// This is one of mandatory property. Even if not set or null set, it sets empty string ("") internally.
441 /// When it is set as null, it gives empty string ("") to be read.
443 /// <since_tizen> 3 </since_tizen>
444 public string ResourceUrl
448 return (string)GetValue(ResourceUrlProperty);
452 SetValue(ResourceUrlProperty, value);
453 resourceUrlSelector.UpdateIfNeeds(this, value);
454 NotifyPropertyChanged();
459 /// This will be deprecated, please use Image instead. <br />
460 /// ImageView ImageMap, type PropertyMap: string if it is a URL, map otherwise.
462 /// <since_tizen> 3 </since_tizen>
463 [Obsolete("Please do not use! This will be deprecated! Please use Image property instead!")]
464 [EditorBrowsable(EditorBrowsableState.Never)]
465 public PropertyMap ImageMap
471 PropertyMap temp = new PropertyMap();
472 GetProperty(ImageView.Property.IMAGE).Get(temp);
484 SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
485 NotifyPropertyChanged();
491 /// ImageView Image, type PropertyMap
493 /// <since_tizen> 4 </since_tizen>
494 public PropertyMap Image
500 return (PropertyMap)GetValue(ImageProperty);
511 SetValue(ImageProperty, value);
512 NotifyPropertyChanged();
518 /// ImageView PreMultipliedAlpha, type Boolean.<br />
519 /// Image must be initialized.<br />
521 /// <since_tizen> 3 </since_tizen>
522 public bool PreMultipliedAlpha
526 return (bool)GetValue(PreMultipliedAlphaProperty);
530 SetValue(PreMultipliedAlphaProperty, value);
531 NotifyPropertyChanged();
536 /// ImageView PixelArea, type Vector4 (Animatable property).<br />
537 /// Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].<br />
540 /// The property cascade chaining set is possible. For example, this (imageView.PixelArea.X = 0.1f;) is possible.
542 /// <since_tizen> 3 </since_tizen>
543 public RelativeVector4 PixelArea
547 RelativeVector4 temp = (RelativeVector4)GetValue(PixelAreaProperty);
548 return new RelativeVector4(OnPixelAreaChanged, temp.X, temp.Y, temp.Z, temp.W);
552 SetValue(PixelAreaProperty, value);
553 NotifyPropertyChanged();
558 /// The border of the image in the order: left, right, bottom, top.<br />
559 /// If set, ImageMap will be ignored.<br />
560 /// For N-Patch images only.<br />
564 /// The property cascade chaining set is possible. For example, this (imageView.Border.X = 1;) is possible.
566 /// <since_tizen> 3 </since_tizen>
567 public Rectangle Border
571 Rectangle temp = (Rectangle)GetValue(BorderProperty);
578 return new Rectangle(OnBorderChanged, temp.X, temp.Y, temp.Width, temp.Height);
583 SetValue(BorderProperty, value);
584 borderSelector.UpdateIfNeeds(this, value);
585 NotifyPropertyChanged();
590 /// Gets or sets whether to draw the borders only (if true).<br />
591 /// If not specified, the default is false.<br />
592 /// For N-Patch images only.<br />
595 /// <since_tizen> 3 </since_tizen>
596 public bool BorderOnly
600 return (bool)GetValue(BorderOnlyProperty);
604 SetValue(BorderOnlyProperty, value);
605 NotifyPropertyChanged();
610 /// Gets or sets whether to synchronos loading the resourceurl of image.<br />
612 /// <since_tizen> 3 </since_tizen>
613 public bool SynchronosLoading
617 return (bool)GetValue(SynchronosLoadingProperty);
621 SetValue(SynchronosLoadingProperty, value);
622 NotifyPropertyChanged();
627 /// Gets or sets whether to automatically correct the orientation of an image.<br />
629 /// <since_tizen> 5 </since_tizen>
630 public bool OrientationCorrection
634 return (bool)GetValue(OrientationCorrectionProperty);
638 SetValue(OrientationCorrectionProperty, value);
639 NotifyPropertyChanged();
644 /// Gets the loading state of the visual resource.
646 /// <since_tizen> 5 </since_tizen>
647 public ImageView.LoadingStatusType LoadingStatus
651 return (ImageView.LoadingStatusType)Interop.View.View_GetVisualResourceStatus(swigCPtr, (int)Property.IMAGE);
656 /// Downcasts a handle to imageView handle.
658 /// Please do not use! this will be deprecated!
659 /// Instead please use as keyword.
660 /// <since_tizen> 3 </since_tizen>
661 [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
663 "BaseHandle handle = new ImageView(imagePath); " +
664 "ImageView image = handle as ImageView")]
665 [EditorBrowsable(EditorBrowsableState.Never)]
666 public static ImageView DownCast(BaseHandle handle)
668 ImageView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as ImageView;
669 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
674 /// Sets this ImageView from the given URL.<br />
675 /// If the URL is empty, ImageView will not display anything.<br />
677 /// <param name="url">The URL to the image resource to display.</param>
678 /// <since_tizen> 3 </since_tizen>
679 public void SetImage(string url)
681 if(url.Contains(".json"))
683 Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
687 Interop.ImageView.ImageView_SetImage__SWIG_1(swigCPtr, url);
688 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
694 /// Queries if all resources required by a control are loaded and ready.<br />
695 /// Most resources are only loaded when the control is placed on the stage.<br />
696 /// True if the resources are loaded and ready, false otherwise.<br />
698 /// <since_tizen> 3 </since_tizen>
699 public new bool IsResourceReady()
701 bool ret = Interop.View.IsResourceReady(swigCPtr);
702 if (NDalicPINVOKE.SWIGPendingException.Pending)
703 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
708 /// Forcefully reloads the image. All the visuals using this image will reload to the latest image.
710 /// <since_tizen> 5 </since_tizen>
713 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_RELOAD, new PropertyValue(0));
717 /// Plays the animated GIF. This is also the default playback mode.
719 /// <since_tizen> 5 </since_tizen>
722 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PLAY, new PropertyValue(0));
726 /// Pauses the animated GIF.
728 /// <since_tizen> 5 </since_tizen>
731 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PAUSE, new PropertyValue(0));
735 /// Stops the animated GIF.
737 /// <since_tizen> 5 </since_tizen>
740 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_STOP, new PropertyValue(0));
744 /// Gets or sets the URL of the alpha mask.<br />
747 /// <since_tizen> 6</since_tizen>
748 [EditorBrowsable(EditorBrowsableState.Never)]
749 public string AlphaMaskURL
754 PropertyMap imageMap = new PropertyMap();
755 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
756 imageMap?.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out ret);
768 _alphaMaskUrl = value;
769 UpdateImage(ImageVisualProperty.AlphaMaskURL, new PropertyValue(value));
775 /// Whether to crop image to mask or scale mask to fit image.
777 /// <since_tizen> 6 </since_tizen>
778 public bool CropToMask
783 PropertyMap imageMap = new PropertyMap();
784 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
785 imageMap?.Find(ImageVisualProperty.CropToMask)?.Get(out ret);
791 UpdateImage(ImageVisualProperty.CropToMask, new PropertyValue(value));
795 internal VisualFittingModeType CovertFittingModetoVisualFittingMode(FittingModeType value)
799 case FittingModeType.ShrinkToFit:
800 return VisualFittingModeType.FitKeepAspectRatio;
801 case FittingModeType.ScaleToFill:
802 return VisualFittingModeType.OverFitKeepAspectRatio;
803 case FittingModeType.Center:
804 return VisualFittingModeType.Center;
805 case FittingModeType.Fill:
806 return VisualFittingModeType.Fill;
807 case FittingModeType.FitHeight:
808 return VisualFittingModeType.FitHeight;
809 case FittingModeType.FitWidth:
810 return VisualFittingModeType.FitHeight;
812 return VisualFittingModeType.Fill;
816 internal FittingModeType ConvertVisualFittingModetoFittingMode(VisualFittingModeType value)
820 case VisualFittingModeType.FitKeepAspectRatio:
821 return FittingModeType.ShrinkToFit;
822 case VisualFittingModeType.OverFitKeepAspectRatio:
823 return FittingModeType.ScaleToFill;
824 case VisualFittingModeType.Center:
825 return FittingModeType.Center;
826 case VisualFittingModeType.Fill:
827 return FittingModeType.Fill;
828 case VisualFittingModeType.FitHeight:
829 return FittingModeType.FitHeight;
830 case VisualFittingModeType.FitWidth:
831 return FittingModeType.FitHeight;
833 return FittingModeType.ShrinkToFit;
838 /// Gets or sets fitting options used when resizing images to fit.<br />
839 /// If not supplied, the default is FittingModeType.Fill.<br />
840 /// For normal quad images only.<br />
843 /// <since_tizen> 6 </since_tizen>
844 [EditorBrowsable(EditorBrowsableState.Never)]
845 public FittingModeType FittingMode
849 int ret = (int)VisualFittingModeType.Fill;
850 PropertyMap imageMap = new PropertyMap();
851 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
852 imageMap?.Find(Visual.Property.VisualFittingMode)?.Get(out ret);
853 return ConvertVisualFittingModetoFittingMode((VisualFittingModeType)ret);
857 VisualFittingModeType ret = CovertFittingModetoVisualFittingMode(value);
858 UpdateImage(Visual.Property.VisualFittingMode, new PropertyValue((int) ret));
865 /// Gets or sets the desired image width.<br />
866 /// If not specified, the actual image width is used.<br />
867 /// For normal quad images only.<br />
870 /// <since_tizen> 6 </since_tizen>
871 [EditorBrowsable(EditorBrowsableState.Never)]
872 public int DesiredWidth
876 PropertyMap imageMap = new PropertyMap();
877 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
878 imageMap?.Find(ImageVisualProperty.DesiredWidth)?.Get(out _desired_width);
880 return _desired_width;
884 UpdateImage(ImageVisualProperty.DesiredWidth, new PropertyValue(value));
885 _desired_width = value;
890 /// Gets or sets the desired image height.<br />
891 /// If not specified, the actual image height is used.<br />
892 /// For normal quad images only.<br />
895 /// <since_tizen> 6 </since_tizen>
896 [EditorBrowsable(EditorBrowsableState.Never)]
897 public int DesiredHeight
901 PropertyMap imageMap = new PropertyMap();
902 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
903 imageMap?.Find(ImageVisualProperty.DesiredHeight)?.Get(out _desired_height);
905 return _desired_height;
909 UpdateImage(ImageVisualProperty.DesiredHeight, new PropertyValue(value));
910 _desired_height = value;
915 /// Gets or sets ReleasePolicy for image.<br />
916 /// If not supplied, the default is ReleasePolicyType.Detached.<br />
918 [EditorBrowsable(EditorBrowsableState.Never)]
919 public ReleasePolicyType ReleasePolicy
923 int ret = (int)ReleasePolicyType.Detached;
924 PropertyMap imageMap = new PropertyMap();
925 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
926 imageMap?.Find(ImageVisualProperty.ReleasePolicy)?.Get(out ret);
927 return (ReleasePolicyType)ret;
931 UpdateImage(ImageVisualProperty.ReleasePolicy, new PropertyValue((int)value));
936 /// Gets or sets the wrap mode for the u coordinate.<br />
937 /// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.<br />
938 /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
939 /// For normal quad images only.<br />
942 /// <since_tizen> 6 </since_tizen>
943 [EditorBrowsable(EditorBrowsableState.Never)]
944 public WrapModeType WrapModeU
948 int ret = (int)WrapModeType.Default;
949 PropertyMap imageMap = new PropertyMap();
950 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
951 imageMap?.Find(ImageVisualProperty.WrapModeU)?.Get(out ret);
953 return (WrapModeType)ret;
957 UpdateImage(ImageVisualProperty.WrapModeU, new PropertyValue((int)value));
962 /// Gets or sets the wrap mode for the v coordinate.<br />
963 /// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.<br />
964 /// The first two elements indicate the top-left position of the area, and the last two elements are the areas of the width and the height respectively.<br />
965 /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
966 /// For normal quad images only.
969 /// <since_tizen> 6 </since_tizen>
970 [EditorBrowsable(EditorBrowsableState.Never)]
971 public WrapModeType WrapModeV
975 int ret = (int)WrapModeType.Default;
976 PropertyMap imageMap = new PropertyMap();
977 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
978 imageMap?.Find(ImageVisualProperty.WrapModeV)?.Get(out ret);
980 return (WrapModeType)ret;
984 UpdateImage(ImageVisualProperty.WrapModeV, new PropertyValue((int)value));
989 /// Get attribues, it is abstract function and must be override.
991 /// <since_tizen> 6 </since_tizen>
992 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
993 [EditorBrowsable(EditorBrowsableState.Never)]
994 protected override ViewStyle GetViewStyle()
996 return new ImageViewStyle();
999 internal void SetImage(string url, Uint16Pair size)
1001 if(url.Contains(".json"))
1003 Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
1007 Interop.ImageView.ImageView_SetImage__SWIG_2(swigCPtr, url, Uint16Pair.getCPtr(size));
1008 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1013 internal ViewResourceReadySignal ResourceReadySignal(View view)
1015 ViewResourceReadySignal ret = new ViewResourceReadySignal(Interop.View.ResourceReadySignal(View.getCPtr(view)), false);
1016 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1020 internal override void UpdateCornerRadius(float value)
1022 base.UpdateCornerRadius(value);
1024 UpdateImage(0, null);
1027 internal ResourceLoadingStatusType GetResourceStatus()
1029 return (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
1033 /// you can override it to clean-up your own resources.
1035 /// <param name="type">DisposeTypes</param>
1036 /// <since_tizen> 3 </since_tizen>
1037 protected override void Dispose(DisposeTypes type)
1044 if (type == DisposeTypes.Explicit)
1047 //Release your own managed resources here.
1048 //You should release all of your own disposable objects here.
1051 borderSelector.Reset(this);
1052 resourceUrlSelector.Reset(this);
1058 /// This will not be public opened.
1059 [EditorBrowsable(EditorBrowsableState.Never)]
1060 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1062 Interop.ImageView.delete_ImageView(swigCPtr);
1065 // Callback for View ResourceReady signal
1066 private void OnResourceReady(IntPtr data)
1068 ResourceReadyEventArgs e = new ResourceReadyEventArgs();
1071 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1074 if (_resourceReadyEventHandler != null)
1076 _resourceReadyEventHandler(this, e);
1080 private void UpdateImageMap(PropertyMap fromMap)
1082 PropertyMap imageMap = new PropertyMap();
1083 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
1084 imageMap.Merge(fromMap);
1086 SetProperty(ImageView.Property.IMAGE, new PropertyValue(imageMap));
1089 private void UpdateImage(int key, PropertyValue value)
1091 PropertyMap temp = new PropertyMap();
1093 if(_alphaMaskUrl != null)
1095 temp.Insert(ImageVisualProperty.AlphaMaskURL, new PropertyValue(_alphaMaskUrl));
1098 if (_resourceUrl == "")
1100 temp.Insert(ImageVisualProperty.URL, new PropertyValue(_resourceUrl));
1101 SetProperty(ImageView.Property.IMAGE, new PropertyValue(temp));
1105 if (_border == null)
1107 temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
1111 temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
1112 temp.Insert(NpatchImageVisualProperty.Border, new PropertyValue(_border));
1115 temp.Insert(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue(_synchronosLoading));
1117 if (backgroundExtraData != null && backgroundExtraData.CornerRadius > 0)
1119 temp.Insert(Visual.Property.CornerRadius, new PropertyValue(backgroundExtraData.CornerRadius));
1124 temp.Insert(key, value);
1127 // Do Fitting Buffer when desired dimension is set
1128 if( _desired_width != -1 && _desired_height != -1)
1130 if(_resourceUrl != null)
1132 Size2D imageSize = ImageLoading.GetOriginalImageSize(_resourceUrl);
1134 int ret_width,ret_height;
1135 if( imageSize.Width > imageSize.Height)
1137 ret_width = _desired_width;
1138 ret_height = imageSize.Height * _desired_height /(imageSize.Width);
1142 ret_width = imageSize.Width*_desired_width/(imageSize.Height);
1143 ret_height = _desired_height;
1146 temp.Insert(ImageVisualProperty.DesiredWidth, new PropertyValue((int)ret_width));
1147 temp.Insert(ImageVisualProperty.DesiredHeight, new PropertyValue((int)ret_height));
1148 temp.Insert(ImageVisualProperty.FittingMode, new PropertyValue((int) FittingModeType.ShrinkToFit));
1152 UpdateImageMap(temp);
1159 private void OnResourceLoaded(IntPtr view)
1161 ResourceLoadedEventArgs e = new ResourceLoadedEventArgs();
1162 e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
1164 if (_resourceLoadedEventHandler != null)
1166 _resourceLoadedEventHandler(this, e);
1171 /// Event arguments of resource ready.
1173 /// <since_tizen> 3 </since_tizen>
1174 public class ResourceReadyEventArgs : EventArgs
1179 /// The view whose resource is ready.
1181 /// <since_tizen> 3 </since_tizen>
1195 internal class ResourceLoadedEventArgs : EventArgs
1197 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1198 public ResourceLoadingStatusType Status
1211 internal new class Property
1213 internal static readonly int IMAGE = Interop.ImageView.ImageView_Property_IMAGE_get();
1214 internal static readonly int PRE_MULTIPLIED_ALPHA = Interop.ImageView.ImageView_Property_PRE_MULTIPLIED_ALPHA_get();
1215 internal static readonly int PIXEL_AREA = Interop.ImageView.ImageView_Property_PIXEL_AREA_get();
1216 internal static readonly int ACTION_RELOAD = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_RELOAD_get();
1217 internal static readonly int ACTION_PLAY = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PLAY_get();
1218 internal static readonly int ACTION_PAUSE = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PAUSE_get();
1219 internal static readonly int ACTION_STOP = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_STOP_get();
1222 private enum ImageType
1225 /// For Normal Image.
1230 /// For normal image, with synchronous loading and orientation correction property
1235 /// For nine-patch image
1240 private void OnBorderChanged(int x, int y, int width, int height)
1242 Border = new Rectangle(x, y, width, height);
1244 private void OnPixelAreaChanged(float x, float y, float z, float w)
1246 PixelArea = new RelativeVector4(x, y, z, w);