1
0
Fork 0

Codechange: add and use GetToolTip instead of direct access

pull/13247/head
Rubidium 2025-01-03 10:09:36 +01:00 committed by rubidium42
parent f0a74fcabb
commit 56d4d3cc7a
3 changed files with 14 additions and 4 deletions

View File

@ -1154,6 +1154,15 @@ void NWidgetCore::SetToolTip(StringID tool_tip)
this->tool_tip = tool_tip;
}
/**
* Get the tool tip of the nested widget.
* @return The tool tip string.
*/
StringID NWidgetCore::GetToolTip() const
{
return this->tool_tip;
}
/**
* Set the text/image alignment of the nested widget.
* @param align Alignment to use.

View File

@ -377,6 +377,7 @@ public:
void SetSpriteTip(SpriteID sprite, StringID tool_tip) { this->SetDataTip(sprite, tool_tip); }
void SetMatrixDataTip(uint8_t cols, uint8_t rows, StringID tip) { this->SetDataTip(static_cast<uint32_t>((rows << MAT_ROW_START) | (cols << MAT_COL_START)), tip); }
void SetToolTip(StringID tool_tip);
StringID GetToolTip() const;
void SetTextStyle(TextColour colour, FontSize size);
void SetAlignment(StringAlignment align);

View File

@ -756,8 +756,8 @@ static void DispatchRightClickEvent(Window *w, int x, int y)
} else if (_settings_client.gui.right_click_wnd_close == RCC_YES_EXCEPT_STICKY && (w->flags & WF_STICKY) == 0 && (w->window_desc.flags & WDF_NO_CLOSE) == 0) {
/* Right-click close is enabled, but excluding sticky windows. */
w->Close();
} else if (_settings_client.gui.hover_delay_ms == 0 && !w->OnTooltip(pt, wid->index, TCC_RIGHT_CLICK) && wid->tool_tip != 0) {
GuiShowTooltips(w, wid->tool_tip, TCC_RIGHT_CLICK);
} else if (_settings_client.gui.hover_delay_ms == 0 && !w->OnTooltip(pt, wid->index, TCC_RIGHT_CLICK) && wid->GetToolTip() != STR_NULL) {
GuiShowTooltips(w, wid->GetToolTip(), TCC_RIGHT_CLICK);
}
}
@ -777,8 +777,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->index, TCC_HOVER) && wid->tool_tip != 0) {
GuiShowTooltips(w, wid->tool_tip, TCC_HOVER);
if (!w->OnTooltip(pt, wid->index, TCC_HOVER) && wid->GetToolTip() != STR_NULL) {
GuiShowTooltips(w, wid->GetToolTip(), TCC_HOVER);
return;
}