From 79868c40cdcdba56aa2c48dfaac4ab3ea494508d Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 19 Feb 2023 19:54:40 +0100 Subject: [PATCH] Some enhancements for image editing (e.g. selection remains after moving handles) --- src/img/img/imgService.cc | 21 ++++++++++++++------- src/img/img/imgService.h | 2 +- src/laybasic/laybasic/layEditable.cc | 1 - src/laybasic/laybasic/layLayoutViewBase.cc | 2 ++ src/layview/layview/layLayoutView_qt.cc | 1 + 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/img/img/imgService.cc b/src/img/img/imgService.cc index 284467010..9724f902a 100644 --- a/src/img/img/imgService.cc +++ b/src/img/img/imgService.cc @@ -418,7 +418,7 @@ Service::Service (db::Manager *manager, lay::LayoutViewBase *view) mp_transient_view (0), m_move_mode (Service::move_none), m_moved_landmark (0), - m_keep_selection_for_landmark (false), + m_keep_selection_for_move (false), m_images_visible (true) { // place images behind the grid @@ -623,7 +623,7 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang m_move_mode = mm; m_moved_landmark = ml; - m_keep_selection_for_landmark = true; + m_keep_selection_for_move = true; // found a handle of one of the selected object: make the moved image the selection clear_selection (); @@ -660,7 +660,7 @@ Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::ang m_move_mode = mm; m_moved_landmark = ml; - m_keep_selection_for_landmark = false; + m_keep_selection_for_move = false; // found anything: make the moved image the selection clear_selection (); @@ -893,7 +893,7 @@ Service::end_move (const db::DPoint &, lay::angle_constraint_type) image_changed_event (id); // clear the selection (that was artificially created before) - if (! m_keep_selection_for_landmark) { + if (! m_keep_selection_for_move) { clear_selection (); } else { selection_to_view (); @@ -907,7 +907,11 @@ Service::end_move (const db::DPoint &, lay::angle_constraint_type) image_changed_event (id); // clear the selection (that was artificially created before) - clear_selection (); + if (! m_keep_selection_for_move) { + clear_selection (); + } else { + selection_to_view (); + } } @@ -956,6 +960,7 @@ Service::find_image (const db::DPoint &p, const db::DBox &search_box, double l, void Service::selection_to_view (img::View::Mode mode) { + clear_transient_selection (); image_selection_changed_event (); // the selection objects need to be recreated since we destroyed the old images @@ -1006,8 +1011,10 @@ Service::transform (const db::DCplxTrans &trans) void Service::edit_cancel () { - m_move_mode = move_none; - selection_to_view (); + if (m_move_mode != move_none) { + m_move_mode = move_none; + selection_to_view (); + } } void diff --git a/src/img/img/imgService.h b/src/img/img/imgService.h index c2cd1aa8d..7151f5c6b 100644 --- a/src/img/img/imgService.h +++ b/src/img/img/imgService.h @@ -506,7 +506,7 @@ private: // The index of the landmark being moved size_t m_moved_landmark; // Flag indicating that we want to keep the selection after the landmark was moved - bool m_keep_selection_for_landmark; + bool m_keep_selection_for_move; // Flag indicating whether images are visible bool m_images_visible; diff --git a/src/laybasic/laybasic/layEditable.cc b/src/laybasic/laybasic/layEditable.cc index ba48170a9..4a3b0e3bf 100644 --- a/src/laybasic/laybasic/layEditable.cc +++ b/src/laybasic/laybasic/layEditable.cc @@ -318,7 +318,6 @@ Editables::transient_to_selection () { bool had_transient_selection = false; bool had_selection = false; - cancel_edits (); for (iterator e = begin (); e != end (); ++e) { if (e->has_selection ()) { had_selection = true; diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index bf711a53d..b25775fee 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -5290,6 +5290,7 @@ LayoutViewBase::paste_interactive () void LayoutViewBase::copy () { + cancel_edits (); if (! lay::Editables::has_selection ()) { // try to use the transient selection for the real one lay::Editables::transient_to_selection (); @@ -5301,6 +5302,7 @@ LayoutViewBase::copy () void LayoutViewBase::cut () { + cancel_edits (); if (! lay::Editables::has_selection ()) { // try to use the transient selection for the real one lay::Editables::transient_to_selection (); diff --git a/src/layview/layview/layLayoutView_qt.cc b/src/layview/layview/layLayoutView_qt.cc index b0cd035bc..fe9010206 100644 --- a/src/layview/layview/layLayoutView_qt.cc +++ b/src/layview/layview/layLayoutView_qt.cc @@ -590,6 +590,7 @@ LayoutView::show_properties () return; } + cancel_edits (); if (! has_selection ()) { // try to use the transient selection for the real one transient_to_selection ();