mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 13:11:05 +01:00 
			
		
		
		
	Docking: Added Docking system. Enable with io.ConfigFlags |= ImGuiConfigFlags_DockingEnable. (Part 1) (#351)
This commit is contained in:
		| @@ -210,6 +210,8 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst) | ||||
|     colors[ImGuiCol_TabUnfocused]           = ImLerp(colors[ImGuiCol_Tab],          colors[ImGuiCol_TitleBg], 0.80f); | ||||
|     colors[ImGuiCol_TabUnfocusedActive]     = ImLerp(colors[ImGuiCol_TabActive],    colors[ImGuiCol_TitleBg], 0.40f); | ||||
|     colors[ImGuiCol_TabHovered]             = colors[ImGuiCol_HeaderHovered]; | ||||
|     colors[ImGuiCol_DockingPreview]         = colors[ImGuiCol_HeaderActive] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f); | ||||
|     colors[ImGuiCol_DockingBg]              = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);; | ||||
|     colors[ImGuiCol_PlotLines]              = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); | ||||
|     colors[ImGuiCol_PlotLinesHovered]       = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); | ||||
|     colors[ImGuiCol_PlotHistogram]          = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); | ||||
| @@ -265,6 +267,8 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst) | ||||
|     colors[ImGuiCol_TabUnfocused]           = ImLerp(colors[ImGuiCol_Tab],          colors[ImGuiCol_TitleBg], 0.80f); | ||||
|     colors[ImGuiCol_TabUnfocusedActive]     = ImLerp(colors[ImGuiCol_TabActive],    colors[ImGuiCol_TitleBg], 0.40f); | ||||
|     colors[ImGuiCol_TabHovered]             = colors[ImGuiCol_HeaderHovered]; | ||||
|     colors[ImGuiCol_DockingPreview]         = colors[ImGuiCol_Header] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f); | ||||
|     colors[ImGuiCol_DockingBg]              = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);; | ||||
|     colors[ImGuiCol_PlotLines]              = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); | ||||
|     colors[ImGuiCol_PlotLinesHovered]       = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); | ||||
|     colors[ImGuiCol_PlotHistogram]          = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); | ||||
| @@ -321,6 +325,8 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst) | ||||
|     colors[ImGuiCol_TabUnfocused]           = ImLerp(colors[ImGuiCol_Tab],          colors[ImGuiCol_TitleBg], 0.80f); | ||||
|     colors[ImGuiCol_TabUnfocusedActive]     = ImLerp(colors[ImGuiCol_TabActive],    colors[ImGuiCol_TitleBg], 0.40f); | ||||
|     colors[ImGuiCol_TabHovered]             = colors[ImGuiCol_HeaderHovered]; | ||||
|     colors[ImGuiCol_DockingPreview]         = colors[ImGuiCol_Header] * ImVec4(1.0f, 1.0f, 1.0f, 0.7f); | ||||
|     colors[ImGuiCol_DockingBg]              = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);; | ||||
|     colors[ImGuiCol_PlotLines]              = ImVec4(0.39f, 0.39f, 0.39f, 1.00f); | ||||
|     colors[ImGuiCol_PlotLinesHovered]       = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); | ||||
|     colors[ImGuiCol_PlotHistogram]          = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); | ||||
| @@ -2831,8 +2837,10 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col | ||||
| // (progressively moved from imgui.cpp to here when they are redesigned to stop accessing ImGui global state) | ||||
| //----------------------------------------------------------------------------- | ||||
| // - RenderMouseCursor() | ||||
| // - RenderArrowDockMenu() | ||||
| // - RenderArrowPointingAt() | ||||
| // - RenderRectFilledRangeH() | ||||
| // - RenderRectFilledWithHole() | ||||
| // - RenderPixelEllipsis() | ||||
| //----------------------------------------------------------------------------- | ||||
|  | ||||
| @@ -2874,6 +2882,14 @@ void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half | ||||
|     } | ||||
| } | ||||
|  | ||||
| // This is less wide than RenderArrow() and we use in dock nodes instead of the regular RenderArrow() to denote a change of functionality, | ||||
| // 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); | ||||
| } | ||||
|  | ||||
| static inline float ImAcos01(float x) | ||||
| { | ||||
|     if (x <= 0.0f) return IM_PI * 0.5f; | ||||
| @@ -2942,6 +2958,24 @@ void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, Im | ||||
|     draw_list->PathFillConvex(col); | ||||
| } | ||||
|  | ||||
| // For CTRL+TAB within a docking node we need to render the dimming background in 8 steps | ||||
| // (Because the root node renders the background in one shot, in order to avoid flickering when a child dock node is not submitted) | ||||
| void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect inner, ImU32 col, float rounding) | ||||
| { | ||||
|     const bool fill_L = (inner.Min.x > outer.Min.x); | ||||
|     const bool fill_R = (inner.Max.x < outer.Max.x); | ||||
|     const bool fill_U = (inner.Min.y > outer.Min.y); | ||||
|     const bool fill_D = (inner.Max.y < outer.Max.y); | ||||
|     if (fill_L) draw_list->AddRectFilled(ImVec2(outer.Min.x, inner.Min.y), ImVec2(inner.Min.x, inner.Max.y), col, rounding, (fill_U ? 0 : ImDrawCornerFlags_TopLeft) | (fill_D ? 0 : ImDrawCornerFlags_BotLeft)); | ||||
|     if (fill_R) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Min.y), ImVec2(outer.Max.x, inner.Max.y), col, rounding, (fill_U ? 0 : ImDrawCornerFlags_TopRight) | (fill_D ? 0 : ImDrawCornerFlags_BotRight)); | ||||
|     if (fill_U) draw_list->AddRectFilled(ImVec2(inner.Min.x, outer.Min.y), ImVec2(inner.Max.x, inner.Min.y), col, rounding, (fill_L ? 0 : ImDrawCornerFlags_TopLeft) | (fill_R ? 0 : ImDrawCornerFlags_TopRight)); | ||||
|     if (fill_D) draw_list->AddRectFilled(ImVec2(inner.Min.x, inner.Max.y), ImVec2(inner.Max.x, outer.Max.y), col, rounding, (fill_L ? 0 : ImDrawCornerFlags_BotLeft) | (fill_R ? 0 : ImDrawCornerFlags_BotRight)); | ||||
|     if (fill_L && fill_U) draw_list->AddRectFilled(ImVec2(outer.Min.x, outer.Min.y), ImVec2(inner.Min.x, inner.Min.y), col, rounding, ImDrawCornerFlags_TopLeft); | ||||
|     if (fill_R && fill_U) draw_list->AddRectFilled(ImVec2(inner.Max.x, outer.Min.y), ImVec2(outer.Max.x, inner.Min.y), col, rounding, ImDrawCornerFlags_TopRight); | ||||
|     if (fill_L && fill_D) draw_list->AddRectFilled(ImVec2(outer.Min.x, inner.Max.y), ImVec2(inner.Min.x, outer.Max.y), col, rounding, ImDrawCornerFlags_BotLeft); | ||||
|     if (fill_R && fill_D) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Max.y), ImVec2(outer.Max.x, outer.Max.y), col, rounding, ImDrawCornerFlags_BotRight); | ||||
| } | ||||
|  | ||||
| // FIXME: Rendering an ellipsis "..." is a surprisingly tricky problem... can't rely on font glyph having it, and regular dot are typically too wide. | ||||
| // If we render a dot/shape ourselves it comes with the risk that it wouldn't match the boldness or positioning of what the font uses... | ||||
| void ImGui::RenderPixelEllipsis(ImDrawList* draw_list, ImFont* font, ImVec2 pos, int count, ImU32 col) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user