Merge branch 'master' into docking

# Conflicts:
#	imgui.cpp
#	imgui_demo.cpp
#	imgui_widgets.cpp
This commit is contained in:
omar 2018-12-11 19:46:46 +01:00
commit 991b16cc6a
5 changed files with 208 additions and 169 deletions

View File

@ -68,12 +68,15 @@ Other Changes:
(It does not provide the docking/splitting/merging of windows available in the Docking branch) (It does not provide the docking/splitting/merging of windows available in the Docking branch)
- Added ImGuiWindowFlags_UnsavedDocument window flag to append '*' to title without altering - Added ImGuiWindowFlags_UnsavedDocument window flag to append '*' to title without altering
the ID, as a convenience to avoid using the ### operator. the ID, as a convenience to avoid using the ### operator.
- Resizing windows from edge is now enabled by default (io.ConfigWindowsResizeFromEdges=true). Note that - Window: Contents size is preserved while a window collapsed. Fix auto-resizing window losing their size for one frame when uncollapsed.
- Window: Contents size is preserved while a window contents is hidden (unless it is hidden for resizing purpose).
- Window: Resizing windows from edge is now enabled by default (io.ConfigWindowsResizeFromEdges=true). Note that
it only works _if_ the back-end sets ImGuiBackendFlags_HasMouseCursors, which the standard back-end do. it only works _if_ the back-end sets ImGuiBackendFlags_HasMouseCursors, which the standard back-end do.
- Added io.ConfigWindowsMoveFromTitleBarOnly option. Still is ignored by window with no title bars (often popups). - Window: Added io.ConfigWindowsMoveFromTitleBarOnly option. Still is ignored by window with no title bars (often popups).
This affects clamping window within the visible area: with this option enabled title bars need to be visible. (#899) This affects clamping window within the visible area: with this option enabled title bars need to be visible. (#899)
- Style: Tweaked default value of style.DisplayWindowPadding from (20,20) to (19,19) so the default style as a value - Style: Tweaked default value of style.DisplayWindowPadding from (20,20) to (19,19) so the default style as a value
which is the same as the title bar height. which is the same as the title bar height.
- Demo: "Simple Layout" and "Style Editor" are now using tabs.
- Examples: DirectX10/11/12: Made imgui_impl_dx10/dx11/dx12.cpp link d3dcompiler.lib from the .cpp file - Examples: DirectX10/11/12: Made imgui_impl_dx10/dx11/dx12.cpp link d3dcompiler.lib from the .cpp file
to ease integration. to ease integration.

View File

@ -4650,6 +4650,8 @@ static ImVec2 CalcSizeAfterConstraint(ImGuiWindow* window, ImVec2 new_size)
static ImVec2 CalcSizeContents(ImGuiWindow* window) static ImVec2 CalcSizeContents(ImGuiWindow* window)
{ {
if (window->Collapsed)
return window->SizeContents;
if (window->Hidden && window->HiddenFramesForResize == 0 && window->HiddenFramesRegular > 0) if (window->Hidden && window->HiddenFramesForResize == 0 && window->HiddenFramesRegular > 0)
return window->SizeContents; return window->SizeContents;

View File

@ -548,7 +548,7 @@ namespace ImGui
// [BETA API] API may evolve! // [BETA API] API may evolve!
// Note: Tabs are automatically created by the docking system. Use this to create tab bars/tabs yourself without docking being involved. // Note: Tabs are automatically created by the docking system. Use this to create tab bars/tabs yourself without docking being involved.
IMGUI_API bool BeginTabBar(const char* str_id, ImGuiTabBarFlags flags = 0); // create and append into a TabBar IMGUI_API bool BeginTabBar(const char* str_id, ImGuiTabBarFlags flags = 0); // create and append into a TabBar
IMGUI_API void EndTabBar(); IMGUI_API void EndTabBar(); // only call EndTabBar() if BeginTabBar() returns true!
IMGUI_API bool BeginTabItem(const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0);// create a Tab. Returns true if the Tab is selected. IMGUI_API bool BeginTabItem(const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0);// create a Tab. Returns true if the Tab is selected.
IMGUI_API void EndTabItem(); // only call EndTabItem() if BeginTabItem() returns true! IMGUI_API void EndTabItem(); // only call EndTabItem() if BeginTabItem() returns true!
IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name. IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name.

View File

@ -2578,7 +2578,11 @@ static void ShowDemoWindowMisc()
void ImGui::ShowAboutWindow(bool* p_open) void ImGui::ShowAboutWindow(bool* p_open)
{ {
ImGui::Begin("About Dear ImGui", p_open, ImGuiWindowFlags_AlwaysAutoResize); if (!ImGui::Begin("About Dear ImGui", p_open, ImGuiWindowFlags_AlwaysAutoResize))
{
ImGui::End();
return;
}
ImGui::Text("Dear ImGui %s", ImGui::GetVersion()); ImGui::Text("Dear ImGui %s", ImGui::GetVersion());
ImGui::Separator(); ImGui::Separator();
ImGui::Text("By Omar Cornut and all dear imgui contributors."); ImGui::Text("By Omar Cornut and all dear imgui contributors.");
@ -2792,20 +2796,13 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
ImGui::SameLine(); ImGui::SameLine();
ShowHelpMarker("Save/Revert in local non-persistent storage. Default Colors definition are not affected. Use \"Export Colors\" below to save them somewhere."); ShowHelpMarker("Save/Revert in local non-persistent storage. Default Colors definition are not affected. Use \"Export Colors\" below to save them somewhere.");
if (ImGui::TreeNode("Rendering")) ImGui::Separator();
{
ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines); ImGui::SameLine(); ShowHelpMarker("When disabling anti-aliasing lines, you'll probably want to disable borders in your style as well.");
ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill);
ImGui::PushItemWidth(100);
ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, "%.2f", 2.0f);
if (style.CurveTessellationTol < 0.10f) style.CurveTessellationTol = 0.10f;
ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero.
ImGui::PopItemWidth();
ImGui::TreePop();
}
if (ImGui::TreeNode("Settings")) if (ImGui::BeginTabBar("##tabs", ImGuiTabBarFlags_None))
{ {
if (ImGui::BeginTabItem("Sizes"))
{
ImGui::Text("Main");
ImGui::SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f"); ImGui::SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f");
ImGui::SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 16.0f, "%.0f"); ImGui::SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 16.0f, "%.0f");
ImGui::SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f"); ImGui::SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f");
@ -2815,7 +2812,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f"); ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f");
ImGui::SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f"); ImGui::SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f");
ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f"); ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f");
ImGui::Text("BorderSize"); ImGui::Text("Borders");
ImGui::SliderFloat("WindowBorderSize", &style.WindowBorderSize, 0.0f, 1.0f, "%.0f"); ImGui::SliderFloat("WindowBorderSize", &style.WindowBorderSize, 0.0f, 1.0f, "%.0f");
ImGui::SliderFloat("ChildBorderSize", &style.ChildBorderSize, 0.0f, 1.0f, "%.0f"); ImGui::SliderFloat("ChildBorderSize", &style.ChildBorderSize, 0.0f, 1.0f, "%.0f");
ImGui::SliderFloat("PopupBorderSize", &style.PopupBorderSize, 0.0f, 1.0f, "%.0f"); ImGui::SliderFloat("PopupBorderSize", &style.PopupBorderSize, 0.0f, 1.0f, "%.0f");
@ -2833,10 +2830,10 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
ImGui::SliderFloat2("ButtonTextAlign", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f"); ImGui::SameLine(); ShowHelpMarker("Alignment applies when a button is larger than its text content."); ImGui::SliderFloat2("ButtonTextAlign", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f"); ImGui::SameLine(); ShowHelpMarker("Alignment applies when a button is larger than its text content.");
ImGui::Text("Safe Area Padding"); ImGui::SameLine(); ShowHelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured)."); ImGui::Text("Safe Area Padding"); ImGui::SameLine(); ShowHelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).");
ImGui::SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f"); ImGui::SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f");
ImGui::TreePop(); ImGui::EndTabItem();
} }
if (ImGui::TreeNode("Colors")) if (ImGui::BeginTabItem("Colors"))
{ {
static int output_dest = 0; static int output_dest = 0;
static bool output_only_modified = true; static bool output_only_modified = true;
@ -2852,24 +2849,23 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
const ImVec4& col = style.Colors[i]; const ImVec4& col = style.Colors[i];
const char* name = ImGui::GetStyleColorName(i); const char* name = ImGui::GetStyleColorName(i);
if (!output_only_modified || memcmp(&col, &ref->Colors[i], sizeof(ImVec4)) != 0) if (!output_only_modified || memcmp(&col, &ref->Colors[i], sizeof(ImVec4)) != 0)
ImGui::LogText("colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 23-(int)strlen(name), "", col.x, col.y, col.z, col.w); ImGui::LogText("colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 23 - (int)strlen(name), "", col.x, col.y, col.z, col.w);
} }
ImGui::LogFinish(); ImGui::LogFinish();
} }
ImGui::SameLine(); ImGui::PushItemWidth(120); ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0"); ImGui::PopItemWidth(); ImGui::SameLine(); ImGui::PushItemWidth(120); ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0"); ImGui::PopItemWidth();
ImGui::SameLine(); ImGui::Checkbox("Only Modified Colors", &output_only_modified); ImGui::SameLine(); ImGui::Checkbox("Only Modified Colors", &output_only_modified);
ImGui::Text("Tip: Left-click on colored square to open color picker,\nRight-click to open edit options menu.");
static ImGuiTextFilter filter; static ImGuiTextFilter filter;
filter.Draw("Filter colors", 200); filter.Draw("Filter colors", ImGui::GetFontSize() * 16);
static ImGuiColorEditFlags alpha_flags = 0; static ImGuiColorEditFlags alpha_flags = 0;
ImGui::RadioButton("Opaque", &alpha_flags, 0); ImGui::SameLine(); ImGui::RadioButton("Opaque", &alpha_flags, 0); ImGui::SameLine();
ImGui::RadioButton("Alpha", &alpha_flags, ImGuiColorEditFlags_AlphaPreview); ImGui::SameLine(); ImGui::RadioButton("Alpha", &alpha_flags, ImGuiColorEditFlags_AlphaPreview); ImGui::SameLine();
ImGui::RadioButton("Both", &alpha_flags, ImGuiColorEditFlags_AlphaPreviewHalf); ImGui::RadioButton("Both", &alpha_flags, ImGuiColorEditFlags_AlphaPreviewHalf); ImGui::SameLine();
ShowHelpMarker("In the color list:\nLeft-click on colored square to open color picker,\nRight-click to open edit options menu.");
ImGui::BeginChild("#colors", ImVec2(0, 300), true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened); ImGui::BeginChild("##colors", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened);
ImGui::PushItemWidth(-160); ImGui::PushItemWidth(-160);
for (int i = 0; i < ImGuiCol_COUNT; i++) for (int i = 0; i < ImGuiCol_COUNT; i++)
{ {
@ -2892,24 +2888,19 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
ImGui::PopItemWidth(); ImGui::PopItemWidth();
ImGui::EndChild(); ImGui::EndChild();
ImGui::TreePop(); ImGui::EndTabItem();
} }
bool fonts_opened = ImGui::TreeNode("Fonts", "Fonts (%d)", ImGui::GetIO().Fonts->Fonts.Size); if (ImGui::BeginTabItem("Fonts"))
if (fonts_opened)
{ {
ImFontAtlas* atlas = ImGui::GetIO().Fonts; ImFontAtlas* atlas = ImGui::GetIO().Fonts;
if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight)) ShowHelpMarker("Read FAQ and misc/fonts/README.txt for details on font loading.");
{ ImGui::PushItemWidth(120);
ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0,0), ImVec2(1,1), ImColor(255,255,255,255), ImColor(255,255,255,128));
ImGui::TreePop();
}
ImGui::PushItemWidth(100);
for (int i = 0; i < atlas->Fonts.Size; i++) for (int i = 0; i < atlas->Fonts.Size; i++)
{ {
ImFont* font = atlas->Fonts[i]; ImFont* font = atlas->Fonts[i];
ImGui::PushID(font); ImGui::PushID(font);
bool font_details_opened = ImGui::TreeNode(font, "Font %d: \'%s\', %.2f px, %d glyphs", i, font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size); bool font_details_opened = ImGui::TreeNode(font, "Font %d: \"%s\"\n%.2f px, %d glyphs, %d file(s)", i, font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount);
ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) ImGui::GetIO().FontDefault = font; ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) ImGui::GetIO().FontDefault = font;
if (font_details_opened) if (font_details_opened)
{ {
@ -2933,7 +2924,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
int count = 0; int count = 0;
for (int n = 0; n < 256; n++) for (int n = 0; n < 256; n++)
count += font->FindGlyphNoFallback((ImWchar)(base + n)) ? 1 : 0; count += font->FindGlyphNoFallback((ImWchar)(base + n)) ? 1 : 0;
if (count > 0 && ImGui::TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base+255, count, count > 1 ? "glyphs" : "glyph")) if (count > 0 && ImGui::TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph"))
{ {
float cell_size = font->FontSize * 1; float cell_size = font->FontSize * 1;
float cell_spacing = style.ItemSpacing.y; float cell_spacing = style.ItemSpacing.y;
@ -2943,14 +2934,14 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
{ {
ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing)); ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing));
ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size); ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base+n)); const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n));
draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255,255,255,100) : IM_COL32(255,255,255,50)); draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
if (glyph) if (glyph)
font->RenderChar(draw_list, cell_size, cell_p1, ImGui::GetColorU32(ImGuiCol_Text), (ImWchar)(base+n)); // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions available to generate a string. font->RenderChar(draw_list, cell_size, cell_p1, ImGui::GetColorU32(ImGuiCol_Text), (ImWchar)(base + n)); // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions available to generate a string.
if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2)) if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2))
{ {
ImGui::BeginTooltip(); ImGui::BeginTooltip();
ImGui::Text("Codepoint: U+%04X", base+n); ImGui::Text("Codepoint: U+%04X", base + n);
ImGui::Separator(); ImGui::Separator();
ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX); ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX);
ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1); ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1);
@ -2968,12 +2959,35 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
} }
ImGui::PopID(); ImGui::PopID();
} }
if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
{
ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0, 0), ImVec2(1, 1), ImColor(255, 255, 255, 255), ImColor(255, 255, 255, 128));
ImGui::TreePop();
}
static float window_scale = 1.0f; static float window_scale = 1.0f;
ImGui::DragFloat("this window scale", &window_scale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale only this window if (ImGui::DragFloat("this window scale", &window_scale, 0.005f, 0.3f, 2.0f, "%.1f")) // scale only this window
ImGui::SetWindowFontScale(window_scale);
ImGui::DragFloat("global scale", &ImGui::GetIO().FontGlobalScale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale everything ImGui::DragFloat("global scale", &ImGui::GetIO().FontGlobalScale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale everything
ImGui::PopItemWidth(); ImGui::PopItemWidth();
ImGui::SetWindowFontScale(window_scale);
ImGui::TreePop(); ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Rendering"))
{
ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines); ImGui::SameLine(); ShowHelpMarker("When disabling anti-aliasing lines, you'll probably want to disable borders in your style as well.");
ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill);
ImGui::PushItemWidth(100);
ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, "%.2f", 2.0f);
if (style.CurveTessellationTol < 0.10f) style.CurveTessellationTol = 0.10f;
ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero.
ImGui::PopItemWidth();
ImGui::EndTabItem();
}
ImGui::EndTabBar();
} }
ImGui::PopItemWidth(); ImGui::PopItemWidth();
@ -3513,7 +3527,20 @@ static void ShowExampleAppLayout(bool* p_open)
ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us
ImGui::Text("MyObject: %d", selected); ImGui::Text("MyObject: %d", selected);
ImGui::Separator(); ImGui::Separator();
if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None))
{
if (ImGui::BeginTabItem("Description"))
{
ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "); ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ");
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Details"))
{
ImGui::Text("ID: 0123456789");
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
ImGui::EndChild(); ImGui::EndChild();
if (ImGui::Button("Revert")) {} if (ImGui::Button("Revert")) {}
ImGui::SameLine(); ImGui::SameLine();
@ -4090,7 +4117,11 @@ void ShowExampleAppDocuments(bool* p_open)
{ {
static ExampleAppDocuments app; static ExampleAppDocuments app;
ImGui::Begin("Examples: Documents", p_open, ImGuiWindowFlags_MenuBar); if (!ImGui::Begin("Examples: Documents", p_open, ImGuiWindowFlags_MenuBar))
{
ImGui::End();
return;
}
// Options // Options
enum Target enum Target

View File

@ -6329,7 +6329,10 @@ bool ImGui::BeginTabItem(const char* label, bool* p_open, ImGuiTabItemFlags f
ImGuiTabBar* tab_bar = g.CurrentTabBar.back(); ImGuiTabBar* tab_bar = g.CurrentTabBar.back();
bool ret = TabItemEx(tab_bar, label, p_open, flags, NULL); bool ret = TabItemEx(tab_bar, label, p_open, flags, NULL);
if (ret && !(flags & ImGuiTabItemFlags_NoPushId)) if (ret && !(flags & ImGuiTabItemFlags_NoPushId))
PushID(tab_bar->Tabs[tab_bar->LastTabItemIdx].ID); {
ImGuiTabItem* tab = &tab_bar->Tabs[tab_bar->LastTabItemIdx];
g.CurrentWindow->IDStack.push_back(tab->ID); // We already hashed 'label' so push into the ID stack directly instead of doing another hash through PushID(label)
}
return ret; return ret;
} }
@ -6343,7 +6346,7 @@ void ImGui::EndTabItem()
ImGuiTabBar* tab_bar = g.CurrentTabBar.back(); ImGuiTabBar* tab_bar = g.CurrentTabBar.back();
ImGuiTabItem* tab = &tab_bar->Tabs[tab_bar->LastTabItemIdx]; ImGuiTabItem* tab = &tab_bar->Tabs[tab_bar->LastTabItemIdx];
if (!(tab->Flags & ImGuiTabItemFlags_NoPushId)) if (!(tab->Flags & ImGuiTabItemFlags_NoPushId))
PopID(); g.CurrentWindow->IDStack.pop_back();
} }
bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags, ImGuiWindow* docked_window) bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags, ImGuiWindow* docked_window)