aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJuuxel <6596629+Juuxel@users.noreply.github.com>2020-06-30 20:14:24 +0300
committerJuuxel <6596629+Juuxel@users.noreply.github.com>2020-06-30 20:14:24 +0300
commit5f108ee93b32475d254f82032b7919986a7b0706 (patch)
treec788dd2432f7196df42bdb8ae220e40445dd31cd /src
parenta991dd97d05f275bbd55049b18532fe748ba8514 (diff)
downloadLibGui-5f108ee93b32475d254f82032b7919986a7b0706.tar.gz
LibGui-5f108ee93b32475d254f82032b7919986a7b0706.tar.bz2
LibGui-5f108ee93b32475d254f82032b7919986a7b0706.zip
Add WWidget.host accessors, use them in WListPanel to avoid unsafe validations
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java5
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java23
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.
*/