/** Creates an image stretched, and aligned center. * @param region May be null. */ public Image (TextureRegion region) { this(new TextureRegionDrawable(region), Scaling.stretch, Align.center); }
/** Creates a new drawable that renders the same as this drawable tinted the specified color. */ public Drawable tint (Color tint) { Sprite sprite; if (region instanceof AtlasRegion) sprite = new AtlasSprite((AtlasRegion)region); else sprite = new Sprite(region); sprite.setColor(tint); sprite.setSize(getMinWidth(), getMinHeight()); SpriteDrawable drawable = new SpriteDrawable(sprite); drawable.setLeftWidth(getLeftWidth()); drawable.setRightWidth(getRightWidth()); drawable.setTopHeight(getTopHeight()); drawable.setBottomHeight(getBottomHeight()); return drawable; } }
public void setRegion (TextureRegion region) { this.region = region; if (region != null) { setMinWidth(region.getRegionWidth()); setMinHeight(region.getRegionHeight()); } }
TextureRegionDrawable hScroll = new TextureRegionDrawable(textureAtlas.findRegion(selectBoxModel.getSelection())); TextureRegionDrawable hScrollKnob = new TextureRegionDrawable(textureAtlas.findRegion(selectBoxModel.getSelection())); TextureRegionDrawable vScroll = new TextureRegionDrawable(textureAtlas.findRegion(selectBoxModel.getSelection())); TextureRegionDrawable vScrollKnob = new TextureRegionDrawable(textureAtlas.findRegion(selectBoxModel.getSelection())); TextureRegionDrawable selection = new TextureRegionDrawable(textureAtlas.findRegion(selectBoxModel.getSelection())); Color fontColorUnselected = selectBoxModel.getFontColorUnselected()==null ? DEFAULT_COLOR : Color.valueOf(selectBoxModel.getFontColorUnselected()); selection.setLeftWidth(selectBoxModel.getPaddingLeft()==0 ? DEFAULT_PADDING_LEFT * positionMultiplier : selectBoxModel.getPaddingLeft()); selection.setRightWidth(selectBoxModel.getPaddingRight() == 0 ? DEFAULT_PADDING_RIGHT * positionMultiplier : selectBoxModel.getPaddingRight()); selection.setTopHeight(selectBoxModel.getPaddingTop()==0 ? DEFAULT_PADDING_TOP * positionMultiplier : selectBoxModel.getPaddingTop()); selection.setBottomHeight(selectBoxModel.getPaddingBottom() == 0 ? DEFAULT_PADDING_BOTTOM * positionMultiplier : selectBoxModel.getPaddingBottom());
protected void updateDrawableSize( TextureRegionDrawable textureRegionDrawable){ float sizeMultiplier = resolutionHelper.getSizeMultiplier(); textureRegionDrawable.setMinWidth( textureRegionDrawable.getMinWidth() * sizeMultiplier); textureRegionDrawable.setMinHeight( textureRegionDrawable.getMinHeight() * sizeMultiplier); } }
@Override public Actor build(BaseModel model, Group parent) { CheckBoxModel checkBoxModel = (CheckBoxModel) model; setTextures( checkBoxModel); String text = ( checkBoxModel.getText() == null) ? "" : getLocalizedString( checkBoxModel.getText()).replace("\\n", String.format("%n")); BitmapFont font = assets.getFont( checkBoxModel.getFontName()); Color fontColor = Color.valueOf( checkBoxModel.getFontColor()); CheckBox.CheckBoxStyle style = new CheckBox.CheckBoxStyle( checkBoxOff, checkBoxOn, font, fontColor); if ( this.checkBoxOver != null){ style.checkboxOver = checkBoxOver; } CheckBox checkBox = new CheckBox( text, style); normalizeModelSize( checkBoxModel, parent, checkBoxOff.getMinWidth(), checkBoxOff.getMinHeight()); setBasicProperties( checkBoxModel, checkBox); setTextButtonProperties( checkBoxModel, font, checkBox); applyTableAlignment(checkBoxModel.getAlignment(), checkBox); return checkBox; }
/** Returns a tinted copy of a drawable found in the skin via {@link #getDrawable(String)}. */ public Drawable newDrawable (Drawable drawable, Color tint) { Drawable newDrawable; if (drawable instanceof TextureRegionDrawable) newDrawable = ((TextureRegionDrawable)drawable).tint(tint); else if (drawable instanceof NinePatchDrawable) newDrawable = ((NinePatchDrawable)drawable).tint(tint); else if (drawable instanceof SpriteDrawable) newDrawable = ((SpriteDrawable)drawable).tint(tint); else throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass()); if (newDrawable instanceof BaseDrawable) { BaseDrawable named = (BaseDrawable)newDrawable; if (drawable instanceof BaseDrawable) named.setName(((BaseDrawable)drawable).getName() + " (" + tint + ")"); else named.setName(" (" + tint + ")"); } return newDrawable; }
protected void updateDrawableSize( TextureRegionDrawable textureRegionDrawable){ float sizeMultiplier = resolutionHelper.getSizeMultiplier(); textureRegionDrawable.setMinWidth( textureRegionDrawable.getMinWidth() * sizeMultiplier); textureRegionDrawable.setMinHeight( textureRegionDrawable.getMinHeight() * sizeMultiplier); }
@Override public Actor build(BaseModel model, Group parent) { SliderModel sliderModel = (SliderModel) model; setTextures(sliderModel); Slider slider = new Slider( sliderModel.getMinValue(), sliderModel.getMaxValue(), sliderModel.getStepSize(), sliderModel.isVertical(), new Slider.SliderStyle( background, knob)); updateDrawableSize( knob); normalizeModelSize( sliderModel, parent, background.getMinWidth(), background.getMinHeight()); updateDrawableSize( background); setBasicProperties( model, slider); return slider; }
/** Returns a tinted copy of a drawable found in the skin via {@link #getDrawable(String)}. */ public Drawable newDrawable (Drawable drawable, Color tint) { Drawable newDrawable; if (drawable instanceof TextureRegionDrawable) newDrawable = ((TextureRegionDrawable)drawable).tint(tint); else if (drawable instanceof NinePatchDrawable) newDrawable = ((NinePatchDrawable)drawable).tint(tint); else if (drawable instanceof SpriteDrawable) newDrawable = ((SpriteDrawable)drawable).tint(tint); else throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass()); if (newDrawable instanceof BaseDrawable) { BaseDrawable named = (BaseDrawable)newDrawable; if (drawable instanceof BaseDrawable) named.setName(((BaseDrawable)drawable).getName() + " (" + tint + ")"); else named.setName(" (" + tint + ")"); } return newDrawable; }
/** Creates an image stretched, and aligned center. * @param region May be null. */ public Image (TextureRegion region) { this(new TextureRegionDrawable(region), Scaling.stretch, Align.center); }
/** Creates a new drawable that renders the same as this drawable tinted the specified color. */ public Drawable tint (Color tint) { Sprite sprite; if (region instanceof AtlasRegion) sprite = new AtlasSprite((AtlasRegion)region); else sprite = new Sprite(region); sprite.setColor(tint); sprite.setSize(getMinWidth(), getMinHeight()); SpriteDrawable drawable = new SpriteDrawable(sprite); drawable.setLeftWidth(getLeftWidth()); drawable.setRightWidth(getRightWidth()); drawable.setTopHeight(getTopHeight()); drawable.setBottomHeight(getBottomHeight()); return drawable; } }
public void setRegion (TextureRegion region) { this.region = region; if (region != null) { setMinWidth(region.getRegionWidth()); setMinHeight(region.getRegionHeight()); } }
/** Returns a tinted copy of a drawable found in the skin via {@link #getDrawable(String)}. */ public Drawable newDrawable (Drawable drawable, Color tint) { Drawable newDrawable; if (drawable instanceof TextureRegionDrawable) newDrawable = ((TextureRegionDrawable)drawable).tint(tint); else if (drawable instanceof NinePatchDrawable) newDrawable = ((NinePatchDrawable)drawable).tint(tint); else if (drawable instanceof SpriteDrawable) newDrawable = ((SpriteDrawable)drawable).tint(tint); else throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass()); if (newDrawable instanceof BaseDrawable) { BaseDrawable named = (BaseDrawable)newDrawable; if (drawable instanceof BaseDrawable) named.setName(((BaseDrawable)drawable).getName() + " (" + tint + ")"); else named.setName(" (" + tint + ")"); } return newDrawable; }
/** Creates an image stretched, and aligned center. */ public Image (Texture texture) { this(new TextureRegionDrawable(new TextureRegion(texture))); }
/** Creates a new drawable that renders the same as this drawable tinted the specified color. */ public Drawable tint (Color tint) { Sprite sprite; if (region instanceof AtlasRegion) sprite = new AtlasSprite((AtlasRegion)region); else sprite = new Sprite(region); sprite.setColor(tint); sprite.setSize(getMinWidth(), getMinHeight()); SpriteDrawable drawable = new SpriteDrawable(sprite); drawable.setLeftWidth(getLeftWidth()); drawable.setRightWidth(getRightWidth()); drawable.setTopHeight(getTopHeight()); drawable.setBottomHeight(getBottomHeight()); return drawable; } }
public void setRegion (TextureRegion region) { this.region = region; if (region != null) { setMinWidth(region.getRegionWidth()); setMinHeight(region.getRegionHeight()); } }
Drawable drawable = ((TextureRegionDrawable) getUI().getSkin().getDrawable("circle")).tint(Color.RED);
/** Creates an image stretched, and aligned center. */ public Image (Texture texture) { this(new TextureRegionDrawable(new TextureRegion(texture))); }
/** Returns a copy of the specified drawable. */ public Drawable newDrawable (Drawable drawable) { if (drawable instanceof TiledDrawable) return new TiledDrawable((TiledDrawable)drawable); if (drawable instanceof TextureRegionDrawable) return new TextureRegionDrawable((TextureRegionDrawable)drawable); if (drawable instanceof NinePatchDrawable) return new NinePatchDrawable((NinePatchDrawable)drawable); if (drawable instanceof SpriteDrawable) return new SpriteDrawable((SpriteDrawable)drawable); throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass()); }