Files
kryon/examples/09_geometry.kry
T
2026-08-09 19:52:01 -03:00

52 lines
2.5 KiB
Plaintext

#import "kryon.h"
app "Kryon Geometry" {
size 800 600
fps 60
font examples
theme THEME_SKY light
}
screen GeometryExample(viewport: Rectangle) {
Background(GetThemeBackground())
SetUIViewSize(GetScreenWidth(),GetScreenHeight())
shell: Rectangle = {40,42,GetUIViewWidth()-80,GetUIViewHeight()-84}
frame: UIFrame = BeginUIFrameBox(shell,16,16,12)
header: Rectangle = UIFramePack(&frame,UI_SIDE_TOP,54)
footer: Rectangle = UIFramePack(&frame,UI_SIDE_BOTTOM,46)
rail: Rectangle = UIFramePack(&frame,UI_SIDE_LEFT,150)
body: Rectangle = frame.bounds
grid: UIGrid = {body,2,3,10,10,16,16}
card0: Rectangle = UIGridCell(grid,0,0,1,2)
card1: Rectangle = UIGridCell(grid,0,2,1,1)
card2: Rectangle = UIGridCell(grid,1,0,1,1)
card3: Rectangle = UIGridCell(grid,1,1,1,2)
badge: Rectangle = UIPlace(card1,14,42,92,28)
action: Rectangle = UIPlace(footer,16,7,150,32)
Text("Geometry helpers", 40, 14, UI_TEXT_24, GetThemeText())
DrawRectangleRec(shell,GetThemeSurface())
DrawRectangleLinesEx(shell,1,GetThemeIcon())
DrawRectangleRec(header,GetThemeButton())
DrawRectangleRec(rail,DarkenUIColor(GetThemeSurface(),8))
Separator((Rectangle){rail.x+rail.width+6,rail.y,1,rail.height},1)
Text("Packed header", header.x+16, header.y+16, UI_TEXT_16, GetThemeText())
Text("Left rail", rail.x+16, rail.y+16, UI_TEXT_16, GetThemeText())
DrawRectangleRec(card0,DarkenUIColor(GetThemeSurface(),12))
DrawRectangleLinesEx(card0,1,GetThemeButton())
DrawRectangleRec(card1,DarkenUIColor(GetThemeSurface(),16))
DrawRectangleLinesEx(card1,1,GetThemeButton())
DrawRectangleRec(card2,DarkenUIColor(GetThemeSurface(),18))
DrawRectangleLinesEx(card2,1,GetThemeButton())
DrawRectangleRec(card3,DarkenUIColor(GetThemeSurface(),22))
DrawRectangleLinesEx(card3,1,GetThemeButton())
Text("UIGridCell 2-column span", card0.x+14, card0.y+18, UI_TEXT_16, GetThemeText())
Text("UIPlace badge", card1.x+14, card1.y+18, UI_TEXT_16, GetThemeText())
DrawRectangleRec(badge,GetThemeButtonHover())
Text("badge", badge.x+18, badge.y+7, UI_TEXT_12, GetThemeText())
Text("cell 1,0", card2.x+14, card2.y+18, UI_TEXT_16, GetThemeText())
Text("wide footer cell", card3.x+14, card3.y+18, UI_TEXT_16, GetThemeText())
Separator((Rectangle){footer.x,footer.y-7,footer.width,1},0)
DrawRectangleRec(action,GetThemeButton())
Text("placed action", action.x+14, action.y+9, UI_TEXT_12, GetThemeText())
}