UI.Builder

From GiderosMobile

Available since: Gideros 2023.1
Class: UI

Description

Builds UI layouts.

UI.Builder(layout)

Parameters

layout: (table) all the widgets composing the UI layout

Example

A login layout

local loginui=UI.Builder({
	class="UI.Panel",
	layoutModel=UI.Layout.Vertical,
	children={
		{
			Border=UI.Border.Basic.new{ thickness=8, radius=16, bgColor=0x5555ff, fgColor=0x000055 },
			class="UI.Panel", Color=0xffffff,
			layoutModel=UI.Layout.Vertical,
			children={
				{ class="UI.Label", Text="Login:", Color=0x0000aa, },
				{ class="UI.TextField", name="tfLogin", Color=0x0000ff, },
				{ class="UI.Label", Text="Password:", Color=0x0000aa, },
				{ class="UI.TextField", name="tfPass", Password="•", Color=0x0000ff,  },
				{ class="UI.Label", Text="Server:" },
				{ class="UI.TextField", name="tfServer" },
				{ class="UI.Label", 
					name="tfError", Text="", 
					TextLayout={flags=FontBase.TLF_CENTER|FontBase.TLF_VCENTER|FontBase.TLF_REF_LINETOP|FontBase.TLF_BREAKWORDS}, 
					Style={ font=TTFont.new("fonts/OpenSans-Regular.ttf",10,"") }, 
					Color=0xFF4040,
				},
				{ class="UI.Panel", Color=0x00ff00, layoutModel=UI.Layout.Vertical, 
					children={
						{ class="UI.Panel", Color=0x0000ff, layoutModel=UI.Layout.Vertical,layout={}, 
							Border=UI.Border.Basic.new{ radius=3, bgColor=0x8080FF}, name="tfConnect", 
							children={
								{ class="UI.Label", Text="Connect" }
							}
						},
					}
				},
			}
		}
	}
})

-- ui screen
loginui:setPosition(64, 64)
local screen=UI.Screen.new()
screen:ui(loginui)