mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:52:53 +08:00
Use closest origin along with closest anchor
This commit is contained in:
parent
5cdaafdb1e
commit
0b61e2cd42
@ -457,7 +457,7 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
}
|
}
|
||||||
|
|
||||||
SelectedComponents.Add(component);
|
SelectedComponents.Add(component);
|
||||||
SkinSelectionHandler.ApplyClosestAnchor(drawableComponent);
|
SkinSelectionHandler.ApplyClosestAnchorOrigin(drawableComponent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,15 +204,20 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
|
|
||||||
drawable.Position += drawable.ScreenSpaceDeltaToParentSpace(moveEvent.ScreenSpaceDelta);
|
drawable.Position += drawable.ScreenSpaceDeltaToParentSpace(moveEvent.ScreenSpaceDelta);
|
||||||
|
|
||||||
if (item.UsesFixedAnchor) continue;
|
if (!item.UsesFixedAnchor)
|
||||||
|
ApplyClosestAnchorOrigin(drawable);
|
||||||
ApplyClosestAnchor(drawable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ApplyClosestAnchor(Drawable drawable) => applyAnchor(drawable, getClosestAnchor(drawable));
|
public static void ApplyClosestAnchorOrigin(Drawable drawable)
|
||||||
|
{
|
||||||
|
var closest = getClosestAnchor(drawable);
|
||||||
|
|
||||||
|
applyAnchor(drawable, closest);
|
||||||
|
applyOrigin(drawable, closest);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnSelectionChanged()
|
protected override void OnSelectionChanged()
|
||||||
{
|
{
|
||||||
@ -325,15 +330,10 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
{
|
{
|
||||||
var drawable = (Drawable)item;
|
var drawable = (Drawable)item;
|
||||||
|
|
||||||
if (origin == drawable.Origin) continue;
|
applyOrigin(drawable, origin);
|
||||||
|
|
||||||
var previousOrigin = drawable.OriginPosition;
|
if (item.UsesFixedAnchor)
|
||||||
drawable.Origin = origin;
|
ApplyClosestAnchorOrigin(drawable);
|
||||||
drawable.Position += drawable.OriginPosition - previousOrigin;
|
|
||||||
|
|
||||||
if (item.UsesFixedAnchor) continue;
|
|
||||||
|
|
||||||
ApplyClosestAnchor(drawable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OnOperationEnded();
|
OnOperationEnded();
|
||||||
@ -368,7 +368,7 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
foreach (var item in SelectedItems)
|
foreach (var item in SelectedItems)
|
||||||
{
|
{
|
||||||
item.UsesFixedAnchor = false;
|
item.UsesFixedAnchor = false;
|
||||||
ApplyClosestAnchor((Drawable)item);
|
ApplyClosestAnchorOrigin((Drawable)item);
|
||||||
}
|
}
|
||||||
|
|
||||||
OnOperationEnded();
|
OnOperationEnded();
|
||||||
@ -414,6 +414,15 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
drawable.Position -= drawable.AnchorPosition - previousAnchor;
|
drawable.Position -= drawable.AnchorPosition - previousAnchor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void applyOrigin(Drawable drawable, Anchor origin)
|
||||||
|
{
|
||||||
|
if (origin == drawable.Origin) return;
|
||||||
|
|
||||||
|
var previousOrigin = drawable.OriginPosition;
|
||||||
|
drawable.Origin = origin;
|
||||||
|
drawable.Position += drawable.OriginPosition - previousOrigin;
|
||||||
|
}
|
||||||
|
|
||||||
private static void adjustScaleFromAnchor(ref Vector2 scale, Anchor reference)
|
private static void adjustScaleFromAnchor(ref Vector2 scale, Anchor reference)
|
||||||
{
|
{
|
||||||
// cancel out scale in axes we don't care about (based on which drag handle was used).
|
// cancel out scale in axes we don't care about (based on which drag handle was used).
|
||||||
|
Loading…
Reference in New Issue
Block a user