mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Tweak UI for advanced search
This commit is contained in:
@@ -224,6 +224,7 @@ public class CardAdvancedFilter extends ItemFilter<PaperCard> {
|
|||||||
super("Advanced Search");
|
super("Advanced Search");
|
||||||
|
|
||||||
scroller.add(new OptionRow(false));
|
scroller.add(new OptionRow(false));
|
||||||
|
scroller.add(new OptionRow(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -231,60 +232,35 @@ public class CardAdvancedFilter extends ItemFilter<PaperCard> {
|
|||||||
scroller.setBounds(0, startY, width, height - startY);
|
scroller.setBounds(0, startY, width, height - startY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFilter(ItemFilter<PaperCard> filter, OptionRow belowRow) {
|
private void addFilter(ItemFilter<PaperCard> filter, OptionRow filterRow) {
|
||||||
if (scroller.getChildAt(scroller.getChildCount() - 1) == belowRow) {
|
filterRow.clear();
|
||||||
scroller.add(new OptionRow(filter));
|
filterRow.filter = filter;
|
||||||
scroller.add(new OptionRow(true));
|
filterRow.add(filter.getWidget());
|
||||||
scroller.revalidate();
|
scroller.add(new OptionRow(true));
|
||||||
scroller.scrollToBottom();
|
scroller.revalidate();
|
||||||
}
|
scroller.scrollToBottom();
|
||||||
else { //support swapping out one filter for another
|
|
||||||
OptionRow filterRow = (OptionRow)scroller.getChildAt(scroller.indexOf(belowRow) + 1);
|
|
||||||
filterRow.filter = filter;
|
|
||||||
filterRow.clear();
|
|
||||||
filterRow.add(filter.getWidget());
|
|
||||||
filterRow.revalidate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFilterSelectRow(OptionRow belowRow) {
|
private void addFilterSelectRow(OptionRow belowRow) {
|
||||||
if (scroller.getChildAt(scroller.getChildCount() - 1) == belowRow) {
|
if (scroller.getChildAt(scroller.getChildCount() - 1) == belowRow) {
|
||||||
scroller.add(new OptionRow(false));
|
scroller.add(new OptionRow(false));
|
||||||
|
scroller.add(new OptionRow(null));
|
||||||
scroller.revalidate();
|
scroller.revalidate();
|
||||||
scroller.scrollToBottom();
|
scroller.scrollToBottom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class OptionRow extends FContainer {
|
private class OptionRow extends FContainer {
|
||||||
private FLabel btnOpenParen, btnCloseParen, btnAnd, btnOr, btnNot;
|
private FLabel btnOpenParen, btnCloseParen, btnAnd, btnOr, btnNot1, btnNot2;
|
||||||
private ItemFilter<PaperCard> filter;
|
private ItemFilter<PaperCard> filter;
|
||||||
|
|
||||||
private OptionRow(ItemFilter<PaperCard> filter0) {
|
private OptionRow(ItemFilter<PaperCard> filter0) {
|
||||||
filter = filter0;
|
if (filter0 != null) {
|
||||||
add(filter.getWidget());
|
filter = filter0;
|
||||||
}
|
add(filter.getWidget());
|
||||||
private OptionRow(boolean includeOperators) {
|
|
||||||
if (includeOperators) {
|
|
||||||
btnCloseParen = add(new FLabel.Builder().align(HAlignment.CENTER).selectable().text(")").build());
|
|
||||||
btnAnd = add(new FLabel.Builder().align(HAlignment.CENTER).text("AND").selectable().command(new FEventHandler() {
|
|
||||||
@Override
|
|
||||||
public void handleEvent(FEvent e) {
|
|
||||||
btnOr.setSelected(false);
|
|
||||||
addFilterSelectRow(OptionRow.this);
|
|
||||||
}
|
|
||||||
}).build());
|
|
||||||
btnOr = add(new FLabel.Builder().align(HAlignment.CENTER).text("OR").selectable().command(new FEventHandler() {
|
|
||||||
@Override
|
|
||||||
public void handleEvent(FEvent e) {
|
|
||||||
btnAnd.setSelected(false);
|
|
||||||
addFilterSelectRow(OptionRow.this);
|
|
||||||
}
|
|
||||||
}).build());
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
btnOpenParen = add(new FLabel.Builder().align(HAlignment.CENTER).text("(").selectable().build());
|
add(new FLabel.ButtonBuilder().text("Filter...").command(new FEventHandler() {
|
||||||
btnNot = add(new FLabel.Builder().align(HAlignment.CENTER).text("NOT").selectable().build());
|
|
||||||
add(new FLabel.ButtonBuilder().text("...").command(new FEventHandler() {
|
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
FPopupMenu menu = new FPopupMenu() {
|
FPopupMenu menu = new FPopupMenu() {
|
||||||
@@ -346,6 +322,30 @@ public class CardAdvancedFilter extends ItemFilter<PaperCard> {
|
|||||||
}).build());
|
}).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private OptionRow(boolean includeOperators) {
|
||||||
|
if (includeOperators) {
|
||||||
|
btnCloseParen = add(new FLabel.Builder().align(HAlignment.CENTER).selectable().text(")").build());
|
||||||
|
btnAnd = add(new FLabel.Builder().align(HAlignment.CENTER).text("AND").selectable().command(new FEventHandler() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(FEvent e) {
|
||||||
|
btnOr.setSelected(false);
|
||||||
|
addFilterSelectRow(OptionRow.this);
|
||||||
|
}
|
||||||
|
}).build());
|
||||||
|
btnOr = add(new FLabel.Builder().align(HAlignment.CENTER).text("OR").selectable().command(new FEventHandler() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(FEvent e) {
|
||||||
|
btnAnd.setSelected(false);
|
||||||
|
addFilterSelectRow(OptionRow.this);
|
||||||
|
}
|
||||||
|
}).build());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
btnNot1 = add(new FLabel.Builder().align(HAlignment.CENTER).text("NOT").selectable().build());
|
||||||
|
btnOpenParen = add(new FLabel.Builder().align(HAlignment.CENTER).text("(").selectable().build());
|
||||||
|
btnNot1 = add(new FLabel.Builder().align(HAlignment.CENTER).text("NOT").selectable().build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLayout(float width, float height) {
|
protected void doLayout(float width, float height) {
|
||||||
|
|||||||
Reference in New Issue
Block a user