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 TypeMethodDescriptionvoid
Guis should use this method to add clientside styles and BackgroundPainters to their controlsvoid
addSlotPeer
(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.int
Gets the position of the screen title.default net.fabricmc.fabric.api.util.TriState
Checks whether dark mode is used for this GUI description.boolean
Tests whether the widget is the currently-focused one.boolean
Gets whether this GUI is fullscreen.boolean
Gets whether the title of this GUI should be rendered by the screen.void
releaseFocus
(WWidget widget) Notifies this gui that the widget wants to give up its hold over focus.void
requestFocus
(WWidget widget) Notifies this gui that the widget wants to acquire focus.void
setFullscreen
(boolean fullscreen) Sets whether this GUI is fullscreen.setPropertyDelegate
(PropertyDelegate delegate) Sets the object which manages the integer properties used by WBarssetRootPanel
(WPanel panel) void
setTitleAlignment
(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.void
setTitlePos
(Vec2i titlePos) Sets the position of the screen title.void
setTitleVisible
(boolean titleVisible) Sets whether the title of this GUI should be rendered by the screen.
-
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 -
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.TRUE
to force dark modeTriState.FALSE
to force light modeTriState.DEFAULT
to use the global dark mode setting
- Since:
- 7.1.0
-