Permalink
Browse files

Mac: Pass available size to GetNaturalSize() so we can adjust properl…

…y for scrollable containers, etc.
  • Loading branch information...
1 parent 8943b5a commit 12e7ed99f44b746884ec2922e3280084d3e9ad41 @cwensley cwensley committed Mar 26, 2013
@@ -40,9 +40,9 @@ public DateTimePickerHandler ()
this.Mode = DateTimePicker.DefaultMode;
}
- protected override Size GetNaturalSize ()
+ protected override Size GetNaturalSize (Size availableSize)
{
- return Size.Max (new Size (mode == DateTimePickerMode.DateTime ? 180 : 120, 10), base.GetNaturalSize ());
+ return Size.Max (new Size (mode == DateTimePickerMode.DateTime ? 180 : 120, 10), base.GetNaturalSize (availableSize));
}
public override void OnLoad (EventArgs e)
@@ -337,7 +337,7 @@ public System.Drawing.RectangleF GetVisibleRect ()
return ScrollView.VisibleRect ();
}
- protected override Eto.Drawing.Size GetNaturalSize ()
+ protected override Size GetNaturalSize (Size availableSize)
{
var width = Widget.Columns.Sum (r => r.Width);
if (width == 0) width = 100;
@@ -20,7 +20,7 @@ public ImageViewHandler ()
Control = new EtoImageView { Handler = this, ImageScaling = NSImageScale.ProportionallyUpOrDown };
}
- protected override Size GetNaturalSize ()
+ protected override Size GetNaturalSize (Size availableSize)
{
if (image != null)
return image.Size;
@@ -69,7 +69,7 @@ public NumericUpDownHandler ()
Control.AddSubview (text);
Control.AddSubview (stepper);
- var naturalSize = GetNaturalSize ();
+ var naturalSize = GetNaturalSize (Size.MaxValue);
Control.Frame = new System.Drawing.RectangleF (0, 0, naturalSize.Width, naturalSize.Height);
}
@@ -93,7 +93,7 @@ public override void PostKeyDown (KeyEventArgs e)
}
}
- protected override Size GetNaturalSize ()
+ protected override Size GetNaturalSize (Size availableSize)
{
if (naturalSize == null) {
text.SizeToFit ();
@@ -21,7 +21,7 @@ public ProgressBarHandler ()
MaxValue = 100;
}
- protected override Size GetNaturalSize ()
+ protected override Size GetNaturalSize (Size availableSize)
{
return new Size (80, 30);
}
@@ -118,9 +118,9 @@ public override Size GetPreferredSize (Size availableSize)
return Size.Min (base.GetPreferredSize (availableSize), availableSize);
}
- protected override Size GetNaturalSize ()
+ protected override Size GetNaturalSize (Size availableSize)
{
- return base.GetNaturalSize () + GetBorderSize ();
+ return base.GetNaturalSize (availableSize) + GetBorderSize ();
}
void InternalSetFrameSize (SD.SizeF size)
@@ -132,7 +132,7 @@ void InternalSetFrameSize (SD.SizeF size)
public void UpdateScrollSizes ()
{
- var contentSize = base.GetNaturalSize ();
+ var contentSize = base.GetNaturalSize (Size.MaxValue);
if (ExpandContentWidth)
contentSize.Width = Math.Max (this.ClientSize.Width, contentSize.Width);
@@ -28,7 +28,7 @@ public SliderHandler ()
MaxValue = 100;
}
- protected override Size GetNaturalSize ()
+ protected override Size GetNaturalSize (Size availableSize)
{
if (Orientation == SliderOrientation.Horizontal)
return new Size (80, 30);
@@ -223,14 +223,14 @@ public SplitterHandler ()
#endregion
- protected override Size GetNaturalSize ()
+ protected override Size GetNaturalSize (Size availableSize)
{
Size size = new Size ();
var p1 = panel1 != null ? panel1.Handler as IMacAutoSizing : null;
var p2 = panel2 != null ? panel2.Handler as IMacAutoSizing : null;
- var p1size = p1 != null ? p1.GetPreferredSize (Size.MaxValue) : Size.Empty;
- var p2size = p2 != null ? p2.GetPreferredSize (Size.MaxValue) : Size.Empty;
+ var p1size = p1 != null ? p1.GetPreferredSize (availableSize) : Size.Empty;
+ var p2size = p2 != null ? p2.GetPreferredSize (availableSize) : Size.Empty;
if (Control.IsVertical) {
if (position != null) {
switch (FixedPanel) {
@@ -75,14 +75,12 @@ public void RemoveTab (int index, TabPage page)
disableSelectedIndexChanged = false;
}
}
-
- protected override Size GetNaturalSize ()
+
+ protected override Size GetNaturalSize (Size availableSize)
{
- Size size = base.GetNaturalSize();
+ Size size = base.GetNaturalSize(availableSize);
foreach (var tab in Widget.TabPages) {
- var tabsizing = tab.Handler as IMacAutoSizing;
- if (tabsizing != null)
- size = Size.Max (size, tabsizing.GetPreferredSize (Size.MaxValue));
+ size = Size.Max (size, tab.GetPreferredSize(availableSize));
}
return size;
}
@@ -2,6 +2,7 @@
using Eto.Forms;
using MonoMac.AppKit;
using MonoMac.Foundation;
+using Eto.Drawing;
namespace Eto.Platform.Mac.Forms.Controls
{
@@ -75,7 +76,7 @@ public TextAreaHandler ()
};
}
- protected override Eto.Drawing.Size GetNaturalSize ()
+ protected override Size GetNaturalSize (Size availableSize)
{
return TextArea.DefaultSize;
}
@@ -4,6 +4,7 @@
using MonoMac.Foundation;
using Eto.Platform.Mac.Forms.Controls;
using MonoMac.ObjCRuntime;
+using Eto.Drawing;
namespace Eto.Platform.Mac.Forms.Controls
{
@@ -90,9 +91,9 @@ protected override void Initialize()
MaxLength = -1;
}
- protected override Eto.Drawing.Size GetNaturalSize ()
+ protected override Size GetNaturalSize (Size availableSize)
{
- var size = base.GetNaturalSize ();
+ var size = base.GetNaturalSize (availableSize);
size.Width = Math.Max (100, size.Height);
return size;
}
@@ -48,16 +48,15 @@ public virtual void SetLayout (Layout layout)
container.AddSubview (control);
}
}
-
- protected override Size GetNaturalSize ()
+
+ protected override Size GetNaturalSize (Size availableSize)
{
- var size = base.GetNaturalSize ();
if (Widget.Layout != null && Widget.Layout.InnerLayout != null) {
var layout = Widget.Layout.InnerLayout.Handler as IMacLayout;
if (layout != null)
- size = layout.GetPreferredSize (Size.MaxValue);
+ return layout.GetPreferredSize (availableSize);
}
- return size;
+ return base.GetNaturalSize (availableSize);
}
public virtual void SetContentSize (SD.SizeF contentSize)
@@ -157,7 +157,7 @@ public MacView ()
this.AutoSize = true;
}
- protected virtual Size GetNaturalSize ()
+ protected virtual Size GetNaturalSize (Size availableSize)
{
if (naturalSize != null)
return naturalSize.Value;
@@ -175,7 +175,7 @@ protected virtual Size GetNaturalSize ()
public virtual Size GetPreferredSize (Size availableSize)
{
- var size = GetNaturalSize ();
+ var size = GetNaturalSize (availableSize);
if (!AutoSize && PreferredSize != null) {
var preferredSize = PreferredSize.Value;
if (preferredSize.Width >= 0)

0 comments on commit 12e7ed9

Please sign in to comment.