Built-in types

In this document, we provide all the built-in types that you can use directly in the GenUI project. Generally speaking, you will rarely use these types because GenUI has shielded the lowest-level component construction for you.

However, since the writing of the attribute values ​​of these built-in types will be involved in the built-in components, we still provide you with a relatively complete writing reference.

TIP

If you have studied the value parsing and writing in the Data Type section, you should be able to understand how to write it very easily.

Align

Usage

range: [0.0, 1.0]

  • {x: 0.5}
  • {y: 0.2}
  • {x: 0.2, y: 0.9}

Source Code

1pub struct Align {
2    pub x: f64,
3    pub y: f64,
4}

GChooseType

Usage

  • Round
  • Tick
  • Cross
  • GChooseType::Round
  • GChooseType::Tick
  • GChooseType::Cross

Source Code

1pub enum GChooseType {
2    #[default]
3    Round,
4    Tick,
5    Cross,
6}

MouseCursor

Usage

  • Hidden
  • Hand
  • MouseCursor::Move

Source Code

1pub enum MouseCursor {
2    Hidden,
3    /// default
4    #[default]
5    Default,
6    Crosshair,
7    Hand,
8    Arrow,
9    Move,
10    Text,
11    Wait,
12    Help,
13    NotAllowed,
14    NResize,
15    NeResize,
16    EResize,
17    SeResize,
18    SResize,
19    SwResize,
20    WResize,
21    NwResize,
22    NsResize,
23    NeswResize,
24    EwResize,
25    NwseResize,
26    ColResize,
27    RowResize,
28}

LiveDependency

Usage

  • template: dep('path')
  • style: dep("path")

Source Code

1pub struct LiveDependency(String);

Direction

Usage

  • Horizontal
  • Vertical
  • Direction::Horizontal

Source Code

1pub enum Direction {
2    #[default]
3    Horizontal,
4    Vertical,
5}

EventOrder

Usage

  • Down
  • Up

Source Code

1pub enum EventOrder {
2    Down,
3    #[default]
4    Up,
5}

Flow

Usage

  • Right
  • Down

Source Code

1pub enum Flow {
2    #[default]
3    Right,
4    Down,
5    Overlay,
6    RightWrap,
7}

ImageFit

Usage

  • Stretch
  • Horizontal

Source Code

1pub enum ImageFit {
2    #[default]
3    Stretch,
4    Horizontal,
5    Vertical,
6    Smallest,
7    Biggest,
8    Size,
9}

LinkType

Usage

  • NewTab

Source Code

1pub enum LinkType {
2    #[default]
3    NewTab,
4    SameTab,
5}

ViewOptimize

Usage

  • DrawList
  • Texture

Source Code

1pub enum ViewOptimize {
2    #[default]
3    None,
4    DrawList,
5    Texture,
6}

GOsType

Usage

  • Mac

Source Code

1pub enum GOsType {
2    Windows,
3    Mac,
4    #[default]
5    Linux,
6    Other,
7}

Padding

Usage

  • 1.0 means: {left: 1.0, top: 1.0, right: 1.0, bottom: 1.0}
  • 1.0 2.0 means: {left: 2.0, top: 1.0, right: 2.0, bottom: 1.0}
  • 1.0 2.0 4.0 6.0 means: {left: 6.0, top: 1.0, right: 2.0, bottom: 4.0}

Source Code

1pub struct Padding {
2    pub left: f64,
3    pub top: f64,
4    pub right: f64,
5    pub bottom: f64,
6}

Margin

Usage

  • 1.0 means: {left: 1.0, top: 1.0, right: 1.0, bottom: 1.0}
  • 1.0 2.0 means: {left: 2.0, top: 1.0, right: 2.0, bottom: 1.0}
  • 1.0 2.0 4.0 6.0 means: {left: 6.0, top: 1.0, right: 2.0, bottom: 4.0}

Source Code

1pub struct Margin {
2    pub left: f64,
3    pub top: f64,
4    pub right: f64,
5    pub bottom: f64,
6}

TextWrap

Usage

  • Ellipsis
  • Word

Source Code

1pub enum TextWrap {
2    #[default]
3    Ellipsis,
4    Word,
5    Line,
6}

DVec2 ~DVec4

Usage

range: [0.0, 1.0]

  • {x: 0.2}
  • {y: 0.4, z: 0.7}

Source Code

1pub struct DVec2 {
2    pub x: f64,
3    pub y: f64,
4}
5
6pub struct DVec3 {
7    pub x: f64,
8    pub y: f64,
9    pub z: f64,
10}
11
12pub struct DVec4 {
13    pub x: f64,
14    pub y: f64,
15    pub z: f64,
16    pub w: f64,
17}

Vec2 ~Vec4

same as DVec

Size

Usage

  • Fit
  • Fill
  • 200.0 means: Size::Fixed(200.0)
  • Fixed(200.0)

Source Code

1pub enum Size {
2    #[default]
3    /// Fill the size of the parent widget
4    Fill,
5    /// detail size of the current widget
6    Fixed(f64),
7    /// Fit content
8    Fit,
9    All,
10}

Themes

Usage

  • Dark
  • Info

Source Code

1pub enum Themes {
2    Dark,
3    #[default]
4    Primary,
5    Error,
6    Warning,
7    Success,
8    Info,
9}