Package tripleplay.ui
Class Tabs
A
Composite
that implements tabbing. Has a horizontal row of buttons along
the top and a stretching content group underneath. The buttons are instances of ToggleButton
. Each button is associated with a content element. When the button is clicked,
its content is shown alone in the content group.
This diagram shows a Tabs
with A and B tabs. When A's button is clicked, A's content
is shown. B content is not generated or not visible.
--------------------------------------
| ----- ----- |
| |*A*| | B | | <--- the buttons group, A selected
| ----- ----- |
|------------------------------------|
| | <--- the contentArea group
| -------------------------------- |
| | A content | |
| -------------------------------- |
| |
--------------------------------------
The tab content associated with a button is supplied on demand via a Supplier
instance. The contract of Supplier
is obeyed in that Supplier.close()
is called
whenever the associated tab goes out of scope.
NOTE: The inheritance from Composite means that child elements may not be added or removed directly. It you need, for example, a title bar, just use a Group with the title bar and tabs. TODO: do we care about scrolling buttons? yes
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Defines the highlighting of a tab.class
Represents a tab: button and content.Nested classes/interfaces inherited from class tripleplay.ui.Container
Container.Mutable<T extends Container.Mutable<T>>
Nested classes/interfaces inherited from class tripleplay.ui.Element
Element.Take
-
Field Summary
Modifier and TypeFieldDescriptionfinal Group
The row of buttons, one per tab.final Group
The content group.static Style<Tabs.Highlighter>
Style for highlighting a tab.static Tabs.Highlighter
A no-op highlighter to use if you want to make highlighting do nothing.final react.Value<Tabs.Tab>
The value containing the currently selected tab. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds a new tab to the container with a pre-constructed element for its content.Adds a new tab to the container with a pre-constructed element for its content.Adds a new tab to the container with the given label, icon and supplier.Adds a new tab to the container with the given label and supplier.void
destroyTab
(Tabs.Tab tab) Removes the given tab and destroys its resources.Gets our highlighter.void
repositionTab
(Tabs.Tab tab, int position) Moves the given tab into the given position.tabAt
(int index) Gets the tab at the given index, or null if the index is out of range.int
tabCount()
Gets the number of tabs.static Tabs.Highlighter
textColorHighlighter
(int originalColor, int highlightColor) Creates a highlighter that will simply change the button's text color.Methods inherited from class tripleplay.ui.Composite
childAt, childCount, iterator, setStylesheet, stylesheet
Methods inherited from class tripleplay.ui.Container
removeFromParent
Methods inherited from class tripleplay.ui.Element
addStyles, addStyles, bindEnabled, bindVisible, bounds, constraint, enabledSlot, hierarchyChanged, isAdded, isEnabled, isShowing, isVisible, location, parent, setConstraint, setEnabled, setStyles, setStyles, setVisible, size, styles, visibleSlot, x, y
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
NOOP_HIGHLIGHTER
A no-op highlighter to use if you want to make highlighting do nothing. -
HIGHLIGHTER
Style for highlighting a tab. The default value is a no-op highlighter. -
buttons
The row of buttons, one per tab. -
contentArea
The content group. -
selected
The value containing the currently selected tab.
-
-
Constructor Details
-
Tabs
public Tabs()Creates a new tabbed container.
-
-
Method Details
-
textColorHighlighter
Creates a highlighter that will simply change the button's text color.- Parameters:
originalColor
- the button text color when unhighlightedhighlightColor
- the button text color when highlighted
-
tabCount
public int tabCount()Gets the number of tabs. -
tabAt
Gets the tab at the given index, or null if the index is out of range. -
add
Adds a new tab to the container with the given label and supplier. Adds a new button to thebuttons
group. The supplier is used to generate an element to put in thecontentArea
group if and when the tab is selected.- Returns:
- the newly added tab
-
add
Adds a new tab to the container with a pre-constructed element for its content. This is a shortcut for callingadd(String, Supplier)
with aSupplier.auto(tripleplay.ui.Element<?>)
.- Returns:
- the newly added tab
-
add
Adds a new tab to the container with the given label, icon and supplier. Adds a new button to thebuttons
group. The supplier is used to generate an element to put in thecontentArea
group when the tab is selected.- Returns:
- the newly added tab
-
add
Adds a new tab to the container with a pre-constructed element for its content. Seeadd(String, Supplier)
.- Returns:
- the newly added tab
-
repositionTab
Moves the given tab into the given position. -
destroyTab
Removes the given tab and destroys its resources. -
highlighter
Gets our highlighter. Resolved from theHIGHLIGHTER
style.
-