/// <summary> /// Measure the layout and its content to determine the measured width and the measured height.<br /> /// If this method is overridden, it is the subclass's responsibility to make /// sure the measured height and width are at least the layout's minimum height /// and width. <br /> /// </summary> /// <param name="widthMeasureSpec">horizontal space requirements as imposed by the parent.</param> /// <param name="heightMeasureSpec">vertical space requirements as imposed by the parent.</param> protected override void OnMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec) { Log.Info("NUI", "OnMeasure\n"); LayoutLength childWidth = new LayoutLength(0); LayoutLength childHeight = new LayoutLength(0); LayoutLength measuredWidth = childWidth; LayoutLength measuredHeight = childHeight; for (uint i = 0; i < ChildCount; ++i) { var childLayout = GetChildAt(i); if (childLayout) { MeasureChild(childLayout, widthMeasureSpec, heightMeasureSpec); childWidth = childLayout.MeasuredWidth; childHeight = childLayout.MeasuredHeight; // Layout takes size of largest width and height dimension of children measuredWidth.Value = System.Math.Max(measuredWidth.Value, childWidth.Value); measuredHeight.Value = System.Math.Max(measuredHeight.Value, childHeight.Value); } } if (0 == ChildCount) { // Must be a leaf as has no children measuredWidth = GetDefaultSize(SuggestedMinimumWidth, widthMeasureSpec); measuredHeight = GetDefaultSize(SuggestedMinimumHeight, heightMeasureSpec); } SetMeasuredDimensions(new MeasuredSize(measuredWidth), new MeasuredSize(measuredHeight)); }
public void Measure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec) { LayoutPINVOKE.LayoutItemPtr_Measure(swigCPtr, LayoutMeasureSpec.getCPtr(widthMeasureSpec), LayoutMeasureSpec.getCPtr(heightMeasureSpec)); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } }
/// <summary> /// [Draft] Adjust the measure size by the given delta. Used only for EXACT and AT_MOST modes. /// if the adjusted size is negative, it is zeroed. /// </summary> /// <param name="measureSpec">the measure spec to adjust</param> /// <param name="delta">A positive or negative value to adjust the measure spec by.</param> /// <returns>A new measure spec with the adjusted values.</returns> public static LayoutMeasureSpec Adjust(LayoutMeasureSpec measureSpec, int delta) { LayoutMeasureSpec ret = new LayoutMeasureSpec(LayoutPINVOKE.MeasureSpec_Adjust(LayoutMeasureSpec.getCPtr(measureSpec), delta), true); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
private bool EqualTo(LayoutMeasureSpec value) { bool ret = LayoutPINVOKE.MeasureSpec_EqualTo(swigCPtr, LayoutMeasureSpec.getCPtr(value)); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public LayoutLength GetDefaultSize(LayoutLength size, LayoutMeasureSpec measureSpec) { LayoutLength ret = new LayoutLength(LayoutPINVOKE.LayoutItemPtr_GetDefaultSize(swigCPtr, LayoutLength.getCPtr(size), LayoutMeasureSpec.getCPtr(measureSpec)), true); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
/// <summary> /// Determines whether the specified object is equal to the current object. /// </summary> /// <param name="obj">The object to compare with the current object.</param> /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns> public override bool Equals(object obj) { LayoutMeasureSpec layoutMeasureSpec = obj as LayoutMeasureSpec; bool equal = false; if (Size == layoutMeasureSpec?.Size && Mode == layoutMeasureSpec?.Mode) { equal = true; } return(equal); }
/// <summary> /// Ask one of the children of this view to measure itself, taking into /// account both the MeasureSpec requirements for this view and its padding.<br /> /// and margins. The child must have MarginLayoutParams The heavy lifting is /// done in GetChildMeasureSpec.<br /> /// </summary> /// <param name="child">The child to measure.</param> /// <param name="parentWidthMeasureSpec">The width requirements for this view.</param> /// <param name="widthUsed">Extra space that has been used up by the parent horizontally (possibly by other children of the parent).</param> /// <param name="parentHeightMeasureSpec">The height requirements for this view.</param> /// <param name="heightUsed">Extra space that has been used up by the parent vertically (possibly by other children of the parent).</param> protected virtual void MeasureChildWithMargins(LayoutItem child, LayoutMeasureSpec parentWidthMeasureSpec, LayoutLength widthUsed, LayoutMeasureSpec parentHeightMeasureSpec, LayoutLength heightUsed) { layoutGroupWrapperImpl.MeasureChildWithMarginsNative(child, parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed); }
/// <summary> /// Ask one of the children of this view to measure itself, taking into /// account both the MeasureSpec requirements for this view and its padding.<br /> /// The heavy lifting is done in GetChildMeasureSpec.<br /> /// </summary> /// <param name="child">The child to measure.</param> /// <param name="parentWidthMeasureSpec">The width requirements for this view.</param> /// <param name="parentHeightMeasureSpec">The height requirements for this view.</param> protected virtual void MeasureChild(LayoutItem child, LayoutMeasureSpec parentWidthMeasureSpec, LayoutMeasureSpec parentHeightMeasureSpec) { layoutGroupWrapperImpl.MeasureChildNative(child, parentWidthMeasureSpec, parentHeightMeasureSpec); }
/// <summary> /// Ask all of the children of this view to measure themselves, taking into /// account both the MeasureSpec requirements for this view and its padding.<br /> /// The heavy lifting is done in GetChildMeasureSpec.<br /> /// </summary> /// <param name="widthMeasureSpec">The width requirements for this view.</param> /// <param name="heightMeasureSpec">The height requirements for this view.</param> protected virtual void MeasureChildren(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec) { layoutGroupWrapperImpl.MeasureChildrenNative(widthMeasureSpec, heightMeasureSpec); }
internal void OnMeasureNative(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec) { LayoutPINVOKE.LayoutItemWrapperImpl_OnMeasureSwigExplicitLayoutItemWrapperImpl(swigCPtr, LayoutMeasureSpec.getCPtr(widthMeasureSpec), LayoutMeasureSpec.getCPtr(heightMeasureSpec)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); }
internal static LayoutLength GetDefaultSize(LayoutLength size, LayoutMeasureSpec measureSpec) { LayoutLength ret = new LayoutLength(LayoutPINVOKE.LayoutItemWrapperImpl_GetDefaultSize(LayoutLength.getCPtr(size), LayoutMeasureSpec.getCPtr(measureSpec)), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; }
internal void MeasureChildWithMarginsNative(LayoutItem child, LayoutMeasureSpec parentWidthMeasureSpec, LayoutLength widthUsed, LayoutMeasureSpec parentHeightMeasureSpec, LayoutLength heightUsed) { LayoutPINVOKE.LayoutGroupWrapperImpl_MeasureChildWithMarginsSwigExplicitLayoutGroupWrapperImpl(swigCPtr, LayoutItem.getCPtr(child), LayoutMeasureSpec.getCPtr(parentWidthMeasureSpec), LayoutLength.getCPtr(widthUsed), LayoutMeasureSpec.getCPtr(parentHeightMeasureSpec), LayoutLength.getCPtr(heightUsed)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); }
internal virtual void MeasureChildrenNative(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec) { LayoutPINVOKE.LayoutGroupWrapperImpl_MeasureChildrenSwigExplicitLayoutGroupWrapperImpl(swigCPtr, LayoutMeasureSpec.getCPtr(widthMeasureSpec), LayoutMeasureSpec.getCPtr(heightMeasureSpec)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); }
/// <summary> /// Utility to return a default size.<br /> /// Uses the supplied size if the MeasureSpec imposed no constraints. Will get larger if allowed by the /// MeasureSpec.<br /> /// </summary> /// <param name="size"> Default size for this layout.</param> /// <param name="measureSpec"> Constraints imposed by the parent.</param> /// <returns>The size this layout should be.</returns> public static LayoutLength GetDefaultSize(LayoutLength size, LayoutMeasureSpec measureSpec) { return(LayoutItemWrapperImpl.GetDefaultSize(size, measureSpec)); }
/// <summary> /// This is called to find out how big a layout should be. <br /> /// The parent supplies constraint information in the width and height parameters. <br /> /// The actual measurement work of a layout is performed in OnMeasure called by this /// method. Therefore, only OnMeasure can and must be overridden by subclasses. <br /> /// </summary> /// <param name="widthMeasureSpec"> Horizontal space requirements as imposed by the parent.</param> /// <param name="heightMeasureSpec">Vertical space requirements as imposed by the parent.</param> internal void Measure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec) { layoutItemWrapperImpl.Measure(widthMeasureSpec, heightMeasureSpec); }
/// <summary> /// Measure the layout and its content to determine the measured width and the /// measured height.<br /> /// The base class implementation of measure defaults to the background size, /// unless a larger size is allowed by the MeasureSpec. Subclasses should /// override to provide better measurements of their content.<br /> /// If this method is overridden, it is the subclass's responsibility to make sure the /// measured height and width are at least the layout's minimum height and width.<br /> /// </summary> /// <param name="widthMeasureSpec">horizontal space requirements as imposed by the parent.</param> /// <param name="heightMeasureSpec">vertical space requirements as imposed by the parent.</param> protected virtual void OnMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec) { layoutItemWrapperImpl.OnMeasureNative(widthMeasureSpec, heightMeasureSpec); }
/// <summary> /// Calculate the right measure spec for this child. /// Does the hard part of MeasureChildren: figuring out the MeasureSpec to /// pass to a particular child. This method figures out the right MeasureSpec /// for one dimension (height or width) of one child view.<br /> /// </summary> /// <param name="measureSpec">The requirements for this view.</param> /// <param name="padding">The padding of this view for the current dimension and margins, if applicable.</param> /// <param name="childDimension"> How big the child wants to be in the current dimension.</param> /// <returns>a MeasureSpec for the child.</returns> public static LayoutMeasureSpec GetChildMeasureSpec(LayoutMeasureSpec measureSpec, LayoutLength padding, LayoutLength childDimension) { return(LayoutGroupWrapperImpl.GetChildMeasureSpec(measureSpec, padding, childDimension)); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LayoutMeasureSpec obj) { return((obj.Equals(null)) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
internal static LayoutMeasureSpec GetChildMeasureSpec(LayoutMeasureSpec measureSpec, LayoutLength padding, LayoutLength childDimension) { LayoutMeasureSpec ret = new LayoutMeasureSpec(LayoutPINVOKE.LayoutGroupWrapperImpl_GetChildMeasureSpec(LayoutMeasureSpec.getCPtr(measureSpec), LayoutLength.getCPtr(padding), LayoutLength.getCPtr(childDimension)), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; }
/// <summary> /// Measure the layout and its content to determine the measured width and the measured height.<br /> /// If this method is overridden, it is the subclass's responsibility to make /// sure the measured height and width are at least the layout's minimum height /// and width. <br /> /// </summary> /// <param name="widthMeasureSpec">horizontal space requirements as imposed by the parent.</param> /// <param name="heightMeasureSpec">vertical space requirements as imposed by the parent.</param> protected virtual void OnMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec) { SetMeasuredDimensions(new MeasuredSize(LayoutItemWrapperImpl.GetDefaultSize(layoutItemWrapperImpl.GetSuggestedMinimumWidth(), widthMeasureSpec)), new MeasuredSize(LayoutItemWrapperImpl.GetDefaultSize(layoutItemWrapperImpl.GetSuggestedMinimumHeight(), heightMeasureSpec))); }