Kaynağa Gözat

Updated ImGui.

Бранимир Караџић 6 yıl önce
ebeveyn
işleme
0243485c53

+ 15 - 6
3rdparty/dear-imgui/imgui.cpp

@@ -1,4 +1,4 @@
-// dear imgui, v1.71 WIP
+// dear imgui, v1.71
 // (main code and documentation)
 // (main code and documentation)
 
 
 // Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
 // Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
@@ -2426,7 +2426,7 @@ void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, cons
 
 
 
 
 // Another overly complex function until we reorganize everything into a nice all-in-one helper.
 // Another overly complex function until we reorganize everything into a nice all-in-one helper.
-// This is made more complex because we have dissociated the layout rectangle (pos_min..pos_max) which define where the ellipsis is, from actual clipping and limit of the ellipsis display.
+// This is made more complex because we have dissociated the layout rectangle (pos_min..pos_max) which define _where_ the ellipsis is, from actual clipping of text and limit of the ellipsis display.
 // This is because in the context of tabs we selectively hide part of the text when the Close Button appears, but we don't want the ellipsis to move. 
 // This is because in the context of tabs we selectively hide part of the text when the Close Button appears, but we don't want the ellipsis to move. 
 void    ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end_full, const ImVec2* text_size_if_known)
 void    ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end_full, const ImVec2* text_size_if_known)
 {
 {
@@ -2437,27 +2437,36 @@ void    ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min,
 
 
     if (text_size.x > pos_max.x - pos_min.x)
     if (text_size.x > pos_max.x - pos_min.x)
     {
     {
+        // Hello wo...
+        // |       |   |
+        // min   max   ellipsis_max
+        //          <-> this is generally some padding value
 
 
+        // FIXME-STYLE: RenderPixelEllipsis() style should use actual font data.
         const ImFont* font = draw_list->_Data->Font;
         const ImFont* font = draw_list->_Data->Font;
         const float font_size = draw_list->_Data->FontSize;
         const float font_size = draw_list->_Data->FontSize;
         const int ellipsis_dot_count = 3;
         const int ellipsis_dot_count = 3;
         const float ellipsis_width = (1.0f + 1.0f) * ellipsis_dot_count - 1.0f;
         const float ellipsis_width = (1.0f + 1.0f) * ellipsis_dot_count - 1.0f;
         const char* text_end_ellipsis = NULL;
         const char* text_end_ellipsis = NULL;
-        float text_size_clipped_x = font->CalcTextSizeA(font_size, (pos_max.x - pos_min.x) - ellipsis_width + 1.0f, 0.0f, text, text_end_full, &text_end_ellipsis).x;
-        if (text == text_end_ellipsis && text_end_ellipsis < text_end_full)    // Always display at least 1 character if there's no room for character + ellipsis
+
+        float text_width = ImMax((pos_max.x - ellipsis_width) - pos_min.x, 1.0f);
+        float text_size_clipped_x = font->CalcTextSizeA(font_size, text_width, 0.0f, text, text_end_full, &text_end_ellipsis).x;
+        if (text == text_end_ellipsis && text_end_ellipsis < text_end_full)
         {
         {
+            // Always display at least 1 character if there's no room for character + ellipsis
             text_end_ellipsis = text + ImTextCountUtf8BytesFromChar(text, text_end_full);
             text_end_ellipsis = text + ImTextCountUtf8BytesFromChar(text, text_end_full);
             text_size_clipped_x = font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text, text_end_ellipsis).x;
             text_size_clipped_x = font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text, text_end_ellipsis).x;
         }
         }
-        while (text_end_ellipsis > text && ImCharIsBlankA(text_end_ellipsis[-1])) // Trim trailing space
+        while (text_end_ellipsis > text && ImCharIsBlankA(text_end_ellipsis[-1]))
         {
         {
+            // Trim trailing space before ellipsis
             text_end_ellipsis--;
             text_end_ellipsis--;
             text_size_clipped_x -= font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text_end_ellipsis, text_end_ellipsis + 1).x; // Ascii blanks are always 1 byte
             text_size_clipped_x -= font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text_end_ellipsis, text_end_ellipsis + 1).x; // Ascii blanks are always 1 byte
         }
         }
         RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), text, text_end_ellipsis, &text_size, ImVec2(0.0f, 0.0f));
         RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), text, text_end_ellipsis, &text_size, ImVec2(0.0f, 0.0f));
 
 
         const float ellipsis_x = pos_min.x + text_size_clipped_x + 1.0f;
         const float ellipsis_x = pos_min.x + text_size_clipped_x + 1.0f;
-        if (ellipsis_x + ellipsis_width <= ellipsis_max_x)
+        if (ellipsis_x + ellipsis_width - 1.0f <= ellipsis_max_x)
             RenderPixelEllipsis(draw_list, ImVec2(ellipsis_x, pos_min.y), GetColorU32(ImGuiCol_Text), ellipsis_dot_count);
             RenderPixelEllipsis(draw_list, ImVec2(ellipsis_x, pos_min.y), GetColorU32(ImGuiCol_Text), ellipsis_dot_count);
     }
     }
     else
     else

+ 5 - 4
3rdparty/dear-imgui/imgui.h

@@ -1,4 +1,4 @@
-// dear imgui, v1.71 WIP
+// dear imgui, v1.71
 // (headers)
 // (headers)
 
 
 // See imgui.cpp file for documentation.
 // See imgui.cpp file for documentation.
@@ -46,12 +46,13 @@ Index of this file:
 
 
 // Version
 // Version
 // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
 // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
-#define IMGUI_VERSION               "1.71 WIP"
-#define IMGUI_VERSION_NUM           17003
+#define IMGUI_VERSION               "1.71"
+#define IMGUI_VERSION_NUM           17100
 #define IMGUI_CHECKVERSION()        ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
 #define IMGUI_CHECKVERSION()        ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
 
 
 // Define attributes of all API symbols declarations (e.g. for DLL under Windows)
 // Define attributes of all API symbols declarations (e.g. for DLL under Windows)
 // IMGUI_API is used for core imgui functions, IMGUI_IMPL_API is used for the default bindings files (imgui_impl_xxx.h)
 // IMGUI_API is used for core imgui functions, IMGUI_IMPL_API is used for the default bindings files (imgui_impl_xxx.h)
+// Using dear imgui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
 #ifndef IMGUI_API
 #ifndef IMGUI_API
 #define IMGUI_API
 #define IMGUI_API
 #endif
 #endif
@@ -1535,7 +1536,7 @@ struct ImGuiPayload
 #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
 #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
 namespace ImGui
 namespace ImGui
 {
 {
-    // OBSOLETED in 1.71 (from May 2019)
+    // OBSOLETED in 1.71 (from June 2019)
     static inline void SetNextTreeNodeOpen(bool open, ImGuiCond cond = 0)   { SetNextItemOpen(open, cond); }
     static inline void SetNextTreeNodeOpen(bool open, ImGuiCond cond = 0)   { SetNextItemOpen(open, cond); }
     // OBSOLETED in 1.70 (from May 2019)
     // OBSOLETED in 1.70 (from May 2019)
     static inline float GetContentRegionAvailWidth()          { return GetContentRegionAvail().x; }
     static inline float GetContentRegionAvailWidth()          { return GetContentRegionAvail().x; }

+ 1 - 1
3rdparty/dear-imgui/imgui_demo.cpp

@@ -1,4 +1,4 @@
-// dear imgui, v1.71 WIP
+// dear imgui, v1.71
 // (demo code)
 // (demo code)
 
 
 // Message to the person tempted to delete this file when integrating Dear ImGui into their code base:
 // Message to the person tempted to delete this file when integrating Dear ImGui into their code base:

+ 1 - 1
3rdparty/dear-imgui/imgui_draw.cpp

@@ -1,4 +1,4 @@
-// dear imgui, v1.71 WIP
+// dear imgui, v1.71
 // (drawing and font code)
 // (drawing and font code)
 
 
 /*
 /*

+ 1 - 1
3rdparty/dear-imgui/imgui_internal.h

@@ -1,4 +1,4 @@
-// dear imgui, v1.71 WIP
+// dear imgui, v1.71
 // (internal structures/api)
 // (internal structures/api)
 
 
 // You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
 // You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!

+ 2 - 2
3rdparty/dear-imgui/imgui_widgets.cpp

@@ -1,4 +1,4 @@
-// dear imgui, v1.71 WIP
+// dear imgui, v1.71
 // (widgets code)
 // (widgets code)
 
 
 /*
 /*
@@ -7092,7 +7092,7 @@ bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
         text_pixel_clip_bb.Max.x -= close_button_sz;
         text_pixel_clip_bb.Max.x -= close_button_sz;
     }
     }
 
 
-    float ellipsis_max_x = close_button_visible ? -FLT_MAX : bb.Max.x;
+    float ellipsis_max_x = close_button_visible ? text_pixel_clip_bb.Max.x : bb.Max.x - 1.0f;
     RenderTextEllipsis(draw_list, text_ellipsis_clip_bb.Min, text_ellipsis_clip_bb.Max, text_pixel_clip_bb.Max.x, ellipsis_max_x, label, NULL, &label_size);
     RenderTextEllipsis(draw_list, text_ellipsis_clip_bb.Min, text_ellipsis_clip_bb.Max, text_pixel_clip_bb.Max.x, ellipsis_max_x, label, NULL, &label_size);
 
 
     return close_button_pressed;
     return close_button_pressed;