This commit is contained in:
Matthias Koefferlein
2026-01-13 16:21:59 +01:00
parent ee622fc104
commit c2aa597022
13 changed files with 142 additions and 18 deletions
+32 -1
View File
@@ -621,7 +621,38 @@ Editables::move_transform (const db::DPoint &p, db::DFTrans t, lay::angle_constr
}
}
void
void
Editables::end_move (const db::DVector &v, db::Transaction *transaction)
{
std::unique_ptr<db::Transaction> trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (tr ("Move"))));
if (m_any_move_operation) {
trans_holder->open ();
// this dummy operation will update the screen:
if (manager ()) {
manager ()->queue (this, new db::Op ());
}
for (iterator e = begin (); e != end (); ++e) {
e->end_move (v);
}
// clear the selection that was set previously
if (m_move_selection) {
clear_selection ();
}
} else {
trans_holder->cancel ();
edit_cancel ();
}
}
void
Editables::end_move (const db::DPoint &p, lay::angle_constraint_type ac, db::Transaction *transaction)
{
std::unique_ptr<db::Transaction> trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (tr ("Move"))));
+20
View File
@@ -326,6 +326,16 @@ public:
// .. by default, nothing is implemented ..
}
/**
* @brief Terminate a "move" operation with compulsory shift vector
*
* @param v The move distance to be applied
*/
virtual void end_move (const db::DVector & /*v*/)
{
// .. by default, nothing is implemented ..
}
/**
* @brief Cancel any pending operations
*
@@ -610,6 +620,16 @@ public:
*/
void end_move (const db::DPoint &p, lay::angle_constraint_type ac, db::Transaction *transaction = 0);
/**
* @brief End "move" operation with given vector
*
* If a transaction is given, the operation will be appended to this pending transaction
* The Editables object takes ownership over the Transaction object.
*
* The vector is supposed to be taken "as is" and no snapping shall be applied.
*/
void end_move (const db::DVector &v, db::Transaction *transaction = 0);
/**
* @brief Indicates how many objects are selected.
*
+19 -10
View File
@@ -91,12 +91,28 @@ void
MoveService::function (const std::string &name, const std::string &value)
{
if (name == move_function_name) {
try {
db::DVector s;
tl::from_string (value, s);
tl::info << "@@@ move " << s.to_string ();
m_dragging = false;
show_toolbox (false);
ui ()->ungrab_mouse (this);
mp_editables->end_move (s, mp_transaction.release ());
if (m_dragging_transient) {
mp_editables->clear_selection ();
}
drag_cancel ();
} catch (...) {
}
}
}
@@ -481,8 +497,6 @@ public:
virtual void commit (lay::Dispatcher *dispatcher)
{
tl::info << "@@@ Commit!";
try {
double dx = 0.0, dy = 0.0;
@@ -505,19 +519,14 @@ public:
db::DVector mv;
tl::from_string (value, mv);
mp_x_le->setText (tl::to_qstring (tl::to_string (mv.x ())));
mp_y_le->setText (tl::to_qstring (tl::to_string (mv.y ())));
mp_x_le->setText (tl::to_qstring (tl::micron_to_string (mv.x ())));
mp_y_le->setText (tl::to_qstring (tl::micron_to_string (mv.y ())));
} catch (...) {
}
}
}
virtual void cancel ()
{
tl::info << "@@@ Escape!";
}
private:
QHBoxLayout *mp_layout;
QLineEdit *mp_x_le, *mp_y_le;