You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
It is often very unintuitive how default sizes are applied, or why the setBackgroundPainter works on any panel but the root panel.
Describe the solution you'd like
For the RootPanel -> it is possible to set the background painters by overriding addPainters in the Description. That should not be necessary and simply setting setBackgroundPainter should be enough. Setting a value and than having it overwritten by another code piece is very unintuitive. The default code in description addPainters should, in my opinion, be
if (this.rootPanel!=null && !fullscreen && this.rootPanel.getBackgroundPainter() == null /* having null as the default if not set explicitly*/) {
this.rootPanel.setBackgroundPainter(BackgroundPainter.VANILLA);
}
For the default sizes:
a lot of Widgets could have reasonable default sizes e.g. a WLabel or WTextField could just calculate the default size based on their text content, or in the case of WTextField their MaxLength (its easy to do, as I am doing that right now with my workaround)
e.g by using: textRenderer.getWrappedLinesHeight, textRenderer.getWidth(text)
currently this would just be overwritten by calling WPlainPanel.add(widget, posX, posY) to be width 18, height 18 when not using the overload add(WWidget w, int x, int y, int width, int height) where you have to do all that calculation manually. This is especially cumbersome to do with split client-server code as you need to implement a facade that fakes the real calculated widths on the server and is implemented with the correct calls on the client.
Solution: if add(WWidget w, int x, int y) is called on a WPlainPanel, it should check the widget being added for its default/auto size and only if none is specified in the widget itself it would default to 18,18.
This solution would the current code that I have in at least half.
When on the subject of having a facade to call client code, such as MinecraftClient.getInstance().textrenderer.XXX
it would be really cool to have that built into the LibGui. i.e. the description base class could have methods that delegate the calls to the textrenderer when executed on the client, and return dummy values when called on the server.
I could add a PR for these changes myself, but would appreciate feedback first if this wouldn't break some behaviour with e.g. InventorySlot drawing that I am just not aware of.
The text was updated successfully, but these errors were encountered:
In 12.0.0, you can call setUseDefaultRootBackground(false) to disable the VANILLA background painter.
The default size feature can't really be implemented as the text renderer isn't available on the server. With the way LibGui is designed, it would need that cumbersome "facade that fakes the real calculated widths on the server" you mentioned.
I do think it'd make sense to add non-resizing overloads of the add methods, though.
Is your feature request related to a problem? Please describe.
It is often very unintuitive how default sizes are applied, or why the setBackgroundPainter works on any panel but the root panel.
Describe the solution you'd like
For the RootPanel -> it is possible to set the background painters by overriding addPainters in the Description. That should not be necessary and simply setting setBackgroundPainter should be enough. Setting a value and than having it overwritten by another code piece is very unintuitive. The default code in description addPainters should, in my opinion, be
For the default sizes:
e.g by using: textRenderer.getWrappedLinesHeight, textRenderer.getWidth(text)
Solution: if add(WWidget w, int x, int y) is called on a WPlainPanel, it should check the widget being added for its default/auto size and only if none is specified in the widget itself it would default to 18,18.
This solution would the current code that I have in at least half.
When on the subject of having a facade to call client code, such as MinecraftClient.getInstance().textrenderer.XXX
it would be really cool to have that built into the LibGui. i.e. the description base class could have methods that delegate the calls to the textrenderer when executed on the client, and return dummy values when called on the server.
I could add a PR for these changes myself, but would appreciate feedback first if this wouldn't break some behaviour with e.g. InventorySlot drawing that I am just not aware of.
The text was updated successfully, but these errors were encountered: