mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Support remembering change to compact mode on list views
This commit is contained in:
@@ -68,6 +68,7 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup(ItemManagerConfig config, Map<ColumnDef, ItemColumn> colOverrides) {
|
public void setup(ItemManagerConfig config, Map<ColumnDef, ItemColumn> colOverrides) {
|
||||||
|
list.compactModeHandler.setCompactMode(config.getCompactListView());
|
||||||
refresh(null, 0, 0);
|
refresh(null, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,6 +285,9 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
if (compactModeHandler.update(amount)) {
|
if (compactModeHandler.update(amount)) {
|
||||||
revalidate(); //update scroll bounds
|
revalidate(); //update scroll bounds
|
||||||
scrollSelectionIntoView(); //ensure selection remains in view
|
scrollSelectionIntoView(); //ensure selection remains in view
|
||||||
|
|
||||||
|
//update compact mode configuration
|
||||||
|
itemManager.getConfig().setCompactListView(compactModeHandler.isCompactMode());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class SettingsPage extends TabPage<SettingsScreen> {
|
|||||||
4);
|
4);
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.UI_COMPACT_LIST_ITEMS,
|
lstSettings.addItem(new BooleanSetting(FPref.UI_COMPACT_LIST_ITEMS,
|
||||||
"Compact List Items",
|
"Compact List Items",
|
||||||
"Show only a single line of text for cards and decks on list views by default."),
|
"Show only a single line of text for cards and decks on all list views by default."),
|
||||||
4);
|
4);
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.UI_HIDE_REMINDER_TEXT,
|
lstSettings.addItem(new BooleanSetting(FPref.UI_HIDE_REMINDER_TEXT,
|
||||||
"Hide Reminder Text",
|
"Hide Reminder Text",
|
||||||
|
|||||||
@@ -267,6 +267,9 @@ public class FList<E> extends FScrollPane implements Iterable<E> {
|
|||||||
public boolean isCompactMode() {
|
public boolean isCompactMode() {
|
||||||
return compactMode;
|
return compactMode;
|
||||||
}
|
}
|
||||||
|
public void setCompactMode(boolean compactMode0) {
|
||||||
|
compactMode = compactMode0;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean update(float amount) {
|
public boolean update(float amount) {
|
||||||
totalZoomAmount += amount;
|
totalZoomAmount += amount;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package forge.itemmanager;
|
package forge.itemmanager;
|
||||||
|
|
||||||
import forge.itemmanager.ItemColumnConfig.SortState;
|
import forge.itemmanager.ItemColumnConfig.SortState;
|
||||||
|
import forge.model.FModel;
|
||||||
import forge.properties.ForgeConstants;
|
import forge.properties.ForgeConstants;
|
||||||
|
import forge.properties.ForgePreferences.FPref;
|
||||||
import forge.util.XmlUtil;
|
import forge.util.XmlUtil;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@@ -88,6 +90,7 @@ public enum ItemManagerConfig {
|
|||||||
|
|
||||||
private Prop<Boolean> uniqueCardsOnly;
|
private Prop<Boolean> uniqueCardsOnly;
|
||||||
private Prop<Boolean> hideFilters;
|
private Prop<Boolean> hideFilters;
|
||||||
|
private Prop<Boolean> compactListView;
|
||||||
private Prop<GroupDef> groupBy;
|
private Prop<GroupDef> groupBy;
|
||||||
private Prop<ColumnDef> pileBy;
|
private Prop<ColumnDef> pileBy;
|
||||||
private Prop<Integer> imageColumnCount;
|
private Prop<Integer> imageColumnCount;
|
||||||
@@ -102,6 +105,7 @@ public enum ItemManagerConfig {
|
|||||||
|
|
||||||
uniqueCardsOnly = new Prop<Boolean>(uniqueCardsOnly0);
|
uniqueCardsOnly = new Prop<Boolean>(uniqueCardsOnly0);
|
||||||
hideFilters = new Prop<Boolean>(hideFilters0);
|
hideFilters = new Prop<Boolean>(hideFilters0);
|
||||||
|
compactListView = new Prop<Boolean>(FModel.getPreferences().getPrefBoolean(FPref.UI_COMPACT_LIST_ITEMS)); //use main setting to determine default
|
||||||
groupBy = new Prop<GroupDef>(groupBy0);
|
groupBy = new Prop<GroupDef>(groupBy0);
|
||||||
pileBy = new Prop<ColumnDef>(pileBy0);
|
pileBy = new Prop<ColumnDef>(pileBy0);
|
||||||
imageColumnCount = new Prop<Integer>(imageColumnCount0);
|
imageColumnCount = new Prop<Integer>(imageColumnCount0);
|
||||||
@@ -167,6 +171,13 @@ public enum ItemManagerConfig {
|
|||||||
hideFilters.setValue(value0);
|
hideFilters.setValue(value0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getCompactListView() {
|
||||||
|
return compactListView.getValue();
|
||||||
|
}
|
||||||
|
public void setCompactListView(boolean value0) {
|
||||||
|
compactListView.setValue(value0);
|
||||||
|
}
|
||||||
|
|
||||||
public GroupDef getGroupBy() {
|
public GroupDef getGroupBy() {
|
||||||
return groupBy.getValue();
|
return groupBy.getValue();
|
||||||
}
|
}
|
||||||
@@ -210,6 +221,9 @@ public enum ItemManagerConfig {
|
|||||||
if (el.hasAttribute("hideFilters")) {
|
if (el.hasAttribute("hideFilters")) {
|
||||||
config.hideFilters.value = Boolean.parseBoolean(el.getAttribute("hideFilters"));
|
config.hideFilters.value = Boolean.parseBoolean(el.getAttribute("hideFilters"));
|
||||||
}
|
}
|
||||||
|
if (el.hasAttribute("compactListView")) {
|
||||||
|
config.compactListView.value = Boolean.parseBoolean(el.getAttribute("compactListView"));
|
||||||
|
}
|
||||||
if (el.hasAttribute("groupBy")) {
|
if (el.hasAttribute("groupBy")) {
|
||||||
String value = el.getAttribute("groupBy");
|
String value = el.getAttribute("groupBy");
|
||||||
if (value.isEmpty()) {
|
if (value.isEmpty()) {
|
||||||
@@ -289,6 +303,7 @@ public enum ItemManagerConfig {
|
|||||||
el.setAttribute("name", config.name());
|
el.setAttribute("name", config.name());
|
||||||
config.uniqueCardsOnly.writeValue(el, "uniqueCardsOnly");
|
config.uniqueCardsOnly.writeValue(el, "uniqueCardsOnly");
|
||||||
config.hideFilters.writeValue(el, "hideFilters");
|
config.hideFilters.writeValue(el, "hideFilters");
|
||||||
|
config.compactListView.writeValue(el, "compactListView");
|
||||||
config.groupBy.writeValue(el, "groupBy");
|
config.groupBy.writeValue(el, "groupBy");
|
||||||
config.pileBy.writeValue(el, "pileBy");
|
config.pileBy.writeValue(el, "pileBy");
|
||||||
config.imageColumnCount.writeValue(el, "imageColumnCount");
|
config.imageColumnCount.writeValue(el, "imageColumnCount");
|
||||||
|
|||||||
Reference in New Issue
Block a user