[NUI] CanvasView:: Add ViewBox Property (#3361)
authorJunsuChoi <jsuya.choi@samsung.com>
Tue, 3 Aug 2021 08:10:00 +0000 (17:10 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 6 Aug 2021 04:49:25 +0000 (13:49 +0900)
* [NUI] CanvasView:: Add ViewBox Property

Add a property that can change the viewbox value of CanvasView.
If the viewbox is smaller than the view size, the canvas will appear larger.
Conversely, if the viewbox is large, the canvas will look small.

* [NUI] CanvasView: Change viewBox property to method

we currently recommend NOT to use class type as a property.

src/Tizen.NUI/src/internal/Interop/Interop.CanvasView.cs
src/Tizen.NUI/src/public/BaseComponents/VectorGraphics/CanvasView.cs

index 70d231c..2ba1520 100755 (executable)
@@ -40,6 +40,9 @@ namespace Tizen.NUI
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_CanvasView_RemoveAllDrawables")]
             public static extern void RemoveAllDrawables(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_CanvasView_Property_VIEWBOX_get")]
+            public static extern int PropertyViewBoxGet();
         }
     }
 }
index 7130d11..bcaf585 100755 (executable)
@@ -90,6 +90,39 @@ namespace Tizen.NUI.BaseComponents.VectorGraphics
         }
 
         /// <summary>
+        /// Set size of CanvasView's viewbox.
+        /// </summary>
+        /// <param name="viewBox">The size of viewBox</param>
+        /// <exception cref="ArgumentNullException"> Thrown when drawable is null. </exception>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void SetViewBoxSize(Size2D viewBox)
+        {
+            if (viewBox == null)
+            {
+                throw new ArgumentNullException(nameof(viewBox));
+            }
+            PropertyValue setVal = new Tizen.NUI.PropertyValue(viewBox);
+            SetProperty(Interop.CanvasView.PropertyViewBoxGet(), setVal);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            setVal?.Dispose();
+        }
+
+        /// <summary>
+        /// Get size of CanvasView's viewbox.
+        /// </summary>
+        /// <returns>The size of viewBox</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Size2D GetViewBoxSize()
+        {
+            Size2D retVal = new Size2D(0, 0);
+            PropertyValue viewBoxPropertyValue = GetProperty(Interop.CanvasView.PropertyViewBoxGet());
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            viewBoxPropertyValue?.Get(retVal);
+            viewBoxPropertyValue?.Dispose();
+            return retVal;
+        }
+
+        /// <summary>
         /// Add drawable object to the CanvasView.
         /// This method is similar to registration. The added shape is drawn on the inner canvas.
         /// </summary>