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.
37 lines
988 B
Plaintext
Executable File
37 lines
988 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";
|
|
|
|
ImageView :: struct {
|
|
texture_id: u32;
|
|
width: f32;
|
|
height: f32;
|
|
tint: Color;
|
|
}
|
|
|
|
impl View for ImageView {
|
|
size_that_fits :: (self: *ImageView, proposal: ProposedSize) -> Size {
|
|
pw := proposal.width ?? self.width;
|
|
ph := proposal.height ?? self.height;
|
|
// Maintain aspect ratio: fit within proposal
|
|
aspect := self.width / self.height;
|
|
if pw / ph > aspect {
|
|
Size.{ width = ph * aspect, height = ph };
|
|
} else {
|
|
Size.{ width = pw, height = pw / aspect };
|
|
}
|
|
}
|
|
|
|
layout :: (self: *ImageView, bounds: Frame) {}
|
|
|
|
render :: (self: *ImageView, ctx: *RenderContext, frame: Frame) {
|
|
ctx.add_image(frame, self.texture_id);
|
|
}
|
|
|
|
handle_event :: (self: *ImageView, event: *Event, frame: Frame) -> bool {
|
|
false;
|
|
}
|
|
}
|