Skip to content

Commit 2c92073

Browse files
committed
add dockspace
1 parent c7d263b commit 2c92073

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/gui/gui.cc

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,13 @@ void PCSX::GUI::endFrame() {
11271127
m_offscreenShaderEditor.configure(this);
11281128
m_outputShaderEditor.configure(this);
11291129

1130+
ImGuiID dockspace = ImGui::DockSpaceOverViewport(0, nullptr, ImGuiDockNodeFlags_PassthruCentralNode);
1131+
ImGuiContext* context = ImGui::GetCurrentContext();
1132+
ImGuiDockNode* dockspaceNode = ImGui::DockContextFindNodeByID(context, dockspace);
1133+
if (m_fullWindowRender && !dockspaceNode->IsEmpty()) {
1134+
m_fullWindowRender = false;
1135+
ImGui::SetNextWindowDockID(dockspace);
1136+
}
11301137
if (m_fullWindowRender) {
11311138
ImTextureID texture = m_offscreenTextures[m_currentTexture];
11321139
const auto basePos = ImGui::GetMainViewport()->Pos;
@@ -1152,10 +1159,16 @@ void PCSX::GUI::endFrame() {
11521159
} else {
11531160
ImGui::SetNextWindowPos(ImVec2(50, 50), ImGuiCond_FirstUseEver);
11541161
ImGui::SetNextWindowSize(ImVec2(640, 480), ImGuiCond_FirstUseEver);
1155-
bool outputShown = true;
1162+
bool outputWindowShown = true;
11561163
if (ImGui::Begin(
1157-
_("Output"), &outputShown,
1164+
_("Output"), &outputWindowShown,
11581165
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse)) {
1166+
ImGuiDockNode* outputNode = ImGui::GetWindowDockNode();
1167+
if (outputNode && dockspaceNode->OnlyNodeWithWindows == outputNode
1168+
&& (!outputNode->TabBar || outputNode->TabBar->Tabs.size() == 1)) {
1169+
// if output is the only visible window in dockspace, switch to full window render mode automatically
1170+
outputWindowShown = false;
1171+
}
11591172
ImVec2 textureSize = ImGui::GetContentRegionAvail();
11601173
if ((m_outputWindowSize.x != textureSize.x) || (m_outputWindowSize.y != textureSize.y)) {
11611174
m_outputWindowSize = textureSize;
@@ -1170,7 +1183,11 @@ void PCSX::GUI::endFrame() {
11701183
}
11711184
}
11721185
ImGui::End();
1173-
if (!outputShown) m_fullWindowRender = true;
1186+
if (!outputWindowShown) {
1187+
m_fullWindowRender = true;
1188+
// full window render mode can't have anything docked in the dockspace
1189+
ImGui::DockContextClearNodes(context, dockspace, true);
1190+
}
11741191
}
11751192

11761193
bool showOpenIsoFileDialog = false;
@@ -1433,6 +1450,8 @@ in Configuration->Emulation, restart PCSX-Redux, then try again.)"));
14331450
if (ImGui::BeginMenu(_("Rendering"))) {
14341451
if (ImGui::MenuItem(_("Full window render"), nullptr, &m_fullWindowRender)) {
14351452
m_setupScreenSize = true;
1453+
// full window render mode can't have anything docked in the dockspace
1454+
ImGui::DockContextClearNodes(context, dockspace, true);
14361455
}
14371456
if (ImGui::MenuItem(_("Fullscreen"), nullptr, &m_fullscreen)) {
14381457
setFullscreen(m_fullscreen);

0 commit comments

Comments
 (0)