// 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 osuTK; namespace osu.Game.Screens.Edit.Compose.Components { /// /// Base handler for editor rotation operations. /// public partial class SelectionRotationHandler : Component { /// /// Whether there is any ongoing scale operation right now. /// public Bindable OperationInProgress { get; private set; } = new BindableBool(); /// /// Whether rotation anchored by the selection origin can currently be performed. /// public Bindable CanRotateAroundSelectionOrigin { get; private set; } = new BindableBool(); /// /// Whether rotation anchored by the center of the playfield can currently be performed. /// public Bindable CanRotateAroundPlayfieldOrigin { get; private set; } = new BindableBool(); /// /// Implementation-defined origin point to rotate around when no explicit origin is provided. /// This field is only assigned during a rotation operation. /// public Vector2? DefaultOrigin { get; protected set; } /// /// Performs a single, instant, atomic rotation operation. /// /// /// This method is intended to be used in atomic contexts (such as when pressing a single button). /// For continuous operations, see the -- flow. /// /// Rotation to apply in degrees. /// /// The origin point to rotate around. /// If the default value is supplied, a sane implementation-defined default will be used. /// public void Rotate(float rotation, Vector2? origin = null) { Begin(); Update(rotation, origin); Commit(); } /// /// Begins a continuous rotation operation. /// /// /// This flow is intended to be used when a rotation operation is made incrementally (such as when dragging a rotation handle or slider). /// For instantaneous, atomic operations, use the convenience method. /// public virtual void Begin() { OperationInProgress.Value = true; } /// /// Updates a continuous rotation operation. /// Must be preceded by a call. /// /// /// /// This flow is intended to be used when a rotation operation is made incrementally (such as when dragging a rotation handle or slider). /// As such, the values of and supplied should be relative to the state of the objects being rotated /// when was called, rather than instantaneous deltas. /// /// /// For instantaneous, atomic operations, use the convenience method. /// /// /// Rotation to apply in degrees. /// /// The origin point to rotate around. /// If the default value is supplied, a sane implementation-defined default will be used. /// public virtual void Update(float rotation, Vector2? origin = null) { } /// /// Ends a continuous rotation operation. /// Must be preceded by a call. /// /// /// This flow is intended to be used when a rotation operation is made incrementally (such as when dragging a rotation handle or slider). /// For instantaneous, atomic operations, use the convenience method. /// public virtual void Commit() { OperationInProgress.Value = false; } } }