ui pipeline
This commit is contained in:
30
ui/view.sx
Normal file
30
ui/view.sx
Normal file
@@ -0,0 +1,30 @@
|
||||
#import "ui/types.sx";
|
||||
#import "ui/render.sx";
|
||||
#import "ui/events.sx";
|
||||
|
||||
View :: protocol {
|
||||
// Measure: given a size proposal, return desired size
|
||||
size_that_fits :: (proposal: ProposedSize) -> Size;
|
||||
|
||||
// Place: position children within the given bounds
|
||||
layout :: (bounds: Frame);
|
||||
|
||||
// Render: emit render nodes
|
||||
render :: (ctx: *RenderContext, frame: Frame);
|
||||
|
||||
// Event handling: return true if the event was consumed
|
||||
handle_event :: (event: *Event, frame: Frame) -> bool;
|
||||
}
|
||||
|
||||
// A child view with its computed frame (set during layout)
|
||||
ViewChild :: struct {
|
||||
view: View;
|
||||
computed_frame: Frame;
|
||||
|
||||
make :: (view: View) -> ViewChild {
|
||||
ViewChild.{
|
||||
view = view,
|
||||
computed_frame = Frame.zero()
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user