Changeset - r16734:e078163a5383
[Not reviewed]
master
0 6 0
rubidium - 14 years ago 2010-12-12 14:14:26
rubidium@openttd.org
(svn r21477) -Fix [FS#4300]: tooltips were removed when their related window got closed
6 files changed with 12 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/depot_gui.cpp
Show inline comments
 
@@ -832,13 +832,13 @@ struct DepotWindow : Window {
 
		}
 

	
 
		/* Show tooltip window */
 
		uint64 args[2];
 
		args[0] = (whole_chain ? num : v->engine_type);
 
		args[1] = (uint64)(size_t)details;
 
		GuiShowTooltips(whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
 
		GuiShowTooltips(this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
 

	
 
		return true;
 
	}
 

	
 
	/**
 
	 * Clones a vehicle
src/industry_gui.cpp
Show inline comments
 
@@ -2561,24 +2561,24 @@ struct IndustryCargoesWindow : public Wi
 
				cid = fld->CargoLabelClickedAt(xy);
 
				break;
 
			}
 

	
 
			case CFT_INDUSTRY:
 
				if (fld->u.industry.ind_type < NUM_INDUSTRYTYPES && (this->ind_cargo >= NUM_INDUSTRYTYPES || fieldxy.x != 2)) {
 
					GuiShowTooltips(STR_INDUSTRY_CARGOES_INDUSTRY_TOOLTIP, 0, NULL, TCC_HOVER);
 
					GuiShowTooltips(this, STR_INDUSTRY_CARGOES_INDUSTRY_TOOLTIP, 0, NULL, TCC_HOVER);
 
				}
 
				return;
 

	
 
			default:
 
				break;
 
		}
 
		if (cid != INVALID_CARGO && (this->ind_cargo < NUM_INDUSTRYTYPES || cid != this->ind_cargo - NUM_INDUSTRYTYPES)) {
 
			const CargoSpec *csp = CargoSpec::Get(cid);
 
			uint64 params[5];
 
			params[0] = csp->name;
 
			GuiShowTooltips(STR_INDUSTRY_CARGOES_CARGO_TOOLTIP, 1, params, TCC_HOVER);
 
			GuiShowTooltips(this, STR_INDUSTRY_CARGOES_CARGO_TOOLTIP, 1, params, TCC_HOVER);
 
		}
 
	}
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, ICW_PANEL);
src/misc_gui.cpp
Show inline comments
 
@@ -819,14 +819,15 @@ struct TooltipsWindow : public Window
 
{
 
	StringID string_id;               ///< String to display as tooltip.
 
	byte paramcount;                  ///< Number of string parameters in #string_id.
 
	uint64 params[5];                 ///< The string parameters.
 
	TooltipCloseCondition close_cond; ///< Condition for closing the window.
 

	
 
	TooltipsWindow(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip) : Window()
 
	TooltipsWindow(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip) : Window()
 
	{
 
		this->parent = parent;
 
		this->string_id = str;
 
		assert_compile(sizeof(this->params[0]) == sizeof(params[0]));
 
		assert(paramcount <= lengthof(this->params));
 
		memcpy(this->params, params, sizeof(this->params[0]) * paramcount);
 
		this->paramcount = paramcount;
 
		this->close_cond = close_tooltip;
 
@@ -898,24 +899,25 @@ struct TooltipsWindow : public Window
 
		}
 
	}
 
};
 

	
 
/**
 
 * Shows a tooltip
 
 * @param parent The window this tooltip is related to.
 
 * @param str String to be displayed
 
 * @param paramcount number of params to deal with
 
 * @param params (optional) up to 5 pieces of additional information that may be added to a tooltip
 
 * @param use_left_mouse_button close the tooltip when the left (true) or right (false) mousebutton is released
 
 */
 
void GuiShowTooltips(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip)
 
void GuiShowTooltips(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip)
 
{
 
	DeleteWindowById(WC_TOOLTIPS, 0);
 

	
 
	if (str == STR_NULL) return;
 

	
 
	new TooltipsWindow(str, paramcount, params, close_tooltip);
 
	new TooltipsWindow(parent, str, paramcount, params, close_tooltip);
 
}
 

	
 
/* Delete a character at the caret position in a text buf.
 
 * If backspace is set, delete the character before the caret,
 
 * else delete the character after it. */
 
static void DelChar(Textbuf *tb, bool backspace)
src/viewport.cpp
Show inline comments
 
@@ -2055,13 +2055,13 @@ void UpdateTileSelection()
 
 * @param params (optional) up to 5 pieces of additional information that may be added to a tooltip
 
 * @param close_cond Condition for closing this tooltip.
 
 */
 
static inline void ShowMeasurementTooltips(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_cond = TCC_LEFT_CLICK)
 
{
 
	if (!_settings_client.gui.measure_tooltip) return;
 
	GuiShowTooltips(str, paramcount, params, close_cond);
 
	GuiShowTooltips(FindWindowById(_thd.window_class, _thd.window_number), str, paramcount, params, close_cond);
 
}
 

	
 
/** highlighting tiles while only going over them with the mouse */
 
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
 
{
 
	_thd.select_method = method;
src/window.cpp
Show inline comments
 
@@ -403,13 +403,13 @@ static void DispatchRightClickEvent(Wind
 
	/* No widget to handle, or the window is not interested in it. */
 
	if (wid->index >= 0) {
 
		Point pt = { x, y };
 
		if (w->OnRightClick(pt, wid->index)) return;
 
	}
 

	
 
	if (_settings_client.gui.hover_delay == 0 && wid->tool_tip != 0) GuiShowTooltips(wid->tool_tip, 0, NULL, TCC_RIGHT_CLICK);
 
	if (_settings_client.gui.hover_delay == 0 && wid->tool_tip != 0) GuiShowTooltips(w, wid->tool_tip, 0, NULL, TCC_RIGHT_CLICK);
 
}
 

	
 
/**
 
 * Dispatch hover of the mouse over a window.
 
 * @param w Window to dispatch event in.
 
 * @param x X coordinate of the click.
 
@@ -421,13 +421,13 @@ static void DispatchHoverEvent(Window *w
 

	
 
	/* No widget to handle */
 
	if (wid == NULL) return;
 

	
 
	/* Show the tooltip if there is any */
 
	if (wid->tool_tip != 0) {
 
		GuiShowTooltips(wid->tool_tip);
 
		GuiShowTooltips(w, wid->tool_tip);
 
		return;
 
	}
 

	
 
	/* Widget has no index, so the window is not interested in it. */
 
	if (wid->index < 0) return;
 

	
src/window_gui.h
Show inline comments
 
@@ -789,13 +789,13 @@ void RelocateAllWindows(int neww, int ne
 
enum TooltipCloseCondition {
 
	TCC_RIGHT_CLICK,
 
	TCC_LEFT_CLICK,
 
	TCC_HOVER,
 
};
 

	
 
void GuiShowTooltips(StringID str, uint paramcount = 0, const uint64 params[] = NULL, TooltipCloseCondition close_tooltip = TCC_HOVER);
 
void GuiShowTooltips(Window *parent, StringID str, uint paramcount = 0, const uint64 params[] = NULL, TooltipCloseCondition close_tooltip = TCC_HOVER);
 

	
 
/* widget.cpp */
 
int GetWidgetFromPos(const Window *w, int x, int y);
 

	
 
/** Iterate over all windows */
 
#define FOR_ALL_WINDOWS_FROM_BACK_FROM(w, start)  for (w = start; w != NULL; w = w->z_front) if (w->window_class != WC_INVALID)
0 comments (0 inline, 0 general)