summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2019-03-20 01:21:10 +0000
committerPeterN <peter@fuzzle.org>2019-03-20 23:00:32 +0000
commit4da83d2f661691b40eb53591d2a998596f5d16a0 (patch)
tree2e0910912bf2b08f8e713a4690a4bd11edfed2b8 /src
parente3c639a09f1d2251477f69496120d057dd8320a9 (diff)
downloadopenttd-4da83d2f661691b40eb53591d2a998596f5d16a0.tar.xz
Fix #7386: Measurement tooltip for tunnels, aqueducts & docks did not display or flickered.
Measurement tooltip was auto-closed as the hover/right-click test for tooltips was not satisfied in this case. This is fixed by keeping the tooltip visible and instead explicitly closing the tooltip when the PlaceObject is cancelled/completed.
Diffstat (limited to 'src')
-rw-r--r--src/misc_gui.cpp2
-rw-r--r--src/viewport.cpp18
-rw-r--r--src/window_gui.h2
3 files changed, 17 insertions, 5 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 149ebe717..061070a2b 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -724,8 +724,8 @@ struct TooltipsWindow : public Window
* we are dragging the tool. Normal tooltips work with hover or rmb. */
switch (this->close_cond) {
case TCC_RIGHT_CLICK: if (!_right_button_down) delete this; break;
- case TCC_LEFT_CLICK: if (!_left_button_down) delete this; break;
case TCC_HOVER: if (!_mouse_hovering) delete this; break;
+ case TCC_NONE: break;
}
}
};
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 8d9f4513e..729dfca7b 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -2508,12 +2508,17 @@ 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)
+static inline void ShowMeasurementTooltips(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_cond = TCC_NONE)
{
if (!_settings_client.gui.measure_tooltip) return;
GuiShowTooltips(_thd.GetCallbackWnd(), str, paramcount, params, close_cond);
}
+void HideMeasurementTooltips()
+{
+ DeleteWindowById(WC_TOOLTIPS, 0);
+}
+
/** highlighting tiles while only going over them with the mouse */
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
{
@@ -2569,7 +2574,11 @@ void VpSetPresizeRange(TileIndex from, TileIndex to)
_thd.next_drawstyle = HT_RECT;
/* show measurement only if there is any length to speak of */
- if (distance > 1) ShowMeasurementTooltips(STR_MEASURE_LENGTH, 1, &distance, TCC_HOVER);
+ if (distance > 1) {
+ ShowMeasurementTooltips(STR_MEASURE_LENGTH, 1, &distance);
+ } else {
+ HideMeasurementTooltips();
+ }
}
static void VpStartPreSizing()
@@ -3221,7 +3230,10 @@ void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowC
* this function might in some cases reset the newly set object to
* place or not properly reset the original selection. */
_thd.window_class = WC_INVALID;
- if (w != NULL) w->OnPlaceObjectAbort();
+ if (w != NULL) {
+ w->OnPlaceObjectAbort();
+ HideMeasurementTooltips();
+ }
}
/* Mark the old selection dirty, in case the selection shape or colour changes */
diff --git a/src/window_gui.h b/src/window_gui.h
index 0abf79cca..05a2b3c5a 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -873,8 +873,8 @@ void RelocateAllWindows(int neww, int newh);
/* misc_gui.cpp */
enum TooltipCloseCondition {
TCC_RIGHT_CLICK,
- TCC_LEFT_CLICK,
TCC_HOVER,
+ TCC_NONE,
};
void GuiShowTooltips(Window *parent, StringID str, uint paramcount = 0, const uint64 params[] = NULL, TooltipCloseCondition close_tooltip = TCC_HOVER);