// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osuTK; namespace osu.Game.Screens.Edit.Compose.Components { /// /// Base handler for editor scale operations. /// public partial class SelectionScaleHandler : Component { /// /// Whether horizontal scaling (from the left or right edge) support should be enabled. /// public Bindable CanScaleX { get; private set; } = new BindableBool(); /// /// Whether vertical scaling (from the top or bottom edge) support should be enabled. /// public Bindable CanScaleY { get; private set; } = new BindableBool(); /// /// Whether diagonal scaling (from a corner) support should be enabled. /// /// /// There are some cases where we only want to allow proportional resizing, and not allow /// one or both explicit directions of scale. /// public Bindable CanScaleDiagonally { get; private set; } = new BindableBool(); public Quad? OriginalSurroundingQuad { get; protected set; } /// /// Performs a single, instant, atomic scale operation. /// /// /// This method is intended to be used in atomic contexts (such as when pressing a single button). /// For continuous operations, see the -- flow. /// /// The scale to apply, as multiplier. /// /// The origin point to scale from. /// If the default value is supplied, a sane implementation-defined default will be used. /// /// The axes to adjust the scale in. public void ScaleSelection(Vector2 scale, Vector2? origin = null, Axes adjustAxis = Axes.Both) { Begin(); Update(scale, origin, adjustAxis); Commit(); } /// /// Begins a continuous scale operation. /// /// /// This flow is intended to be used when a scale operation is made incrementally (such as when dragging a scale handle or slider). /// For instantaneous, atomic operations, use the convenience method. /// public virtual void Begin() { } /// /// Updates a continuous scale operation. /// Must be preceded by a call. /// /// /// /// This flow is intended to be used when a scale operation is made incrementally (such as when dragging a scale handle or slider). /// As such, the values of and supplied should be relative to the state of the objects being scaled /// when was called, rather than instantaneous deltas. /// /// /// For instantaneous, atomic operations, use the convenience method. /// /// /// The Scale to apply, as multiplier. /// /// The origin point to scale from. /// If the default value is supplied, a sane implementation-defined default will be used. /// /// The axes to adjust the scale in. public virtual void Update(Vector2 scale, Vector2? origin = null, Axes adjustAxis = Axes.Both) { } /// /// Ends a continuous scale operation. /// Must be preceded by a call. /// /// /// This flow is intended to be used when a scale operation is made incrementally (such as when dragging a scale handle or slider). /// For instantaneous, atomic operations, use the convenience method. /// public virtual void Commit() { } } }