Skip to content

Commit

Permalink
There's no need to change the editor size after open the panels.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Aug 15, 2024
1 parent 4872f11 commit 4593133
Showing 1 changed file with 1 addition and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public LyricComposer()
closeOtherPanelsInTheSameDirection(type);
}

togglePanel(type, show);
panelInstance[type].State.Value = show ? Visibility.Visible : Visibility.Hidden;
}, true);
}
}
Expand Down Expand Up @@ -191,13 +191,6 @@ static Panel getInstance(PanelType panelType) =>
};
}

private void togglePanel(PanelType panel, bool show)
{
panelInstance[panel].State.Value = show ? Visibility.Visible : Visibility.Hidden;

calculateLyricEditorSize();
}

private void calculatePanelPosition()
{
float radio = DrawWidth / DrawHeight;
Expand Down Expand Up @@ -234,7 +227,6 @@ private void assignPanelPosition(PanelLayout panelLayout)
}

closeOtherPanelsInTheSameDirection(PanelType.Property);
calculateLyricEditorSize();
}

private void closeOtherPanelsInTheSameDirection(PanelType exceptPanel)
Expand All @@ -248,36 +240,6 @@ private void closeOtherPanelsInTheSameDirection(PanelType exceptPanel)
}
}

private void calculateLyricEditorSize()
{
var padding = new MarginPadding();

foreach (var (position, panelTypes) in panelDirections)
{
var instances = panelTypes.Select(panelType => panelInstance[panelType]).ToArray();
float maxWidth = instances.Any() ? instances.Max(getWidth) : 0;

switch (position)
{
case PanelDirection.Left:
padding.Left = maxWidth;
break;

case PanelDirection.Right:
padding.Right = maxWidth;
break;

default:
throw new ArgumentOutOfRangeException(nameof(position), position, null);
}
}

mainEditorArea.Padding = padding;

static float getWidth(Panel panel)
=> panel.State.Value == Visibility.Visible ? panel.Width : 0;
}

#endregion

#region Bottom editor
Expand Down

0 comments on commit 4593133

Please sign in to comment.