mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-20 23:06:36 +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& g = *ctx;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable))
|
||||
return;
|
||||
|
||||
ImGuiDockNode* node = DockContextFindNodeByID(ctx, id);
|
||||
if (!node)
|
||||
|
5
imgui.h
5
imgui.h
@ -524,11 +524,12 @@ namespace ImGui
|
||||
|
||||
// Docking
|
||||
// [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.
|
||||
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 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 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.
|
||||
void ImGui::ShowUserGuide()
|
||||
{
|
||||
@ -3752,10 +3762,18 @@ void ShowExampleAppDockSpace(bool* p_open)
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
//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();
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
|
||||
{
|
||||
//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();
|
||||
if (opt_fullscreen)
|
||||
@ -3964,38 +3982,45 @@ void ShowExampleAppDocuments(bool* p_open)
|
||||
}
|
||||
else if (opt_target == Target_Window)
|
||||
{
|
||||
NotifyOfDocumentsClosedElsewhere(app);
|
||||
|
||||
// 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++)
|
||||
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable)
|
||||
{
|
||||
MyDocument* doc = &app.Documents[doc_n];
|
||||
if (!doc->Open)
|
||||
continue;
|
||||
NotifyOfDocumentsClosedElsewhere(app);
|
||||
|
||||
// Create a DockSpace node where any window can be docked
|
||||
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
|
||||
ImGui::DockSpace(dockspace_id);
|
||||
|
||||
// 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)
|
||||
// Create Windows
|
||||
for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
|
||||
{
|
||||
doc->Open = true;
|
||||
doc->DoQueueClose();
|
||||
MyDocument* doc = &app.Documents[doc_n];
|
||||
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);
|
||||
if (visible)
|
||||
MyDocument::DisplayContents(doc);
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowDockingDisabledMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user