| 323 | } |
| 324 | |
| 325 | bool |
| 326 | MoveService::start_move (db::Transaction *transaction, bool transient_selection) |
| 327 | { |
| 328 | if (m_dragging) { |
| 329 | return false; |
| 330 | } |
| 331 | |
| 332 | std::unique_ptr<db::Transaction> trans_holder (transaction); |
| 333 | |
| 334 | bool drag_transient = false; |
| 335 | |
| 336 | if (! transaction) { |
| 337 | |
| 338 | // unless in "continue with move" use case try to establish a selection |
| 339 | |
| 340 | if (! mp_editables->has_selection ()) { |
| 341 | // try to use the transient selection for the real one |
| 342 | mp_editables->transient_to_selection (); |
| 343 | drag_transient = true; |
| 344 | } |
| 345 | |
| 346 | if (! mp_editables->has_selection ()) { |
| 347 | // still nothing selected |
| 348 | return false; |
| 349 | } |
| 350 | |
| 351 | } else { |
| 352 | |
| 353 | // inherit transient selection mode from previous operation |
| 354 | drag_transient = transient_selection; |
| 355 | |
| 356 | } |
| 357 | |
| 358 | db::DBox bbox = mp_editables->selection_bbox (); |
| 359 | if (bbox.empty ()) { |
| 360 | // nothing (useful) selected |
| 361 | return false; |
| 362 | } |
| 363 | |
| 364 | set_cursor (lay::Cursor::size_all); |
| 365 | |
| 366 | // emulate a "begin move" at the current mouse position if inside the box or the closest point |
| 367 | // of the box. |
| 368 | |
| 369 | db::DPoint pstart = m_mouse_pos; |
| 370 | if (! bbox.contains (pstart)) { |
| 371 | pstart.set_x (std::max (pstart.x (), bbox.p1 ().x ())); |
| 372 | pstart.set_x (std::min (pstart.x (), bbox.p2 ().x ())); |
| 373 | pstart.set_y (std::max (pstart.y (), bbox.p1 ().y ())); |
| 374 | pstart.set_y (std::min (pstart.y (), bbox.p2 ().y ())); |
| 375 | } |
| 376 | |
| 377 | return handle_click (pstart, 0, drag_transient, trans_holder.release ()); |
| 378 | } |
| 379 | |
| 380 | void |
| 381 | MoveService::finish_move () |
no test coverage detected