First implementation of infix mode

Three mode menu items appear in "Targets for Key Binding"
in the setup dialog and can be bound to a key.

"Move Interactive" will immediately start moving the
selection.

"Paste Interactive" and "Duplicate Interactive" will
paste and then immediately start moving.

Remaining issue: when Paste or Duplicate moves are
cancelled the pasted objects will still be there and
at the original location. So they are may be hard to
see. Also with Undo, two undo items are there: Paste
and Move.
This commit is contained in:
Matthias Koefferlein
2019-09-03 22:53:32 +02:00
parent 1106d3faac
commit 70a4ce82b3
7 changed files with 165 additions and 33 deletions
+40
View File
@@ -5085,6 +5085,29 @@ LayoutView::paste ()
}
}
void
LayoutView::paste_interactive ()
{
clear_selection ();
{
db::Transaction trans (manager (), tl::to_string (QObject::tr ("Paste")));
// let the receivers sort out who is pasting what ..
if (mp_hierarchy_panel) {
mp_hierarchy_panel->paste ();
}
if (mp_control_panel) {
mp_control_panel->paste ();
}
lay::Editables::paste ();
}
if (mp_move_service->begin_move ()) {
switch_mode (-1); // move mode
}
}
void
LayoutView::copy ()
{
@@ -6763,6 +6786,23 @@ LayoutView::cm_sel_scale ()
}
}
void
LayoutView::cm_sel_move_interactive ()
{
if (mp_move_service->begin_move ()) {
switch_mode (-1); // move mode
}
}
void
LayoutView::switch_mode (int m)
{
if (m_mode != m) {
mode (m);
emit mode_change (m);
}
}
void
LayoutView::cm_sel_move_to ()
{
+19
View File
@@ -254,6 +254,11 @@ public:
*/
void paste ();
/**
* @brief Pastes from clipboard and initiates a move
*/
void paste_interactive ();
/**
* @brief Copies to clipboard
*
@@ -1617,6 +1622,14 @@ public:
*/
void mode (int m);
/**
* @brief Switches the application's mode
*
* Switches the mode on application level. Use this method to initiate
* a mode switch from the view.
*/
void switch_mode (int m);
/**
* @brief Test, if the view is currently in move mode.
*/
@@ -2582,6 +2595,7 @@ public slots:
void cm_sel_scale ();
void cm_sel_move ();
void cm_sel_move_to ();
void cm_sel_move_interactive ();
// forwarded to the layer control panel
void cm_new_tab ();
@@ -2698,6 +2712,11 @@ signals:
*/
void menu_needs_update ();
/**
* @brief The view initiated a mode change
*/
void mode_change (int m);
protected:
/**
* @brief Establish the view operations
+16
View File
@@ -229,6 +229,22 @@ MoveService::mouse_press_event (const db::DPoint &p, unsigned int buttons, bool
return false;
}
bool
MoveService::begin_move ()
{
drag_cancel ();
db::DBox bbox = mp_editables->selection_bbox ();
if (bbox.empty ()) {
// nothing selected
return false;
}
set_cursor (lay::Cursor::size_all);
// emulate a "begin move" at the center of the selection bbox - this will become the reference point
return handle_dragging (bbox.center (), 0);
}
bool
MoveService::handle_dragging (const db::DPoint &p, unsigned int buttons)
+1
View File
@@ -46,6 +46,7 @@ public:
~MoveService ();
virtual bool configure (const std::string &name, const std::string &value);
bool begin_move ();
private:
virtual bool mouse_press_event (const db::DPoint &p, unsigned int buttons, bool prio);