From 90780fd25bab45fb97304337f10b78c9210a7190 Mon Sep 17 00:00:00 2001 From: alberth Date: Thu, 23 Dec 2010 14:24:34 +0000 Subject: (svn r21608) -Codechange: Move diagnonal rectangle dragging detection completely to tile highlighting. --- src/viewport.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/viewport.cpp') diff --git a/src/viewport.cpp b/src/viewport.cpp index b0116e39e..cf58fccf5 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -2025,6 +2025,15 @@ static HighLightStyle GetAutorailHT(int x, int y) return HT_RAIL | _autorail_piece[x & TILE_UNIT_MASK][y & TILE_UNIT_MASK]; } +/** + * Is the user dragging a 'diagonal rectangle'? + * @return User is dragging a rotated rectangle. + */ +bool TileHighlightData::IsDraggingDiagonal() +{ + return (this->place_mode & HT_DIAGONAL) != 0 && _ctrl_pressed && _left_button_down; +} + /** * Updates tile highlighting for all cases. * Uses _thd.selstart and _thd.selend and _thd.place_mode (set elsewhere) to determine _thd.pos and _thd.size @@ -2049,7 +2058,7 @@ void UpdateTileSelection() x1 &= ~TILE_UNIT_MASK; y1 &= ~TILE_UNIT_MASK; - if (IsDraggingDiagonal()) { + if (_thd.IsDraggingDiagonal()) { new_diagonal = true; } else { if (x1 >= x2) Swap(x1, x2); @@ -2724,7 +2733,7 @@ calc_heightdiff_single_direction:; /* If dragging an area (eg dynamite tool) and it is actually a single * row/column, change the type to 'line' to get proper calculation for height */ style = (HighLightStyle)_thd.next_drawstyle; - if (IsDraggingDiagonal()) { + if (_thd.IsDraggingDiagonal()) { /* Determine the "area" of the diagonal dragged selection. * We assume the area is the number of tiles along the X * edge and the number of tiles along the Y edge. However, -- cgit v1.2.3-54-g00ecf