tweaked docking so that windows do not float by default

master
Martin Felis 2017-04-11 12:55:30 +02:00
parent 5fc54a04f6
commit e6d12e22a2
1 changed files with 8 additions and 3 deletions

View File

@ -856,7 +856,12 @@ namespace ImGui
void rootDock(const ImVec2& pos, const ImVec2& size) void rootDock(const ImVec2& pos, const ImVec2& size)
{ {
Dock* root = getRootDock(); Dock* root = getRootDock();
if (!root) return;
// martin: make sure we have a root dock
if (!root)
root = &getDock("Root", true);
root->status = Status_Docked;
ImVec2 min_size = root->getMinSize(); ImVec2 min_size = root->getMinSize();
ImVec2 requested_size = size; ImVec2 requested_size = size;
@ -901,7 +906,6 @@ namespace ImGui
void tryDockToStoredLocation(Dock& dock) void tryDockToStoredLocation(Dock& dock)
{ {
if (dock.status == Status_Docked) return; if (dock.status == Status_Docked) return;
if (dock.location[0] == 0) return;
Dock* tmp = getRootDock(); Dock* tmp = getRootDock();
if (!tmp) return; if (!tmp) return;
@ -921,7 +925,8 @@ namespace ImGui
bool begin(const char* label, bool* opened, ImGuiWindowFlags extra_flags) bool begin(const char* label, bool* opened, ImGuiWindowFlags extra_flags)
{ {
Dock& dock = getDock(label, !opened || *opened); Dock& dock = getDock(label, !opened || *opened);
if (!dock.opened && (!opened || *opened)) tryDockToStoredLocation(dock); // martin: tweak docking for better defaults
if (!dock.opened || (!opened || *opened)) tryDockToStoredLocation(dock);
dock.last_frame = ImGui::GetFrameCount(); dock.last_frame = ImGui::GetFrameCount();
if (strcmp(dock.label, label) != 0) if (strcmp(dock.label, label) != 0)
{ {