Merge "[ElmSharp] Remove layout for Button"
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / ImageView.cs
index 2c721a7..025818c 100755 (executable)
 * limitations under the License.
 *
 */
-// This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts
-//------------------------------------------------------------------------------
-// <auto-generated />
-//
-// This file was automatically generated by SWIG (http://www.swig.org).
-// Version 3.0.9
-//
-// Do not make changes to this file unless you know what you are doing--modify
-// the SWIG interface file instead.
-//------------------------------------------------------------------------------
 
 namespace Tizen.NUI.BaseComponents
 {
@@ -40,8 +30,6 @@ namespace Tizen.NUI.BaseComponents
         internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.ImageView_SWIGUpcast(cPtr), cMemoryOwn)
         {
             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
-            // By default, we do not want the position to use the anchor point
-            PositionUsesAnchorPoint = false;
         }
 
         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImageView obj)
@@ -113,7 +101,7 @@ namespace Tizen.NUI.BaseComponents
             ResourceReadyEventArgs e = new ResourceReadyEventArgs();
             if(data != null)
             {
-                e.View = View.GetViewFromPtr(data);
+                e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
             }
 
             if (_resourceReadyEventHandler != null)
@@ -125,7 +113,7 @@ namespace Tizen.NUI.BaseComponents
         //you can override it to clean-up your own resources.
         protected override void Dispose(DisposeTypes type)
         {
-            if (!disposed)
+            if (disposed)
             {
                 return;
             }
@@ -143,7 +131,7 @@ namespace Tizen.NUI.BaseComponents
 
             //Release your own unmanaged resources here.
             //You should not access any managed member here except static instance.
-            //because the execution order of Finalizes is non-deterministic.         
+            //because the execution order of Finalizes is non-deterministic.
 
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
@@ -158,97 +146,12 @@ namespace Tizen.NUI.BaseComponents
             base.Dispose(type);
         }
 
-        internal class Property : global::System.IDisposable
+        internal new class Property
         {
-            private global::System.Runtime.InteropServices.HandleRef swigCPtr;
-            protected bool swigCMemOwn;
-
-            internal Property(global::System.IntPtr cPtr, bool cMemoryOwn)
-            {
-                swigCMemOwn = cMemoryOwn;
-                swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
-            }
-
-            internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Property obj)
-            {
-                return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
-            }
-
-            //NUI Dispose Pattern written by Jinwoo Nam(jjw.nam) 
-
-            //A Flag to check who called Dispose(). (By User or DisposeQueue)
-            private bool isDisposeQueued = false;
-            //A Flat to check if it is already disposed.
-            protected bool disposed = false;
-
-            ~Property()
-            {
-                if(!isDisposeQueued)
-                {
-                    isDisposeQueued = true;
-                    DisposeQueue.Instance.Add(this);
-                }
-            }
-
-            public void Dispose()
-            {
-                //Throw excpetion if Dispose() is called in separate thread.
-                if (!Window.IsInstalled())
-                {
-                    throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
-                }
-
-                if (isDisposeQueued)
-                {
-                    Dispose(DisposeTypes.Implicit);
-                }
-                else
-                {
-                    Dispose(DisposeTypes.Explicit);
-                    System.GC.SuppressFinalize(this);
-                }
-            }
-
-            protected virtual void Dispose(DisposeTypes type)
-            {
-                if (disposed)
-                {
-                    return;
-                }
-
-                if(type == DisposeTypes.Explicit)
-                {
-                    //Called by User
-                    //Release your own managed resources here.
-                    //You should release all of your own disposable objects here.
-                }
-
-                //Release your own unmanaged resources here.
-                //You should not access any managed member here except static instance.
-                //because the execution order of Finalizes is non-deterministic.
-
-                if (swigCPtr.Handle != global::System.IntPtr.Zero)
-                {
-                    if (swigCMemOwn)
-                    {
-                        swigCMemOwn = false;
-                        NDalicPINVOKE.delete_ImageView_Property(swigCPtr);
-                    }
-                    swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
-                }
-                disposed = true;
-            }
-
-            internal Property() : this(NDalicPINVOKE.new_ImageView_Property(), true)
-            {
-                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            }
-
             internal static readonly int RESOURCE_URL = NDalicPINVOKE.ImageView_Property_RESOURCE_URL_get();
             internal static readonly int IMAGE = NDalicPINVOKE.ImageView_Property_IMAGE_get();
             internal static readonly int PRE_MULTIPLIED_ALPHA = NDalicPINVOKE.ImageView_Property_PRE_MULTIPLIED_ALPHA_get();
             internal static readonly int PIXEL_AREA = NDalicPINVOKE.ImageView_Property_PIXEL_AREA_get();
-
         }
 
         /// <summary>
@@ -266,34 +169,21 @@ namespace Tizen.NUI.BaseComponents
         /// <param name="url">The url of the image resource to display</param>
         public ImageView(string url) : this(NDalicPINVOKE.ImageView_New__SWIG_2(url), true)
         {
+            _url = url;
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
         }
         internal ImageView(string url, Uint16Pair size) : this(NDalicPINVOKE.ImageView_New__SWIG_3(url, Uint16Pair.getCPtr(size)), true)
         {
+            _url = url;
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
         }
-        internal ImageView(ImageView imageView) : this(NDalicPINVOKE.new_ImageView__SWIG_1(ImageView.getCPtr(imageView)), true)
-        {
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-        }
-        internal ImageView Assign(ImageView imageView)
-        {
-            ImageView ret = new ImageView(NDalicPINVOKE.ImageView_Assign(swigCPtr, ImageView.getCPtr(imageView)), false);
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
-        }
-        /// <summary>
-        /// Downcasts a handle to ImageView handle.<br>
-        /// If handle points to a ImageView, the downcast produces valid handle.<br>
-        /// If not, the returned handle is left uninitialized.<br>
-        /// </summary>
-        /// <param name="handle">Handle to an object</param>
-        /// <returns>Handle to a ImageView or an uninitialized handle</returns>
+
+        [Obsolete("Please do not use! this will be deprecated")]
         public new static ImageView DownCast(BaseHandle handle)
         {
-            ImageView ret = new ImageView(NDalicPINVOKE.ImageView_DownCast(BaseHandle.getCPtr(handle)), true);
+            ImageView ret =  Registry.GetManagedBaseHandleFromNativePtr(handle) as ImageView;
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
@@ -304,22 +194,16 @@ namespace Tizen.NUI.BaseComponents
         /// <param name="url">The URL to the image resource to display</param>
         public void SetImage(string url)
         {
+            _url = url;
             NDalicPINVOKE.ImageView_SetImage__SWIG_1(swigCPtr, url);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
         internal void SetImage(string url, Uint16Pair size)
         {
+            _url = url;
             NDalicPINVOKE.ImageView_SetImage__SWIG_2(swigCPtr, url, Uint16Pair.getCPtr(size));
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
-        internal enum PropertyRange
-        {
-            PROPERTY_START_INDEX = PropertyRanges.PROPERTY_REGISTRATION_START_INDEX,
-            PROPERTY_END_INDEX = View.PropertyRange.PROPERTY_START_INDEX + 1000,
-            ANIMATABLE_PROPERTY_START_INDEX = PropertyRanges.ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,
-            ANIMATABLE_PROPERTY_END_INDEX = PropertyRanges.ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000
-        }
-
 
         internal ViewResourceReadySignal ResourceReadySignal(View view) {
             ViewResourceReadySignal ret = new ViewResourceReadySignal(NDalicPINVOKE.ResourceReadySignal(View.getCPtr(view)), false);
@@ -332,7 +216,7 @@ namespace Tizen.NUI.BaseComponents
         /// Most resources are only loaded when the control is placed on stage.<br>
         /// true if the resources are loaded and ready, false otherwise.<br>
         /// </summary>
-        public bool IsResourceReady()
+        public new  bool IsResourceReady()
         {
             bool ret = NDalicPINVOKE.IsResourceReady(swigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending)
@@ -347,6 +231,7 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
+                GetProperty(ImageView.Property.RESOURCE_URL).Get(out _url);
                 return _url;
             }
             set
@@ -392,7 +277,7 @@ namespace Tizen.NUI.BaseComponents
             get
             {
                 bool temp = false;
-                GetProperty(ImageView.Property.PRE_MULTIPLIED_ALPHA).Get(ref temp);
+                GetProperty(ImageView.Property.PRE_MULTIPLIED_ALPHA).Get(out temp);
                 return temp;
             }
             set
@@ -448,7 +333,7 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
-                return _borderOnly;
+                return _borderOnly ?? false;
             }
             set
             {
@@ -457,27 +342,53 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
-        private void UpdateImage()
+        public bool SynchronosLoading
         {
-            if (_border != null && _url != null)
+            get
             {
-                _nPatchMap = new PropertyMap();
-                _nPatchMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
-                _nPatchMap.Add(NpatchImageVisualProperty.URL, new PropertyValue(_url));
-                _nPatchMap.Add(NpatchImageVisualProperty.Border, new PropertyValue(_border));
-                if (_borderOnly) { _nPatchMap.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue(_borderOnly)); }
-                SetProperty(ImageView.Property.IMAGE, new PropertyValue(_nPatchMap));
+                return _synchronousLoading ?? false;
             }
-            else
+            set
             {
-                if (_url != null) { SetProperty(ImageView.Property.RESOURCE_URL, new PropertyValue(_url)); }
+                _synchronousLoading = value;
+                UpdateImage();
+            }
+        }
+
+        private void UpdateImage()
+        {
+            if (_url != null)
+            {
+                if (_border != null)
+                { // for nine-patch image
+                    _nPatchMap = new PropertyMap();
+                    _nPatchMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
+                    _nPatchMap.Add(NpatchImageVisualProperty.URL, new PropertyValue(_url));
+                    _nPatchMap.Add(NpatchImageVisualProperty.Border, new PropertyValue(_border));
+                    if (_borderOnly != null) { _nPatchMap.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)_borderOnly)); }
+                    if (_synchronousLoading != null) _nPatchMap.Add(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading));
+                    SetProperty(ImageView.Property.IMAGE, new PropertyValue(_nPatchMap));
+                }
+                else if(_synchronousLoading != null)
+                { // for normal image, with synchronous loading property
+                    PropertyMap imageMap = new PropertyMap();
+                    imageMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
+                    imageMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
+                    imageMap.Add(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading));
+                    SetProperty(ImageView.Property.IMAGE, new PropertyValue(imageMap));
+                }
+                else
+                { // just for normal image
+                    SetProperty(ImageView.Property.RESOURCE_URL, new PropertyValue(_url));
+                }
             }
         }
 
         private Rectangle _border = null;
-        private bool _borderOnly = false;
-        private string _url = null;
         private PropertyMap _nPatchMap = null;
+        private bool? _synchronousLoading = null;
+        private bool? _borderOnly = null;
+        private string _url = null;
 
     }