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:
20
library/modules/ui/font.sx
Executable file
20
library/modules/ui/font.sx
Executable file
@@ -0,0 +1,20 @@
|
||||
#import "modules/std.sx";
|
||||
#import "modules/ui/types.sx";
|
||||
#import "modules/ui/glyph_cache.sx";
|
||||
|
||||
// Global glyph cache pointer for views (Label, Button) to access
|
||||
g_font : *GlyphCache = null;
|
||||
|
||||
set_global_font :: (font: *GlyphCache) {
|
||||
g_font = font;
|
||||
}
|
||||
|
||||
// Convenience measurement function for views
|
||||
measure_text :: (text: string, font_size: f32) -> Size {
|
||||
if g_font == null {
|
||||
// Fallback approximate measurement
|
||||
scale := font_size / 16.0;
|
||||
return Size.{ width = xx text.len * 8.0 * scale, height = font_size };
|
||||
}
|
||||
g_font.measure_text(text, font_size);
|
||||
}
|
||||
Reference in New Issue
Block a user