mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-19 06:26:35 +00:00
Docking: Demo: Displaying a message if master docking flag is disabled. + DockSpace() early out + comments.
This commit is contained in:
parent
6ebc63d3ef
commit
9cfc40c2cc
@ -11475,6 +11475,8 @@ void ImGui::DockSpace(ImGuiID id, const ImVec2& size_arg, ImGuiDockNodeFlags doc
|
|||||||
ImGuiContext* ctx = GImGui;
|
ImGuiContext* ctx = GImGui;
|
||||||
ImGuiContext& g = *ctx;
|
ImGuiContext& g = *ctx;
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
|
if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable))
|
||||||
|
return;
|
||||||
|
|
||||||
ImGuiDockNode* node = DockContextFindNodeByID(ctx, id);
|
ImGuiDockNode* node = DockContextFindNodeByID(ctx, id);
|
||||||
if (!node)
|
if (!node)
|
||||||
|
5
imgui.h
5
imgui.h
@ -524,11 +524,12 @@ namespace ImGui
|
|||||||
|
|
||||||
// Docking
|
// Docking
|
||||||
// [BETA API] Enable with io.ConfigFlags |= ImGuiConfigFlags_DockingEnable.
|
// [BETA API] Enable with io.ConfigFlags |= ImGuiConfigFlags_DockingEnable.
|
||||||
// Note: you DO NOT need to call DockSpace() to use most Docking facilities! You can hold SHIFT anywhere while moving windows.
|
// Note: you DO NOT need to call DockSpace() to use most Docking facilities!
|
||||||
|
// To dock windows: hold SHIFT anywhere while moving windows (if io.ConfigDockingWithKeyMod == true) or drag windows from their title bar (if io.ConfigDockingWithKeyMod = false)
|
||||||
// Use DockSpace() to create an explicit dock node _within_ an existing window. See Docking demo for details.
|
// Use DockSpace() to create an explicit dock node _within_ an existing window. See Docking demo for details.
|
||||||
IMGUI_API void DockSpace(ImGuiID id, const ImVec2& size = ImVec2(0, 0), ImGuiDockNodeFlags flags = 0, const ImGuiDockFamily* dock_family = NULL);
|
IMGUI_API void DockSpace(ImGuiID id, const ImVec2& size = ImVec2(0, 0), ImGuiDockNodeFlags flags = 0, const ImGuiDockFamily* dock_family = NULL);
|
||||||
IMGUI_API void SetNextWindowDockId(ImGuiID dock_id, ImGuiCond cond = 0); // set next window dock id (FIXME-DOCK)
|
IMGUI_API void SetNextWindowDockId(ImGuiID dock_id, ImGuiCond cond = 0); // set next window dock id (FIXME-DOCK)
|
||||||
IMGUI_API void SetNextWindowDockFamily(const ImGuiDockFamily* dock_family); // FIXME-DOCK: set next window user type (docking filters by same user_type)
|
IMGUI_API void SetNextWindowDockFamily(const ImGuiDockFamily* dock_family); // set next window user type (docking filters by same user_type)
|
||||||
IMGUI_API ImGuiID GetWindowDockId();
|
IMGUI_API ImGuiID GetWindowDockId();
|
||||||
IMGUI_API bool IsWindowDocked(); // is current window docked into another window?
|
IMGUI_API bool IsWindowDocked(); // is current window docked into another window?
|
||||||
|
|
||||||
|
@ -129,6 +129,16 @@ static void ShowHelpMarker(const char* desc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ShowDockingDisabledMessage()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui::Text("ERROR: Docking is not enabled! See Demo > Configuration.");
|
||||||
|
ImGui::Text("Set io.ConfigFlags |= ImGuiConfigFlags_DockingEnable in your code, or ");
|
||||||
|
ImGui::SameLine(0.0f, 0.0f);
|
||||||
|
if (ImGui::SmallButton("click here"))
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||||
|
}
|
||||||
|
|
||||||
// Helper to display basic user controls.
|
// Helper to display basic user controls.
|
||||||
void ImGui::ShowUserGuide()
|
void ImGui::ShowUserGuide()
|
||||||
{
|
{
|
||||||
@ -3752,10 +3762,18 @@ void ShowExampleAppDockSpace(bool* p_open)
|
|||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
//ImGui::PushStyleColor(ImGuiCol_DockingBg, ImVec4(0.2f, 0.2f, 0.2f, 1.0f));
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGuiID dockspace_id = ImGui::GetID("MyDockspace");
|
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
|
||||||
ImGui::DockSpace(dockspace_id);
|
{
|
||||||
//ImGui::PopStyleColor();
|
//ImGui::PushStyleColor(ImGuiCol_DockingBg, ImVec4(0.2f, 0.2f, 0.2f, 1.0f));
|
||||||
|
ImGuiID dockspace_id = ImGui::GetID("MyDockspace");
|
||||||
|
ImGui::DockSpace(dockspace_id);
|
||||||
|
//ImGui::PopStyleColor();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowDockingDisabledMessage();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
if (opt_fullscreen)
|
if (opt_fullscreen)
|
||||||
@ -3964,38 +3982,45 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
}
|
}
|
||||||
else if (opt_target == Target_Window)
|
else if (opt_target == Target_Window)
|
||||||
{
|
{
|
||||||
NotifyOfDocumentsClosedElsewhere(app);
|
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable)
|
||||||
|
|
||||||
// Create a DockSpace node where any window can be docked
|
|
||||||
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
|
|
||||||
ImGui::DockSpace(dockspace_id);
|
|
||||||
|
|
||||||
// Create Windows
|
|
||||||
for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
|
|
||||||
{
|
{
|
||||||
MyDocument* doc = &app.Documents[doc_n];
|
NotifyOfDocumentsClosedElsewhere(app);
|
||||||
if (!doc->Open)
|
|
||||||
continue;
|
// Create a DockSpace node where any window can be docked
|
||||||
|
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
|
||||||
|
ImGui::DockSpace(dockspace_id);
|
||||||
|
|
||||||
// FIXME-DOCK: SetNextWindowDock()
|
// Create Windows
|
||||||
//ImGuiID default_dock_id = GetDockspaceRootDocumentDockID();
|
for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
|
||||||
//ImGuiID default_dock_id = GetDockspacePreferedDocumentDockID();
|
|
||||||
ImGui::SetNextWindowDockId(dockspace_id, redock_all ? ImGuiCond_Always : ImGuiCond_FirstUseEver);
|
|
||||||
ImGuiWindowFlags window_flags = (doc->Dirty ? ImGuiWindowFlags_UnsavedDocument : 0);
|
|
||||||
bool visible = ImGui::Begin(doc->Name, &doc->Open, window_flags);
|
|
||||||
|
|
||||||
// Cancel attempt to close when unsaved add to save queue so we can display a popup.
|
|
||||||
if (!doc->Open && doc->Dirty)
|
|
||||||
{
|
{
|
||||||
doc->Open = true;
|
MyDocument* doc = &app.Documents[doc_n];
|
||||||
doc->DoQueueClose();
|
if (!doc->Open)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// FIXME-DOCK: SetNextWindowDock()
|
||||||
|
//ImGuiID default_dock_id = GetDockspaceRootDocumentDockID();
|
||||||
|
//ImGuiID default_dock_id = GetDockspacePreferedDocumentDockID();
|
||||||
|
ImGui::SetNextWindowDockId(dockspace_id, redock_all ? ImGuiCond_Always : ImGuiCond_FirstUseEver);
|
||||||
|
ImGuiWindowFlags window_flags = (doc->Dirty ? ImGuiWindowFlags_UnsavedDocument : 0);
|
||||||
|
bool visible = ImGui::Begin(doc->Name, &doc->Open, window_flags);
|
||||||
|
|
||||||
|
// Cancel attempt to close when unsaved add to save queue so we can display a popup.
|
||||||
|
if (!doc->Open && doc->Dirty)
|
||||||
|
{
|
||||||
|
doc->Open = true;
|
||||||
|
doc->DoQueueClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
MyDocument::DisplayContextMenu(doc);
|
||||||
|
if (visible)
|
||||||
|
MyDocument::DisplayContents(doc);
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
MyDocument::DisplayContextMenu(doc);
|
else
|
||||||
if (visible)
|
{
|
||||||
MyDocument::DisplayContents(doc);
|
ShowDockingDisabledMessage();
|
||||||
|
|
||||||
ImGui::End();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user