mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
apprt/gtk: initialize and run the inspector
This commit is contained in:
@ -5,6 +5,17 @@ const Inspector = @This();
|
||||
|
||||
const cimgui = @import("cimgui");
|
||||
|
||||
/// Setup the ImGui state. This requires an ImGui context to be set.
|
||||
pub fn setup() void {
|
||||
const io: *cimgui.c.ImGuiIO = cimgui.c.igGetIO();
|
||||
|
||||
// Enable docking, which we use heavily for the UI.
|
||||
io.ConfigFlags |= cimgui.c.ImGuiConfigFlags_DockingEnable;
|
||||
|
||||
// Our colorspace is sRGB.
|
||||
io.ConfigFlags |= cimgui.c.ImGuiConfigFlags_IsSRGB;
|
||||
}
|
||||
|
||||
pub fn init() Inspector {
|
||||
return .{};
|
||||
}
|
||||
@ -13,9 +24,16 @@ pub fn deinit(self: *Inspector) void {
|
||||
_ = self;
|
||||
}
|
||||
|
||||
/// Render the frame.
|
||||
pub fn render(self: *Inspector) void {
|
||||
_ = self;
|
||||
|
||||
_ = cimgui.c.igDockSpaceOverViewport(
|
||||
cimgui.c.igGetMainViewport(),
|
||||
cimgui.c.ImGuiDockNodeFlags_None,
|
||||
null,
|
||||
);
|
||||
|
||||
var show: bool = true;
|
||||
cimgui.c.igShowDemoWindow(&show);
|
||||
}
|
||||
|
@ -608,14 +608,6 @@ pub fn deactivateInspector(self: *Surface) void {
|
||||
self.inspector = null;
|
||||
}
|
||||
|
||||
/// Render the inspector. This requires an active ImGui context.
|
||||
pub fn renderInspector(self: *Surface) void {
|
||||
const inspector = self.inspector orelse return;
|
||||
self.renderer_state.mutex.lock();
|
||||
defer self.renderer_state.mutex.unlock();
|
||||
inspector.render();
|
||||
}
|
||||
|
||||
/// True if the surface requires confirmation to quit. This should be called
|
||||
/// by apprt to determine if the surface should confirm before quitting.
|
||||
pub fn needsConfirmQuit(self: *Surface) bool {
|
||||
|
@ -8,6 +8,7 @@ const TerminalWindow = @import("Window.zig");
|
||||
const ImguiWidget = @import("ImguiWidget.zig");
|
||||
const c = @import("c.zig");
|
||||
const icon = @import("icon.zig");
|
||||
const CoreInspector = @import("../../Inspector.zig");
|
||||
|
||||
const log = std.log.scoped(.inspector);
|
||||
|
||||
@ -144,6 +145,7 @@ const Window = struct {
|
||||
errdefer self.imgui_widget.deinit();
|
||||
self.imgui_widget.render_callback = &imguiRender;
|
||||
self.imgui_widget.render_userdata = self;
|
||||
CoreInspector.setup();
|
||||
|
||||
// Signals
|
||||
_ = c.g_signal_connect_data(window, "destroy", c.G_CALLBACK(>kDestroy), self, null, c.G_CONNECT_DEFAULT);
|
||||
@ -164,7 +166,12 @@ const Window = struct {
|
||||
|
||||
fn imguiRender(ud: ?*anyopaque) void {
|
||||
const self: *Window = @ptrCast(@alignCast(ud orelse return));
|
||||
self.inspector.surface.core_surface.renderInspector();
|
||||
const surface = &self.inspector.surface.core_surface;
|
||||
const inspector = surface.inspector orelse return;
|
||||
|
||||
surface.renderer_state.mutex.lock();
|
||||
defer surface.renderer_state.mutex.unlock();
|
||||
inspector.render();
|
||||
}
|
||||
|
||||
/// "destroy" signal for the window
|
||||
|
Reference in New Issue
Block a user