com.badlogic.gdx.scenes.scene2d.utils.Drawable.getRightWidth()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(12.2k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中com.badlogic.gdx.scenes.scene2d.utils.Drawable.getRightWidth()方法的一些代码示例,展示了Drawable.getRightWidth()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Drawable.getRightWidth()方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.utils.Drawable
类名称:Drawable
方法名:getRightWidth

Drawable.getRightWidth介绍

暂无

代码示例

代码示例来源:origin: libgdx/libgdx

public float get (Actor context) {
    Drawable background = ((Table)context).background;
    return background == null ? 0 : background.getRightWidth();
  }
};

代码示例来源:origin: libgdx/libgdx

public float get (Actor context) {
    Drawable background = ((Table)context).background;
    return background == null ? 0 : background.getRightWidth();
  }
};

代码示例来源: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

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
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

@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();
  }
}

代码示例来源: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

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

if (selected != null) {
  if (background != null) {
    width -= background.getLeftWidth() + background.getRightWidth();
    height -= background.getBottomHeight() + background.getTopHeight();
    x += background.getLeftWidth();

代码示例来源:origin: libgdx/libgdx

if (selected != null) {
  if (background != null) {
    width -= background.getLeftWidth() + background.getRightWidth();
    height -= background.getBottomHeight() + background.getTopHeight();
    x += background.getLeftWidth();

相关文章