[Core] Split aspect ratio scaling into its own config (#426)

This commit is contained in:
Nic Barker 2025-06-02 10:36:58 +10:00 committed by GitHub
parent 89ce22e894
commit d6f3957a60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 167 additions and 64 deletions

View file

@ -113,9 +113,12 @@ TextElementConfig :: struct {
textAlignment: TextAlignment,
}
AspectRatioElementConfig :: struct {
aspectRatio: f32,
}
ImageElementConfig :: struct {
imageData: rawptr,
sourceDimensions: Dimensions,
}
CustomElementConfig :: struct {
@ -203,7 +206,6 @@ RectangleRenderData :: struct {
ImageRenderData :: struct {
backgroundColor: Color,
cornerRadius: CornerRadius,
sourceDimensions: Dimensions,
imageData: rawptr,
}
@ -340,6 +342,7 @@ ElementDeclaration :: struct {
layout: LayoutConfig,
backgroundColor: Color,
cornerRadius: CornerRadius,
aspectRatio: AspectRatioElementConfig,
image: ImageElementConfig,
floating: FloatingElementConfig,
custom: CustomElementConfig,

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -72,7 +72,8 @@ LandingPageBlob :: proc(index: u32, fontSize: u16, fontId: u16, color: clay.Colo
if clay.UI()({
id = clay.ID("CheckImage", index),
layout = { sizing = { width = clay.SizingFixed(32) } },
image = { imageData = image, sourceDimensions = { 128, 128 } },
aspectRatio = { 1.0 },
image = { imageData = image },
}) {}
clay.Text(text, clay.TextConfig({fontSize = fontSize, fontId = fontId, textColor = color}))
}
@ -213,7 +214,8 @@ DeclarativeSyntaxPage :: proc(titleTextConfig: clay.TextElementConfig, widthSizi
if clay.UI()({
id = clay.ID("SyntaxPageRightImageInner"),
layout = { sizing = { width = clay.SizingGrow({ max = 568 }) } },
image = { imageData = &syntaxImage, sourceDimensions = { 1136, 1194 } },
aspectRatio = { 1136.0 / 1194.0 },
image = { imageData = &syntaxImage },
}) {}
}
}