-
Notifications
You must be signed in to change notification settings - Fork 0
Tutorial EzLang Layout Modes Tab
Tab mode creates tabs for you based on child layouts. This means that in tab mode, you can only add other layouts, not individual widgets. The root layout cannot be tab mode. A tab header button will automatically be created for each child layout using the 'tab_name' property of the child layout as a tab name. If the 'tab_name' property is not set, the child ID is used. Here is an example with three tabs:
- Layout:
mode: box
orientation: vertical
- Label:
text: Tabs example:
auto_scale: true, true
halign: center
- Layout:
mode: tab
active_tab: tab_one
tab_header_fg_color: white
tab_header_bg_color: black
tab_header_border_fg_color: white
tab_header_border_bg_color: black
tab_header_active_fg_color: yellow
tab_header_active_bg_color: black
selection_order: 4
border: true
- Layout:
id: tab_one
tab_name: Tab one
mode: box
- Label:
text: Hello tab one!
- Layout:
id: tab_two
tab_name: Tab two
mode: box
- Label:
text: Hello tab two!
- Layout:
id: tab_three
tab_name: Tab three
mode: box
- Label:
text: Hello tab three!
Note that the active_tab property is optional, by default the first tab is active. Users can then switch tabs using the tab header buttons that are created automatically. This example also showed all tab related color properties, but because all default foreground colors are white and all default background colors are black, most could have been left out in this example.
Keep in mind that tab header buttons are three pixels high, so the effective height of your layout will be three pixels smaller.
It is possible to change the active tab from code. Although callbacks will be discussed in a later chapter, we'll look at an example just for reference:
use ez_term::*;
fn change_tab_callback(context: Context) {
let state = context.state_tree.get_mut("my_tab_layout").as_layout_mut();
state.set_active_tab("tab_two");
state.update(context.scheduler);
}
The general tutorial continues with: EzLang Screen mode layouts.
Tutorial
Tutorial-Project-StructureMinimal example
EzLang
EzLang basics
EzLang Templates
Ezlang Layout modes
EzLang Box mode layouts
EzLang Stack mode layouts
EzLang Table mode layouts
EzLang Float mode layouts
EzLang Tab mode layouts
EzLang Screen mode layouts
EzLang Layout Scrolling
EzLang Layout Views
EzLang Widget overview
EzLang Label
EzLang Text Input
EzLang Button
EzLang Checkbox
EzLang Radio button
EzLang Dropdown
EzLang Slider
EzLang Canvas
EzLang Property Binding
EzLang Sizing
EzLang Size hints
EzLang Auto scaling
EzLang Maths Sizing
EzLang Manual Sizing
EzLang Positioning
EzLang Layout Mode Positioning
EzLang Position Hints
EzLang Position Maths
EzLang Manual Position
EzLang Adjusting Position
EzLang Keyboard Selection
Scheduler
Widget States and the State Tree
The Scheduler Object
Managing callbacks
Callback Structure
Callback Configs
Callback: On keyboard enter
Callback: On Left Mouse Click
Callback: On Press
Callback: On Select
Callback: On Deselect
Callback: On Right Mouse Click
Callback: On Hover
Callback: On Drag
Callback: On Scroll Up
Callback: On Scroll Down
Callback: On Value Change
Callback: Custom Key Binds
Callback: Global Key Binds
Callback: Property Binds
Tasks
Scheduled Single Exectution Tasks
Scheduled Recurring Tasks
Threaded Tasks
Custom Properties
Modals
Programmatic Widgets
Updating widgets
Managing selection
Default global (key)binds
Performance
Examples
Layout: Box Mode NestedLayout: Box Mode Size Hints
Layout: Stack Mode
Layout: Table Mode Dynamic
Layout: Table Mode Static
Layout: Float Mode Manual
Layout: Float Mode Position hints
Layout: Screen Mode
Layout: Tab Mode
Layout: Scrolling
Layout: Views
Widget: Label
Widget: Text input
Widget: Button
Widget: Checkbox
Widget: Radio Button
Widget: Dropdown
Widget: Slider
Widget: Progress Bar
Widget: Canvas
Scheduler: Schedule Once
Scheduler: Schedule Once Callback
Scheduler: Schedule Recurring
Scheduler: Schedule Recurring Callback
Scheduler: Threaded Task State Tree
Scheduler: Threaded Task Custom Property
Scheduler: Create Widgets
Scheduler: Modal Popup
Reference
WidgetsCommon Properties
Label
Text Input
Button
Checkbox
Radio button
Dropdown
Slider
Canvas
Scheduler
Schedule once
Schedule Recurring
Schedule Threaded
Cancel Task
Cancel Recurring Task
Create Widget
Remove Widget
Select Widget
Deselect Widget
Update Widget
Force Redraw
Open Modal
Dismiss Modal
Bind Global Key
Remove Global Key
Clear Global Keys
Bind Property
Create Custom Properties
Get Property
Get Property Mut
Overwrite Callback Config
Update Callback Config
Exit