Skip to content

Commit b79751e

Browse files
committed
Docking: Added DockingSeparatorSize to style: amends (#3481, #4721, #2522)
Add ImGuiStyleVar_DockingSeparatorSize + misc Docking related comments.
1 parent a5aff5f commit b79751e

File tree

4 files changed

+34
-19
lines changed

4 files changed

+34
-19
lines changed

docs/CHANGELOG.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ Other changes:
9797
Note that Linux/Mac still have inconsistent support for multi-viewports. If you want to help see https://github.com/ocornut/imgui/issues/2117.
9898

9999

100+
-----------------------------------------------------------------------
101+
VERSION 1.89.8 WIP (In Progress)
102+
-----------------------------------------------------------------------
103+
104+
Docking+Viewports Branch:
105+
106+
- Docking: added style.DockingSeparatorSize, ImGuiStyleVar_DockingSeparatorSize. Now
107+
also scaled by style.ScaleAllSizes(). (#3481, #4721, #2522) [@PossiblyAShrub, @wobbier]
108+
109+
100110
-----------------------------------------------------------------------
101111
VERSION 1.89.7 (Released 2023-07-04)
102112
-----------------------------------------------------------------------

imgui.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ ImGuiStyle::ImGuiStyle()
11841184
SeparatorTextPadding = ImVec2(20.0f,3.f);// Horizontal offset of text from each edge of the separator + spacing on other axis. Generally small values. .y is recommended to be == FramePadding.y.
11851185
DisplayWindowPadding = ImVec2(19,19); // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
11861186
DisplaySafeAreaPadding = ImVec2(3,3); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
1187-
DockingSplitterSize = 2.0f; // Thickness of border/padding between docked windows
1187+
DockingSeparatorSize = 2.0f; // Thickness of resizing border between docked windows
11881188
MouseCursorScale = 1.0f; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
11891189
AntiAliasedLines = true; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU.
11901190
AntiAliasedLinesUseTex = true; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering).
@@ -1228,6 +1228,7 @@ void ImGuiStyle::ScaleAllSizes(float scale_factor)
12281228
TabRounding = ImFloor(TabRounding * scale_factor);
12291229
TabMinWidthForCloseButton = (TabMinWidthForCloseButton != FLT_MAX) ? ImFloor(TabMinWidthForCloseButton * scale_factor) : FLT_MAX;
12301230
SeparatorTextPadding = ImFloor(SeparatorTextPadding * scale_factor);
1231+
DockingSeparatorSize = ImFloor(DockingSeparatorSize * scale_factor);
12311232
DisplayWindowPadding = ImFloor(DisplayWindowPadding * scale_factor);
12321233
DisplaySafeAreaPadding = ImFloor(DisplaySafeAreaPadding * scale_factor);
12331234
MouseCursorScale = ImFloor(MouseCursorScale * scale_factor);
@@ -3151,6 +3152,7 @@ static const ImGuiDataVarInfo GStyleVarInfo[] =
31513152
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, SeparatorTextBorderSize) },// ImGuiStyleVar_SeparatorTextBorderSize
31523153
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SeparatorTextAlign) }, // ImGuiStyleVar_SeparatorTextAlign
31533154
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SeparatorTextPadding) }, // ImGuiStyleVar_SeparatorTextPadding
3155+
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, DockingSeparatorSize) }, // ImGuiStyleVar_DockingSeparatorSize
31543156
};
31553157

31563158
const ImGuiDataVarInfo* ImGui::GetStyleVarInfo(ImGuiStyleVar idx)
@@ -15294,7 +15296,7 @@ void ImGui::DockContextEndFrame(ImGuiContext* ctx)
1529415296
if (node->LastFrameActive == g.FrameCount && node->IsVisible && node->HostWindow && node->IsLeafNode() && !node->IsBgDrawnThisFrame)
1529515297
{
1529615298
ImRect bg_rect(node->Pos + ImVec2(0.0f, GetFrameHeight()), node->Pos + node->Size);
15297-
ImDrawFlags bg_rounding_flags = CalcRoundingFlagsForRectInRect(bg_rect, node->HostWindow->Rect(), g.Style.DockingSplitterSize);
15299+
ImDrawFlags bg_rounding_flags = CalcRoundingFlagsForRectInRect(bg_rect, node->HostWindow->Rect(), g.Style.DockingSeparatorSize);
1529815300
node->HostWindow->DrawList->ChannelsSetCurrent(DOCKING_HOST_DRAW_CHANNEL_BG);
1529915301
node->HostWindow->DrawList->AddRectFilled(bg_rect.Min, bg_rect.Max, node->LastBgColor, node->HostWindow->WindowRounding, bg_rounding_flags);
1530015302
}
@@ -16767,7 +16769,7 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w
1676716769
if (is_focused)
1676816770
node->LastFrameFocused = g.FrameCount;
1676916771
ImU32 title_bar_col = GetColorU32(host_window->Collapsed ? ImGuiCol_TitleBgCollapsed : is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg);
16770-
ImDrawFlags rounding_flags = CalcRoundingFlagsForRectInRect(title_bar_rect, host_window->Rect(), g.Style.DockingSplitterSize);
16772+
ImDrawFlags rounding_flags = CalcRoundingFlagsForRectInRect(title_bar_rect, host_window->Rect(), g.Style.DockingSeparatorSize);
1677116773
host_window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, host_window->WindowRounding, rounding_flags);
1677216774

1677316775
// Docking/Collapse button
@@ -17249,7 +17251,7 @@ static void ImGui::DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDock
1724917251
overlay_rect.Min.y += GetFrameHeight();
1725017252
if (data->SplitDir != ImGuiDir_None || data->IsCenterAvailable)
1725117253
for (int overlay_n = 0; overlay_n < overlay_draw_lists_count; overlay_n++)
17252-
overlay_draw_lists[overlay_n]->AddRectFilled(overlay_rect.Min, overlay_rect.Max, overlay_col_main, host_window->WindowRounding, CalcRoundingFlagsForRectInRect(overlay_rect, host_window->Rect(), g.Style.DockingSplitterSize));
17254+
overlay_draw_lists[overlay_n]->AddRectFilled(overlay_rect.Min, overlay_rect.Max, overlay_col_main, host_window->WindowRounding, CalcRoundingFlagsForRectInRect(overlay_rect, host_window->Rect(), g.Style.DockingSeparatorSize));
1725317255
}
1725417256

1725517257
// Display tab shape/label preview unless we are splitting node (it generally makes the situation harder to read)
@@ -17366,7 +17368,7 @@ void ImGui::DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImG
1736617368
parent_node->VisibleWindow = NULL;
1736717369
parent_node->AuthorityForPos = parent_node->AuthorityForSize = ImGuiDataAuthority_DockNode;
1736817370

17369-
float size_avail = (parent_node->Size[split_axis] - g.Style.DockingSplitterSize);
17371+
float size_avail = (parent_node->Size[split_axis] - g.Style.DockingSeparatorSize);
1737017372
size_avail = ImMax(size_avail, g.Style.WindowMinSize[split_axis] * 2.0f);
1737117373
IM_ASSERT(size_avail > 0.0f); // If you created a node manually with DockBuilderAddNode(), you need to also call DockBuilderSetNodeSize() before splitting.
1737217374
child_0->SizeRef = child_1->SizeRef = parent_node->Size;
@@ -17447,6 +17449,7 @@ void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 si
1744717449
{
1744817450
// During the regular dock node update we write to all nodes.
1744917451
// 'only_write_to_single_node' is only set when turning a node visible mid-frame and we need its size right-away.
17452+
ImGuiContext& g = *GImGui;
1745017453
const bool write_to_node = only_write_to_single_node == NULL || only_write_to_single_node == node;
1745117454
if (write_to_node)
1745217455
{
@@ -17469,8 +17472,7 @@ void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 si
1746917472

1747017473
if (child_0_is_or_will_be_visible && child_1_is_or_will_be_visible)
1747117474
{
17472-
ImGuiContext& g = *GImGui;
17473-
const float spacing = g.Style.DockingSplitterSize;
17475+
const float spacing = g.Style.DockingSeparatorSize;
1747417476
const ImGuiAxis axis = (ImGuiAxis)node->SplitAxis;
1747517477
const float size_avail = ImMax(size[axis] - spacing, 0.0f);
1747617478

imgui.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,9 @@ namespace ImGui
819819
// - Drag from window menu button (upper-left button) to undock an entire node (all windows).
820820
// - When io.ConfigDockingWithShift == true, you instead need to hold SHIFT to _enable_ docking/undocking.
821821
// About dockspaces:
822-
// - Use DockSpace() to create an explicit dock node _within_ an existing window. See Docking demo for details.
823822
// - Use DockSpaceOverViewport() to create an explicit dock node covering the screen or a specific viewport.
824-
// This is often used with ImGuiDockNodeFlags_PassthruCentralNode.
823+
// This is often used with ImGuiDockNodeFlags_PassthruCentralNode to make it transparent.
824+
// - Use DockSpace() to create an explicit dock node _within_ an existing window. See Docking demo for details.
825825
// - Important: Dockspaces need to be submitted _before_ any window they can host. Submit it early in your frame!
826826
// - Important: Dockspaces need to be kept alive if hidden, otherwise windows docked into it will be undocked.
827827
// e.g. if you have multiple tabs with a dockspace inside each tab: submit the non-visible dockspaces with ImGuiDockNodeFlags_KeepAliveOnly.
@@ -1723,6 +1723,7 @@ enum ImGuiStyleVar_
17231723
ImGuiStyleVar_SeparatorTextBorderSize,// float SeparatorTextBorderSize
17241724
ImGuiStyleVar_SeparatorTextAlign, // ImVec2 SeparatorTextAlign
17251725
ImGuiStyleVar_SeparatorTextPadding,// ImVec2 SeparatorTextPadding
1726+
ImGuiStyleVar_DockingSeparatorSize,// float DockingSeparatorSize
17261727
ImGuiStyleVar_COUNT
17271728
};
17281729

@@ -1992,7 +1993,7 @@ struct ImGuiStyle
19921993
ImVec2 SeparatorTextPadding; // Horizontal offset of text from each edge of the separator + spacing on other axis. Generally small values. .y is recommended to be == FramePadding.y.
19931994
ImVec2 DisplayWindowPadding; // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
19941995
ImVec2 DisplaySafeAreaPadding; // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly!
1995-
float DockingSplitterSize; // Thickness of border/padding between docked windows
1996+
float DockingSeparatorSize; // Thickness of resizing border between docked windows
19961997
float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). We apply per-monitor DPI scaling over this scale. May be removed later.
19971998
bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
19981999
bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering). Latched at the beginning of the frame (copied to ImDrawList).

imgui_demo.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6379,7 +6379,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
63796379
ImGui::SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f");
63806380

63816381
ImGui::SeparatorText("Docking");
6382-
ImGui::SliderFloat("DockingSplitterSize", &style.DockingSplitterSize, 0.0f, 12.0f, "%.0f");
6382+
ImGui::SliderFloat("DockingSplitterSize", &style.DockingSeparatorSize, 0.0f, 12.0f, "%.0f");
63836383

63846384
ImGui::SeparatorText("Tooltips");
63856385
for (int n = 0; n < 2; n++)
@@ -7953,18 +7953,20 @@ static void ShowExampleAppCustomRendering(bool* p_open)
79537953
// your own implicit "Debug##2" window after calling DockSpace() and leave it in the window stack for anyone to use.
79547954
void ShowExampleAppDockSpace(bool* p_open)
79557955
{
7956-
// If you strip some features of, this demo is pretty much equivalent to calling DockSpaceOverViewport()!
7957-
// In most cases you should be able to just call DockSpaceOverViewport() and ignore all the code below!
7958-
// In this specific demo, we are not using DockSpaceOverViewport() because:
7959-
// - we allow the host window to be floating/moveable instead of filling the viewport (when opt_fullscreen == false)
7960-
// - we allow the host window to have padding (when opt_padding == true)
7961-
// - we have a local menu bar in the host window (vs. you could use BeginMainMenuBar() + DockSpaceOverViewport() in your code!)
7962-
// TL;DR; this demo is more complicated than what you would normally use.
7963-
// If we removed all the options we are showcasing, this demo would become:
7956+
// READ THIS !!!
7957+
// TL;DR; this demo is more complicated than what most users you would normally use.
7958+
// If we remove all options we are showcasing, this demo would become:
79647959
// void ShowExampleAppDockSpace()
79657960
// {
79667961
// ImGui::DockSpaceOverViewport(ImGui::GetMainViewport());
79677962
// }
7963+
// In most cases you should be able to just call DockSpaceOverViewport() and ignore all the code below!
7964+
// In this specific demo, we are not using DockSpaceOverViewport() because:
7965+
// - (1) we allow the host window to be floating/moveable instead of filling the viewport (when opt_fullscreen == false)
7966+
// - (2) we allow the host window to have padding (when opt_padding == true)
7967+
// - (3) we expose many flags and need a way to have them visible.
7968+
// - (4) we have a local menu bar in the host window (vs. you could use BeginMainMenuBar() + DockSpaceOverViewport()
7969+
// in your code, but we don't here because we allow the window to be floating)
79687970

79697971
static bool opt_fullscreen = true;
79707972
static bool opt_padding = false;

0 commit comments

Comments
 (0)