2 * Copyright(c) 2022 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.
19 using System.ComponentModel;
20 using System.Reflection;
21 using System.Runtime.InteropServices;
22 using Tizen.NUI.Binding;
24 namespace Tizen.NUI.BaseComponents
27 /// View is the base class for all views.
29 /// <since_tizen> 3 </since_tizen>
30 public partial class View
33 /// Perform an action on a visual registered to this view. <br />
34 /// Visuals will have actions. This API is used to perform one of these actions with the given attributes.
36 /// <param name="propertyIndexOfVisual">The Property index of the visual.</param>
37 /// <param name="propertyIndexOfActionId">The action to perform. See Visual to find the supported actions.</param>
38 /// <param name="attributes">Optional attributes for the action.</param>
39 /// <since_tizen> 5 </since_tizen>
40 public void DoAction(int propertyIndexOfVisual, int propertyIndexOfActionId, PropertyValue attributes)
42 Interop.View.DoAction(SwigCPtr, propertyIndexOfVisual, propertyIndexOfActionId, PropertyValue.getCPtr(attributes));
43 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
47 /// Creates an animation to animate the background color visual. If there is no
48 /// background visual, creates one with transparent black as it's mixColor.
50 /// <since_tizen> 3 </since_tizen>
51 public Animation AnimateBackgroundColor(object destinationValue,
54 AlphaFunction.BuiltinFunctions? alphaFunction = null,
55 object initialValue = null)
57 if (IsBackgroundEmpty())
59 // If there is no background yet, ensure there is a transparent
61 BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);
63 return AnimateColor("background", destinationValue, startTime, endTime, alphaFunction, initialValue);
67 /// Creates an animation to animate the mixColor of the named visual.
69 /// <since_tizen> 3 </since_tizen>
70 public Animation AnimateColor(string targetVisual, object destinationColor, int startTime, int endTime, AlphaFunction.BuiltinFunctions? alphaFunction = null, object initialColor = null)
72 Animation animation = null;
73 using (PropertyMap animator = new PropertyMap())
74 using (PropertyMap timePeriod = new PropertyMap())
75 using (PropertyValue pvDuration = new PropertyValue((endTime - startTime) / 1000.0f))
76 using (PropertyValue pvDelay = new PropertyValue(startTime / 1000.0f))
77 using (PropertyMap transition = new PropertyMap())
78 using (PropertyValue pvTarget = new PropertyValue(targetVisual))
79 using (PropertyValue pvProperty = new PropertyValue("mixColor"))
80 using (PropertyValue destValue = PropertyValue.CreateFromObject(destinationColor))
82 if (alphaFunction != null)
84 using (PropertyValue pvAlpha = new PropertyValue(AlphaFunction.BuiltinToPropertyKey(alphaFunction)))
86 animator.Add("alphaFunction", pvAlpha);
90 timePeriod.Add("duration", pvDuration);
91 timePeriod.Add("delay", pvDelay);
92 using (PropertyValue pvTimePeriod = new PropertyValue(timePeriod))
94 animator.Add("timePeriod", pvTimePeriod);
96 using (PropertyValue pvAnimator = new PropertyValue(animator))
98 transition.Add("animator", pvAnimator);
100 transition.Add("target", pvTarget);
101 transition.Add("property", pvProperty);
103 if (initialColor != null)
105 using (PropertyValue initValue = PropertyValue.CreateFromObject(initialColor))
107 transition.Add("initialValue", initValue);
111 transition.Add("targetValue", destValue);
112 using (TransitionData transitionData = new TransitionData(transition))
114 animation = new Animation(Interop.View.CreateTransition(SwigCPtr, TransitionData.getCPtr(transitionData)), true);
116 if (NDalicPINVOKE.SWIGPendingException.Pending)
117 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
122 // From Container Base class
124 /// Adds a child view to this view.
126 /// <seealso cref="Container.Add" />
127 /// <since_tizen> 4 </since_tizen>
128 public override void Add(View child)
130 bool hasLayout = (layout != null);
134 Tizen.Log.Fatal("NUI", "Child is null");
138 Container oldParent = child.GetParent();
139 if (oldParent != this)
141 // If child already has a parent then re-parent child
142 if (oldParent != null)
144 if (child.Layout != null)
146 child.Layout.SetReplaceFlag();
148 oldParent.Remove(child);
150 child.InternalParent = this;
151 LayoutCount += child.LayoutCount;
153 Interop.Actor.Add(SwigCPtr, View.getCPtr(child));
155 if (NDalicPINVOKE.SWIGPendingException.Pending)
156 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160 if (ChildAdded != null)
162 ChildAddedEventArgs e = new ChildAddedEventArgs
172 /// Removes a child view from this View. If the view was not a child of this view, this is a no-op.
174 /// <seealso cref="Container.Remove" />
175 /// <since_tizen> 4 </since_tizen>
176 /// <exception cref="InvalidOperationException">Thrown when deleting a view that is not a child of this view</exception>
177 public override void Remove(View child)
179 if (child == null || child.GetParent() == null) // Early out if child null.
182 if (child.GetParent() != this)
184 //throw new System.InvalidOperationException("You have deleted a view that is not a child of this view.");
185 Tizen.Log.Error("NUI", "You have deleted a view that is not a child of this view.");
189 bool hasLayout = (layout != null);
191 // If View has a layout then do a deferred child removal
192 // Actual child removal is performed by the layouting system so
193 // transitions can be completed.
196 (layout as LayoutGroup)?.RemoveChildFromLayoutGroup(child);
203 /// Retrieves a child view by index.
205 /// <seealso cref="Container.GetChildAt" />
206 /// <since_tizen> 4 </since_tizen>
207 public override View GetChildAt(uint index)
209 if (index < Children.Count)
211 return Children[Convert.ToInt32(index)];
220 /// Retrieves a child view as Animatable by index.
222 /// <param name="index">The index of the Animatable to find.</param>
223 /// <returns>A handle to the view as Animatable if found, or an empty handle if not.</returns>
224 /// This will not be public opened.
225 [EditorBrowsable(EditorBrowsableState.Never)]
226 public Animatable GetChildAnimatableAt(uint index)
228 if (index < Children.Count)
230 return Children[Convert.ToInt32(index)] as Animatable;
239 /// Retrieves the number of children held by the view.
241 /// <seealso cref="Container.GetChildCount" />
242 /// <since_tizen> 4 </since_tizen>
243 [Obsolete("This has been deprecated in API9 and will be removed in API11. Use ChildCount property instead.")]
244 public override uint GetChildCount()
246 return Convert.ToUInt32(Children.Count);
250 /// Gets the views parent.
252 /// <seealso cref="Container.GetParent()" />
253 /// <since_tizen> 4 </since_tizen>
254 public override Container GetParent()
256 return InternalParent as Container;
260 /// Queries whether the view has a focus.
262 /// <returns>True if this view has a focus.</returns>
263 /// <since_tizen> 3 </since_tizen>
264 public bool HasFocus()
267 if (SwigCPtr.Handle != global::System.IntPtr.Zero)
269 ret = Interop.View.HasKeyInputFocus(SwigCPtr);
270 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274 Tizen.Log.Error("NUI", "swigCPtr of view is already disposed.");
280 /// Sets the name of the style to be applied to the view.
282 /// <param name="styleName">A string matching a style described in a stylesheet.</param>
283 /// <since_tizen> 3 </since_tizen>
284 [Obsolete("This has been deprecated in API9 and will be removed in API11. Use StyleName property instead.")]
285 public void SetStyleName(string styleName)
287 Interop.View.SetStyleName(SwigCPtr, styleName);
288 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
292 /// Retrieves the name of the style to be applied to the view (if any).
294 /// <returns>A string matching a style, or an empty string.</returns>
295 /// <since_tizen> 3 </since_tizen>
296 [Obsolete("This has been deprecated in API9 and will be removed in API11. Use StyleName property instead.")]
297 public string GetStyleName()
299 string ret = Interop.View.GetStyleName(SwigCPtr);
300 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
305 /// Clears the background.
307 /// <since_tizen> 3 </since_tizen>
308 public void ClearBackground()
310 Interop.View.ClearBackground(SwigCPtr);
311 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318 /// This is an asynchronous method.
320 /// <since_tizen> 3 </since_tizen>
325 if (GetAccessibilityStates()[AccessibilityState.Modal])
327 RegisterDefaultLabel();
329 if (Accessibility.Accessibility.IsEnabled)
331 EmitAccessibilityStateChangedEvent(AccessibilityState.Showing, true);
340 /// This is an asynchronous method.
341 /// If the view is hidden, then the view and its children will not be rendered.
342 /// This is regardless of the individual visibility of the children, i.e., the view will only be rendered if all of its parents are shown.
344 /// <since_tizen> 3 </since_tizen>
349 if (GetAccessibilityStates()[AccessibilityState.Modal])
351 UnregisterDefaultLabel();
353 if (Accessibility.Accessibility.IsEnabled)
355 EmitAccessibilityStateChangedEvent(AccessibilityState.Showing, false);
361 /// Raises the view above all other views.
364 /// Sibling order of views within the parent will be updated automatically.
365 /// Once a raise or lower API is used, that view will then have an exclusive sibling order independent of insertion.
367 /// <since_tizen> 3 </since_tizen>
368 public void RaiseToTop()
370 var parentChildren = GetParent()?.Children;
372 if (parentChildren != null)
374 parentChildren.Remove(this);
375 parentChildren.Add(this);
377 LayoutGroup layout = Layout as LayoutGroup;
378 layout?.ChangeLayoutSiblingOrder(parentChildren.Count - 1);
380 Interop.NDalic.RaiseToTop(SwigCPtr);
381 if (NDalicPINVOKE.SWIGPendingException.Pending)
382 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
388 /// Lowers the view to the bottom of all views.
391 /// The sibling order of views within the parent will be updated automatically.
392 /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
394 /// <since_tizen> 3 </since_tizen>
395 public void LowerToBottom()
397 var parentChildren = GetParent()?.Children;
399 if (parentChildren != null)
401 parentChildren.Remove(this);
402 parentChildren.Insert(0, this);
404 LayoutGroup layout = Layout as LayoutGroup;
405 layout?.ChangeLayoutSiblingOrder(0);
407 Interop.NDalic.LowerToBottom(SwigCPtr);
408 if (NDalicPINVOKE.SWIGPendingException.Pending)
409 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
414 /// Queries if all resources required by a view are loaded and ready.
416 /// <remarks>Most resources are only loaded when the control is placed on the stage.
418 /// <since_tizen> 3 </since_tizen>
419 public bool IsResourceReady()
421 bool ret = Interop.View.IsResourceReady(SwigCPtr);
422 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
427 /// Gets the parent layer of this view.If a view has no parent, this method does not do anything.
429 /// <pre>The view has been initialized. </pre>
430 /// <returns>The parent layer of view </returns>
431 /// <since_tizen> 5 </since_tizen>
432 public Layer GetLayer()
434 //to fix memory leak issue, match the handle count with native side.
435 IntPtr cPtr = Interop.Actor.GetLayer(SwigCPtr);
436 Layer ret = this.GetInstanceSafely<Layer>(cPtr);
437 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
442 /// Removes a view from its parent view or layer. If a view has no parent, this method does nothing.
444 /// <pre>The (child) view has been initialized. </pre>
445 /// <since_tizen> 4 </since_tizen>
446 public void Unparent()
448 GetParent()?.Remove(this);
452 /// Search through this view's hierarchy for a view with the given name.
453 /// The view itself is also considered in the search.
455 /// <pre>The view has been initialized.</pre>
456 /// <param name="viewName">The name of the view to find.</param>
457 /// <returns>A handle to the view if found, or an empty handle if not.</returns>
458 /// <since_tizen> 3 </since_tizen>
459 public View FindChildByName(string viewName)
461 //to fix memory leak issue, match the handle count with native side.
462 IntPtr cPtr = Interop.Actor.FindChildByName(SwigCPtr, viewName);
463 View ret = this.GetInstanceSafely<View>(cPtr);
464 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
469 /// Search through this view's hierarchy for a view as Animatable with the given name.
470 /// The view itself is also considered in the search.
472 /// <pre>The view has been initialized.</pre>
473 /// <param name="childName">The name of the Animatable to find.</param>
474 /// <returns>A handle to the view as Animatable if found, or an empty handle if not.</returns>
475 /// This will not be public opened.
476 [EditorBrowsable(EditorBrowsableState.Never)]
477 public Animatable FindChildAnimatableByName(string childName)
479 //to fix memory leak issue, match the handle count with native side.
480 IntPtr cPtr = Interop.Actor.FindChildByName(SwigCPtr, childName);
481 Animatable ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Animatable;
484 // Register new camera into Registry.
485 ret = new Animatable(cPtr, true);
489 // We found matched NUI camera. Reduce cPtr reference count.
490 HandleRef handle = new HandleRef(this, cPtr);
491 Interop.Actor.DeleteActor(handle);
492 handle = new HandleRef(null, IntPtr.Zero);
494 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
499 /// Converts screen coordinates into the view's coordinate system using the default camera.
501 /// <pre>The view has been initialized.</pre>
502 /// <remarks>The view coordinates are relative to the top-left(0.0, 0.0, 0.5).</remarks>
503 /// <param name="localX">On return, the X-coordinate relative to the view.</param>
504 /// <param name="localY">On return, the Y-coordinate relative to the view.</param>
505 /// <param name="screenX">The screen X-coordinate.</param>
506 /// <param name="screenY">The screen Y-coordinate.</param>
507 /// <returns>True if the conversion succeeded.</returns>
508 /// <since_tizen> 3 </since_tizen>
509 public bool ScreenToLocal(out float localX, out float localY, float screenX, float screenY)
511 bool ret = Interop.Actor.ScreenToLocal(SwigCPtr, out localX, out localY, screenX, screenY);
512 if (NDalicPINVOKE.SWIGPendingException.Pending)
513 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
518 /// Sets the relative to parent size factor of the view.<br />
519 /// This factor is only used when ResizePolicy is set to either:
520 /// ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.<br />
521 /// This view's size is set to the view's size multiplied by or added to this factor, depending on ResizePolicy.<br />
523 /// <pre>The view has been initialized.</pre>
524 /// <param name="factor">A Vector3 representing the relative factor to be applied to each axis.</param>
525 /// <since_tizen> 3 </since_tizen>
526 public void SetSizeModeFactor(Vector3 factor)
528 Interop.Actor.SetSizeModeFactor(SwigCPtr, Vector3.getCPtr(factor));
529 if (NDalicPINVOKE.SWIGPendingException.Pending)
530 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
533 /// Calculates the height of the view given a width.<br />
534 /// The natural size is used for default calculation.<br />
535 /// Size 0 is treated as aspect ratio 1:1.<br />
537 /// <param name="width">The width to use.</param>
538 /// <returns>The height based on the width.</returns>
539 /// <since_tizen> 3 </since_tizen>
540 public float GetHeightForWidth(float width)
542 float ret = Interop.Actor.GetHeightForWidth(SwigCPtr, width);
543 if (NDalicPINVOKE.SWIGPendingException.Pending)
544 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
549 /// Calculates the width of the view given a height.<br />
550 /// The natural size is used for default calculation.<br />
551 /// Size 0 is treated as aspect ratio 1:1.<br />
553 /// <param name="height">The height to use.</param>
554 /// <returns>The width based on the height.</returns>
555 /// <since_tizen> 3 </since_tizen>
556 public float GetWidthForHeight(float height)
558 float ret = Interop.Actor.GetWidthForHeight(SwigCPtr, height);
559 if (NDalicPINVOKE.SWIGPendingException.Pending)
560 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
565 /// Return the amount of size allocated for relayout.
567 /// <param name="dimension">The dimension to retrieve.</param>
568 /// <returns>Return the size.</returns>
569 /// <since_tizen> 3 </since_tizen>
570 public float GetRelayoutSize(DimensionType dimension)
572 float ret = Interop.Actor.GetRelayoutSize(SwigCPtr, (int)dimension);
573 if (NDalicPINVOKE.SWIGPendingException.Pending)
574 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
579 /// Set the padding for the view.
581 /// <param name="padding">Padding for the view.</param>
582 /// <since_tizen> 3 </since_tizen>
583 // [Obsolete("This has been deprecated in API9 and will be removed in API11. Use Padding property instead.")]
584 public void SetPadding(PaddingType padding)
586 Interop.Actor.SetPadding(SwigCPtr, PaddingType.getCPtr(padding));
587 if (NDalicPINVOKE.SWIGPendingException.Pending)
588 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
592 /// Return the value of padding for the view.
594 /// <param name="paddingOut">the value of padding for the view</param>
595 /// <since_tizen> 3 </since_tizen>
596 [Obsolete("This has been deprecated in API9 and will be removed in API11. Use Padding property instead.")]
597 public void GetPadding(PaddingType paddingOut)
599 Interop.Actor.GetPadding(SwigCPtr, PaddingType.getCPtr(paddingOut));
600 if (NDalicPINVOKE.SWIGPendingException.Pending)
601 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
604 /// <since_tizen> 3 </since_tizen>
605 public uint AddRenderer(Renderer renderer)
607 uint ret = Interop.Actor.AddRenderer(SwigCPtr, Renderer.getCPtr(renderer));
608 if (NDalicPINVOKE.SWIGPendingException.Pending)
609 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
613 /// <since_tizen> 3 </since_tizen>
614 public Renderer GetRendererAt(uint index)
616 //to fix memory leak issue, match the handle count with native side.
617 IntPtr cPtr = Interop.Actor.GetRendererAt(SwigCPtr, index);
618 HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
619 Renderer ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as Renderer;
620 if (cPtr != null && ret == null)
622 ret = new Renderer(cPtr, false);
623 if (NDalicPINVOKE.SWIGPendingException.Pending)
624 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
627 Interop.BaseHandle.DeleteBaseHandle(CPtr);
628 CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
630 if (NDalicPINVOKE.SWIGPendingException.Pending)
631 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
635 /// <since_tizen> 3 </since_tizen>
636 public void RemoveRenderer(Renderer renderer)
638 Interop.Actor.RemoveRenderer(SwigCPtr, Renderer.getCPtr(renderer));
639 if (NDalicPINVOKE.SWIGPendingException.Pending)
640 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
643 /// <since_tizen> 3 </since_tizen>
644 public void RemoveRenderer(uint index)
646 Interop.Actor.RemoveRenderer(SwigCPtr, index);
647 if (NDalicPINVOKE.SWIGPendingException.Pending)
648 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
651 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
652 [EditorBrowsable(EditorBrowsableState.Never)]
653 public void RotateBy(Degree angle, Vector3 axis)
655 Interop.ActorInternal.RotateByDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
656 if (NDalicPINVOKE.SWIGPendingException.Pending)
657 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
660 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
661 [EditorBrowsable(EditorBrowsableState.Never)]
662 public void RotateBy(Radian angle, Vector3 axis)
664 Interop.ActorInternal.RotateByRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
665 if (NDalicPINVOKE.SWIGPendingException.Pending)
666 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
669 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
670 [EditorBrowsable(EditorBrowsableState.Never)]
671 public void RotateBy(Rotation relativeRotation)
673 Interop.ActorInternal.RotateByQuaternion(SwigCPtr, Rotation.getCPtr(relativeRotation));
674 if (NDalicPINVOKE.SWIGPendingException.Pending)
675 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
678 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
679 [EditorBrowsable(EditorBrowsableState.Never)]
680 public void ScaleBy(Vector3 relativeScale)
682 Interop.ActorInternal.ScaleBy(SwigCPtr, Vector3.getCPtr(relativeScale));
683 if (NDalicPINVOKE.SWIGPendingException.Pending)
684 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
687 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
688 [EditorBrowsable(EditorBrowsableState.Never)]
689 public void SetColorMode(ColorMode colorMode)
691 Interop.ActorInternal.SetColorMode(SwigCPtr, (int)colorMode);
692 if (NDalicPINVOKE.SWIGPendingException.Pending)
693 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
696 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
697 [EditorBrowsable(EditorBrowsableState.Never)]
698 public void ObjectDump()
700 if (0 == Children.Count)
702 Type type = this.GetType();
703 PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
704 foreach (var property in properties)
706 if (null != property && property.CanRead)
708 Tizen.Log.Fatal("NUI", $"{type.Name} {property.Name} ({property.PropertyType.Name}): {property.GetValueString(this, property.PropertyType)}");
714 foreach (View view in Children)
721 /// Search through this View's hierarchy for a View with the given unique ID.
722 /// The View itself is also considered in the search.
724 /// <param name="id">The ID of the View to find</param>
725 /// <returns>A View if found or a null if not</returns>
726 [EditorBrowsable(EditorBrowsableState.Never)]
727 [Obsolete("This will be removed at API11. Use FindDescendantByID(uint id) instead.")]
728 public View FindChildByID(uint id)
730 IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
731 View ret = this.GetInstanceSafely<View>(cPtr);
732 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
737 /// Search through this View's hierarchy for a View with the given unique ID.
739 /// <param name="id">The ID of the View to find.</param>
740 /// <returns>A handle to the View if found, or an empty handle if not.</returns>
741 /// <since_tizen> 9 </since_tizen>
742 public View FindDescendantByID(uint id)
744 return FindChildById(id);
748 /// Raise view above the next sibling view.
750 /// <since_tizen> 9 </since_tizen>
753 var parentChildren = GetParent()?.Children;
755 if (parentChildren != null)
757 int currentIndex = parentChildren.IndexOf(this);
759 // If the view is not already the last item in the list.
760 if (currentIndex >= 0 && currentIndex < parentChildren.Count - 1)
762 View temp = parentChildren[currentIndex + 1];
763 parentChildren[currentIndex + 1] = this;
764 parentChildren[currentIndex] = temp;
766 Interop.NDalic.Raise(SwigCPtr);
767 if (NDalicPINVOKE.SWIGPendingException.Pending)
768 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
774 /// Lower the view below the previous sibling view.
776 /// <since_tizen> 9 </since_tizen>
779 var parentChildren = GetParent()?.Children;
781 if (parentChildren != null)
783 int currentIndex = parentChildren.IndexOf(this);
785 // If the view is not already the first item in the list.
786 if (currentIndex > 0 && currentIndex < parentChildren.Count)
788 View temp = parentChildren[currentIndex - 1];
789 parentChildren[currentIndex - 1] = this;
790 parentChildren[currentIndex] = temp;
792 Interop.NDalic.Lower(SwigCPtr);
793 if (NDalicPINVOKE.SWIGPendingException.Pending)
794 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
800 /// Raises the view to above the target view.
802 /// <remarks>The sibling order of views within the parent will be updated automatically.
803 /// Views on the level above the target view will still be shown above this view.
804 /// Once a raise or lower API is used then that view will have an exclusive sibling order independent of insertion.
806 /// <param name="target">Will be raised above this view.</param>
807 /// <since_tizen> 9 </since_tizen>
808 public void RaiseAbove(View target)
810 var parentChildren = GetParent()?.Children;
812 if (parentChildren != null)
814 int currentIndex = parentChildren.IndexOf(this);
815 int targetIndex = parentChildren.IndexOf(target);
817 if (currentIndex < 0 || targetIndex < 0 ||
818 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
820 NUILog.Error("index should be bigger than 0 and less than children of layer count");
823 // If the currentIndex is less than the target index and the target has the same parent.
824 if (currentIndex < targetIndex)
826 parentChildren.Remove(this);
827 parentChildren.Insert(targetIndex, this);
829 Interop.NDalic.RaiseAbove(SwigCPtr, View.getCPtr(target));
830 if (NDalicPINVOKE.SWIGPendingException.Pending)
831 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
838 /// Lowers the view to below the target view.
840 /// <remarks>The sibling order of views within the parent will be updated automatically.
841 /// Once a raise or lower API is used then that view will have an exclusive sibling order independent of insertion.
843 /// <param name="target">Will be lowered below this view.</param>
844 /// <since_tizen> 9 </since_tizen>
845 public void LowerBelow(View target)
847 var parentChildren = GetParent()?.Children;
849 if (parentChildren != null)
851 int currentIndex = parentChildren.IndexOf(this);
852 int targetIndex = parentChildren.IndexOf(target);
853 if (currentIndex < 0 || targetIndex < 0 ||
854 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
856 NUILog.Error("index should be bigger than 0 and less than children of layer count");
860 // If the currentIndex is not already the 0th index and the target has the same parent.
861 if ((currentIndex != 0) && (targetIndex != -1) &&
862 (currentIndex > targetIndex))
864 parentChildren.Remove(this);
865 parentChildren.Insert(targetIndex, this);
867 Interop.NDalic.LowerBelow(SwigCPtr, View.getCPtr(target));
868 if (NDalicPINVOKE.SWIGPendingException.Pending)
869 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
876 /// Sets the position of the View.
877 /// The coordinates are relative to the View's parent.
878 /// The View's z position will be set to 0.0f.
880 /// <param name="x">The new x position</param>
881 /// <param name="y">The new y position</param>
883 /// This is a hidden API(inhouse API) only for internal purpose.
885 [EditorBrowsable(EditorBrowsableState.Never)]
886 public void SetPosition(float x, float y)
888 Interop.ActorInternal.SetPosition(SwigCPtr, x, y);
889 if (NDalicPINVOKE.SWIGPendingException.Pending)
890 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
894 /// Sets the position of the View.
895 /// The coordinates are relative to the View's parent.
897 /// <param name="x">The new x position</param>
898 /// <param name="y">The new y position</param>
899 /// <param name="z">The new z position</param>
901 /// This is a hidden API(inhouse API) only for internal purpose.
903 [EditorBrowsable(EditorBrowsableState.Never)]
904 public void SetPosition(float x, float y, float z)
906 Interop.ActorInternal.SetPosition(SwigCPtr, x, y, z);
907 if (NDalicPINVOKE.SWIGPendingException.Pending)
908 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
912 /// Sets the position of the View.
913 /// The coordinates are relative to the View's parent.
915 /// <param name="position">The new position</param>
917 /// This is a hidden API(inhouse API) only for internal purpose.
919 [EditorBrowsable(EditorBrowsableState.Never)]
920 public void SetPosition(Vector3 position)
922 Interop.ActorInternal.SetPosition(SwigCPtr, Vector3.getCPtr(position));
923 if (NDalicPINVOKE.SWIGPendingException.Pending)
924 throw NDalicPINVOKE.SWIGPendingException.Retrieve();