1 // Copyright (c) 2024 Samsung Electronics Co., Ltd.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
16 using System.Runtime.InteropServices;
17 using System.Collections.Generic;
19 using System.ComponentModel;
21 namespace Tizen.NUI.Visuals
24 /// The visual which can display an n-patch image resource.
25 /// It will be used when we want to display n-patch image, border only n-patch, or make regular image stretched.
28 /// Following ImageVisual properties are not supported in NPatchVisual.
34 /// We assume that the image is a n-patch image always. So it does not support other image formats, like svg, lottie.
36 [EditorBrowsable(EditorBrowsableState.Never)]
37 public class NPatchVisual : ImageVisual
41 /// Creates an visual object.
43 [EditorBrowsable(EditorBrowsableState.Never)]
44 public NPatchVisual() : this(Interop.VisualObject.VisualObjectNew(), true)
46 NDalicPINVOKE.ThrowExceptionIfExists();
49 internal NPatchVisual(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn)
53 internal NPatchVisual(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister)
55 Type = (int)Tizen.NUI.Visual.Type.NPatch;
59 #region Visual Properties
61 /// Gets or sets whether to draw the borders only (If true).<br />
62 /// If not specified, the default is false.<br />
64 [EditorBrowsable(EditorBrowsableState.Never)]
65 public bool BorderOnly
69 UpdateVisualProperty((int)Tizen.NUI.NpatchImageVisualProperty.BorderOnly, new PropertyValue(value));
74 var propertyValue = GetCachedVisualProperty((int)Tizen.NUI.NpatchImageVisualProperty.BorderOnly);
75 propertyValue?.Get(out ret);
81 /// The border of the regular image is in the order: left, right, bottom, top.<br />
84 /// Note that it is not mean the value from 9 patch image.<br />
86 [EditorBrowsable(EditorBrowsableState.Never)]
87 public Rectangle Border
91 UpdateVisualProperty((int)Tizen.NUI.NpatchImageVisualProperty.Border, (value == null) ? null : new PropertyValue(value));
95 Rectangle ret = new Rectangle();
96 var propertyValue = GetCachedVisualProperty((int)Tizen.NUI.NpatchImageVisualProperty.Border);
97 propertyValue?.Get(ret);
103 /// Overlays the auxiliary image on top of an NPatch image.
104 /// The resulting visual image will be at least as large as the smallest possible n-patch or the auxiliary image, whichever is larger.
106 [EditorBrowsable(EditorBrowsableState.Never)]
107 public string AuxiliaryImageUrl
111 UpdateVisualProperty((int)Tizen.NUI.ImageVisualProperty.AuxiliaryImageURL, string.IsNullOrEmpty(value) ? null : new PropertyValue(value));
116 var propertyValue = GetCachedVisualProperty((int)Tizen.NUI.ImageVisualProperty.AuxiliaryImageURL);
117 propertyValue?.Get(out ret);
123 /// An alpha value for mixing between the masked main NPatch image and the auxiliary image.
125 [EditorBrowsable(EditorBrowsableState.Never)]
126 public float AuxiliaryImageAlpha
130 UpdateVisualProperty((int)Tizen.NUI.ImageVisualProperty.AuxiliaryImageAlpha, new PropertyValue(value));
135 var propertyValue = GetCachedVisualProperty((int)Tizen.NUI.ImageVisualProperty.AuxiliaryImageAlpha);
136 propertyValue?.Get(out ret);