From 2db2418f38f41e58f45704e6b4565bddc1357bae Mon Sep 17 00:00:00 2001 From: Tommy Ettinger Date: Thu, 20 Feb 2025 15:29:36 -0800 Subject: [PATCH] We still need to access Actor.setWidth/Height. TypingLabel needs to go around its parent TextraLabel. --- .../tommyettinger/textra/TextraLabel.java | 20 ++++++++++++++++++- .../tommyettinger/textra/TypingLabel.java | 6 +++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/tommyettinger/textra/TextraLabel.java b/src/main/java/com/github/tommyettinger/textra/TextraLabel.java index b8641c24..0ff12d95 100644 --- a/src/main/java/com/github/tommyettinger/textra/TextraLabel.java +++ b/src/main/java/com/github/tommyettinger/textra/TextraLabel.java @@ -519,7 +519,7 @@ public TextraLabel setWrap(boolean wrap) { } return this; } - + @Override public void setWidth(float width) { super.setWidth(width); @@ -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(); diff --git a/src/main/java/com/github/tommyettinger/textra/TypingLabel.java b/src/main/java/com/github/tommyettinger/textra/TypingLabel.java index f0f27ce9..f60ebff7 100644 --- a/src/main/java/com/github/tommyettinger/textra/TypingLabel.java +++ b/src/main/java/com/github/tommyettinger/textra/TypingLabel.java @@ -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); @@ -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) {