summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-07-11 11:00:09 +0000
committerterkhen <terkhen@openttd.org>2010-07-11 11:00:09 +0000
commit9cf9bb9b920c682515ddbd5ce56f1debe00ebd0d (patch)
treead192b72495c4ceae20a744bb81b8298cd1dcc48 /src
parent10fbb87823dd689844c93ce8b0d43a5098acdba9 (diff)
downloadopenttd-9cf9bb9b920c682515ddbd5ce56f1debe00ebd0d.tar.xz
(svn r20121) -Add: OnHover method for windows.
Diffstat (limited to 'src')
-rw-r--r--src/depot_gui.cpp5
-rw-r--r--src/window.cpp6
-rw-r--r--src/window_gui.h7
3 files changed, 14 insertions, 4 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 1ad79b12e..b3414d384 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -558,6 +558,7 @@ struct DepotWindow : Window {
this->GetWidget<NWidgetCore>(DEPOT_WIDGET_LOCATION)->tool_tip = STR_DEPOT_TRAIN_LOCATION_TOOLTIP + type;
this->GetWidget<NWidgetCore>(DEPOT_WIDGET_VEHICLE_LIST)->tool_tip = STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TOOLTIP + type;
this->GetWidget<NWidgetCore>(DEPOT_WIDGET_AUTOREPLACE)->tool_tip = STR_DEPOT_AUTOREPLACE_TRAIN_TOOLTIP + type;
+ this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->tool_tip = STR_DEPOT_TRAIN_LIST_TOOLTIP + this->type;
switch (type) {
default: NOT_REACHED();
@@ -843,13 +844,9 @@ struct DepotWindow : Window {
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);
- } else {
- /* Show tooltip help */
- GuiShowTooltips(STR_DEPOT_TRAIN_LIST_TOOLTIP + this->type, TCC_RIGHT_CLICK);
}
}
-
virtual void OnPlaceObject(Point pt, TileIndex tile)
{
const Vehicle *v = CheckMouseOverVehicle();
diff --git a/src/window.cpp b/src/window.cpp
index d34f138b6..0fae692df 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -409,6 +409,12 @@ static void DispatchHoverEvent(Window *w, int x, int y)
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->OnHover(pt, wid->index);
}
/**
diff --git a/src/window_gui.h b/src/window_gui.h
index f25ebba08..38129cbfc 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -658,6 +658,13 @@ public:
virtual void OnRightClick(Point pt, int widget) {}
/**
+ * The mouse is hovering over a widget in the window, perform an action for it, like opening a custom tooltip.
+ * @param pt The point where the mouse is hovering.
+ * @param widget The widget where the mouse is hovering.
+ */
+ virtual void OnHover(Point pt, int widget) {}
+
+ /**
* An 'object' is being dragged at the provided position, highlight the target if possible.
* @param pt The point inside the window that the mouse hovers over.
* @param widget The widget the mouse hovers over.