1
- // dear imgui, v1.90.5
1
+ // dear imgui, v1.90.6
2
2
// (demo code)
3
3
4
4
// Help:
10
10
// Read top of imgui.cpp and imgui.h for many details, documentation, comments, links.
11
11
// Get the latest version at https://github.com/ocornut/imgui
12
12
13
+ // How to easily locate code?
14
+ // - Use the Item Picker to debug break in code by clicking any widgets: https://github.com/ocornut/imgui/wiki/Debug-Tools
15
+ // - Browse an online version the demo with code linked to hovered widgets: https://pthom.github.io/imgui_manual_online/manual/imgui_manual.html
16
+ // - Find a visible string and search for it in the code!
17
+
13
18
// ---------------------------------------------------
14
19
// PLEASE DO NOT REMOVE THIS FILE FROM YOUR PROJECT!
15
20
// ---------------------------------------------------
@@ -132,6 +137,7 @@ Index of this file:
132
137
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
133
138
#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning: macro name is a reserved identifier
134
139
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
140
+ #pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
135
141
#elif defined(__GNUC__)
136
142
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
137
143
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
@@ -961,13 +967,18 @@ static void ShowDemoWindowWidgets()
961
967
if (i == 0 )
962
968
ImGui::SetNextItemOpen (true , ImGuiCond_Once);
963
969
964
- if (ImGui::TreeNode ((void *)(intptr_t )i, " Child %d" , i))
970
+ // Here we use PushID() to generate a unique base ID, and then the "" used as TreeNode id won't conflict.
971
+ // An alternative to using 'PushID() + TreeNode("", ...)' to generate a unique ID is to use 'TreeNode((void*)(intptr_t)i, ...)',
972
+ // aka generate a dummy pointer-sized value to be hashed. The demo below uses that technique. Both are fine.
973
+ ImGui::PushID (i);
974
+ if (ImGui::TreeNode (" " , " Child %d" , i))
965
975
{
966
976
ImGui::Text (" blah blah" );
967
977
ImGui::SameLine ();
968
978
if (ImGui::SmallButton (" button" )) {}
969
979
ImGui::TreePop ();
970
980
}
981
+ ImGui::PopID ();
971
982
}
972
983
ImGui::TreePop ();
973
984
}
@@ -985,7 +996,10 @@ static void ShowDemoWindowWidgets()
985
996
ImGui::CheckboxFlags (" ImGuiTreeNodeFlags_OpenOnDoubleClick" , &base_flags, ImGuiTreeNodeFlags_OpenOnDoubleClick);
986
997
ImGui::CheckboxFlags (" ImGuiTreeNodeFlags_SpanAvailWidth" , &base_flags, ImGuiTreeNodeFlags_SpanAvailWidth); ImGui::SameLine (); HelpMarker (" Extend hit area to all available width instead of allowing more items to be laid out after the node." );
987
998
ImGui::CheckboxFlags (" ImGuiTreeNodeFlags_SpanFullWidth" , &base_flags, ImGuiTreeNodeFlags_SpanFullWidth);
999
+ ImGui::CheckboxFlags (" ImGuiTreeNodeFlags_SpanTextWidth" , &base_flags, ImGuiTreeNodeFlags_SpanTextWidth); ImGui::SameLine (); HelpMarker (" Reduce hit area to the text label and a bit of margin." );
988
1000
ImGui::CheckboxFlags (" ImGuiTreeNodeFlags_SpanAllColumns" , &base_flags, ImGuiTreeNodeFlags_SpanAllColumns); ImGui::SameLine (); HelpMarker (" For use in Tables only." );
1001
+ ImGui::CheckboxFlags (" ImGuiTreeNodeFlags_AllowOverlap" , &base_flags, ImGuiTreeNodeFlags_AllowOverlap);
1002
+ ImGui::CheckboxFlags (" ImGuiTreeNodeFlags_Framed" , &base_flags, ImGuiTreeNodeFlags_Framed); ImGui::SameLine (); HelpMarker (" Draw frame with background (e.g. for CollapsingHeader)" );
989
1003
ImGui::Checkbox (" Align label with current X position" , &align_label_with_current_x_position);
990
1004
ImGui::Checkbox (" Test tree node as drag source" , &test_drag_and_drop);
991
1005
ImGui::Text (" Hello!" );
@@ -1018,6 +1032,12 @@ static void ShowDemoWindowWidgets()
1018
1032
ImGui::Text (" This is a drag and drop source" );
1019
1033
ImGui::EndDragDropSource ();
1020
1034
}
1035
+ if (i == 2 )
1036
+ {
1037
+ // Item 2 has an additional inline button to help demonstrate SpanTextWidth.
1038
+ ImGui::SameLine ();
1039
+ if (ImGui::SmallButton (" button" )) {}
1040
+ }
1021
1041
if (node_open)
1022
1042
{
1023
1043
ImGui::BulletText (" Blah blah\n Blah Blah" );
@@ -1881,7 +1901,6 @@ static void ShowDemoWindowWidgets()
1881
1901
ImGui::Checkbox (" Animate" , &animate);
1882
1902
1883
1903
// Plot as lines and plot as histogram
1884
- IMGUI_DEMO_MARKER (" Widgets/Plotting/PlotLines, PlotHistogram" );
1885
1904
static float arr[] = { 0 .6f , 0 .1f , 1 .0f , 0 .5f , 0 .92f , 0 .1f , 0 .2f };
1886
1905
ImGui::PlotLines (" Frame Times" , arr, IM_ARRAYSIZE (arr));
1887
1906
ImGui::PlotHistogram (" Histogram" , arr, IM_ARRAYSIZE (arr), 0 , NULL , 0 .0f , 1 .0f , ImVec2 (0 , 80 .0f ));
@@ -1935,15 +1954,17 @@ static void ShowDemoWindowWidgets()
1935
1954
ImGui::PlotHistogram (" Histogram" , func, NULL , display_count, 0 , NULL , -1 .0f , 1 .0f , ImVec2 (0 , 80 ));
1936
1955
ImGui::Separator ();
1937
1956
1957
+ ImGui::TreePop ();
1958
+ }
1959
+
1960
+ IMGUI_DEMO_MARKER (" Widgets/Progress Bars" );
1961
+ if (ImGui::TreeNode (" Progress Bars" ))
1962
+ {
1938
1963
// Animate a simple progress bar
1939
- IMGUI_DEMO_MARKER (" Widgets/Plotting/ProgressBar" );
1940
1964
static float progress = 0 .0f , progress_dir = 1 .0f ;
1941
- if (animate)
1942
- {
1943
- progress += progress_dir * 0 .4f * ImGui::GetIO ().DeltaTime ;
1944
- if (progress >= +1 .1f ) { progress = +1 .1f ; progress_dir *= -1 .0f ; }
1945
- if (progress <= -0 .1f ) { progress = -0 .1f ; progress_dir *= -1 .0f ; }
1946
- }
1965
+ progress += progress_dir * 0 .4f * ImGui::GetIO ().DeltaTime ;
1966
+ if (progress >= +1 .1f ) { progress = +1 .1f ; progress_dir *= -1 .0f ; }
1967
+ if (progress <= -0 .1f ) { progress = -0 .1f ; progress_dir *= -1 .0f ; }
1947
1968
1948
1969
// Typically we would use ImVec2(-1.0f,0.0f) or ImVec2(-FLT_MIN,0.0f) to use all available width,
1949
1970
// or ImVec2(width,0.0f) for a specified width. ImVec2(0.0f,0.0f) uses ItemWidth.
@@ -1955,6 +1976,13 @@ static void ShowDemoWindowWidgets()
1955
1976
char buf[32 ];
1956
1977
sprintf (buf, " %d/%d" , (int )(progress_saturated * 1753 ), 1753 );
1957
1978
ImGui::ProgressBar (progress, ImVec2 (0 .f , 0 .f ), buf);
1979
+
1980
+ // Pass an animated negative value, e.g. -1.0f * (float)ImGui::GetTime() is the recommended value.
1981
+ // Adjust the factor if you want to adjust the animation speed.
1982
+ ImGui::ProgressBar (-1 .0f * (float )ImGui::GetTime (), ImVec2 (0 .0f , 0 .0f ), " Searching.." );
1983
+ ImGui::SameLine (0 .0f , ImGui::GetStyle ().ItemInnerSpacing .x );
1984
+ ImGui::Text (" Indeterminate" );
1985
+
1958
1986
ImGui::TreePop ();
1959
1987
}
1960
1988
@@ -2089,7 +2117,7 @@ static void ShowDemoWindowWidgets()
2089
2117
if (side_preview)
2090
2118
{
2091
2119
ImGui::SameLine ();
2092
- ImGui::Checkbox (" With Object Color" , &ref_color);
2120
+ ImGui::Checkbox (" With Ref Color" , &ref_color);
2093
2121
if (ref_color)
2094
2122
{
2095
2123
ImGui::SameLine ();
@@ -5216,7 +5244,8 @@ static void ShowDemoWindowTables()
5216
5244
static ImGuiTableFlags flags = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody;
5217
5245
5218
5246
static ImGuiTreeNodeFlags tree_node_flags = ImGuiTreeNodeFlags_SpanAllColumns;
5219
- ImGui::CheckboxFlags (" ImGuiTreeNodeFlags_SpanFullWidth" , &tree_node_flags, ImGuiTreeNodeFlags_SpanFullWidth);
5247
+ ImGui::CheckboxFlags (" ImGuiTreeNodeFlags_SpanFullWidth" , &tree_node_flags, ImGuiTreeNodeFlags_SpanFullWidth);
5248
+ ImGui::CheckboxFlags (" ImGuiTreeNodeFlags_SpanTextWidth" , &tree_node_flags, ImGuiTreeNodeFlags_SpanTextWidth);
5220
5249
ImGui::CheckboxFlags (" ImGuiTreeNodeFlags_SpanAllColumns" , &tree_node_flags, ImGuiTreeNodeFlags_SpanAllColumns);
5221
5250
5222
5251
HelpMarker (" See \" Columns flags\" section to configure how indentation is applied to individual columns." );
@@ -5405,6 +5434,17 @@ static void ShowDemoWindowTables()
5405
5434
ImGui::SliderInt (" Frozen rows" , &frozen_rows, 0 , 2 );
5406
5435
ImGui::CheckboxFlags (" Disable header contributing to column width" , &column_flags, ImGuiTableColumnFlags_NoHeaderWidth);
5407
5436
5437
+ if (ImGui::TreeNode (" Style settings" ))
5438
+ {
5439
+ ImGui::SameLine ();
5440
+ HelpMarker (" Giving access to some ImGuiStyle value in this demo for convenience." );
5441
+ ImGui::SetNextItemWidth (ImGui::GetFontSize () * 8 );
5442
+ ImGui::SliderAngle (" style.TableAngledHeadersAngle" , &ImGui::GetStyle ().TableAngledHeadersAngle , -50 .0f , +50 .0f );
5443
+ ImGui::SetNextItemWidth (ImGui::GetFontSize () * 8 );
5444
+ ImGui::SliderFloat2 (" style.TableAngledHeadersTextAlign" , (float *)&ImGui::GetStyle ().TableAngledHeadersTextAlign , 0 .0f , 1 .0f , " %.2f" );
5445
+ ImGui::TreePop ();
5446
+ }
5447
+
5408
5448
if (ImGui::BeginTable (" table_angled_headers" , columns_count, table_flags, ImVec2 (0 .0f , TEXT_BASE_HEIGHT * 12 )))
5409
5449
{
5410
5450
ImGui::TableSetupColumn (column_names[0 ], ImGuiTableColumnFlags_NoHide | ImGuiTableColumnFlags_NoReorder);
@@ -6669,10 +6709,10 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
6669
6709
{ bool border = (style.PopupBorderSize > 0 .0f ); if (ImGui::Checkbox (" PopupBorder" , &border)) { style.PopupBorderSize = border ? 1 .0f : 0 .0f ; } }
6670
6710
6671
6711
// Save/Revert button
6672
- if (ImGui::Button (" Save Object " ))
6712
+ if (ImGui::Button (" Save Ref " ))
6673
6713
*ref = ref_saved_style = style;
6674
6714
ImGui::SameLine ();
6675
- if (ImGui::Button (" Revert Object " ))
6715
+ if (ImGui::Button (" Revert Ref " ))
6676
6716
style = *ref;
6677
6717
ImGui::SameLine ();
6678
6718
HelpMarker (
@@ -6715,6 +6755,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
6715
6755
ImGui::SeparatorText (" Tables" );
6716
6756
ImGui::SliderFloat2 (" CellPadding" , (float *)&style.CellPadding , 0 .0f , 20 .0f , " %.0f" );
6717
6757
ImGui::SliderAngle (" TableAngledHeadersAngle" , &style.TableAngledHeadersAngle , -50 .0f , +50 .0f );
6758
+ ImGui::SliderFloat2 (" TableAngledHeadersTextAlign" , (float *)&style.TableAngledHeadersTextAlign , 0 .0f , 1 .0f , " %.2f" );
6718
6759
6719
6760
ImGui::SeparatorText (" Widgets" );
6720
6761
ImGui::SliderFloat2 (" WindowTitleAlign" , (float *)&style.WindowTitleAlign , 0 .0f , 1 .0f , " %.2f" );
0 commit comments