From fa0dbec8562dcf845a8f836202768158c1f6ec66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 8 Jun 2016 09:57:52 -0700 Subject: [PATCH] Updated ImGui. --- 3rdparty/ocornut-imgui/imgui.cpp | 2 +- 3rdparty/ocornut-imgui/imgui.h | 2 +- 3rdparty/ocornut-imgui/imgui_demo.cpp | 30 ++++++++++++++++++++++++++- 3rdparty/ocornut-imgui/imgui_draw.cpp | 16 +++++++------- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/3rdparty/ocornut-imgui/imgui.cpp b/3rdparty/ocornut-imgui/imgui.cpp index 3b1f1271e..6ae5c7986 100644 --- a/3rdparty/ocornut-imgui/imgui.cpp +++ b/3rdparty/ocornut-imgui/imgui.cpp @@ -620,8 +620,8 @@ #endif #ifdef _MSC_VER -#pragma warning (disable: 4201) // nonstandard extension used: nameless struct/union #pragma warning (disable: 4127) // condition expression is constant +#pragma warning (disable: 4201) // nonstandard extension used: nameless struct/union #pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff) #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen #endif diff --git a/3rdparty/ocornut-imgui/imgui.h b/3rdparty/ocornut-imgui/imgui.h index 32abcd866..97411beb2 100644 --- a/3rdparty/ocornut-imgui/imgui.h +++ b/3rdparty/ocornut-imgui/imgui.h @@ -1361,7 +1361,7 @@ struct ImFont ImVec2 DisplayOffset; // = (0.f,1.f) // Offset font rendering by xx pixels ImVector Glyphs; // // All glyphs. ImVector IndexXAdvance; // // Sparse. Glyphs->XAdvance in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI). - ImVector IndexLookup; // // Sparse. Index glyphs by Unicode code-point. + ImVector IndexLookup; // // Sparse. Index glyphs by Unicode code-point. const Glyph* FallbackGlyph; // == FindGlyph(FontFallbackChar) float FallbackXAdvance; // == FallbackGlyph->XAdvance ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar() diff --git a/3rdparty/ocornut-imgui/imgui_demo.cpp b/3rdparty/ocornut-imgui/imgui_demo.cpp index e7487f6bb..752cd42b6 100644 --- a/3rdparty/ocornut-imgui/imgui_demo.cpp +++ b/3rdparty/ocornut-imgui/imgui_demo.cpp @@ -442,6 +442,19 @@ void ImGui::ShowTestWindow(bool* p_open) ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes"); ImGui::TreePop(); } + if (ImGui::TreeNode("In columns")) + { + ImGui::Columns(3, NULL, false); + static bool selected[16] = { 0 }; + for (int i = 0; i < 16; i++) + { + char label[32]; sprintf(label, "Item %d", i); + if (ImGui::Selectable(label, &selected[i])) {} + ImGui::NextColumn(); + } + ImGui::Columns(1); + ImGui::TreePop(); + } if (ImGui::TreeNode("Grid")) { static bool selected[16] = { true, false, false, false, false, true, false, false, false, false, true, false, false, false, false, true }; @@ -1312,7 +1325,22 @@ void ImGui::ShowTestWindow(bool* p_open) // Basic columns if (ImGui::TreeNode("Basic")) { - ImGui::Columns(4, "mycolumns"); + ImGui::Text("Without border:"); + ImGui::Columns(3, "mycolumns3", false); // 3-ways, no border + ImGui::Separator(); + for (int n = 0; n < 14; n++) + { + char label[32]; + sprintf(label, "Item %d", n); + if (ImGui::Selectable(label)) {} + //if (ImGui::Button(label, ImVec2(-1,0))) {} + ImGui::NextColumn(); + } + ImGui::Columns(1); + ImGui::Separator(); + + ImGui::Text("With border:"); + ImGui::Columns(4, "mycolumns"); // 4-ways, with border ImGui::Separator(); ImGui::Text("ID"); ImGui::NextColumn(); ImGui::Text("Name"); ImGui::NextColumn(); diff --git a/3rdparty/ocornut-imgui/imgui_draw.cpp b/3rdparty/ocornut-imgui/imgui_draw.cpp index acb50f7f5..1ae0b330a 100644 --- a/3rdparty/ocornut-imgui/imgui_draw.cpp +++ b/3rdparty/ocornut-imgui/imgui_draw.cpp @@ -1697,7 +1697,7 @@ void ImFont::BuildLookupTable() for (int i = 0; i != Glyphs.Size; i++) max_codepoint = ImMax(max_codepoint, (int)Glyphs[i].Codepoint); - IM_ASSERT(Glyphs.Size < 32*1024); + IM_ASSERT(Glyphs.Size < 0xFFFF); // -1 is reserved IndexXAdvance.clear(); IndexLookup.clear(); GrowIndex(max_codepoint + 1); @@ -1705,7 +1705,7 @@ void ImFont::BuildLookupTable() { int codepoint = (int)Glyphs[i].Codepoint; IndexXAdvance[codepoint] = Glyphs[i].XAdvance; - IndexLookup[codepoint] = (short)i; + IndexLookup[codepoint] = (unsigned short)i; } // Create a glyph to handle TAB @@ -1719,7 +1719,7 @@ void ImFont::BuildLookupTable() tab_glyph.Codepoint = '\t'; tab_glyph.XAdvance *= 4; IndexXAdvance[(int)tab_glyph.Codepoint] = (float)tab_glyph.XAdvance; - IndexLookup[(int)tab_glyph.Codepoint] = (short)(Glyphs.Size-1); + IndexLookup[(int)tab_glyph.Codepoint] = (unsigned short)(Glyphs.Size-1); } FallbackGlyph = NULL; @@ -1747,7 +1747,7 @@ void ImFont::GrowIndex(int new_size) for (int i = old_size; i < new_size; i++) { IndexXAdvance[i] = -1.0f; - IndexLookup[i] = (short)-1; + IndexLookup[i] = (unsigned short)-1; } } @@ -1756,13 +1756,13 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst) IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function. int index_size = IndexLookup.Size; - if (dst < index_size && IndexLookup.Data[dst] == -1 && !overwrite_dst) // 'dst' already exists + if (dst < index_size && IndexLookup.Data[dst] == (unsigned short)-1 && !overwrite_dst) // 'dst' already exists return; if (src >= index_size && dst >= index_size) // both 'dst' and 'src' don't exist -> no-op return; GrowIndex(dst + 1); - IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : -1; + IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : (unsigned short)-1; IndexXAdvance[dst] = (src < index_size) ? IndexXAdvance.Data[src] : 1.0f; } @@ -1770,8 +1770,8 @@ const ImFont::Glyph* ImFont::FindGlyph(unsigned short c) const { if (c < IndexLookup.Size) { - const short i = IndexLookup[c]; - if (i != -1) + const unsigned short i = IndexLookup[c]; + if (i != (unsigned short)-1) return &Glyphs.Data[i]; } return FallbackGlyph;