Skip to content

Commit

Permalink
We still need to access Actor.setWidth/Height.
Browse files Browse the repository at this point in the history
TypingLabel needs to go around its parent TextraLabel.
  • Loading branch information
tommyettinger committed Feb 20, 2025
1 parent ada63d6 commit 2db2418
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
20 changes: 19 additions & 1 deletion src/main/java/com/github/tommyettinger/textra/TextraLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ public TextraLabel setWrap(boolean wrap) {
}
return this;
}

@Override
public void setWidth(float width) {
super.setWidth(width);
Expand Down Expand Up @@ -547,6 +547,24 @@ public void setSize(float width, float height) {
invalidateHierarchy();
}

/**
* This only exists so code that needs to use {@link com.badlogic.gdx.scenes.scene2d.Actor#setWidth(float)} still
* can, even with setWidth() implemented here.
* @param width the new width, in world units as a float
*/
public void setSuperWidth(float width) {
super.setWidth(width);
}

/**
* This only exists so code that needs to use {@link com.badlogic.gdx.scenes.scene2d.Actor#setHeight(float)} still
* can, even with setHeight() implemented here.
* @param height the new height, in world units as a float
*/
public void setSuperHeight(float height) {
super.setHeight(height);
}

@Override
public void layout() {
float width = getWidth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public void setText(String newText, boolean modifyOriginalText, boolean restart)
} else {
workingLayout.setTargetWidth(0f);
font.markup(newText, workingLayout.clear());
setWidth(workingLayout.getWidth() + (style != null && style.background != null ?
setSuperWidth(workingLayout.getWidth() + (style != null && style.background != null ?
style.background.getLeftWidth() + style.background.getRightWidth() : 0.0f));
}
if (modifyOriginalText) saveOriginalText(newText);
Expand Down Expand Up @@ -839,11 +839,11 @@ public void setSize(float width, float height) {
// it changes layout, where we only want to change workingLayout.
boolean changed = false;
if (this.getWidth() != width) {
this.setWidth(width);
this.setSuperWidth(width);
changed = true;
}
if(this.getHeight() != height) {
this.setHeight(height);
this.setSuperHeight(height);
changed = true;
}
if(changed) {
Expand Down

0 comments on commit 2db2418

Please sign in to comment.