内置类型

在本文档中我们提供所有您可以直接在GenUI项目中使用的内置类型,通常来说您很少会用到这些类型,因为GenUI已经帮您屏蔽了最底层的组件构建。

但由于在内置组件中会涉及到这些内置类型的属性值的写法,所以我们依然提供给您较为完整的写法参考。

TIP

如果您学习过数据类型部分的值解析与写法,您应该非常容易理解如何编写。

Align

写法

取值范围: [0.0, 1.0]

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

源码

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

GChooseType

写法

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

源码

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

MouseCursor

写法

  • Hidden
  • Hand
  • MouseCursor::Move

源码

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

写法

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

源码

1pub struct LiveDependency(String);

Direction

写法

  • Horizontal
  • Vertical
  • Direction::Horizontal

源码

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

EventOrder

写法

  • Down
  • Up

源码

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

Flow

写法

  • Right
  • Down

源码

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

ImageFit

写法

  • Stretch
  • Horizontal

源码

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

LinkType

写法

  • NewTab

源码

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

ViewOptimize

写法

  • DrawList
  • Texture

源码

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

GOsType

写法

  • Mac

源码

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

Padding

写法

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

源码

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

Margin

写法

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

源码

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

TextWrap

写法

  • Ellipsis
  • Word

源码

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

DVec2 ~DVec4

写法

取值范围: [0.0, 1.0]

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

源码

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

DVec

Size

写法

  • Fit
  • Fill
  • 200.0 表示: Size::Fixed(200.0)
  • Fixed(200.0)

源码

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

写法

  • Dark
  • Info

源码

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