Move cycle section button left of view buttons so an Add Basic Lands button can be added in its place

This commit is contained in:
drdev
2015-09-26 22:01:22 +00:00
parent 4c2da2eea6
commit fc73105532
2 changed files with 31 additions and 8 deletions

View File

@@ -114,6 +114,14 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel implem
.fontSize(12)
.build();
private final FLabel btnCycleSection = new FLabel.Builder()
.text("Change Section")
.tooltip("Toggle between editing the deck and the sideboard/planar/scheme/vanguard parts of this deck")
.icon(FSkin.getIcon(FSkinProp.ICO_EDIT))
.iconScaleAuto(false).hoverable()
.fontSize(12)
.build();
private static final SkinIcon VIEW_OPTIONS_ICON = FSkin.getIcon(FSkinProp.ICO_SETTINGS).resize(20, 20);
private final FLabel btnViewOptions = new FLabel.Builder()
.hoverable()
@@ -184,6 +192,8 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel implem
this.add(this.btnFilters);
this.add(this.lblCaption);
this.add(this.lblRatio);
btnCycleSection.setVisible(false); //hide by default
this.add(btnCycleSection);
for (final ItemView<T> view : this.views) {
this.add(view.getButton());
view.getButton().setSelected(view == this.currentView);
@@ -375,9 +385,10 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel implem
helper.offset(1, 0); //align filters button with expand/collapse all button
helper.include(this.btnFilters, viewButtonWidth, FTextField.HEIGHT);
int captionWidth = this.lblCaption.getAutoSizeWidth();
int btnCycleSectionWidth = this.btnCycleSection.isVisible() ? this.btnCycleSection.getAutoSizeWidth() : 0;
final int ratioWidth = this.lblRatio.getAutoSizeWidth();
final int viewButtonCount = this.views.size() + 1;
final int availableCaptionWidth = helper.getParentWidth() - viewButtonWidth * viewButtonCount - ratioWidth - helper.getX() - (viewButtonCount + 2) * helper.getGapX();
final int availableCaptionWidth = helper.getParentWidth() - viewButtonWidth * viewButtonCount - ratioWidth - btnCycleSectionWidth - 3 * helper.getX() - (viewButtonCount + 2) * helper.getGapX();
if (captionWidth > availableCaptionWidth) { //truncate caption if not enough room for it
this.lblCaption.setToolTipText(this.lblCaption.getText());
captionWidth = availableCaptionWidth;
@@ -385,7 +396,9 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel implem
this.lblCaption.setToolTipText(null);
}
helper.include(this.lblCaption, captionWidth, FTextField.HEIGHT);
helper.fillLine(this.lblRatio, FTextField.HEIGHT, (viewButtonWidth + helper.getGapX()) * viewButtonCount - viewButtonCount + 1); //leave room for view buttons
helper.fillLine(this.lblRatio, FTextField.HEIGHT, (viewButtonWidth + helper.getGapX()) * viewButtonCount - viewButtonCount + btnCycleSectionWidth + 2 * helper.getGapX() + 1); //leave room for view buttons and btnCycleSectionWidth
helper.include(this.btnCycleSection, btnCycleSectionWidth, FTextField.HEIGHT);
helper.offset(helper.getGapX(), 0);
for (final ItemView<T> view : this.views) {
helper.include(view.getButton(), viewButtonWidth, FTextField.HEIGHT);
helper.offset(-1, 0);
@@ -1072,6 +1085,10 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel implem
return this.pnlButtons;
}
public FLabel getBtnCycleSection() {
return btnCycleSection;
}
/**
*
* isIncrementalSearchActive.

View File

@@ -110,11 +110,11 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
.icon(FSkin.getIcon(FSkinProp.ICO_MINUS))
.iconScaleAuto(false).hoverable().build();
private final FLabel btnCycleSection = new FLabel.Builder()
private final FLabel btnAddBasicLands = new FLabel.Builder()
.fontSize(14)
.text("Change Section")
.tooltip("Toggle between editing the deck and the sideboard/planar/scheme/vanguard parts of this deck")
.icon(FSkin.getIcon(FSkinProp.ICO_EDIT))
.text("Add Basic Lands")
.tooltip("Add basic lands to the deck")
.icon(FSkin.getImage(FSkinProp.IMG_LAND, 18, 18))
.iconScaleAuto(false).hoverable().build();
protected ACEditorBase(final FScreen screen0, final CDetailPicture cDetailPicture) {
@@ -299,9 +299,14 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
CDeckEditorUI.SINGLETON_INSTANCE.removeSelectedCards(false, 4);
}
});
btnAddBasicLands.setCommand(new UiCommand() {
@Override public void run() {
}
});
itemManager.getPnlButtons().add(btnRemove, "w 30%!, h 30px!, gapx 5");
itemManager.getPnlButtons().add(btnRemove4, "w 30%!, h 30px!, gapx 5");
itemManager.getPnlButtons().add(btnCycleSection, "w 30%!, h 30px!, gapx 5");
itemManager.getPnlButtons().add(btnAddBasicLands, "w 30%!, h 30px!, gapx 5");
}
/**
@@ -393,7 +398,8 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
public FLabel getBtnAdd4() { return btnAdd4; }
public FLabel getBtnRemove() { return btnRemove; }
public FLabel getBtnRemove4() { return btnRemove4; }
public FLabel getBtnCycleSection() { return btnCycleSection; }
public FLabel getBtnAddBasicLands() { return btnAddBasicLands; }
public FLabel getBtnCycleSection() { return deckManager.getBtnCycleSection(); }
public ContextMenuBuilder createContextMenuBuilder(final boolean isAddContextMenu0) {
return new EditorContextMenuBuilder(isAddContextMenu0);