The layout pack now covers a content-sized card that paints its CSS box beneath its child, a fixed-width column that stretches to its row, an auto-width column that takes what the row left, flex: 1 taking a column's remaining height, margin-left: auto, and Text sizing itself where a container places it. The raster stub provides RasterTriangles for the Text import.
120 lines
3.3 KiB
Ziran
120 lines
3.3 KiB
Ziran
#import "kryon/drawing_props"
|
|
#import "kryon/geometry"
|
|
|
|
CssButtonRasterState :: struct {
|
|
fill_count: s32
|
|
outline_count: s32
|
|
text_count: s32
|
|
fill_color: Color
|
|
text_color: Color
|
|
fill_bounds: Rectangle
|
|
radius: float32
|
|
font: s32
|
|
failed: bool
|
|
}
|
|
|
|
sample: CssButtonRasterState;
|
|
|
|
#program_export
|
|
MeasureGlyphWidth :: (value: string, font: s32, typeface: string) -> s32 {
|
|
unused typeface
|
|
if value != "Save" || font <= 0 { sample.failed = true }
|
|
return 30
|
|
}
|
|
|
|
#program_export
|
|
MeasureGlyphLineHeight :: (font: s32, typeface: string) -> s32 {
|
|
unused typeface
|
|
if font <= 0 { sample.failed = true }
|
|
return font
|
|
}
|
|
|
|
#program_export
|
|
RasterTextClipped :: (value: string, x: s32, y: s32, font: s32,
|
|
color: Color, clip: Rectangle) {
|
|
unused x; unused y; unused clip
|
|
if value != "Save" { sample.failed = true }
|
|
sample.text_count += 1; sample.text_color = color; sample.font = font
|
|
}
|
|
|
|
#program_export
|
|
RasterText :: (value: string, x: s32, y: s32, font: s32,
|
|
color: Color) {
|
|
unused value; unused x; unused y; unused font; unused color
|
|
sample.failed = true
|
|
}
|
|
|
|
#program_export
|
|
RasterTextRotated :: (value: string, x: s32, y: s32, font: s32, color: Color,
|
|
clip: Rectangle, origin: Vector2, rotation: float32, outer_clip: Rectangle,
|
|
outer_clipped: bool, emphasis: bool, italic: bool) {
|
|
unused value; unused x; unused y; unused font; unused color; unused clip
|
|
unused origin; unused rotation; unused outer_clip; unused outer_clipped
|
|
unused emphasis; unused italic
|
|
sample.failed = true
|
|
}
|
|
|
|
#program_export
|
|
RasterRoundedRectangle :: (bounds: Rectangle, radius: float32,
|
|
segments: s32, color: Color) {
|
|
unused segments
|
|
sample.fill_count += 1; sample.fill_bounds = bounds
|
|
sample.radius = radius; sample.fill_color = color
|
|
}
|
|
|
|
#program_export
|
|
RasterRoundedRectangleOutline :: (bounds: Rectangle, radius: float32,
|
|
segments: s32, width: float32, color: Color) {
|
|
unused bounds; unused radius; unused segments; unused width
|
|
sample.outline_count += 1; sample.text_color = color
|
|
}
|
|
|
|
#program_export
|
|
ImageWidth :: (asset_path: string) -> s32 {
|
|
unused asset_path
|
|
return 0
|
|
}
|
|
|
|
#program_export
|
|
ImageHeight :: (asset_path: string) -> s32 {
|
|
unused asset_path
|
|
return 0
|
|
}
|
|
|
|
#program_export
|
|
RasterTriangles :: (points: []Vector2, color: Color) {
|
|
unused points
|
|
unused color
|
|
}
|
|
|
|
#program_export
|
|
RasterLine :: (line: Rectangle, color: Color) {
|
|
unused line; unused color
|
|
}
|
|
|
|
#program_export
|
|
RasterImage :: (asset_path: string, texture_id: u32,
|
|
source: Rectangle, destination: Rectangle, clip: Rectangle,
|
|
origin: Vector2, rotation: float32, radius: float32, tint: Color) {
|
|
unused asset_path; unused texture_id; unused source; unused destination
|
|
unused clip; unused origin; unused rotation; unused radius; unused tint
|
|
}
|
|
|
|
#program_export
|
|
RasterImageMesh :: (asset_path: string, texture_id: u32,
|
|
source: Rectangle, points: []Vector2, columns: s32, rows: s32,
|
|
clip: Rectangle, tint: Color) {
|
|
unused asset_path; unused texture_id; unused source; unused points
|
|
unused columns; unused rows; unused clip; unused tint
|
|
sample.failed = true
|
|
}
|
|
|
|
#program_export
|
|
CssButtonRasterReset :: () -> CssButtonRasterState {
|
|
sample = CssButtonRasterState.{}
|
|
return sample
|
|
}
|
|
|
|
#program_export
|
|
CssButtonRasterSample :: () -> CssButtonRasterState { return sample }
|