Explorar o código

TabBar: fixed calling TabBarQueueFocus() before submitting tabs. (#8929, #6681)

ocornut hai 1 día
pai
achega
1cd08b883c
Modificáronse 3 ficheiros con 5 adicións e 2 borrados
  1. 2 0
      docs/CHANGELOG.txt
  2. 1 1
      imgui.h
  3. 2 1
      imgui_widgets.cpp

+ 2 - 0
docs/CHANGELOG.txt

@@ -71,6 +71,8 @@ Other Changes:
   unmoved. We revert back to move to the end of line in this situation.
 - Selectable: added ImGuiSelectableFlags_SelectOnNav to auto-select an item when
   moved into (automatic when in a BeginMultiSelect() block).
+- TabBar: fixed an issue were forcefully selecting a tab using internal API would
+  be ignored on first/appearing frame before tabs are submitted (#8929, #6681)
 - DrawList: fixed CloneOutput() unnecessarily taking a copy of the ImDrawListSharedData
   pointer, which could to issue when deleting the cloned list. (#8894, #1860)
 - DrawList: made AddCallback() assert when passing a null callback.

+ 1 - 1
imgui.h

@@ -29,7 +29,7 @@
 // Library Version
 // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
 #define IMGUI_VERSION       "1.92.3 WIP"
-#define IMGUI_VERSION_NUM   19226
+#define IMGUI_VERSION_NUM   19227
 #define IMGUI_HAS_TABLE             // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
 #define IMGUI_HAS_TEXTURES          // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
 

+ 2 - 1
imgui_widgets.cpp

@@ -9908,7 +9908,8 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
     tab_bar->TabsNames.Buf.resize(0);
 
     // If we have lost the selected tab, select the next most recently active one
-    if (found_selected_tab_id == false)
+    const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount);
+    if (found_selected_tab_id == false && !tab_bar_appearing)
         tab_bar->SelectedTabId = 0;
     if (tab_bar->SelectedTabId == 0 && tab_bar->NextSelectedTabId == 0 && most_recently_selected_tab != NULL)
         scroll_to_tab_id = tab_bar->SelectedTabId = most_recently_selected_tab->ID;