mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Fix so toggling off And/Or removes filter below
This commit is contained in:
@@ -239,6 +239,17 @@ public class CardAdvancedFilter extends ItemFilter<PaperCard> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeNextFilter(Filter fromFilter) {
|
||||||
|
int index = scroller.indexOf(fromFilter);
|
||||||
|
if (index < scroller.getChildCount() - 1) {
|
||||||
|
Filter nextFilter = (Filter)scroller.getChildAt(index + 1);
|
||||||
|
fromFilter.btnAnd.setSelected(nextFilter.btnAnd.isSelected());
|
||||||
|
fromFilter.btnOr.setSelected(nextFilter.btnOr.isSelected());
|
||||||
|
scroller.remove(nextFilter);
|
||||||
|
scroller.revalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private enum FilterOption {
|
private enum FilterOption {
|
||||||
NONE("Filter...", null, null, -1, -1),
|
NONE("Filter...", null, null, -1, -1),
|
||||||
CMC("CMC", ComparableOp.NUMBER_OPS, ComparableOp.EQUALS, 0, 20),
|
CMC("CMC", ComparableOp.NUMBER_OPS, ComparableOp.EQUALS, 0, 20),
|
||||||
@@ -297,16 +308,26 @@ public class CardAdvancedFilter extends ItemFilter<PaperCard> {
|
|||||||
btnAnd = add(new FLabel.Builder().align(HAlignment.CENTER).text("AND").selectable().command(new FEventHandler() {
|
btnAnd = add(new FLabel.Builder().align(HAlignment.CENTER).text("AND").selectable().command(new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
|
if (btnAnd.isSelected()) {
|
||||||
btnOr.setSelected(false);
|
btnOr.setSelected(false);
|
||||||
addNewFilter(Filter.this);
|
addNewFilter(Filter.this);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
removeNextFilter(Filter.this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}).build());
|
}).build());
|
||||||
btnOr = add(new FLabel.Builder().align(HAlignment.CENTER).text("OR").selectable().command(new FEventHandler() {
|
btnOr = add(new FLabel.Builder().align(HAlignment.CENTER).text("OR").selectable().command(new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
|
if (btnOr.isSelected()) {
|
||||||
btnAnd.setSelected(false);
|
btnAnd.setSelected(false);
|
||||||
addNewFilter(Filter.this);
|
addNewFilter(Filter.this);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
removeNextFilter(Filter.this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}).build());
|
}).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user