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

@@ -559,7 +559,7 @@ void LinkGraphLegendWindow::DrawWidget(const Rect &r, int widget) const
}
}
bool LinkGraphLegendWindow::OnHoverCommon(Point pt, int widget, TooltipCloseCondition close_cond)
bool LinkGraphLegendWindow::OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond)
{
if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) {
if (this->IsWidgetDisabled(widget)) {
@@ -584,19 +584,6 @@ bool LinkGraphLegendWindow::OnHoverCommon(Point pt, int widget, TooltipCloseCond
return false;
}
void LinkGraphLegendWindow::OnHover(Point pt, int widget)
{
this->OnHoverCommon(pt, widget, TCC_HOVER);
}
bool LinkGraphLegendWindow::OnRightClick(Point pt, int widget)
{
if (_settings_client.gui.hover_delay_ms == 0) {
return this->OnHoverCommon(pt, widget, TCC_RIGHT_CLICK);
}
return false;
}
/**
* Update the overlay with the new company selection.
*/

View File

@@ -106,8 +106,7 @@ public:
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize);
virtual void DrawWidget(const Rect &r, int widget) const;
virtual void OnHover(Point pt, int widget);
virtual bool OnRightClick(Point pt, int widget);
virtual bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond);
virtual void OnClick(Point pt, int widget, int click_count);
virtual void OnInvalidateData(int data = 0, bool gui_scope = true);
@@ -116,7 +115,6 @@ private:
void UpdateOverlayCompanies();
void UpdateOverlayCargoes();
bool OnHoverCommon(Point pt, int widget, TooltipCloseCondition close_cond);
};
#endif /* LINKGRAPH_GUI_H */