Fix the size of renderer controls
This commit is contained in:
parent
0ccb07ab5e
commit
75535dd38e
|
@ -8,7 +8,7 @@ namespace Ooui.Forms.Extensions
|
||||||
public static SizeRequest GetSizeRequest (this Ooui.Element self, double widthConstraint, double heightConstraint,
|
public static SizeRequest GetSizeRequest (this Ooui.Element self, double widthConstraint, double heightConstraint,
|
||||||
double minimumWidth = -1, double minimumHeight = -1)
|
double minimumWidth = -1, double minimumHeight = -1)
|
||||||
{
|
{
|
||||||
Size s = self.Text.MeasureSize (self.Style);
|
var s = self.Text.MeasureSize (self.Style);
|
||||||
|
|
||||||
var request = new Size (
|
var request = new Size (
|
||||||
double.IsPositiveInfinity (s.Width) ? double.PositiveInfinity : s.Width,
|
double.IsPositiveInfinity (s.Width) ? double.PositiveInfinity : s.Width,
|
||||||
|
|
|
@ -16,5 +16,7 @@ namespace Ooui.Forms
|
||||||
void SetElementSize (Size size);
|
void SetElementSize (Size size);
|
||||||
|
|
||||||
SizeRequest GetDesiredSize (double widthConstraint, double heightConstraint);
|
SizeRequest GetDesiredSize (double widthConstraint, double heightConstraint);
|
||||||
|
|
||||||
|
void SetControlSize (Size size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,17 @@ namespace Ooui.Forms.Renderers
|
||||||
this.AppendChild (uiview);
|
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)
|
protected override void SendVisualElementInitialized (VisualElement element, Ooui.Element nativeView)
|
||||||
{
|
{
|
||||||
base.SendVisualElementInitialized (element, Control);
|
base.SendVisualElementInitialized (element, Control);
|
||||||
|
|
|
@ -129,6 +129,10 @@ namespace Ooui.Forms
|
||||||
Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Element, new Rectangle (Element.X, Element.Y, size.Width, size.Height));
|
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)
|
protected virtual void OnElementPropertyChanged (object sender, PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName) {
|
if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName) {
|
||||||
|
|
|
@ -145,6 +145,7 @@ namespace Ooui.Forms
|
||||||
uiview.Style.Top = y + "px";
|
uiview.Style.Top = y + "px";
|
||||||
uiview.Style.Width = width + "px";
|
uiview.Style.Width = width + "px";
|
||||||
uiview.Style.Height = height + "px";
|
uiview.Style.Height = height + "px";
|
||||||
|
Renderer.SetControlSize (new Size (width, height));
|
||||||
}
|
}
|
||||||
else if (width <= 0 || height <= 0) {
|
else if (width <= 0 || height <= 0) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue