public ImageView(string url) : this(Interop.ImageView.New(ConvertResourceUrl(ref url)), true)
{
_resourceUrl = url;
+
+ // Update cached property. Note that we should not re-create new visual.
+ using (PropertyValue urlValue = new PropertyValue(_resourceUrl))
+ {
+ UpdateImage(ImageVisualProperty.URL, urlValue, false);
+ }
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
public ImageView(string url, bool shown) : this(Interop.ImageView.New(ConvertResourceUrl(ref url)), true)
{
_resourceUrl = url;
+
+ // Update cached property. Note that we should not re-create new visual.
+ using (PropertyValue urlValue = new PropertyValue(_resourceUrl))
+ {
+ UpdateImage(ImageVisualProperty.URL, urlValue, false);
+ }
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
SetVisible(shown);
}
_resourceUrl = url;
_desired_width = size?.GetWidth() ?? -1;
_desired_height = size?.GetHeight() ?? -1;
+
+ // Update cached property. Note that we should not re-create new visual.
+ using (PropertyValue urlValue = new PropertyValue(_resourceUrl))
+ {
+ UpdateImage(ImageVisualProperty.URL, urlValue, false);
+ }
+ using (PropertyValue desiredWidthValue = new PropertyValue(_desired_width))
+ {
+ UpdateImage(ImageVisualProperty.DesiredWidth, desiredWidthValue, false);
+ }
+ using (PropertyValue desiredHeightValue = new PropertyValue(_desired_height))
+ {
+ UpdateImage(ImageVisualProperty.DesiredWidth, desiredHeightValue, false);
+ }
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
if (!shown)
image?.Dispose();
// Update cached property map
- if(returnValue != null)
+ if (returnValue != null)
{
MergeCachedImageVisualProperty(returnValue);
}
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
_resourceUrl = url;
+ // Update cached property. Note that we should not re-create new visual.
+ using (PropertyValue urlValue = new PropertyValue(_resourceUrl))
+ {
+ UpdateImage(ImageVisualProperty.URL, urlValue, false);
+ }
+ imagePropertyUpdatedFlag = false;
}
/// <summary>
PropertyValue setValue = new PropertyValue(value ?? "");
UpdateImage(ImageVisualProperty.AlphaMaskURL, setValue);
// When we never set CropToMask property before, we should set default value as true.
- using(PropertyValue cropToMask = GetCachedImageVisualProperty(ImageVisualProperty.CropToMask))
+ using (PropertyValue cropToMask = GetCachedImageVisualProperty(ImageVisualProperty.CropToMask))
{
- if(cropToMask == null)
+ if (cropToMask == null)
{
using PropertyValue setCropValue = new PropertyValue(true);
UpdateImage(ImageVisualProperty.CropToMask, setCropValue);
get
{
// Sync as current properties only if both _desired_width and _desired_height are setuped.
- if(_desired_width != -1 && _desired_height != -1)
+ if (_desired_width != -1 && _desired_height != -1)
{
UpdateImage();
}
{
_desired_width = value;
PropertyValue setValue = new PropertyValue(value);
- UpdateImage(ImageVisualProperty.DesiredWidth, setValue);
+ UpdateImage(ImageVisualProperty.DesiredWidth, setValue, false);
setValue?.Dispose();
}
}
get
{
// Sync as current properties only if both _desired_width and _desired_height are setuped.
- if(_desired_width != -1 && _desired_height != -1)
+ if (_desired_width != -1 && _desired_height != -1)
{
UpdateImage();
}
{
_desired_height = value;
PropertyValue setValue = new PropertyValue(value);
- UpdateImage(ImageVisualProperty.DesiredHeight, setValue);
+ UpdateImage(ImageVisualProperty.DesiredHeight, setValue, false);
setValue?.Dispose();
}
}
NotifyPropertyChanged();
}
}
-
+
private ReleasePolicyType InternalReleasePolicy
{
get
_resourceUrl = url;
_desired_width = size?.GetWidth() ?? -1;
_desired_height = size?.GetHeight() ?? -1;
+
+ // Update cached property. Note that we should not re-create new visual.
+ using (PropertyValue urlValue = new PropertyValue(_resourceUrl))
+ {
+ UpdateImage(ImageVisualProperty.URL, urlValue, false);
+ }
+ using (PropertyValue desiredWidthValue = new PropertyValue(_desired_width))
+ {
+ UpdateImage(ImageVisualProperty.DesiredWidth, desiredWidthValue, false);
+ }
+ using (PropertyValue desiredHeightValue = new PropertyValue(_desired_height))
+ {
+ UpdateImage(ImageVisualProperty.DesiredWidth, desiredHeightValue, false);
+ }
+ imagePropertyUpdatedFlag = false;
}
internal ViewResourceReadySignal ResourceReadySignal(View view)
// Callback for View ResourceReady signal
private void OnResourceReady(IntPtr data)
{
- if(!CheckResourceReady())
+ if (!CheckResourceReady())
{
return;
}
private void SetResourceUrl(string value)
{
- if(_resourceUrl != ConvertResourceUrl(ref value))
+ if (_resourceUrl != ConvertResourceUrl(ref value))
{
_resourceUrl = value;
- if(string.IsNullOrEmpty(_resourceUrl))
+ if (string.IsNullOrEmpty(_resourceUrl))
{
// Special case. If we set ResourceUrl as empty, Unregist visual.
RemoveImage();
}
else
{
- using(PropertyValue setValue = new PropertyValue(value))
+ using (PropertyValue setValue = new PropertyValue(value))
{
UpdateImage(ImageVisualProperty.URL, setValue);
}
// Special case. If we set GeneratedUrl, Create ImageVisual synchronously.
- if(value.StartsWith("dali://") || value.StartsWith("enbuf://"))
+ if (value.StartsWith("dali://") || value.StartsWith("enbuf://"))
{
UpdateImage();
}
{
return;
}
- if(_border != value)
+ if (_border != value)
{
_border = new Rectangle(value);
UpdateImage(NpatchImageVisualProperty.Border, new PropertyValue(_border));
// Unregist and detach process only if previous resourceUrl was not empty
string currentResourceUrl = "";
PropertyValue currentResourceUrlValue = GetCachedImageVisualProperty(ImageVisualProperty.URL);
- if((currentResourceUrlValue?.Get(out currentResourceUrl) ?? false) && !string.IsNullOrEmpty(currentResourceUrl))
+ if ((currentResourceUrlValue?.Get(out currentResourceUrl) ?? false) && !string.IsNullOrEmpty(currentResourceUrl))
{
PropertyValue emptyValue = new PropertyValue();
// Image visual is not exist anymore. We should ignore lazy UpdateImage
imagePropertyUpdatedFlag = false;
- if(imagePropertyUpdateProcessAttachedFlag)
+ if (imagePropertyUpdateProcessAttachedFlag)
{
ProcessorController.Instance.ProcessorOnceEvent -= UpdateImage;
imagePropertyUpdateProcessAttachedFlag = false;
/// <summary>
/// Lazy call to UpdateImage.
/// Collect Properties need to be update, and set properties that starts the Processing.
+ ///
+ /// If you want to update cachedImagePropertyMap, but don't want to request new visual creation, make requiredVisualCreation value as false.
+ /// (Example : if we change SynchronousLoading property from 'true' to 'false', or if we call this function during UpdateImage)
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- protected virtual void UpdateImage(int key, PropertyValue value)
+ protected virtual void UpdateImage(int key, PropertyValue value, bool requiredVisualCreation = true)
{
// Update image property map value as inputed value.
if (key != 0)
imagePropertyUpdatedFlag = true;
cachedImagePropertyMap[key] = value;
- // Lazy update only if _resourceUrl is not empty and ProcessAttachedFlag is false.
- if (!string.IsNullOrEmpty(_resourceUrl) && !imagePropertyUpdateProcessAttachedFlag)
+ // Lazy update only if visual creation required, and _resourceUrl is not empty, and ProcessAttachedFlag is false.
+ if (requiredVisualCreation && !string.IsNullOrEmpty(_resourceUrl) && !imagePropertyUpdateProcessAttachedFlag)
{
imagePropertyUpdateProcessAttachedFlag = true;
ProcessorController.Instance.ProcessorOnceEvent += UpdateImage;
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void UpdateImage()
{
- if(!imagePropertyUpdatedFlag) return;
+ if (!imagePropertyUpdatedFlag) return;
imagePropertyUpdatedFlag = false;
- if(cachedImagePropertyMap == null)
+ if (cachedImagePropertyMap == null)
{
cachedImagePropertyMap = new PropertyMap();
}
// Checkup the cached visual type is AnimatedImage.
// It is trick to know that this code is running on AnimatedImageView.UpdateImage() / LottieAnimationView.UpdateImage() or not.
int visualType = (int)Visual.Type.Invalid;
- if(!((GetCachedImageVisualProperty(Visual.Property.Type)?.Get(out visualType) ?? false) && (visualType == (int)Visual.Type.AnimatedImage || visualType == (int)Visual.Type.AnimatedVectorImage)))
+ if (!((GetCachedImageVisualProperty(Visual.Property.Type)?.Get(out visualType) ?? false) && (visualType == (int)Visual.Type.AnimatedImage || visualType == (int)Visual.Type.AnimatedVectorImage)))
{
// If ResourceUrl is not setuped, don't set property. fast return.
- if(string.IsNullOrEmpty(_resourceUrl))
+ if (string.IsNullOrEmpty(_resourceUrl))
{
return;
}
if (_resourceUrl != null)
{
Size2D imageSize = ImageLoader.GetOriginalImageSize(_resourceUrl, true);
- if( imageSize.Height > 0 && imageSize.Width > 0 && _desired_width > 0 && _desired_height > 0 )
+ if (imageSize.Height > 0 && imageSize.Width > 0 && _desired_width > 0 && _desired_height > 0)
{
int adjustedDesiredWidth, adjustedDesiredHeight;
float aspectOfDesiredSize = (float)_desired_height / (float)_desired_width;
private void UpdateImageMap()
{
// Note : We can't use ImageView.Image property here. Because That property call UpdateImage internally.
- using(PropertyMap imageMap = new PropertyMap())
+ using (PropertyMap imageMap = new PropertyMap())
{
- using(PropertyValue returnValue = Tizen.NUI.Object.GetProperty(SwigCPtr, ImageView.Property.IMAGE))
+ using (PropertyValue returnValue = Tizen.NUI.Object.GetProperty(SwigCPtr, ImageView.Property.IMAGE))
{
returnValue?.Get(imageMap);
}
- if(cachedImagePropertyMap != null)
+ if (cachedImagePropertyMap != null)
{
imageMap?.Merge(cachedImagePropertyMap);
}
- using(PropertyValue setValue = new PropertyValue(imageMap))
+ using (PropertyValue setValue = new PropertyValue(imageMap))
{
SetProperty(ImageView.Property.IMAGE, setValue);
}
protected virtual PropertyValue GetImageVisualProperty(int key)
{
PropertyValue ret = GetCachedImageVisualProperty(key);
- if(ret == null)
+ if (ret == null)
{
// If we cannot find result form cached map, Get value from native engine.
ret = Image?.Find(key);
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void MergeCachedImageVisualProperty(PropertyMap map)
{
- if(map == null) return;
- if(cachedImagePropertyMap == null)
+ if (map == null) return;
+ if (cachedImagePropertyMap == null)
{
cachedImagePropertyMap = new PropertyMap();
}
- foreach(var key in cachedImagePropertyKeyList)
+ foreach (var key in cachedImagePropertyKeyList)
{
PropertyValue value = map.Find(key);
- if(value != null)
+ if (value != null)
{
// Update-or-Insert new value
cachedImagePropertyMap[key] = value;
private void OnResourceLoaded(IntPtr view)
{
- if(!CheckResourceReady())
+ if (!CheckResourceReady())
{
return;
}