1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Merge branch 'master' into beatmap-refactor/to-model-removal-2

This commit is contained in:
Dan Balasescu 2021-11-05 13:16:32 +09:00 committed by GitHub
commit 9e2c33d908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 11 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using NUnit.Framework;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
@ -65,10 +66,10 @@ namespace osu.Game.Tests.Visual.UserInterface
private void createPaddedComponent(bool hasDescription = false, bool padded = true)
{
LabelledDrawable<Drawable> component = null;
AddStep("create component", () =>
{
LabelledDrawable<Drawable> component;
Child = new Container
{
Anchor = Anchor.Centre,
@ -81,6 +82,8 @@ namespace osu.Game.Tests.Visual.UserInterface
component.Label = "a sample component";
component.Description = hasDescription ? "this text describes the component" : string.Empty;
});
AddAssert($"description {(hasDescription ? "visible" : "hidden")}", () => component.ChildrenOfType<TextFlowContainer>().ElementAt(1).IsPresent == hasDescription);
}
private class PaddedLabelledDrawable : LabelledDrawable<Drawable>

View File

@ -168,7 +168,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
{
descriptionText.Text = value;
if (value == default)
if (!string.IsNullOrEmpty(value.ToString()))
descriptionText.Show();
else
descriptionText.Hide();

View File

@ -70,14 +70,16 @@ namespace osu.Game.Skinning.Editor
if (anchor.HasFlagFast(Anchor.x1)) scale.X = 0;
if (anchor.HasFlagFast(Anchor.y1)) scale.Y = 0;
bool shouldAspectLock =
// for now aspect lock scale adjustments that occur at corners..
(!anchor.HasFlagFast(Anchor.x1) && !anchor.HasFlagFast(Anchor.y1))
// ..or if any of the selection have been rotated.
// this is to avoid requiring skew logic (which would likely not be the user's expected transform anyway).
|| SelectedBlueprints.Any(b => !Precision.AlmostEquals(((Drawable)b.Item).Rotation, 0));
if (shouldAspectLock)
// for now aspect lock scale adjustments that occur at corners..
if (!anchor.HasFlagFast(Anchor.x1) && !anchor.HasFlagFast(Anchor.y1))
{
// project scale vector along diagonal
Vector2 diag = (selectionRect.TopLeft - selectionRect.BottomRight).Normalized();
scale = Vector2.Dot(scale, diag) * diag;
}
// ..or if any of the selection have been rotated.
// this is to avoid requiring skew logic (which would likely not be the user's expected transform anyway).
else if (SelectedBlueprints.Any(b => !Precision.AlmostEquals(((Drawable)b.Item).Rotation, 0)))
{
if (anchor.HasFlagFast(Anchor.x1))
// if dragging from the horizontal centre, only a vertical component is available.