XU XUv0.13.1
中文

UI / WIDGETS / Layout

SplitView

Arrange content in resizable panes

Run the Xu example

The example executes in the browser using the Xu/WASM runtime.

What to try

Resize the two panes.

Usage notes

The split ratio allocates space to two panes. Parent content to the correct pane and enforce minimum sizes so resizing cannot make it unusable.

Create through Screen

The Screen constructor returns a node ID. Pass that ID to Screen layout, state and event APIs. It is separate from the standalone control object documented below.

Native Xu setup fragment: call configure during initialization of an existing Screen. See the complete example for window creation, event dispatch and cleanup.

#ui/widgets

fn configure(screen $&widgets.Screen) int {
    id := screen.split_view(0.4) or >>
    screen.place(id,24.0,24.0,320.0,80.0) or >>
    << id
}

($&Screen) split_view

XuAPI
pub fn (s $&Screen) split_view(ratio f64) int

Purpose

Create SplitView in Screen and return the component node ID; throw on creation failure.

Parameters

s $&Screen
The Screen instance used by this call (exclusive borrow).
ratio f64
ratio (f64)

Returns

int — component node ID for place and other Screen methods.

Placement, state and events

The application owns the component. Screen.place positions nodes; Screen.set_enabled and Screen.set_visible control availability and visibility. Present again after state changes, handle or errors, and keep topology changes outside paint callbacks. ToastHost uses its own queue API.

Action · Styles · UI lifecycle and styling guide

Screen.place · Screen.set_enabled · Screen.set_visible

Standalone control object API

These types and methods support applications that manage control objects, input and painting directly. Their receiver is a control object, not a Screen node ID. For Screen usage, use the constructor above and the Screen methods in the Widgets module.

struct SplitView

XuAPI
pub struct SplitView {

}

Purpose

SplitView context or state structure.

Public fields

This type has no public fields.

(&SplitView) id

XuAPI
pub fn (v &SplitView) id() int

Purpose

Return the unique integer ID of the element or control.

Parameters

v &SplitView
The SplitView instance used by this call (borrow).

Returns

int — a value of this type

(&SplitView) bounds

XuAPI
pub fn (v &SplitView) bounds() layout.Rect

Purpose

Return the bounding Rectangle of the control or geometry.

Parameters

v &SplitView
The SplitView instance used by this call (borrow).

Returns

layout.Rect — a value of this type

(&SplitView) value

XuAPI
pub fn (v &SplitView) value() f64

Purpose

Execute value on &SplitView.

Parameters

v &SplitView
The SplitView instance used by this call (borrow).

Returns

f64 — a value of this type

(&SplitView) needs_paint

XuAPI
pub fn (v &SplitView) needs_paint() bool

Purpose

Return whether the control needs repainting; call painted after painting to clear the flag.

Parameters

v &SplitView
The SplitView instance used by this call (borrow).

Returns

bool — true or false

($&SplitView) painted

XuAPI
pub fn (v $&SplitView) painted()

Purpose

Acknowledge the painted frame and clear the dirty flag; this is not a query.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).

Returns

This call does not return a value.

(&SplitView) is_enabled

XuAPI
pub fn (v &SplitView) is_enabled() bool

Purpose

Return whether the control is currently enabled.

Parameters

v &SplitView
The SplitView instance used by this call (borrow).

Returns

bool — true or false

(&SplitView) geometry

XuAPI
pub fn (v &SplitView) geometry(bounds &layout.Rect,density f64) SplitLayout

Purpose

Execute geometry on &SplitView.

Parameters

v &SplitView
The SplitView instance used by this call (borrow).
bounds &layout.Rect
bounds (read-only borrow; caller keeps the original; type &layout.Rect)
density f64
density (f64)

Returns

SplitLayout — a value of this type

(&SplitView) layout

XuAPI
pub fn (v &SplitView) layout() SplitLayout

Purpose

Execute layout on &SplitView.

Parameters

v &SplitView
The SplitView instance used by this call (borrow).

Returns

SplitLayout — a value of this type

($&SplitView) set_ratio

XuAPI
pub fn (v $&SplitView) set_ratio(value f64) int

Purpose

Operation on $&SplitView: set ratio. Throws on failure; handle the error or propagate it to the caller.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).
value f64
value (f64)

Returns

int — a value of this type

($&SplitView) set_collapsed

XuAPI
pub fn (v $&SplitView) set_collapsed(pane int,collapsed bool) int

Purpose

Collapse retains the requested ratio; expanding restores it under current minima. Throws on failure; handle the error or propagate it to the caller.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).
pane int
pane (int)
collapsed bool
collapsed (bool)

Returns

int — a value of this type

($&SplitView) set_options

XuAPI
pub fn (v $&SplitView) set_options(o &SplitViewOptions) int

Purpose

Operation on $&SplitView: set options. Throws on failure; handle the error or propagate it to the caller.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).
o &SplitViewOptions
o (read-only borrow; caller keeps the original; type &SplitViewOptions)

Returns

int — a value of this type

($&SplitView) cancel

XuAPI
pub fn (v $&SplitView) cancel()

Purpose

Execute cancel on $&SplitView.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&SplitView) set_focus

XuAPI
pub fn (v $&SplitView) set_focus(value bool)

Purpose

Operation on $&SplitView: set focus.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).
value bool
value (bool)

Returns

This call does not return a value.

($&SplitView) set_enabled

XuAPI
pub fn (v $&SplitView) set_enabled(value bool)

Purpose

Operation on $&SplitView: set enabled.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).
value bool
value (bool)

Returns

This call does not return a value.

($&SplitView) set_read_only

XuAPI
pub fn (v $&SplitView) set_read_only(value bool)

Purpose

Operation on $&SplitView: set read only.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).
value bool
value (bool)

Returns

This call does not return a value.

($&SplitView) set_bounds

XuAPI
pub fn (v $&SplitView) set_bounds(b &layout.Rect) int

Purpose

Operation on $&SplitView: set bounds. Throws on failure; handle the error or propagate it to the caller.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).
b &layout.Rect
b (read-only borrow; caller keeps the original; type &layout.Rect)

Returns

int — a value of this type

($&SplitView) set_style

XuAPI
pub fn (v $&SplitView) set_style(style &ControlStyle) int

Purpose

Operation on $&SplitView: set style. Throws on failure; handle the error or propagate it to the caller.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).
style &ControlStyle
style (read-only borrow; caller keeps the original; type &ControlStyle)

Returns

int — a value of this type

($&SplitView) clear_style

XuAPI
pub fn (v $&SplitView) clear_style()

Purpose

Operation on $&SplitView: clear style.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&SplitView) set_motion

XuAPI
pub fn (v $&SplitView) set_motion(spec &MotionSpec) int

Purpose

Operation on $&SplitView: set motion. Throws on failure; handle the error or propagate it to the caller.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).
spec &MotionSpec
spec (read-only borrow; caller keeps the original; type &MotionSpec)

Returns

int — a value of this type

($&SplitView) apply_styles

XuAPI
pub fn (v $&SplitView) apply_styles(styles &Styles) int

Purpose

Resolve and apply theme metrics to the control.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

int — a value of this type

($&SplitView) tick

XuAPI
pub fn (v $&SplitView) tick(styles &Styles,now time.Instant,reduced bool) bool

Purpose

Advance animation clock and state transition step. Throws on failure; handle the error or propagate it to the caller.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)
now time.Instant
now (time.Instant)
reduced bool
reduced (bool)

Returns

bool — true or false

(&SplitView) next_tick

XuAPI
pub fn (v &SplitView) next_tick(now time.Instant) time.Instant

Purpose

Operation on &SplitView: next tick. Throws on failure; handle the error or propagate it to the caller.

Parameters

v &SplitView
The SplitView instance used by this call (borrow).
now time.Instant
now (time.Instant)

Returns

time.Instant — a value of this type

($&SplitView) dispose

XuAPI
pub fn (v $&SplitView) dispose()

Purpose

Release and dispose native resources and underlying handles.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&SplitView) input

XuAPI
pub fn (v $&SplitView) input(event &ui.InputEvent) Action

Purpose

Process routed mouse, keyboard, or touch input events.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).
event &ui.InputEvent
event (read-only borrow; caller keeps the original; type &ui.InputEvent)

Returns

Action — input result with kind, id, repaint and focus requests.

($&SplitView) route

XuAPI
pub fn (v $&SplitView) route(kind int,event &ui.InputEvent) Action

Purpose

Route and dispatch the input event to matching targets. Throws on failure; handle the error or propagate it to the caller.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).
kind int
kind tag (int)
event &ui.InputEvent
event (read-only borrow; caller keeps the original; type &ui.InputEvent)

Returns

Action — input result with kind, id, repaint and focus requests.

($&SplitView) paint_styled

XuAPI
pub fn (v $&SplitView) paint_styled(frame $&draw.Frame,styles &Styles) int

Purpose

Operation on $&SplitView: paint styled. Throws on failure; handle the error or propagate it to the caller.

Parameters

v $&SplitView
The SplitView instance used by this call (exclusive borrow).
frame $&draw.Frame
frame (exclusive borrow; may modify the original; type $&draw.Frame)
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

int — a value of this type

Complete native example

Component Workshop · Back to Widgets