Skip to content

Commit

Permalink
[NUI] Add CreateDefaultLayout function
Browse files Browse the repository at this point in the history
Signed-off-by: huiyu.eun <[email protected]>
  • Loading branch information
huiyueun authored and dongsug-song committed Sep 27, 2021
1 parent b0d4ad5 commit f619f5a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 38 deletions.
13 changes: 5 additions & 8 deletions src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,6 @@ internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = tru
}
}

/// <summary>
/// Create internal layout of ImageView
/// </summary>
internal static LayoutItem CreateImageLayout()
{
return new ImageLayout();
}

[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void ResourceReadyEventCallbackType(IntPtr data);
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
Expand Down Expand Up @@ -730,6 +722,11 @@ internal FittingModeType ConvertVisualFittingModetoFittingMode(VisualFittingMode
}
}

internal override LayoutItem CreateDefaultLayout()
{
return new ImageLayout();
}

/// <summary>
/// Gets or sets fitting options used when resizing images to fit.<br />
/// If not supplied, the default is FittingModeType.Fill.<br />
Expand Down
13 changes: 5 additions & 8 deletions src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,6 @@ internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = tru
}
}

/// <summary>
/// Create internal layout of TextLabel
/// </summary>
internal LayoutItem CreateTextLayout()
{
return new TextLayout();
}

/// <summary>
/// The TranslatableText property.<br />
/// The text can set the SID value.<br />
Expand Down Expand Up @@ -1328,6 +1320,11 @@ protected override ViewStyle CreateViewStyle()
return new TextLabelStyle();
}

internal override LayoutItem CreateDefaultLayout()
{
return new TextLayout();
}

/// <summary>
/// Invoked whenever the binding context of the textlabel changes. Implement this method to add class handling for this event.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ internal MergedStyle MergedStyle
return mergedStyle;
}
}
internal virtual LayoutItem CreateDefaultLayout()
{
return new AbsoluteLayout();
}

internal class ThemeData
{
Expand Down
29 changes: 7 additions & 22 deletions src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,40 +168,29 @@ public void ChangeLayoutSiblingOrder(int order)
// Attaches to View ChildAdded signal so called when a View is added to a view.
private void AddChildToLayoutGroup(View child)
{
if (View.LayoutingDisabled)
{
return;
}
// Only give children a layout if their parent is an explicit container or a pure View.
// Pure View meaning not derived from a View, e.g a Legacy container.
// layoutSet flag is true when the View became a layout using the set Layout API opposed to automatically due to it's parent.
// First time the set Layout API is used by any View the Window no longer has layoutingDisabled.

// If child already has a Layout then don't change it.
if (!View.LayoutingDisabled && (null == child.Layout))
if (null == child.Layout)
{
// Only wrap View with a Layout if a child a pure View or Layout explicitly set on this Layout
if ((true == Owner.LayoutSet || GetType() == typeof(View)))
{
// If child of this layout is a pure View then assign it a LayoutGroup
// If the child is derived from a View then it may be a legacy or existing container hence will do layouting itself.
if (child is TextLabel textLabel)
{
child.Layout = textLabel.CreateTextLayout();
}
else if (child is ImageView imageView)
{
child.Layout = ImageView.CreateImageLayout();
}
else
{
child.Layout = new AbsoluteLayout();
}
child.Layout = child.CreateDefaultLayout();
}
}
else
{
// Add child layout to this LayoutGroup (Setting parent in the process)
if (child.Layout != null)
{
Add(child.Layout);
}
Add(child.Layout);
}
// Parent transitions are not attached to children.
}
Expand Down Expand Up @@ -500,10 +489,6 @@ protected override void OnAttachedToOwner()
// Layout takes ownership of it's owner's children.
foreach (View view in Owner.Children)
{
if (view is TextLabel)
{
view.Layout = (view as TextLabel)?.CreateTextLayout();
}
AddChildToLayoutGroup(view);
}

Expand Down

0 comments on commit f619f5a

Please sign in to comment.