inspector: get mouse points working

This commit is contained in:
Mitchell Hashimoto
2024-03-14 10:28:55 -07:00
parent 62932f3631
commit 172d62ca12
2 changed files with 56 additions and 39 deletions

View File

@ -2569,8 +2569,12 @@ pub fn cursorPosCallback(
if (self.inspector) |insp| { if (self.inspector) |insp| {
insp.mouse.last_xpos = pos.x; insp.mouse.last_xpos = pos.x;
insp.mouse.last_ypos = pos.y; insp.mouse.last_ypos = pos.y;
// TODO(paged-terminal)
//insp.mouse.last_point = pos_vp.toScreen(&self.io.terminal.screen); const screen = &self.renderer_state.terminal.screen;
insp.mouse.last_point = screen.pages.pin(.{ .viewport = .{
.x = pos_vp.x,
.y = pos_vp.y,
} });
try self.queueRender(); try self.queueRender();
} }

View File

@ -37,8 +37,7 @@ mouse: struct {
last_ypos: f64 = 0, last_ypos: f64 = 0,
// Last hovered screen point // Last hovered screen point
// TODO(paged-terminal) last_point: ?terminal.Pin = null,
// last_point: terminal.point.ScreenPoint = .{},
} = .{}, } = .{},
/// A selected cell. /// A selected cell.
@ -696,25 +695,32 @@ fn renderSizeWindow(self: *Inspector) void {
defer cimgui.c.igEndTable(); defer cimgui.c.igEndTable();
const mouse = &self.surface.mouse; const mouse = &self.surface.mouse;
//const t = self.surface.renderer_state.terminal; const t = self.surface.renderer_state.terminal;
// TODO(paged-terminal) {
// { const hover_point: terminal.point.Coordinate = pt: {
// const hover_point = self.mouse.last_point.toViewport(&t.screen); const p = self.mouse.last_point orelse break :pt .{};
// cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0); const pt = t.screen.pages.pointFromPin(
// { .active,
// _ = cimgui.c.igTableSetColumnIndex(0); p,
// cimgui.c.igText("Hover Grid"); ) orelse break :pt .{};
// } break :pt pt.coord();
// { };
// _ = cimgui.c.igTableSetColumnIndex(1);
// cimgui.c.igText( cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0);
// "row=%d, col=%d", {
// hover_point.y, _ = cimgui.c.igTableSetColumnIndex(0);
// hover_point.x, cimgui.c.igText("Hover Grid");
// ); }
// } {
// } _ = cimgui.c.igTableSetColumnIndex(1);
cimgui.c.igText(
"row=%d, col=%d",
hover_point.y,
hover_point.x,
);
}
}
{ {
cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0); cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0);
@ -771,23 +777,30 @@ fn renderSizeWindow(self: *Inspector) void {
} }
} }
// TODO(paged-terminal) {
// { const left_click_point: terminal.point.Coordinate = pt: {
// const left_click_point = mouse.left_click_point.toViewport(&t.screen); const p = mouse.left_click_pin orelse break :pt .{};
// cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0); const pt = t.screen.pages.pointFromPin(
// { .active,
// _ = cimgui.c.igTableSetColumnIndex(0); p.*,
// cimgui.c.igText("Click Grid"); ) orelse break :pt .{};
// } break :pt pt.coord();
// { };
// _ = cimgui.c.igTableSetColumnIndex(1);
// cimgui.c.igText( cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0);
// "row=%d, col=%d", {
// left_click_point.y, _ = cimgui.c.igTableSetColumnIndex(0);
// left_click_point.x, cimgui.c.igText("Click Grid");
// ); }
// } {
// } _ = cimgui.c.igTableSetColumnIndex(1);
cimgui.c.igText(
"row=%d, col=%d",
left_click_point.y,
left_click_point.x,
);
}
}
{ {
cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0); cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0);