midio_ui/gui/types

Types

Color = string
Point = Vec2[float]
Points = seq[Point]
Bounds = Rect[float]
TextProps = ref object
  text*: string
  fontSize*: Option[float]
  font*: Option[string]
  color*: Option[string]
TextChanged = (string) -> void
TextInputProps = ref object
  text*: string
  fontSize*: Option[float]
  color*: Option[string]
  onChange*: Option[TextChanged]
PathSegmentKind {...}{.pure.} = enum
  MoveTo, LineTo, QuadraticCurveTo, Close
PathSegment = ref object
  case kind*: PathSegmentKind
  of MoveTo, LineTo:
      to*: Point

  of QuadraticCurveTo:
      controlPoint*: Point
      point*: Point

  of Close:
      nil

  
ColorInfo = ref object
  stroke*: Option[string]
  fill*: Option[string]
StrokeInfo = ref object
  width*: float
TextInfo = ref object
  text*: string
  fontSize*: float
  textBaseline*: string
  font*: string
  pos*: Point
  alignment*: string
PrimitiveKind {...}{.pure.} = enum
  Text, Path, Circle, Ellipse, Rectangle
CircleInfo = object
  center*: Point
  radius*: float
EllipseInfo = object
  center*: Point
  radius*: Vec2[float]
  rotation*: float
  startAngle*: float
  endAngle*: float
CornerRadius = tuple[l: float, t: float, r: float, b: float]
RectangleInfo = object
  bounds*: Rect[float]
Primitive = ref object
  colorInfo*: Option[ColorInfo]
  strokeInfo*: Option[StrokeInfo]
  clipBounds*: Option[Rect[float]]
  case kind*: PrimitiveKind
  of Text:
      textInfo*: TextInfo

  of Path:
      segments*: seq[PathSegment]

  of Circle:
      circleInfo*: CircleInfo

  of Ellipse:
      ellipseInfo*: EllipseInfo

  of Rectangle:
      rectangleInfo*: RectangleInfo

  
HorizontalAlignment {...}{.pure.} = enum
  Stretch, Center, Left, Right
VerticalAlignment {...}{.pure.} = enum
  Stretch, Center, Top, Bottom
Visibility {...}{.pure.} = enum
  Visible, Collapsed
ElemProps = ref object
  width*: Option[float]
  height*: Option[float]
  maxWidth*: Option[float]
  minWidth*: Option[float]
  maxHeight*: Option[float]
  minHeight*: Option[float]
  x*: Option[float]
  y*: Option[float]
  xOffset*: Option[float]
  yOffset*: Option[float]
  margin*: Option[Thickness[float]]
  horizontalAlignment*: Option[HorizontalAlignment]
  verticalAlignment*: Option[VerticalAlignment]
  visibility*: Option[Visibility]
  clipToBounds*: Option[bool]
Layout = ref object
  name*: string
  measure*: (Element, Vec2[float]) -> Vec2[float]
  arrange*: (Element, Vec2[float]) -> Vec2[float]
Drawable = ref object
  name*: string
  render*: (Element) -> seq[Primitive]
Element = ref object
  id*: Guid
  children*: seq[Element]
  props*: ElemProps
  parent*: Option[Element]
  desiredSize*: Option[Vec2[float]]
  bounds*: Option[Rect[float]]
  previousArrange*: Option[Rect[float]]
  previousMeasure*: Option[Vec2[float]]
  isArrangeValid*: bool
  isMeasureValid*: bool
  measuring*: bool
  layout*: Option[Layout]
  drawable*: Option[Drawable]
  onRooted*: Option[proc (i0: Element): void]
  onUnrooted*: Option[proc (i0: Element): void]
  pointerInsideLastUpdate*: bool

Procs

proc hash(element: Element): Hash {...}{.raises: [], tags: [].}
proc boundsOfClosestElementWithClipToBounds(self: Element): Option[Bounds] {...}{.
    raises: [UnpackError], tags: [].}