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

Fix #1284

Closed
wants to merge 4 commits into from
Closed

Fix #1284

Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion crates/rnote-engine/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,10 @@ impl Engine {
}

pub fn duplicate_selection(&mut self) -> WidgetFlags {
let new_selected = self.store.duplicate_selection();
let new_selected = self.store.duplicate_selection(
self.document.background.pattern_size,
self.document.snap_positions,
);
self.store.update_geometry_for_strokes(&new_selected);
self.current_pen_update_state()
| self.doc_resize_autoexpand()
Expand Down
5 changes: 4 additions & 1 deletion crates/rnote-engine/src/pens/selector/penevents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,10 @@ impl Selector {
KeyboardKey::Unicode('d') => {
//Duplicate selection
if modifier_keys.contains(&ModifierKey::KeyboardCtrl) {
let duplicated = engine_view.store.duplicate_selection();
let duplicated = engine_view.store.duplicate_selection(
engine_view.document.background.pattern_size,
engine_view.document.snap_positions,
);
engine_view.store.update_geometry_for_strokes(&duplicated);
engine_view.store.regenerate_rendering_for_strokes_threaded(
engine_view.tasks_tx.clone(),
Expand Down
16 changes: 13 additions & 3 deletions crates/rnote-engine/src/store/selection_comp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ impl StrokeStore {
/// Duplicate the selected keys.
///
/// The returned, duplicated strokes then need to update their geometry and rendering.
pub(crate) fn duplicate_selection(&mut self) -> Vec<StrokeKey> {
pub(crate) fn duplicate_selection(
&mut self,
pattern_size: na::Vector2<f64>,
snap_mode: bool,
) -> Vec<StrokeKey> {
let old_selected = self.selection_keys_as_rendered();
self.set_selected_keys(&old_selected, false);

Expand Down Expand Up @@ -126,8 +130,14 @@ impl StrokeStore {
.collect::<Vec<StrokeKey>>();

// Offsetting the new selected stroke to make the duplication apparent
self.translate_strokes(&new_selected, Stroke::IMPORT_OFFSET_DEFAULT);
self.translate_strokes_images(&new_selected, Stroke::IMPORT_OFFSET_DEFAULT);
// check if snap position is activated or not here
let offset = if snap_mode {
pattern_size
} else {
Stroke::IMPORT_OFFSET_DEFAULT
};
self.translate_strokes(&new_selected, offset);
self.translate_strokes_images(&new_selected, offset);

new_selected
}
Expand Down
18 changes: 10 additions & 8 deletions crates/rnote-ui/src/appwindow/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ impl RnAppWindow {
let new_zoom =
canvas.engine_ref().camera.total_zoom() * (1.0 - RnCanvas::ZOOM_SCROLL_STEP);
let mut widget_flags = canvas.engine_mut().zoom_w_timeout(new_zoom);
canvas.engine_ref().camera.total_zoom() * (1.0/(1.0 + RnCanvas::ZOOM_SCROLL_STEP));
widget_flags |= canvas
.engine_mut()
.camera
Expand Down Expand Up @@ -1125,20 +1126,21 @@ impl RnAppWindow {
app.set_accels_for_action("win.print-doc", &["<Ctrl>p"]);
app.set_accels_for_action("win.add-page-to-doc", &["<Ctrl><Shift>a"]);
app.set_accels_for_action("win.remove-page-from-doc", &["<Ctrl><Shift>r"]);
app.set_accels_for_action("win.zoom-in", &["<Ctrl>plus"]);
app.set_accels_for_action("win.zoom-out", &["<Ctrl>minus"]);
app.set_accels_for_action("win.zoom-in", &["<Ctrl>plus","<Ctrl>equal","<Ctrl>KP_Add"]);
app.set_accels_for_action("win.zoom-reset",&["<Ctrl>0","<Ctrl>KP_0"]);
app.set_accels_for_action("win.zoom-out", &["<Ctrl>minus","<Ctrl>KP_Subtract"]);
app.set_accels_for_action("win.import-file", &["<Ctrl>i"]);
app.set_accels_for_action("win.undo", &["<Ctrl>z"]);
app.set_accels_for_action("win.redo", &["<Ctrl><Shift>z"]);
app.set_accels_for_action("win.clipboard-copy", &["<Ctrl>c"]);
app.set_accels_for_action("win.clipboard-cut", &["<Ctrl>x"]);
app.set_accels_for_action("win.clipboard-paste", &["<Ctrl>v"]);
app.set_accels_for_action("win.pen-style::brush", &["<Ctrl>1"]);
app.set_accels_for_action("win.pen-style::shaper", &["<Ctrl>2"]);
app.set_accels_for_action("win.pen-style::typewriter", &["<Ctrl>3"]);
app.set_accels_for_action("win.pen-style::eraser", &["<Ctrl>4"]);
app.set_accels_for_action("win.pen-style::selector", &["<Ctrl>5"]);
app.set_accels_for_action("win.pen-style::tools", &["<Ctrl>6"]);
app.set_accels_for_action("win.pen-style::brush", &["<Ctrl>1","<Ctrl>KP_1"]);
app.set_accels_for_action("win.pen-style::shaper", &["<Ctrl>2","<Ctrl>KP_2"]);
app.set_accels_for_action("win.pen-style::typewriter", &["<Ctrl>3","<Ctrl>KP_3"]);
app.set_accels_for_action("win.pen-style::eraser", &["<Ctrl>4","<Ctrl>KP_4"]);
app.set_accels_for_action("win.pen-style::selector", &["<Ctrl>5","<Ctrl>KP_5"]);
app.set_accels_for_action("win.pen-style::tools", &["<Ctrl>6","<Ctrl>KP_6"]);

// shortcuts for devel build
if config::PROFILE.to_lowercase().as_str() == "devel" {
Expand Down
Loading