diff options
author | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-06-30 20:14:24 +0300 |
---|---|---|
committer | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-06-30 20:14:24 +0300 |
commit | 5f108ee93b32475d254f82032b7919986a7b0706 (patch) | |
tree | c788dd2432f7196df42bdb8ae220e40445dd31cd | |
parent | a991dd97d05f275bbd55049b18532fe748ba8514 (diff) | |
download | LibGui-5f108ee93b32475d254f82032b7919986a7b0706.tar.gz LibGui-5f108ee93b32475d254f82032b7919986a7b0706.tar.bz2 LibGui-5f108ee93b32475d254f82032b7919986a7b0706.zip |
Add WWidget.host accessors, use them in WListPanel to avoid unsafe validations
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java | 5 | ||||
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java | 23 |
2 files changed, 26 insertions, 2 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java index 9ba8562..bcfbf2b 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java @@ -97,8 +97,9 @@ public class WListPanel<D, W extends WWidget> extends WClippedPanel { child.setParent(this); // Set up the widget's host if (host != null) { - child.validate(host); - child.createPeers(host); + // setHost instead of validate since we cannot have independent validations + // TODO: System for independently validating widgets? + child.setHost(host); } return child; } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java index 8df8e14..824a5b2 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java @@ -368,6 +368,29 @@ public class WWidget { } /** + * Gets the host of this widget. + * + * @return the host + * @see #host + * @since 2.1.0 + */ + @Nullable + public final GuiDescription getHost() { + return host; + } + + /** + * Sets the host of this widget without creating peers. + * + * @param host the new host + * @see #host + * @since 2.1.0 + */ + public void setHost(@Nullable GuiDescription host) { + this.host = host; + } + + /** * Adds lines to this widget's tooltip. If the lines remain empty after this call, no tooltip will be drawn. * @param tooltip List containing all previous tooltip data. */ |