2 * Copyright(c) 2020 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 Tizen.NUI.PropertyMap background = Background;
59 if (background.Empty())
61 // If there is no background yet, ensure there is a transparent
63 BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);
64 background = Background;
66 return AnimateColor("background", destinationValue, startTime, endTime, alphaFunction, initialValue);
70 /// Creates an animation to animate the mixColor of the named visual.
72 /// <since_tizen> 3 </since_tizen>
73 public Animation AnimateColor(string targetVisual, object destinationColor, int startTime, int endTime, AlphaFunction.BuiltinFunctions? alphaFunction = null, object initialColor = null)
75 Animation animation = null;
76 using (PropertyMap animator = new PropertyMap())
77 using (PropertyMap timePeriod = new PropertyMap())
78 using (PropertyValue pvDuration = new PropertyValue((endTime - startTime) / 1000.0f))
79 using (PropertyValue pvDelay = new PropertyValue(startTime / 1000.0f))
80 using (PropertyMap transition = new PropertyMap())
81 using (PropertyValue pvTarget = new PropertyValue(targetVisual))
82 using (PropertyValue pvProperty = new PropertyValue("mixColor"))
83 using (PropertyValue destValue = PropertyValue.CreateFromObject(destinationColor))
85 if (alphaFunction != null)
87 using (PropertyValue pvAlpha = new PropertyValue(AlphaFunction.BuiltinToPropertyKey(alphaFunction)))
89 animator.Add("alphaFunction", pvAlpha);
93 timePeriod.Add("duration", pvDuration);
94 timePeriod.Add("delay", pvDelay);
95 using (PropertyValue pvTimePeriod = new PropertyValue(timePeriod))
97 animator.Add("timePeriod", pvTimePeriod);
99 using (PropertyValue pvAnimator = new PropertyValue(animator))
101 transition.Add("animator", pvAnimator);
103 transition.Add("target", pvTarget);
104 transition.Add("property", pvProperty);
106 if (initialColor != null)
108 using (PropertyValue initValue = PropertyValue.CreateFromObject(initialColor))
110 transition.Add("initialValue", initValue);
114 transition.Add("targetValue", destValue);
115 using (TransitionData transitionData = new TransitionData(transition))
117 animation = new Animation(Interop.View.CreateTransition(SwigCPtr, TransitionData.getCPtr(transitionData)), true);
119 if (NDalicPINVOKE.SWIGPendingException.Pending)
120 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125 // From Container Base class
127 /// Adds a child view to this view.
129 /// <seealso cref="Container.Add" />
130 /// <since_tizen> 4 </since_tizen>
131 public override void Add(View child)
133 bool hasLayout = (layout != null);
137 Tizen.Log.Fatal("NUI", "Child is null");
141 Container oldParent = child.GetParent();
142 if (oldParent != this)
144 // If child already has a parent then re-parent child
145 if (oldParent != null)
147 if (child.Layout != null)
149 child.Layout.SetReplaceFlag();
151 oldParent.Remove(child);
153 child.InternalParent = this;
155 Interop.Actor.Add(SwigCPtr, View.getCPtr(child));
157 if (NDalicPINVOKE.SWIGPendingException.Pending)
158 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161 if (ChildAdded != null)
163 ChildAddedEventArgs e = new ChildAddedEventArgs
170 AddChildBindableObject(child);
175 /// Removes a child view from this View. If the view was not a child of this view, this is a no-op.
177 /// <seealso cref="Container.Remove" />
178 /// <since_tizen> 4 </since_tizen>
179 /// <exception cref="InvalidOperationException">Thrown when deleting a view that is not a child of this view</exception>
180 public override void Remove(View child)
182 if (child == null || child.GetParent() == null) // Early out if child null.
185 if (child.GetParent() != this)
187 //throw new System.InvalidOperationException("You have deleted a view that is not a child of this view.");
188 Tizen.Log.Error("NUI", "You have deleted a view that is not a child of this view.");
191 bool hasLayout = (layout != null);
193 // If View has a layout then do a deferred child removal
194 // Actual child removal is performed by the layouting system so
195 // transitions can be completed.
198 (layout as LayoutGroup)?.RemoveChildFromLayoutGroup(child);
205 /// Retrieves a child view by index.
207 /// <seealso cref="Container.GetChildAt" />
208 /// <since_tizen> 4 </since_tizen>
209 public override View GetChildAt(uint index)
211 if (index < Children.Count)
213 return Children[Convert.ToInt32(index)];
222 /// Retrieves the number of children held by the view.
224 /// <seealso cref="Container.GetChildCount" />
225 /// <since_tizen> 4 </since_tizen>
226 [Obsolete("Deprecated in API9, will be removed in API11. Please use ChildCount property instead!")]
227 public override uint GetChildCount()
229 return Convert.ToUInt32(Children.Count);
233 /// Gets the views parent.
235 /// <seealso cref="Container.GetParent()" />
236 /// <since_tizen> 4 </since_tizen>
237 public override Container GetParent()
239 return InternalParent as Container;
243 /// Queries whether the view has a focus.
245 /// <returns>True if this view has a focus.</returns>
246 /// <since_tizen> 3 </since_tizen>
247 public bool HasFocus()
250 if (SwigCPtr.Handle != global::System.IntPtr.Zero)
252 ret = Interop.View.HasKeyInputFocus(SwigCPtr);
253 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257 Tizen.Log.Error("NUI", "swigCPtr of view is already disposed.");
263 /// Sets the name of the style to be applied to the view.
265 /// <param name="styleName">A string matching a style described in a stylesheet.</param>
266 /// <since_tizen> 3 </since_tizen>
267 [Obsolete("Deprecated in API9, will be removed in API11. Please use StyleName property instead!")]
268 public void SetStyleName(string styleName)
270 Interop.View.SetStyleName(SwigCPtr, styleName);
271 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
275 /// Retrieves the name of the style to be applied to the view (if any).
277 /// <returns>A string matching a style, or an empty string.</returns>
278 /// <since_tizen> 3 </since_tizen>
279 [Obsolete("Deprecated in API9, will be removed in API11. Please use StyleName property instead!")]
280 public string GetStyleName()
282 string ret = Interop.View.GetStyleName(SwigCPtr);
283 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288 /// Clears the background.
290 /// <since_tizen> 3 </since_tizen>
291 public void ClearBackground()
293 Interop.View.ClearBackground(SwigCPtr);
294 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
301 /// This is an asynchronous method.
303 /// <since_tizen> 3 </since_tizen>
306 if (Accessibility.Accessibility.Enabled && ((GetAccessibilityStates() & AccessibilityStates.Modal) != 0))
318 /// This is an asynchronous method.
319 /// If the view is hidden, then the view and its children will not be rendered.
320 /// 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.
322 /// <since_tizen> 3 </since_tizen>
327 if (Accessibility.Accessibility.Enabled && ((GetAccessibilityStates() & AccessibilityStates.Modal) != 0))
334 /// Raises the view above all other views.
337 /// Sibling order of views within the parent will be updated automatically.
338 /// Once a raise or lower API is used, that view will then have an exclusive sibling order independent of insertion.
340 /// <since_tizen> 3 </since_tizen>
341 public void RaiseToTop()
343 var parentChildren = GetParent()?.Children;
345 if (parentChildren != null)
347 parentChildren.Remove(this);
348 parentChildren.Add(this);
350 LayoutGroup layout = Layout as LayoutGroup;
351 layout?.ChangeLayoutSiblingOrder(parentChildren.Count - 1);
353 Interop.NDalic.RaiseToTop(SwigCPtr);
354 if (NDalicPINVOKE.SWIGPendingException.Pending)
355 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
361 /// Lowers the view to the bottom of all views.
364 /// The 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 LowerToBottom()
370 var parentChildren = GetParent()?.Children;
372 if (parentChildren != null)
374 parentChildren.Remove(this);
375 parentChildren.Insert(0, this);
377 LayoutGroup layout = Layout as LayoutGroup;
378 layout?.ChangeLayoutSiblingOrder(0);
380 Interop.NDalic.LowerToBottom(SwigCPtr);
381 if (NDalicPINVOKE.SWIGPendingException.Pending)
382 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
387 /// Queries if all resources required by a view are loaded and ready.
389 /// <remarks>Most resources are only loaded when the control is placed on the stage.
391 /// <since_tizen> 3 </since_tizen>
392 public bool IsResourceReady()
394 bool ret = Interop.View.IsResourceReady(SwigCPtr);
395 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
400 /// Gets the parent layer of this view.If a view has no parent, this method does not do anything.
402 /// <pre>The view has been initialized. </pre>
403 /// <returns>The parent layer of view </returns>
404 /// <since_tizen> 5 </since_tizen>
405 public Layer GetLayer()
407 //to fix memory leak issue, match the handle count with native side.
408 IntPtr cPtr = Interop.Actor.GetLayer(SwigCPtr);
409 Layer ret = this.GetInstanceSafely<Layer>(cPtr);
410 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
415 /// Removes a view from its parent view or layer. If a view has no parent, this method does nothing.
417 /// <pre>The (child) view has been initialized. </pre>
418 /// <since_tizen> 4 </since_tizen>
419 public void Unparent()
421 GetParent()?.Remove(this);
425 /// Search through this view's hierarchy for a view with the given name.
426 /// The view itself is also considered in the search.
428 /// <pre>The view has been initialized.</pre>
429 /// <param name="viewName">The name of the view to find.</param>
430 /// <returns>A handle to the view if found, or an empty handle if not.</returns>
431 /// <since_tizen> 3 </since_tizen>
432 public View FindChildByName(string viewName)
434 //to fix memory leak issue, match the handle count with native side.
435 IntPtr cPtr = Interop.Actor.FindChildByName(SwigCPtr, viewName);
436 View ret = this.GetInstanceSafely<View>(cPtr);
437 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
442 /// Converts screen coordinates into the view's coordinate system using the default camera.
444 /// <pre>The view has been initialized.</pre>
445 /// <remarks>The view coordinates are relative to the top-left(0.0, 0.0, 0.5).</remarks>
446 /// <param name="localX">On return, the X-coordinate relative to the view.</param>
447 /// <param name="localY">On return, the Y-coordinate relative to the view.</param>
448 /// <param name="screenX">The screen X-coordinate.</param>
449 /// <param name="screenY">The screen Y-coordinate.</param>
450 /// <returns>True if the conversion succeeded.</returns>
451 /// <since_tizen> 3 </since_tizen>
452 public bool ScreenToLocal(out float localX, out float localY, float screenX, float screenY)
454 bool ret = Interop.Actor.ScreenToLocal(SwigCPtr, out localX, out localY, screenX, screenY);
455 if (NDalicPINVOKE.SWIGPendingException.Pending)
456 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
461 /// Sets the relative to parent size factor of the view.<br />
462 /// This factor is only used when ResizePolicy is set to either:
463 /// ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT.<br />
464 /// This view's size is set to the view's size multiplied by or added to this factor, depending on ResizePolicy.<br />
466 /// <pre>The view has been initialized.</pre>
467 /// <param name="factor">A Vector3 representing the relative factor to be applied to each axis.</param>
468 /// <since_tizen> 3 </since_tizen>
469 public void SetSizeModeFactor(Vector3 factor)
471 Interop.Actor.SetSizeModeFactor(SwigCPtr, Vector3.getCPtr(factor));
472 if (NDalicPINVOKE.SWIGPendingException.Pending)
473 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
476 /// Calculates the height of the view given a width.<br />
477 /// The natural size is used for default calculation.<br />
478 /// Size 0 is treated as aspect ratio 1:1.<br />
480 /// <param name="width">The width to use.</param>
481 /// <returns>The height based on the width.</returns>
482 /// <since_tizen> 3 </since_tizen>
483 public float GetHeightForWidth(float width)
485 float ret = Interop.Actor.GetHeightForWidth(SwigCPtr, width);
486 if (NDalicPINVOKE.SWIGPendingException.Pending)
487 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
492 /// Calculates the width of the view given a height.<br />
493 /// The natural size is used for default calculation.<br />
494 /// Size 0 is treated as aspect ratio 1:1.<br />
496 /// <param name="height">The height to use.</param>
497 /// <returns>The width based on the height.</returns>
498 /// <since_tizen> 3 </since_tizen>
499 public float GetWidthForHeight(float height)
501 float ret = Interop.Actor.GetWidthForHeight(SwigCPtr, height);
502 if (NDalicPINVOKE.SWIGPendingException.Pending)
503 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
508 /// Return the amount of size allocated for relayout.
510 /// <param name="dimension">The dimension to retrieve.</param>
511 /// <returns>Return the size.</returns>
512 /// <since_tizen> 3 </since_tizen>
513 public float GetRelayoutSize(DimensionType dimension)
515 float ret = Interop.Actor.GetRelayoutSize(SwigCPtr, (int)dimension);
516 if (NDalicPINVOKE.SWIGPendingException.Pending)
517 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
522 /// Set the padding for the view.
524 /// <param name="padding">Padding for the view.</param>
525 /// <since_tizen> 3 </since_tizen>
526 // [Obsolete("Deprecated in API9, will be removed in API11. Please use Padding property instead!")]
527 public void SetPadding(PaddingType padding)
529 Interop.Actor.SetPadding(SwigCPtr, PaddingType.getCPtr(padding));
530 if (NDalicPINVOKE.SWIGPendingException.Pending)
531 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
535 /// Return the value of padding for the view.
537 /// <param name="paddingOut">the value of padding for the view</param>
538 /// <since_tizen> 3 </since_tizen>
539 [Obsolete("Deprecated in API9, will be removed in API11. Please use Padding property instead!")]
540 public void GetPadding(PaddingType paddingOut)
542 Interop.Actor.GetPadding(SwigCPtr, PaddingType.getCPtr(paddingOut));
543 if (NDalicPINVOKE.SWIGPendingException.Pending)
544 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
547 /// <since_tizen> 3 </since_tizen>
548 public uint AddRenderer(Renderer renderer)
550 uint ret = Interop.Actor.AddRenderer(SwigCPtr, Renderer.getCPtr(renderer));
551 if (NDalicPINVOKE.SWIGPendingException.Pending)
552 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
556 /// <since_tizen> 3 </since_tizen>
557 public Renderer GetRendererAt(uint index)
559 //to fix memory leak issue, match the handle count with native side.
560 IntPtr cPtr = Interop.Actor.GetRendererAt(SwigCPtr, index);
561 HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
562 Renderer ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as Renderer;
563 if (cPtr != null && ret == null)
565 ret = new Renderer(cPtr, false);
566 if (NDalicPINVOKE.SWIGPendingException.Pending)
567 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
570 Interop.BaseHandle.DeleteBaseHandle(CPtr);
571 CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
573 if (NDalicPINVOKE.SWIGPendingException.Pending)
574 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
578 /// <since_tizen> 3 </since_tizen>
579 public void RemoveRenderer(Renderer renderer)
581 Interop.Actor.RemoveRenderer(SwigCPtr, Renderer.getCPtr(renderer));
582 if (NDalicPINVOKE.SWIGPendingException.Pending)
583 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
586 /// <since_tizen> 3 </since_tizen>
587 public void RemoveRenderer(uint index)
589 Interop.Actor.RemoveRenderer(SwigCPtr, index);
590 if (NDalicPINVOKE.SWIGPendingException.Pending)
591 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
594 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
595 [EditorBrowsable(EditorBrowsableState.Never)]
596 public void RotateBy(Degree angle, Vector3 axis)
598 Interop.ActorInternal.RotateByDegree(SwigCPtr, Degree.getCPtr(angle), Vector3.getCPtr(axis));
599 if (NDalicPINVOKE.SWIGPendingException.Pending)
600 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
603 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
604 [EditorBrowsable(EditorBrowsableState.Never)]
605 public void RotateBy(Radian angle, Vector3 axis)
607 Interop.ActorInternal.RotateByRadian(SwigCPtr, Radian.getCPtr(angle), Vector3.getCPtr(axis));
608 if (NDalicPINVOKE.SWIGPendingException.Pending)
609 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
612 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
613 [EditorBrowsable(EditorBrowsableState.Never)]
614 public void RotateBy(Rotation relativeRotation)
616 Interop.ActorInternal.RotateByQuaternion(SwigCPtr, Rotation.getCPtr(relativeRotation));
617 if (NDalicPINVOKE.SWIGPendingException.Pending)
618 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
622 [EditorBrowsable(EditorBrowsableState.Never)]
623 public void ScaleBy(Vector3 relativeScale)
625 Interop.ActorInternal.ScaleBy(SwigCPtr, Vector3.getCPtr(relativeScale));
626 if (NDalicPINVOKE.SWIGPendingException.Pending)
627 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
630 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
631 [EditorBrowsable(EditorBrowsableState.Never)]
632 public void SetColorMode(ColorMode colorMode)
634 Interop.ActorInternal.SetColorMode(SwigCPtr, (int)colorMode);
635 if (NDalicPINVOKE.SWIGPendingException.Pending)
636 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
639 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
640 [EditorBrowsable(EditorBrowsableState.Never)]
641 public void ObjectDump()
643 if (0 == Children.Count)
645 Type type = this.GetType();
646 PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
647 foreach (var property in properties)
649 if (null != property && property.CanRead)
651 Tizen.Log.Fatal("NUI", $"{type.Name} {property.Name} ({property.PropertyType.Name}): {property.GetValueString(this, property.PropertyType)}");
657 foreach (View view in Children)
664 /// Search through this View's hierarchy for a View with the given unique ID.
665 /// The View itself is also considered in the search.
667 /// <param name="id">The ID of the View to find</param>
668 /// <returns>A View if found or a null if not</returns>
669 [EditorBrowsable(EditorBrowsableState.Never)]
670 [Obsolete("This will be removed at API11! please use FindDescendantByID(uint id) instead!")]
671 public View FindChildByID(uint id)
673 IntPtr cPtr = Interop.Actor.FindChildById(SwigCPtr, id);
674 View ret = this.GetInstanceSafely<View>(cPtr);
675 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
680 /// Search through this View's hierarchy for a View with the given unique ID.
682 /// <param name="id">The ID of the View to find.</param>
683 /// <returns>A handle to the View if found, or an empty handle if not.</returns>
684 /// <since_tizen> 9 </since_tizen>
685 public View FindDescendantByID(uint id)
687 return FindChildById(id);
691 /// Raise view above the next sibling view.
693 /// <since_tizen> 9 </since_tizen>
696 var parentChildren = GetParent()?.Children;
698 if (parentChildren != null)
700 int currentIndex = parentChildren.IndexOf(this);
702 // If the view is not already the last item in the list.
703 if (currentIndex >= 0 && currentIndex < parentChildren.Count - 1)
705 View temp = parentChildren[currentIndex + 1];
706 parentChildren[currentIndex + 1] = this;
707 parentChildren[currentIndex] = temp;
709 Interop.NDalic.Raise(SwigCPtr);
710 if (NDalicPINVOKE.SWIGPendingException.Pending)
711 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
717 /// Lower the view below the previous sibling view.
719 /// <since_tizen> 9 </since_tizen>
722 var parentChildren = GetParent()?.Children;
724 if (parentChildren != null)
726 int currentIndex = parentChildren.IndexOf(this);
728 // If the view is not already the first item in the list.
729 if (currentIndex > 0 && currentIndex < parentChildren.Count)
731 View temp = parentChildren[currentIndex - 1];
732 parentChildren[currentIndex - 1] = this;
733 parentChildren[currentIndex] = temp;
735 Interop.NDalic.Lower(SwigCPtr);
736 if (NDalicPINVOKE.SWIGPendingException.Pending)
737 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
743 /// Raises the view to above the target view.
745 /// <remarks>The sibling order of views within the parent will be updated automatically.
746 /// Views on the level above the target view will still be shown above this view.
747 /// Once a raise or lower API is used then that view will have an exclusive sibling order independent of insertion.
749 /// <param name="target">Will be raised above this view.</param>
750 /// <since_tizen> 9 </since_tizen>
751 public void RaiseAbove(View target)
753 var parentChildren = GetParent()?.Children;
755 if (parentChildren != null)
757 int currentIndex = parentChildren.IndexOf(this);
758 int targetIndex = parentChildren.IndexOf(target);
760 if (currentIndex < 0 || targetIndex < 0 ||
761 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
763 NUILog.Error("index should be bigger than 0 and less than children of layer count");
766 // If the currentIndex is less than the target index and the target has the same parent.
767 if (currentIndex < targetIndex)
769 parentChildren.Remove(this);
770 parentChildren.Insert(targetIndex, this);
772 Interop.NDalic.RaiseAbove(SwigCPtr, View.getCPtr(target));
773 if (NDalicPINVOKE.SWIGPendingException.Pending)
774 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
781 /// Lowers the view to below the target view.
783 /// <remarks>The sibling order of views within the parent will be updated automatically.
784 /// Once a raise or lower API is used then that view will have an exclusive sibling order independent of insertion.
786 /// <param name="target">Will be lowered below this view.</param>
787 /// <since_tizen> 9 </since_tizen>
788 public void LowerBelow(View target)
790 var parentChildren = GetParent()?.Children;
792 if (parentChildren != null)
794 int currentIndex = parentChildren.IndexOf(this);
795 int targetIndex = parentChildren.IndexOf(target);
796 if (currentIndex < 0 || targetIndex < 0 ||
797 currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
799 NUILog.Error("index should be bigger than 0 and less than children of layer count");
803 // If the currentIndex is not already the 0th index and the target has the same parent.
804 if ((currentIndex != 0) && (targetIndex != -1) &&
805 (currentIndex > targetIndex))
807 parentChildren.Remove(this);
808 parentChildren.Insert(targetIndex, this);
810 Interop.NDalic.LowerBelow(SwigCPtr, View.getCPtr(target));
811 if (NDalicPINVOKE.SWIGPendingException.Pending)
812 throw NDalicPINVOKE.SWIGPendingException.Retrieve();