fix: menu and open_recent resize handling
This commit is contained in:
parent
771c1dd980
commit
acd65d0157
4 changed files with 9 additions and 15 deletions
|
@ -36,7 +36,7 @@ pub fn Options(context: type) type {
|
||||||
pub fn on_resize_default(_: context, state: *State(Context), box_: Widget.Box) void {
|
pub fn on_resize_default(_: context, state: *State(Context), box_: Widget.Box) void {
|
||||||
var box = box_;
|
var box = box_;
|
||||||
box.h = state.menu.widgets.items.len;
|
box.h = state.menu.widgets.items.len;
|
||||||
state.menu.handle_resize(box);
|
state.menu.resize(box);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ pub fn State(ctx_type: type) type {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resize(self: *Self, box: Widget.Box) void {
|
pub fn resize(self: *Self, box: Widget.Box) void {
|
||||||
self.menu.handle_resize(box);
|
self.menu.resize(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(self: *Self) void {
|
pub fn update(self: *Self) void {
|
||||||
|
|
|
@ -179,15 +179,15 @@ fn refresh_layout(self: *Self) void {
|
||||||
return if (self.box) |box| self.handle_resize(box);
|
return if (self.box) |box| self.handle_resize(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resize(self: *Self, pos: Widget.Box) void {
|
pub fn handle_resize(self: *Self, pos: Widget.Box) void {
|
||||||
return self.on_resize(self.ctx, self, pos);
|
self.on_resize(self.ctx, self, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_resize_default(_: ?*anyopaque, self: *Self, pos: Widget.Box) void {
|
fn on_resize_default(_: ?*anyopaque, self: *Self, pos: Widget.Box) void {
|
||||||
self.handle_resize(pos);
|
self.resize(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_resize(self: *Self, pos_: Widget.Box) void {
|
pub fn resize(self: *Self, pos_: Widget.Box) void {
|
||||||
self.box = pos_;
|
self.box = pos_;
|
||||||
var pos = pos_;
|
var pos = pos_;
|
||||||
const total = self.get_size_a(&pos).*;
|
const total = self.get_size_a(&pos).*;
|
||||||
|
|
|
@ -101,7 +101,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_resize(self: *Self, pos: Box) void {
|
pub fn handle_resize(self: *Self, pos: Box) void {
|
||||||
self.widgets.resize(pos);
|
self.widgets.handle_resize(pos);
|
||||||
self.floating_views.resize(pos);
|
self.floating_views.resize(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,14 +103,8 @@ fn render_cell(plane: *Plane, y: usize, x: usize, style: Widget.Theme.Style) !vo
|
||||||
_ = plane.putc(&cell) catch {};
|
_ = plane.putc(&cell) catch {};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_resize_menu(self: *Self, state: *Menu.State(*Self), box: Widget.Box) void {
|
fn on_resize_menu(self: *Self, _: *Menu.State(*Self), _: Widget.Box) void {
|
||||||
const w = @min(box.w, @min(self.longest, max_menu_width) + 2);
|
self.menu.resize(.{ .y = 0, .x = 25, .w = @min(self.longest, max_menu_width) + 2 });
|
||||||
self.menu.resize(.{
|
|
||||||
.y = 0,
|
|
||||||
.x = box.w - w / 2,
|
|
||||||
.h = state.menu.widgets.items.len,
|
|
||||||
.w = w,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn menu_action_open_file(menu: **Menu.State(*Self), button: *Button.State(*Menu.State(*Self))) void {
|
fn menu_action_open_file(menu: **Menu.State(*Self), button: *Button.State(*Menu.State(*Self))) void {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue