mirror of
https://github.com/storytold/deckcraft.git
synced 2026-11-02 16:30:36 -06:00
Allow resizing on all selected shapes
This commit is contained in:
@@ -149,9 +149,9 @@ enum Drag {
|
||||
enter_text: Option<(ShapeId, Point)>,
|
||||
},
|
||||
Resize {
|
||||
id: ShapeId,
|
||||
ids: Vec<ShapeId>,
|
||||
handle: u8,
|
||||
orig: Xfrm,
|
||||
origs: Vec<(ShapeId, Xfrm)>,
|
||||
start: Point,
|
||||
},
|
||||
LineEnd {
|
||||
|
||||
@@ -26,10 +26,14 @@ impl Session {
|
||||
Drag::Move { ids, start, origs, moved, duplicate, enter_text } => {
|
||||
return self.drag_move(MoveDrag { ids, start, origs, moved, duplicate, enter_text }, p, mods, tol);
|
||||
}
|
||||
Drag::Resize { id, handle, orig, start } => {
|
||||
let nx = resize_box(&orig, handle, p - start, mods.shift || self.is_picture(id), mods.alt);
|
||||
let nx = self.snap_resize(nx, &orig, handle, id, tol);
|
||||
self.set_xfrm(id, nx)?;
|
||||
Drag::Resize { ids, handle, origs, start } => {
|
||||
if ids.len() >= 1 {
|
||||
for (id, o) in &origs {
|
||||
let nx = resize_box(&o, handle, p - start, mods.shift || self.is_picture(*id), mods.alt);
|
||||
let nx = self.snap_resize(nx, &o, handle, *id, tol);
|
||||
self.set_xfrm(*id, nx)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Drag::LineEnd { id, end, orig } => {
|
||||
let a = orig.affine();
|
||||
|
||||
@@ -302,9 +302,10 @@ impl Session {
|
||||
Some(Hit::TableColumn { id, col }) => self.begin_table_border(id, true, col, p)?,
|
||||
Some(Hit::TableRow { id, row }) => self.begin_table_border(id, false, row, p)?,
|
||||
Some(Hit::Resize { id, handle }) => {
|
||||
let orig = st.shape(id).map(|s| xfrm_of(&st.doc, &st.selection, s)).unwrap_or_default();
|
||||
let ids: Vec<ShapeId> = if st.selection.shapes.contains(&id) { st.selection.shapes.clone() } else { vec![id] };
|
||||
let origs: Vec<(ShapeId, Xfrm)> = ids.iter().filter_map(|i| st.shape(*i).map(|s| (*i, xfrm_of(&st.doc, &st.selection, s)))).collect();
|
||||
self.begin("Size");
|
||||
self.tool.drag = Some(Drag::Resize { id, handle, orig, start: p });
|
||||
self.tool.drag = Some(Drag::Resize { ids, handle, origs, start: p });
|
||||
}
|
||||
Some(Hit::LineEnd { id, end }) => {
|
||||
let orig = st.shape(id).map(|s| xfrm_of(&st.doc, &st.selection, s)).unwrap_or_default();
|
||||
@@ -559,10 +560,12 @@ impl Session {
|
||||
out = self.add_ink(points)?;
|
||||
}
|
||||
}
|
||||
Some(Drag::Resize { id, .. }) => {
|
||||
Some(Drag::Resize { ids, .. }) => {
|
||||
self.commit();
|
||||
let _ = cmd::text::fit_text_box(self, id);
|
||||
self.refit_after_resize(id)?;
|
||||
for id in ids {
|
||||
let _ = cmd::text::fit_text_box(self, id);
|
||||
self.refit_after_resize(id)?;
|
||||
}
|
||||
}
|
||||
Some(Drag::TextSelect { before, .. }) => {
|
||||
out = self.paint_if_selection_changed(before, out)?;
|
||||
|
||||
Reference in New Issue
Block a user