row-alignment.lua 967 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package.path = package.path .. ";../?.lua"
  2. local chui = require'chui'
  3. local panel = chui.panel{pose = mat4(0,1.5, -2):scale(0.3), palette = chui.palettes[16]}
  4. panel:label{ text='ROW 1', text_scale=2 }
  5. panel:button{ span= 2, thickness=0.1}
  6. panel:row()
  7. panel:label{ text='ROW 2', text_scale=2 }
  8. panel:button{ span=1.5, thickness=0.1 }
  9. panel:button{ span={1.5, 2}, thickness=0.1 }
  10. panel:button{ span=1.5, thickness=0.1 }
  11. panel:row()
  12. panel:label{ text='ROW 3', text_scale=2 }
  13. panel:button{ span= 4, thickness=0.1}
  14. panel:layout('center', 'center')
  15. function lovr.update(dt)
  16. chui.update(dt)
  17. end
  18. function lovr.draw(pass)
  19. lovr.graphics.setBackgroundColor(1,1,1)
  20. chui.draw(pass)
  21. pass:setColor(0.8, 0.6, 0.6, 0.2)
  22. pass:transform(panel.pose)
  23. pass:setDepthTest('none')
  24. for _, widget in ipairs(panel.widgets) do
  25. pass:push()
  26. pass:transform(widget.pose)
  27. pass:box(0, 0, 0, 10, 0.02, 0.02)
  28. pass:box(0, 0, 0, 0.02, 10, 0.02)
  29. pass:pop()
  30. end
  31. end