Improve caption slightly more

This commit is contained in:
drdev
2014-04-12 04:56:48 +00:00
parent 5085b85331
commit 4afab1c6d1
3 changed files with 18 additions and 15 deletions

View File

@@ -303,8 +303,6 @@ public class FDeckChooser extends FScreen {
} }
if (deckType == null) { return; } if (deckType == null) { return; }
lstDecks.setCaption(deckType.toString());
switch (deckType) { switch (deckType) {
case CUSTOM_DECK: case CUSTOM_DECK:
updateCustom(); updateCustom();

View File

@@ -40,35 +40,37 @@ public final class DeckManager extends ItemManager<DeckProxy> {
*/ */
public DeckManager(final GameType gt) { public DeckManager(final GameType gt) {
super(DeckProxy.class, true); super(DeckProxy.class, true);
this.gametype = gt; gametype = gt;
this.setItemActivateHandler(new FEventHandler() { setItemActivateHandler(new FEventHandler() {
@Override @Override
public void handleEvent(FEvent e) { public void handleEvent(FEvent e) {
editDeck(getSelectedItem()); editDeck(getSelectedItem());
} }
}); });
setCaption("Decks");
} }
@Override @Override
public void setup(ItemManagerConfig config0) { public void setup(ItemManagerConfig config0) {
boolean wasStringOnly = (this.getConfig() == ItemManagerConfig.STRING_ONLY); boolean wasStringOnly = (getConfig() == ItemManagerConfig.STRING_ONLY);
boolean isStringOnly = (config0 == ItemManagerConfig.STRING_ONLY); boolean isStringOnly = (config0 == ItemManagerConfig.STRING_ONLY);
super.setup(config0, null); super.setup(config0, null);
if (isStringOnly != wasStringOnly) { if (isStringOnly != wasStringOnly) {
this.restoreDefaultFilters(); restoreDefaultFilters();
} }
} }
public void setDeleteCommand(final FEventHandler c0) { public void setDeleteCommand(final FEventHandler c0) {
this.cmdDelete = c0; cmdDelete = c0;
} }
@Override @Override
protected void addDefaultFilters() { protected void addDefaultFilters() {
if (this.getConfig() == ItemManagerConfig.STRING_ONLY) { return; } if (getConfig() == ItemManagerConfig.STRING_ONLY) { return; }
addFilter(new DeckColorFilter(this)); addFilter(new DeckColorFilter(this));
} }
@@ -164,7 +166,7 @@ public final class DeckManager extends ItemManager<DeckProxy> {
/*FScreen screen = null; /*FScreen screen = null;
switch (this.gametype) { switch (gametype) {
case Quest: case Quest:
screen = FScreen.DECK_EDITOR_QUEST; screen = FScreen.DECK_EDITOR_QUEST;
editorCtrl = new CEditorQuest(FModel.getQuest()); editorCtrl = new CEditorQuest(FModel.getQuest());
@@ -208,7 +210,7 @@ public final class DeckManager extends ItemManager<DeckProxy> {
} }
// consider using deck proxy's method to delete deck // consider using deck proxy's method to delete deck
switch(this.gametype) { switch(gametype) {
case Constructed: case Constructed:
case Draft: case Draft:
case Sealed: case Sealed:
@@ -222,10 +224,10 @@ public final class DeckManager extends ItemManager<DeckProxy> {
throw new UnsupportedOperationException("Delete not implemneted for game type = " + gametype.toString()); throw new UnsupportedOperationException("Delete not implemneted for game type = " + gametype.toString());
} }
this.removeItem(deck, 1); removeItem(deck, 1);
if (this.cmdDelete != null) { if (cmdDelete != null) {
this.cmdDelete.handleEvent(new FEvent(this, FEventType.DELETE)); cmdDelete.handleEvent(new FEvent(this, FEventType.DELETE));
} }
return true; return true;
} }

View File

@@ -283,12 +283,15 @@ public abstract class ItemManager<T extends InventoryItem> extends FContainer im
float ratioWidth = lblRatio.getAutoSizeBounds().width; float ratioWidth = lblRatio.getAutoSizeBounds().width;
float viewButtonWidth = fieldHeight; float viewButtonWidth = fieldHeight;
float viewButtonCount = views.size() + 1; float viewButtonCount = views.size() + 1;
float availableCaptionWidth = helper.getParentWidth() - viewButtonWidth * viewButtonCount - ratioWidth - helper.getX() - (viewButtonCount + 2) * helper.getGapX(); float availableCaptionWidth = helper.getParentWidth() - viewButtonWidth * viewButtonCount - ratioWidth - helper.getX() - (viewButtonCount + 1) * helper.getGapX();
if (captionWidth > availableCaptionWidth) { //truncate caption if not enough room for it if (captionWidth > availableCaptionWidth) { //truncate caption if not enough room for it
captionWidth = availableCaptionWidth; captionWidth = availableCaptionWidth;
} }
helper.offset(0, 1); //shift caption downward
helper.include(lblCaption, captionWidth, fieldHeight); helper.include(lblCaption, captionWidth, fieldHeight);
helper.offset(-helper.getGapX(), 0);
helper.fillLine(lblRatio, fieldHeight, (viewButtonWidth + helper.getGapX()) * viewButtonCount - viewButtonCount + 1); //leave room for view buttons helper.fillLine(lblRatio, fieldHeight, (viewButtonWidth + helper.getGapX()) * viewButtonCount - viewButtonCount + 1); //leave room for view buttons
helper.offset(0, -1);
for (ItemView<T> view : views) { for (ItemView<T> view : views) {
helper.include(view.getButton(), viewButtonWidth, fieldHeight); helper.include(view.getButton(), viewButtonWidth, fieldHeight);
helper.offset(-1, 0); helper.offset(-1, 0);