Previously, Layouts in the default Window were supported.
Now, Layouts in all Windows are supported.
To enable Multi-Window, Window.IsSupportedMultiWindow() should be true
and the following code should not be executed.
Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
private float windowHeight;
private LayoutTransitionManager transitionManager;
- private bool subscribed;
+ private int layoutCount = 0;
/// <summary>
/// Constructs a LayoutController which controls the measuring and layouting.<br />
return;
}
- if (subscribed)
- {
- ProcessorController.Instance.LayoutProcessorEvent -= Process;
- subscribed = false;
- }
+ LayoutCount = 0;
//Release your own unmanaged resources here.
//You should not access any managed member here except static instance.
}
/// <summary>
- /// Create and set process callback
- /// </summary>
- internal void CreateProcessCallback()
- {
- if (!subscribed)
- {
- ProcessorController.Instance.LayoutProcessorEvent += Process;
- subscribed = true;
- }
- }
-
- /// <summary>
/// Add transition data for a LayoutItem to the transition stack.
/// </summary>
/// <param name="transitionDataEntry">Transition data for a LayoutItem.</param>
transitionManager.AddToRemovalStack(itemToRemove);
}
+ /// <summary>
+ /// The number of layouts.
+ /// This can be used to set/unset Process callback to calculate Layout.
+ /// </summary>
+ internal int LayoutCount
+ {
+ get
+ {
+ return layoutCount;
+ }
+
+ set
+ {
+ if (layoutCount == value) return;
+
+ if (value < 0) throw new global::System.ArgumentOutOfRangeException(nameof(LayoutCount), "LayoutCount(" + LayoutCount + ") should not be less than zero");
+
+ if (layoutCount == 0)
+ {
+ ProcessorController.Instance.LayoutProcessorEvent += Process;
+ }
+ else if (value == 0)
+ {
+ ProcessorController.Instance.LayoutProcessorEvent -= Process;
+ }
+
+ layoutCount = value;
+ }
+ }
+
// Traverse the tree looking for a root node that is a layout.
// Once found, it's children can be assigned Layouts and the Measure process started.
private void FindRootLayouts(View rootNode, float parentWidth, float parentHeight)
private Vector3 internalScale = null;
private Size internalSize = null;
private Size2D internalSize2D = null;
+ private int layoutCount = 0;
static View()
{
internal void SetLayout(LayoutItem layout)
{
- Window.Instance.LayoutController.CreateProcessCallback();
+ LayoutCount++;
+
this.layout = layout;
this.layout?.AttachToOwner(this);
this.layout?.RequestLayout();
}
/// <summary>
+ /// The number of layouts including view's layout and children's layouts.
+ /// This can be used to set/unset Process callback to calculate Layout.
+ /// </summary>
+ internal int LayoutCount
+ {
+ get
+ {
+ return layoutCount;
+ }
+
+ set
+ {
+ if (layoutCount == value) return;
+
+ if (value < 0) throw new global::System.ArgumentOutOfRangeException(nameof(LayoutCount), "LayoutCount(" + LayoutCount + ") should not be less than zero");
+
+ int diff = value - layoutCount;
+ layoutCount = value;
+
+ if (InternalParent != null)
+ {
+ var parentView = InternalParent as View;
+ if (parentView != null)
+ {
+ parentView.LayoutCount += diff;
+ }
+ else
+ {
+ var parentLayer = InternalParent as Layer;
+ if (parentLayer != null)
+ {
+ parentLayer.LayoutCount += diff;
+ }
+ }
+ }
+ }
+ }
+
+ /// <summary>
/// Indicates that this View should listen Touch event to handle its ControlState.
/// </summary>
private bool enableControlState = false;
Children.Remove(child);
child.InternalParent = null;
+ LayoutCount -= child.LayoutCount;
RemoveChildBindableObject(child);
/// </summary>
internal void ResetLayout()
{
+ LayoutCount--;
+
layout = null;
}
view.InternalParent = null;
}
+ LayoutCount = 0;
+
NUILog.Debug($"[Dispose] View.Dispose({type}) END");
NUILog.Debug($"=============================");
oldParent.Remove(child);
}
child.InternalParent = this;
+ LayoutCount += child.LayoutCount;
Interop.Actor.Add(SwigCPtr, View.getCPtr(child));
{
private Window window;
+ private int layoutCount = 0;
+
/// <summary>
/// Creates a Layer object.
/// </summary>
}
/// <summary>
+ /// Dispose Explicit or Implicit
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void Dispose(DisposeTypes type)
+ {
+ if (Disposed)
+ {
+ return;
+ }
+
+ LayoutCount = 0;
+
+ base.Dispose(type);
+ }
+
+ /// <summary>
/// Enumeration for the behavior of the layer.
/// </summary>
/// <since_tizen> 3 </since_tizen>
{
child.InternalParent = this;
}
+
+ LayoutCount += child.LayoutCount;
+
Interop.Actor.Add(SwigCPtr, View.getCPtr(child));
if (NDalicPINVOKE.SWIGPendingException.Pending)
throw NDalicPINVOKE.SWIGPendingException.Retrieve();
Children.Remove(child);
child.InternalParent = null;
+
+ LayoutCount -= child.LayoutCount;
}
/// <summary>
internal void SetWindow(Window win)
{
+ if (window == win) return;
+
+ if (window != null)
+ {
+ window.LayoutController.LayoutCount -= LayoutCount;
+ }
+
window = win;
+
+ if (window != null)
+ {
+ window.LayoutController.LayoutCount += LayoutCount;
+ }
}
internal uint GetId()
return ret;
}
+ /// <summary>
+ /// The number of layouts of children views.
+ /// This can be used to set/unset Process callback to calculate Layout.
+ /// </summary>
+ internal int LayoutCount
+ {
+ get
+ {
+ return layoutCount;
+ }
+
+ set
+ {
+ if (layoutCount == value) return;
+
+ if (value < 0) throw new global::System.ArgumentOutOfRangeException(nameof(LayoutCount), "LayoutCount(" + LayoutCount + ") should not be less than zero");
+
+ int diff = value - layoutCount;
+ layoutCount = value;
+
+ if (window != null)
+ {
+ window.LayoutController.LayoutCount += diff;
+ }
+ }
+ }
+
/// This will not be public opened.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
if (null != view)
{
view.InternalParent = this.GetRootLayer();
+
+ this.GetRootLayer().LayoutCount += view.LayoutCount;
}
}
if (null != view)
{
view.InternalParent = null;
+
+ this.GetRootLayer().LayoutCount -= view.LayoutCount;
}
}
--- /dev/null
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace Tizen.NUI.Samples
+{
+ public class MultiWindowLayoutSample : IExample
+ {
+ private Window mainWindow = null;
+ private Window subWindow = null;
+ private View mainView = null;
+ private View subView = null;
+
+ public void Activate()
+ {
+ mainWindow = NUIApplication.GetDefaultWindow();
+
+ mainView = new View()
+ {
+ Layout = new LinearLayout(),
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ BackgroundColor = Color.White
+ };
+ mainWindow.Add(mainView);
+
+ var mainChild = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ BackgroundColor = Color.Red
+ };
+ mainView.Add(mainChild);
+
+ var mainChild2 = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ BackgroundColor = Color.Yellow
+ };
+ mainView.Add(mainChild2);
+
+ subWindow = new Window();
+
+ subView = new View()
+ {
+ Layout = new LinearLayout(),
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ BackgroundColor = Color.White
+ };
+ subWindow.Add(subView);
+
+ var subChild = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ BackgroundColor = Color.Green
+ };
+ subView.Add(subChild);
+
+ var subChild2 = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ BackgroundColor = Color.Blue
+ };
+ subView.Add(subChild2);
+ }
+
+ public void Deactivate()
+ {
+ if (subWindow != null)
+ {
+ if (subView != null)
+ {
+ subWindow.Remove(subView);
+ subView.Dispose();
+ subView = null;
+ }
+
+ subWindow.Dispose();
+ subWindow = null;
+ }
+
+ if (mainWindow != null)
+ {
+ if (mainView != null)
+ {
+ mainWindow.Remove(mainView);
+ mainView.Dispose();
+ mainView = null;
+ }
+
+ mainWindow = null;
+ }
+ }
+ }
+}