fix(home): resize home screen menu before rendering
This commit is contained in:
parent
00030759f6
commit
f60ccd7c37
1 changed files with 14 additions and 13 deletions
|
@ -136,8 +136,6 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
|||
self.plane.home();
|
||||
if (self.fire) |*fire| fire.render();
|
||||
|
||||
const more = self.menu.render(theme);
|
||||
|
||||
const style_title = if (tui.find_scope_style(theme, "function")) |sty| sty.style else theme.editor;
|
||||
const style_subtext = if (tui.find_scope_style(theme, "comment")) |sty| sty.style else theme.editor;
|
||||
|
||||
|
@ -145,33 +143,36 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
|||
const subtext = "a programmer's text editor";
|
||||
|
||||
if (self.plane.dim_x() > 120 and self.plane.dim_y() > 22) {
|
||||
self.plane.cursor_move_yx(2, 4) catch return more;
|
||||
fonts.print_string_large(&self.plane, title, style_title) catch return more;
|
||||
self.plane.cursor_move_yx(2, 4) catch return false;
|
||||
fonts.print_string_large(&self.plane, title, style_title) catch return false;
|
||||
|
||||
self.plane.cursor_move_yx(10, 8) catch return more;
|
||||
fonts.print_string_medium(&self.plane, subtext, style_subtext) catch return more;
|
||||
self.plane.cursor_move_yx(10, 8) catch return false;
|
||||
fonts.print_string_medium(&self.plane, subtext, style_subtext) catch return false;
|
||||
|
||||
self.menu.resize(.{ .y = 15, .x = 10, .w = 32 });
|
||||
} else if (self.plane.dim_x() > 55 and self.plane.dim_y() > 16) {
|
||||
self.plane.cursor_move_yx(2, 4) catch return more;
|
||||
fonts.print_string_medium(&self.plane, title, style_title) catch return more;
|
||||
self.plane.cursor_move_yx(2, 4) catch return false;
|
||||
fonts.print_string_medium(&self.plane, title, style_title) catch return false;
|
||||
|
||||
self.plane.set_style_bg_transparent(style_subtext);
|
||||
self.plane.cursor_move_yx(7, 6) catch return more;
|
||||
self.plane.cursor_move_yx(7, 6) catch return false;
|
||||
_ = self.plane.print(subtext, .{}) catch {};
|
||||
|
||||
self.menu.resize(.{ .y = 9, .x = 8, .w = 32 });
|
||||
} else {
|
||||
self.plane.set_style_bg_transparent(style_title);
|
||||
self.plane.cursor_move_yx(1, 4) catch return more;
|
||||
_ = self.plane.print(title, .{}) catch return more;
|
||||
self.plane.cursor_move_yx(1, 4) catch return false;
|
||||
_ = self.plane.print(title, .{}) catch return false;
|
||||
|
||||
self.plane.set_style_bg_transparent(style_subtext);
|
||||
self.plane.cursor_move_yx(3, 6) catch return more;
|
||||
self.plane.cursor_move_yx(3, 6) catch return false;
|
||||
_ = self.plane.print(subtext, .{}) catch {};
|
||||
|
||||
self.menu.resize(.{ .y = 5, .x = 8, .w = 32 });
|
||||
const x = @min(self.plane.dim_x() -| 32, 8);
|
||||
self.menu.resize(.{ .y = 5, .x = x, .w = 32 });
|
||||
}
|
||||
const more = self.menu.render(theme);
|
||||
|
||||
return more or self.fire != null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue