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.
This commit is contained in:
38
library/modules/ui/label.sx
Executable file
38
library/modules/ui/label.sx
Executable file
@@ -0,0 +1,38 @@
|
||||
#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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user