/// <since_tizen> 4 </since_tizen>
public override void Add(View child)
{
- NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child));
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
- Children.Add(child);
+ Container oldParent = child.GetParent();
+ if(oldParent != this)
+ {
+ if (oldParent != null)
+ {
+ oldParent.Remove(child);
+ }
+ NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child));
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ Children.Add(child);
+ }
}
/// <summary>
/// Sets the sibling order of the view so the depth position can be defined within the same parent.
/// </summary>
/// <remarks>
- /// Note the initial value is 0.
+ /// Note the initial value is 0. SiblingOrder should be bigger than 0 or equal to 0.
/// Raise, Lower, RaiseToTop, LowerToBottom, RaiseAbove, and LowerBelow will override the sibling order.
/// The values set by this property will likely change.
/// </remarks>
{
get
{
- var parentChildren = Parent?.Children;
+ var parentChildren = GetParent()?.Children;
int currentOrder = 0;
if (parentChildren != null)
{
}
set
{
- SetProperty(View.Property.SIBLING_ORDER, new Tizen.NUI.PropertyValue(value));
+ if(value < 0)
+ {
+ NUILog.Error("SiblingOrder should be bigger than 0 or equal to 0.");
+ return;
+ }
+ var siblings = GetParent()?.Children;
+ if (siblings != null)
+ {
+ int currentOrder = siblings.IndexOf(this);
+ if (value != currentOrder)
+ {
+ if (value == 0)
+ {
+ LowerToBottom();
+ }
+ else if (value < siblings.Count - 1)
+ {
+ if (value > currentOrder)
+ {
+ RaiseAbove(siblings[value]);
+ }
+ else
+ {
+ LowerBelow(siblings[value]);
+ }
+ }
+ else
+ {
+ RaiseToTop();
+ }
+ }
+ }
}
}
internal void Raise()
{
- var parentChildren = Parent?.Children;
+ var parentChildren = GetParent()?.Children;
if (parentChildren != null)
{
int currentIndex = parentChildren.IndexOf(this);
// If the view is not already the last item in the list.
- if (currentIndex != parentChildren.Count -1)
+ if (currentIndex >= 0 && currentIndex < parentChildren.Count -1)
{
View temp = parentChildren[currentIndex + 1];
parentChildren[currentIndex + 1] = this;
parentChildren[currentIndex] = temp;
+
+ NDalicPINVOKE.Raise(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}
- NDalicPINVOKE.Raise(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal void Lower()
{
- var parentChildren = Parent?.Children;
+ var parentChildren = GetParent()?.Children;
if (parentChildren != null)
{
int currentIndex = parentChildren.IndexOf(this);
// If the view is not already the first item in the list.
- if (currentIndex > 0)
+ if (currentIndex > 0 && currentIndex < parentChildren.Count)
{
View temp = parentChildren[currentIndex - 1];
parentChildren[currentIndex - 1] = this;
parentChildren[currentIndex] = temp;
+
+ NDalicPINVOKE.Lower(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}
-
- NDalicPINVOKE.Lower(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
/// <summary>
/// <since_tizen> 3 </since_tizen>
public void RaiseToTop()
{
- var parentChildren = Parent?.Children;
+ var parentChildren = GetParent()?.Children;
if (parentChildren != null)
{
parentChildren.Remove(this);
parentChildren.Add(this);
+
+ NDalicPINVOKE.RaiseToTop(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
- NDalicPINVOKE.RaiseToTop(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
/// <summary>
/// <since_tizen> 3 </since_tizen>
public void LowerToBottom()
{
- var parentChildren = Parent?.Children;
+ var parentChildren = GetParent()?.Children;
if (parentChildren != null)
{
parentChildren.Remove(this);
parentChildren.Insert(0, this);
- }
- NDalicPINVOKE.LowerToBottom(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ NDalicPINVOKE.LowerToBottom(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
}
/// <summary>
/// <param name="target">Will be raised above this view.</param>
internal void RaiseAbove(View target)
{
- var parentChildren = Parent?.Children;
+ var parentChildren = GetParent()?.Children;
if (parentChildren != null)
{
int currentIndex = parentChildren.IndexOf(this);
int targetIndex = parentChildren.IndexOf(target);
+ if(currentIndex < 0 || targetIndex < 0 ||
+ currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
+ {
+ NUILog.Error("index should be bigger than 0 and less than children of layer count");
+ return;
+ }
// If the currentIndex is less than the target index and the target has the same parent.
if (currentIndex < targetIndex)
{
parentChildren.Remove(this);
parentChildren.Insert(targetIndex, this);
+
+ NDalicPINVOKE.RaiseAbove(swigCPtr, View.getCPtr(target));
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}
- NDalicPINVOKE.RaiseAbove(swigCPtr, View.getCPtr(target));
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
/// <summary>
/// <param name="target">Will be lowered below this view.</param>
internal void LowerBelow(View target)
{
- var parentChildren = Parent?.Children;
+ var parentChildren = GetParent()?.Children;
if (parentChildren != null)
{
int currentIndex = parentChildren.IndexOf(this);
int targetIndex = parentChildren.IndexOf(target);
+ if(currentIndex < 0 || targetIndex < 0 ||
+ currentIndex >= parentChildren.Count ||targetIndex >= parentChildren.Count)
+ {
+ NUILog.Error("index should be bigger than 0 and less than children of layer count");
+ return;
+ }
// If the currentIndex is not already the 0th index and the target has the same parent.
if ((currentIndex != 0) && (targetIndex != -1) &&
{
parentChildren.Remove(this);
parentChildren.Insert(targetIndex, this);
+
+ NDalicPINVOKE.LowerBelow(swigCPtr, View.getCPtr(target));
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}
- NDalicPINVOKE.LowerBelow(swigCPtr, View.getCPtr(target));
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal string GetName()
/// <since_tizen> 4 </since_tizen>
public override void Add(View child)
{
- NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child));
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
- Children.Add(child);
+ Container oldParent = child.GetParent();
+ if (oldParent != this)
+ {
+ if (oldParent != null)
+ {
+ oldParent.Remove(child);
+ }
+ NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child));
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ Children.Add(child);
+ }
}
/// <summary>
{
int currentIdx = parentChildren.IndexOf(this);
- if (currentIdx != parentChildren.Count - 1)
+ if (currentIdx >= 0 && currentIdx < parentChildren.Count - 1)
{
RaiseAbove(parentChildren[currentIdx + 1]);
Layer temp = parentChildren[currentIdx + 1];
parentChildren[currentIdx + 1] = this;
parentChildren[currentIdx] = temp;
+
+ NDalicPINVOKE.Layer_Raise(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}
}
{
int currentIdx = parentChildren.IndexOf(this);
- if (currentIdx > 0)
+ if (currentIdx > 0 && currentIdx < parentChildren.Count)
{
LowerBelow(parentChildren[currentIdx - 1]);
parentChildren[currentIdx - 1] = this;
parentChildren[currentIdx] = temp;
+ NDalicPINVOKE.Layer_Lower(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}
}
internal void RaiseAbove(Layer target)
{
- NDalicPINVOKE.Layer_RaiseAbove(swigCPtr, Layer.getCPtr(target));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ var parentChildren = Window.Instance.LayersChildren;
+ if (parentChildren != null)
+ {
+ int currentIndex = parentChildren.IndexOf(this);
+ int targetIndex = parentChildren.IndexOf(target);
+
+ if(currentIndex < 0 || targetIndex < 0 ||
+ currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
+ {
+ NUILog.Error("index should be bigger than 0 and less than children of layer count");
+ return;
+ }
+
+ // If the currentIndex is less than the target index and the target has the same parent.
+ if (currentIndex < targetIndex)
+ {
+ parentChildren.Remove(this);
+ parentChildren.Insert(targetIndex, this);
+
+ NDalicPINVOKE.Layer_RaiseAbove(swigCPtr, Layer.getCPtr(target));
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ }
}
internal void LowerBelow(Layer target)
{
- NDalicPINVOKE.Layer_LowerBelow(swigCPtr, Layer.getCPtr(target));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ var parentChildren = Window.Instance.LayersChildren;
+
+ if (parentChildren != null)
+ {
+ int currentIndex = parentChildren.IndexOf(this);
+ int targetIndex = parentChildren.IndexOf(target);
+
+ if(currentIndex < 0 || targetIndex < 0 ||
+ currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count)
+ {
+ NUILog.Error("index should be bigger than 0 and less than children of layer count");
+ return;
+ }
+
+ // If the currentIndex is not already the 0th index and the target has the same parent.
+ if ((currentIndex != 0) && (targetIndex != -1) &&
+ (currentIndex > targetIndex))
+ {
+ parentChildren.Remove(this);
+ parentChildren.Insert(targetIndex, this);
+
+ NDalicPINVOKE.Layer_LowerBelow(swigCPtr, Layer.getCPtr(target));
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ }
}
/// <summary>
{
parentChildren.Remove(this);
parentChildren.Add(this);
+
+ NDalicPINVOKE.Layer_RaiseToTop(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
- NDalicPINVOKE.Layer_RaiseToTop(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
/// <summary>
{
parentChildren.Remove(this);
parentChildren.Insert(0, this);
+
+ NDalicPINVOKE.Layer_LowerToBottom(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
- NDalicPINVOKE.Layer_LowerToBottom(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
/// <summary>