Files
sx/library/modules/ui/label.sx
agra dc8529e3ea ui: port game UI framework into library/modules/ui
20 files (~3,830 lines): view protocol, layout, renderer, glyph cache,
fonts, gestures, animation, scroll, stacks, modifiers, etc.

Internal imports rewritten from "ui/..." to "modules/ui/...".
Consumers now `#import "modules/ui"` from any project; no symlink
hacks needed. Verified by compiling game/main.sx without its local
ui/ — resolves via the Phase 6 stdlib fallback.
2026-05-17 13:54:11 +03:00

39 lines
900 B
Plaintext
Executable File

#import "modules/std.sx";
#import "modules/ui/types.sx";
#import "modules/ui/render.sx";
#import "modules/ui/events.sx";
#import "modules/ui/view.sx";
#import "modules/ui/font.sx";
Label :: struct {
text: string;
font_size: f32;
color: Color;
make :: (text: string) -> Label {
Label.{
text = text,
font_size = 14.0,
color = COLOR_WHITE
};
}
}
impl View for Label {
size_that_fits :: (self: *Label, proposal: ProposedSize) -> Size {
measure_text(self.text, self.font_size);
}
layout :: (self: *Label, bounds: Frame) {
// Leaf view — nothing to place
}
render :: (self: *Label, ctx: *RenderContext, frame: Frame) {
ctx.add_text(frame, self.text, self.font_size, self.color);
}
handle_event :: (self: *Label, event: *Event, frame: Frame) -> bool {
false;
}
}