diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 8601d7133b..be04b00b8e 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -86,7 +86,7 @@ struct BuildAirToolbarWindow : Window { { switch (widget) { case WID_AT_AIRPORT: - if (HandlePlacePushButton(this, WID_AT_AIRPORT, SPR_CURSOR_AIRPORT, HT_RECT)) { + if (HandlePlacePushButton(this, WID_AT_AIRPORT, SPR_CURSOR_AIRPORT, HT_RECT | HT_SCROLL_VIEWPORT)) { ShowBuildAirportPicker(this); this->last_user_action = widget; } diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index c163e7e3fe..f02702d3f4 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -139,7 +139,7 @@ struct BuildDocksToolbarWindow : Window { case WID_DT_DEPOT: // Build depot button if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; - if (HandlePlacePushButton(this, WID_DT_DEPOT, SPR_CURSOR_SHIP_DEPOT, HT_RECT)) ShowBuildDocksDepotPicker(this); + if (HandlePlacePushButton(this, WID_DT_DEPOT, SPR_CURSOR_SHIP_DEPOT, HT_RECT | HT_SCROLL_VIEWPORT)) ShowBuildDocksDepotPicker(this); break; case WID_DT_STATION: // Build station button @@ -149,7 +149,7 @@ struct BuildDocksToolbarWindow : Window { case WID_DT_BUOY: // Build buoy button if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; - HandlePlacePushButton(this, WID_DT_BUOY, SPR_CURSOR_BUOY, HT_RECT); + HandlePlacePushButton(this, WID_DT_BUOY, SPR_CURSOR_BUOY, HT_RECT | HT_SCROLL_VIEWPORT); break; case WID_DT_RIVER: // Build river button (in scenario editor) diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 4d04adb36d..2f75ade816 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -580,9 +580,9 @@ private: assert(type > OPOS_NONE && type < OPOS_END); static const HighLightStyle goto_place_style[OPOS_END - 1] = { - HT_RECT | HT_VEHICLE, // OPOS_GOTO + HT_RECT | HT_VEHICLE | HT_SCROLL_VIEWPORT, // OPOS_GOTO HT_NONE, // OPOS_CONDITIONAL - HT_VEHICLE, // OPOS_SHARE + HT_VEHICLE | HT_SCROLL_VIEWPORT, // OPOS_SHARE }; SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, goto_place_style[type - 1], this); this->goto_type = type; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index c407585432..c406965faf 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -520,7 +520,7 @@ struct BuildRailToolbarWindow : Window { break; case WID_RAT_BUILD_DEPOT: - if (HandlePlacePushButton(this, WID_RAT_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, HT_RECT)) { + if (HandlePlacePushButton(this, WID_RAT_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, HT_RECT | HT_SCROLL_VIEWPORT)) { ShowBuildTrainDepotPicker(this); this->last_user_action = widget; } @@ -529,7 +529,7 @@ struct BuildRailToolbarWindow : Window { case WID_RAT_BUILD_WAYPOINT: this->last_user_action = widget; _waypoint_count = StationClass::Get(STAT_CLASS_WAYP)->GetSpecCount(); - if (HandlePlacePushButton(this, WID_RAT_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, HT_RECT) && _waypoint_count > 1) { + if (HandlePlacePushButton(this, WID_RAT_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, HT_RECT | HT_SCROLL_VIEWPORT) && _waypoint_count > 1) { ShowBuildWaypointPicker(this); } break; diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 13851e1027..c82bf54f91 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -406,7 +406,7 @@ struct BuildRoadToolbarWindow : Window { case WID_ROT_DEPOT: if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return; - if (HandlePlacePushButton(this, WID_ROT_DEPOT, SPR_CURSOR_ROAD_DEPOT, HT_RECT)) { + if (HandlePlacePushButton(this, WID_ROT_DEPOT, SPR_CURSOR_ROAD_DEPOT, HT_RECT | HT_SCROLL_VIEWPORT)) { ShowRoadDepotPicker(this); this->last_started_action = widget; } diff --git a/src/tilehighlight_type.h b/src/tilehighlight_type.h index 3d64248dff..207f865a35 100644 --- a/src/tilehighlight_type.h +++ b/src/tilehighlight_type.h @@ -28,6 +28,7 @@ enum HighLightStyle { HT_RAIL = 0x080, ///< autorail (one piece), lower bits: direction HT_VEHICLE = 0x100, ///< vehicle is accepted as target as well (bitmask) HT_DIAGONAL = 0x200, ///< Also allow 'diagonal rectangles'. Only usable in combination with #HT_RECT or #HT_POINT. + HT_SCROLL_VIEWPORT = 0x400, ///< Allow scrolling viewport with left mouse button, this disables drag&drop, use only when selection cannot grow. HT_DRAG_MASK = 0x0F8, ///< Mask for the tile drag-type modes. /* lower bits (used with HT_LINE and HT_RAIL): diff --git a/src/viewport.cpp b/src/viewport.cpp index 8116ba014f..37a73fb258 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1953,7 +1953,9 @@ bool HandleViewportClicked(const ViewPort *vp, int x, int y) { if (_move_pressed) return false; - if ((_thd.place_mode & HT_DRAG_MASK) != HT_NONE) { + // Allow scrolling viewport with mouse even in selection mode, + // unless we select line or area, or perform drag&drop + if ((_thd.place_mode & HT_DRAG_MASK) != HT_NONE && !(_thd.place_mode & HT_SCROLL_VIEWPORT)) { PlaceObject(); return true; } @@ -1971,6 +1973,11 @@ bool HandleViewportMouseUp(const ViewPort *vp, int x, int y) if (v != NULL && VehicleClicked(v)) return true; } + if ((_thd.place_mode & HT_DRAG_MASK) != HT_NONE) { + PlaceObject(); + return true; + } + if (CheckClickOnTown(vp, x, y)) return true; if (CheckClickOnStation(vp, x, y)) return true; if (CheckClickOnSign(vp, x, y)) return true; diff --git a/src/window.cpp b/src/window.cpp index 8e6883d303..b69508783c 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -2913,6 +2913,7 @@ static void MouseLoop(MouseClick click, int mousewheel) _scrolling_viewport = true; _cursor.fix_at = false; } else { + // Viewport already clicked, prevent sending same event on mouse-up _left_button_dragged = true; } mouse_down_on_viewport = true;