Skip to content

Commit

Permalink
turn ellipse into a circle when shift is pressed
Browse files Browse the repository at this point in the history
  • Loading branch information
jacekpoz committed Jul 14, 2024
1 parent 5f9fa51 commit 870aced
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/tools/ellipse.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;
use femtovg::{FontId, Path};
use relm4::gtk::gdk::Key;
use relm4::gtk::gdk::{Key, ModifierType};

use crate::{
math::Vec2D,
Expand Down Expand Up @@ -65,7 +65,11 @@ impl Tool for EllipseTool {

ToolUpdateResult::Redraw
} else {
ellipse.radii = Some(event.pos);
if event.modifier.contains(ModifierType::SHIFT_MASK) {
ellipse.radii = Some(Vec2D::new(event.pos.x, event.pos.x));
} else {
ellipse.radii = Some(event.pos);
}
let result = ellipse.clone_box();
self.ellipse = None;

Expand All @@ -80,7 +84,11 @@ impl Tool for EllipseTool {
if event.pos == Vec2D::zero() {
return ToolUpdateResult::Unmodified;
}
ellipse.radii = Some(event.pos);
if event.modifier.contains(ModifierType::SHIFT_MASK) {
ellipse.radii = Some(Vec2D::new(event.pos.x, event.pos.x));
} else {
ellipse.radii = Some(event.pos);
}

ToolUpdateResult::Redraw
} else {
Expand Down

0 comments on commit 870aced

Please sign in to comment.