Package com.simsilica.lemur.component
Class TbtQuadBackgroundComponent
java.lang.Object
com.simsilica.lemur.component.AbstractGuiComponent
com.simsilica.lemur.component.TbtQuadBackgroundComponent
- All Implemented Interfaces:
ColoredComponent
,GuiComponent
,Cloneable
public class TbtQuadBackgroundComponent
extends AbstractGuiComponent
implements Cloneable, ColoredComponent
A texture-covered background quad.
All coordinates are relative to the lower-left border.
The texture is split up into a three-by-three grid in this fashion:
+---+--------------+-------+ | | <-----> | | y2 +---+--------------+-------+ | | | | | ^ | ^ | ^ | | | | | | | | | | | <-----> | | | | | | | | | | | v | v | v | | | | | y1 +---+--------------+-------+ | | <-----> | | +---+--------------+-------+ x1 x2Arrows indicate the direction in which each grid cell will stretch to fill the area given by the component.
All coordinates are relative to the lower-left border.
Common pitfalls
- Placing controls on a fractional coordinate. This usually happens when centering controls.
- Having a contrast at the border between stretched and unstretched texture
zone (e.g. a black border and a white center). Stretching involves
interpolating colors with the neighbouring pixels (i.e. you'll get a
black-to-white color gradient).
The easiest workaround is to make the border one pixel wider so that the contrast will be safely inside the unstretched area. - Using a texture that is larger than the quad.
-
Constructor Summary
ConstructorsConstructorDescriptionTbtQuadBackgroundComponent
(TbtQuad quad, Texture texture) TbtQuadBackgroundComponent
(TbtQuad quad, Texture texture, float xMargin, float yMargin) TbtQuadBackgroundComponent
(TbtQuad quad, Texture texture, float xMargin, float yMargin, float zOffset, boolean lit) -
Method Summary
Modifier and TypeMethodDescriptionvoid
attach
(GuiControl parent) void
clone()
static TbtQuadBackgroundComponent
static TbtQuadBackgroundComponent
create
(String texture, float imageScale, int x1, int y1, int x2, int y2, float zOffset, boolean lit) protected void
protected void
void
detach
(GuiControl parent) float
getAlpha()
Returns the current alpha multiplier that is applied to the color when set to the actual visuals.getColor()
Returns the current color of this component.float
protected void
refreshBackground
(Vector3f size) protected void
void
void
setAlpha
(float f) Sets an alpha multiplier that will be applied to the color when set to the actual visuals.void
Sets the color for this component.void
setMargin
(float x, float y) void
void
void
setZOffset
(float z) toString()
Methods inherited from class com.simsilica.lemur.component.AbstractGuiComponent
getGuiControl, getNode, invalidate, isAttached
-
Constructor Details
-
TbtQuadBackgroundComponent
-
TbtQuadBackgroundComponent
-
TbtQuadBackgroundComponent
-
TbtQuadBackgroundComponent
-
-
Method Details
-
create
public static TbtQuadBackgroundComponent create(String texture, float imageScale, int x1, int y1, int x2, int y2, float zOffset, boolean lit) -
create
public static TbtQuadBackgroundComponent create(Texture t, float imageScale, int x1, int y1, int x2, int y2, float zOffset, boolean lit) -
clone
- Specified by:
clone
in interfaceGuiComponent
- Overrides:
clone
in classAbstractGuiComponent
-
attach
- Specified by:
attach
in interfaceGuiComponent
- Overrides:
attach
in classAbstractGuiComponent
-
detach
- Specified by:
detach
in interfaceGuiComponent
- Overrides:
detach
in classAbstractGuiComponent
-
setColor
Description copied from interface:ColoredComponent
Sets the color for this component.- Specified by:
setColor
in interfaceColoredComponent
-
resetColor
protected void resetColor() -
getColor
Description copied from interface:ColoredComponent
Returns the current color of this component.- Specified by:
getColor
in interfaceColoredComponent
-
setAlpha
public void setAlpha(float f) Description copied from interface:ColoredComponent
Sets an alpha multiplier that will be applied to the color when set to the actual visuals.- Specified by:
setAlpha
in interfaceColoredComponent
-
getAlpha
public float getAlpha()Description copied from interface:ColoredComponent
Returns the current alpha multiplier that is applied to the color when set to the actual visuals.- Specified by:
getAlpha
in interfaceColoredComponent
-
setTexture
-
getTexture
-
setMargin
public void setMargin(float x, float y) -
setMargin
-
getMargin
-
setZOffset
public void setZOffset(float z) -
getZOffset
public float getZOffset() -
getMaterial
-
calculatePreferredSize
- Specified by:
calculatePreferredSize
in interfaceGuiComponent
-
reshape
- Specified by:
reshape
in interfaceGuiComponent
-
createMaterial
protected void createMaterial() -
createGeometry
protected void createGeometry() -
refreshBackground
-
toString
-