From f309cb9247051a8cc5f4fe3d26248ef37cd8ae68 Mon Sep 17 00:00:00 2001 From: "Frank A. Krueger" Date: Sun, 15 Apr 2018 19:06:31 -0700 Subject: [PATCH] Fix sizes of controls --- Ooui.Forms/Renderers/ButtonRenderer.cs | 2 +- Ooui.Forms/Renderers/DatePickerRenderer.cs | 2 +- Ooui.Forms/Renderers/EntryRenderer.cs | 5 ++-- Ooui.Forms/Renderers/TimePickerRenderer.cs | 2 +- Samples/WrappingTextSample.cs | 31 ++++++++++++++++++++++ 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Ooui.Forms/Renderers/ButtonRenderer.cs b/Ooui.Forms/Renderers/ButtonRenderer.cs index 7687430..647008e 100644 --- a/Ooui.Forms/Renderers/ButtonRenderer.cs +++ b/Ooui.Forms/Renderers/ButtonRenderer.cs @@ -15,7 +15,7 @@ namespace Ooui.Forms.Renderers public override SizeRequest GetDesiredSize (double widthConstraint, double heightConstraint) { var size = Element.Text.MeasureSize (Element.FontFamily, Element.FontSize, Element.FontAttributes, widthConstraint, heightConstraint); - size = new Size (size.Width + 2 * Element.FontSize, size.Height + Element.FontSize); + size = new Size (size.Width + 32, size.Height + 16); return new SizeRequest (size, size); } diff --git a/Ooui.Forms/Renderers/DatePickerRenderer.cs b/Ooui.Forms/Renderers/DatePickerRenderer.cs index c97fd3b..2725125 100644 --- a/Ooui.Forms/Renderers/DatePickerRenderer.cs +++ b/Ooui.Forms/Renderers/DatePickerRenderer.cs @@ -14,7 +14,7 @@ namespace Ooui.Forms.Renderers public override SizeRequest GetDesiredSize (double widthConstraint, double heightConstraint) { var size = "00/00/0000".MeasureSize ("", 16.0, FontAttributes.None, widthConstraint, heightConstraint); - size = new Size (size.Width, size.Height); + size = new Size (size.Width + 32, size.Height + 16); return new SizeRequest (size, size); } diff --git a/Ooui.Forms/Renderers/EntryRenderer.cs b/Ooui.Forms/Renderers/EntryRenderer.cs index 4704819..410c19e 100644 --- a/Ooui.Forms/Renderers/EntryRenderer.cs +++ b/Ooui.Forms/Renderers/EntryRenderer.cs @@ -25,8 +25,9 @@ namespace Ooui.Forms.Renderers text = " "; } var size = text.MeasureSize (Element.FontFamily, Element.FontSize, Element.FontAttributes, widthConstraint, heightConstraint); - var vpadding = Element.FontSize; - size = new Size (size.Width, size.Height + vpadding); + var vpadding = 16; + var hpadding = 32; + size = new Size (size.Width + hpadding, size.Height + vpadding); return new SizeRequest (size, size); } diff --git a/Ooui.Forms/Renderers/TimePickerRenderer.cs b/Ooui.Forms/Renderers/TimePickerRenderer.cs index 56fe30d..680160e 100644 --- a/Ooui.Forms/Renderers/TimePickerRenderer.cs +++ b/Ooui.Forms/Renderers/TimePickerRenderer.cs @@ -15,7 +15,7 @@ namespace Ooui.Forms.Renderers { var fontSize = 16.0; var size = "00:00:00".MeasureSize(string.Empty, fontSize, FontAttributes.None, widthConstraint, heightConstraint); - size = new Size(size.Width, size.Height + fontSize); + size = new Size(size.Width + 32, size.Height + 16); return new SizeRequest(size, size); } diff --git a/Samples/WrappingTextSample.cs b/Samples/WrappingTextSample.cs index 18e2daa..e4580e1 100644 --- a/Samples/WrappingTextSample.cs +++ b/Samples/WrappingTextSample.cs @@ -23,6 +23,37 @@ namespace Samples row1.Children.Add (new Label { Text = longText, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.End }); rows.Children.Add (row1); + var row2 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.Azure }; + row2.Children.Add (new Entry { Text = shortText, FontSize = 8, VerticalOptions = LayoutOptions.Center }); + row2.Children.Add (new Entry { Text = shortText, FontSize = 16, VerticalOptions = LayoutOptions.Center }); + row2.Children.Add (new Entry { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center }); + row2.Children.Add (new Button { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center }); + rows.Children.Add (row2); + + var row3 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.GhostWhite }; + row3.Children.Add (new Entry { Text = shortText, FontSize = 8, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }); + row3.Children.Add (new Entry { Text = shortText, FontSize = 16, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }); + row3.Children.Add (new Entry { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }); + row3.Children.Add (new Button { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }); + rows.Children.Add (row3); + + var row4 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.Azure }; + row4.Children.Add (new Button { Text = shortText, FontSize = 8, VerticalOptions = LayoutOptions.Center }); + row4.Children.Add (new Button { Text = shortText, FontSize = 16, VerticalOptions = LayoutOptions.Center }); + row4.Children.Add (new Button { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center }); + rows.Children.Add (row4); + + var row5 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.GhostWhite }; + row5.Children.Add (new Button { Text = shortText, FontSize = 8, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }); + row5.Children.Add (new Button { Text = shortText, FontSize = 16, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }); + row5.Children.Add (new Button { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }); + rows.Children.Add (row5); + + var row6 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.GhostWhite }; + row6.Children.Add (new DatePicker { VerticalOptions = LayoutOptions.Center }); + row6.Children.Add (new TimePicker { VerticalOptions = LayoutOptions.Center }); + rows.Children.Add (row6); + var page = new ContentPage { Content = rows