Transformation cage (#502)

* Render corners and edges of selection box

* Refactor

* Add drag detection

* Implement the transform handles

* Implement rotation by dragging <40px from bounds

* Refine clustered handle behaviour

* Add cursors

* Add snap angle

* Fix MMB drag whilst in select tool

* Convert calculate_pivot into a seperate function

* rename start_vec to start_offset

* Fix typo

* Remove Undo transaction on <10px mouse move

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
0HyperCube
2022-02-04 16:46:44 +00:00
committed by Keavon Chambers
parent 2a313471d8
commit 599a9d076b
12 changed files with 401 additions and 62 deletions

View File

@@ -191,9 +191,9 @@ impl MessageHandler<MovementMessage, (&Document, &InputPreprocessorMessageHandle
let half_viewport = ipp.viewport_bounds.size() / 2.;
let rotation = {
let start_vec = self.mouse_position - half_viewport;
let end_vec = ipp.mouse.position - half_viewport;
start_vec.angle_between(end_vec)
let start_offset = self.mouse_position - half_viewport;
let end_offset = ipp.mouse.position - half_viewport;
start_offset.angle_between(end_offset)
};
responses.push_back(SetCanvasRotation { angle_radians: self.tilt + rotation }.into());
@@ -329,7 +329,6 @@ impl MessageHandler<MovementMessage, (&Document, &InputPreprocessorMessageHandle
fn actions(&self) -> ActionList {
let mut common = actions!(MovementMessageDiscriminant;
MouseMove,
TranslateCanvasBegin,
RotateCanvasBegin,
ZoomCanvasBegin,
@@ -345,6 +344,7 @@ impl MessageHandler<MovementMessage, (&Document, &InputPreprocessorMessageHandle
if self.panning || self.tilting || self.zooming {
let transforming = actions!(MovementMessageDiscriminant;
MouseMove,
TransformCanvasEnd,
);
common.extend(transforming);