Selaa lähdekoodia

Updated imgui to v1.35 wip

Thomas Buck 9 vuotta sitten
vanhempi
commit
ce2b8c05d7
4 muutettua tiedostoa jossa 249 lisäystä ja 98 poistoa
  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 Näytä tiedosto

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

+ 5
- 1
src/deps/imgui/imconfig.h Näytä tiedosto

@@ -15,6 +15,10 @@
15 15
 #include "global.h"
16 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 22
 //---- Don't implement default clipboard handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions)
19 23
 //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS
20 24
 
@@ -37,7 +41,7 @@
37 41
 
38 42
 //---- Freely implement extra functions within the ImGui:: namespace.
39 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 46
 namespace ImGui
43 47
 {

+ 214
- 81
src/deps/imgui/imgui.cpp Näytä tiedosto

@@ -1,4 +1,4 @@
1
-// ImGui library v1.33
1
+// ImGui library v1.35 wip
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
@@ -129,6 +129,8 @@
129 129
  Occasionally introducing changes that are breaking the API. The breakage are generally minor and easy to fix.
130 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 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 135
  - 2015/02/10 (1.32) - renamed GetItemWidth() to CalcItemWidth() to clarify its evolving behavior
134 136
  - 2015/02/08 (1.31) - renamed GetTextLineSpacing() to GetTextLineHeightWithSpacing()
@@ -289,7 +291,6 @@
289 291
  - text edit: flag to disable live update of the user buffer. 
290 292
  - text edit: field resize behavior - field could stretch when being edited? hover tooltip shows more text?
291 293
  - text edit: add multi-line text edit
292
- - tree: reformulate OpenNextNode() into SetNextWindowCollapsed() api
293 294
  - tree: add treenode/treepush int variants? because (void*) cast from int warns on some platforms/settings
294 295
  - settings: write more decent code to allow saving/loading new fields
295 296
  - settings: api for per-tool simple persistent data (bool,int,float) in .ini file
@@ -416,13 +417,13 @@ static void         RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool
416 417
 static void         RenderCollapseTriangle(ImVec2 p_min, bool opened, float scale = 1.0f, bool shadow = false);
417 418
 
418 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 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 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 427
 static bool         IsKeyPressedMap(ImGuiKey key, bool repeat = true);
427 428
 
428 429
 static bool         CloseWindowButton(bool* p_opened = NULL);
@@ -889,7 +890,6 @@ struct ImGuiDrawContext
889 890
     ImVector<float>         TextWrapPos;
890 891
     ImGuiColorEditMode      ColorEditMode;
891 892
     ImGuiStorage*           StateStorage;
892
-    int                     OpenNextNode;        // FIXME: Reformulate this feature like SetNextWindowCollapsed() API
893 893
 
894 894
     float                   ColumnsStartX;       // Start position from left of window (increased by TreePush/TreePop, etc.)
895 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,7 +912,6 @@ struct ImGuiDrawContext
912 912
         LastItemAabb = ImGuiAabb(0.0f,0.0f,0.0f,0.0f);
913 913
         LastItemHovered = false;
914 914
         StateStorage = NULL;
915
-        OpenNextNode = -1;
916 915
 
917 916
         ColumnsStartX = 0.0f;
918 917
         ColumnsOffsetX = 0.0f;
@@ -994,17 +993,22 @@ struct ImGuiState
994 993
     ImGuiID                 ActiveIdPreviousFrame;
995 994
     bool                    ActiveIdIsAlive;
996 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 997
     float                   SettingsDirtyTimer;
998 998
     ImVector<ImGuiIniData*> Settings;
999 999
     ImVector<ImGuiColMod>   ColorModifiers;
1000 1000
     ImVector<ImGuiStyleMod> StyleModifiers;
1001 1001
     ImVector<ImFont*>       FontStack;
1002
+
1002 1003
     ImVec2                  SetNextWindowPosVal;
1003
-    ImGuiSetCondition       SetNextWindowPosCond;
1004
+    ImGuiSetCond            SetNextWindowPosCond;
1004 1005
     ImVec2                  SetNextWindowSizeVal;
1005
-    ImGuiSetCondition       SetNextWindowSizeCond;
1006
+    ImGuiSetCond            SetNextWindowSizeCond;
1006 1007
     bool                    SetNextWindowCollapsedVal;
1007
-    ImGuiSetCondition       SetNextWindowCollapsedCond;
1008
+    ImGuiSetCond            SetNextWindowCollapsedCond;
1009
+    bool                    SetNextWindowFocus;
1010
+    bool                    SetNextTreeNodeOpenedVal;
1011
+    ImGuiSetCond            SetNextTreeNodeOpenedCond;
1008 1012
 
1009 1013
     // Render
1010 1014
     ImVector<ImDrawList*>   RenderDrawLists;
@@ -1049,13 +1053,18 @@ struct ImGuiState
1049 1053
         ActiveIdPreviousFrame = 0;
1050 1054
         ActiveIdIsAlive = false;
1051 1055
         ActiveIdIsFocusedOnly = false;
1056
+        MovedWindow = NULL;
1052 1057
         SettingsDirtyTimer = 0.0f;
1058
+
1053 1059
         SetNextWindowPosVal = ImVec2(0.0f, 0.0f);
1054 1060
         SetNextWindowPosCond = 0;
1055 1061
         SetNextWindowSizeVal = ImVec2(0.0f, 0.0f);
1056 1062
         SetNextWindowSizeCond = 0;
1057 1063
         SetNextWindowCollapsedVal = false;
1058 1064
         SetNextWindowCollapsedCond = 0;
1065
+        SetNextWindowFocus = false;
1066
+        SetNextTreeNodeOpenedVal = false;
1067
+        SetNextTreeNodeOpenedCond = 0;
1059 1068
 
1060 1069
         SliderAsInputTextId = 0;
1061 1070
         ActiveComboID = 0;
@@ -1096,9 +1105,9 @@ struct ImGuiWindow
1096 1105
     bool                    SkipItems;                          // == Visible && !Collapsed
1097 1106
     int                     AutoFitFrames;
1098 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 1112
     ImGuiDrawContext        DC;
1104 1113
     ImVector<ImGuiID>       IDStack;
@@ -1295,7 +1304,6 @@ ImGuiTextFilter::ImGuiTextFilter(const char* default_filter)
1295 1304
 
1296 1305
 void ImGuiTextFilter::Draw(const char* label, float width)
1297 1306
 {
1298
-    ImGuiWindow* window = GetCurrentWindow();
1299 1307
     if (width > 0.0f)
1300 1308
         ImGui::PushItemWidth(width);
1301 1309
     ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf));
@@ -1430,7 +1438,7 @@ ImGuiWindow::ImGuiWindow(const char* name)
1430 1438
     SkipItems = false;
1431 1439
     AutoFitFrames = -1;
1432 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 1443
     IDStack.push_back(ID);
1436 1444
     LastFrameDrawn = -1;
@@ -1761,6 +1769,8 @@ void ImGui::NewFrame()
1761 1769
         SetActiveId(0);
1762 1770
     g.ActiveIdPreviousFrame = g.ActiveId;
1763 1771
     g.ActiveIdIsAlive = false;
1772
+    if (!g.ActiveId)
1773
+        g.MovedWindow = NULL;
1764 1774
 
1765 1775
     // Delay saving settings so we don't spam disk too much
1766 1776
     if (g.SettingsDirtyTimer > 0.0f)
@@ -1835,13 +1845,11 @@ void ImGui::NewFrame()
1835 1845
     }
1836 1846
 
1837 1847
     // Mark all windows as not visible
1838
-    // Clear root windows at this point.
1839 1848
     for (size_t i = 0; i != g.Windows.size(); i++)
1840 1849
     {
1841 1850
         ImGuiWindow* window = g.Windows[i];
1842 1851
         window->Visible = false;
1843 1852
         window->Accessed = false;
1844
-        window->RootWindow = NULL;
1845 1853
     }
1846 1854
 
1847 1855
     // No window should be open at the beginning of the frame.
@@ -1972,9 +1980,13 @@ void ImGui::Render()
1972 1980
             g.CurrentWindow->Visible = false;
1973 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 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 1988
             SetActiveId(g.HoveredRootWindow->GetID("#MOVE"));
1989
+        }
1978 1990
 
1979 1991
         // Sort the window list so that all child windows are after their parent
1980 1992
         // We cannot do that on FocusWindow() because childs may not exist yet
@@ -2346,13 +2358,13 @@ static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs)
2346 2358
 // Test if mouse cursor is hovering given aabb
2347 2359
 // NB- Box is clipped by our current clip setting
2348 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 2363
     ImGuiState& g = *GImGui;
2352 2364
     ImGuiWindow* window = GetCurrentWindow();
2353 2365
 
2354 2366
     // Clip
2355
-    ImGuiAabb box_clipped = box;
2367
+    ImGuiAabb box_clipped = bb;
2356 2368
     if (!window->ClipRectStack.empty())
2357 2369
     {
2358 2370
         const ImVec4 clip_rect = window->ClipRectStack.back();
@@ -2603,10 +2615,11 @@ void ImGui::EndChildFrame()
2603 2615
 
2604 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 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 2623
             return g.Windows[i];
2611 2624
     return NULL;
2612 2625
 }
@@ -2639,9 +2652,9 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
2639 2652
         }
2640 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 2660
         if (settings->Pos.x != FLT_MAX)
@@ -2666,7 +2679,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
2666 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 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 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 2683
 bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size, float bg_alpha, ImGuiWindowFlags flags)
2671 2684
 {
2672 2685
     ImGuiState& g = *GImGui;
@@ -2704,11 +2717,16 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size, float bg
2704 2717
         ImGui::SetWindowCollapsed(g.SetNextWindowCollapsedVal, g.SetNextWindowCollapsedCond);
2705 2718
         g.SetNextWindowCollapsedCond = 0;
2706 2719
     }
2720
+    if (g.SetNextWindowFocus)
2721
+    {
2722
+        ImGui::SetWindowFocus();
2723
+        g.SetNextWindowFocus = false;
2724
+    }
2707 2725
 
2708 2726
     // Find parent
2709 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 2730
     size_t root_idx = g.CurrentWindowStack.size() - 1;
2713 2731
     while (root_idx > 0)
2714 2732
     {
@@ -2763,7 +2781,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size, float bg
2763 2781
         window->IDStack.resize(0);
2764 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 2785
         const ImGuiID move_id = window->GetID("#MOVE");
2768 2786
         RegisterAliveId(move_id);
2769 2787
         if (g.ActiveId == move_id)
@@ -2776,11 +2794,13 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size, float bg
2776 2794
                     if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings))
2777 2795
                         MarkSettingsDirty();
2778 2796
                 }
2779
-                FocusWindow(window);
2797
+                IM_ASSERT(g.MovedWindow != NULL);
2798
+                FocusWindow(g.MovedWindow);
2780 2799
             }
2781 2800
             else
2782 2801
             {
2783 2802
                 SetActiveId(0);
2803
+                g.MovedWindow = NULL;   // Not strictly necessary but doing it for sanity.
2784 2804
             }
2785 2805
         }
2786 2806
 
@@ -3028,7 +3048,6 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size, float bg
3028 3048
         window->DC.ColumnsCellMinY = window->DC.ColumnsCellMaxY = window->DC.ColumnsStartPos.y;
3029 3049
         window->DC.TreeDepth = 0;
3030 3050
         window->DC.StateStorage = &window->StateStorage;
3031
-        window->DC.OpenNextNode = -1;
3032 3051
 
3033 3052
         // Reset contents size for auto-fitting
3034 3053
         window->SizeContentsFit = ImVec2(0.0f, 0.0f);
@@ -3108,7 +3127,7 @@ void ImGui::End()
3108 3127
         ImGui::LogFinish();
3109 3128
 
3110 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 3131
     g.CurrentWindowStack.pop_back();
3113 3132
     g.CurrentWindow = g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back();
3114 3133
 }
@@ -3117,8 +3136,14 @@ void ImGui::End()
3117 3136
 static void FocusWindow(ImGuiWindow* window)
3118 3137
 {
3119 3138
     ImGuiState& g = *GImGui;
3139
+
3140
+    // Always mark the window we passed as focused. This is used for keyboard interactions such as tabbing.
3120 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 3147
     if (g.Windows.back() == window)
3123 3148
         return;
3124 3149
 
@@ -3379,14 +3404,12 @@ ImVec2 ImGui::GetWindowPos()
3379 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 3409
     // Test condition (NB: bit 0 is always true) and clear flags for next time
3387 3410
     if (cond && (window->SetWindowPosAllowFlags & cond) == 0)
3388 3411
         return;
3389
-    window->SetWindowPosAllowFlags &= ~(ImGuiSetCondition_FirstUseThisSession | ImGuiSetCondition_FirstUseEver);
3412
+    window->SetWindowPosAllowFlags &= ~(ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver);
3390 3413
 
3391 3414
     // Set
3392 3415
     const ImVec2 old_pos = window->Pos;
@@ -3395,20 +3418,31 @@ void ImGui::SetWindowPos(const ImVec2& pos, ImGuiSetCondition cond)
3395 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 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 3436
     ImGuiWindow* window = GetCurrentWindow();
3437
+    return window->Size;
3438
+}
3407 3439
 
3440
+static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiSetCond cond)
3441
+{
3408 3442
     // Test condition (NB: bit 0 is always true) and clear flags for next time
3409 3443
     if (cond && (window->SetWindowSizeAllowFlags & cond) == 0)
3410 3444
         return;
3411
-    window->SetWindowSizeAllowFlags &= ~(ImGuiSetCondition_FirstUseThisSession | ImGuiSetCondition_FirstUseEver);
3445
+    window->SetWindowSizeAllowFlags &= ~(ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver);
3412 3446
 
3413 3447
     // Set
3414 3448
     if (ImLengthSqr(size) > 0.00001f)
@@ -3424,38 +3458,87 @@ void ImGui::SetWindowSize(const ImVec2& size, ImGuiSetCondition cond)
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 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 3476
     // Test condition (NB: bit 0 is always true) and clear flags for next time
3432 3477
     if (cond && (window->SetWindowCollapsedAllowFlags & cond) == 0)
3433 3478
         return;
3434
-    window->SetWindowCollapsedAllowFlags &= ~(ImGuiSetCondition_FirstUseThisSession | ImGuiSetCondition_FirstUseEver);
3479
+    window->SetWindowCollapsedAllowFlags &= ~(ImGuiSetCond_Once | ImGuiSetCond_FirstUseEver);
3435 3480
 
3436 3481
     // Set
3437 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 3519
     ImGuiState& g = *GImGui;
3443 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 3526
     ImGuiState& g = *GImGui;
3450 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 3533
     ImGuiState& g = *GImGui;
3457 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 3544
 ImVec2 ImGui::GetContentRegionMax()
@@ -4145,7 +4228,7 @@ void ImGui::LogButtons()
4145 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 4233
     ImGuiState& g = *GImGui;
4151 4234
     ImGuiWindow* window = GetCurrentWindow();
@@ -4161,14 +4244,31 @@ bool ImGui::CollapsingHeader(const char* label, const char* str_id, const bool d
4161 4244
         label = str_id;
4162 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 4248
     ImGuiStorage* storage = window->DC.StateStorage;
4166 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 4273
     else
4174 4274
     {
@@ -4242,6 +4342,28 @@ bool ImGui::CollapsingHeader(const char* label, const char* str_id, const bool d
4242 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 4367
 // Text with a little bullet aligned to the typical tree node.
4246 4368
 void ImGui::BulletTextV(const char* fmt, va_list args)
4247 4369
 {
@@ -4250,12 +4372,11 @@ void ImGui::BulletTextV(const char* fmt, va_list args)
4250 4372
     if (window->SkipItems)
4251 4373
         return;
4252 4374
     
4253
-    const ImGuiStyle& style = g.Style;
4254
-
4255 4375
     static char buf[1024];
4256 4376
     const char* text_begin = buf;
4257 4377
     const char* text_end = text_begin + ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
4258 4378
 
4379
+    const ImGuiStyle& style = g.Style;
4259 4380
     const float line_height = window->FontSize();
4260 4381
     const ImVec2 text_size = CalcTextSize(text_begin, text_end, true);
4261 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,10 +4459,11 @@ bool ImGui::TreeNode(const char* str_label_id)
4338 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 4469
 void ImGui::PushID(const char* str_id)
@@ -5644,7 +5766,8 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT
5644 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 5772
     if ((flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0)
5650 5773
         return enter_pressed;
@@ -5765,11 +5888,11 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
5765 5888
 
5766 5889
     const ImVec2 text_size = CalcTextSize(label, NULL, true);
5767 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 5893
     if (!ItemAdd(frame_bb, &id))
5770 5894
         return false;
5771 5895
 
5772
-    const ImGuiAabb bb(frame_bb.Min, frame_bb.Max + ImVec2(style.ItemInnerSpacing.x + text_size.x,0));
5773 5896
     const float arrow_size = (window->FontSize() + style.FramePadding.x * 2.0f);
5774 5897
     const bool hovered = IsHovered(frame_bb, id);
5775 5898
 
@@ -5786,12 +5909,8 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
5786 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 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 5915
     ImGui::PushID((int)id);
5797 5916
     bool menu_toggled = false;
@@ -6249,9 +6368,9 @@ static void ItemSize(ImVec2 size, ImVec2* adjust_vertical_offset)
6249 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 6376
 static bool IsClipped(const ImGuiAabb& bb)
@@ -6378,9 +6497,9 @@ void ImGui::SetColumnOffset(int column_index, float offset)
6378 6497
     const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
6379 6498
 
6380 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 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 6503
     window->DC.ColumnsOffsetsT[column_index] = t;
6385 6504
 }
6386 6505
 
@@ -6473,7 +6592,7 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
6473 6592
             const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
6474 6593
             RegisterAliveId(column_id);
6475 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 6596
             window->DC.ColumnsOffsetsT[column_index] = t;
6478 6597
         }
6479 6598
 
@@ -7361,7 +7480,9 @@ const ImWchar*  ImFontAtlas::GetGlyphRangesChinese()
7361 7480
     static const ImWchar ranges[] =
7362 7481
     {
7363 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 7486
         0xFF00, 0xFFEF, // Half-width characters
7366 7487
         0x4e00, 0x9FAF, // CJK Ideograms
7367 7488
         0,
@@ -7409,18 +7530,19 @@ const ImWchar*  ImFontAtlas::GetGlyphRangesJapanese()
7409 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 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 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 7539
         0xFF00, 0xFFEF, // Half-width characters
7417
-        0, 
7418 7540
     };
7419 7541
     if (!ranges_unpacked)
7420 7542
     {
7421 7543
         // Unpack
7422 7544
         int codepoint = 0x4e00;
7423
-        ImWchar* dst = &ranges[6];
7545
+        ImWchar* dst = &ranges[10];
7424 7546
         for (int n = 0; n < IM_ARRAYSIZE(offsets_from_0x4E00); n++, dst += 2)
7425 7547
             dst[0] = dst[1] = (ImWchar)(codepoint += (offsets_from_0x4E00[n] + 1));
7426 7548
         dst[0] = 0;
@@ -7453,7 +7575,7 @@ void ImFont::BuildLookupTable()
7453 7575
 
7454 7576
     // Create a glyph to handle TAB
7455 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 7580
         Glyphs.resize(Glyphs.size() + 1);
7459 7581
         ImFont::Glyph& tab_glyph = Glyphs.back();
@@ -8302,7 +8424,9 @@ void ImGui::ShowTestWindow(bool* opened)
8302 8424
         {
8303 8425
             ImGui::BulletText("Bullet point 1");
8304 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 8430
             ImGui::TreePop();
8307 8431
         }
8308 8432
 
@@ -8554,9 +8678,10 @@ void ImGui::ShowTestWindow(bool* opened)
8554 8678
         ImGui::ColorEdit4("color 2", col2);
8555 8679
 
8556 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 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 8685
         //ImGui::PushItemWidth(-1);
8561 8686
         //ImGui::ListBox("##listbox2", &listbox_item_current2, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
8562 8687
         //ImGui::PopItemWidth();
@@ -8623,6 +8748,14 @@ void ImGui::ShowTestWindow(bool* opened)
8623 8748
         // SliderFloat
8624 8749
         static float f0=1.0f, f1=2.0f, f2=3.0f;
8625 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 8759
         ImGui::SliderFloat("X", &f0, 0.0f,5.0f);
8627 8760
         ImGui::SameLine();
8628 8761
         ImGui::SliderFloat("Y", &f1, 0.0f,5.0f);

+ 29
- 16
src/deps/imgui/imgui.h Näytä tiedosto

@@ -1,4 +1,4 @@
1
-// ImGui library v1.33
1
+// ImGui library v1.35 wip
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.
@@ -23,11 +23,13 @@ struct ImGuiWindow;
23 23
 #include <stdlib.h>         // NULL, malloc
24 24
 #include <string.h>         // memset, memmove
25 25
 
26
+// Define assertion handler.
26 27
 #ifndef IM_ASSERT
27 28
 #include <assert.h>
28 29
 #define IM_ASSERT(_EXPR)    assert(_EXPR)
29 30
 #endif
30 31
 
32
+// Define attributes of all API symbols declarations, e.g. for DLL under Windows.
31 33
 #ifndef IMGUI_API
32 34
 #define IMGUI_API
33 35
 #endif
@@ -41,7 +43,7 @@ typedef int ImGuiStyleVar;          // enum ImGuiStyleVar_
41 43
 typedef int ImGuiKey;               // enum ImGuiKey_
42 44
 typedef int ImGuiColorEditMode;     // enum ImGuiColorEditMode_
43 45
 typedef int ImGuiWindowFlags;       // enum ImGuiWindowFlags_
44
-typedef int ImGuiSetCondition;      // enum ImGuiSetCondition_
46
+typedef int ImGuiSetCond;           // enum ImGuiSetCondition_
45 47
 typedef int ImGuiInputTextFlags;    // enum ImGuiInputTextFlags_
46 48
 struct ImGuiTextEditCallbackData;   // for advanced uses of InputText() 
47 49
 typedef int (*ImGuiTextEditCallback)(ImGuiTextEditCallbackData *data);
@@ -175,12 +177,19 @@ namespace ImGui
175 177
     IMGUI_API ImVec2        GetWindowSize();                                                    // get current window position.
176 178
     IMGUI_API float         GetWindowWidth();
177 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 194
     IMGUI_API void          SetScrollPosHere();                                                 // adjust scrolling position to center into the current cursor position.
186 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,6 +261,7 @@ namespace ImGui
252 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 262
     IMGUI_API void          LabelText(const char* label, const char* fmt, ...);                 // display text+label aligned the same way as value+label widgets 
254 263
     IMGUI_API void          LabelTextV(const char* label, const char* fmt, va_list args);
264
+    IMGUI_API void          Bullet();
255 265
     IMGUI_API void          BulletText(const char* fmt, ...);
256 266
     IMGUI_API void          BulletTextV(const char* fmt, va_list args);
257 267
     IMGUI_API bool          Button(const char* label, const ImVec2& size = ImVec2(0,0), bool repeat_when_held = false);
@@ -259,7 +269,7 @@ namespace ImGui
259 269
     IMGUI_API bool          InvisibleButton(const char* str_id, const ImVec2& size);
260 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 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 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 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 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,6 +300,8 @@ namespace ImGui
290 300
     IMGUI_API bool          ColorEdit3(const char* label, float col[3]);
291 301
     IMGUI_API bool          ColorEdit4(const char* label, float col[4], bool show_alpha = true);
292 302
     IMGUI_API void          ColorEditMode(ImGuiColorEditMode mode);
303
+
304
+    // Trees
293 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 306
     IMGUI_API bool          TreeNode(const char* str_id, const char* fmt, ...);                 // "
295 307
     IMGUI_API bool          TreeNode(const void* ptr_id, const char* fmt, ...);                 // "
@@ -298,7 +310,7 @@ namespace ImGui
298 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 311
     IMGUI_API void          TreePush(const void* ptr_id = NULL);                                // "
300 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 315
     // Selectable / Lists
304 316
     IMGUI_API bool          Selectable(const char* label, bool selected, const ImVec2& size = ImVec2(0,0));
@@ -360,6 +372,7 @@ namespace ImGui
360 372
 
361 373
     // Obsolete (will be removed)
362 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 377
 } // namespace ImGui
365 378
 
@@ -493,13 +506,13 @@ enum ImGuiColorEditMode_
493 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 518
 struct ImGuiStyle

Loading…
Peruuta
Tallenna