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