Mercurial > hg > openttd
changeset 15251:c75bfd4a1143 draft
(svn r19886) -Add [FS#3705]: Perform window callback during mouse dragging for the purpose of highlighting the destination (sbr).
author | alberth <alberth@openttd.org> |
---|---|
date | Sun, 23 May 2010 14:53:39 +0000 |
parents | 91e0e573c069 |
children | f422122b47a6 |
files | src/window.cpp src/window_gui.h |
diffstat | 2 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/window.cpp +++ b/src/window.cpp @@ -1382,6 +1382,24 @@ return false; } +static bool HandleMouseDrag() +{ + if (_special_mouse_mode != WSM_DRAGDROP) return true; + if (!_left_button_down || (_cursor.delta.x == 0 && _cursor.delta.y == 0)) return true; + + Window *w = GetCallbackWnd(); + + if (w != NULL) { + /* Send an event in client coordinates. */ + Point pt; + pt.x = _cursor.pos.x - w->left; + pt.y = _cursor.pos.y - w->top; + w->OnMouseDrag(pt, GetWidgetFromPos(w, pt.x, pt.y)); + } + + return false; +} + static bool HandleMouseOver() { Window *w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y); @@ -2057,6 +2075,7 @@ UpdateTileSelection(); if (!VpHandlePlaceSizingDrag()) return; + if (!HandleMouseDrag()) return; if (!HandleDragDrop()) return; if (!HandleWindowDragging()) return; if (!HandleScrollbarScrolling()) return;
--- a/src/window_gui.h +++ b/src/window_gui.h @@ -657,6 +657,13 @@ virtual void OnRightClick(Point pt, int widget) {} /** + * An 'object' is being dragged at the provided position, highlight the target if possible. + * @param pt The point inside the window that the mouse hovers over. + * @param widget The widget the mouse hovers over. + */ + virtual void OnMouseDrag(Point pt, int widget) {} + + /** * A dragged 'object' has been released. * @param pt the point inside the window where the release took place. * @param widget the widget where the release took place.