Skip to content

Commit

Permalink
imgui dock API - default dock size
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed Feb 14, 2017
1 parent b2e8761 commit d5ce4b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion external/imgui/imgui_dock.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace ImGui

IMGUI_API void ShutdownDock();
IMGUI_API void RootDock(const ImVec2& pos, const ImVec2& size);
IMGUI_API bool BeginDock(const char* label, bool* opened = nullptr, ImGuiWindowFlags extra_flags = 0);
IMGUI_API bool BeginDock(const char* label, bool* opened = nullptr, ImGuiWindowFlags extra_flags = 0, const ImVec2& default_size = ImVec2(-1, -1));
IMGUI_API void EndDock();
IMGUI_API void SetDockActive();
IMGUI_API void SaveDock(Lumix::FS::OsFile& file);
Expand Down
13 changes: 7 additions & 6 deletions external/imgui/imgui_dock.inl
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ struct DockContext
~DockContext() {}


Dock& getDock(const char* label, bool opened)
Dock& getDock(const char* label, bool opened, const ImVec2& default_size)
{
ImU32 id = ImHash(label, 0);
for (int i = 0; i < m_docks.size(); ++i)
Expand All @@ -224,7 +224,8 @@ struct DockContext
new_dock->setActive();
new_dock->status = Status_Float;
new_dock->pos = ImVec2(0, 0);
new_dock->size = GetIO().DisplaySize;
new_dock->size.x = default_size.x < 0 ? GetIO().DisplaySize.x : default_size.x;
new_dock->size.y = default_size.y < 0 ? GetIO().DisplaySize.y : default_size.y;
new_dock->opened = opened;
new_dock->first = true;
new_dock->last_frame = 0;
Expand Down Expand Up @@ -881,9 +882,9 @@ struct DockContext
}


bool begin(const char* label, bool* opened, ImGuiWindowFlags extra_flags)
bool begin(const char* label, bool* opened, ImGuiWindowFlags extra_flags, const ImVec2& default_size)
{
Dock& dock = getDock(label, !opened || *opened);
Dock& dock = getDock(label, !opened || *opened, default_size);
if (!dock.opened && (!opened || *opened)) tryDockToStoredLocation(dock);
dock.last_frame = ImGui::GetFrameCount();
if (strcmp(dock.label, label) != 0)
Expand Down Expand Up @@ -1159,9 +1160,9 @@ void SetDockActive()
}


bool BeginDock(const char* label, bool* opened, ImGuiWindowFlags extra_flags)
bool BeginDock(const char* label, bool* opened, ImGuiWindowFlags extra_flags, const ImVec2& default_size)
{
return g_dock.begin(label, opened, extra_flags);
return g_dock.begin(label, opened, extra_flags, default_size);
}


Expand Down

0 comments on commit d5ce4b1

Please sign in to comment.