mirror of https://github.com/ppy/osu
Add padding and avoid using invalidation (triggers too often when toolbar is being toggled)
This commit is contained in:
parent
003a3de270
commit
a8764b67e1
|
@ -15,6 +15,7 @@
|
|||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Edit.Components;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Skinning.Editor
|
||||
{
|
||||
|
@ -36,6 +37,8 @@ public class SkinEditorOverlay : OverlayContainer, IKeyBindingHandler<GlobalActi
|
|||
|
||||
private OsuScreen lastTargetScreen;
|
||||
|
||||
private Vector2 lastDrawSize;
|
||||
|
||||
public SkinEditorOverlay(ScalingContainer scalingContainer)
|
||||
{
|
||||
this.scalingContainer = scalingContainer;
|
||||
|
@ -92,18 +95,31 @@ protected override bool OnInvalidate(Invalidation invalidation, InvalidationSour
|
|||
return base.OnInvalidate(invalidation, source);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (game.DrawSize != lastDrawSize)
|
||||
{
|
||||
lastDrawSize = game.DrawSize;
|
||||
updateScreenSizing();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateScreenSizing()
|
||||
{
|
||||
if (skinEditor?.State.Value != Visibility.Visible) return;
|
||||
|
||||
float relativeSidebarWidth = EditorSidebar.WIDTH / DrawWidth;
|
||||
float relativeToolbarHeight = (SkinEditorSceneLibrary.HEIGHT + SkinEditor.MENU_HEIGHT) / DrawHeight;
|
||||
const float padding = 10;
|
||||
|
||||
float relativeSidebarWidth = (EditorSidebar.WIDTH + padding) / DrawWidth;
|
||||
float relativeToolbarHeight = (SkinEditorSceneLibrary.HEIGHT + SkinEditor.MENU_HEIGHT + padding) / DrawHeight;
|
||||
|
||||
var rect = new RectangleF(
|
||||
relativeSidebarWidth,
|
||||
relativeToolbarHeight,
|
||||
1 - relativeSidebarWidth * 2,
|
||||
1f - relativeToolbarHeight);
|
||||
1f - relativeToolbarHeight - padding / DrawHeight);
|
||||
|
||||
scalingContainer.SetCustomRect(rect, true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue