Browse Source

Updated imgui to v1.35 wip

Thomas Buck 9 years ago
parent
commit
ce2b8c05d7
4 changed files with 249 additions and 98 deletions
  1. 1
    0
      ChangeLog.md
  2. 5
    1
      src/deps/imgui/imconfig.h
  3. 214
    81
      src/deps/imgui/imgui.cpp
  4. 29
    16
      src/deps/imgui/imgui.h

+ 1
- 0
ChangeLog.md View File

4
 
4
 
5
     [ 20140304 ]
5
     [ 20140304 ]
6
     * Added (more or less working) support for loading TR1 levels
6
     * Added (more or less working) support for loading TR1 levels
7
+    * Updated imgui
7
 
8
 
8
     [ 20140222 ]
9
     [ 20140222 ]
9
     * Updated imgui to version 1.33
10
     * Updated imgui to version 1.33

+ 5
- 1
src/deps/imgui/imconfig.h View File

15
 #include "global.h"
15
 #include "global.h"
16
 #define IM_ASSERT(_EXPR)  assert(_EXPR)
16
 #define IM_ASSERT(_EXPR)  assert(_EXPR)
17
 
17
 
18
+//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
19
+//#define IMGUI_API __declspec( dllexport )
20
+//#define IMGUI_API __declspec( dllimport )
21
+
18
 //---- Don't implement default clipboard handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions)
22
 //---- Don't implement default clipboard handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions)
19
 //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS
23
 //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS
20
 
24
 
37
 
41
 
38
 //---- Freely implement extra functions within the ImGui:: namespace.
42
 //---- Freely implement extra functions within the ImGui:: namespace.
39
 //---- Declare helpers or widgets implemented in imgui_user.inl or elsewhere, so end-user doesn't need to include multiple files.
43
 //---- Declare helpers or widgets implemented in imgui_user.inl or elsewhere, so end-user doesn't need to include multiple files.
40
-//---- e.g. you can create variants of the ImGui::Value() helper for your low-level math types.
44
+//---- e.g. you can create variants of the ImGui::Value() helper for your low-level math types, or your own widgets/helpers.
41
 /*
45
 /*
42
 namespace ImGui
46
 namespace ImGui
43
 {
47
 {

+ 214
- 81
src/deps/imgui/imgui.cpp View File

1
-// ImGui library v1.33
1
+// ImGui library v1.35 wip
2
 // See ImGui::ShowTestWindow() for sample code.
2
 // See ImGui::ShowTestWindow() for sample code.
3
 // Read 'Programmer guide' below for notes on how to setup ImGui in your codebase.
3
 // Read 'Programmer guide' below for notes on how to setup ImGui in your codebase.
4
 // Get latest version at https://github.com/ocornut/imgui
4
 // Get latest version at https://github.com/ocornut/imgui
129
  Occasionally introducing changes that are breaking the API. The breakage are generally minor and easy to fix.
129
  Occasionally introducing changes that are breaking the API. The breakage are generally minor and easy to fix.
130
  Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
130
  Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
131
  
131
  
132
+ - 2015/02/27 (1.34) - renamed OpenNextNode(bool) to SetNextTreeNodeOpened(bool, ImGuiSetCond), kept inline redirection function.
133
+ - 2015/02/27 (1.34) - renamed ImGuiSetCondition_*** to ImGuiSetCond_***, and _FirstUseThisSession becomes _Once.
132
  - 2015/02/11 (1.32) - changed text input callback ImGuiTextEditCallback return type from void-->int. reserved for future use, return 0 for now.
134
  - 2015/02/11 (1.32) - changed text input callback ImGuiTextEditCallback return type from void-->int. reserved for future use, return 0 for now.
133
  - 2015/02/10 (1.32) - renamed GetItemWidth() to CalcItemWidth() to clarify its evolving behavior
135
  - 2015/02/10 (1.32) - renamed GetItemWidth() to CalcItemWidth() to clarify its evolving behavior
134
  - 2015/02/08 (1.31) - renamed GetTextLineSpacing() to GetTextLineHeightWithSpacing()
136
  - 2015/02/08 (1.31) - renamed GetTextLineSpacing() to GetTextLineHeightWithSpacing()
289
  - text edit: flag to disable live update of the user buffer. 
291
  - text edit: flag to disable live update of the user buffer. 
290
  - text edit: field resize behavior - field could stretch when being edited? hover tooltip shows more text?
292
  - text edit: field resize behavior - field could stretch when being edited? hover tooltip shows more text?
291
  - text edit: add multi-line text edit
293
  - text edit: add multi-line text edit
292
- - tree: reformulate OpenNextNode() into SetNextWindowCollapsed() api
293
  - tree: add treenode/treepush int variants? because (void*) cast from int warns on some platforms/settings
294
  - tree: add treenode/treepush int variants? because (void*) cast from int warns on some platforms/settings
294
  - settings: write more decent code to allow saving/loading new fields
295
  - settings: write more decent code to allow saving/loading new fields
295
  - settings: api for per-tool simple persistent data (bool,int,float) in .ini file
296
  - settings: api for per-tool simple persistent data (bool,int,float) in .ini file
416
 static void         RenderCollapseTriangle(ImVec2 p_min, bool opened, float scale = 1.0f, bool shadow = false);
417
 static void         RenderCollapseTriangle(ImVec2 p_min, bool opened, float scale = 1.0f, bool shadow = false);
417
 
418
 
418
 static void         SetFont(ImFont* font);
419
 static void         SetFont(ImFont* font);
419
-static bool         ItemAdd(const ImGuiAabb& aabb, const ImGuiID* id);
420
+static bool         ItemAdd(const ImGuiAabb& bb, const ImGuiID* id);
420
 static void         ItemSize(ImVec2 size, ImVec2* adjust_start_offset = NULL);
421
 static void         ItemSize(ImVec2 size, ImVec2* adjust_start_offset = NULL);
421
-static void         ItemSize(const ImGuiAabb& aabb, ImVec2* adjust_start_offset = NULL);
422
+static void         ItemSize(const ImGuiAabb& bb, ImVec2* adjust_start_offset = NULL);
422
 static void         PushColumnClipRect(int column_index = -1);
423
 static void         PushColumnClipRect(int column_index = -1);
423
-static bool         IsClipped(const ImGuiAabb& aabb);
424
+static bool         IsClipped(const ImGuiAabb& bb);
424
 
425
 
425
-static bool         IsMouseHoveringBox(const ImGuiAabb& box);
426
+static bool         IsMouseHoveringBox(const ImGuiAabb& bb);
426
 static bool         IsKeyPressedMap(ImGuiKey key, bool repeat = true);
427
 static bool         IsKeyPressedMap(ImGuiKey key, bool repeat = true);
427
 
428
 
428
 static bool         CloseWindowButton(bool* p_opened = NULL);
429
 static bool         CloseWindowButton(bool* p_opened = NULL);
889
     ImVector<float>         TextWrapPos;
890
     ImVector<float>         TextWrapPos;
890
     ImGuiColorEditMode      ColorEditMode;
891
     ImGuiColorEditMode      ColorEditMode;
891
     ImGuiStorage*           StateStorage;
892
     ImGuiStorage*           StateStorage;
892
-    int                     OpenNextNode;        // FIXME: Reformulate this feature like SetNextWindowCollapsed() API
893
 
893
 
894
     float                   ColumnsStartX;       // Start position from left of window (increased by TreePush/TreePop, etc.)
894
     float                   ColumnsStartX;       // Start position from left of window (increased by TreePush/TreePop, etc.)
895
     float                   ColumnsOffsetX;      // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
895
     float                   ColumnsOffsetX;      // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
912
         LastItemAabb = ImGuiAabb(0.0f,0.0f,0.0f,0.0f);
912
         LastItemAabb = ImGuiAabb(0.0f,0.0f,0.0f,0.0f);
913
         LastItemHovered = false;
913
         LastItemHovered = false;
914
         StateStorage = NULL;
914
         StateStorage = NULL;
915
-        OpenNextNode = -1;
916
 
915
 
917
         ColumnsStartX = 0.0f;
916
         ColumnsStartX = 0.0f;
918
         ColumnsOffsetX = 0.0f;
917
         ColumnsOffsetX = 0.0f;
994
     ImGuiID                 ActiveIdPreviousFrame;
993
     ImGuiID                 ActiveIdPreviousFrame;
995
     bool                    ActiveIdIsAlive;
994
     bool                    ActiveIdIsAlive;
996
     bool                    ActiveIdIsFocusedOnly;              // Set only by active widget. Denote focus but no active interaction.
995
     bool                    ActiveIdIsFocusedOnly;              // Set only by active widget. Denote focus but no active interaction.
996
+    ImGuiWindow*            MovedWindow;                        // Track the child window we clicked on to move a window. Only valid if ActiveID is the "#MOVE" identifier of a window.
997
     float                   SettingsDirtyTimer;
997
     float                   SettingsDirtyTimer;
998
     ImVector<ImGuiIniData*> Settings;
998
     ImVector<ImGuiIniData*> Settings;
999
     ImVector<ImGuiColMod>   ColorModifiers;
999
     ImVector<ImGuiColMod>   ColorModifiers;
1000
     ImVector<ImGuiStyleMod> StyleModifiers;
1000
     ImVector<ImGuiStyleMod> StyleModifiers;
1001
     ImVector<ImFont*>       FontStack;
1001
     ImVector<ImFont*>       FontStack;
1002
+
1002
     ImVec2                  SetNextWindowPosVal;
1003
     ImVec2                  SetNextWindowPosVal;
1003
-    ImGuiSetCondition       SetNextWindowPosCond;
1004
+    ImGuiSetCond            SetNextWindowPosCond;
1004
     ImVec2                  SetNextWindowSizeVal;
1005
     ImVec2                  SetNextWindowSizeVal;
1005
-    ImGuiSetCondition       SetNextWindowSizeCond;
1006
+    ImGuiSetCond            SetNextWindowSizeCond;
1006
     bool                    SetNextWindowCollapsedVal;
1007
     bool                    SetNextWindowCollapsedVal;
1007
-    ImGuiSetCondition       SetNextWindowCollapsedCond;
1008
+    ImGuiSetCond            SetNextWindowCollapsedCond;
1009
+    bool                    SetNextWindowFocus;
1010
+    bool                    SetNextTreeNodeOpenedVal;
1011
+    ImGuiSetCond            SetNextTreeNodeOpenedCond;
1008
 
1012
 
1009
     // Render
1013
     // Render
1010
     ImVector<ImDrawList*>   RenderDrawLists;
1014
     ImVector<ImDrawList*>   RenderDrawLists;
1049
         ActiveIdPreviousFrame = 0;
1053
         ActiveIdPreviousFrame = 0;
1050
         ActiveIdIsAlive = false;
1054
         ActiveIdIsAlive = false;
1051
         ActiveIdIsFocusedOnly = false;
1055
         ActiveIdIsFocusedOnly = false;
1056
+        MovedWindow = NULL;
1052
         SettingsDirtyTimer = 0.0f;
1057
         SettingsDirtyTimer = 0.0f;
1058
+
1053
         SetNextWindowPosVal = ImVec2(0.0f, 0.0f);
1059
         SetNextWindowPosVal = ImVec2(0.0f, 0.0f);
1054
         SetNextWindowPosCond = 0;
1060
         SetNextWindowPosCond = 0;
1055
         SetNextWindowSizeVal = ImVec2(0.0f, 0.0f);
1061
         SetNextWindowSizeVal = ImVec2(0.0f, 0.0f);
1056
         SetNextWindowSizeCond = 0;
1062
         SetNextWindowSizeCond = 0;
1057
         SetNextWindowCollapsedVal = false;
1063
         SetNextWindowCollapsedVal = false;
1058
         SetNextWindowCollapsedCond = 0;
1064
         SetNextWindowCollapsedCond = 0;
1065
+        SetNextWindowFocus = false;
1066
+        SetNextTreeNodeOpenedVal = false;
1067
+        SetNextTreeNodeOpenedCond = 0;
1059
 
1068
 
1060
         SliderAsInputTextId = 0;
1069
         SliderAsInputTextId = 0;
1061
         ActiveComboID = 0;
1070
         ActiveComboID = 0;
1096
     bool                    SkipItems;                          // == Visible && !Collapsed
1105
     bool                    SkipItems;                          // == Visible && !Collapsed
1097
     int                     AutoFitFrames;
1106
     int                     AutoFitFrames;
1098
     bool                    AutoFitOnlyGrows;
1107
     bool                    AutoFitOnlyGrows;
1099
-    int                     SetWindowPosAllowFlags;             // bit ImGuiSetCondition_*** specify if SetWindowPos() call is allowed with this particular flag. 
1100
-    int                     SetWindowSizeAllowFlags;            // bit ImGuiSetCondition_*** specify if SetWindowSize() call is allowed with this particular flag. 
1101
-    int                     SetWindowCollapsedAllowFlags;       // bit ImGuiSetCondition_*** specify if SetWindowCollapsed() call is allowed with this particular flag. 
1108
+    int                     SetWindowPosAllowFlags;             // bit ImGuiSetCond_*** specify if SetWindowPos() call is allowed with this particular flag. 
1109
+    int                     SetWindowSizeAllowFlags;            // bit ImGuiSetCond_*** specify if SetWindowSize() call is allowed with this particular flag. 
1110
+    int                     SetWindowCollapsedAllowFlags;       // bit ImGuiSetCond_*** specify if SetWindowCollapsed() call is allowed with this particular flag. 
1102
 
1111
 
1103
     ImGuiDrawContext        DC;
1112
     ImGuiDrawContext        DC;
1104
     ImVector<ImGuiID>       IDStack;
1113
     ImVector<ImGuiID>       IDStack;
1295
 
1304
 
1296
 void ImGuiTextFilter::Draw(const char* label, float width)
1305
 void ImGuiTextFilter::Draw(const char* label, float width)
1297
 {
1306
 {
1298
-    ImGuiWindow* window = GetCurrentWindow();
1299
     if (width > 0.0f)
1307
     if (width > 0.0f)
1300
         ImGui::PushItemWidth(width);
1308
         ImGui::PushItemWidth(width);
1301
     ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf));
1309
     ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf));
1430
     SkipItems = false;
1438
     SkipItems = false;
1431
     AutoFitFrames = -1;
1439
     AutoFitFrames = -1;
1432
     AutoFitOnlyGrows = false;
1440
     AutoFitOnlyGrows = false;
1433
-    SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiSetCondition_Always | ImGuiSetCondition_FirstUseThisSession | ImGuiSetCondition_FirstUseEver;
1441
+    SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiSetCond_Always | ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver;
1434
 
1442
 
1435
     IDStack.push_back(ID);
1443
     IDStack.push_back(ID);
1436
     LastFrameDrawn = -1;
1444
     LastFrameDrawn = -1;
1761
         SetActiveId(0);
1769
         SetActiveId(0);
1762
     g.ActiveIdPreviousFrame = g.ActiveId;
1770
     g.ActiveIdPreviousFrame = g.ActiveId;
1763
     g.ActiveIdIsAlive = false;
1771
     g.ActiveIdIsAlive = false;
1772
+    if (!g.ActiveId)
1773
+        g.MovedWindow = NULL;
1764
 
1774
 
1765
     // Delay saving settings so we don't spam disk too much
1775
     // Delay saving settings so we don't spam disk too much
1766
     if (g.SettingsDirtyTimer > 0.0f)
1776
     if (g.SettingsDirtyTimer > 0.0f)
1835
     }
1845
     }
1836
 
1846
 
1837
     // Mark all windows as not visible
1847
     // Mark all windows as not visible
1838
-    // Clear root windows at this point.
1839
     for (size_t i = 0; i != g.Windows.size(); i++)
1848
     for (size_t i = 0; i != g.Windows.size(); i++)
1840
     {
1849
     {
1841
         ImGuiWindow* window = g.Windows[i];
1850
         ImGuiWindow* window = g.Windows[i];
1842
         window->Visible = false;
1851
         window->Visible = false;
1843
         window->Accessed = false;
1852
         window->Accessed = false;
1844
-        window->RootWindow = NULL;
1845
     }
1853
     }
1846
 
1854
 
1847
     // No window should be open at the beginning of the frame.
1855
     // No window should be open at the beginning of the frame.
1972
             g.CurrentWindow->Visible = false;
1980
             g.CurrentWindow->Visible = false;
1973
         ImGui::End();
1981
         ImGui::End();
1974
 
1982
 
1975
-        // Select window for move/focus when we're done with all our widgets (we only consider non-child windows here)
1983
+        // Select window for move/focus when we're done with all our widgets (we use the root window ID here)
1976
         if (g.ActiveId == 0 && g.HoveredId == 0 && g.HoveredRootWindow != NULL && g.IO.MouseClicked[0])
1984
         if (g.ActiveId == 0 && g.HoveredId == 0 && g.HoveredRootWindow != NULL && g.IO.MouseClicked[0])
1985
+        {
1986
+            IM_ASSERT(g.MovedWindow == NULL);
1987
+            g.MovedWindow = g.HoveredWindow;
1977
             SetActiveId(g.HoveredRootWindow->GetID("#MOVE"));
1988
             SetActiveId(g.HoveredRootWindow->GetID("#MOVE"));
1989
+        }
1978
 
1990
 
1979
         // Sort the window list so that all child windows are after their parent
1991
         // Sort the window list so that all child windows are after their parent
1980
         // We cannot do that on FocusWindow() because childs may not exist yet
1992
         // We cannot do that on FocusWindow() because childs may not exist yet
2346
 // Test if mouse cursor is hovering given aabb
2358
 // Test if mouse cursor is hovering given aabb
2347
 // NB- Box is clipped by our current clip setting
2359
 // NB- Box is clipped by our current clip setting
2348
 // NB- Expand the aabb to be generous on imprecise inputs systems (g.Style.TouchExtraPadding)
2360
 // NB- Expand the aabb to be generous on imprecise inputs systems (g.Style.TouchExtraPadding)
2349
-static bool IsMouseHoveringBox(const ImGuiAabb& box)
2361
+static bool IsMouseHoveringBox(const ImGuiAabb& bb)
2350
 {
2362
 {
2351
     ImGuiState& g = *GImGui;
2363
     ImGuiState& g = *GImGui;
2352
     ImGuiWindow* window = GetCurrentWindow();
2364
     ImGuiWindow* window = GetCurrentWindow();
2353
 
2365
 
2354
     // Clip
2366
     // Clip
2355
-    ImGuiAabb box_clipped = box;
2367
+    ImGuiAabb box_clipped = bb;
2356
     if (!window->ClipRectStack.empty())
2368
     if (!window->ClipRectStack.empty())
2357
     {
2369
     {
2358
         const ImVec4 clip_rect = window->ClipRectStack.back();
2370
         const ImVec4 clip_rect = window->ClipRectStack.back();
2603
 
2615
 
2604
 static ImGuiWindow* FindWindowByName(const char* name)
2616
 static ImGuiWindow* FindWindowByName(const char* name)
2605
 {
2617
 {
2606
-    // FIXME-OPT: Consider optimizing this (e.g. sorted hashes to window pointers)
2618
+    // FIXME-OPT: Store sorted hashes -> pointers.
2619
+    ImGuiID id = ImCrc32(name, 0, 0);
2607
     ImGuiState& g = *GImGui;
2620
     ImGuiState& g = *GImGui;
2608
-    for (size_t i = 0; i != g.Windows.size(); i++)
2609
-        if (strcmp(g.Windows[i]->Name, name) == 0)
2621
+    for (size_t i = 0; i < g.Windows.size(); i++)
2622
+        if (g.Windows[i]->ID == id)
2610
             return g.Windows[i];
2623
             return g.Windows[i];
2611
     return NULL;
2624
     return NULL;
2612
 }
2625
 }
2639
         }
2652
         }
2640
         else
2653
         else
2641
         {
2654
         {
2642
-            window->SetWindowPosAllowFlags &= ~ImGuiSetCondition_FirstUseEver;
2643
-            window->SetWindowSizeAllowFlags &= ~ImGuiSetCondition_FirstUseEver;
2644
-            window->SetWindowCollapsedAllowFlags &= ~ImGuiSetCondition_FirstUseEver;
2655
+            window->SetWindowPosAllowFlags &= ~ImGuiSetCond_FirstUseEver;
2656
+            window->SetWindowSizeAllowFlags &= ~ImGuiSetCond_FirstUseEver;
2657
+            window->SetWindowCollapsedAllowFlags &= ~ImGuiSetCond_FirstUseEver;
2645
         }
2658
         }
2646
 
2659
 
2647
         if (settings->Pos.x != FLT_MAX)
2660
         if (settings->Pos.x != FLT_MAX)
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.
2679
 // - 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.
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.
2680
 // - 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.
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.
2681
 // - 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.
2669
-// - Passing non-zero 'size' is roughly equivalent to calling SetNextWindowSize(size, ImGuiSetCondition_FirstUseEver) prior to calling Begin().
2682
+// - Passing non-zero 'size' is roughly equivalent to calling SetNextWindowSize(size, ImGuiSetCond_FirstUseEver) prior to calling Begin().
2670
 bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size, float bg_alpha, ImGuiWindowFlags flags)
2683
 bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size, float bg_alpha, ImGuiWindowFlags flags)
2671
 {
2684
 {
2672
     ImGuiState& g = *GImGui;
2685
     ImGuiState& g = *GImGui;
2704
         ImGui::SetWindowCollapsed(g.SetNextWindowCollapsedVal, g.SetNextWindowCollapsedCond);
2717
         ImGui::SetWindowCollapsed(g.SetNextWindowCollapsedVal, g.SetNextWindowCollapsedCond);
2705
         g.SetNextWindowCollapsedCond = 0;
2718
         g.SetNextWindowCollapsedCond = 0;
2706
     }
2719
     }
2720
+    if (g.SetNextWindowFocus)
2721
+    {
2722
+        ImGui::SetWindowFocus();
2723
+        g.SetNextWindowFocus = false;
2724
+    }
2707
 
2725
 
2708
     // Find parent
2726
     // Find parent
2709
     ImGuiWindow* parent_window = (flags & ImGuiWindowFlags_ChildWindow) != 0 ? g.CurrentWindowStack[g.CurrentWindowStack.size()-2] : NULL;
2727
     ImGuiWindow* parent_window = (flags & ImGuiWindowFlags_ChildWindow) != 0 ? g.CurrentWindowStack[g.CurrentWindowStack.size()-2] : NULL;
2710
 
2728
 
2711
-    // Find root (if we are a child window)
2729
+    // Update known root window (if we are a child window, otherwise window == window->RootWindow)
2712
     size_t root_idx = g.CurrentWindowStack.size() - 1;
2730
     size_t root_idx = g.CurrentWindowStack.size() - 1;
2713
     while (root_idx > 0)
2731
     while (root_idx > 0)
2714
     {
2732
     {
2763
         window->IDStack.resize(0);
2781
         window->IDStack.resize(0);
2764
         ImGui::PushID(window);
2782
         ImGui::PushID(window);
2765
 
2783
 
2766
-        // Move window (at the beginning of the frame to avoid input lag or sheering)
2784
+        // Move window (at the beginning of the frame to avoid input lag or sheering). Only valid for root windows.
2767
         const ImGuiID move_id = window->GetID("#MOVE");
2785
         const ImGuiID move_id = window->GetID("#MOVE");
2768
         RegisterAliveId(move_id);
2786
         RegisterAliveId(move_id);
2769
         if (g.ActiveId == move_id)
2787
         if (g.ActiveId == move_id)
2776
                     if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings))
2794
                     if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings))
2777
                         MarkSettingsDirty();
2795
                         MarkSettingsDirty();
2778
                 }
2796
                 }
2779
-                FocusWindow(window);
2797
+                IM_ASSERT(g.MovedWindow != NULL);
2798
+                FocusWindow(g.MovedWindow);
2780
             }
2799
             }
2781
             else
2800
             else
2782
             {
2801
             {
2783
                 SetActiveId(0);
2802
                 SetActiveId(0);
2803
+                g.MovedWindow = NULL;   // Not strictly necessary but doing it for sanity.
2784
             }
2804
             }
2785
         }
2805
         }
2786
 
2806
 
3028
         window->DC.ColumnsCellMinY = window->DC.ColumnsCellMaxY = window->DC.ColumnsStartPos.y;
3048
         window->DC.ColumnsCellMinY = window->DC.ColumnsCellMaxY = window->DC.ColumnsStartPos.y;
3029
         window->DC.TreeDepth = 0;
3049
         window->DC.TreeDepth = 0;
3030
         window->DC.StateStorage = &window->StateStorage;
3050
         window->DC.StateStorage = &window->StateStorage;
3031
-        window->DC.OpenNextNode = -1;
3032
 
3051
 
3033
         // Reset contents size for auto-fitting
3052
         // Reset contents size for auto-fitting
3034
         window->SizeContentsFit = ImVec2(0.0f, 0.0f);
3053
         window->SizeContentsFit = ImVec2(0.0f, 0.0f);
3108
         ImGui::LogFinish();
3127
         ImGui::LogFinish();
3109
 
3128
 
3110
     // Pop
3129
     // Pop
3111
-    // NB: we don't clear 'window->RootWindow' yet, it will be used then cleared in NewFrame()
3130
+    // NB: we don't clear 'window->RootWindow'. The pointer is allowed to live until the next call to Begin().
3112
     g.CurrentWindowStack.pop_back();
3131
     g.CurrentWindowStack.pop_back();
3113
     g.CurrentWindow = g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back();
3132
     g.CurrentWindow = g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back();
3114
 }
3133
 }
3117
 static void FocusWindow(ImGuiWindow* window)
3136
 static void FocusWindow(ImGuiWindow* window)
3118
 {
3137
 {
3119
     ImGuiState& g = *GImGui;
3138
     ImGuiState& g = *GImGui;
3139
+
3140
+    // Always mark the window we passed as focused. This is used for keyboard interactions such as tabbing.
3120
     g.FocusedWindow = window;
3141
     g.FocusedWindow = window;
3121
 
3142
 
3143
+    // And move its root window to the top of the pile 
3144
+    if (window->RootWindow)
3145
+        window = window->RootWindow;
3146
+
3122
     if (g.Windows.back() == window)
3147
     if (g.Windows.back() == window)
3123
         return;
3148
         return;
3124
 
3149
 
3379
     return window->Pos;
3404
     return window->Pos;
3380
 }
3405
 }
3381
 
3406
 
3382
-void ImGui::SetWindowPos(const ImVec2& pos, ImGuiSetCondition cond)
3407
+static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiSetCond cond)
3383
 {
3408
 {
3384
-    ImGuiWindow* window = GetCurrentWindow();
3385
-
3386
     // Test condition (NB: bit 0 is always true) and clear flags for next time
3409
     // Test condition (NB: bit 0 is always true) and clear flags for next time
3387
     if (cond && (window->SetWindowPosAllowFlags & cond) == 0)
3410
     if (cond && (window->SetWindowPosAllowFlags & cond) == 0)
3388
         return;
3411
         return;
3389
-    window->SetWindowPosAllowFlags &= ~(ImGuiSetCondition_FirstUseThisSession | ImGuiSetCondition_FirstUseEver);
3412
+    window->SetWindowPosAllowFlags &= ~(ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver);
3390
 
3413
 
3391
     // Set
3414
     // Set
3392
     const ImVec2 old_pos = window->Pos;
3415
     const ImVec2 old_pos = window->Pos;
3395
     window->DC.CursorPos += (window->Pos - old_pos);  // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor
3418
     window->DC.CursorPos += (window->Pos - old_pos);  // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor
3396
 }
3419
 }
3397
 
3420
 
3398
-ImVec2 ImGui::GetWindowSize()
3421
+void ImGui::SetWindowPos(const ImVec2& pos, ImGuiSetCond cond)
3399
 {
3422
 {
3400
     ImGuiWindow* window = GetCurrentWindow();
3423
     ImGuiWindow* window = GetCurrentWindow();
3401
-    return window->Size;
3424
+    SetWindowPos(window, pos, cond);
3425
+}
3426
+
3427
+void ImGui::SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond)
3428
+{
3429
+    ImGuiWindow* window = FindWindowByName(name);
3430
+    if (window)
3431
+        SetWindowPos(window, pos, cond);
3402
 }
3432
 }
3403
 
3433
 
3404
-void ImGui::SetWindowSize(const ImVec2& size, ImGuiSetCondition cond)
3434
+ImVec2 ImGui::GetWindowSize()
3405
 {
3435
 {
3406
     ImGuiWindow* window = GetCurrentWindow();
3436
     ImGuiWindow* window = GetCurrentWindow();
3437
+    return window->Size;
3438
+}
3407
 
3439
 
3440
+static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiSetCond cond)
3441
+{
3408
     // Test condition (NB: bit 0 is always true) and clear flags for next time
3442
     // Test condition (NB: bit 0 is always true) and clear flags for next time
3409
     if (cond && (window->SetWindowSizeAllowFlags & cond) == 0)
3443
     if (cond && (window->SetWindowSizeAllowFlags & cond) == 0)
3410
         return;
3444
         return;
3411
-    window->SetWindowSizeAllowFlags &= ~(ImGuiSetCondition_FirstUseThisSession | ImGuiSetCondition_FirstUseEver);
3445
+    window->SetWindowSizeAllowFlags &= ~(ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver);
3412
 
3446
 
3413
     // Set
3447
     // Set
3414
     if (ImLengthSqr(size) > 0.00001f)
3448
     if (ImLengthSqr(size) > 0.00001f)
3424
     }
3458
     }
3425
 }
3459
 }
3426
 
3460
 
3427
-void ImGui::SetWindowCollapsed(bool collapsed, ImGuiSetCondition cond)
3461
+void ImGui::SetWindowSize(const ImVec2& size, ImGuiSetCond cond)
3428
 {
3462
 {
3429
     ImGuiWindow* window = GetCurrentWindow();
3463
     ImGuiWindow* window = GetCurrentWindow();
3464
+    SetWindowSize(window, size, cond);
3465
+}
3430
 
3466
 
3467
+void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCond cond)
3468
+{
3469
+    ImGuiWindow* window = FindWindowByName(name);
3470
+    if (window)
3471
+        SetWindowSize(window, size, cond);
3472
+}
3473
+
3474
+static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiSetCond cond)
3475
+{
3431
     // Test condition (NB: bit 0 is always true) and clear flags for next time
3476
     // Test condition (NB: bit 0 is always true) and clear flags for next time
3432
     if (cond && (window->SetWindowCollapsedAllowFlags & cond) == 0)
3477
     if (cond && (window->SetWindowCollapsedAllowFlags & cond) == 0)
3433
         return;
3478
         return;
3434
-    window->SetWindowCollapsedAllowFlags &= ~(ImGuiSetCondition_FirstUseThisSession | ImGuiSetCondition_FirstUseEver);
3479
+    window->SetWindowCollapsedAllowFlags &= ~(ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver);
3435
 
3480
 
3436
     // Set
3481
     // Set
3437
     window->Collapsed = collapsed;
3482
     window->Collapsed = collapsed;
3438
 }
3483
 }
3439
 
3484
 
3440
-void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiSetCondition cond)
3485
+void ImGui::SetWindowCollapsed(bool collapsed, ImGuiSetCond cond)
3486
+{
3487
+    ImGuiWindow* window = GetCurrentWindow();
3488
+    SetWindowCollapsed(window, collapsed, cond);
3489
+}
3490
+
3491
+bool ImGui::GetWindowCollapsed()
3492
+{
3493
+    ImGuiWindow* window = GetCurrentWindow();
3494
+    return window->Collapsed;
3495
+}
3496
+
3497
+void ImGui::SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCond cond)
3498
+{
3499
+    ImGuiWindow* window = FindWindowByName(name);
3500
+    if (window)
3501
+        SetWindowCollapsed(window, collapsed, cond);
3502
+}
3503
+
3504
+void ImGui::SetWindowFocus()
3505
+{
3506
+    ImGuiWindow* window = GetCurrentWindow();
3507
+    FocusWindow(window);
3508
+}
3509
+
3510
+void ImGui::SetWindowFocus(const char* name)
3511
+{
3512
+    ImGuiWindow* window = FindWindowByName(name);
3513
+    if (window)
3514
+        FocusWindow(window);
3515
+}
3516
+
3517
+void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond)
3441
 {
3518
 {
3442
     ImGuiState& g = *GImGui;
3519
     ImGuiState& g = *GImGui;
3443
     g.SetNextWindowPosVal = pos;
3520
     g.SetNextWindowPosVal = pos;
3444
-    g.SetNextWindowPosCond = cond ? cond : ImGuiSetCondition_Always;
3521
+    g.SetNextWindowPosCond = cond ? cond : ImGuiSetCond_Always;
3445
 }
3522
 }
3446
 
3523
 
3447
-void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiSetCondition cond)
3524
+void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond)
3448
 {
3525
 {
3449
     ImGuiState& g = *GImGui;
3526
     ImGuiState& g = *GImGui;
3450
     g.SetNextWindowSizeVal = size;
3527
     g.SetNextWindowSizeVal = size;
3451
-    g.SetNextWindowSizeCond = cond ? cond : ImGuiSetCondition_Always;
3528
+    g.SetNextWindowSizeCond = cond ? cond : ImGuiSetCond_Always;
3452
 }
3529
 }
3453
 
3530
 
3454
-void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiSetCondition cond)
3531
+void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond)
3455
 {
3532
 {
3456
     ImGuiState& g = *GImGui;
3533
     ImGuiState& g = *GImGui;
3457
     g.SetNextWindowCollapsedVal = collapsed;
3534
     g.SetNextWindowCollapsedVal = collapsed;
3458
-    g.SetNextWindowCollapsedCond = cond ? cond : ImGuiSetCondition_Always;
3535
+    g.SetNextWindowCollapsedCond = cond ? cond : ImGuiSetCond_Always;
3536
+}
3537
+
3538
+void ImGui::SetNextWindowFocus()
3539
+{
3540
+    ImGuiState& g = *GImGui;
3541
+    g.SetNextWindowFocus = true;
3459
 }
3542
 }
3460
 
3543
 
3461
 ImVec2 ImGui::GetContentRegionMax()
3544
 ImVec2 ImGui::GetContentRegionMax()
4145
         LogToClipboard(g.LogAutoExpandMaxDepth);
4228
         LogToClipboard(g.LogAutoExpandMaxDepth);
4146
 }
4229
 }
4147
 
4230
 
4148
-bool ImGui::CollapsingHeader(const char* label, const char* str_id, const bool display_frame, const bool default_open)
4231
+bool ImGui::CollapsingHeader(const char* label, const char* str_id, bool display_frame, bool default_open)
4149
 {
4232
 {
4150
     ImGuiState& g = *GImGui;
4233
     ImGuiState& g = *GImGui;
4151
     ImGuiWindow* window = GetCurrentWindow();
4234
     ImGuiWindow* window = GetCurrentWindow();
4161
         label = str_id;
4244
         label = str_id;
4162
     const ImGuiID id = window->GetID(str_id);
4245
     const ImGuiID id = window->GetID(str_id);
4163
 
4246
 
4164
-    // We only write to the tree storage if the user clicks
4247
+    // We only write to the tree storage if the user clicks (or explicitely use SetNextTreeNode*** functions)
4165
     ImGuiStorage* storage = window->DC.StateStorage;
4248
     ImGuiStorage* storage = window->DC.StateStorage;
4166
     bool opened;
4249
     bool opened;
4167
-    if (window->DC.OpenNextNode != -1)
4250
+    if (g.SetNextTreeNodeOpenedCond != 0)
4168
     {
4251
     {
4169
-        opened = window->DC.OpenNextNode > 0;
4170
-        storage->SetInt(id, opened);
4171
-        window->DC.OpenNextNode = -1;
4252
+        if (g.SetNextTreeNodeOpenedCond & ImGuiSetCond_Always)
4253
+        {
4254
+            opened = g.SetNextTreeNodeOpenedVal;
4255
+            storage->SetInt(id, opened);
4256
+        }
4257
+        else
4258
+        {
4259
+            // We treat ImGuiSetCondition_Once and ImGuiSetCondition_FirstUseEver the same because tree node state are not saved persistently.
4260
+            const int stored_value = storage->GetInt(id, -1);
4261
+            if (stored_value == -1)
4262
+            {
4263
+                opened = g.SetNextTreeNodeOpenedVal;
4264
+                storage->SetInt(id, opened);
4265
+            }
4266
+            else
4267
+            {
4268
+                opened = stored_value != 0;
4269
+            }
4270
+        }
4271
+        g.SetNextTreeNodeOpenedCond = 0;
4172
     }
4272
     }
4173
     else
4273
     else
4174
     {
4274
     {
4242
     return opened;
4342
     return opened;
4243
 }
4343
 }
4244
 
4344
 
4345
+void ImGui::Bullet()
4346
+{
4347
+    ImGuiState& g = *GImGui;
4348
+    ImGuiWindow* window = GetCurrentWindow();
4349
+    if (window->SkipItems)
4350
+        return;
4351
+
4352
+    const ImGuiStyle& style = g.Style;
4353
+    const float line_height = window->FontSize();
4354
+    const ImGuiAabb bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(line_height, line_height));
4355
+    ItemSize(bb);
4356
+    if (!ItemAdd(bb, NULL))
4357
+        return;
4358
+
4359
+    // Render
4360
+    const float bullet_size = line_height*0.15f;
4361
+    window->DrawList->AddCircleFilled(bb.Min + ImVec2(style.FramePadding.x + line_height*0.5f, line_height*0.5f), bullet_size, window->Color(ImGuiCol_Text));
4362
+
4363
+    // Stay on same line
4364
+    ImGui::SameLine(0, -1);
4365
+}
4366
+
4245
 // Text with a little bullet aligned to the typical tree node.
4367
 // Text with a little bullet aligned to the typical tree node.
4246
 void ImGui::BulletTextV(const char* fmt, va_list args)
4368
 void ImGui::BulletTextV(const char* fmt, va_list args)
4247
 {
4369
 {
4250
     if (window->SkipItems)
4372
     if (window->SkipItems)
4251
         return;
4373
         return;
4252
     
4374
     
4253
-    const ImGuiStyle& style = g.Style;
4254
-
4255
     static char buf[1024];
4375
     static char buf[1024];
4256
     const char* text_begin = buf;
4376
     const char* text_begin = buf;
4257
     const char* text_end = text_begin + ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
4377
     const char* text_end = text_begin + ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
4258
 
4378
 
4379
+    const ImGuiStyle& style = g.Style;
4259
     const float line_height = window->FontSize();
4380
     const float line_height = window->FontSize();
4260
     const ImVec2 text_size = CalcTextSize(text_begin, text_end, true);
4381
     const ImVec2 text_size = CalcTextSize(text_begin, text_end, true);
4261
     const ImGuiAabb bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(line_height + (text_size.x > 0.0f ? (style.FramePadding.x*2) : 0.0f),0) + text_size);  // Empty text doesn't add padding
4382
     const ImGuiAabb bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(line_height + (text_size.x > 0.0f ? (style.FramePadding.x*2) : 0.0f),0) + text_size);  // Empty text doesn't add padding
4338
     return TreeNode(str_label_id, "%s", str_label_id);
4459
     return TreeNode(str_label_id, "%s", str_label_id);
4339
 }
4460
 }
4340
 
4461
 
4341
-void ImGui::OpenNextNode(bool open)
4462
+void ImGui::SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond)
4342
 {
4463
 {
4343
-    ImGuiWindow* window = GetCurrentWindow();
4344
-    window->DC.OpenNextNode = open ? 1 : 0;
4464
+    ImGuiState& g = *GImGui;
4465
+    g.SetNextTreeNodeOpenedVal = opened;
4466
+    g.SetNextTreeNodeOpenedCond = cond ? cond : ImGuiSetCond_Always;
4345
 }
4467
 }
4346
 
4468
 
4347
 void ImGui::PushID(const char* str_id)
4469
 void ImGui::PushID(const char* str_id)
5644
         edit_state.InputCursorScreenPos = cursor_pos;
5766
         edit_state.InputCursorScreenPos = cursor_pos;
5645
     }
5767
     }
5646
 
5768
 
5647
-    RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
5769
+    if (text_size.x > 0)
5770
+        RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
5648
 
5771
 
5649
     if ((flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0)
5772
     if ((flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0)
5650
         return enter_pressed;
5773
         return enter_pressed;
5765
 
5888
 
5766
     const ImVec2 text_size = CalcTextSize(label, NULL, true);
5889
     const ImVec2 text_size = CalcTextSize(label, NULL, true);
5767
     const ImGuiAabb frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, text_size.y) + style.FramePadding*2.0f);
5890
     const ImGuiAabb frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, text_size.y) + style.FramePadding*2.0f);
5768
-    ItemSize(frame_bb);
5891
+    const ImGuiAabb bb(frame_bb.Min, frame_bb.Max + ImVec2(style.ItemInnerSpacing.x + text_size.x,0));
5892
+    ItemSize(bb);
5769
     if (!ItemAdd(frame_bb, &id))
5893
     if (!ItemAdd(frame_bb, &id))
5770
         return false;
5894
         return false;
5771
 
5895
 
5772
-    const ImGuiAabb bb(frame_bb.Min, frame_bb.Max + ImVec2(style.ItemInnerSpacing.x + text_size.x,0));
5773
     const float arrow_size = (window->FontSize() + style.FramePadding.x * 2.0f);
5896
     const float arrow_size = (window->FontSize() + style.FramePadding.x * 2.0f);
5774
     const bool hovered = IsHovered(frame_bb, id);
5897
     const bool hovered = IsHovered(frame_bb, id);
5775
 
5898
 
5786
             RenderTextClipped(frame_bb.Min + style.FramePadding, item_text, NULL, NULL, value_bb.Max);
5909
             RenderTextClipped(frame_bb.Min + style.FramePadding, item_text, NULL, NULL, value_bb.Max);
5787
     }
5910
     }
5788
 
5911
 
5789
-    // Empty text doesn't add padding
5790
     if (text_size.x > 0)
5912
     if (text_size.x > 0)
5791
-    {
5792
-        ImGui::SameLine(0, (int)style.ItemInnerSpacing.x);
5793
-        ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
5794
-    }
5913
+        RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
5795
 
5914
 
5796
     ImGui::PushID((int)id);
5915
     ImGui::PushID((int)id);
5797
     bool menu_toggled = false;
5916
     bool menu_toggled = false;
6249
     window->DC.CurrentLineHeight = 0.0f;
6368
     window->DC.CurrentLineHeight = 0.0f;
6250
 }
6369
 }
6251
 
6370
 
6252
-static void ItemSize(const ImGuiAabb& aabb, ImVec2* adjust_start_offset) 
6371
+static void ItemSize(const ImGuiAabb& bb, ImVec2* adjust_start_offset) 
6253
 { 
6372
 { 
6254
-    ItemSize(aabb.GetSize(), adjust_start_offset); 
6373
+    ItemSize(bb.GetSize(), adjust_start_offset); 
6255
 }
6374
 }
6256
 
6375
 
6257
 static bool IsClipped(const ImGuiAabb& bb)
6376
 static bool IsClipped(const ImGuiAabb& bb)
6378
     const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
6497
     const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
6379
 
6498
 
6380
     const float min_x = window->DC.ColumnsStartX;
6499
     const float min_x = window->DC.ColumnsStartX;
6381
-    const float max_x = window->Size.x - (window->ScrollbarY);// - window->WindowPadding().x;
6500
+    const float max_x = window->Size.x - (g.Style.ScrollBarWidth);// - window->WindowPadding().x;
6382
     const float t = (offset - min_x) / (max_x - min_x);
6501
     const float t = (offset - min_x) / (max_x - min_x);
6383
-    window->StateStorage.SetFloat(column_id, t);
6502
+    window->DC.StateStorage->SetFloat(column_id, t);
6384
     window->DC.ColumnsOffsetsT[column_index] = t;
6503
     window->DC.ColumnsOffsetsT[column_index] = t;
6385
 }
6504
 }
6386
 
6505
 
6473
             const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
6592
             const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
6474
             RegisterAliveId(column_id);
6593
             RegisterAliveId(column_id);
6475
             const float default_t = column_index / (float)window->DC.ColumnsCount;
6594
             const float default_t = column_index / (float)window->DC.ColumnsCount;
6476
-            const float t = window->StateStorage.GetFloat(column_id, default_t);      // Cheaply store our floating point value inside the integer (could store an union into the map?)
6595
+            const float t = window->DC.StateStorage->GetFloat(column_id, default_t);      // Cheaply store our floating point value inside the integer (could store an union into the map?)
6477
             window->DC.ColumnsOffsetsT[column_index] = t;
6596
             window->DC.ColumnsOffsetsT[column_index] = t;
6478
         }
6597
         }
6479
 
6598
 
7361
     static const ImWchar ranges[] =
7480
     static const ImWchar ranges[] =
7362
     {
7481
     {
7363
         0x0020, 0x00FF, // Basic Latin + Latin Supplement
7482
         0x0020, 0x00FF, // Basic Latin + Latin Supplement
7364
-        0x3040, 0x309F, // Hiragana, Katakana
7483
+        0x3000, 0x3000, // Ideographic Space
7484
+        0x3040, 0x30FF, // Hiragana, Katakana
7485
+        0x31F0, 0x31FF, // Katakana Phonetic Extensions
7365
         0xFF00, 0xFFEF, // Half-width characters
7486
         0xFF00, 0xFFEF, // Half-width characters
7366
         0x4e00, 0x9FAF, // CJK Ideograms
7487
         0x4e00, 0x9FAF, // CJK Ideograms
7367
         0,
7488
         0,
7409
         109,2,18,23,0,0,9,61,3,0,28,41,77,27,19,17,81,5,2,14,5,83,57,252,14,154,263,14,20,8,13,6,57,39,38,
7530
         109,2,18,23,0,0,9,61,3,0,28,41,77,27,19,17,81,5,2,14,5,83,57,252,14,154,263,14,20,8,13,6,57,39,38,
7410
     };
7531
     };
7411
     static int ranges_unpacked = false;
7532
     static int ranges_unpacked = false;
7412
-    static ImWchar ranges[6 + 1 + IM_ARRAYSIZE(offsets_from_0x4E00)*2] =
7533
+    static ImWchar ranges[10 + IM_ARRAYSIZE(offsets_from_0x4E00)*2 + 1] =
7413
     {
7534
     {
7414
         0x0020, 0x00FF, // Basic Latin + Latin Supplement
7535
         0x0020, 0x00FF, // Basic Latin + Latin Supplement
7415
-        0x3040, 0x309F, // Hiragana, Katakana
7536
+        0x3000, 0x3000, // Ideographic Space
7537
+        0x3040, 0x30FF, // Hiragana, Katakana
7538
+        0x31F0, 0x31FF, // Katakana Phonetic Extensions
7416
         0xFF00, 0xFFEF, // Half-width characters
7539
         0xFF00, 0xFFEF, // Half-width characters
7417
-        0, 
7418
     };
7540
     };
7419
     if (!ranges_unpacked)
7541
     if (!ranges_unpacked)
7420
     {
7542
     {
7421
         // Unpack
7543
         // Unpack
7422
         int codepoint = 0x4e00;
7544
         int codepoint = 0x4e00;
7423
-        ImWchar* dst = &ranges[6];
7545
+        ImWchar* dst = &ranges[10];
7424
         for (int n = 0; n < IM_ARRAYSIZE(offsets_from_0x4E00); n++, dst += 2)
7546
         for (int n = 0; n < IM_ARRAYSIZE(offsets_from_0x4E00); n++, dst += 2)
7425
             dst[0] = dst[1] = (ImWchar)(codepoint += (offsets_from_0x4E00[n] + 1));
7547
             dst[0] = dst[1] = (ImWchar)(codepoint += (offsets_from_0x4E00[n] + 1));
7426
         dst[0] = 0;
7548
         dst[0] = 0;
7453
 
7575
 
7454
     // Create a glyph to handle TAB
7576
     // Create a glyph to handle TAB
7455
     // FIXME: Needs proper TAB handling but it needs to be contextualized (can arbitrary say that each string starts at "column 0"
7577
     // FIXME: Needs proper TAB handling but it needs to be contextualized (can arbitrary say that each string starts at "column 0"
7456
-    if (const ImFont::Glyph* space_glyph = FindGlyph((unsigned short)' '))
7578
+    if (FindGlyph((unsigned short)' '))
7457
     {
7579
     {
7458
         Glyphs.resize(Glyphs.size() + 1);
7580
         Glyphs.resize(Glyphs.size() + 1);
7459
         ImFont::Glyph& tab_glyph = Glyphs.back();
7581
         ImFont::Glyph& tab_glyph = Glyphs.back();
8302
         {
8424
         {
8303
             ImGui::BulletText("Bullet point 1");
8425
             ImGui::BulletText("Bullet point 1");
8304
             ImGui::BulletText("Bullet point 2\nOn multiple lines");
8426
             ImGui::BulletText("Bullet point 2\nOn multiple lines");
8305
-            ImGui::BulletText("Bullet point 3");
8427
+            ImGui::Bullet(); ImGui::Text("Bullet point 3 (two calls)");
8428
+            ImGui::Bullet(); ImGui::SmallButton("Button 1");
8429
+            ImGui::Bullet(); ImGui::SmallButton("Button 2");
8306
             ImGui::TreePop();
8430
             ImGui::TreePop();
8307
         }
8431
         }
8308
 
8432
 
8554
         ImGui::ColorEdit4("color 2", col2);
8678
         ImGui::ColorEdit4("color 2", col2);
8555
 
8679
 
8556
         const char* listbox_items[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" };
8680
         const char* listbox_items[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" };
8557
-        static int listbox_item_current = 1, listbox_item_current2 = 2;
8681
+        static int listbox_item_current = 1;
8558
         ImGui::ListBox("listbox\n(single select)", &listbox_item_current, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
8682
         ImGui::ListBox("listbox\n(single select)", &listbox_item_current, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
8559
 
8683
 
8684
+        //static int listbox_item_current2 = 2;
8560
         //ImGui::PushItemWidth(-1);
8685
         //ImGui::PushItemWidth(-1);
8561
         //ImGui::ListBox("##listbox2", &listbox_item_current2, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
8686
         //ImGui::ListBox("##listbox2", &listbox_item_current2, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
8562
         //ImGui::PopItemWidth();
8687
         //ImGui::PopItemWidth();
8623
         // SliderFloat
8748
         // SliderFloat
8624
         static float f0=1.0f, f1=2.0f, f2=3.0f;
8749
         static float f0=1.0f, f1=2.0f, f2=3.0f;
8625
         ImGui::PushItemWidth(80);
8750
         ImGui::PushItemWidth(80);
8751
+        const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD" };
8752
+        static int item = -1;
8753
+        ImGui::Combo("Combo", &item, items, IM_ARRAYSIZE(items));
8754
+        //ImGui::SameLine();
8755
+        //ImGui::ListBox("Listbox", &item, items, IM_ARRAYSIZE(items));
8756
+        //if (ImGui::IsItemHovered())
8757
+        //    ImGui::SetTooltip("Hovered"); 
8758
+        ImGui::SameLine(); 
8626
         ImGui::SliderFloat("X", &f0, 0.0f,5.0f);
8759
         ImGui::SliderFloat("X", &f0, 0.0f,5.0f);
8627
         ImGui::SameLine();
8760
         ImGui::SameLine();
8628
         ImGui::SliderFloat("Y", &f1, 0.0f,5.0f);
8761
         ImGui::SliderFloat("Y", &f1, 0.0f,5.0f);

+ 29
- 16
src/deps/imgui/imgui.h View File

1
-// ImGui library v1.33
1
+// ImGui library v1.35 wip
2
 // See .cpp file for documentation.
2
 // See .cpp file for documentation.
3
 // See ImGui::ShowTestWindow() for sample code.
3
 // See ImGui::ShowTestWindow() for sample code.
4
 // Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
4
 // Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
23
 #include <stdlib.h>         // NULL, malloc
23
 #include <stdlib.h>         // NULL, malloc
24
 #include <string.h>         // memset, memmove
24
 #include <string.h>         // memset, memmove
25
 
25
 
26
+// Define assertion handler.
26
 #ifndef IM_ASSERT
27
 #ifndef IM_ASSERT
27
 #include <assert.h>
28
 #include <assert.h>
28
 #define IM_ASSERT(_EXPR)    assert(_EXPR)
29
 #define IM_ASSERT(_EXPR)    assert(_EXPR)
29
 #endif
30
 #endif
30
 
31
 
32
+// Define attributes of all API symbols declarations, e.g. for DLL under Windows.
31
 #ifndef IMGUI_API
33
 #ifndef IMGUI_API
32
 #define IMGUI_API
34
 #define IMGUI_API
33
 #endif
35
 #endif
41
 typedef int ImGuiKey;               // enum ImGuiKey_
43
 typedef int ImGuiKey;               // enum ImGuiKey_
42
 typedef int ImGuiColorEditMode;     // enum ImGuiColorEditMode_
44
 typedef int ImGuiColorEditMode;     // enum ImGuiColorEditMode_
43
 typedef int ImGuiWindowFlags;       // enum ImGuiWindowFlags_
45
 typedef int ImGuiWindowFlags;       // enum ImGuiWindowFlags_
44
-typedef int ImGuiSetCondition;      // enum ImGuiSetCondition_
46
+typedef int ImGuiSetCond;           // enum ImGuiSetCondition_
45
 typedef int ImGuiInputTextFlags;    // enum ImGuiInputTextFlags_
47
 typedef int ImGuiInputTextFlags;    // enum ImGuiInputTextFlags_
46
 struct ImGuiTextEditCallbackData;   // for advanced uses of InputText() 
48
 struct ImGuiTextEditCallbackData;   // for advanced uses of InputText() 
47
 typedef int (*ImGuiTextEditCallback)(ImGuiTextEditCallbackData *data);
49
 typedef int (*ImGuiTextEditCallback)(ImGuiTextEditCallbackData *data);
175
     IMGUI_API ImVec2        GetWindowSize();                                                    // get current window position.
177
     IMGUI_API ImVec2        GetWindowSize();                                                    // get current window position.
176
     IMGUI_API float         GetWindowWidth();
178
     IMGUI_API float         GetWindowWidth();
177
     IMGUI_API bool          GetWindowCollapsed();
179
     IMGUI_API bool          GetWindowCollapsed();
178
-    IMGUI_API void          SetNextWindowPos(const ImVec2& pos, ImGuiSetCondition cond = 0);    // set next window position - call before Begin().
179
-    IMGUI_API void          SetNextWindowSize(const ImVec2& size, ImGuiSetCondition cond = 0);  // set next window size. set to ImVec2(0,0) to force an auto-fit.
180
-    IMGUI_API void          SetNextWindowCollapsed(bool collapsed, ImGuiSetCondition cond = 0); // set next window collapsed state.
181
-    IMGUI_API void          SetWindowPos(const ImVec2& pos, ImGuiSetCondition cond = 0);        // set current window position - call within Begin()/End(). may incur tearing.
182
-    IMGUI_API void          SetWindowSize(const ImVec2& size, ImGuiSetCondition cond = 0);      // set current window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing.
183
-    IMGUI_API void          SetWindowCollapsed(bool collapsed, ImGuiSetCondition cond = 0);     // set current window collapsed state.
180
+
181
+    IMGUI_API void          SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0);         // set next window position - call before Begin().
182
+    IMGUI_API void          SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond = 0);       // set next window size. set to ImVec2(0,0) to force an auto-fit.
183
+    IMGUI_API void          SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0);      // set next window collapsed state.
184
+    IMGUI_API void          SetNextWindowFocus();                                               // set next window to be focused / front-most
185
+    IMGUI_API void          SetWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0);             // set current window position - call within Begin()/End(). may incur tearing.
186
+    IMGUI_API void          SetWindowSize(const ImVec2& size, ImGuiSetCond cond = 0);           // set current window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing.
187
+    IMGUI_API void          SetWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0);          // set current window collapsed state.
188
+    IMGUI_API void          SetWindowFocus();                                                   // set current window to be focused / front-most
189
+    IMGUI_API void          SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond = 0);      // set named window position - call within Begin()/End(). may incur tearing.
190
+    IMGUI_API void          SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCond cond = 0);    // set named window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing.
191
+    IMGUI_API void          SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCond cond = 0);   // set named window collapsed state.
192
+    IMGUI_API void          SetWindowFocus(const char* name);                                              // set named window to be focused / front-most
184
 
193
 
185
     IMGUI_API void          SetScrollPosHere();                                                 // adjust scrolling position to center into the current cursor position.
194
     IMGUI_API void          SetScrollPosHere();                                                 // adjust scrolling position to center into the current cursor position.
186
     IMGUI_API void          SetKeyboardFocusHere(int offset = 0);                               // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget.
195
     IMGUI_API void          SetKeyboardFocusHere(int offset = 0);                               // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget.
252
     IMGUI_API void          TextUnformatted(const char* text, const char* text_end = NULL);     // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, recommended for long chunks of text.
261
     IMGUI_API void          TextUnformatted(const char* text, const char* text_end = NULL);     // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, recommended for long chunks of text.
253
     IMGUI_API void          LabelText(const char* label, const char* fmt, ...);                 // display text+label aligned the same way as value+label widgets 
262
     IMGUI_API void          LabelText(const char* label, const char* fmt, ...);                 // display text+label aligned the same way as value+label widgets 
254
     IMGUI_API void          LabelTextV(const char* label, const char* fmt, va_list args);
263
     IMGUI_API void          LabelTextV(const char* label, const char* fmt, va_list args);
264
+    IMGUI_API void          Bullet();
255
     IMGUI_API void          BulletText(const char* fmt, ...);
265
     IMGUI_API void          BulletText(const char* fmt, ...);
256
     IMGUI_API void          BulletTextV(const char* fmt, va_list args);
266
     IMGUI_API void          BulletTextV(const char* fmt, va_list args);
257
     IMGUI_API bool          Button(const char* label, const ImVec2& size = ImVec2(0,0), bool repeat_when_held = false);
267
     IMGUI_API bool          Button(const char* label, const ImVec2& size = ImVec2(0,0), bool repeat_when_held = false);
259
     IMGUI_API bool          InvisibleButton(const char* str_id, const ImVec2& size);
269
     IMGUI_API bool          InvisibleButton(const char* str_id, const ImVec2& size);
260
     IMGUI_API void          Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
270
     IMGUI_API void          Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
261
     IMGUI_API bool          ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0),  const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,1), const ImVec4& tint_col = ImVec4(1,1,1,1));    // <0 frame_padding uses default frame padding settings. 0 for no paddnig.
271
     IMGUI_API bool          ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0),  const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,1), const ImVec4& tint_col = ImVec4(1,1,1,1));    // <0 frame_padding uses default frame padding settings. 0 for no paddnig.
262
-    IMGUI_API bool          CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
272
+    IMGUI_API bool          CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false);
263
     IMGUI_API bool          SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);     // adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders.
273
     IMGUI_API bool          SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);     // adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders.
264
     IMGUI_API bool          SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
274
     IMGUI_API bool          SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
265
     IMGUI_API bool          SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
275
     IMGUI_API bool          SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
290
     IMGUI_API bool          ColorEdit3(const char* label, float col[3]);
300
     IMGUI_API bool          ColorEdit3(const char* label, float col[3]);
291
     IMGUI_API bool          ColorEdit4(const char* label, float col[4], bool show_alpha = true);
301
     IMGUI_API bool          ColorEdit4(const char* label, float col[4], bool show_alpha = true);
292
     IMGUI_API void          ColorEditMode(ImGuiColorEditMode mode);
302
     IMGUI_API void          ColorEditMode(ImGuiColorEditMode mode);
303
+
304
+    // Trees
293
     IMGUI_API bool          TreeNode(const char* str_label_id);                                 // if returning 'true' the node is open and the user is responsible for calling TreePop
305
     IMGUI_API bool          TreeNode(const char* str_label_id);                                 // if returning 'true' the node is open and the user is responsible for calling TreePop
294
     IMGUI_API bool          TreeNode(const char* str_id, const char* fmt, ...);                 // "
306
     IMGUI_API bool          TreeNode(const char* str_id, const char* fmt, ...);                 // "
295
     IMGUI_API bool          TreeNode(const void* ptr_id, const char* fmt, ...);                 // "
307
     IMGUI_API bool          TreeNode(const void* ptr_id, const char* fmt, ...);                 // "
298
     IMGUI_API void          TreePush(const char* str_id = NULL);                                // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose
310
     IMGUI_API void          TreePush(const char* str_id = NULL);                                // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose
299
     IMGUI_API void          TreePush(const void* ptr_id = NULL);                                // "
311
     IMGUI_API void          TreePush(const void* ptr_id = NULL);                                // "
300
     IMGUI_API void          TreePop();
312
     IMGUI_API void          TreePop();
301
-    IMGUI_API void          OpenNextNode(bool open);                                            // force open/close the next TreeNode or CollapsingHeader
313
+    IMGUI_API void          SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond = 0);          // set next tree node to be opened.
302
 
314
 
303
     // Selectable / Lists
315
     // Selectable / Lists
304
     IMGUI_API bool          Selectable(const char* label, bool selected, const ImVec2& size = ImVec2(0,0));
316
     IMGUI_API bool          Selectable(const char* label, bool selected, const ImVec2& size = ImVec2(0,0));
360
 
372
 
361
     // Obsolete (will be removed)
373
     // Obsolete (will be removed)
362
     IMGUI_API void          GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size);
374
     IMGUI_API void          GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size);
375
+    static inline void      OpenNextNode(bool open) { ImGui::SetNextTreeNodeOpened(open, 0); }
363
 
376
 
364
 } // namespace ImGui
377
 } // namespace ImGui
365
 
378
 
493
     ImGuiColorEditMode_HEX = 2
506
     ImGuiColorEditMode_HEX = 2
494
 };
507
 };
495
 
508
 
496
-// Condition flags for ImGui::SetWindow***() and SetNextWindow***() functions
497
-// Those functions treat 0 as a shortcut to ImGuiSetCondition_Always
498
-enum ImGuiSetCondition_
509
+// Condition flags for ImGui::SetWindow***(), SetNextWindow***(), SetNextTreeNode***() functions
510
+// All those functions treat 0 as a shortcut to ImGuiSetCond_Always
511
+enum ImGuiSetCond_
499
 {
512
 {
500
-    ImGuiSetCondition_Always              = 1 << 0, // Set the variable
501
-    ImGuiSetCondition_FirstUseThisSession = 1 << 1, // Only set the variable on the first call per runtime session
502
-    ImGuiSetCondition_FirstUseEver        = 1 << 2  // Only set the variable if the window doesn't exist in the .ini file
513
+    ImGuiSetCond_Always        = 1 << 0, // Set the variable
514
+    ImGuiSetCond_Once          = 1 << 1, // Only set the variable on the first call per runtime session
515
+    ImGuiSetCond_FirstUseEver  = 1 << 2  // Only set the variable if the window doesn't exist in the .ini file
503
 };
516
 };
504
 
517
 
505
 struct ImGuiStyle
518
 struct ImGuiStyle

Loading…
Cancel
Save