Skip to content

Commit 7f82161

Browse files
committed
Add setNextWindowViewport function binding
This is necessary to create an invisible dockspace covering the whole screen as described at ocornut/imgui#2109 (comment).
1 parent c16629e commit 7f82161

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/gui.zig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,11 @@ extern fn zguiShowMetricsWindow(popen: ?*bool) void;
666666
// Windows
667667
//
668668
//--------------------------------------------------------------------------------------------------
669+
pub fn setNextWindowViewport(viewport_id: Ident) void {
670+
zguiSetNextWindowViewport(viewport_id);
671+
}
672+
extern fn zguiSetNextWindowViewport(viewport_id: Ident) void;
673+
//--------------------------------------------------------------------------------------------------
669674
const SetNextWindowPos = struct {
670675
x: f32,
671676
y: f32,
@@ -3635,6 +3640,11 @@ extern fn zguiSetTabItemClosed(tab_or_docked_window_label: [*:0]const u8) void;
36353640
//
36363641
//--------------------------------------------------------------------------------------------------
36373642
pub const Viewport = *opaque {
3643+
pub fn getId(viewport: Viewport) Ident {
3644+
return zguiViewport_GetId(viewport);
3645+
}
3646+
extern fn zguiViewport_GetId(viewport: Viewport) Ident;
3647+
36383648
pub fn getPos(viewport: Viewport) [2]f32 {
36393649
var pos: [2]f32 = undefined;
36403650
zguiViewport_GetPos(viewport, &pos);

src/zgui.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ extern "C"
3434
ImGui::SetAllocatorFunctions(alloc_func, free_func, nullptr);
3535
}
3636

37+
ZGUI_API void zguiSetNextWindowViewport(ImGuiID viewport_id)
38+
{
39+
ImGui::SetNextWindowViewport(viewport_id);
40+
}
41+
3742
ZGUI_API void zguiSetNextWindowPos(float x, float y, ImGuiCond cond, float pivot_x, float pivot_y)
3843
{
3944
ImGui::SetNextWindowPos({x, y}, cond, {pivot_x, pivot_y});
@@ -2535,6 +2540,11 @@ extern "C"
25352540
return ImGui::GetMainViewport();
25362541
}
25372542

2543+
ZGUI_API ImGuiID zguiViewport_GetId(ImGuiViewport *viewport)
2544+
{
2545+
return viewport->ID;
2546+
}
2547+
25382548
ZGUI_API void zguiViewport_GetPos(ImGuiViewport *viewport, float p[2])
25392549
{
25402550
const ImVec2 pos = viewport->Pos;

0 commit comments

Comments
 (0)