Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ellipse tool #98

Merged
merged 4 commits into from
Jul 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
turn ellipse into a circle when shift is pressed
jacekpoz committed Jul 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 870aced169aa88dcfef9e7dd17f2cc1b75964cb6
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,
@@ -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;

@@ -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 {