diff -r 0b5da310ed15 src/order_gui.cpp --- a/src/order_gui.cpp Sat May 22 17:17:27 2010 +0200 +++ b/src/order_gui.cpp Sat May 22 18:31:21 2010 +0200 @@ -459,6 +459,7 @@ }; int selected_order; + OrderID order_over; ///< Order over which another order is dragged, INVALID_ORDER if none OrderPlaceObjectState goto_type; const Vehicle *vehicle; ///< Vehicle owning the orders being displayed and manipulated. @@ -689,6 +690,7 @@ this->InitNested(desc, v->index); this->selected_order = -1; + this->order_over = INVALID_ORDER; this->owner = v->owner; if (_settings_client.gui.quick_goto && v->owner == _local_company) { @@ -949,6 +951,12 @@ /* Don't draw anything if it extends past the end of the window. */ if (!this->vscroll.IsVisible(i)) break; + if (i != this->selected_order && i == this->order_over) { + /* Highlight dragged order destination. */ + uint top = (this->order_over < this->selected_order ? y : y + line_height); + GfxFillRect(r.left + WD_FRAMETEXT_LEFT, top - 1, r.right - WD_FRAMETEXT_RIGHT, top + 1, _colour_gradient[COLOUR_GREY][7]); + } + DrawOrderString(this->vehicle, order, i, y, i == this->selected_order, false, r.left + WD_FRAMETEXT_LEFT, middle, r.right - WD_FRAMETEXT_RIGHT); y += line_height; @@ -1184,6 +1192,12 @@ } ResetObjectToPlace(); + + if (this->order_over != INVALID_ORDER) { + /* End of drag-and-drop, hide dragged order destination highlight. */ + this->order_over = INVALID_ORDER; + this->SetWidgetDirty(ORDER_WIDGET_ORDER_LIST); + } } virtual EventState OnKeyPress(uint16 key, uint16 keycode) @@ -1264,6 +1278,26 @@ } } + virtual void OnMouseDrag(Point pt, int widget) + { + if (this->selected_order != -1 && widget == ORDER_WIDGET_ORDER_LIST) { + /* An order is dragged… */ + OrderID from_order = this->OrderGetSel(); + OrderID to_order = this->GetOrderFromPt(pt.y); + uint num_orders = this->vehicle->GetNumOrders(); + + if (from_order != INVALID_ORDER && from_order <= num_orders) { + if (to_order != INVALID_ORDER && to_order <= num_orders) { // …over an existing order. + this->order_over = to_order; + this->SetWidgetDirty(widget); + } else if (from_order != to_order && this->order_over != INVALID_ORDER) { // …outside of the order list. + this->order_over = INVALID_ORDER; + this->SetWidgetDirty(widget); + } + } + } + } + virtual void OnResize() { /* Update the scroll bar */