Truncate item manager caption if not enough room for it

This commit is contained in:
drdev
2014-01-18 02:53:32 +00:00
parent f9178dcff2
commit 86cea92ca1
2 changed files with 33 additions and 12 deletions

View File

@@ -144,4 +144,18 @@ public final class LayoutHelper {
public int getParentHeight() { public int getParentHeight() {
return parentHeight; return parentHeight;
} }
/**
* @return current X
*/
public int getX() {
return x;
}
/**
* @return current Y
*/
public int getY() {
return y;
}
} }

View File

@@ -319,8 +319,15 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel {
helper.fillLine(this.pnlButtons, showButtonPanel ? buttonPanelHeight : 1); //just show border if no buttons helper.fillLine(this.pnlButtons, showButtonPanel ? buttonPanelHeight : 1); //just show border if no buttons
} }
helper.include(this.btnFilters, 61, FTextField.HEIGHT); helper.include(this.btnFilters, 61, FTextField.HEIGHT);
helper.include(this.lblCaption, this.lblCaption.getAutoSizeWidth(), FTextField.HEIGHT); int captionWidth = this.lblCaption.getAutoSizeWidth();
helper.fillLine(this.lblRatio, FTextField.HEIGHT, this.cbViews.getAutoSizeWidth()); //leave room for cbViews int ratioWidth = this.lblRatio.getAutoSizeWidth();
int cbViewsWidth = this.cbViews.getAutoSizeWidth();
int availableCaptionWidth = helper.getParentWidth() - cbViewsWidth - ratioWidth - helper.getX() - 9;
if (captionWidth > availableCaptionWidth) { //truncate caption if not enough room for it
captionWidth = availableCaptionWidth;
}
helper.include(this.lblCaption, captionWidth, FTextField.HEIGHT);
helper.fillLine(this.lblRatio, FTextField.HEIGHT, cbViewsWidth); //leave room for cbViews
helper.fillLine(this.cbViews.getComponent(), FTextField.HEIGHT); helper.fillLine(this.cbViews.getComponent(), FTextField.HEIGHT);
helper.fill(this.viewScroller); helper.fill(this.viewScroller);
} }