Fix the size of renderer controls

This commit is contained in:
Frank A. Krueger 2017-11-09 18:12:02 -08:00
parent 0ccb07ab5e
commit 75535dd38e
5 changed files with 19 additions and 1 deletions

View File

@ -8,7 +8,7 @@ namespace Ooui.Forms.Extensions
public static SizeRequest GetSizeRequest (this Ooui.Element self, double widthConstraint, double heightConstraint,
double minimumWidth = -1, double minimumHeight = -1)
{
Size s = self.Text.MeasureSize (self.Style);
var s = self.Text.MeasureSize (self.Style);
var request = new Size (
double.IsPositiveInfinity (s.Width) ? double.PositiveInfinity : s.Width,

View File

@ -16,5 +16,7 @@ namespace Ooui.Forms
void SetElementSize (Size size);
SizeRequest GetDesiredSize (double widthConstraint, double heightConstraint);
void SetControlSize (Size size);
}
}

View File

@ -97,6 +97,17 @@ namespace Ooui.Forms.Renderers
this.AppendChild (uiview);
}
public override void SetControlSize (Size size)
{
if (Control != null) {
//Control.Style.Position = "absolute";
//Control.Style.Left = "0px";
//Control.Style.Top = "0px";
Control.Style.Width = size.Width + "px";
Control.Style.Height = size.Height + "px";
}
}
protected override void SendVisualElementInitialized (VisualElement element, Ooui.Element nativeView)
{
base.SendVisualElementInitialized (element, Control);

View File

@ -129,6 +129,10 @@ namespace Ooui.Forms
Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Element, new Rectangle (Element.X, Element.Y, size.Width, size.Height));
}
public virtual void SetControlSize (Size size)
{
}
protected virtual void OnElementPropertyChanged (object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName) {

View File

@ -145,6 +145,7 @@ namespace Ooui.Forms
uiview.Style.Top = y + "px";
uiview.Style.Width = width + "px";
uiview.Style.Height = height + "px";
Renderer.SetControlSize (new Size (width, height));
}
else if (width <= 0 || height <= 0) {
return;