Aller au contenu
galdurdocs

GaldurTabs

classclient uniquementdepuis 0.1.0

com.galdurstudio.galdurui.api.widget.GaldurTabs

Pas encore traduit : texte d’origine en anglais.

Themed row of tabs, usable in vanilla layouts. The player switches tab with a click, or with the left and right arrows.

Like GaldurScrollList, the widget does not keep the active tab: it reads it every frame from a supplier and reports the tab the player picks. Showing the matching content is up to the caller; in a GaldurWindow, addTabs() does it.

Example.java
List<Component> titles = List.of(Component.literal("Storage"), Component.literal("Crafting"));int[] active = {0};column.addChild(GaldurTabs.of(titles, () -> active[0], index -> active[0] = index));
  • Active tab: tab_selected sprite tinted accent, joined to the bottom line of the same colour.
  • Other tabs: lower, tab sprite tinted surface, text_muted text; the tint moves towards the accent on hover.
  • Keyboard: left and right arrows while the row has focus; the active tab is then outlined in accent_hover.
  • Disabled (active = false): muted colours, no click or arrows.

Sizes from the theme: spacing.tab_height and spacing.tab_padding_x. The width can exceed the tabs' (see of()): the bottom line then runs the full width and the tabs stay on the left.

public class GaldurTabs extends AbstractWidget
PAQUETapi.widget
CÔTÉclient uniquement
HÉRITE DEAbstractWidget

Constructeurs 1

GaldurTabs

protected
protected GaldurTabs(int width, List<Component> titles, IntSupplier selected, IntConsumer onSelect)

Prefer of().

PARAMÈTRES

widthintwanted width, in pixels; never less than the tabs'
titlesList<Component>tab titles, in order; the list is copied
selectedIntSuppliersupplier of the active tab index, called every frame
onSelectIntConsumercalled with the index of the tab the player picks

Méthodes 4

of

static2 surcharges
public static GaldurTabs of(List<Component> titles, IntSupplier selected, IntConsumer onSelect)
public static GaldurTabs of(int width, List<Component> titles, IntSupplier selected, IntConsumer onSelect)

PARAMÈTRES

titlesList<Component>tab titles, in order; the list is copied
selectedIntSuppliersupplier of the active tab index, called every frame
onSelectIntConsumercalled with the index of the tab the player picks
widthintminimum width, in pixels

RENVOIEGaldurTabs — a tab row just wide enough for its titles, at (0, 0) for a layout to place

preferredWidth

static
public static int preferredWidth(List<Component> titles)

PARAMÈTRES

titlesList<Component>the tab titles

RENVOIEint — the width that shows all tabs side by side, gaps included

getTitles

public List<Component> getTitles()

RENVOIEList<Component> — the tab titles, read-only

clicked

protected
protected boolean clicked(double mouseX, double mouseY)

Only a click on a tab counts: no sound or focus on the line or the empty space.

PARAMÈTRES

mouseXdouble—
mouseYdouble—
© 2026 Galdur Studio · galdurstudio.com · Discord · LGPL-3.0-onlyProduit non officiel. Non approuvé par Mojang ou Microsoft, ni associé à eux.