diff --git a/src/Tizen.NUI/src/public/Layouting/AbsoluteLayout.cs b/src/Tizen.NUI/src/public/Layouting/AbsoluteLayout.cs index 2ab9b409683..d30f9e74da6 100755 --- a/src/Tizen.NUI/src/public/Layouting/AbsoluteLayout.cs +++ b/src/Tizen.NUI/src/public/Layouting/AbsoluteLayout.cs @@ -1,4 +1,4 @@ -/* Copyright (c) 2021 Samsung Electronics Co., Ltd. +/* Copyright (c) 2019-2025 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,6 +13,10 @@ * limitations under the License. * */ +using System; +using System.ComponentModel; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Binding; namespace Tizen.NUI { @@ -30,6 +34,117 @@ public AbsoluteLayout() { } + /// + /// LayoutBoundsXProperty + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty LayoutBoundsXProperty = BindableProperty.CreateAttached("LayoutBoundsX", typeof(float), typeof(AbsoluteLayout), float.NaN, propertyChanged: OnChildPropertyChanged); + + /// + /// LayoutBoundsYProperty + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty LayoutBoundsYProperty = BindableProperty.CreateAttached("LayoutBoundsY", typeof(float), typeof(AbsoluteLayout), float.NaN, propertyChanged: OnChildPropertyChanged); + + /// + /// LayoutBoundsWidthProperty + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty LayoutBoundsWidthProperty = BindableProperty.CreateAttached("LayoutBoundsWidth", typeof(float), typeof(AbsoluteLayout), float.NaN, propertyChanged: OnChildPropertyChanged); + + /// + /// LayoutBoundsHeightProperty + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty LayoutBoundsHeightProperty = BindableProperty.CreateAttached("LayoutBoundsHeight", typeof(float), typeof(AbsoluteLayout), float.NaN, propertyChanged: OnChildPropertyChanged); + + /// + /// LayoutFlagsProperty + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty LayoutFlagsProperty = BindableProperty.CreateAttached("LayoutFlags", typeof(AbsoluteLayoutFlags), typeof(AbsoluteLayout), default(AbsoluteLayoutFlags), validateValue: ValidateEnum((int)AbsoluteLayoutFlags.None, (int)AbsoluteLayoutFlags.All), propertyChanged: OnChildPropertyChanged); + + /// + /// Gets the layout bounds x of the child view. The default layout bounds x is float.NaN. + /// + /// The child view. + /// The layout bounds x of . + /// The cannot be null. + public static float GetLayoutBoundsX(View view) => GetAttachedValue(view, LayoutBoundsXProperty); + + /// + /// Sets the layout bounds x of the child view. The default layout bounds x is float.NaN. + /// + /// The child view. + /// The layout bounds x of . + /// The cannot be null. + public static void SetLayoutBoundsX(View view, float value) => SetAttachedValue(view, LayoutBoundsXProperty, value); + + /// + /// Gets the layout bounds y of the child view. The default layout bounds y is float.NaN. + /// + /// The child view. + /// The layout bounds y of . + /// The cannot be null. + public static float GetLayoutBoundsY(View view) => GetAttachedValue(view, LayoutBoundsYProperty); + + /// + /// Sets the layout bounds y of the child view. The default layout bounds y is float.NaN. + /// + /// The child view. + /// The layout bounds y of . + /// The cannot be null. + public static void SetLayoutBoundsY(View view, float value) => SetAttachedValue(view, LayoutBoundsYProperty, value); + + /// + /// Gets the layout bounds width of the child view. The default layout bounds width is float.NaN. + /// + /// The child view. + /// The layout bounds width of . + /// The cannot be null. + public static float GetLayoutBoundsWidth(View view) => GetAttachedValue(view, LayoutBoundsWidthProperty); + + /// + /// Sets the layout bounds width of the child view. The default layout bounds width is float.NaN. + /// + /// The child view. + /// The layout bounds width of . + /// The cannot be null. + public static void SetLayoutBoundsWidth(View view, float value) => SetAttachedValue(view, LayoutBoundsWidthProperty, value); + + /// + /// Gets the layout bounds height of the child view. The default layout bounds height is float.NaN. + /// + /// The child view. + /// The layout bounds height of . + /// The cannot be null. + public static float GetLayoutBoundsHeight(View view) => GetAttachedValue(view, LayoutBoundsHeightProperty); + + /// + /// Sets the layout bounds height of the child view. The default layout bounds height is float.NaN. + /// + /// The child view. + /// The layout bounds height of . + /// The cannot be null. + public static void SetLayoutBoundsHeight(View view, float value) => SetAttachedValue(view, LayoutBoundsHeightProperty, value); + + /// + /// Gets the absolute layout flags of the child view. The default absolute layout flags is . + /// + /// The child view. + /// The absolute layout flags of . + /// The cannot be null. + public static AbsoluteLayoutFlags GetLayoutFlags(View view) => GetAttachedValue(view, LayoutFlagsProperty); + + /// + /// Sets the absolute layout flags of the child view. The default absolute layout flags is . + /// + /// The child view. + /// The absolute layout flags of . + /// The cannot be null. + /// The should be . + public static void SetLayoutFlags(View view, AbsoluteLayoutFlags value) => SetAttachedValue(view, LayoutFlagsProperty, value); + /// /// Measure the layout and its content to determine the measured width and the measured height.
///
@@ -52,6 +167,17 @@ protected override void OnMeasure(MeasureSpecification widthMeasureSpec, Measure continue; } + // var boundsX = GetLayoutBoundsX(childLayout.Owner); + // var boundsY = GetLayoutBoundsY(childLayout.Owner); + // var boundsWidth = GetLayoutBoundsWidth(childLayout.Owner); + // var boundsHeight = GetLayoutBoundsHeight(childLayout.Owner); + // var flags = GetLayoutFlags(childLayout.Owner); + // bool isWidthProportional = flags.HasFlag(AbsoluteLayoutFlags.WidthProportional); + // bool isHeightProportional = flags.HasFlag(AbsoluteLayoutFlags.HeightProportional); + + // var measureWidth = ResolveChildMeasureConstraint(boundsWidth, isWidthProportional, widthMeasureSpec.GetSize().AsDecimal()); + // var measureHeight = ResolveChildMeasureConstraint(boundsHeight, isHeightProportional, heightMeasureSpec.GetSize().AsDecimal()); + // Get size of child with no padding, no margin. we won't support margin, padding for AbsolutLayout. MeasureChildWithoutPadding(childLayout, widthMeasureSpec, heightMeasureSpec); @@ -109,5 +235,21 @@ protected override void OnLayout(bool changed, LayoutLength left, LayoutLength t childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight, true); } } + + static float ResolveChildMeasureConstraint(float boundsValue, bool proportional, float constraint) + { + if (boundsValue < 0) + { + // If the child view doesn't have bounds set by the AbsoluteLayout, then we'll let it auto-size + return float.PositiveInfinity; + } + + if (proportional) + { + return boundsValue * constraint; + } + + return boundsValue; + } } } // namespace diff --git a/src/Tizen.NUI/src/public/Layouting/AbsoluteLayoutFlags.cs b/src/Tizen.NUI/src/public/Layouting/AbsoluteLayoutFlags.cs new file mode 100755 index 00000000000..6eeea1fe5f8 --- /dev/null +++ b/src/Tizen.NUI/src/public/Layouting/AbsoluteLayoutFlags.cs @@ -0,0 +1,66 @@ +/* Copyright (c) 2025 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +using System; + +namespace Tizen.NUI +{ + /// + /// Enumeration for AbsoluteLayoutFlags. + /// + [Flags] + public enum AbsoluteLayoutFlags + { + /// + /// No flags set. + /// + None = 0, + + /// + /// Indicates that the X position of the child element should be proportional to its parent. + /// + XProportional = 1 << 0, + + /// + /// Indicates that the Y position of the child element should be proportional to its parent. + /// + YProportional = 1 << 1, + + /// + /// Indicates that the width of the child element should be proportional to its parent. + /// + WidthProportional = 1 << 2, + + /// + /// Indicates that the height of the child element should be proportional to its parent. + /// + HeightProportional = 1 << 3, + + /// + /// Indicates that both the X and Y positions of the child element should be proportional to its parent. + /// + PositionProportional = 1 | 1 << 1, + + /// + /// Indicates that both the width and height of the child element should be proportional to its parent. + /// + SizeProportional = 1 << 2 | 1 << 3, + + /// + /// Indicates that all properties of the child element should be proportional to its parent. + /// + All = ~0 + } +} \ No newline at end of file