Skip to content

Commit

Permalink
Merge pull request #991 from peppy/visibility-container-fix
Browse files Browse the repository at this point in the history
Fix PopIn/Out being run before a VisibilityContainer is added to the scene graph
  • Loading branch information
smoogipoo authored Aug 22, 2017
2 parents ba70b8e + e4529ad commit 00be5c7
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions osu.Framework/Graphics/Containers/VisibilityContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ protected override void LoadComplete()
{
if (state == Visibility.Hidden)
{
// do this without triggering the StateChanged event, since hidden is a default.
PopOut();
FinishTransforms(true);
}
else
updateState();

base.LoadComplete();
}
Expand All @@ -31,20 +34,27 @@ public Visibility State
if (value == state) return;
state = value;

switch (value)
{
case Visibility.Hidden:
PopOut();
break;
case Visibility.Visible:
PopIn();
break;
}

StateChanged?.Invoke(this, state);
if (!IsLoaded) return;

updateState();
}
}

private void updateState()
{
switch (state)
{
case Visibility.Hidden:
PopOut();
break;
case Visibility.Visible:
PopIn();
break;
}

StateChanged?.Invoke(this, state);
}

public override void Hide() => State = Visibility.Hidden;

public override void Show() => State = Visibility.Visible;
Expand Down

0 comments on commit 00be5c7

Please sign in to comment.