Changeset - r15461:b891e28db626
[Not reviewed]
master
0 3 0
terkhen - 14 years ago 2010-07-11 10:58:55
terkhen@openttd.org
(svn r20120) -Feature [FS#3913]: Tooltips are shown by hovering the mouse over a widget instead of by right clicking on it.
3 files changed with 22 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/depot_gui.cpp
Show inline comments
 
@@ -842,10 +842,10 @@ struct DepotWindow : 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);
 
			GuiShowTooltips(whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
 
		} else {
 
			/* Show tooltip help */
 
			GuiShowTooltips(STR_DEPOT_TRAIN_LIST_TOOLTIP + this->type);
 
			GuiShowTooltips(STR_DEPOT_TRAIN_LIST_TOOLTIP + this->type, TCC_RIGHT_CLICK);
 
		}
 
	}
 

	
src/window.cpp
Show inline comments
 
@@ -384,6 +384,23 @@ static void DispatchRightClickEvent(Wind
 
{
 
	NWidgetCore *wid = w->nested_root->GetWidgetFromPos(x, y);
 

	
 
	/* No widget to handle, or the window is not interested in it. */
 
	if (wid == NULL || wid->index < 0) return;
 

	
 
	Point pt = { x, y };
 
	w->OnRightClick(pt, wid->index);
 
}
 

	
 
/**
 
 * Dispatch hover of the mouse over a window.
 
 * @param w Window to dispatch event in.
 
 * @param x X coordinate of the click.
 
 * @param y Y coordinate of the click.
 
 */
 
static void DispatchHoverEvent(Window *w, int x, int y)
 
{
 
	NWidgetCore *wid = w->nested_root->GetWidgetFromPos(x, y);
 

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

	
 
@@ -392,12 +409,6 @@ static void DispatchRightClickEvent(Wind
 
		GuiShowTooltips(wid->tool_tip);
 
		return;
 
	}
 

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

	
 
	Point pt = { x, y };
 
	w->OnRightClick(pt, wid->index);
 
}
 

	
 
/**
 
@@ -2178,6 +2189,8 @@ static void MouseLoop(MouseClick click, 
 

	
 
				/* fallthough */
 
			case MC_RIGHT: DispatchRightClickEvent(w, x - w->left, y - w->top); break;
 

	
 
			case MC_HOVER: DispatchHoverEvent(w, x - w->left, y - w->top); break;
 
		}
 
	}
 
}
src/window_gui.h
Show inline comments
 
@@ -900,7 +900,7 @@ enum TooltipCloseCondition {
 
	TCC_HOVER,
 
};
 

	
 
void GuiShowTooltips(StringID str, uint paramcount = 0, const uint64 params[] = NULL, TooltipCloseCondition close_tooltip = TCC_RIGHT_CLICK);
 
void GuiShowTooltips(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);
0 comments (0 inline, 0 general)