Browse Source

Updated imgui

Thomas Buck 10 years ago
parent
commit
eb9ebdf7e5
3 changed files with 124 additions and 70 deletions
  1. 1
    1
      src/deps/imgui/imconfig.h
  2. 109
    63
      src/deps/imgui/imgui.cpp
  3. 14
    6
      src/deps/imgui/imgui.h

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

39
 {
39
 {
40
     void    Value(const char* prefix, const MyVec2& v, const char* float_format = NULL);
40
     void    Value(const char* prefix, const MyVec2& v, const char* float_format = NULL);
41
     void    Value(const char* prefix, const MyVec4& v, const char* float_format = NULL);
41
     void    Value(const char* prefix, const MyVec4& v, const char* float_format = NULL);
42
-};
42
+}
43
 */
43
 */
44
 
44
 

+ 109
- 63
src/deps/imgui/imgui.cpp View File

1
-// ImGui library v1.14 wip
1
+// ImGui library v1.15 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
5
-// Developped by Omar Cornut and contributors.
5
+// Developed by Omar Cornut and contributors.
6
 
6
 
7
 /*
7
 /*
8
  
8
  
10
  =================
10
  =================
11
 
11
 
12
  - easy to use to create code-driven and data-driven tools
12
  - easy to use to create code-driven and data-driven tools
13
- - easy to use to create adhoc short-lived tools and long-lived, more elaborate tools
13
+ - easy to use to create ad hoc short-lived tools and long-lived, more elaborate tools
14
  - easy to hack and improve
14
  - easy to hack and improve
15
  - minimize screen real-estate usage
15
  - minimize screen real-estate usage
16
  - minimize setup and maintainance
16
  - minimize setup and maintainance
17
  - minimize state storage on user side
17
  - minimize state storage on user side
18
  - portable, minimize dependencies, run on target (consoles, etc.)
18
  - portable, minimize dependencies, run on target (consoles, etc.)
19
- - efficient runtime (nb- we do allocate when "growing" content - creating a window / opening a tree node for the first time, etc. - but a typical frame won't allocate anything)
19
+ - efficient runtime (NB- we do allocate when "growing" content - creating a window / opening a tree node for the first time, etc. - but a typical frame won't allocate anything)
20
  - read about immediate-mode GUI principles @ http://mollyrocket.com/861, http://mollyrocket.com/forums/index.html
20
  - read about immediate-mode GUI principles @ http://mollyrocket.com/861, http://mollyrocket.com/forums/index.html
21
 
21
 
22
  Designed for developers and content-creators, not the typical end-user! Some of the weaknesses includes:
22
  Designed for developers and content-creators, not the typical end-user! Some of the weaknesses includes:
72
         io.DeltaTime = 1.0f/60.0f;
72
         io.DeltaTime = 1.0f/60.0f;
73
         io.IniFilename = "imgui.ini";
73
         io.IniFilename = "imgui.ini";
74
 
74
 
75
-        // Application mainloop
75
+        // Application main loop
76
         while (true)
76
         while (true)
77
         {
77
         {
78
             // 1/ get low-level input
78
             // 1/ get low-level input
170
  - combo: turn child handling code into popup helper
170
  - combo: turn child handling code into popup helper
171
  - list selection, concept of a selectable "block" (that can be multiple widgets)
171
  - list selection, concept of a selectable "block" (that can be multiple widgets)
172
  - menubar, menus
172
  - menubar, menus
173
- - plot: make it easier for user to draw into the graph (e.g: draw basis, highlight certain pointsm, 2d plots, multiple plots)
173
+ - plot: make it easier for user to draw into the graph (e.g: draw basis, highlight certain points, 2d plots, multiple plots)
174
  - plot: "smooth" automatic scale, user give an input 0.0(full user scale) 1.0(full derived from value)
174
  - plot: "smooth" automatic scale, user give an input 0.0(full user scale) 1.0(full derived from value)
175
  - plot: add a helper e.g. Plot(char* label, float value, float time_span=2.0f) that stores values and Plot them for you - probably another function name. and/or automatically allow to plot ANY displayed value (more reliance on stable ID)
175
  - plot: add a helper e.g. Plot(char* label, float value, float time_span=2.0f) that stores values and Plot them for you - probably another function name. and/or automatically allow to plot ANY displayed value (more reliance on stable ID)
176
  - file selection widget -> build the tool in our codebase to improve model-dialog idioms (may or not lead to ImGui changes)
176
  - file selection widget -> build the tool in our codebase to improve model-dialog idioms (may or not lead to ImGui changes)
177
  - slider: allow using the [-]/[+] buttons used by InputFloat()/InputInt()
177
  - slider: allow using the [-]/[+] buttons used by InputFloat()/InputInt()
178
- - slider: initial absolute click is unprecise. change to relative movement slider? hide mouse cursor, allow more precise input using less screen-space.
179
- - text edit: centered text for slider or input text to it matches typical positionning.
178
+ - slider: initial absolute click is imprecise. change to relative movement slider? hide mouse cursor, allow more precise input using less screen-space.
179
+ - text edit: centered text for slider or input text to it matches typical positioning.
180
  - text edit: flag to disable live update of the user buffer. 
180
  - text edit: flag to disable live update of the user buffer. 
181
- - text edit: field resize behaviour - field could stretch when being edited? hover tooltip shows more text?
181
+ - text edit: field resize behavior - field could stretch when being edited? hover tooltip shows more text?
182
  - text edit: pasting text into a number box should filter the characters the same way direct input does
182
  - text edit: pasting text into a number box should filter the characters the same way direct input does
183
  - settings: write more decent code to allow saving/loading new fields
183
  - settings: write more decent code to allow saving/loading new fields
184
- - settings: api for per-tool simple persistant data (bool,int,float) in .ini file
184
+ - settings: api for per-tool simple persistent data (bool,int,float) in .ini file
185
  - log: be able to right-click and log a window or tree-node into tty/file/clipboard?
185
  - log: be able to right-click and log a window or tree-node into tty/file/clipboard?
186
  - filters: set a current filter that tree node can automatically query to hide themselves
186
  - filters: set a current filter that tree node can automatically query to hide themselves
187
  - filters: handle wildcards (with implicit leading/trailing *), regexps
187
  - filters: handle wildcards (with implicit leading/trailing *), regexps
188
  - shortcuts: add a shortcut api, e.g. parse "&Save" and/or "Save (CTRL+S)", pass in to widgets or provide simple ways to use (button=activate, input=focus)
188
  - shortcuts: add a shortcut api, e.g. parse "&Save" and/or "Save (CTRL+S)", pass in to widgets or provide simple ways to use (button=activate, input=focus)
189
  ! keyboard: tooltip & combo boxes are messing up / not honoring keyboard tabbing
189
  ! keyboard: tooltip & combo boxes are messing up / not honoring keyboard tabbing
190
  - keyboard: full keyboard navigation and focus.
190
  - keyboard: full keyboard navigation and focus.
191
- - input: reowrk IO to be able to pass actual events to fix temporal aliasing issues.
192
- - input: support trackpad style scrolling & slider edit.
191
+ - input: rework IO to be able to pass actual events to fix temporal aliasing issues.
192
+ - input: support track pad style scrolling & slider edit.
193
  - tooltip: move to fit within screen (e.g. when mouse cursor is right of the screen).
193
  - tooltip: move to fit within screen (e.g. when mouse cursor is right of the screen).
194
  - misc: not thread-safe
194
  - misc: not thread-safe
195
  - misc: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon?
195
  - misc: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon?
196
  - style editor: add a button to output C code.
196
  - style editor: add a button to output C code.
197
- - optimisation/render: use indexed rendering
198
- - optimisation/render: move clip-rect to vertex data? would allow merging all commands
199
- - optimisation/render: merge command-lists with same clip-rect into one even if they aren't sequential? (as long as in-between clip rectangle don't overlap)?
200
- - optimisation/render: font exported by bmfont is not tight fit on vertical axis, incur unneeded pixel-shading cost.
201
- - optimisation: turn some the various stack vectors into statically-sized arrays
202
- - optimisation: better clipping for multi-component widgets
203
- - optimisation: specialize for height based clipping first (assume widgets never go up + height tests before width tests?)
197
+ - optimization/render: use indexed rendering
198
+ - optimization/render: move clip-rect to vertex data? would allow merging all commands
199
+ - optimization/render: merge command-lists with same clip-rect into one even if they aren't sequential? (as long as in-between clip rectangle don't overlap)?
200
+ - optimization/render: font exported by bmfont is not tight fit on vertical axis, incur unneeded pixel-shading cost.
201
+ - optimization: turn some the various stack vectors into statically-sized arrays
202
+ - optimization: better clipping for multi-component widgets
203
+ - optimization: specialize for height based clipping first (assume widgets never go up + height tests before width tests?)
204
 */
204
 */
205
 
205
 
206
 #include "imgui.h"
206
 #include "imgui.h"
243
 static ImGuiWindow* FindWindow(const char* name);
243
 static ImGuiWindow* FindWindow(const char* name);
244
 static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs);
244
 static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs);
245
 
245
 
246
-}; // namespace ImGui
246
+} // namespace ImGui
247
 
247
 
248
 //-----------------------------------------------------------------------------
248
 //-----------------------------------------------------------------------------
249
 // Platform dependant default implementations
249
 // Platform dependant default implementations
1023
     FontWindowScale = 1.0f;
1023
     FontWindowScale = 1.0f;
1024
 
1024
 
1025
     if (ImLength(Size) < 0.001f)
1025
     if (ImLength(Size) < 0.001f)
1026
-        AutoFitFrames = 3;
1026
+        AutoFitFrames = 2;
1027
 
1027
 
1028
     DrawList = (ImDrawList*)ImGui::MemAlloc(sizeof(ImDrawList));
1028
     DrawList = (ImDrawList*)ImGui::MemAlloc(sizeof(ImDrawList));
1029
     new(DrawList) ImDrawList();
1029
     new(DrawList) ImDrawList();
2001
         }
2001
         }
2002
         else
2002
         else
2003
         {
2003
         {
2004
+            // Normal windows store settings in .ini file
2004
             ImGuiIniData* settings = FindWindowSettings(name);
2005
             ImGuiIniData* settings = FindWindowSettings(name);
2005
             if (settings && ImLength(settings->Size) > 0.0f && !(flags & ImGuiWindowFlags_NoResize))// && ImLengthsize) == 0.0f)
2006
             if (settings && ImLength(settings->Size) > 0.0f && !(flags & ImGuiWindowFlags_NoResize))// && ImLengthsize) == 0.0f)
2006
                 size = settings->Size;
2007
                 size = settings->Size;
2170
                     window->SizeFull = window->SizeContentsFit + g.Style.WindowPadding - ImVec2(0.0f, g.Style.ItemSpacing.y);
2171
                     window->SizeFull = window->SizeContentsFit + g.Style.WindowPadding - ImVec2(0.0f, g.Style.ItemSpacing.y);
2171
                 }
2172
                 }
2172
             }
2173
             }
2173
-            else if (!(window->Flags & ImGuiWindowFlags_NoResize))
2174
+            else
2174
             {
2175
             {
2175
-                // Draw resize grip
2176
-                const ImGuiAabb resize_aabb(window->Aabb().GetBR()-ImVec2(18,18), window->Aabb().GetBR());
2177
-                const ImGuiID resize_id = window->GetID("#RESIZE");
2178
-                bool hovered, held;
2179
-                ButtonBehaviour(resize_aabb, resize_id, &hovered, &held, true);
2180
-                resize_col = window->Color(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip);
2181
-
2182
                 ImVec2 size_auto_fit = ImClamp(window->SizeContentsFit + style.AutoFitPadding, style.WindowMinSize, g.IO.DisplaySize - style.AutoFitPadding);
2176
                 ImVec2 size_auto_fit = ImClamp(window->SizeContentsFit + style.AutoFitPadding, style.WindowMinSize, g.IO.DisplaySize - style.AutoFitPadding);
2183
                 if (window->AutoFitFrames > 0)
2177
                 if (window->AutoFitFrames > 0)
2184
                 {
2178
                 {
2186
                     window->SizeFull = ImMax(window->SizeFull, size_auto_fit);
2180
                     window->SizeFull = ImMax(window->SizeFull, size_auto_fit);
2187
                     MarkSettingsDirty();
2181
                     MarkSettingsDirty();
2188
                 }
2182
                 }
2189
-                else if (g.HoveredWindow == window && held && g.IO.MouseDoubleClicked[0])
2190
-                {
2191
-                    // Manual auto-fit
2192
-                    window->SizeFull = size_auto_fit;
2193
-                    window->Size = window->SizeFull;
2194
-                    MarkSettingsDirty();
2195
-                }
2196
-                else if (held)
2183
+                else if (!(window->Flags & ImGuiWindowFlags_NoResize))
2197
                 {
2184
                 {
2198
-                    // Resize
2199
-                    window->SizeFull = ImMax(window->SizeFull + g.IO.MouseDelta, style.WindowMinSize);
2200
-                    window->Size = window->SizeFull;
2201
-                    MarkSettingsDirty();
2185
+                    // Resize grip
2186
+                    const ImGuiAabb resize_aabb(window->Aabb().GetBR()-ImVec2(18,18), window->Aabb().GetBR());
2187
+                    const ImGuiID resize_id = window->GetID("#RESIZE");
2188
+                    bool hovered, held;
2189
+                    ButtonBehaviour(resize_aabb, resize_id, &hovered, &held, true);
2190
+                    resize_col = window->Color(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip);
2191
+
2192
+                    if (g.HoveredWindow == window && held && g.IO.MouseDoubleClicked[0])
2193
+                    {
2194
+                        // Manual auto-fit
2195
+                        window->SizeFull = size_auto_fit;
2196
+                        window->Size = window->SizeFull;
2197
+                        MarkSettingsDirty();
2198
+                    }
2199
+                    else if (held)
2200
+                    {
2201
+                        // Resize
2202
+                        window->SizeFull = ImMax(window->SizeFull + g.IO.MouseDelta, style.WindowMinSize);
2203
+                        window->Size = window->SizeFull;
2204
+                        MarkSettingsDirty();
2205
+                    }
2202
                 }
2206
                 }
2203
 
2207
 
2204
                 // Update aabb immediately so that the rendering below isn't one frame late
2208
                 // Update aabb immediately so that the rendering below isn't one frame late
2565
     return window->Size;
2569
     return window->Size;
2566
 }
2570
 }
2567
 
2571
 
2572
+void SetWindowSize(const ImVec2& size)
2573
+{
2574
+    ImGuiWindow* window = GetCurrentWindow();
2575
+    window->SizeFull = size;
2576
+    if (ImLength(size) < 0.001f)
2577
+        window->AutoFitFrames = 3;
2578
+}
2579
+
2568
 ImVec2 GetWindowContentRegionMin()
2580
 ImVec2 GetWindowContentRegionMin()
2569
 {
2581
 {
2570
     ImGuiWindow* window = GetCurrentWindow();
2582
     ImGuiWindow* window = GetCurrentWindow();
2599
     return window->DrawList;
2611
     return window->DrawList;
2600
 }
2612
 }
2601
 
2613
 
2614
+ImFont GetWindowFont()
2615
+{
2616
+    ImGuiWindow* window = GetCurrentWindow();
2617
+    return window->Font();
2618
+}
2619
+
2620
+float GetWindowFontSize()
2621
+{
2622
+    ImGuiWindow* window = GetCurrentWindow();
2623
+    return window->FontSize();
2624
+}
2625
+
2602
 void SetWindowFontScale(float scale)
2626
 void SetWindowFontScale(float scale)
2603
 {
2627
 {
2604
     ImGuiWindow* window = GetCurrentWindow();
2628
     ImGuiWindow* window = GetCurrentWindow();
3600
     ImGuiPlotType_Histogram,
3624
     ImGuiPlotType_Histogram,
3601
 };
3625
 };
3602
 
3626
 
3603
-static float PlotGetValue(const float* values, size_t stride, int idx)
3604
-{
3605
-    const float v = *(float*)((unsigned char*)values + (size_t)idx * stride);
3606
-    return v;
3607
-}
3608
-
3609
-static void Plot(ImGuiPlotType plot_type, const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, size_t stride)
3627
+static void Plot(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size)
3610
 {
3628
 {
3611
     ImGuiState& g = GImGui;
3629
     ImGuiState& g = GImGui;
3612
     ImGuiWindow* window = GetCurrentWindow();
3630
     ImGuiWindow* window = GetCurrentWindow();
3636
         float v_max = -FLT_MAX;
3654
         float v_max = -FLT_MAX;
3637
         for (int i = 0; i < values_count; i++)
3655
         for (int i = 0; i < values_count; i++)
3638
         {
3656
         {
3639
-            const float v = PlotGetValue(values, stride, i);
3657
+            const float v = values_getter(data, i);
3640
             v_min = ImMin(v_min, v);
3658
             v_min = ImMin(v_min, v);
3641
             v_max = ImMax(v_max, v);
3659
             v_max = ImMax(v_max, v);
3642
         }
3660
         }
3660
         const int v_idx = (int)(t * (values_count + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0)));
3678
         const int v_idx = (int)(t * (values_count + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0)));
3661
         IM_ASSERT(v_idx >= 0 && v_idx < values_count);
3679
         IM_ASSERT(v_idx >= 0 && v_idx < values_count);
3662
         
3680
         
3663
-        const float v0 = PlotGetValue(values, stride, (v_idx + values_offset) % values_count);
3664
-        const float v1 = PlotGetValue(values, stride, (v_idx + 1 + values_offset) % values_count);
3681
+        const float v0 = values_getter(data, (v_idx + values_offset) % values_count);
3682
+        const float v1 = values_getter(data, (v_idx + 1 + values_offset) % values_count);
3665
         if (plot_type == ImGuiPlotType_Lines)
3683
         if (plot_type == ImGuiPlotType_Lines)
3666
             ImGui::SetTooltip("%d: %8.4g\n%d: %8.4g", v_idx, v0, v_idx+1, v1);
3684
             ImGui::SetTooltip("%d: %8.4g\n%d: %8.4g", v_idx, v0, v_idx+1, v1);
3667
         else if (plot_type == ImGuiPlotType_Histogram)
3685
         else if (plot_type == ImGuiPlotType_Histogram)
3671
 
3689
 
3672
     const float t_step = 1.0f / (float)res_w;
3690
     const float t_step = 1.0f / (float)res_w;
3673
 
3691
 
3674
-    float v0 = PlotGetValue(values, stride, (0 + values_offset) % values_count);
3692
+    float v0 = values_getter(data, (0 + values_offset) % values_count);
3675
     float t0 = 0.0f;
3693
     float t0 = 0.0f;
3676
     ImVec2 p0 = ImVec2( t0, 1.0f - ImSaturate((v0 - scale_min) / (scale_max - scale_min)) );
3694
     ImVec2 p0 = ImVec2( t0, 1.0f - ImSaturate((v0 - scale_min) / (scale_max - scale_min)) );
3677
 
3695
 
3683
         const float t1 = t0 + t_step;
3701
         const float t1 = t0 + t_step;
3684
         const int v_idx = (int)(t0 * values_count);
3702
         const int v_idx = (int)(t0 * values_count);
3685
         IM_ASSERT(v_idx >= 0 && v_idx < values_count);
3703
         IM_ASSERT(v_idx >= 0 && v_idx < values_count);
3686
-        const float v1 = PlotGetValue(values, stride, (v_idx + values_offset + 1) % values_count);
3704
+        const float v1 = values_getter(data, (v_idx + values_offset + 1) % values_count);
3687
         const ImVec2 p1 = ImVec2( t1, 1.0f - ImSaturate((v1 - scale_min) / (scale_max - scale_min)) );
3705
         const ImVec2 p1 = ImVec2( t1, 1.0f - ImSaturate((v1 - scale_min) / (scale_max - scale_min)) );
3688
 
3706
 
3689
         // NB- Draw calls are merged together by the DrawList system.
3707
         // NB- Draw calls are merged together by the DrawList system.
3703
     RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, graph_bb.Min.y), label);
3721
     RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, graph_bb.Min.y), label);
3704
 }
3722
 }
3705
 
3723
 
3724
+struct ImGuiPlotArrayGetterData
3725
+{
3726
+    const float* Values;
3727
+    size_t Stride;
3728
+
3729
+    ImGuiPlotArrayGetterData(const float* values, size_t stride) { Values = values; Stride = stride; }
3730
+};
3731
+
3732
+static float Plot_ArrayGetter(void* data, int idx)
3733
+{
3734
+    ImGuiPlotArrayGetterData* plot_data = (ImGuiPlotArrayGetterData*)data;
3735
+    const float v = *(float*)((unsigned char*)plot_data->Values + (size_t)idx * plot_data->Stride);
3736
+    return v;
3737
+}
3738
+
3706
 void PlotLines(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, size_t stride)
3739
 void PlotLines(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, size_t stride)
3707
 {
3740
 {
3708
-    ImGui::Plot(ImGuiPlotType_Lines, label, values, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size, stride);
3741
+    ImGuiPlotArrayGetterData data(values, stride);
3742
+    ImGui::Plot(ImGuiPlotType_Lines, label, &Plot_ArrayGetter, (void*)&data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size);
3743
+}
3744
+
3745
+void PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size)
3746
+{
3747
+    ImGui::Plot(ImGuiPlotType_Lines, label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size);
3709
 }
3748
 }
3710
 
3749
 
3711
 void PlotHistogram(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, size_t stride)
3750
 void PlotHistogram(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, size_t stride)
3712
 {
3751
 {
3713
-    ImGui::Plot(ImGuiPlotType_Histogram, label, values, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size, stride);
3752
+    ImGuiPlotArrayGetterData data(values, stride);
3753
+    ImGui::Plot(ImGuiPlotType_Histogram, label, &Plot_ArrayGetter, (void*)&data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size);
3714
 }
3754
 }
3715
 
3755
 
3756
+void PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size)
3757
+{
3758
+    ImGui::Plot(ImGuiPlotType_Histogram, label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size);
3759
+}
3716
 bool Checkbox(const char* label, bool* v)
3760
 bool Checkbox(const char* label, bool* v)
3717
 {
3761
 {
3718
     ImGuiState& g = GImGui;
3762
     ImGuiState& g = GImGui;
3830
     return pressed;
3874
     return pressed;
3831
 }
3875
 }
3832
 
3876
 
3833
-}; // namespace ImGui
3877
+} // namespace ImGui
3834
 
3878
 
3835
 // Wrapper for stb_textedit.h to edit text (our wrapper is for: statically sized buffer, single-line, ASCII, fixed-width font)
3879
 // Wrapper for stb_textedit.h to edit text (our wrapper is for: statically sized buffer, single-line, ASCII, fixed-width font)
3836
 int     STB_TEXTEDIT_STRINGLEN(const STB_TEXTEDIT_STRING* obj)                                  { return (int)ImStrlenW(obj->Text); }
3880
 int     STB_TEXTEDIT_STRINGLEN(const STB_TEXTEDIT_STRING* obj)                                  { return (int)ImStrlenW(obj->Text); }
4633
             char* p = buf;
4677
             char* p = buf;
4634
             while (*p == '#' || *p == ' ' || *p == '\t') 
4678
             while (*p == '#' || *p == ' ' || *p == '\t') 
4635
                 p++;
4679
                 p++;
4680
+
4681
+            // Treat at unsigned (%X is unsigned)
4636
             ix = iy = iz = iw = 0;
4682
             ix = iy = iz = iw = 0;
4637
             if (alpha)
4683
             if (alpha)
4638
-                sscanf(p, "%02X%02X%02X%02X", &ix, &iy, &iz, &iw);
4684
+                sscanf(p, "%02X%02X%02X%02X", (unsigned int*)&ix, (unsigned int*)&iy, (unsigned int*)&iz, (unsigned int*)&iw);
4639
             else
4685
             else
4640
-                sscanf(p, "%02X%02X%02X", &ix, &iy, &iz);
4686
+                sscanf(p, "%02X%02X%02X", (unsigned int*)&ix, (unsigned int*)&iy, (unsigned int*)&iz);
4641
         }
4687
         }
4642
         break;
4688
         break;
4643
     }
4689
     }
4837
     const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
4883
     const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
4838
     RegisterAliveId(column_id);
4884
     RegisterAliveId(column_id);
4839
     const float default_t = column_index / (float)window->DC.ColumnsCount;
4885
     const float default_t = column_index / (float)window->DC.ColumnsCount;
4840
-    const float t = (float)window->StateStorage.GetInt(column_id, (int)(default_t * 8096)) / 8096;      // Cheaply store our floating point value inside the integer (could store an union into the map?)
4886
+    const float t = (float)window->StateStorage.GetInt(column_id, (int)(default_t * 8192)) / 8192;      // Cheaply store our floating point value inside the integer (could store an union into the map?)
4841
 
4887
 
4842
     const float offset = window->DC.ColumnStartX + t * (window->Size.x - g.Style.ScrollBarWidth - window->DC.ColumnStartX);
4888
     const float offset = window->DC.ColumnStartX + t * (window->Size.x - g.Style.ScrollBarWidth - window->DC.ColumnStartX);
4843
     return offset;
4889
     return offset;
4852
 
4898
 
4853
     const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
4899
     const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
4854
     const float t = (offset - window->DC.ColumnStartX) / (window->Size.x - g.Style.ScrollBarWidth - window->DC.ColumnStartX);
4900
     const float t = (offset - window->DC.ColumnStartX) / (window->Size.x - g.Style.ScrollBarWidth - window->DC.ColumnStartX);
4855
-    window->StateStorage.SetInt(column_id, (int)(t*8096));
4901
+    window->StateStorage.SetInt(column_id, (int)(t*8192));
4856
 }
4902
 }
4857
 
4903
 
4858
 float GetColumnWidth(int column_index)
4904
 float GetColumnWidth(int column_index)
5016
     ImGui::ColorButton(col, true);
5062
     ImGui::ColorButton(col, true);
5017
 }
5063
 }
5018
 
5064
 
5019
-}; // namespace ImGui
5065
+} // namespace ImGui
5020
 
5066
 
5021
 //-----------------------------------------------------------------------------
5067
 //-----------------------------------------------------------------------------
5022
 // ImDrawList
5068
 // ImDrawList
6452
 }
6498
 }
6453
 // End of Sample code
6499
 // End of Sample code
6454
 
6500
 
6455
-}; // namespace ImGui
6501
+} // namespace ImGui
6456
 
6502
 
6457
 //-----------------------------------------------------------------------------
6503
 //-----------------------------------------------------------------------------
6458
 // Font data
6504
 // Font data
6661
     if (png_size) *png_size = proggy_clean_13_png_size;
6707
     if (png_size) *png_size = proggy_clean_13_png_size;
6662
 }
6708
 }
6663
 
6709
 
6664
-};
6710
+} // namespace ImGui
6665
 
6711
 
6666
 //-----------------------------------------------------------------------------
6712
 //-----------------------------------------------------------------------------
6667
 
6713
 

+ 14
- 6
src/deps/imgui/imgui.h View File

1
-// ImGui library v1.14 wip
1
+// ImGui library v1.15 wip
2
 // See .cpp file for commentary.
2
 // See .cpp file for commentary.
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.
63
     void*       MemAlloc(size_t sz);
63
     void*       MemAlloc(size_t sz);
64
     void        MemFree(void* ptr);
64
     void        MemFree(void* ptr);
65
     void*       MemRealloc(void* ptr, size_t sz);
65
     void*       MemRealloc(void* ptr, size_t sz);
66
-};
66
+}
67
 
67
 
68
 // std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug). 
68
 // std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug). 
69
 // Use '#define ImVector std::vector' if you want to use the STL type or your own type.
69
 // Use '#define ImVector std::vector' if you want to use the STL type or your own type.
139
     void        ShowTestWindow(bool* open = NULL);
139
     void        ShowTestWindow(bool* open = NULL);
140
 
140
 
141
     // Window
141
     // Window
142
-    bool        Begin(const char* name = "Debug", bool* open = NULL, ImVec2 size = ImVec2(0,0), float fill_alpha = -1.0f, ImGuiWindowFlags flags = 0);
142
+    bool        Begin(const char* name = "Debug", bool* open = NULL, ImVec2 size = ImVec2(0,0), float fill_alpha = -1.0f, ImGuiWindowFlags flags = 0);    // return false when window is collapsed, so you can early out in your code.
143
     void        End();
143
     void        End();
144
     void        BeginChild(const char* str_id, ImVec2 size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0);
144
     void        BeginChild(const char* str_id, ImVec2 size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0);
145
     void        EndChild();
145
     void        EndChild();
146
     bool        GetWindowIsFocused();
146
     bool        GetWindowIsFocused();
147
     ImVec2      GetWindowSize();
147
     ImVec2      GetWindowSize();
148
     float       GetWindowWidth();
148
     float       GetWindowWidth();
149
+    void		SetWindowSize(const ImVec2& size);                                  // set to ImVec2(0,0) to force an auto-fit
149
     ImVec2      GetWindowPos();                                                     // you should rarely need/care about the window position, but it can be useful if you want to use your own drawing.
150
     ImVec2      GetWindowPos();                                                     // you should rarely need/care about the window position, but it can be useful if you want to use your own drawing.
150
     void        SetWindowPos(const ImVec2& pos);                                    // set current window pos.
151
     void        SetWindowPos(const ImVec2& pos);                                    // set current window pos.
151
     ImVec2      GetWindowContentRegionMin();
152
     ImVec2      GetWindowContentRegionMin();
152
     ImVec2      GetWindowContentRegionMax();
153
     ImVec2      GetWindowContentRegionMax();
153
     ImDrawList* GetWindowDrawList();                                                // get rendering command-list if you want to append your own draw primitives.
154
     ImDrawList* GetWindowDrawList();                                                // get rendering command-list if you want to append your own draw primitives.
155
+    ImFont      GetWindowFont();
156
+    float       GetWindowFontSize();
154
     void        SetWindowFontScale(float scale);                                    // per-window font scale. Adjust IO.FontBaseScale if you want to scale all windows together.
157
     void        SetWindowFontScale(float scale);                                    // per-window font scale. Adjust IO.FontBaseScale if you want to scale all windows together.
155
     void        SetScrollPosHere();                                                 // adjust scrolling position to center into the current cursor position.
158
     void        SetScrollPosHere();                                                 // adjust scrolling position to center into the current cursor position.
156
     void        SetKeyboardFocusHere(int offset = 0);                               // focus keyboard on the next widget. Use 'offset' to access sub components of a multiple component widget.
159
     void        SetKeyboardFocusHere(int offset = 0);                               // focus keyboard on the next widget. Use 'offset' to access sub components of a multiple component widget.
214
     bool        SliderAngle(const char* label, float* v, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f);     // *v in radians
217
     bool        SliderAngle(const char* label, float* v, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f);     // *v in radians
215
     bool        SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f");
218
     bool        SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f");
216
     void        PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
219
     void        PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
220
+    void        PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0));
217
     void        PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
221
     void        PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
222
+    void        PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0));
218
     bool        Checkbox(const char* label, bool* v);
223
     bool        Checkbox(const char* label, bool* v);
219
     bool        CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
224
     bool        CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
220
     bool        RadioButton(const char* label, bool active);
225
     bool        RadioButton(const char* label, bool active);
277
     void        GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size);
282
     void        GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size);
278
     ImVec2      CalcTextSize(const char* text, const char* text_end = NULL, const bool hide_text_after_hash = true);
283
     ImVec2      CalcTextSize(const char* text, const char* text_end = NULL, const bool hide_text_after_hash = true);
279
 
284
 
280
-}; // namespace ImGui
285
+} // namespace ImGui
281
 
286
 
282
 // Flags for ImGui::Begin()
287
 // Flags for ImGui::Begin()
283
 enum ImGuiWindowFlags_
288
 enum ImGuiWindowFlags_
575
     ImVec4          clip_rect;
580
     ImVec4          clip_rect;
576
 };
581
 };
577
 
582
 
578
-// sizeof() == 20
579
 struct ImDrawVert
583
 struct ImDrawVert
580
 {
584
 {
581
     ImVec2  pos;
585
     ImVec2  pos;
584
 };
588
 };
585
 
589
 
586
 // Draw command list
590
 // Draw command list
587
-// User is responsible for providing a renderer for this in ImGuiIO::RenderDrawListFn
591
+// This is the low-level list of polygon that ImGui:: functions are filling. At the end of the frame, all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering.
592
+// Each ImGui window contains its own ImDrawList.
593
+// If you want to add custom rendering within a window, you can use ImGui::GetWindowDrawList() to access the current draw list and add your own primitives.
594
+// You can interleave normal ImGui:: calls and adding primitives to the current draw list.
595
+// Note that this only gives you access to rendering polygons. If your intent is to create custom widgets and the publicly exposed functions/data aren't sufficient, you can add code in imgui_user.inl
588
 struct ImDrawList
596
 struct ImDrawList
589
 {
597
 {
590
     // This is what you have to render
598
     // This is what you have to render

Loading…
Cancel
Save