t_basic.nim 622 B

1234567891011121314151617181920212223242526272829
  1. import sigui, siwin
  2. let win = newOpenglWindow(size=ivec2(1280, 720), title="Hello sigui").newUiWindow
  3. win.makeLayout:
  4. - UiRect():
  5. this.centerIn(parent)
  6. this.w[] = 100
  7. this.binding h: this.w[]
  8. var state = 0.property
  9. this.binding color:
  10. (
  11. case state[]
  12. of 0: color(1, 0, 0)
  13. of 1: color(0, 1, 0)
  14. else: color(0, 0, 1)
  15. ).lighten(if mouse.hovered[]: 0.3 else: 0)
  16. - this.color.transition(0.4's)
  17. - MouseArea() as mouse:
  18. this.fill(parent)
  19. this.mouseDownAndUpInside.connectTo root:
  20. state[] = (state[] + 1) mod 3
  21. run win.siwinWindow