@Override public Vector2i getPreferredContentSize(Canvas canvas, Vector2i sizeHint) { canvas.setPart("handle"); int x = canvas.getCurrentStyle().getFixedWidth(); if (x == 0) { x = canvas.getCurrentStyle().getMinWidth(); } int y = canvas.getCurrentStyle().getFixedHeight(); if (y == 0) { y = canvas.getCurrentStyle().getMinHeight(); } return new Vector2i(x, y); }
@Override public void draw(Module value, Canvas canvas) { canvas.getCurrentStyle().setTextColor(validateModuleDependencies(value.getId()) ? Color.WHITE : Color.RED); super.draw(value, canvas); canvas.getCurrentStyle().setTextColor(Color.WHITE); } });
@Override public Vector2i getPreferredContentSize(Canvas canvas, Vector2i areaHint) { Vector2i result = new Vector2i(); canvas.setPart(SLIDER_PART); result.x = canvas.getCurrentStyle().getFixedWidth(); if (result.x == 0) { result.x = canvas.getCurrentStyle().getMinWidth(); } result.y = canvas.getCurrentStyle().getFixedHeight(); if (result.y == 0) { result.y = canvas.getCurrentStyle().getMinHeight(); } Vector2i left = getTickerPreferredContentSize(canvas, TICKER_LEFT_PART); Vector2i right = getTickerPreferredContentSize(canvas, TICKER_RIGHT_PART); result.y = Math.max(result.y, Math.max(left.y, right.y)); result.x = Math.max(result.x, left.x + left.y); return result; }
@Override public Vector2i getPreferredSize(ModuleSelectionInfo value, Canvas canvas) { String text = getString(value); return new Vector2i(canvas.getCurrentStyle().getFont().getWidth(text), canvas.getCurrentStyle().getFont().getLineHeight()); } });
@Override public Vector2i getPreferredSize(ModuleSelectionInfo value, Canvas canvas) { String text = getString(value); return new Vector2i(canvas.getCurrentStyle().getFont().getWidth(text), canvas.getCurrentStyle().getFont().getLineHeight()); } });
@Override public Vector2i getPreferredSize(WorldInfo value, Canvas canvas) { String text = value.getCustomTitle(); return new Vector2i(canvas.getCurrentStyle().getFont().getWidth(text), canvas.getCurrentStyle().getFont().getLineHeight()); } });
@Override public Vector2i getPreferredSize(DependencyInfo value, Canvas canvas) { String text = getString(value); return new Vector2i( canvas.getCurrentStyle().getFont().getWidth(text), canvas.getCurrentStyle().getFont().getLineHeight()); } });
@Override public Vector2i getPreferredContentSize(Canvas canvas, Vector2i sizeHint) { if (displayedPage != null) { return DocumentRenderer.getDocumentPreferredSize(displayedPage, canvas.getCurrentStyle().getFont(), canvas.getCurrentStyle().getTextColor(), canvas.getRegion().sizeX()); } else { return new Vector2i(0, 0); } }
@Override public Vector2i getPreferredSize(Biome biome, Canvas canvas) { String text = getString(biome); return new Vector2i(canvas.getCurrentStyle().getFont().getWidth(text), canvas.getCurrentStyle().getFont().getLineHeight()); } });
@Override public void onDraw(Canvas canvas) { if (image.get() != null) { if (ignoreAspectRatio) { ScaleMode scaleMode = canvas.getCurrentStyle().getTextureScaleMode(); canvas.getCurrentStyle().setTextureScaleMode(ScaleMode.STRETCH); canvas.drawTexture(image.get(), tint.get()); canvas.getCurrentStyle().setTextureScaleMode(scaleMode); } else { canvas.drawTexture(image.get(), tint.get()); } } }
@Override public Vector2i getPreferredContentSize(Canvas canvas, Vector2i areaHint) { if (selection.get() != null) { return canvas.getCurrentStyle().getMargin().grow(optionRenderer.getPreferredSize(selection.get(), canvas)); } return canvas.getCurrentStyle().getMargin().grow(new Vector2i(1, canvas.getCurrentStyle().getFont().getLineHeight())); }
@Override public Vector2i getPreferredContentSize(Canvas canvas, Vector2i areaHint) { Font font = canvas.getCurrentStyle().getFont(); List<String> lines = TextLineBuilder.getLines(font, getText(), areaHint.x); return font.getSize(lines); } }
/** * Retrieves the preferred content size of this {@code UIScrollingText}. * This is the minimum size this layout will take, given no space restrictions. * * @param canvas The {@code Canvas} on which this {@code UIScrollingText} is drawn * @param areaHint A {@link Vector2i} representing the available space for this {@code UIScrollingText} * @return A {@code Vector2i} representing the preferred content size of this {@code UIScrollingText} */ @Override public Vector2i getPreferredContentSize(Canvas canvas, Vector2i areaHint) { Font font = canvas.getCurrentStyle().getFont(); List<String> lines = TextLineBuilder.getLines(font, getText(), areaHint.x); return font.getSize(lines); }
@Override public Vector2i getPreferredContentSize(Canvas canvas, Vector2i areaHint) { canvas.setPart("item"); Vector2i result = new Vector2i(); for (T item : list.get()) { Vector2i preferredSize = canvas.getCurrentStyle().getMargin().grow(itemRenderer.getPreferredSize(item, canvas)); result.x = Math.max(result.x, preferredSize.x); result.y += preferredSize.y; } return result; }
@Override public Vector2i getPreferredContentSize(Canvas canvas, Vector2i areaHint) { Font font = canvas.getCurrentStyle().getFont(); String text = ""; if (capturingInput) { text = "???"; } else if (newInput != null) { text = newInput.getDisplayName(); } List<String> lines = TextLineBuilder.getLines(font, text, areaHint.getX()); return font.getSize(lines); }
/** * Retrieves the preferred content size of the {@code UIButton}. * This is the minimum size this layout will take, given no space restrictions. * * @param canvas The {@code Canvas} on which the {@code UIButton} is drawn * @param areaHint A {@link Vector2i} representing the available space for this {@code UIButton} * @return A {@link Vector2i} representing the preferred content size of the {@code UIButton} */ @Override public Vector2i getPreferredContentSize(Canvas canvas, Vector2i areaHint) { Font font = canvas.getCurrentStyle().getFont(); List<String> lines = TextLineBuilder.getLines(font, text.get(), areaHint.getX()); return font.getSize(lines); }
/** * Get the maximum content size of the widget. * * @param canvas The canvas on which the widget resides * @return The maximum content size of the widget */ @Override public Vector2i getMaxContentSize(Canvas canvas) { Font font = canvas.getCurrentStyle().getFont(); if (isMultiline()) { return new Vector2i(Integer.MAX_VALUE, Integer.MAX_VALUE); } else { return new Vector2i(Integer.MAX_VALUE, font.getLineHeight()); } }
@Override public Vector2i getPreferredSize(T value, Canvas canvas) { Font font = canvas.getCurrentStyle().getFont(); String text = getString(value); if (wrap) { List<String> lines = TextLineBuilder.getLines(font, text, canvas.size().x); return font.getSize(lines); } else { return new Vector2i(font.getWidth(text), font.getLineHeight()); } }
@Override public Vector2i getPreferredSize(T value, Canvas canvas) { Font font = canvas.getCurrentStyle().getFont(); String text = getString(value); TextureRegion texture = getTexture(value); if (texture == null) { List<String> lines = TextLineBuilder.getLines(font, text, canvas.size().x); return font.getSize(lines); } else { int iconWidth = marginLeft + texture.getWidth() + marginRight; List<String> lines = TextLineBuilder.getLines(font, text, canvas.size().x - iconWidth); return font.getSize(lines).addX(iconWidth); } }
private void drawNode(Canvas canvas, Rect2i nodeRegion, Tree<T> node, TreeViewListenerSet listenerSet) { canvas.drawBackground(nodeRegion); itemRenderer.draw(node.getValue(), canvas, canvas.getCurrentStyle().getMargin().shrink(nodeRegion)); // Add the top listener. canvas.addInteractionRegion(listenerSet.getTopListener(), itemRenderer.getTooltip(node.getValue()), Rect2i.createFromMinAndSize(nodeRegion.minX(), nodeRegion.minY(), nodeRegion.width(), nodeRegion.height() / 3)); // Add the central listener. canvas.addInteractionRegion(listenerSet.getCenterListener(), itemRenderer.getTooltip(node.getValue()), Rect2i.createFromMinAndSize(nodeRegion.minX(), nodeRegion.minY() + nodeRegion.height() / 3, nodeRegion.width(), nodeRegion.height() / 3)); int heightOffset = nodeRegion.height() - 3 * (nodeRegion.height() / 3); // Add the bottom listener. canvas.addInteractionRegion(listenerSet.getBottomListener(), itemRenderer.getTooltip(node.getValue()), Rect2i.createFromMinAndSize(nodeRegion.minX(), nodeRegion.minY() + 2 * nodeRegion.height() / 3, nodeRegion.width(), heightOffset + nodeRegion.height() / 3)); }