* Handle the mouse while dragging for placement/resizing. * @return State of handling the event. */
| 3454 | * @return State of handling the event. |
| 3455 | */ |
| 3456 | EventState VpHandlePlaceSizingDrag() |
| 3457 | { |
| 3458 | if (_special_mouse_mode != WSM_SIZING && _special_mouse_mode != WSM_DRAGGING) return ES_NOT_HANDLED; |
| 3459 | |
| 3460 | /* stop drag mode if the window has been closed */ |
| 3461 | Window *w = _thd.GetCallbackWnd(); |
| 3462 | if (w == nullptr) { |
| 3463 | ResetObjectToPlace(); |
| 3464 | return ES_HANDLED; |
| 3465 | } |
| 3466 | |
| 3467 | /* while dragging execute the drag procedure of the corresponding window (mostly VpSelectTilesWithMethod() ) */ |
| 3468 | if (_left_button_down) { |
| 3469 | if (_special_mouse_mode == WSM_DRAGGING) { |
| 3470 | /* Only register a drag event when the mouse moved. */ |
| 3471 | if (_thd.new_pos.x == _thd.selstart.x && _thd.new_pos.y == _thd.selstart.y) return ES_HANDLED; |
| 3472 | _thd.selstart.x = _thd.new_pos.x; |
| 3473 | _thd.selstart.y = _thd.new_pos.y; |
| 3474 | } |
| 3475 | |
| 3476 | w->OnPlaceDrag(_thd.select_method, _thd.select_proc, GetTileBelowCursor()); |
| 3477 | return ES_HANDLED; |
| 3478 | } |
| 3479 | |
| 3480 | /* Mouse button released. */ |
| 3481 | _special_mouse_mode = WSM_NONE; |
| 3482 | if (_special_mouse_mode == WSM_DRAGGING) return ES_HANDLED; |
| 3483 | |
| 3484 | /* Keep the selected tool, but reset it to the original mode. */ |
| 3485 | HighLightStyle others = _thd.place_mode & ~(HT_DRAG_MASK | HT_DIR_MASK); |
| 3486 | if ((_thd.next_drawstyle & HT_DRAG_MASK) == HT_RECT) { |
| 3487 | _thd.place_mode = HT_RECT | others; |
| 3488 | } else if (_thd.select_method & VPM_SIGNALDIRS) { |
| 3489 | _thd.place_mode = HT_RECT | others; |
| 3490 | } else if (_thd.select_method & VPM_RAILDIRS) { |
| 3491 | _thd.place_mode = (_thd.select_method & ~VPM_RAILDIRS) ? _thd.next_drawstyle : (HT_RAIL | others); |
| 3492 | } else { |
| 3493 | _thd.place_mode = HT_POINT | others; |
| 3494 | } |
| 3495 | SetTileSelectSize(1, 1); |
| 3496 | |
| 3497 | HideMeasurementTooltips(); |
| 3498 | w->OnPlaceMouseUp(_thd.select_method, _thd.select_proc, _thd.selend, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y)); |
| 3499 | |
| 3500 | return ES_HANDLED; |
| 3501 | } |
| 3502 | |
| 3503 | /** |
| 3504 | * Change the cursor and mouse click/drag handling to a mode for performing special operations like tile area selection, object placement, etc. |
no test coverage detected