Codechange: Implement OnTooltip event for custom window tooltips.

This avoids windows from needing to know or care about tooltip delay settings.
This commit is contained in:
peter1138
2019-03-20 02:13:36 +00:00
committed by PeterN
parent 4da83d2f66
commit f5f33da126
4 changed files with 24 additions and 29 deletions

View File

@@ -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,12 +636,20 @@ 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.
@@ -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 */