Package io.github.cottonmc.cotton.gui
Interface GuiDescription
- All Known Implementing Classes:
ItemSyncedGuiDescription,LightweightGuiDescription,SyncedGuiDescription
public interface GuiDescription
A GUI description represents a GUI without depending on screens.
GUI descriptions contain the root panel and the property delegate of the GUI. They also manage the focused widget.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidGuis should use this method to add clientside styles and BackgroundPainters to their controlsvoidaddSlotPeer(ValidatedSlot slot) Typical users won't call this.getFocus()Gets the currently-focused WWidget.Gets the object which manages the integer properties used by WBars and such.Gets the horizontal alignment of the GUI title.intGets the position of the screen title.booleanTests whether the root panel should get a vanilla background in the defaultaddPainters()implementations.default net.fabricmc.fabric.api.util.TriStateChecks whether dark mode is used for this GUI description.booleanTests whether the widget is the currently-focused one.booleanGets whether this GUI is fullscreen.booleanGets whether the title of this GUI should be rendered by the screen.voidreleaseFocus(WWidget widget) Notifies this gui that the widget wants to give up its hold over focus.voidrequestFocus(WWidget widget) Notifies this gui that the widget wants to acquire focus.voidsetFullscreen(boolean fullscreen) Sets whether this GUI is fullscreen.setPropertyDelegate(PropertyDelegate delegate) Sets the object which manages the integer properties used by WBarssetRootPanel(WPanel panel) voidsetTitleAlignment(HorizontalAlignment alignment) Sets the horizontal alignment of the GUI title.setTitleColor(int color) Sets the title color of this GUI.setTitleColor(int lightColor, int darkColor) Sets the light and dark title colors of this GUI.voidsetTitlePos(Vec2i titlePos) Sets the position of the screen title.voidsetTitleVisible(boolean titleVisible) Sets whether the title of this GUI should be rendered by the screen.voidsetUseDefaultRootBackground(boolean useDefaultRootBackground) Enables or disables the default vanilla background for root panels.
-
Method Details
-
getRootPanel
WPanel getRootPanel() -
getTitleColor
int getTitleColor() -
setRootPanel
-
setTitleColor
Sets the title color of this GUI.The dark-mode title color will also be set by this method. If the specified color is
WLabel.DEFAULT_TEXT_COLOR, the dark-mode color will beWLabel.DEFAULT_DARKMODE_TEXT_COLOR; otherwise it will be the specified color.- Parameters:
color- the new title color- Returns:
- this GUI
-
setTitleColor
Sets the light and dark title colors of this GUI.- Parameters:
lightColor- the light-mode colordarkColor- the dark-mode color- Returns:
- this GUI
- Since:
- 2.1.0
-
setPropertyDelegate
Sets the object which manages the integer properties used by WBars -
addSlotPeer
Typical users won't call this. This adds a Slot to Container/Controller-based guis, and does nothing on lightweight guis. -
addPainters
@Environment(CLIENT) void addPainters()Guis should use this method to add clientside styles and BackgroundPainters to their controls -
getUseDefaultRootBackground
boolean getUseDefaultRootBackground()Tests whether the root panel should get a vanilla background in the defaultaddPainters()implementations.- Returns:
trueif the default background painter is applied,falseotherwise- Since:
- 12.0.0
-
setUseDefaultRootBackground
void setUseDefaultRootBackground(boolean useDefaultRootBackground) Enables or disables the default vanilla background for root panels.- Parameters:
useDefaultRootBackground-trueif the default background painter is applied,falseotherwise- Since:
- 12.0.0
- See Also:
-
getPropertyDelegate
Gets the object which manages the integer properties used by WBars and such. -
isFocused
Tests whether the widget is the currently-focused one. -
getFocus
Gets the currently-focused WWidget. May be null. -
requestFocus
Notifies this gui that the widget wants to acquire focus. -
releaseFocus
Notifies this gui that the widget wants to give up its hold over focus. -
isFullscreen
boolean isFullscreen()Gets whether this GUI is fullscreen.Fullscreen GUIs have no default background painter and have the root panel stretched to fit the entire screen on the client.
- Returns:
- true if this GUI is fullscreen, false otherwise
- Since:
- 2.0.0
-
setFullscreen
void setFullscreen(boolean fullscreen) Sets whether this GUI is fullscreen.- Parameters:
fullscreen- true if this GUI is fullscreen, false otherwise- Since:
- 2.0.0
-
isTitleVisible
boolean isTitleVisible()Gets whether the title of this GUI should be rendered by the screen.Modders can disable this to render the title themselves with a widget.
- Returns:
- true if the title is visible, false otherwise
- Since:
- 2.0.0
-
setTitleVisible
void setTitleVisible(boolean titleVisible) Sets whether the title of this GUI should be rendered by the screen.- Parameters:
titleVisible- true if the title is visible, false otherwise- Since:
- 2.0.0
-
getTitleAlignment
HorizontalAlignment getTitleAlignment()Gets the horizontal alignment of the GUI title.- Returns:
- the alignment
- Since:
- 2.1.0
-
setTitleAlignment
Sets the horizontal alignment of the GUI title.- Parameters:
alignment- the new alignment- Since:
- 2.1.0
-
getTitlePos
Vec2i getTitlePos()Gets the position of the screen title.- Returns:
- the title position
- Since:
- 4.0.0
-
setTitlePos
Sets the position of the screen title.- Parameters:
titlePos- the new title position- Since:
- 4.0.0
-
isDarkMode
default net.fabricmc.fabric.api.util.TriState isDarkMode()Checks whether dark mode is used for this GUI description.- Returns:
TriState.TRUEto force dark modeTriState.FALSEto force light modeTriState.DEFAULTto use the global dark mode setting
- Since:
- 7.1.0
-