Fix viewport drag tooltips not being removed when dragging over other windows

pull/238/head
Jonathan G Rennison 3 years ago
parent 638d4cdbe0
commit e3d9cce3ae

@ -842,6 +842,12 @@ struct TooltipsWindow : public Window
this->delete_next_mouse_loop = true;
}
break;
case TCC_EXIT_VIEWPORT: {
Window *w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
if (w == nullptr || IsPtInWindowViewport(w, _cursor.pos.x, _cursor.pos.y) == nullptr) this->delete_next_mouse_loop = true;
break;
}
}
}
};

@ -4869,7 +4869,7 @@ static int CalcHeightdiff(HighLightStyle style, uint distance, TileIndex start_t
return (int)(h1 - h0) * TILE_HEIGHT_STEP;
}
static void ShowLengthMeasurement(HighLightStyle style, TileIndex start_tile, TileIndex end_tile, TooltipCloseCondition close_cond = TCC_NONE, bool show_single_tile_length = false)
static void ShowLengthMeasurement(HighLightStyle style, TileIndex start_tile, TileIndex end_tile, TooltipCloseCondition close_cond = TCC_EXIT_VIEWPORT, bool show_single_tile_length = false)
{
static const StringID measure_strings_length[] = {STR_NULL, STR_MEASURE_LENGTH, STR_MEASURE_LENGTH_HEIGHTDIFF};
@ -5353,7 +5353,7 @@ static HighLightStyle CalcPolyrailDrawstyle(Point pt, bool dragging)
}
HighLightStyle ret = HT_LINE | (HighLightStyle)TrackdirToTrack(seldir);
ShowLengthMeasurement(ret, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), TCC_NONE, true);
ShowLengthMeasurement(ret, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), TCC_EXIT_VIEWPORT, true);
return ret;
}
@ -5475,7 +5475,7 @@ calc_heightdiff_single_direction:;
params[index++] = GetTileMaxZ(t1) * TILE_HEIGHT_STEP;
params[index++] = heightdiff;
//Show always the measurement tooltip
GuiShowTooltips(_thd.GetCallbackWnd(),STR_MEASURE_DIST_HEIGHTDIFF, index, params, TCC_NONE);
GuiShowTooltips(_thd.GetCallbackWnd(),STR_MEASURE_DIST_HEIGHTDIFF, index, params, TCC_EXIT_VIEWPORT);
break;
}

@ -285,6 +285,7 @@ enum TooltipCloseCondition {
TCC_NONE,
TCC_HOVER_VIEWPORT,
TCC_NEXT_LOOP,
TCC_EXIT_VIEWPORT,
};
struct WindowBase {

Loading…
Cancel
Save