mod: replace Layout.content with Layout.render
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 30s
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 30s
The App.Renderer is used for the new `Layout.render` method. Each layout renders itself now with corresponding renderers which might only update parts of the screen, etc.
This commit is contained in:
14
src/main.zig
14
src/main.zig
@@ -24,7 +24,9 @@ pub fn main() !void {
|
||||
const allocator = gpa.allocator();
|
||||
|
||||
var app: App = .{};
|
||||
var renderer: App.Renderer = .{};
|
||||
const renderer: App.Renderer = .{};
|
||||
// FIX: when not running fullscreen, the application needs to screen down accordingly to display the contents
|
||||
// -> size hint how much should it use?
|
||||
|
||||
const mainFile = try std.fs.cwd().openFile("./src/main.zig", .{});
|
||||
var mainFileText = App.Widget.RawText.init(allocator, mainFile);
|
||||
@@ -35,17 +37,11 @@ pub fn main() !void {
|
||||
appFile.close();
|
||||
|
||||
var spacer = App.Widget.Spacer.init();
|
||||
var framing = App.Layout.Framing.init(allocator, .{
|
||||
.widget = App.Widget.createFrom(&mainFileText),
|
||||
});
|
||||
var hstack = App.Layout.HStack.init(allocator, .{
|
||||
App.Layout.createFrom(&framing),
|
||||
});
|
||||
// TODO: corresponding contents need to be filled out by the layout accordingly!
|
||||
var vstack = App.Layout.VStack.init(allocator, .{
|
||||
App.Widget.createFrom(&appFileText),
|
||||
App.Layout.createFrom(&hstack),
|
||||
App.Widget.createFrom(&spacer),
|
||||
App.Widget.createFrom(&mainFileText),
|
||||
});
|
||||
var layout = App.Layout.createFrom(&vstack);
|
||||
defer layout.deinit();
|
||||
@@ -88,6 +84,6 @@ pub fn main() !void {
|
||||
for (events.items) |e| {
|
||||
app.postEvent(e);
|
||||
}
|
||||
try renderer.render(try layout.content());
|
||||
try layout.render(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user