mirror of
https://github.com/ppy/osu
synced 2025-02-17 02:47:19 +00:00
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.Graphics.Containers;
|
|||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osu.Game.Screens.Edit.Components;
|
using osu.Game.Screens.Edit.Components;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Skinning.Editor
|
namespace osu.Game.Skinning.Editor
|
||||||
{
|
{
|
||||||
@ -36,6 +37,8 @@ namespace osu.Game.Skinning.Editor
|
|||||||
|
|
||||||
private OsuScreen lastTargetScreen;
|
private OsuScreen lastTargetScreen;
|
||||||
|
|
||||||
|
private Vector2 lastDrawSize;
|
||||||
|
|
||||||
public SkinEditorOverlay(ScalingContainer scalingContainer)
|
public SkinEditorOverlay(ScalingContainer scalingContainer)
|
||||||
{
|
{
|
||||||
this.scalingContainer = scalingContainer;
|
this.scalingContainer = scalingContainer;
|
||||||
@ -92,18 +95,31 @@ namespace osu.Game.Skinning.Editor
|
|||||||
return base.OnInvalidate(invalidation, source);
|
return base.OnInvalidate(invalidation, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (game.DrawSize != lastDrawSize)
|
||||||
|
{
|
||||||
|
lastDrawSize = game.DrawSize;
|
||||||
|
updateScreenSizing();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateScreenSizing()
|
private void updateScreenSizing()
|
||||||
{
|
{
|
||||||
if (skinEditor?.State.Value != Visibility.Visible) return;
|
if (skinEditor?.State.Value != Visibility.Visible) return;
|
||||||
|
|
||||||
float relativeSidebarWidth = EditorSidebar.WIDTH / DrawWidth;
|
const float padding = 10;
|
||||||
float relativeToolbarHeight = (SkinEditorSceneLibrary.HEIGHT + SkinEditor.MENU_HEIGHT) / DrawHeight;
|
|
||||||
|
float relativeSidebarWidth = (EditorSidebar.WIDTH + padding) / DrawWidth;
|
||||||
|
float relativeToolbarHeight = (SkinEditorSceneLibrary.HEIGHT + SkinEditor.MENU_HEIGHT + padding) / DrawHeight;
|
||||||
|
|
||||||
var rect = new RectangleF(
|
var rect = new RectangleF(
|
||||||
relativeSidebarWidth,
|
relativeSidebarWidth,
|
||||||
relativeToolbarHeight,
|
relativeToolbarHeight,
|
||||||
1 - relativeSidebarWidth * 2,
|
1 - relativeSidebarWidth * 2,
|
||||||
1f - relativeToolbarHeight);
|
1f - relativeToolbarHeight - padding / DrawHeight);
|
||||||
|
|
||||||
scalingContainer.SetCustomRect(rect, true);
|
scalingContainer.SetCustomRect(rect, true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user