本文整理了Java中com.badlogic.gdx.scenes.scene2d.utils.Drawable.getLeftWidth()
方法的一些代码示例,展示了Drawable.getLeftWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Drawable.getLeftWidth()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.utils.Drawable
类名称:Drawable
方法名:getLeftWidth
暂无
代码示例来源:origin: libgdx/libgdx
public float get (Actor context) {
Drawable background = ((Table)context).background;
return background == null ? 0 : background.getLeftWidth();
}
};
代码示例来源:origin: libgdx/libgdx
public float get (Actor context) {
Drawable background = ((Table)context).background;
return background == null ? 0 : background.getLeftWidth();
}
};
代码示例来源:origin: libgdx/libgdx
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;
}
代码示例来源:origin: libgdx/libgdx
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;
}
代码示例来源:origin: libgdx/libgdx
protected int letterUnderCursor (float x) {
x -= textOffset + fontOffset - style.font.getData().cursorX - glyphPositions.get(visibleTextStart);
Drawable background = getBackgroundDrawable();
if (background != null) x -= style.background.getLeftWidth();
int n = this.glyphPositions.size;
float[] glyphPositions = this.glyphPositions.items;
for (int i = 1; i < n; i++) {
if (glyphPositions[i] > x) {
if (glyphPositions[i] - x <= x - glyphPositions[i - 1]) return i;
return i - 1;
}
}
return n - 1;
}
代码示例来源:origin: libgdx/libgdx
protected int letterUnderCursor (float x) {
x -= textOffset + fontOffset - style.font.getData().cursorX - glyphPositions.get(visibleTextStart);
Drawable background = getBackgroundDrawable();
if (background != null) x -= style.background.getLeftWidth();
int n = this.glyphPositions.size;
float[] glyphPositions = this.glyphPositions.items;
for (int i = 1; i < n; i++) {
if (glyphPositions[i] > x) {
if (glyphPositions[i] - x <= x - glyphPositions[i - 1]) return i;
return i - 1;
}
}
return n - 1;
}
代码示例来源:origin: libgdx/libgdx
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;
}
代码示例来源:origin: libgdx/libgdx
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;
}
代码示例来源:origin: libgdx/libgdx
@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();
}
代码示例来源:origin: libgdx/libgdx
@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();
}
代码示例来源:origin: libgdx/libgdx
boolean calculatePositionAndValue (float x, float y) {
final SliderStyle style = getStyle();
final Drawable knob = getKnobDrawable();
final Drawable bg = (disabled && style.disabledBackground != null) ? style.disabledBackground : style.background;
float value;
float oldPosition = position;
final float min = getMinValue();
final float max = getMaxValue();
if (vertical) {
float height = getHeight() - bg.getTopHeight() - bg.getBottomHeight();
float knobHeight = knob == null ? 0 : knob.getMinHeight();
position = y - bg.getBottomHeight() - knobHeight * 0.5f;
value = min + (max - min) * visualInterpolationInverse.apply(position / (height - knobHeight));
position = Math.max(Math.min(0, bg.getBottomHeight()), position);
position = Math.min(height - knobHeight, position);
} else {
float width = getWidth() - bg.getLeftWidth() - bg.getRightWidth();
float knobWidth = knob == null ? 0 : knob.getMinWidth();
position = x - bg.getLeftWidth() - knobWidth * 0.5f;
value = min + (max - min) * visualInterpolationInverse.apply(position / (width - knobWidth));
position = Math.max(Math.min(0, bg.getLeftWidth()), position);
position = Math.min(width - knobWidth, position);
}
float oldValue = value;
if (!Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) && !Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT)) value = snap(value);
boolean valueSet = setValue(value);
if (value == oldValue) position = oldPosition;
return valueSet;
}
代码示例来源:origin: libgdx/libgdx
@Override
public void layout () {
Drawable bg = style.background;
BitmapFont font = style.font;
if (bg != null) {
prefHeight = Math.max(bg.getTopHeight() + bg.getBottomHeight() + font.getCapHeight() - font.getDescent() * 2,
bg.getMinHeight());
} else
prefHeight = font.getCapHeight() - font.getDescent() * 2;
float maxItemWidth = 0;
Pool<GlyphLayout> layoutPool = Pools.get(GlyphLayout.class);
GlyphLayout layout = layoutPool.obtain();
for (int i = 0; i < items.size; i++) {
layout.setText(font, toString(items.get(i)));
maxItemWidth = Math.max(layout.width, maxItemWidth);
}
layoutPool.free(layout);
prefWidth = maxItemWidth;
if (bg != null) prefWidth += bg.getLeftWidth() + bg.getRightWidth();
ListStyle listStyle = style.listStyle;
ScrollPaneStyle scrollStyle = style.scrollStyle;
float listWidth = maxItemWidth + listStyle.selection.getLeftWidth() + listStyle.selection.getRightWidth();
if (scrollStyle.background != null)
listWidth += scrollStyle.background.getLeftWidth() + scrollStyle.background.getRightWidth();
if (selectBoxList == null || !selectBoxList.disableY)
listWidth += Math.max(style.scrollStyle.vScroll != null ? style.scrollStyle.vScroll.getMinWidth() : 0,
style.scrollStyle.vScrollKnob != null ? style.scrollStyle.vScrollKnob.getMinWidth() : 0);
prefWidth = Math.max(prefWidth, listWidth);
}
代码示例来源:origin: libgdx/libgdx
/** 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();
}
代码示例来源:origin: libgdx/libgdx
/** 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();
}
代码示例来源:origin: libgdx/libgdx
/** 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();
}
}
代码示例来源:origin: libgdx/libgdx
private void computePrefSize () {
prefSizeInvalid = false;
GlyphLayout prefSizeLayout = Label.prefSizeLayout;
if (wrap && ellipsis == null) {
float width = getWidth();
if (style.background != null) width -= style.background.getLeftWidth() + style.background.getRightWidth();
prefSizeLayout.setText(cache.getFont(), text, Color.WHITE, width, Align.left, true);
} else
prefSizeLayout.setText(cache.getFont(), text);
prefSize.set(prefSizeLayout.width, prefSizeLayout.height);
}
代码示例来源:origin: libgdx/libgdx
private void computePrefSize () {
prefSizeInvalid = false;
GlyphLayout prefSizeLayout = Label.prefSizeLayout;
if (wrap && ellipsis == null) {
float width = getWidth();
if (style.background != null) width -= style.background.getLeftWidth() + style.background.getRightWidth();
prefSizeLayout.setText(cache.getFont(), text, Color.WHITE, width, Align.left, true);
} else
prefSizeLayout.setText(cache.getFont(), text);
prefSize.set(prefSizeLayout.width, prefSizeLayout.height);
}
代码示例来源:origin: libgdx/libgdx
/** 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();
}
}
代码示例来源:origin: libgdx/libgdx
public void layout () {
BitmapFont font = style.font;
Drawable selectedDrawable = style.selection;
itemHeight = font.getCapHeight() - font.getDescent() * 2;
itemHeight += selectedDrawable.getTopHeight() + selectedDrawable.getBottomHeight();
prefWidth = 0;
Pool<GlyphLayout> layoutPool = Pools.get(GlyphLayout.class);
GlyphLayout layout = layoutPool.obtain();
for (int i = 0; i < items.size; i++) {
layout.setText(font, toString(items.get(i)));
prefWidth = Math.max(layout.width, prefWidth);
}
layoutPool.free(layout);
prefWidth += selectedDrawable.getLeftWidth() + selectedDrawable.getRightWidth();
prefHeight = items.size * itemHeight;
Drawable background = style.background;
if (background != null) {
prefWidth += background.getLeftWidth() + background.getRightWidth();
prefHeight += background.getTopHeight() + background.getBottomHeight();
}
}
代码示例来源:origin: libgdx/libgdx
public void layout () {
BitmapFont font = style.font;
Drawable selectedDrawable = style.selection;
itemHeight = font.getCapHeight() - font.getDescent() * 2;
itemHeight += selectedDrawable.getTopHeight() + selectedDrawable.getBottomHeight();
prefWidth = 0;
Pool<GlyphLayout> layoutPool = Pools.get(GlyphLayout.class);
GlyphLayout layout = layoutPool.obtain();
for (int i = 0; i < items.size; i++) {
layout.setText(font, toString(items.get(i)));
prefWidth = Math.max(layout.width, prefWidth);
}
layoutPool.free(layout);
prefWidth += selectedDrawable.getLeftWidth() + selectedDrawable.getRightWidth();
prefHeight = items.size * itemHeight;
Drawable background = style.background;
if (background != null) {
prefWidth += background.getLeftWidth() + background.getRightWidth();
prefHeight += background.getTopHeight() + background.getBottomHeight();
}
}
内容来源于网络,如有侵权,请联系作者删除!