Package net.mezzdev.config.gui.api
Interface IConfigValuePopup<T>
- Type Parameters:
T- the config value type selected by this popup
public interface IConfigValuePopup<T>
Popup content opened by a custom config value editor.
The config GUI places the popup near the editor control and keeps it inside the visible config area. Implementations only need to provide their preferred size and handle drawing and hit testing inside the provided popup bounds.
- Since:
- 0.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordA preferred popup size. -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanHandle a typed character while this popup has an active text field.default booleanWhether the popup should close after it selects a value.voiddraw(net.minecraft.client.gui.GuiGraphics guiGraphics, net.minecraft.client.renderer.Rect2i area, double mouseX, double mouseY) Draw the popup.getClickedValue(net.minecraft.client.renderer.Rect2i area, double mouseX, double mouseY, int button) Get the value selected by a mouse click, orOptional.empty()when the click did not select a value.getDraggedValue(net.minecraft.client.renderer.Rect2i area, double mouseX, double mouseY, int button) Get the value selected while dragging the mouse, orOptional.empty()when this popup does not handle dragging.intThe preferred popup height.getHoveredValue(net.minecraft.client.renderer.Rect2i area, double mouseX, double mouseY) Get the value currently under the mouse, orOptional.empty()when hovering no value.default IConfigValuePopup.SizegetPreferredSize(int availableWidth, int availableHeight) Negotiate the preferred popup size for the currently available area.intgetWidth()The preferred popup width.default booleankeyPressed(int keyCode, int scanCode, int modifiers, Consumer<T> valueConsumer) Handle a key press while this popup has an active text field.default voidmouseReleased(net.minecraft.client.renderer.Rect2i area, double mouseX, double mouseY, int button) Called after a mouse button is released over an active popup, including after a handled drag.default booleanmouseScrolled(net.minecraft.client.renderer.Rect2i area, double mouseX, double mouseY, double scrollX, double scrollY) Handle mouse-wheel input over this popup.default voidonClosed()Called when this popup is closed or replaced.default voidonOpened()Called after this popup becomes active.
-
Method Details
-
getWidth
int getWidth()The preferred popup width.- Returns:
- the preferred popup width
- Since:
- 0.1.0
-
getHeight
int getHeight()The preferred popup height.- Returns:
- the preferred popup height
- Since:
- 0.1.0
-
getPreferredSize
Negotiate the preferred popup size for the currently available area.The default preserves fixed-size popup behavior. Responsive implementations can return a smaller layout when the preferred fixed size does not fit.
- Parameters:
availableWidth- available width inside the visible config areaavailableHeight- available height inside the visible config area- Returns:
- the preferred popup size for the available area
- Since:
- 0.1.0
-
getHoveredValue
Optional<T> getHoveredValue(net.minecraft.client.renderer.Rect2i area, double mouseX, double mouseY) Get the value currently under the mouse, orOptional.empty()when hovering no value.- Parameters:
area- the popup boundsmouseX- the current mouse x-coordinatemouseY- the current mouse y-coordinate- Returns:
- the hovered value
- Since:
- 0.1.0
-
draw
void draw(net.minecraft.client.gui.GuiGraphics guiGraphics, net.minecraft.client.renderer.Rect2i area, double mouseX, double mouseY) Draw the popup.- Parameters:
guiGraphics- the draw contextarea- the popup boundsmouseX- the current mouse x-coordinatemouseY- the current mouse y-coordinate- Since:
- 0.1.0
-
getClickedValue
default Optional<T> getClickedValue(net.minecraft.client.renderer.Rect2i area, double mouseX, double mouseY, int button) Get the value selected by a mouse click, orOptional.empty()when the click did not select a value.By default, a left-click selects the hovered value.
- Parameters:
area- the popup boundsmouseX- the click x-coordinatemouseY- the click y-coordinatebutton- the clicked mouse button- Returns:
- the clicked value
- Since:
- 0.1.0
-
getDraggedValue
default Optional<T> getDraggedValue(net.minecraft.client.renderer.Rect2i area, double mouseX, double mouseY, int button) Get the value selected while dragging the mouse, orOptional.empty()when this popup does not handle dragging.- Parameters:
area- the popup boundsmouseX- the current mouse x-coordinatemouseY- the current mouse y-coordinatebutton- the held mouse button- Returns:
- the value selected by the drag
- Since:
- 0.1.0
-
mouseScrolled
default boolean mouseScrolled(net.minecraft.client.renderer.Rect2i area, double mouseX, double mouseY, double scrollX, double scrollY) Handle mouse-wheel input over this popup.- Parameters:
area- the popup boundsmouseX- the current mouse x-coordinatemouseY- the current mouse y-coordinatescrollX- horizontal scroll amountscrollY- vertical scroll amount- Returns:
- true when the popup handled the scroll
- Since:
- 0.1.0
-
mouseReleased
default void mouseReleased(net.minecraft.client.renderer.Rect2i area, double mouseX, double mouseY, int button) Called after a mouse button is released over an active popup, including after a handled drag.Click selection is routed through
getClickedValue(Rect2i, double, double, int)separately. Releasing a handled drag does not invokegetClickedValueagain.- Parameters:
area- the popup boundsmouseX- the release x-coordinatemouseY- the release y-coordinatebutton- the released mouse button- Since:
- 0.1.0
-
onOpened
default void onOpened()Called after this popup becomes active.- Since:
- 0.1.0
-
onClosed
default void onClosed()Called when this popup is closed or replaced.- Since:
- 0.1.0
-
charTyped
Handle a typed character while this popup has an active text field.- Parameters:
codePoint- the typed charactermodifiers- the active keyboard modifiersvalueConsumer- receives a new value when the edit becomes valid- Returns:
- true when the popup handled the character
- Since:
- 0.1.0
-
keyPressed
Handle a key press while this popup has an active text field.- Parameters:
keyCode- the key codescanCode- the platform scan codemodifiers- the active keyboard modifiersvalueConsumer- receives a new value when the edit becomes valid- Returns:
- true when the popup handled the key press
- Since:
- 0.1.0
-
closesAfterValueSelected
default boolean closesAfterValueSelected()Whether the popup should close after it selects a value.Return
falsefor interactive controls such as color pickers that support several adjustments before the user clicks outside the popup.- Returns:
- true to close after selecting a value
- Since:
- 0.1.0
-