mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 21:21:06 +01:00 
			
		
		
		
	TabBar: made a change to that declared ideal width (for auto-resize) won't lag by an extra frame.
Vaguely relate to underlying (uncommited) work for #3291
This commit is contained in:
		| @@ -6657,9 +6657,9 @@ bool    ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG | |||||||
|     tab_bar->CurrFrameVisible = g.FrameCount; |     tab_bar->CurrFrameVisible = g.FrameCount; | ||||||
|     tab_bar->FramePadding = g.Style.FramePadding; |     tab_bar->FramePadding = g.Style.FramePadding; | ||||||
|  |  | ||||||
|     // Layout |     // Set cursor pos in a way which only be used in the off-chance the user erroneously submits item before BeginTabItem(): items will overlap | ||||||
|     ItemSize(ImVec2(tab_bar->OffsetMaxIdeal, tab_bar->BarRect.GetHeight()), tab_bar->FramePadding.y); |  | ||||||
|     window->DC.CursorPos.x = tab_bar->BarRect.Min.x; |     window->DC.CursorPos.x = tab_bar->BarRect.Min.x; | ||||||
|  |     window->DC.CursorPos.y = tab_bar->BarRect.Max.y + g.Style.ItemSpacing.y; | ||||||
|  |  | ||||||
|     // Draw separator |     // Draw separator | ||||||
|     const ImU32 col = GetColorU32((flags & ImGuiTabBarFlags_IsFocused) ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive); |     const ImU32 col = GetColorU32((flags & ImGuiTabBarFlags_IsFocused) ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive); | ||||||
| @@ -6685,7 +6685,7 @@ void    ImGui::EndTabBar() | |||||||
|         IM_ASSERT_USER_ERROR(tab_bar != NULL, "Mismatched BeginTabBar()/EndTabBar()!"); |         IM_ASSERT_USER_ERROR(tab_bar != NULL, "Mismatched BeginTabBar()/EndTabBar()!"); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     if (tab_bar->WantLayout) |     if (tab_bar->WantLayout) // Fallback in case no TabItem have been submitted | ||||||
|         TabBarLayout(tab_bar); |         TabBarLayout(tab_bar); | ||||||
|  |  | ||||||
|     // Restore the last visible height if no tab is visible, this reduce vertical flicker/movement when a tabs gets removed without calling SetTabItemClosed(). |     // Restore the last visible height if no tab is visible, this reduce vertical flicker/movement when a tabs gets removed without calling SetTabItemClosed(). | ||||||
| @@ -6871,6 +6871,11 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar) | |||||||
|     // Clear name buffers |     // Clear name buffers | ||||||
|     if ((tab_bar->Flags & ImGuiTabBarFlags_DockNode) == 0) |     if ((tab_bar->Flags & ImGuiTabBarFlags_DockNode) == 0) | ||||||
|         tab_bar->TabsNames.Buf.resize(0); |         tab_bar->TabsNames.Buf.resize(0); | ||||||
|  |  | ||||||
|  |     // Actual layout in host window (we don't do it in BeginTabBar() so as not to waste an extra frame) | ||||||
|  |     ImGuiWindow* window = g.CurrentWindow; | ||||||
|  |     window->DC.CursorPos = tab_bar->BarRect.Min; | ||||||
|  |     ItemSize(ImVec2(tab_bar->OffsetMaxIdeal, tab_bar->BarRect.GetHeight()), tab_bar->FramePadding.y); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Dockables uses Name/ID in the global namespace. Non-dockable items use the ID stack. | // Dockables uses Name/ID in the global namespace. Non-dockable items use the ID stack. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user