mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-20 18:56:08 +03:00
inspector: setup basic modes window (empty), dock
This commit is contained in:
@ -6,6 +6,11 @@ const Inspector = @This();
|
||||
const cimgui = @import("cimgui");
|
||||
const Surface = @import("Surface.zig");
|
||||
|
||||
/// The window names. These are used with docking so we need to have access.
|
||||
const window_modes = "Modes";
|
||||
|
||||
show_modes_window: bool = true,
|
||||
|
||||
/// Setup the ImGui state. This requires an ImGui context to be set.
|
||||
pub fn setup() void {
|
||||
const io: *cimgui.c.ImGuiIO = cimgui.c.igGetIO();
|
||||
@ -16,6 +21,10 @@ pub fn setup() void {
|
||||
// Our colorspace is sRGB.
|
||||
io.ConfigFlags |= cimgui.c.ImGuiConfigFlags_IsSRGB;
|
||||
|
||||
// Disable the ini file to save layout
|
||||
io.IniFilename = null;
|
||||
io.LogFilename = null;
|
||||
|
||||
// Use our own embedded font
|
||||
{
|
||||
// TODO: This will have to be recalculated for different screen DPIs.
|
||||
@ -46,14 +55,35 @@ pub fn deinit(self: *Inspector) void {
|
||||
|
||||
/// Render the frame.
|
||||
pub fn render(self: *Inspector) void {
|
||||
_ = self;
|
||||
|
||||
_ = cimgui.c.igDockSpaceOverViewport(
|
||||
const dock_id = cimgui.c.igDockSpaceOverViewport(
|
||||
cimgui.c.igGetMainViewport(),
|
||||
cimgui.c.ImGuiDockNodeFlags_None,
|
||||
null,
|
||||
);
|
||||
|
||||
// Flip this boolean to true whenever you want to see the ImGui demo
|
||||
// window which can help you figure out how to use various ImGui widgets.
|
||||
if (false) {
|
||||
var show: bool = true;
|
||||
cimgui.c.igShowDemoWindow(&show);
|
||||
}
|
||||
|
||||
self.renderModesWindow();
|
||||
|
||||
// Setup our dock. We want all our main windows to be tabs in the main bar.
|
||||
cimgui.c.igDockBuilderDockWindow(window_modes, dock_id);
|
||||
}
|
||||
|
||||
/// The modes window shows the currently active terminal modes and allows
|
||||
/// users to toggle them on and off.
|
||||
fn renderModesWindow(self: *Inspector) void {
|
||||
if (!self.show_modes_window) return;
|
||||
|
||||
// Start our window. If we're collapsed we do nothing.
|
||||
defer cimgui.c.igEnd();
|
||||
if (!cimgui.c.igBegin(
|
||||
window_modes,
|
||||
&self.show_modes_window,
|
||||
cimgui.c.ImGuiWindowFlags_None,
|
||||
)) return;
|
||||
}
|
||||
|
@ -201,9 +201,12 @@ fn gtkRender(area: *c.GtkGLArea, ctx: *c.GdkGLContext, ud: ?*anyopaque) callconv
|
||||
_ = area;
|
||||
_ = ctx;
|
||||
const self: *ImguiWidget = @ptrCast(@alignCast(ud.?));
|
||||
|
||||
// Setup our frame
|
||||
cimgui.c.igSetCurrentContext(self.ig_ctx);
|
||||
|
||||
// Setup our frame. We render twice because some ImGui behaviors
|
||||
// take multiple renders to process. I don't know how to make this
|
||||
// more efficient.
|
||||
for (0..2) |_| {
|
||||
cimgui.c.ImGui_ImplOpenGL3_NewFrame();
|
||||
self.newFrame() catch |err| {
|
||||
log.err("failed to setup frame: {}", .{err});
|
||||
@ -216,6 +219,7 @@ fn gtkRender(area: *c.GtkGLArea, ctx: *c.GdkGLContext, ud: ?*anyopaque) callconv
|
||||
|
||||
// Render
|
||||
cimgui.c.igRender();
|
||||
}
|
||||
|
||||
// OpenGL final render
|
||||
gl.clearColor(0x28 / 0xFF, 0x2C / 0xFF, 0x34 / 0xFF, 1.0);
|
||||
|
Reference in New Issue
Block a user