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

This commit is contained in:
Jonathan G Rennison
2021-04-05 12:30:58 +01:00
parent 638d4cdbe0
commit e3d9cce3ae
3 changed files with 10 additions and 3 deletions

View File

@@ -842,6 +842,12 @@ struct TooltipsWindow : public Window
this->delete_next_mouse_loop = true; this->delete_next_mouse_loop = true;
} }
break; 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;
}
} }
} }
}; };

View File

@@ -4869,7 +4869,7 @@ static int CalcHeightdiff(HighLightStyle style, uint distance, TileIndex start_t
return (int)(h1 - h0) * TILE_HEIGHT_STEP; 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}; 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); 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; return ret;
} }
@@ -5475,7 +5475,7 @@ calc_heightdiff_single_direction:;
params[index++] = GetTileMaxZ(t1) * TILE_HEIGHT_STEP; params[index++] = GetTileMaxZ(t1) * TILE_HEIGHT_STEP;
params[index++] = heightdiff; params[index++] = heightdiff;
//Show always the measurement tooltip //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; break;
} }

View File

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