Przeglądaj źródła

Updated imgui to v1.33

Thomas Buck 9 lat temu
rodzic
commit
6f206c9af0
3 zmienionych plików z 250 dodań i 148 usunięć
  1. 3
    0
      ChangeLog.md
  2. 227
    128
      src/deps/imgui/imgui.cpp
  3. 20
    20
      src/deps/imgui/imgui.h

+ 3
- 0
ChangeLog.md Wyświetl plik

@@ -2,6 +2,9 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20140222 ]
6
+    * Updated imgui to version 1.33
7
+
5 8
     [ 20140219 ]
6 9
     * Started implementing ability to render into textures (mainly for debugging)
7 10
     * Started implementing camera movement room tracking

+ 227
- 128
src/deps/imgui/imgui.cpp Wyświetl plik

@@ -1,4 +1,4 @@
1
-// ImGui library v1.32
1
+// ImGui library v1.33
2 2
 // See ImGui::ShowTestWindow() for sample code.
3 3
 // Read 'Programmer guide' below for notes on how to setup ImGui in your codebase.
4 4
 // Get latest version at https://github.com/ocornut/imgui
@@ -269,7 +269,7 @@
269 269
  - columns: declare column set (each column: fixed size, %, fill, distribute default size among fills)
270 270
  - columns: columns header to act as button (~sort op) and allow resize/reorder
271 271
  - columns: user specify columns size
272
- - columns: tree node example actually has a small bug (opening node in right column extends the column different from opening node in left column) 
272
+ - columns: tree node example, removing the last NextColumn() makes a padding difference (it should not)
273 273
  - combo: turn child handling code into pop up helper
274 274
  - combo: contents should extends to fit label if combo widget is small
275 275
  - listbox: multiple selection
@@ -289,12 +289,14 @@
289 289
  - text edit: flag to disable live update of the user buffer. 
290 290
  - text edit: field resize behavior - field could stretch when being edited? hover tooltip shows more text?
291 291
  - text edit: add multi-line text edit
292
+ - tree: reformulate OpenNextNode() into SetNextWindowCollapsed() api
292 293
  - tree: add treenode/treepush int variants? because (void*) cast from int warns on some platforms/settings
293 294
  - settings: write more decent code to allow saving/loading new fields
294 295
  - settings: api for per-tool simple persistent data (bool,int,float) in .ini file
295 296
  ! style: store rounded corners in texture to use 1 quad per corner (filled and wireframe). so rounding have minor cost.
296 297
  - style: checkbox: padding for "active" color should be a multiplier of the 
297 298
  - style: colorbox not always square?
299
+ - text: simple markup language for color change?
298 300
  - log: LogButtons() options for specifying depth and/or hiding depth slider
299 301
  - log: have more control over the log scope (e.g. stop logging when leaving current tree node scope)
300 302
  - log: be able to right-click and log a window or tree-node into tty/file/clipboard / generalized context menu?
@@ -530,8 +532,8 @@ ImGuiStyle::ImGuiStyle()
530 532
     Colors[ImGuiCol_TooltipBg]              = ImVec4(0.05f, 0.05f, 0.10f, 0.90f);
531 533
 }
532 534
 
533
-// Statically allocated font atlas. This is merely a maneuver to keep its definition at the bottom of the .H file.
534
-// Because we cannot new() at this point (before users may define IO.MemAllocFn)
535
+// Statically allocated font atlas. This is merely a maneuver to keep ImFontAtlas definition at the bottom of the .h file (otherwise it'd be inside ImGuiIO)
536
+// Also we wouldn't be able to new() one at this point, before users may define IO.MemAllocFn.
535 537
 static ImFontAtlas GDefaultFontAtlas;
536 538
 
537 539
 ImGuiIO::ImGuiIO()
@@ -563,7 +565,7 @@ ImGuiIO::ImGuiIO()
563 565
 
564 566
 // Pass in translated ASCII characters for text input.
565 567
 // - with glfw you can get those from the callback set in glfwSetCharCallback()
566
-// - on Windows you can get those using ToAscii+keyboard state, or via the VM_CHAR message
568
+// - on Windows you can get those using ToAscii+keyboard state, or via the WM_CHAR message
567 569
 void ImGuiIO::AddInputCharacter(ImWchar c)
568 570
 {
569 571
     const size_t n = ImStrlenW(InputCharacters);
@@ -589,7 +591,7 @@ const float PI = 3.14159265358979323846f;
589 591
 #define IM_INT_MAX 2147483647
590 592
 #endif
591 593
 
592
-// Play it nice with Windows users. Notepad in 2014 still doesn't display text data with Unix-style \n.
594
+// Play it nice with Windows users. Notepad in 2015 still doesn't display text data with Unix-style \n.
593 595
 #ifdef _MSC_VER
594 596
 #define STR_NEWLINE "\r\n"
595 597
 #else
@@ -648,8 +650,7 @@ static char* ImStrdup(const char *str)
648 650
 static size_t ImStrlenW(const ImWchar* str)
649 651
 {
650 652
     size_t n = 0;
651
-    while (*str++)
652
-        n++;
653
+    while (*str++) n++;
653 654
     return n;
654 655
 }
655 656
 
@@ -842,7 +843,7 @@ struct ImGuiStyleMod    // Style modifier, backup of modified data so we can res
842 843
     ImVec2      PreviousValue;
843 844
 };
844 845
 
845
-struct ImGuiAabb    // 2D axis aligned bounding-box
846
+struct ImGuiAabb        // 2D axis aligned bounding-box
846 847
 {
847 848
     ImVec2      Min;
848 849
     ImVec2      Max;
@@ -927,6 +928,7 @@ struct ImGuiDrawContext
927 928
 // Internal state of the currently focused/edited text input box
928 929
 struct ImGuiTextEditState
929 930
 {
931
+    ImGuiID             Id;                             // widget id owning the text state
930 932
     ImWchar             Text[1024];                     // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer.
931 933
     char                InitialText[1024*3+1];          // backup of end-user buffer at the time of focus (in UTF-8, unconverted)
932 934
     size_t              BufSize;                        // end-user buffer size, <= 1024 (or increase above)
@@ -934,7 +936,7 @@ struct ImGuiTextEditState
934 936
     float               ScrollX;
935 937
     STB_TexteditState   StbState;
936 938
     float               CursorAnim;
937
-    ImVec2              LastCursorPos;                  // Cursor position in screen space to be used by IME callback.
939
+    ImVec2              InputCursorScreenPos;           // Cursor position in screen space to be used by IME callback.
938 940
     bool                SelectedAllMouseLock;
939 941
     ImFont*             Font;
940 942
     float               FontSize;
@@ -991,6 +993,7 @@ struct ImGuiState
991 993
     ImGuiID                 ActiveId;
992 994
     ImGuiID                 ActiveIdPreviousFrame;
993 995
     bool                    ActiveIdIsAlive;
996
+    bool                    ActiveIdIsFocusedOnly;              // Set only by active widget. Denote focus but no active interaction.
994 997
     float                   SettingsDirtyTimer;
995 998
     ImVector<ImGuiIniData*> Settings;
996 999
     ImVector<ImGuiColMod>   ColorModifiers;
@@ -1030,6 +1033,10 @@ struct ImGuiState
1030 1033
     ImGuiState()
1031 1034
     {
1032 1035
         Initialized = false;
1036
+        Font = NULL;
1037
+        FontSize = 0.0f;
1038
+        FontTexUvWhitePixel = ImVec2(0.0f, 0.0f);
1039
+
1033 1040
         Time = 0.0f;
1034 1041
         FrameCount = 0;
1035 1042
         FrameCountRendered = -1;
@@ -1037,7 +1044,11 @@ struct ImGuiState
1037 1044
         FocusedWindow = NULL;
1038 1045
         HoveredWindow = NULL;
1039 1046
         HoveredRootWindow = NULL;
1047
+        HoveredId = 0;
1048
+        ActiveId = 0;
1049
+        ActiveIdPreviousFrame = 0;
1040 1050
         ActiveIdIsAlive = false;
1051
+        ActiveIdIsFocusedOnly = false;
1041 1052
         SettingsDirtyTimer = 0.0f;
1042 1053
         SetNextWindowPosVal = ImVec2(0.0f, 0.0f);
1043 1054
         SetNextWindowPosCond = 0;
@@ -1045,15 +1056,21 @@ struct ImGuiState
1045 1056
         SetNextWindowSizeCond = 0;
1046 1057
         SetNextWindowCollapsedVal = false;
1047 1058
         SetNextWindowCollapsedCond = 0;
1059
+
1048 1060
         SliderAsInputTextId = 0;
1049 1061
         ActiveComboID = 0;
1050 1062
         memset(Tooltip, 0, sizeof(Tooltip));
1051 1063
         PrivateClipboard = NULL;
1064
+
1052 1065
         LogEnabled = false;
1053 1066
         LogFile = NULL;
1067
+        LogClipboard = NULL;
1054 1068
         LogStartDepth = 0;
1055 1069
         LogAutoExpandMaxDepth = 2;
1056
-        LogClipboard = NULL;
1070
+
1071
+        memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
1072
+        FramerateSecPerFrameIdx = 0;
1073
+        FramerateSecPerFrameAccum = 0.0f;
1057 1074
     }
1058 1075
 };
1059 1076
 
@@ -1086,6 +1103,7 @@ struct ImGuiWindow
1086 1103
     ImGuiDrawContext        DC;
1087 1104
     ImVector<ImGuiID>       IDStack;
1088 1105
     ImVector<ImVec4>        ClipRectStack;                      // Scissoring / clipping rectangle. x1, y1, x2, y2.
1106
+    ImGuiAabb               ClippedAabb;                        // = ClipRectStack.front() after setup in Begin()
1089 1107
     int                     LastFrameDrawn;
1090 1108
     float                   ItemWidthDefault;
1091 1109
     ImGuiStorage            StateStorage;
@@ -1118,12 +1136,12 @@ public:
1118 1136
     ImVec2      CursorPos() const                       { return DC.CursorPos; }
1119 1137
     float       TitleBarHeight() const                  { return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0 : FontSize() + GImGui->Style.FramePadding.y * 2.0f; }
1120 1138
     ImGuiAabb   TitleBarAabb() const                    { return ImGuiAabb(Pos, Pos + ImVec2(SizeFull.x, TitleBarHeight())); }
1121
-    ImVec2      WindowPadding() const                   { return ((Flags & ImGuiWindowFlags_ChildWindow) && !(Flags & ImGuiWindowFlags_ShowBorders)) ? ImVec2(1,1) : GImGui->Style.WindowPadding; }
1139
+    ImVec2      WindowPadding() const                   { return ((Flags & ImGuiWindowFlags_ChildWindow) && !(Flags & ImGuiWindowFlags_ShowBorders)) ? ImVec2(0,0) : GImGui->Style.WindowPadding; }
1122 1140
     ImU32       Color(ImGuiCol idx, float a=1.f) const  { ImVec4 c = GImGui->Style.Colors[idx]; c.w *= GImGui->Style.Alpha * a; return ImGui::ColorConvertFloat4ToU32(c); }
1123 1141
     ImU32       Color(const ImVec4& col) const          { ImVec4 c = col; c.w *= GImGui->Style.Alpha; return ImGui::ColorConvertFloat4ToU32(c); }
1124 1142
 };
1125 1143
 
1126
-static ImGuiWindow* GetCurrentWindow()
1144
+static inline ImGuiWindow* GetCurrentWindow()
1127 1145
 {
1128 1146
     ImGuiState& g = *GImGui;
1129 1147
     IM_ASSERT(g.CurrentWindow != NULL);    // ImGui::NewFrame() hasn't been called yet?
@@ -1135,6 +1153,7 @@ static void SetActiveId(ImGuiID id)
1135 1153
 {
1136 1154
     ImGuiState& g = *GImGui;
1137 1155
     g.ActiveId = id; 
1156
+    g.ActiveIdIsFocusedOnly = false;
1138 1157
 }
1139 1158
 
1140 1159
 static void RegisterAliveId(const ImGuiID& id)
@@ -1260,23 +1279,28 @@ void ImGuiStorage::SetAllInt(int v)
1260 1279
 //-----------------------------------------------------------------------------
1261 1280
 
1262 1281
 // Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
1263
-ImGuiTextFilter::ImGuiTextFilter()
1282
+ImGuiTextFilter::ImGuiTextFilter(const char* default_filter)
1264 1283
 {
1265
-    InputBuf[0] = 0;
1266
-    CountGrep = 0;
1284
+    if (default_filter)
1285
+    {
1286
+        ImFormatString(InputBuf, IM_ARRAYSIZE(InputBuf), "%s", default_filter);
1287
+        Build();
1288
+    }
1289
+    else
1290
+    {
1291
+        InputBuf[0] = 0;
1292
+        CountGrep = 0;
1293
+    }
1267 1294
 }
1268 1295
 
1269 1296
 void ImGuiTextFilter::Draw(const char* label, float width)
1270 1297
 {
1271 1298
     ImGuiWindow* window = GetCurrentWindow();
1272
-    if (width < 0.0f)
1273
-    {
1274
-        ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true);
1275
-        width = ImMax(window->Pos.x + ImGui::GetContentRegionMax().x - window->DC.CursorPos.x - (label_size.x + GImGui->Style.ItemSpacing.x*4), 10.0f);
1276
-    }
1277
-    ImGui::PushItemWidth(width);
1299
+    if (width > 0.0f)
1300
+        ImGui::PushItemWidth(width);
1278 1301
     ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf));
1279
-    ImGui::PopItemWidth();
1302
+    if (width > 0.0f)
1303
+        ImGui::PopItemWidth();
1280 1304
     Build();
1281 1305
 }
1282 1306
 
@@ -1393,8 +1417,7 @@ ImGuiWindow::ImGuiWindow(const char* name)
1393 1417
 {
1394 1418
     Name = ImStrdup(name);
1395 1419
     ID = GetID(name); 
1396
-    IDStack.push_back(ID);
1397
-
1420
+    Flags = 0;
1398 1421
     PosFloat = Pos = ImVec2(0.0f, 0.0f);
1399 1422
     Size = SizeFull = ImVec2(0.0f, 0.0f);
1400 1423
     SizeContentsFit = ImVec2(0.0f, 0.0f);
@@ -1409,6 +1432,7 @@ ImGuiWindow::ImGuiWindow(const char* name)
1409 1432
     AutoFitOnlyGrows = false;
1410 1433
     SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiSetCondition_Always | ImGuiSetCondition_FirstUseThisSession | ImGuiSetCondition_FirstUseEver;
1411 1434
 
1435
+    IDStack.push_back(ID);
1412 1436
     LastFrameDrawn = -1;
1413 1437
     ItemWidthDefault = 0.0f;
1414 1438
     FontWindowScale = 1.0f;
@@ -1421,6 +1445,7 @@ ImGuiWindow::ImGuiWindow(const char* name)
1421 1445
 
1422 1446
     DrawList = (ImDrawList*)ImGui::MemAlloc(sizeof(ImDrawList));
1423 1447
     new(DrawList) ImDrawList();
1448
+    RootWindow = NULL;
1424 1449
 
1425 1450
     FocusIdxAllCounter = FocusIdxTabCounter = -1;
1426 1451
     FocusIdxAllRequestCurrent = FocusIdxTabRequestCurrent = IM_INT_MAX;
@@ -2309,7 +2334,9 @@ static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs)
2309 2334
             continue;
2310 2335
         if (excluding_childs && (window->Flags & ImGuiWindowFlags_ChildWindow) != 0)
2311 2336
             continue;
2312
-        ImGuiAabb bb(window->Pos - g.Style.TouchExtraPadding, window->Pos + window->Size + g.Style.TouchExtraPadding);
2337
+
2338
+        // Using the clipped AABB so a child window will typically be clipped by its parent.
2339
+        ImGuiAabb bb(window->ClippedAabb.Min - g.Style.TouchExtraPadding, window->ClippedAabb.Max + g.Style.TouchExtraPadding);
2313 2340
         if (bb.Contains(pos))
2314 2341
             return window;
2315 2342
     }
@@ -2432,6 +2459,12 @@ bool ImGui::IsItemActive()
2432 2459
     return false;
2433 2460
 }
2434 2461
 
2462
+bool ImGui::IsAnyItemActive()
2463
+{
2464
+    ImGuiState& g = *GImGui;
2465
+    return g.ActiveId != 0;
2466
+}
2467
+
2435 2468
 ImVec2 ImGui::GetItemBoxMin()
2436 2469
 {
2437 2470
     ImGuiWindow* window = GetCurrentWindow();
@@ -2482,14 +2515,7 @@ void ImGui::EndTooltip()
2482 2515
     ImGui::End();
2483 2516
 }
2484 2517
 
2485
-void ImGui::BeginChild(ImGuiID id, ImVec2 size, bool border, ImGuiWindowFlags extra_flags)
2486
-{
2487
-    char str_id[32];
2488
-    ImFormatString(str_id, IM_ARRAYSIZE(str_id), "child_%x", id);
2489
-    ImGui::BeginChild(str_id, size, border, extra_flags);
2490
-}
2491
-
2492
-void ImGui::BeginChild(const char* str_id, ImVec2 size, bool border, ImGuiWindowFlags extra_flags)
2518
+bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
2493 2519
 {
2494 2520
     ImGuiState& g = *GImGui;
2495 2521
     ImGuiWindow* window = GetCurrentWindow();
@@ -2498,6 +2524,7 @@ void ImGui::BeginChild(const char* str_id, ImVec2 size, bool border, ImGuiWindow
2498 2524
 
2499 2525
     const ImVec2 content_max = window->Pos + ImGui::GetContentRegionMax();
2500 2526
     const ImVec2 cursor_pos = window->Pos + ImGui::GetCursorPos();
2527
+    ImVec2 size = size_arg;
2501 2528
     if (size.x <= 0.0f)
2502 2529
     {
2503 2530
         if (size.x == 0.0f)
@@ -2518,10 +2545,20 @@ void ImGui::BeginChild(const char* str_id, ImVec2 size, bool border, ImGuiWindow
2518 2545
     ImFormatString(title, IM_ARRAYSIZE(title), "%s.%s", window->Name, str_id);
2519 2546
 
2520 2547
     const float alpha = 1.0f;
2521
-    ImGui::Begin(title, NULL, size, alpha, flags);
2548
+    bool ret = ImGui::Begin(title, NULL, size, alpha, flags);
2522 2549
 
2523 2550
     if (!(window->Flags & ImGuiWindowFlags_ShowBorders))
2524 2551
         g.CurrentWindow->Flags &= ~ImGuiWindowFlags_ShowBorders;
2552
+
2553
+    return ret;
2554
+}
2555
+
2556
+bool ImGui::BeginChild(ImGuiID id, const ImVec2& size, bool border, ImGuiWindowFlags extra_flags)
2557
+{
2558
+    char str_id[32];
2559
+    ImFormatString(str_id, IM_ARRAYSIZE(str_id), "child_%x", id);
2560
+    bool ret = ImGui::BeginChild(str_id, size, border, extra_flags);
2561
+    return ret;
2525 2562
 }
2526 2563
 
2527 2564
 void ImGui::EndChild()
@@ -2623,13 +2660,14 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
2623 2660
 }
2624 2661
 
2625 2662
 // Push a new ImGui window to add widgets to. 
2626
-// - A default window called "Debug" is automatically stacked at the beginning of every frame.
2627
-// - This can be called multiple times during the frame with the same window name to append content to the same window.
2663
+// - 'size' for a regular window denote the initial size for first-time creation (no saved data) and isn't that useful. Use SetNextWindowSize() prior to calling Begin() for more flexible window manipulation.
2664
+// - A default window called "Debug" is automatically stacked at the beginning of every frame so you can use widgets without explicitly calling a Begin/End pair.
2665
+// - Begin/End can be called multiple times during the frame with the same window name to append content.
2628 2666
 // - The window name is used as a unique identifier to preserve window information across frames (and save rudimentary information to the .ini file). Note that you can use ## to append unique data that isn't displayed, e.g. "My window##1" will use "My window##1" as unique window ID but display "My window" to the user.
2629 2667
 // - Return false when window is collapsed, so you can early out in your code. You always need to call ImGui::End() even if false is returned.
2630 2668
 // - Passing 'bool* p_opened' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed.
2631 2669
 // - Passing non-zero 'size' is roughly equivalent to calling SetNextWindowSize(size, ImGuiSetCondition_FirstUseEver) prior to calling Begin().
2632
-bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alpha, ImGuiWindowFlags flags)
2670
+bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size, float bg_alpha, ImGuiWindowFlags flags)
2633 2671
 {
2634 2672
     ImGuiState& g = *GImGui;
2635 2673
     const ImGuiStyle& style = g.Style;
@@ -2681,8 +2719,8 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
2681 2719
     window->RootWindow = g.CurrentWindowStack[root_idx];
2682 2720
 
2683 2721
     // Default alpha
2684
-    if (fill_alpha < 0.0f)
2685
-        fill_alpha = style.WindowFillAlphaDefault;
2722
+    if (bg_alpha < 0.0f)
2723
+        bg_alpha = style.WindowFillAlphaDefault;
2686 2724
 
2687 2725
     // When reusing window again multiple times a frame, just append content (don't need to setup again)
2688 2726
     const int current_frame = ImGui::GetFrameCount();
@@ -2888,16 +2926,16 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
2888 2926
             window->ScrollbarY = (window->SizeContentsFit.y > window->Size.y) && !(window->Flags & ImGuiWindowFlags_NoScrollbar);
2889 2927
 
2890 2928
             // Window background
2891
-            if (fill_alpha > 0.0f)
2929
+            if (bg_alpha > 0.0f)
2892 2930
             {
2893 2931
                 if ((window->Flags & ImGuiWindowFlags_ComboBox) != 0)
2894
-                    window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_ComboBg, fill_alpha), window_rounding);
2932
+                    window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_ComboBg, bg_alpha), window_rounding);
2895 2933
                 else if ((window->Flags & ImGuiWindowFlags_Tooltip) != 0)
2896
-                    window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_TooltipBg, fill_alpha), window_rounding);
2934
+                    window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_TooltipBg, bg_alpha), window_rounding);
2897 2935
                 else if ((window->Flags & ImGuiWindowFlags_ChildWindow) != 0)
2898
-                    window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size-ImVec2(window->ScrollbarY?style.ScrollBarWidth:0.0f,0.0f), window->Color(ImGuiCol_ChildWindowBg, fill_alpha), window_rounding, window->ScrollbarY ? (1|8) : (0xF));
2936
+                    window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size-ImVec2(window->ScrollbarY?style.ScrollBarWidth:0.0f,0.0f), window->Color(ImGuiCol_ChildWindowBg, bg_alpha), window_rounding, window->ScrollbarY ? (1|8) : (0xF));
2899 2937
                 else
2900
-                    window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_WindowBg, fill_alpha), window_rounding);
2938
+                    window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_WindowBg, bg_alpha), window_rounding);
2901 2939
             }
2902 2940
 
2903 2941
             // Title bar
@@ -3014,6 +3052,10 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
3014 3052
             const ImVec2 text_max = window->Pos + ImVec2(window->Size.x - (p_opened ? (title_bar_aabb.GetHeight()-3) : style.FramePadding.x), style.FramePadding.y*2 + text_size.y);
3015 3053
             RenderTextClipped(text_min, name, NULL, &text_size, text_max);
3016 3054
         }
3055
+
3056
+        // Save clipped aabb so we can access it in constant-time in FindHoveredWindow()
3057
+        window->ClippedAabb = window->Aabb();
3058
+        window->ClippedAabb.Clip(window->ClipRectStack.front());
3017 3059
     }
3018 3060
 
3019 3061
     // Inner clipping rectangle
@@ -3033,8 +3075,10 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
3033 3075
     if (flags & ImGuiWindowFlags_ChildWindow)
3034 3076
     {
3035 3077
         IM_ASSERT((flags & ImGuiWindowFlags_NoTitleBar) != 0);
3078
+        window->Collapsed = parent_window && parent_window->Collapsed;
3079
+
3036 3080
         const ImVec4 clip_rect_t = window->ClipRectStack.back();
3037
-        window->Collapsed = (clip_rect_t.x >= clip_rect_t.z || clip_rect_t.y >= clip_rect_t.w);
3081
+        window->Collapsed |= (clip_rect_t.x >= clip_rect_t.z || clip_rect_t.y >= clip_rect_t.w);
3038 3082
 
3039 3083
         // We also hide the window from rendering because we've already added its border to the command list.
3040 3084
         // (we could perform the check earlier in the function but it is simpler at this point)
@@ -3417,11 +3461,12 @@ void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiSetCondition cond)
3417 3461
 ImVec2 ImGui::GetContentRegionMax()
3418 3462
 {
3419 3463
     ImGuiWindow* window = GetCurrentWindow();
3420
-    ImVec2 mx = window->Size - window->WindowPadding();
3464
+    ImVec2 window_padding = window->WindowPadding();
3465
+    ImVec2 mx = window->Size - window_padding;
3421 3466
     if (window->DC.ColumnsCount != 1)
3422 3467
     {
3423 3468
         mx.x = ImGui::GetColumnOffset(window->DC.ColumnsCurrent + 1);
3424
-        mx.x -= GImGui->Style.WindowPadding.x;
3469
+        mx.x -= window_padding.x;
3425 3470
     }
3426 3471
     else
3427 3472
     {
@@ -3761,8 +3806,11 @@ static bool IsHovered(const ImGuiAabb& bb, const ImGuiID& id)
3761 3806
     if (g.HoveredId == 0)
3762 3807
     {
3763 3808
         ImGuiWindow* window = GetCurrentWindow();
3764
-        const bool hovered = (g.HoveredRootWindow == window->RootWindow) && (g.ActiveId == 0 || g.ActiveId == id) && IsMouseHoveringBox(bb);
3765
-        return hovered;
3809
+        if (g.HoveredRootWindow == window->RootWindow)
3810
+        {
3811
+            bool hovered = (g.ActiveId == 0 || g.ActiveId == id || g.ActiveIdIsFocusedOnly) && IsMouseHoveringBox(bb);
3812
+            return hovered;
3813
+        }
3766 3814
     }
3767 3815
     return false;
3768 3816
 }
@@ -4486,20 +4534,14 @@ bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, c
4486 4534
         if (g.SliderAsInputTextId == 0)
4487 4535
         {
4488 4536
             // First frame
4489
-            IM_ASSERT(g.ActiveId == id);    // InputText ID should match the Slider ID (else we'd need to store them both which is also possible)
4537
+            IM_ASSERT(g.ActiveId == id);    // InputText ID expected to match the Slider ID (else we'd need to store them both, which is also possible)
4490 4538
             g.SliderAsInputTextId = g.ActiveId;
4491
-            SetActiveId(id);
4492 4539
             g.HoveredId = id;
4493 4540
         }
4494
-        else
4541
+        else if (g.ActiveId != g.SliderAsInputTextId)
4495 4542
         {
4496
-            if (g.ActiveId == g.SliderAsInputTextId)
4497
-                SetActiveId(id);
4498
-            else
4499
-            {
4500
-                SetActiveId(0);
4501
-                g.SliderAsInputTextId = 0;
4502
-            }
4543
+            // Release
4544
+            g.SliderAsInputTextId = 0;
4503 4545
         }
4504 4546
         if (value_changed)
4505 4547
         {
@@ -4594,8 +4636,9 @@ bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, c
4594 4636
 
4595 4637
     // Draw value using user-provided display format so user can add prefix/suffix/decorations to the value.
4596 4638
     char value_buf[64];
4597
-    ImFormatString(value_buf, IM_ARRAYSIZE(value_buf), display_format, *v);
4598
-    RenderText(ImVec2(slider_bb.GetCenter().x-CalcTextSize(value_buf, NULL, true).x*0.5f, frame_bb.Min.y + style.FramePadding.y), value_buf);
4639
+    char* value_buf_end = value_buf + ImFormatString(value_buf, IM_ARRAYSIZE(value_buf), display_format, *v);
4640
+    const ImVec2 value_text_size = CalcTextSize(value_buf, value_buf_end, true);
4641
+    RenderTextClipped(ImVec2(ImMax(frame_bb.Min.x + style.FramePadding.x, slider_bb.GetCenter().x - value_text_size.x*0.5f), frame_bb.Min.y + style.FramePadding.y), value_buf, value_buf_end, &value_text_size, frame_bb.Max);
4599 4642
 
4600 4643
     RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, slider_bb.Min.y), label);
4601 4644
 
@@ -5010,7 +5053,7 @@ static void STB_TEXTEDIT_DELETECHARS(STB_TEXTEDIT_STRING* obj, int pos, int n)
5010 5053
 static bool STB_TEXTEDIT_INSERTCHARS(STB_TEXTEDIT_STRING* obj, int pos, const ImWchar* new_text, int new_text_len)
5011 5054
 {
5012 5055
     const size_t text_len = ImStrlenW(obj->Text);
5013
-    if ((size_t)new_text_len + text_len + 1 >= obj->BufSize)
5056
+    if ((size_t)new_text_len + text_len + 1 > obj->BufSize)
5014 5057
         return false;
5015 5058
 
5016 5059
     if (pos != (int)text_len)
@@ -5311,29 +5354,45 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT
5311 5354
 
5312 5355
     const bool is_ctrl_down = io.KeyCtrl;
5313 5356
     const bool is_shift_down = io.KeyShift;
5314
-    const bool tab_focus_requested = window->FocusItemRegister(g.ActiveId == id, (flags & ImGuiInputTextFlags_CallbackCompletion) == 0);    // Using completion callback disable keyboard tabbing
5315
-    //const bool align_center = (bool)(flags & ImGuiInputTextFlags_AlignCenter);    // FIXME: Unsupported
5357
+    const bool focus_requested = window->FocusItemRegister(g.ActiveId == id, (flags & ImGuiInputTextFlags_CallbackCompletion) == 0);    // Using completion callback disable keyboard tabbing
5358
+    const bool focus_requested_by_code = focus_requested && (window->FocusIdxAllCounter == window->FocusIdxAllRequestCurrent);
5359
+    const bool focus_requested_by_tab = focus_requested && !focus_requested_by_code;
5316 5360
 
5317 5361
     const bool hovered = IsHovered(frame_bb, id);
5318 5362
     if (hovered)
5319 5363
         g.HoveredId = id;
5364
+    const bool user_clicked = hovered && io.MouseClicked[0];
5320 5365
 
5321 5366
     bool select_all = (g.ActiveId != id) && (flags & ImGuiInputTextFlags_AutoSelectAll) != 0;
5322
-    if (tab_focus_requested || (hovered && io.MouseClicked[0]))
5367
+    if (focus_requested || user_clicked)
5323 5368
     {
5324 5369
         if (g.ActiveId != id)
5325 5370
         {
5326 5371
             // Start edition
5327 5372
             // Take a copy of the initial buffer value (both in original UTF-8 format and converted to wchar)
5328 5373
             ImFormatString(edit_state.InitialText, IM_ARRAYSIZE(edit_state.InitialText), "%s", buf);
5329
-            ImTextStrFromUtf8(edit_state.Text, IM_ARRAYSIZE(edit_state.Text), buf, NULL);
5330
-            edit_state.ScrollX = 0.0f;
5374
+            size_t buf_len = ImTextStrFromUtf8(edit_state.Text, IM_ARRAYSIZE(edit_state.Text), buf, NULL);
5331 5375
             edit_state.Width = w;
5332
-            stb_textedit_initialize_state(&edit_state.StbState, true); 
5376
+            edit_state.InputCursorScreenPos = ImVec2(-1.f,-1.f);
5333 5377
             edit_state.CursorAnimReset();
5334
-            edit_state.LastCursorPos = ImVec2(-1.f,-1.f);
5335 5378
 
5336
-            if (tab_focus_requested || is_ctrl_down)
5379
+            if (edit_state.Id != id)
5380
+            {
5381
+                edit_state.Id = id;
5382
+                edit_state.ScrollX = 0.0f;
5383
+                stb_textedit_initialize_state(&edit_state.StbState, true); 
5384
+                if (focus_requested_by_code)
5385
+                    select_all = true;
5386
+            }
5387
+            else
5388
+            {
5389
+                // Recycle existing cursor/selection/undo stack but clamp position
5390
+                // Note a single mouse click will override the cursor/position immediately by calling stb_textedit_click handler.
5391
+                edit_state.StbState.cursor = ImMin(edit_state.StbState.cursor, buf_len);
5392
+                edit_state.StbState.select_start = ImMin(edit_state.StbState.select_start, buf_len);
5393
+                edit_state.StbState.select_end = ImMin(edit_state.StbState.select_end, buf_len);
5394
+            }
5395
+            if (focus_requested_by_tab || (user_clicked && is_ctrl_down))
5337 5396
                 select_all = true;
5338 5397
         }
5339 5398
         SetActiveId(id);
@@ -5348,6 +5407,11 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT
5348 5407
         }
5349 5408
     }
5350 5409
 
5410
+    // Although we are active we don't prevent mouse from hovering other elements unless we are interacting right now with the widget.
5411
+    // Down the line we should have a cleaner concept of focused vs active in the library.
5412
+    if (g.ActiveId == id)
5413
+        g.ActiveIdIsFocusedOnly = !io.MouseDown[0];
5414
+
5351 5415
     bool value_changed = false;
5352 5416
     bool cancel_edit = false;
5353 5417
     bool enter_pressed = false;
@@ -5563,7 +5627,6 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT
5563 5627
         }
5564 5628
     }
5565 5629
 
5566
-    // FIXME: 'align_center' unsupported
5567 5630
     ImGuiTextEditState::RenderTextScrolledClipped(window->Font(), window->FontSize(), buf, frame_bb.Min + style.FramePadding, w, (g.ActiveId == id) ? edit_state.ScrollX : 0.0f);
5568 5631
 
5569 5632
     if (g.ActiveId == id)
@@ -5574,11 +5637,11 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT
5574 5637
         if (g.InputTextState.CursorIsVisible())
5575 5638
             window->DrawList->AddRect(cursor_pos - font_off_up + ImVec2(0,2), cursor_pos + font_off_dn - ImVec2(0,3), window->Color(ImGuiCol_Text));
5576 5639
         
5577
-        // Notify OS of text input position
5578
-        if (io.ImeSetInputScreenPosFn && ImLengthSqr(edit_state.LastCursorPos - cursor_pos) > 0.0001f)
5640
+        // Notify OS of text input position for advanced IME
5641
+        if (io.ImeSetInputScreenPosFn && ImLengthSqr(edit_state.InputCursorScreenPos - cursor_pos) > 0.0001f)
5579 5642
             io.ImeSetInputScreenPosFn((int)cursor_pos.x - 1, (int)(cursor_pos.y - window->FontSize()));   // -1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.
5580 5643
 
5581
-        edit_state.LastCursorPos = cursor_pos;
5644
+        edit_state.InputCursorScreenPos = cursor_pos;
5582 5645
     }
5583 5646
 
5584 5647
     RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
@@ -6148,7 +6211,10 @@ void ImGui::Separator()
6148 6211
     window->DrawList->AddLine(bb.Min, bb.Max, window->Color(ImGuiCol_Border));
6149 6212
 
6150 6213
     if (window->DC.ColumnsCount > 1)
6214
+    {
6151 6215
         PushColumnClipRect();
6216
+        window->DC.ColumnsCellMinY = window->DC.CursorPos.y;
6217
+    }
6152 6218
 }
6153 6219
 
6154 6220
 // A little vertical spacing.
@@ -6206,6 +6272,7 @@ bool ImGui::IsClipped(const ImVec2& item_size)
6206 6272
 
6207 6273
 static bool ItemAdd(const ImGuiAabb& bb, const ImGuiID* id)
6208 6274
 {
6275
+    //ImGuiState& g = *GImGui;
6209 6276
     ImGuiWindow* window = GetCurrentWindow();
6210 6277
     window->DC.LastItemID = id ? *id : 0;
6211 6278
     window->DC.LastItemAabb = bb;
@@ -6214,7 +6281,11 @@ static bool ItemAdd(const ImGuiAabb& bb, const ImGuiID* id)
6214 6281
         window->DC.LastItemHovered = false;
6215 6282
         return false;
6216 6283
     }
6217
-    window->DC.LastItemHovered = IsMouseHoveringBox(bb);     // this is a sensible default but widgets are free to override it after calling ItemAdd()
6284
+
6285
+    // This is a sensible default, but widgets are free to override it after calling ItemAdd()
6286
+    const bool hovered = IsMouseHoveringBox(bb);
6287
+    //const bool hovered = (g.ActiveId == 0 || (id && g.ActiveId == *id) || g.ActiveIdIsFocusedOnly) && IsMouseHoveringBox(bb);  // matching the behaviour of IsHovered(), not always what the user wants?
6288
+    window->DC.LastItemHovered = hovered;
6218 6289
     return true;
6219 6290
 }
6220 6291
 
@@ -6289,7 +6360,10 @@ float ImGui::GetColumnOffset(int column_index)
6289 6360
     // Read from cache
6290 6361
     IM_ASSERT(column_index < (int)window->DC.ColumnsOffsetsT.size());
6291 6362
     const float t = window->DC.ColumnsOffsetsT[column_index];
6292
-    const float offset = window->DC.ColumnsStartX + t * (window->Size.x - g.Style.ScrollBarWidth - window->DC.ColumnsStartX);
6363
+
6364
+    const float min_x = window->DC.ColumnsStartX;
6365
+    const float max_x = window->Size.x - (g.Style.ScrollBarWidth);// - window->WindowPadding().x;
6366
+    const float offset = min_x + t * (max_x - min_x);
6293 6367
     return offset;
6294 6368
 }
6295 6369
 
@@ -6302,7 +6376,10 @@ void ImGui::SetColumnOffset(int column_index, float offset)
6302 6376
 
6303 6377
     IM_ASSERT(column_index < (int)window->DC.ColumnsOffsetsT.size());
6304 6378
     const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
6305
-    const float t = (offset - window->DC.ColumnsStartX) / (window->Size.x - g.Style.ScrollBarWidth - window->DC.ColumnsStartX);
6379
+
6380
+    const float min_x = window->DC.ColumnsStartX;
6381
+    const float max_x = window->Size.x - (window->ScrollbarY);// - window->WindowPadding().x;
6382
+    const float t = (offset - min_x) / (max_x - min_x);
6306 6383
     window->StateStorage.SetFloat(column_id, t);
6307 6384
     window->DC.ColumnsOffsetsT[column_index] = t;
6308 6385
 }
@@ -6332,8 +6409,6 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
6332 6409
 {
6333 6410
     ImGuiState& g = *GImGui;
6334 6411
     ImGuiWindow* window = GetCurrentWindow();
6335
-    if (window->SkipItems)
6336
-        return;
6337 6412
 
6338 6413
     if (window->DC.ColumnsCount != 1)
6339 6414
     {
@@ -6347,7 +6422,7 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
6347 6422
     }
6348 6423
 
6349 6424
     // Draw columns borders and handle resize at the time of "closing" a columns set
6350
-    if (window->DC.ColumnsCount != columns_count && window->DC.ColumnsCount != 1 && window->DC.ColumnsShowBorders)
6425
+    if (window->DC.ColumnsCount != columns_count && window->DC.ColumnsCount != 1 && window->DC.ColumnsShowBorders && !window->SkipItems)
6351 6426
     {
6352 6427
         const float y1 = window->DC.ColumnsStartPos.y;
6353 6428
         const float y2 = window->DC.CursorPos.y;
@@ -7382,7 +7457,7 @@ void ImFont::BuildLookupTable()
7382 7457
     {
7383 7458
         Glyphs.resize(Glyphs.size() + 1);
7384 7459
         ImFont::Glyph& tab_glyph = Glyphs.back();
7385
-        tab_glyph = *space_glyph;
7460
+        tab_glyph = *FindGlyph((unsigned short)' ');
7386 7461
         tab_glyph.Codepoint = '\t';
7387 7462
         tab_glyph.XAdvance *= 4;
7388 7463
         IndexXAdvance[(size_t)tab_glyph.Codepoint] = (float)tab_glyph.XAdvance;
@@ -8115,7 +8190,7 @@ void ImGui::ShowTestWindow(bool* opened)
8115 8190
     static bool no_move = false;
8116 8191
     static bool no_scrollbar = false;
8117 8192
     static bool no_collapse = false;
8118
-    static float fill_alpha = 0.65f;
8193
+    static float bg_alpha = 0.65f;
8119 8194
 
8120 8195
     // Demonstrate the various window flags. Typically you would just use the default.
8121 8196
     ImGuiWindowFlags window_flags = 0;
@@ -8125,7 +8200,7 @@ void ImGui::ShowTestWindow(bool* opened)
8125 8200
     if (no_move)      window_flags |= ImGuiWindowFlags_NoMove;
8126 8201
     if (no_scrollbar) window_flags |= ImGuiWindowFlags_NoScrollbar;
8127 8202
     if (no_collapse)  window_flags |= ImGuiWindowFlags_NoCollapse;
8128
-    if (!ImGui::Begin("ImGui Test", opened, ImVec2(550,680), fill_alpha, window_flags))
8203
+    if (!ImGui::Begin("ImGui Test", opened, ImVec2(550,680), bg_alpha, window_flags))
8129 8204
     {
8130 8205
         // Early out if the window is collapsed, as an optimization.
8131 8206
         ImGui::End();
@@ -8156,7 +8231,7 @@ void ImGui::ShowTestWindow(bool* opened)
8156 8231
         ImGui::Checkbox("no move", &no_move); ImGui::SameLine(150);
8157 8232
         ImGui::Checkbox("no scrollbar", &no_scrollbar); ImGui::SameLine(300);
8158 8233
         ImGui::Checkbox("no collapse", &no_collapse);
8159
-        ImGui::SliderFloat("fill alpha", &fill_alpha, 0.0f, 1.0f);
8234
+        ImGui::SliderFloat("bg alpha", &bg_alpha, 0.0f, 1.0f);
8160 8235
 
8161 8236
         if (ImGui::TreeNode("Style"))
8162 8237
         {
@@ -8595,34 +8670,59 @@ void ImGui::ShowTestWindow(bool* opened)
8595 8670
 
8596 8671
     if (ImGui::CollapsingHeader("Columns"))
8597 8672
     {
8598
-        ImGui::Columns(4, "data", true);
8673
+        // Basic columns
8674
+        ImGui::Text("Basic:");
8675
+        ImGui::Columns(4, "mycolumns");
8599 8676
         ImGui::Text("ID"); ImGui::NextColumn();
8600 8677
         ImGui::Text("Name"); ImGui::NextColumn();
8601 8678
         ImGui::Text("Path"); ImGui::NextColumn();
8602 8679
         ImGui::Text("Flags"); ImGui::NextColumn();
8603 8680
         ImGui::Separator();
8681
+        const char* names[3] = { "Robert", "Stephanie", "C64" };
8682
+        const char* paths[3] = { "/path/robert", "/path/stephanie", "/path/computer" };
8683
+        for (int i = 0; i < 3; i++)
8684
+        {
8685
+            ImGui::Text("%04d", i); ImGui::NextColumn();
8686
+            ImGui::Text(names[i]); ImGui::NextColumn();
8687
+            ImGui::Text(paths[i]); ImGui::NextColumn(); 
8688
+            ImGui::Text("...."); ImGui::NextColumn();
8689
+        }
8690
+        ImGui::Columns(1);
8604 8691
 
8605
-        ImGui::Text("0000"); ImGui::NextColumn();
8606
-        ImGui::Text("Robert"); ImGui::NextColumn();
8607
-        ImGui::Text("/path/robert"); ImGui::NextColumn();
8608
-        ImGui::Text("...."); ImGui::NextColumn();
8609
-
8610
-        ImGui::Text("0001"); ImGui::NextColumn();
8611
-        ImGui::Text("Stephanie"); ImGui::NextColumn();
8612
-        ImGui::Text("/path/stephanie"); ImGui::NextColumn();
8613
-        ImGui::Text("line 1"); ImGui::Text("line 2"); ImGui::NextColumn(); // two lines, two items
8692
+        ImGui::Separator();
8693
+        ImGui::Spacing();
8614 8694
 
8615
-        ImGui::Text("0002"); ImGui::NextColumn();
8616
-        ImGui::Text("C64"); ImGui::NextColumn();
8617
-        ImGui::Text("/path/computer"); ImGui::NextColumn();
8618
-        ImGui::Text("...."); ImGui::NextColumn();
8695
+        // Scrolling columns
8696
+		/*
8697
+        ImGui::Text("Scrolling:");
8698
+        ImGui::BeginChild("##header", ImVec2(0, ImGui::GetTextLineHeightWithSpacing()+ImGui::GetStyle().ItemSpacing.y));
8699
+        ImGui::Columns(3);
8700
+        ImGui::Text("ID"); ImGui::NextColumn();
8701
+        ImGui::Text("Name"); ImGui::NextColumn();
8702
+        ImGui::Text("Path"); ImGui::NextColumn();
8703
+        ImGui::Columns(1);
8704
+        ImGui::Separator();
8705
+        ImGui::EndChild();
8706
+        ImGui::BeginChild("##scrollingregion", ImVec2(0, 60));
8707
+        ImGui::Columns(3);
8708
+        for (int i = 0; i < 10; i++)
8709
+        {
8710
+            ImGui::Text("%04d", i); ImGui::NextColumn();
8711
+            ImGui::Text("Foobar"); ImGui::NextColumn();
8712
+            ImGui::Text("/path/foobar/%04d/", i); ImGui::NextColumn();
8713
+        }
8619 8714
         ImGui::Columns(1);
8715
+        ImGui::EndChild();
8620 8716
 
8621 8717
         ImGui::Separator();
8718
+        ImGui::Spacing();
8719
+		*/
8622 8720
 
8721
+        // Create multiple items in a same cell before switching to next column
8722
+        ImGui::Text("Mixed items:");
8623 8723
         ImGui::Columns(3, "mixed");
8724
+        ImGui::Separator();
8624 8725
 
8625
-        // Create multiple items in a same cell because switching to next column
8626 8726
         static int e = 0;
8627 8727
         ImGui::Text("Hello"); 
8628 8728
         ImGui::Button("Banana");
@@ -8632,38 +8732,41 @@ void ImGui::ShowTestWindow(bool* opened)
8632 8732
         ImGui::Text("ImGui"); 
8633 8733
         ImGui::Button("Apple");
8634 8734
         ImGui::RadioButton("radio b", &e, 1);
8735
+        static float foo = 1.0f;
8736
+        ImGui::InputFloat("red", &foo, 0.05f, 0, 3); 
8635 8737
         ImGui::Text("An extra line here.");
8636 8738
         ImGui::NextColumn();
8637 8739
         
8638 8740
         ImGui::Text("World!");
8639 8741
         ImGui::Button("Corniflower");
8640 8742
         ImGui::RadioButton("radio c", &e, 2);
8743
+        static float bar = 1.0f;
8744
+        ImGui::InputFloat("blue", &bar, 0.05f, 0, 3); 
8641 8745
         ImGui::NextColumn();
8642 8746
 
8643 8747
         if (ImGui::CollapsingHeader("Category A")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
8644 8748
         if (ImGui::CollapsingHeader("Category B")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
8645 8749
         if (ImGui::CollapsingHeader("Category C")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
8646
-
8647
-        ImGui::Columns(1);
8648
-
8649
-        ImGui::Separator();
8650
-
8651
-        ImGui::Columns(2, "multiple components");
8652
-        static float foo = 1.0f;
8653
-        ImGui::InputFloat("red", &foo, 0.05f, 0, 3); ImGui::NextColumn();
8654
-        static float bar = 1.0f;
8655
-        ImGui::InputFloat("blue", &bar, 0.05f, 0, 3); ImGui::NextColumn();
8656 8750
         ImGui::Columns(1);
8657 8751
 
8658 8752
         ImGui::Separator();
8753
+        ImGui::Spacing();
8659 8754
 
8755
+        // Tree items
8756
+        ImGui::Text("Tree items:");
8660 8757
         ImGui::Columns(2, "tree items");
8758
+        ImGui::Separator();
8661 8759
         if (ImGui::TreeNode("Hello")) { ImGui::BulletText("World"); ImGui::TreePop(); } ImGui::NextColumn();
8662
-        if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Monde"); ImGui::TreePop(); }
8760
+        if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Monde"); ImGui::TreePop(); } ImGui::NextColumn();
8663 8761
         ImGui::Columns(1);
8762
+
8664 8763
         ImGui::Separator();
8764
+        ImGui::Spacing();
8665 8765
 
8666
-        ImGui::Columns(2, "word wrapping");
8766
+        // Word-wrapping
8767
+        ImGui::Text("Word-wrapping:");
8768
+        ImGui::Columns(2, "word-wrapping");
8769
+        ImGui::Separator();
8667 8770
         ImGui::TextWrapped("The quick brown fox jumps over the lazy dog.");
8668 8771
         ImGui::Text("Hello Left");
8669 8772
         ImGui::NextColumn();
@@ -8672,34 +8775,29 @@ void ImGui::ShowTestWindow(bool* opened)
8672 8775
         ImGui::Columns(1);
8673 8776
 
8674 8777
         ImGui::Separator();
8778
+        ImGui::Spacing();
8675 8779
 
8676 8780
         if (ImGui::TreeNode("Inside a tree.."))
8677 8781
         {
8678 8782
             if (ImGui::TreeNode("node 1 (with borders)"))
8679 8783
             {
8680 8784
                 ImGui::Columns(4);
8681
-                ImGui::Text("aaa"); ImGui::NextColumn();
8682
-                ImGui::Text("bbb"); ImGui::NextColumn();
8683
-                ImGui::Text("ccc"); ImGui::NextColumn();
8684
-                ImGui::Text("ddd"); ImGui::NextColumn();
8685
-                ImGui::Text("eee"); ImGui::NextColumn();
8686
-                ImGui::Text("fff"); ImGui::NextColumn();
8687
-                ImGui::Text("ggg"); ImGui::NextColumn();
8688
-                ImGui::Text("hhh"); ImGui::NextColumn();
8785
+                for (int i = 0; i < 8; i++)
8786
+                {
8787
+                    ImGui::Text("%c%c%c", 'a'+i, 'a'+i, 'a'+i);
8788
+                    ImGui::NextColumn();
8789
+                }
8689 8790
                 ImGui::Columns(1);
8690 8791
                 ImGui::TreePop();
8691 8792
             }
8692 8793
             if (ImGui::TreeNode("node 2 (without borders)"))
8693 8794
             {
8694 8795
                 ImGui::Columns(4, NULL, false);
8695
-                ImGui::Text("aaa"); ImGui::NextColumn();
8696
-                ImGui::Text("bbb"); ImGui::NextColumn();
8697
-                ImGui::Text("ccc"); ImGui::NextColumn();
8698
-                ImGui::Text("ddd"); ImGui::NextColumn();
8699
-                ImGui::Text("eee"); ImGui::NextColumn();
8700
-                ImGui::Text("fff"); ImGui::NextColumn();
8701
-                ImGui::Text("ggg"); ImGui::NextColumn();
8702
-                ImGui::Text("hhh"); ImGui::NextColumn();
8796
+                for (int i = 0; i < 8; i++)
8797
+                {
8798
+                    ImGui::Text("%c%c%c", 'a'+i, 'a'+i, 'a'+i);
8799
+                    ImGui::NextColumn();
8800
+                }
8703 8801
                 ImGui::Columns(1);
8704 8802
                 ImGui::TreePop();
8705 8803
             }
@@ -8764,6 +8862,7 @@ void ImGui::ShowTestWindow(bool* opened)
8764 8862
                 ImGui::Text("Item with focus: %d", has_focus);
8765 8863
             else 
8766 8864
                 ImGui::Text("Item with focus: <none>");
8865
+            ImGui::TextWrapped("Cursor & selection are preserved when refocusing last used item in code.");
8767 8866
             ImGui::TreePop();
8768 8867
         }
8769 8868
     }

+ 20
- 20
src/deps/imgui/imgui.h Wyświetl plik

@@ -1,4 +1,4 @@
1
-// ImGui library v1.32
1
+// ImGui library v1.33
2 2
 // See .cpp file for documentation.
3 3
 // See ImGui::ShowTestWindow() for sample code.
4 4
 // Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
@@ -142,7 +142,7 @@ public:
142 142
 // - struct ImDrawList                  // Draw command list
143 143
 // - struct ImFont                      // TTF font loader, bake glyphs into bitmap
144 144
 
145
-// ImGui End-user API
145
+// ImGui end-user API
146 146
 // In a namespace so that user can add extra functions (e.g. Value() helpers for your vector or common types)
147 147
 namespace ImGui
148 148
 {
@@ -157,10 +157,11 @@ namespace ImGui
157 157
     IMGUI_API void          ShowTestWindow(bool* open = NULL);
158 158
 
159 159
     // Window
160
-    IMGUI_API bool          Begin(const char* name = "Debug", bool* p_opened = NULL, ImVec2 size = ImVec2(0,0), float fill_alpha = -1.0f, ImGuiWindowFlags flags = 0);// return false when window is collapsed, so you can early out in your code. passing 'bool* p_opened' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed.
160
+    // See implementation in .cpp for details
161
+    IMGUI_API bool          Begin(const char* name = "Debug", bool* p_opened = NULL, const ImVec2& initial_size = ImVec2(0,0), float bg_alpha = -1.0f, ImGuiWindowFlags flags = 0); // return false when window is collapsed, so you can early out in your code. passing 'bool* p_opened' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed.
161 162
     IMGUI_API void          End();
162
-    IMGUI_API void          BeginChild(const char* str_id, ImVec2 size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0);                         // size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). on each axis.
163
-    IMGUI_API void          BeginChild(ImGuiID id, ImVec2 size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0);                                 // "
163
+    IMGUI_API bool          BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0);            // size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). on each axis.
164
+    IMGUI_API bool          BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0);                    // "
164 165
     IMGUI_API void          EndChild();
165 166
     IMGUI_API bool          GetWindowIsFocused();
166 167
     IMGUI_API ImVec2        GetContentRegionMax();                                              // window or current column boundaries, in windows coordinates
@@ -232,8 +233,8 @@ namespace ImGui
232 233
     IMGUI_API float         GetTextLineHeightWithSpacing();                                     // spacing (in pixels) between 2 consecutive lines of text == GetWindowFontSize() + GetStyle().ItemSpacing.y
233 234
 
234 235
     // ID scopes
235
-    // If you are creating repeated widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them.
236
-    // You can also use ## within your widget name to distinguish them from each others (see 'Programmer Guide')
236
+    // If you are creating widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them.
237
+    // You can also use "##extra" within your widget name to distinguish them from each others (see 'Programmer Guide')
237 238
     IMGUI_API void          PushID(const char* str_id);                                         // push identifier into the ID stack. IDs are hash of the *entire* stack!
238 239
     IMGUI_API void          PushID(const void* ptr_id);
239 240
     IMGUI_API void          PushID(const int int_id);
@@ -327,6 +328,7 @@ namespace ImGui
327 328
     // Utilities
328 329
     IMGUI_API bool          IsItemHovered();                                                    // was the last item hovered by mouse?
329 330
     IMGUI_API bool          IsItemActive();                                                     // was the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false)
331
+    IMGUI_API bool          IsAnyItemActive();                                                  // 
330 332
     IMGUI_API ImVec2        GetItemBoxMin();                                                    // get bounding box of last item
331 333
     IMGUI_API ImVec2        GetItemBoxMax();                                                    // get bounding box of last item
332 334
     IMGUI_API bool          IsClipped(const ImVec2& item_size);                                 // to perform coarse clipping on user's side (as an optimization)
@@ -390,13 +392,12 @@ enum ImGuiInputTextFlags_
390 392
     ImGuiInputTextFlags_CharsHexadecimal    = 1 << 1,   // Allow 0123456789ABCDEFabcdef
391 393
     ImGuiInputTextFlags_CharsUppercase      = 1 << 2,   // Turn a..z into A..Z
392 394
     ImGuiInputTextFlags_CharsNoBlank        = 1 << 3,   // Filter out spaces, tabs
393
-    ImGuiInputTextFlags_AutoSelectAll       = 1 << 4,   // Select entire text when first taking focus
395
+    ImGuiInputTextFlags_AutoSelectAll       = 1 << 4,   // Select entire text when first taking mouse focus
394 396
     ImGuiInputTextFlags_EnterReturnsTrue    = 1 << 5,   // Return 'true' when Enter is pressed (as opposed to when the value was modified)
395 397
     ImGuiInputTextFlags_CallbackCompletion  = 1 << 6,   // Call user function on pressing TAB (for completion handling)
396 398
     ImGuiInputTextFlags_CallbackHistory     = 1 << 7,   // Call user function on pressing Up/Down arrows (for history handling)
397 399
     ImGuiInputTextFlags_CallbackAlways      = 1 << 8,   // Call user function every time
398 400
     ImGuiInputTextFlags_CallbackCharFilter  = 1 << 9    // Call user function to filter character. Modify data->EventChar to replace/filter input, or return 1 to discard character.
399
-    //ImGuiInputTextFlags_AlignCenter       = 1 << 6,
400 401
 };
401 402
 
402 403
 // User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
@@ -497,7 +498,7 @@ enum ImGuiColorEditMode_
497 498
 enum ImGuiSetCondition_
498 499
 {
499 500
     ImGuiSetCondition_Always              = 1 << 0, // Set the variable
500
-    ImGuiSetCondition_FirstUseThisSession = 1 << 1, // Only set the variable on the first call for this window (once per session)
501
+    ImGuiSetCondition_FirstUseThisSession = 1 << 1, // Only set the variable on the first call per runtime session
501 502
     ImGuiSetCondition_FirstUseEver        = 1 << 2  // Only set the variable if the window doesn't exist in the .ini file
502 503
 };
503 504
 
@@ -533,7 +534,7 @@ struct ImGuiIO
533 534
 
534 535
     ImVec2        DisplaySize;              // <unset>              // Display size, in pixels. For clamping windows positions.
535 536
     float         DeltaTime;                // = 1.0f/60.0f         // Time elapsed since last frame, in seconds.
536
-    float         IniSavingRate;            // = 5.0f               // Maximum time between saving .ini file, in seconds.
537
+    float         IniSavingRate;            // = 5.0f               // Maximum time between saving positions/sizes to .ini file, in seconds.
537 538
     const char*   IniFilename;              // = "imgui.ini"        // Path to .ini file. NULL to disable .ini saving.
538 539
     const char*   LogFilename;              // = "imgui_log.txt"    // Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
539 540
     float         MouseDoubleClickTime;     // = 0.30f              // Time for a double-click, in seconds.
@@ -555,8 +556,8 @@ struct ImGuiIO
555 556
     // See example code if you are unsure of how to implement this.
556 557
     void        (*RenderDrawListsFn)(ImDrawList** const draw_lists, int count);      
557 558
 
558
-    // Optional: access OS clipboard (default to use native Win32 clipboard on Windows, otherwise use a ImGui private clipboard)
559
-    // Override to access OS clipboard on other architectures.
559
+    // Optional: access OS clipboard
560
+    // (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
560 561
     const char* (*GetClipboardTextFn)();
561 562
     void        (*SetClipboardTextFn)(const char* text);
562 563
 
@@ -564,7 +565,7 @@ struct ImGuiIO
564 565
     void*       (*MemAllocFn)(size_t sz);
565 566
     void        (*MemFreeFn)(void* ptr);
566 567
 
567
-    // Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese inputs in Windows)
568
+    // Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME in Windows)
568 569
     void        (*ImeSetInputScreenPosFn)(int x, int y);
569 570
 
570 571
     //------------------------------------------------------------------
@@ -572,12 +573,12 @@ struct ImGuiIO
572 573
     //------------------------------------------------------------------
573 574
 
574 575
     ImVec2      MousePos;                   // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
575
-    bool        MouseDown[5];               // Mouse buttons. ImGui itself only uses button 0 (left button) but you can use others as storage for convenience.
576
+    bool        MouseDown[5];               // Mouse buttons. ImGui itself only uses button 0 (left button). Others buttons allows to track if mouse is being used by your application + available to user as a convenience via IsMouse** API.
576 577
     float       MouseWheel;                 // Mouse wheel: 1 unit scrolls about 5 lines text. 
577 578
     bool        MouseDrawCursor;            // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor).
578 579
     bool        KeyCtrl;                    // Keyboard modifier pressed: Control
579 580
     bool        KeyShift;                   // Keyboard modifier pressed: Shift
580
-    bool        KeysDown[512];              // Keyboard keys that are pressed (in whatever order user naturally has access to keyboard data)
581
+    bool        KeysDown[512];              // Keyboard keys that are pressed (in whatever storage order you naturally have access to keyboard data)
581 582
     ImWchar     InputCharacters[16+1];      // List of characters input (translated by user from keypress+keyboard state). Fill using AddInputCharacter() helper.
582 583
 
583 584
     // Function
@@ -595,7 +596,7 @@ struct ImGuiIO
595 596
     // [Internal] ImGui will maintain those fields for you
596 597
     //------------------------------------------------------------------
597 598
 
598
-    ImVec2      MousePosPrev;               //
599
+    ImVec2      MousePosPrev;               // Previous mouse position
599 600
     ImVec2      MouseDelta;                 // Mouse delta. Note that this is zero if either current or previous position are negative to allow mouse enabling/disabling.
600 601
     bool        MouseClicked[5];            // Mouse button went from !Down to Down
601 602
     ImVec2      MouseClickedPos[5];         // Position at time of clicking
@@ -651,7 +652,7 @@ struct ImGuiTextFilter
651 652
     ImVector<TextRange> Filters;
652 653
     int                 CountGrep;
653 654
 
654
-    ImGuiTextFilter();
655
+    ImGuiTextFilter(const char* default_filter = "");
655 656
     void Clear() { InputBuf[0] = 0; Build(); }
656 657
     void Draw(const char* label = "Filter (inc,-exc)", float width = -1.0f);    // Helper calling InputText+Build
657 658
     bool PassFilter(const char* val) const;
@@ -751,7 +752,6 @@ struct ImColor
751 752
     ImColor(int r, int g, int b, int a = 255)                       { Value.x = (float)r / 255.0f; Value.y = (float)g / 255.0f; Value.z = (float)b / 255.0f; Value.w = (float)a / 255.0f; }
752 753
     ImColor(float r, float g, float b, float a = 1.0f)              { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
753 754
     ImColor(const ImVec4& col)                                      { Value = col; }
754
-
755 755
     operator ImU32() const                                          { return ImGui::ColorConvertFloat4ToU32(Value); }
756 756
     operator ImVec4() const                                         { return Value; }
757 757
 
@@ -774,7 +774,7 @@ struct ImColor
774 774
 // It is up to you to decide if your rendering loop or the callback should be responsible for backup/restoring rendering state.
775 775
 typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd);
776 776
 
777
-// Typically, 1 command = 1 gpu draw call
777
+// Typically, 1 command = 1 gpu draw call (unless command is a callback)
778 778
 struct ImDrawCmd
779 779
 {
780 780
     unsigned int    vtx_count;                  // Number of vertices (multiple of 3) to be drawn as triangles. The vertices are stored in the callee ImDrawList's vtx_buffer[] array.

Ładowanie…
Anuluj
Zapisz