mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-20 06:46:36 +00:00
Docking: Docking node tab bar honors ItemInnerSpacing.x before first tab. Tweak rendering and alignment of dock node menu marker. (#4130)
+ Fix ~0 in EndFrameDrawDimmedBackgrounds() which is obsolete way of signifying "all round corners".
This commit is contained in:
parent
86c2b609ef
commit
105d82d134
@ -177,7 +177,9 @@ Docking+Viewports Branch:
|
||||
option set to false (dock/undock by default, hold shift to avoid docking). (#2109)
|
||||
- Docking: DockSpace() returns its node ID.
|
||||
- Docking: Dockspace() never draws a background. (#3924)
|
||||
- Docking: undocking nodes/windows covering most of the monitor max their size down to 90% to ease manipulations.
|
||||
- Docking: Undocking nodes/windows covering most of the monitor max their size down to 90% to ease manipulations.
|
||||
- Docking: Docking node tab bar honors ItemInnerSpacing.x before first tab. (#4130)
|
||||
- Docking: Tweak rendering and alignment of dock node menu marker. (#4130)
|
||||
- Docking: Fixed restoring of tab order within a dockspace or a split node.
|
||||
- Docking: Fixed reappearing docked windows with no close button showing a tab with extraneous space for one frame.
|
||||
- Docking: Fixed multiple simultaneously reappearing window from appearing undocked for one frame.
|
||||
|
40
imgui.cpp
40
imgui.cpp
@ -4600,7 +4600,7 @@ static void ImGui::EndFrameDrawDimmedBackgrounds()
|
||||
bb.Expand(-g.FontSize - 1.0f);
|
||||
rounding = window->WindowRounding;
|
||||
}
|
||||
draw_list->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha), rounding, ~0, 3.0f);
|
||||
draw_list->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha), rounding, 0, 3.0f);
|
||||
draw_list->PopClipRect();
|
||||
}
|
||||
}
|
||||
@ -5960,7 +5960,7 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
|
||||
}
|
||||
|
||||
// Render title text, collapse button, close button
|
||||
// When inside a dock node, this is handled in DockNodeUpdateTabBar() instead.
|
||||
// When inside a dock node, this is handled in DockNodeCalcTabBarLayout() instead.
|
||||
void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -12361,7 +12361,7 @@ namespace ImGui
|
||||
static bool DockNodeIsDropAllowed(ImGuiWindow* host_window, ImGuiWindow* payload_window);
|
||||
static void DockNodePreviewDockSetup(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* payload_window, ImGuiDockPreviewData* preview_data, bool is_explicit_target, bool is_outer_docking);
|
||||
static void DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* payload_window, const ImGuiDockPreviewData* preview_data);
|
||||
static void DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* out_title_rect, ImRect* out_tab_bar_rect, ImVec2* out_window_menu_button_pos);
|
||||
static void DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* out_title_rect, ImRect* out_tab_bar_rect, ImVec2* out_window_menu_button_pos, ImVec2* out_close_button_pos);
|
||||
static void DockNodeCalcSplitRects(ImVec2& pos_old, ImVec2& size_old, ImVec2& pos_new, ImVec2& size_new, ImGuiDir dir, ImVec2 size_new_desired);
|
||||
static bool DockNodeCalcDropRectsAndTestMousePos(const ImRect& parent, ImGuiDir dir, ImRect& out_draw, bool outer_docking, ImVec2* test_mouse_pos);
|
||||
static const char* DockNodeGetHostWindowTitle(ImGuiDockNode* node, char* buf, int buf_size) { ImFormatString(buf, buf_size, "##DockNode_%02X", node->ID); return buf; }
|
||||
@ -13872,7 +13872,8 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w
|
||||
// Layout
|
||||
ImRect title_bar_rect, tab_bar_rect;
|
||||
ImVec2 window_menu_button_pos;
|
||||
DockNodeCalcTabBarLayout(node, &title_bar_rect, &tab_bar_rect, &window_menu_button_pos);
|
||||
ImVec2 close_button_pos;
|
||||
DockNodeCalcTabBarLayout(node, &title_bar_rect, &tab_bar_rect, &window_menu_button_pos, &close_button_pos);
|
||||
|
||||
// Submit new tabs, they will be added as Unsorted and sorted below based on relative DockOrder value.
|
||||
const int tabs_count_old = tab_bar->Tabs.Size;
|
||||
@ -13996,8 +13997,7 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w
|
||||
PushItemFlag(ImGuiItemFlags_Disabled, true);
|
||||
PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_Text] * ImVec4(1.0f,1.0f,1.0f,0.4f));
|
||||
}
|
||||
const float button_sz = g.FontSize;
|
||||
if (CloseButton(host_window->GetID("#CLOSE"), title_bar_rect.GetTR() + ImVec2(-style.FramePadding.x * 2.0f - button_sz, 0.0f)))
|
||||
if (CloseButton(host_window->GetID("#CLOSE"), close_button_pos))
|
||||
if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_bar->VisibleTabId))
|
||||
{
|
||||
node->WantCloseTabId = tab->ID;
|
||||
@ -14115,27 +14115,35 @@ static bool ImGui::DockNodeIsDropAllowed(ImGuiWindow* host_window, ImGuiWindow*
|
||||
}
|
||||
|
||||
// window menu button == collapse button when not in a dock node.
|
||||
// FIXME: This is similar to RenderWindowTitleBarContents, may want to share code.
|
||||
static void ImGui::DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* out_title_rect, ImRect* out_tab_bar_rect, ImVec2* out_window_menu_button_pos)
|
||||
// FIXME: This is similar to RenderWindowTitleBarContents(), may want to share code.
|
||||
static void ImGui::DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* out_title_rect, ImRect* out_tab_bar_rect, ImVec2* out_window_menu_button_pos, ImVec2* out_close_button_pos)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiStyle& style = g.Style;
|
||||
|
||||
ImRect r = ImRect(node->Pos.x, node->Pos.y, node->Pos.x + node->Size.x, node->Pos.y + g.FontSize + g.Style.FramePadding.y * 2.0f);
|
||||
if (out_title_rect) { *out_title_rect = r; }
|
||||
|
||||
r.Min.x += style.WindowBorderSize;
|
||||
r.Max.x -= style.WindowBorderSize;
|
||||
|
||||
float button_sz = g.FontSize;
|
||||
|
||||
ImVec2 window_menu_button_pos = r.Min;
|
||||
r.Min.x += g.Style.FramePadding.x;
|
||||
r.Max.x -= g.Style.FramePadding.x;
|
||||
r.Min.x += style.FramePadding.x;
|
||||
r.Max.x -= style.FramePadding.x;
|
||||
if (node->HasCloseButton)
|
||||
{
|
||||
r.Max.x -= g.FontSize;// +1.0f; // In DockNodeUpdateTabBar() we currently display a disabled close button even if there is none.
|
||||
r.Max.x -= button_sz;
|
||||
if (out_close_button_pos) *out_close_button_pos = ImVec2(r.Max.x - style.FramePadding.x, r.Min.y);
|
||||
}
|
||||
if (node->HasWindowMenuButton && g.Style.WindowMenuButtonPosition == ImGuiDir_Left)
|
||||
if (node->HasWindowMenuButton && style.WindowMenuButtonPosition == ImGuiDir_Left)
|
||||
{
|
||||
r.Min.x += g.FontSize; // + g.Style.ItemInnerSpacing.x; // <-- Adding ItemInnerSpacing makes the title text moves slightly when in a docking tab bar. Instead we adjusted RenderArrowDockMenu()
|
||||
r.Min.x += button_sz + style.ItemInnerSpacing.x;
|
||||
}
|
||||
else if (node->HasWindowMenuButton && g.Style.WindowMenuButtonPosition == ImGuiDir_Right)
|
||||
else if (node->HasWindowMenuButton && style.WindowMenuButtonPosition == ImGuiDir_Right)
|
||||
{
|
||||
r.Max.x -= g.FontSize + g.Style.FramePadding.x;
|
||||
r.Max.x -= button_sz + style.FramePadding.x;
|
||||
window_menu_button_pos = ImVec2(r.Max.x, r.Min.y);
|
||||
}
|
||||
if (out_tab_bar_rect) { *out_tab_bar_rect = r; }
|
||||
@ -14352,7 +14360,7 @@ static void ImGui::DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDock
|
||||
{
|
||||
// Compute target tab bar geometry so we can locate our preview tabs
|
||||
ImRect tab_bar_rect;
|
||||
DockNodeCalcTabBarLayout(&data->FutureNode, NULL, &tab_bar_rect, NULL);
|
||||
DockNodeCalcTabBarLayout(&data->FutureNode, NULL, &tab_bar_rect, NULL, NULL);
|
||||
ImVec2 tab_pos = tab_bar_rect.Min;
|
||||
if (host_node && host_node->TabBar)
|
||||
{
|
||||
|
@ -3811,8 +3811,8 @@ void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half
|
||||
// and because the saved space means that the left-most tab label can stay at exactly the same position as the label of a loose window.
|
||||
void ImGui::RenderArrowDockMenu(ImDrawList* draw_list, ImVec2 p_min, float sz, ImU32 col)
|
||||
{
|
||||
draw_list->AddRectFilled(p_min + ImVec2(sz * 0.10f, sz * 0.15f), p_min + ImVec2(sz * 0.70f, sz * 0.30f), col);
|
||||
RenderArrowPointingAt(draw_list, p_min + ImVec2(sz * 0.40f, sz * 0.85f), ImVec2(sz * 0.30f, sz * 0.40f), ImGuiDir_Down, col);
|
||||
draw_list->AddRectFilled(p_min + ImVec2(sz * 0.20f, sz * 0.15f), p_min + ImVec2(sz * 0.80f, sz * 0.30f), col);
|
||||
RenderArrowPointingAt(draw_list, p_min + ImVec2(sz * 0.50f, sz * 0.85f), ImVec2(sz * 0.30f, sz * 0.40f), ImGuiDir_Down, col);
|
||||
}
|
||||
|
||||
static inline float ImAcos01(float x)
|
||||
|
@ -838,12 +838,11 @@ bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos, ImGuiDockNode* dock_no
|
||||
|
||||
// Render
|
||||
//bool is_dock_menu = (window->DockNodeAsHost && !window->Collapsed);
|
||||
ImVec2 off = dock_node ? ImVec2(IM_FLOOR(-g.Style.ItemInnerSpacing.x * 0.5f) + 0.5f, 0.0f) : ImVec2(0.0f, 0.0f);
|
||||
ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
||||
ImU32 text_col = GetColorU32(ImGuiCol_Text);
|
||||
ImVec2 center = bb.GetCenter();
|
||||
if (hovered || held)
|
||||
window->DrawList->AddCircleFilled(center + off + ImVec2(0,-0.5f), g.FontSize * 0.5f + 1.0f, bg_col, 12);
|
||||
window->DrawList->AddCircleFilled(center + ImVec2(0,-0.5f), g.FontSize * 0.5f + 1.0f, bg_col, 12);
|
||||
|
||||
if (dock_node)
|
||||
RenderArrowDockMenu(window->DrawList, bb.Min + g.Style.FramePadding, g.FontSize, text_col);
|
||||
|
Loading…
Reference in New Issue
Block a user