-
Notifications
You must be signed in to change notification settings - Fork 0
Tutorial EzLang Layout Modes Float
In float mode, widgets can be placed freely anywhere in the layout. This mode does not have any orientations. Placing widgets can be done using hardcoded positions, or using position hints. Positions hints are suggestions for where you want to place your widgets; the framework will then do the work for you. Let's say we want to put a label in each corner of the screen and one label in the middle of the screen, like this:
1 2
3
4 5
We could most easily accomplish this using a float layout with position hints:
- <FloatLabel@Label>:
auto_scale: true, true
- Layout:
mode: float
- FloatLabel:
text: 1
pos_hint: left, top
- FloatLabel:
text: 2
pos_hint: right, top
- FloatLabel:
text: 3
pos_hint: center, middle
- FloatLabel:
text: 4
pos_hint: left, bottom
- FloatLabel:
text: 5
pos_hint: right, bottom
All the positioning is taken care of for us; even if the window resizes these relative positions will be maintained. available The position hints are:
- Horizontal:
- Left
- Center
- Right
- Vertical
- Top
- Middle
- Bottom
You can also specify an offset with positions hints, for example 'right: 0.2' means 20% of the right side of the parent. So if the parent is 10 wide, 'right: 0.2' resolves to the x position '2'. Let's use position hints with offsets to create a label that is slightly off-center:
- Layout:
mode: float
- Label:
text: Hello world
pos_hint: right: 0.4, bottom: 0.6
auto_scale: true, true
Float mode also allows you to hardcode positions:
- Layout:
mode: float
- Label:
text: Hello world
auto_scale: true, true
pos: 10, 10
There are use cases for hard coded positions, but keep in mind these positions won't change if the terminal is resized. In most cases position hints are the better choice as they will scale with the terminal.
The general tutorial continues with: EzLang Tab 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