mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Fix selection after expand/collapse group
This commit is contained in:
@@ -63,15 +63,26 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
//if didn't click on item, see if clicked on group header
|
//if didn't click on item, see if clicked on group header
|
||||||
if (groupBy != null) {
|
if (groupBy != null) {
|
||||||
Point point = e.getPoint();
|
Point point = e.getPoint();
|
||||||
|
boolean collapsedChanged = false;
|
||||||
for (Group group : groups) {
|
for (Group group : groups) {
|
||||||
if (group.getBounds().contains(point)) {
|
if (!collapsedChanged && group.getBounds().contains(point)) {
|
||||||
if (point.y < group.getTop() + GROUP_HEADER_HEIGHT) {
|
if (point.y < group.getTop() + GROUP_HEADER_HEIGHT) {
|
||||||
group.isCollapsed = !group.isCollapsed;
|
group.isCollapsed = !group.isCollapsed;
|
||||||
updateLayout();
|
updateLayout();
|
||||||
|
collapsedChanged = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (collapsedChanged) {
|
||||||
|
//if found group to expand/collapse, select next visible item starting at beginning of group
|
||||||
|
if (!group.isCollapsed && !group.items.isEmpty()) {
|
||||||
|
setSelectedIndex(group.piles.get(0).items.get(0).index);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -218,6 +229,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateLayout() {
|
private void updateLayout() {
|
||||||
|
clearSelection(); //must clear selection since indices and visible items will be changing
|
||||||
orderedItems.clear();
|
orderedItems.clear();
|
||||||
|
|
||||||
int x, groupY;
|
int x, groupY;
|
||||||
|
|||||||
Reference in New Issue
Block a user