Docking: Added ImGuiDockNodeFlags_NoOuterBorder, tweaked DockSpace demo to remove window border. Made docking splitter use the same standard setting as resizing from edges. (#2109)

This commit is contained in:
omar 2018-10-03 18:30:36 +02:00
parent 059560d28b
commit 2dd8338e7d
3 changed files with 19 additions and 18 deletions

View File

@ -9578,7 +9578,7 @@ void ImGui::EndDragDropTarget()
// Docking: Internal Types
//-----------------------------------------------------------------------------
static float IMGUI_DOCK_SPLITTER_SIZE = 4.0f;
static float IMGUI_DOCK_SPLITTER_SIZE = 2.0f;
enum ImGuiDockRequestType
{
@ -11375,13 +11375,6 @@ void ImGui::DockNodeTreeUpdateSplitter(ImGuiDockNode* node)
ImGuiDockNode* child_1 = node->ChildNodes[1];
if (child_0->IsVisible && child_1->IsVisible)
{
// Extend hovering range past the displayed border
// FIXME-DOCKING: This is not working as expected.
float HOVER_EXTEND = 4.0f;
// Use a short delay before highlighting the splitter (and changing the mouse cursor) in order for regular mouse movement to not highlight many splitters
float HOVER_VISIBILITY_DELAY = 0.040f;
// Bounding box of the splitter cover the space between both nodes (w = Spacing, h = Size[xy^1] for when splitting horizontally)
const ImGuiAxis axis = (ImGuiAxis)node->SplitAxis;
IM_ASSERT(axis != ImGuiAxis_None);
@ -11390,12 +11383,12 @@ void ImGui::DockNodeTreeUpdateSplitter(ImGuiDockNode* node)
bb.Max = child_1->Pos;
bb.Min[axis] += child_0->Size[axis];
bb.Max[axis ^ 1] += child_1->Size[axis ^ 1];
//GetOverlayDrawList(g.CurrentWindow->Viewport)->AddRect(bb.Min, bb.Max, IM_COL32(255,0,255,255));
//if (g.IO.KeyCtrl) GetOverlayDrawList(g.CurrentWindow->Viewport)->AddRect(bb.Min, bb.Max, IM_COL32(255,0,255,255));
float w1 = child_0->Size[axis];
float w2 = child_1->Size[axis];
bb.Min[axis] += 1; // Display a little inward so highlight doesn't connect with nearby tabs on the neighbor node.
bb.Max[axis] -= 1;
//bb.Min[axis] += 1; // Display a little inward so highlight doesn't connect with nearby tabs on the neighbor node.
//bb.Max[axis] -= 1;
PushID(node->ID);
// Gather list of nodes that are touching the splitter line. Find resizing limits based on those nodes.
@ -11427,9 +11420,10 @@ void ImGui::DockNodeTreeUpdateSplitter(ImGuiDockNode* node)
*/
}
// Use a short delay before highlighting the splitter (and changing the mouse cursor) in order for regular mouse movement to not highlight many splitters
float min_size_0 = resize_limits[0] - child_0->Pos[axis];
float min_size_1 = child_1->Pos[axis] + child_1->Size[axis] - resize_limits[1];
if (SplitterBehavior(bb, GetID("##Splitter"), axis, &w1, &w2, min_size_0, min_size_1, HOVER_EXTEND, HOVER_VISIBILITY_DELAY))
if (SplitterBehavior(bb, GetID("##Splitter"), axis, &w1, &w2, min_size_0, min_size_1, RESIZE_WINDOWS_FROM_EDGES_HALF_THICKNESS, RESIZE_WINDOWS_FROM_EDGES_FEEDBACK_TIMER))
{
if (touching_nodes[0].Size > 0 && touching_nodes[1].Size > 0)
{
@ -11574,7 +11568,11 @@ void ImGui::DockSpace(ImGuiID id, const ImVec2& size_arg, ImGuiDockNodeFlags doc
if (node->Windows.Size > 0 || node->IsSplitNode())
PushStyleColor(ImGuiCol_ChildBg, IM_COL32(0, 0, 0, 0));
if (dockspace_flags & ImGuiDockNodeFlags_NoOuterBorder)
PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f);
Begin(title, NULL, window_flags);
if (dockspace_flags & ImGuiDockNodeFlags_NoOuterBorder)
PopStyleVar();
if (node->Windows.Size > 0 || node->IsSplitNode())
PopStyleColor();

View File

@ -798,7 +798,8 @@ enum ImGuiDockNodeFlags_
ImGuiDockNodeFlags_None = 0,
ImGuiDockNodeFlags_KeepAliveOnly = 1 << 0, // Don't display the dockspace node but keep it alive. Windows docked into this dockspace node won't be undocked.
ImGuiDockNodeFlags_NoSplit = 1 << 1, // Disable splitting the node into smaller nodes. Useful e.g. when embedding dockspaces into a main root one (the root one may have splitting disabled to reduce confusion)
ImGuiDockNodeFlags_NoDockingInsideCentralNode = 1 << 2 // Disable docking inside the central node (which can stay empty). Useful if it is kept empty and invisible.
ImGuiDockNodeFlags_NoOuterBorder = 1 << 2, // Disable outer border on a DockSpace() node.
ImGuiDockNodeFlags_NoDockingInsideCentralNode = 1 << 3 // Disable docking inside the central node (which can stay empty). Useful if it is kept empty and invisible.
};
// Flags for ImGui::IsWindowFocused()

View File

@ -3735,15 +3735,16 @@ void ShowExampleAppDockSpace(bool* p_open)
static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
ImGui::Begin("DockSpace Demo", p_open, flags);
ImGui::PopStyleVar();
ImGui::PopStyleVar(2);
// Dockspace
ImGuiIO& io = ImGui::GetIO();
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
{
ImGuiID dockspace_id = ImGui::GetID("MyDockspace");
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags | ImGuiDockNodeFlags_NoOuterBorder);
}
else
{
@ -3758,14 +3759,15 @@ void ShowExampleAppDockSpace(bool* p_open)
*p_open = false;
ImGui::Separator();
// Disabling fullscreen would allow the window to be moved to the front of other windows,
// which we can't undo at the moment without finer window depth/z control.
//ImGui::MenuItem("Fullscreen", NULL, &opt_fullscreen_persistant);
if (ImGui::MenuItem("Flag: NoSplit", "", (dockspace_flags & ImGuiDockNodeFlags_NoSplit) != 0))
dockspace_flags ^= ImGuiDockNodeFlags_NoSplit;
if (ImGui::MenuItem("Flag: NoDockingInsideCentralNode", "", (dockspace_flags & ImGuiDockNodeFlags_NoDockingInsideCentralNode) != 0))
dockspace_flags ^= ImGuiDockNodeFlags_NoDockingInsideCentralNode;
// Disabling fullscreen would allow the window to be moved to the front of other windows,
// which we can't undo at the moment without finer window depth/z control.
//ImGui::MenuItem("Fullscreen", NULL, &opt_fullscreen_persistant);
ImGui::EndMenu();
}
ShowHelpMarker(