Skip to content

Commit

Permalink
Gtk: Splitter initial position should be set when allocated space, no…
Browse files Browse the repository at this point in the history
…t only when realized
  • Loading branch information
cwensley committed Feb 1, 2018
1 parent ac2331d commit da4ab46
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Eto.Gtk/Forms/Controls/SplitterHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class SplitterHandler : GtkContainer<Gtk.Paned, Splitter, Splitter.ICallb
int? position;
double relative = double.NaN;
int suppressSplitterMoved;
bool initialPositionSet;
int _panel1MinimumSize, _panel2MinimumSize;

int GetPreferredPanelSize(int width1, int width2)
Expand Down Expand Up @@ -90,7 +91,7 @@ protected override void OnSizeAllocated(Gdk.Rectangle allocation)
base.OnSizeAllocated(allocation);
it.suppressSplitterMoved--;

Handler.EnsurePosition();
it.EnsurePosition();
}
}

Expand Down Expand Up @@ -143,7 +144,7 @@ protected override void OnSizeAllocated(Gdk.Rectangle allocation)
base.OnSizeAllocated(allocation);
it.suppressSplitterMoved--;

Handler.EnsurePosition();
it.EnsurePosition();
}
}

Expand Down Expand Up @@ -337,7 +338,6 @@ void Create()

void Control_Realized(object sender, EventArgs e)
{
SetInitialPosition();
HookEvents();
}

Expand Down Expand Up @@ -466,6 +466,13 @@ void EnsurePosition()
if (size <= 0)
return;

if (!initialPositionSet && Control.IsRealized)
{
initialPositionSet = true;
SetInitialPosition();
}


if (_panel1MinimumSize + _panel2MinimumSize > size || Control.Position < _panel1MinimumSize)
Control.Position = _panel1MinimumSize;
else if (Position > size - _panel2MinimumSize)
Expand Down

0 comments on commit da4ab46

Please sign in to comment.