Skip to content

Commit

Permalink
Mac: Layout views if visibility of an object is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
cwensley committed Apr 5, 2012
1 parent 678ea8a commit 59cc58b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Source/Eto.Platform.Mac/Forms/MacView.cs
Expand Up @@ -91,13 +91,13 @@ public abstract class MacView<T, W> : MacObject<T, W>, IControl, IMacViewHandler
}
}

protected virtual bool LayoutIfNeeded (Size? oldPreferredSize = null)
protected virtual bool LayoutIfNeeded (Size? oldPreferredSize = null, bool force = false)
{
naturalSize = null;
if (Widget.Loaded) {
var oldSize = oldPreferredSize ?? Generator.ConvertF (Control.Frame.Size);
var newSize = GetPreferredSize ();
if (newSize != oldSize) {
if (newSize != oldSize || force) {
var layout = Widget.ParentLayout.Handler as IMacLayout;
if (layout != null)
layout.UpdateParentLayout (true);
Expand Down Expand Up @@ -391,7 +391,13 @@ public virtual void Focus ()

public bool Visible {
get { return !Control.Hidden; }
set { Control.Hidden = !value; }
set {
if (Control.Hidden == value) {
var oldSize = this.GetPreferredSize ();
Control.Hidden = !value;
LayoutIfNeeded (oldSize, true);
}
}
}

public Cursor Cursor {
Expand Down

0 comments on commit 59cc58b

Please sign in to comment.