Codechange: make TooltipCloseCondition scoped

This commit is contained in:
Rubidium
2026-06-14 20:39:03 +02:00
committed by rubidium42
parent 52793c0e8b
commit 760cd803c5
5 changed files with 17 additions and 17 deletions
+2 -2
View File
@@ -917,9 +917,9 @@ struct DepotWindow : Window {
/* Show tooltip window */
if (whole_chain) {
GuiShowTooltips(this, GetEncodedString(STR_DEPOT_VEHICLE_TOOLTIP_CHAIN, num, details), TCC_RIGHT_CLICK);
GuiShowTooltips(this, GetEncodedString(STR_DEPOT_VEHICLE_TOOLTIP_CHAIN, num, details), TooltipCloseCondition::RightClick);
} else {
GuiShowTooltips(this, GetEncodedString(STR_DEPOT_VEHICLE_TOOLTIP, v->engine_type, details), TCC_RIGHT_CLICK);
GuiShowTooltips(this, GetEncodedString(STR_DEPOT_VEHICLE_TOOLTIP, v->engine_type, details), TooltipCloseCondition::RightClick);
}
return true;
+4 -4
View File
@@ -668,11 +668,11 @@ struct TooltipsWindow : public Window
/* We can show tooltips while dragging tools. These are shown as long as
* we are dragging the tool. Normal tooltips work with hover or rmb. */
switch (this->close_cond) {
case TCC_RIGHT_CLICK: if (!_right_button_down) this->Close(); break;
case TCC_HOVER: if (!_mouse_hovering) this->Close(); break;
case TCC_NONE: break;
case TooltipCloseCondition::RightClick: if (!_right_button_down) this->Close(); break;
case TooltipCloseCondition::Hover: if (!_mouse_hovering) this->Close(); break;
case TooltipCloseCondition::None: break;
case TCC_EXIT_VIEWPORT: {
case TooltipCloseCondition::ExitViewport: {
Window *w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
if (w == nullptr || IsPtInWindowViewport(w, _cursor.pos.x, _cursor.pos.y) == nullptr) this->Close();
break;
+1 -1
View File
@@ -2789,7 +2789,7 @@ void UpdateTileSelection()
static inline void ShowMeasurementTooltips(EncodedString &&text)
{
if (!_settings_client.gui.measure_tooltip) return;
GuiShowTooltips(_thd.GetCallbackWnd(), std::move(text), TCC_EXIT_VIEWPORT);
GuiShowTooltips(_thd.GetCallbackWnd(), std::move(text), TooltipCloseCondition::ExitViewport);
}
static void HideMeasurementTooltips()
+4 -4
View File
@@ -782,8 +782,8 @@ static void DispatchRightClickEvent(Window *w, int x, int y)
} else if (_settings_client.gui.right_click_wnd_close == RightClickClose::YesExceptSticky && !w->flags.Test(WindowFlag::Sticky) && !w->window_desc.flags.Test(WindowDefaultFlag::NoClose)) {
/* Right-click close is enabled, but excluding sticky windows. */
w->Close();
} else if (_settings_client.gui.hover_delay_ms == 0 && !w->OnTooltip(pt, wid->GetIndex(), TCC_RIGHT_CLICK) && wid->GetToolTip() != STR_NULL) {
GuiShowTooltips(w, GetEncodedString(wid->GetToolTip()), TCC_RIGHT_CLICK);
} else if (_settings_client.gui.hover_delay_ms == 0 && !w->OnTooltip(pt, wid->GetIndex(), TooltipCloseCondition::RightClick) && wid->GetToolTip() != STR_NULL) {
GuiShowTooltips(w, GetEncodedString(wid->GetToolTip()), TooltipCloseCondition::RightClick);
}
}
@@ -803,8 +803,8 @@ static void DispatchHoverEvent(Window *w, int x, int y)
Point pt = { x, y };
/* Show the tooltip if there is any */
if (!w->OnTooltip(pt, wid->GetIndex(), TCC_HOVER) && wid->GetToolTip() != STR_NULL) {
GuiShowTooltips(w, GetEncodedString(wid->GetToolTip()), TCC_HOVER);
if (!w->OnTooltip(pt, wid->GetIndex(), TooltipCloseCondition::Hover) && wid->GetToolTip() != STR_NULL) {
GuiShowTooltips(w, GetEncodedString(wid->GetToolTip()), TooltipCloseCondition::Hover);
return;
}
+6 -6
View File
@@ -259,12 +259,12 @@ struct ViewportData : Viewport {
struct QueryString;
/* misc_gui.cpp */
enum TooltipCloseCondition : uint8_t {
TCC_RIGHT_CLICK,
TCC_HOVER,
TCC_NONE,
TCC_EXIT_VIEWPORT,
/* Automatic closing conditions for tooltips. */
enum class TooltipCloseCondition : uint8_t {
RightClick, ///< Close the tooltip when releasing the right mouse button.
Hover, ///< Close the tooltip when stopping to hovering, i.e. moving the mouse.
None, ///< Do not automatically close the tooltip.
ExitViewport, ///< Close the tooltip when leaving the viewport.
};
/**