mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r24595) -Change [FS#5168]: Make the group GUI drag&drop highlighting behave more intelligible. (based on work by Juanjo)
This commit is contained in:
parent
7e9aa98898
commit
1ffa7d4488
|
@ -207,11 +207,13 @@ private:
|
||||||
*/
|
*/
|
||||||
void DrawGroupInfo(int y, int left, int right, GroupID g_id, bool protection = false) const
|
void DrawGroupInfo(int y, int left, int right, GroupID g_id, bool protection = false) const
|
||||||
{
|
{
|
||||||
/* Highlight the group if a vehicle is dragged over it and it isn't selected. */
|
/* Highlight the group if a vehicle is dragged over it */
|
||||||
if (g_id == this->group_over && g_id != this->vli.index) {
|
if (g_id == this->group_over) {
|
||||||
GfxFillRect(left + WD_FRAMERECT_LEFT, y + WD_FRAMERECT_TOP, right - WD_FRAMERECT_RIGHT, y + this->tiny_step_height - WD_FRAMERECT_BOTTOM - WD_MATRIX_TOP, _colour_gradient[COLOUR_GREY][7]);
|
GfxFillRect(left + WD_FRAMERECT_LEFT, y + WD_FRAMERECT_TOP, right - WD_FRAMERECT_RIGHT, y + this->tiny_step_height - WD_FRAMERECT_BOTTOM - WD_MATRIX_TOP, _colour_gradient[COLOUR_GREY][7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_id == NEW_GROUP) return;
|
||||||
|
|
||||||
/* draw the selected group in white, else we draw it in black */
|
/* draw the selected group in white, else we draw it in black */
|
||||||
TextColour colour = g_id == this->vli.index ? TC_WHITE : TC_BLACK;
|
TextColour colour = g_id == this->vli.index ? TC_WHITE : TC_BLACK;
|
||||||
const GroupStatistics &stats = GroupStatistics::Get(this->vli.company, g_id, this->vli.vtype);
|
const GroupStatistics &stats = GroupStatistics::Get(this->vli.company, g_id, this->vli.vtype);
|
||||||
|
@ -509,6 +511,9 @@ public:
|
||||||
|
|
||||||
y1 += this->tiny_step_height;
|
y1 += this->tiny_step_height;
|
||||||
}
|
}
|
||||||
|
if (this->group_sb->GetPosition() + this->group_sb->GetCapacity() > this->groups.Length()) {
|
||||||
|
DrawGroupInfo(y1, r.left, r.right, NEW_GROUP);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,7 +629,6 @@ public:
|
||||||
virtual void OnDragDrop(Point pt, int widget)
|
virtual void OnDragDrop(Point pt, int widget)
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_GL_ALL_VEHICLES: // All vehicles
|
|
||||||
case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles
|
case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles
|
||||||
DoCommandP(0, DEFAULT_GROUP, this->vehicle_sel | (_ctrl_pressed ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE));
|
DoCommandP(0, DEFAULT_GROUP, this->vehicle_sel | (_ctrl_pressed ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE));
|
||||||
|
|
||||||
|
@ -747,25 +751,20 @@ public:
|
||||||
/* A vehicle is dragged over... */
|
/* A vehicle is dragged over... */
|
||||||
GroupID new_group_over = INVALID_GROUP;
|
GroupID new_group_over = INVALID_GROUP;
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_GL_ALL_VEHICLES: // ... the 'all' group.
|
|
||||||
/* Moving a vehicle from the all group to the default group
|
|
||||||
* is a no-op, so do not highlight then. */
|
|
||||||
if (!IsDefaultGroupID(Vehicle::Get(vehicle_sel)->group_id)) new_group_over = ALL_GROUP;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WID_GL_DEFAULT_VEHICLES: // ... the 'default' group.
|
case WID_GL_DEFAULT_VEHICLES: // ... the 'default' group.
|
||||||
/* Moving a vehicle from the default group to the all group
|
new_group_over = DEFAULT_GROUP;
|
||||||
* is a no-op, so do not highlight then. */
|
|
||||||
if (!IsDefaultGroupID(Vehicle::Get(vehicle_sel)->group_id)) new_group_over = DEFAULT_GROUP;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GL_LIST_GROUP: { // ... the list of custom groups.
|
case WID_GL_LIST_GROUP: { // ... the list of custom groups.
|
||||||
uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height);
|
uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height);
|
||||||
if (id_g < this->groups.Length()) new_group_over = this->groups[id_g]->index;
|
new_group_over = id_g >= this->groups.Length() ? NEW_GROUP : this->groups[id_g]->index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Do not highlight when dragging over the current group */
|
||||||
|
if (Vehicle::Get(vehicle_sel)->group_id == new_group_over) new_group_over = INVALID_GROUP;
|
||||||
|
|
||||||
/* Mark widgets as dirty if the group changed. */
|
/* Mark widgets as dirty if the group changed. */
|
||||||
if (new_group_over != this->group_over) {
|
if (new_group_over != this->group_over) {
|
||||||
this->DirtyHighlightedGroupWidget();
|
this->DirtyHighlightedGroupWidget();
|
||||||
|
|
Loading…
Reference in New Issue