mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Add combo box as way to change column count in addition to Ctrl+MouseWheel
This commit is contained in:
@@ -85,6 +85,10 @@ public class FComboBoxWrapper<E> {
|
|||||||
this.comboBox.setSelectedIndex(index);
|
this.comboBox.setSelectedIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMaximumRowCount(int count) {
|
||||||
|
this.comboBox.setMaximumRowCount(count);
|
||||||
|
}
|
||||||
|
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return this.comboBox.getItemCount();
|
return this.comboBox.getItemCount();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
private final ArrayList<Group> groups = new ArrayList<Group>();
|
private final ArrayList<Group> groups = new ArrayList<Group>();
|
||||||
private final FComboBoxWrapper<Object> cbGroupByOptions = new FComboBoxWrapper<Object>();
|
private final FComboBoxWrapper<Object> cbGroupByOptions = new FComboBoxWrapper<Object>();
|
||||||
private final FComboBoxWrapper<Object> cbPileByOptions = new FComboBoxWrapper<Object>();
|
private final FComboBoxWrapper<Object> cbPileByOptions = new FComboBoxWrapper<Object>();
|
||||||
|
private final FComboBoxWrapper<Integer> cbColumnCount = new FComboBoxWrapper<Integer>();
|
||||||
|
|
||||||
public ImageView(ItemManager<T> itemManager0, ItemManagerModel<T> model0) {
|
public ImageView(ItemManager<T> itemManager0, ItemManagerModel<T> model0) {
|
||||||
super(itemManager0, model0);
|
super(itemManager0, model0);
|
||||||
@@ -94,8 +95,15 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
for (ColumnDef option : pileByOptions) {
|
for (ColumnDef option : pileByOptions) {
|
||||||
cbPileByOptions.addItem(option);
|
cbPileByOptions.addItem(option);
|
||||||
}
|
}
|
||||||
|
for (Integer i = MIN_COLUMN_COUNT; i <= MAX_COLUMN_COUNT; i++) {
|
||||||
|
cbColumnCount.addItem(i);
|
||||||
|
}
|
||||||
|
cbGroupByOptions.setMaximumRowCount(cbGroupByOptions.getItemCount());
|
||||||
|
cbPileByOptions.setMaximumRowCount(cbPileByOptions.getItemCount());
|
||||||
|
cbColumnCount.setMaximumRowCount(cbColumnCount.getItemCount());
|
||||||
cbGroupByOptions.setSelectedIndex(0);
|
cbGroupByOptions.setSelectedIndex(0);
|
||||||
cbPileByOptions.setSelectedIndex(0);
|
cbPileByOptions.setSelectedIndex(0);
|
||||||
|
cbColumnCount.setSelectedIndex(columnCount - MIN_COLUMN_COUNT);
|
||||||
|
|
||||||
cbGroupByOptions.addActionListener(new ActionListener() {
|
cbGroupByOptions.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -121,11 +129,20 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
cbColumnCount.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
focus();
|
||||||
|
setColumnCount(cbColumnCount.getSelectedItem());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
getPnlOptions().add(new FLabel.Builder().text("Group by:").fontSize(12).build());
|
getPnlOptions().add(new FLabel.Builder().text("Group by:").fontSize(12).build());
|
||||||
cbGroupByOptions.addTo(getPnlOptions(), "pushx, growx");
|
cbGroupByOptions.addTo(getPnlOptions(), "pushx, growx");
|
||||||
getPnlOptions().add(new FLabel.Builder().text("Pile by:").fontSize(12).build());
|
getPnlOptions().add(new FLabel.Builder().text("Pile by:").fontSize(12).build());
|
||||||
cbPileByOptions.addTo(getPnlOptions(), "pushx, growx");
|
cbPileByOptions.addTo(getPnlOptions(), "pushx, growx");
|
||||||
|
getPnlOptions().add(new FLabel.Builder().text("Columns:").fontSize(12).build());
|
||||||
|
cbColumnCount.addTo(getPnlOptions(), "w 38px!");
|
||||||
|
|
||||||
//setup display
|
//setup display
|
||||||
display = new CardViewDisplay();
|
display = new CardViewDisplay();
|
||||||
@@ -335,6 +352,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
}
|
}
|
||||||
if (columnCount == columnCount0) { return; }
|
if (columnCount == columnCount0) { return; }
|
||||||
columnCount = columnCount0;
|
columnCount = columnCount0;
|
||||||
|
cbColumnCount.setSelectedIndex(columnCount - MIN_COLUMN_COUNT);
|
||||||
|
|
||||||
//determine item to retain scroll position of following column count change
|
//determine item to retain scroll position of following column count change
|
||||||
ItemInfo focalItem0 = getFocalItem();
|
ItemInfo focalItem0 = getFocalItem();
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public abstract class ItemView<T extends InventoryItem> {
|
|||||||
protected final ItemManagerModel<T> model;
|
protected final ItemManagerModel<T> model;
|
||||||
private final FScrollPane scroller;
|
private final FScrollPane scroller;
|
||||||
private final FLabel button;
|
private final FLabel button;
|
||||||
private final SkinnedPanel pnlOptions = new SkinnedPanel(new MigLayout("insets 3 1 0 1, gap 3, hidemode 3"));
|
private final SkinnedPanel pnlOptions = new SkinnedPanel(new MigLayout("insets 3 1 0 1, gap 3 4, hidemode 3"));
|
||||||
private int heightBackup;
|
private int heightBackup;
|
||||||
private boolean isIncrementalSearchActive = false;
|
private boolean isIncrementalSearchActive = false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user