Lower create group button when vehicle dragged over it
This commit is contained in:
@@ -1123,6 +1123,21 @@ public:
|
|||||||
this->group_sel = INVALID_GROUP;
|
this->group_sel = INVALID_GROUP;
|
||||||
this->group_over = INVALID_GROUP;
|
this->group_over = INVALID_GROUP;
|
||||||
this->SetWidgetDirty(WID_GL_LIST_VEHICLE);
|
this->SetWidgetDirty(WID_GL_LIST_VEHICLE);
|
||||||
|
this->SetVehicleDraggedOverCreateGroupButton(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetVehicleDraggedOverCreateGroupButton(bool dragged)
|
||||||
|
{
|
||||||
|
NWidgetCore *create_group = this->GetWidget<NWidgetCore>(WID_GL_CREATE_GROUP);
|
||||||
|
if (dragged && (create_group->type & WWB_PUSHBUTTON)) {
|
||||||
|
create_group->type = static_cast<WidgetType>(create_group->type & ~WWB_PUSHBUTTON);
|
||||||
|
create_group->SetLowered(true);
|
||||||
|
create_group->SetDirty(this);
|
||||||
|
} else if (!dragged && !(create_group->type & WWB_PUSHBUTTON)) {
|
||||||
|
create_group->type = static_cast<WidgetType>(create_group->type | WWB_PUSHBUTTON);
|
||||||
|
create_group->SetLowered(false);
|
||||||
|
create_group->SetDirty(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnMouseDrag(Point pt, int widget) override
|
void OnMouseDrag(Point pt, int widget) override
|
||||||
@@ -1131,6 +1146,8 @@ public:
|
|||||||
|
|
||||||
/* A vehicle is dragged over... */
|
/* A vehicle is dragged over... */
|
||||||
GroupID new_group_over = INVALID_GROUP;
|
GroupID new_group_over = INVALID_GROUP;
|
||||||
|
|
||||||
|
bool create_group_drag_over = false;
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_GL_DEFAULT_VEHICLES: // ... the 'default' group.
|
case WID_GL_DEFAULT_VEHICLES: // ... the 'default' group.
|
||||||
new_group_over = DEFAULT_GROUP;
|
new_group_over = DEFAULT_GROUP;
|
||||||
@@ -1141,7 +1158,14 @@ public:
|
|||||||
new_group_over = id_g >= this->groups.size() ? NEW_GROUP : this->groups[id_g]->index;
|
new_group_over = id_g >= this->groups.size() ? NEW_GROUP : this->groups[id_g]->index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WID_GL_CREATE_GROUP: {
|
||||||
|
if (this->vehicle_sel != INVALID_VEHICLE) create_group_drag_over = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->SetVehicleDraggedOverCreateGroupButton(create_group_drag_over);
|
||||||
|
|
||||||
/* Do not highlight when dragging over the current group */
|
/* Do not highlight when dragging over the current group */
|
||||||
if (this->vehicle_sel != INVALID_VEHICLE) {
|
if (this->vehicle_sel != INVALID_VEHICLE) {
|
||||||
|
Reference in New Issue
Block a user