diff options
author | peter1138 <peter1138@openttd.org> | 2019-03-20 02:13:36 +0000 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2019-03-20 23:00:32 +0000 |
commit | f5f33da126a072ddacfdb8e5887054f4225d4d86 (patch) | |
tree | 8980086c1c703ff55136a13ca2fbf204d95b22f8 /src/window_gui.h | |
parent | 4da83d2f661691b40eb53591d2a998596f5d16a0 (diff) | |
download | openttd-f5f33da126a072ddacfdb8e5887054f4225d4d86.tar.xz |
Codechange: Implement OnTooltip event for custom window tooltips.
This avoids windows from needing to know or care about tooltip delay settings.
Diffstat (limited to 'src/window_gui.h')
-rw-r--r-- | src/window_gui.h | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/window_gui.h b/src/window_gui.h index 05a2b3c5a..b2bba675b 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -265,6 +265,13 @@ struct ViewportData : ViewPort { struct QueryString; +/* misc_gui.cpp */ +enum TooltipCloseCondition { + TCC_RIGHT_CLICK, + TCC_HOVER, + TCC_NONE, +}; + /** * Data structure for an opened window */ @@ -629,13 +636,21 @@ public: virtual bool OnRightClick(Point pt, int widget) { return false; } /** - * The mouse is hovering over a widget in the window, perform an action for it, like opening a custom tooltip. + * The mouse is hovering over a widget in the window, perform an action for it. * @param pt The point where the mouse is hovering. * @param widget The widget where the mouse is hovering. */ virtual void OnHover(Point pt, int widget) {} /** + * Event to display a custom tooltip. + * @param pt The point where the mouse is located. + * @param widget The widget where the mouse is located. + * @return True if the event is handled, false if it is ignored. + */ + virtual bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) { return false; } + + /** * 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. @@ -870,13 +885,6 @@ Wcls *AllocateWindowDescFront(WindowDesc *desc, int window_number, bool return_e void RelocateAllWindows(int neww, int newh); -/* misc_gui.cpp */ -enum TooltipCloseCondition { - TCC_RIGHT_CLICK, - TCC_HOVER, - TCC_NONE, -}; - void GuiShowTooltips(Window *parent, StringID str, uint paramcount = 0, const uint64 params[] = NULL, TooltipCloseCondition close_tooltip = TCC_HOVER); /* widget.cpp */ |