/** Draws selection rectangle **/ protected void drawSelection (Drawable selection, Batch batch, BitmapFont font, float x, float y) { selection.draw(batch, x + textOffset + selectionX + fontOffset, y - textHeight - font.getDescent(), selectionWidth, textHeight); }
/** Creates a new empty drawable with the same sizing information as the specified drawable. */ public BaseDrawable (Drawable drawable) { if (drawable instanceof BaseDrawable) name = ((BaseDrawable)drawable).getName(); leftWidth = drawable.getLeftWidth(); rightWidth = drawable.getRightWidth(); topHeight = drawable.getTopHeight(); bottomHeight = drawable.getBottomHeight(); minWidth = drawable.getMinWidth(); minHeight = drawable.getMinHeight(); }
/** @return -1 if not over an item. */ public int getItemIndexAt (float y) { float height = getHeight(); Drawable background = List.this.style.background; if (background != null) { height -= background.getTopHeight() + background.getBottomHeight(); y -= background.getBottomHeight(); } int index = (int)((height - y) / itemHeight); if (index < 0 || index >= items.size) return -1; return index; }
public float getPrefWidth () { if (widget instanceof Layout) { float width = ((Layout)widget).getPrefWidth(); if (style.background != null) width += style.background.getLeftWidth() + style.background.getRightWidth(); if (forceScrollY) { float scrollbarWidth = 0; if (style.vScrollKnob != null) scrollbarWidth = style.vScrollKnob.getMinWidth(); if (style.vScroll != null) scrollbarWidth = Math.max(scrollbarWidth, style.vScroll.getMinWidth()); width += scrollbarWidth; } return width; } return 150; }
/** Sets the background drawable and, if adjustPadding is true, sets the container's padding to * {@link Drawable#getBottomHeight()} , {@link Drawable#getTopHeight()}, {@link Drawable#getLeftWidth()}, and * {@link Drawable#getRightWidth()}. * @param background If null, the background will be cleared and padding removed. */ public void setBackground (Drawable background, boolean adjustPadding) { if (this.background == background) return; this.background = background; if (adjustPadding) { if (background == null) pad(Value.zero); else pad(background.getTopHeight(), background.getLeftWidth(), background.getBottomHeight(), background.getRightWidth()); invalidate(); } }
public float getPrefHeight () { if (widget instanceof Layout) { float height = ((Layout)widget).getPrefHeight(); if (style.background != null) height += style.background.getTopHeight() + style.background.getBottomHeight(); if (forceScrollX) { float scrollbarHeight = 0; if (style.hScrollKnob != null) scrollbarHeight = style.hScrollKnob.getMinHeight(); if (style.hScroll != null) scrollbarHeight = Math.max(scrollbarHeight, style.hScroll.getMinHeight()); height += scrollbarHeight; } return height; } return 150; }
@Override public void draw (Batch batch, float parentAlpha) { validate(); Color c = getColor(); batch.setColor(c.r, c.g, c.b, c.a * parentAlpha); float x = getX(); float y = getY(); float w = getWidth(); float h = getHeight(); final Drawable bg = style.background; if (bg != null) bg.draw(batch, x, y, w, h); final Drawable knob = style.knob; if (knob != null) { x += knobPosition.x - knob.getMinWidth() / 2f; y += knobPosition.y - knob.getMinHeight() / 2f; knob.draw(batch, x, y, knob.getMinWidth(), knob.getMinHeight()); } }
public float getScrollBarHeight () { if (!scrollX) return 0; float height = 0; if (style.hScrollKnob != null) height = style.hScrollKnob.getMinHeight(); if (style.hScroll != null) height = Math.max(height, style.hScroll.getMinHeight()); return height; }
protected void drawCursor (Drawable cursorPatch, Batch batch, BitmapFont font, float x, float y) { cursorPatch.draw(batch, x + textOffset + glyphPositions.get(cursor) - glyphPositions.get(visibleTextStart) + fontOffset + font.getData().cursorX, y - textHeight - font.getDescent(), cursorPatch.getMinWidth(), textHeight); }
public float getScrollBarWidth () { if (!scrollY) return 0; float width = 0; if (style.vScrollKnob != null) width = style.vScrollKnob.getMinWidth(); if (style.vScroll != null) width = Math.max(width, style.vScroll.getMinWidth()); return width; }
public float getPrefWidth () { if (wrap) return 0; if (prefSizeInvalid) scaleAndComputePrefSize(); float width = prefSize.x; Drawable background = style.background; if (background != null) width += background.getLeftWidth() + background.getRightWidth(); return width; }
/** Sets a new drawable for the image. The image's pref size is the drawable's min size. If using the image actor's size rather * than the pref size, {@link #pack()} can be used to size the image to its pref size. * @param drawable May be null. */ public void setDrawable (Drawable drawable) { if (this.drawable == drawable) return; if (drawable != null) { if (getPrefWidth() != drawable.getMinWidth() || getPrefHeight() != drawable.getMinHeight()) invalidateHierarchy(); } else invalidateHierarchy(); this.drawable = drawable; }
@Override protected void setCursorPosition (float x, float y) { moveOffset = -1; Drawable background = style.background; BitmapFont font = style.font; float height = getHeight(); if (background != null) { height -= background.getTopHeight(); x -= background.getLeftWidth(); } x = Math.max(0, x); if (background != null) { y -= background.getTopHeight(); } cursorLine = (int)Math.floor((height - y) / font.getLineHeight()) + firstLineShowing; cursorLine = Math.max(0, Math.min(cursorLine, getLines() - 1)); super.setCursorPosition(x, y); updateCurrentLine(); }
public float get (Actor context) { Drawable background = ((Table)context).background; return background == null ? 0 : background.getTopHeight(); } };
public float get (Actor context) { Drawable background = ((Table)context).background; return background == null ? 0 : background.getLeftWidth(); } };
public float get (Actor context) { Drawable background = ((Table)context).background; return background == null ? 0 : background.getBottomHeight(); } };
public float get (Actor context) { Drawable background = ((Table)context).background; return background == null ? 0 : background.getRightWidth(); } };
/** Sets the background drawable and, if adjustPadding is true, sets the container's padding to * {@link Drawable#getBottomHeight()} , {@link Drawable#getTopHeight()}, {@link Drawable#getLeftWidth()}, and * {@link Drawable#getRightWidth()}. * @param background If null, the background will be cleared and padding removed. */ public void setBackground (Drawable background, boolean adjustPadding) { if (this.background == background) return; this.background = background; if (adjustPadding) { if (background == null) pad(Value.zero); else pad(background.getTopHeight(), background.getLeftWidth(), background.getBottomHeight(), background.getRightWidth()); invalidate(); } }
public float getPrefHeight () { if (widget instanceof Layout) { float height = ((Layout)widget).getPrefHeight(); if (style.background != null) height += style.background.getTopHeight() + style.background.getBottomHeight(); if (forceScrollX) { float scrollbarHeight = 0; if (style.hScrollKnob != null) scrollbarHeight = style.hScrollKnob.getMinHeight(); if (style.hScroll != null) scrollbarHeight = Math.max(scrollbarHeight, style.hScroll.getMinHeight()); height += scrollbarHeight; } return height; } return 150; }
@Override public void draw (Batch batch, float parentAlpha) { validate(); Color c = getColor(); batch.setColor(c.r, c.g, c.b, c.a * parentAlpha); float x = getX(); float y = getY(); float w = getWidth(); float h = getHeight(); final Drawable bg = style.background; if (bg != null) bg.draw(batch, x, y, w, h); final Drawable knob = style.knob; if (knob != null) { x += knobPosition.x - knob.getMinWidth() / 2f; y += knobPosition.y - knob.getMinHeight() / 2f; knob.draw(batch, x, y, knob.getMinWidth(), knob.getMinHeight()); } }