mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 20:07:01 +00:00
TabBar: Fixed using more than 32 KB-worth of tab names. (#4176)
This commit is contained in:
parent
04fd5072fb
commit
79e18896fe
@ -36,6 +36,7 @@ HOW TO UPDATE?
|
|||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
|
- TabBar: Fixed using more than 32 KB-worth of tab names. (#4176)
|
||||||
- Demo: Fixed requirement in 1.83 to link with imgui_demo.cpp if IMGUI_DISABLE_METRICS_WINDOW is not set. (#4171)
|
- Demo: Fixed requirement in 1.83 to link with imgui_demo.cpp if IMGUI_DISABLE_METRICS_WINDOW is not set. (#4171)
|
||||||
Normally the right way to disable compiling the demo is to set IMGUI_DISABLE_DEMO_WINDOWS, but we want to avoid
|
Normally the right way to disable compiling the demo is to set IMGUI_DISABLE_DEMO_WINDOWS, but we want to avoid
|
||||||
implying that the file is required.
|
implying that the file is required.
|
||||||
|
@ -1952,7 +1952,7 @@ enum ImGuiTabItemFlagsPrivate_
|
|||||||
ImGuiTabItemFlags_Button = 1 << 21 // Used by TabItemButton, change the tab item behavior to mimic a button
|
ImGuiTabItemFlags_Button = 1 << 21 // Used by TabItemButton, change the tab item behavior to mimic a button
|
||||||
};
|
};
|
||||||
|
|
||||||
// Storage for one active tab item (sizeof() 28~32 bytes)
|
// Storage for one active tab item (sizeof() 40 bytes)
|
||||||
struct ImGuiTabItem
|
struct ImGuiTabItem
|
||||||
{
|
{
|
||||||
ImGuiID ID;
|
ImGuiID ID;
|
||||||
@ -1962,12 +1962,12 @@ struct ImGuiTabItem
|
|||||||
float Offset; // Position relative to beginning of tab
|
float Offset; // Position relative to beginning of tab
|
||||||
float Width; // Width currently displayed
|
float Width; // Width currently displayed
|
||||||
float ContentWidth; // Width of label, stored during BeginTabItem() call
|
float ContentWidth; // Width of label, stored during BeginTabItem() call
|
||||||
ImS16 NameOffset; // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
|
ImS32 NameOffset; // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
|
||||||
ImS16 BeginOrder; // BeginTabItem() order, used to re-order tabs after toggling ImGuiTabBarFlags_Reorderable
|
ImS16 BeginOrder; // BeginTabItem() order, used to re-order tabs after toggling ImGuiTabBarFlags_Reorderable
|
||||||
ImS16 IndexDuringLayout; // Index only used during TabBarLayout()
|
ImS16 IndexDuringLayout; // Index only used during TabBarLayout()
|
||||||
bool WantClose; // Marked as closed by SetTabItemClosed()
|
bool WantClose; // Marked as closed by SetTabItemClosed()
|
||||||
|
|
||||||
ImGuiTabItem() { memset(this, 0, sizeof(*this)); LastFrameVisible = LastFrameSelected = -1; NameOffset = BeginOrder = IndexDuringLayout = -1; }
|
ImGuiTabItem() { memset(this, 0, sizeof(*this)); LastFrameVisible = LastFrameSelected = -1; NameOffset = -1; BeginOrder = IndexDuringLayout = -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Storage for a tab bar (sizeof() 152 bytes)
|
// Storage for a tab bar (sizeof() 152 bytes)
|
||||||
@ -2009,7 +2009,7 @@ struct ImGuiTabBar
|
|||||||
int GetTabOrder(const ImGuiTabItem* tab) const { return Tabs.index_from_ptr(tab); }
|
int GetTabOrder(const ImGuiTabItem* tab) const { return Tabs.index_from_ptr(tab); }
|
||||||
const char* GetTabName(const ImGuiTabItem* tab) const
|
const char* GetTabName(const ImGuiTabItem* tab) const
|
||||||
{
|
{
|
||||||
IM_ASSERT(tab->NameOffset != -1 && (int)tab->NameOffset < TabsNames.Buf.Size);
|
IM_ASSERT(tab->NameOffset != -1 && tab->NameOffset < TabsNames.Buf.Size);
|
||||||
return TabsNames.Buf.Data + tab->NameOffset;
|
return TabsNames.Buf.Data + tab->NameOffset;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -7765,7 +7765,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|||||||
tab->Flags = flags;
|
tab->Flags = flags;
|
||||||
|
|
||||||
// Append name with zero-terminator
|
// Append name with zero-terminator
|
||||||
tab->NameOffset = (ImS16)tab_bar->TabsNames.size();
|
tab->NameOffset = (ImS32)tab_bar->TabsNames.size();
|
||||||
tab_bar->TabsNames.append(label, label + strlen(label) + 1);
|
tab_bar->TabsNames.append(label, label + strlen(label) + 1);
|
||||||
|
|
||||||
// Update selected tab
|
// Update selected tab
|
||||||
|
Loading…
Reference in New Issue
Block a user