Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
imgui_demo.cpp
Go to the documentation of this file.
1 // dear imgui, v1.52 WIP
2 // (demo code)
3 
4 // Message to the person tempted to delete this file when integrating ImGui into their code base:
5 // Don't do it! Do NOT remove this file from your project! It is useful reference code that you and other users will want to refer to.
6 // Everything in this file will be stripped out by the linker if you don't call ImGui::ShowTestWindow().
7 // During development, you can call ImGui::ShowTestWindow() in your code to learn about various features of ImGui. Have it wired in a debug menu!
8 // Removing this file from your project is hindering access to documentation for everyone in your team, likely leading you to poorer usage of the library.
9 // Note that you can #define IMGUI_DISABLE_TEST_WINDOWS in imconfig.h for the same effect.
10 // If you want to link core ImGui in your public builds but not those test windows, #define IMGUI_DISABLE_TEST_WINDOWS in imconfig.h and those functions will be empty.
11 // For any other case, if you have ImGui available you probably want this to be available for reference and execution.
12 // Thank you,
13 // -Your beloved friend, imgui_demo.cpp (that you won't delete)
14 
15 // Message to beginner C/C++ programmer about the meaning of 'static': in this demo code, we frequently we use 'static' variables inside functions.
16 // We do this as a way to gather code and data in the same place, make the demo code faster to read, faster to write, and smaller. A static variable persist across calls,
17 // so it is essentially like a global variable but declared inside the scope of the function.
18 // It also happens to be a convenient way of storing simple UI related information as long as your function doesn't need to be reentrant or used in threads.
19 // This may be a pattern you want to use in your code (simple is beautiful!), but most of the real data you would be editing is likely to be stored outside your function.
20 
21 #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
22 #define _CRT_SECURE_NO_WARNINGS
23 #endif
24 
25 #include "imgui.h"
26 #include <ctype.h> // toupper, isprint
27 #include <math.h> // sqrtf, powf, cosf, sinf, floorf, ceilf
28 #include <stdio.h> // vsnprintf, sscanf, printf
29 #include <stdlib.h> // NULL, malloc, free, atoi
30 #if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
31 #include <stddef.h> // intptr_t
32 #else
33 #include <stdint.h> // intptr_t
34 #endif
35 
36 #ifdef _MSC_VER
37 #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
38 #define snprintf _snprintf
39 #endif
40 #ifdef __clang__
41 #pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
42 #pragma clang diagnostic ignored "-Wdeprecated-declarations" // warning : 'xx' is deprecated: The POSIX name for this item.. // for strdup used in demo code (so user can copy & paste the code)
43 #pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int'
44 #pragma clang diagnostic ignored "-Wformat-security" // warning : warning: format string is not a string literal
45 #pragma clang diagnostic ignored "-Wexit-time-destructors" // warning : declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals.
46 #if __has_warning("-Wreserved-id-macro")
47 #pragma clang diagnostic ignored "-Wreserved-id-macro" // warning : macro name is a reserved identifier //
48 #endif
49 #elif defined(__GNUC__)
50 #pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
51 #pragma GCC diagnostic ignored "-Wformat-security" // warning : format string is not a string literal (potentially insecure)
52 #pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
53 #pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
54 #if (__GNUC__ >= 6)
55 #pragma GCC diagnostic ignored "-Wmisleading-indentation" // warning: this 'if' clause does not guard this statement // GCC 6.0+ only. See #883 on github.
56 #endif
57 #endif
58 
59 // Play it nice with Windows users. Notepad in 2015 still doesn't display text data with Unix-style \n.
60 #ifdef _WIN32
61 #define IM_NEWLINE "\r\n"
62 #else
63 #define IM_NEWLINE "\n"
64 #endif
65 
66 #define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR)))
67 #define IM_MAX(_A,_B) (((_A) >= (_B)) ? (_A) : (_B))
68 
69 //-----------------------------------------------------------------------------
70 // DEMO CODE
71 //-----------------------------------------------------------------------------
72 
73 #ifndef IMGUI_DISABLE_TEST_WINDOWS
74 
75 static void ShowExampleAppConsole(bool* p_open);
76 static void ShowExampleAppLog(bool* p_open);
77 static void ShowExampleAppLayout(bool* p_open);
78 static void ShowExampleAppPropertyEditor(bool* p_open);
79 static void ShowExampleAppLongText(bool* p_open);
80 static void ShowExampleAppAutoResize(bool* p_open);
81 static void ShowExampleAppConstrainedResize(bool* p_open);
82 static void ShowExampleAppFixedOverlay(bool* p_open);
83 static void ShowExampleAppManipulatingWindowTitle(bool* p_open);
84 static void ShowExampleAppCustomRendering(bool* p_open);
85 static void ShowExampleAppMainMenuBar();
86 static void ShowExampleMenuFile();
87 
88 static void ShowHelpMarker(const char* desc)
89 {
90  ImGui::TextDisabled("(?)");
92  {
94  ImGui::PushTextWrapPos(450.0f);
98  }
99 }
100 
102 {
103  ImGui::BulletText("Double-click on title bar to collapse window.");
104  ImGui::BulletText("Click and drag on lower right corner to resize window.");
105  ImGui::BulletText("Click and drag on any empty space to move window.");
106  ImGui::BulletText("Mouse Wheel to scroll.");
107  if (ImGui::GetIO().FontAllowUserScaling)
108  ImGui::BulletText("CTRL+Mouse Wheel to zoom window contents.");
109  ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
110  ImGui::BulletText("CTRL+Click on a slider or drag box to input text.");
112  "While editing text:\n"
113  "- Hold SHIFT or use mouse to select text\n"
114  "- CTRL+Left/Right to word jump\n"
115  "- CTRL+A or double-click to select all\n"
116  "- CTRL+X,CTRL+C,CTRL+V clipboard\n"
117  "- CTRL+Z,CTRL+Y undo/redo\n"
118  "- ESCAPE to revert\n"
119  "- You can apply arithmetic operators +,*,/ on numerical values.\n"
120  " Use +- to subtract.\n");
121 }
122 
123 // Demonstrate most ImGui features (big function!)
124 void ImGui::ShowTestWindow(bool* p_open)
125 {
126  // Examples apps
127  static bool show_app_main_menu_bar = false;
128  static bool show_app_console = false;
129  static bool show_app_log = false;
130  static bool show_app_layout = false;
131  static bool show_app_property_editor = false;
132  static bool show_app_long_text = false;
133  static bool show_app_auto_resize = false;
134  static bool show_app_constrained_resize = false;
135  static bool show_app_fixed_overlay = false;
136  static bool show_app_manipulating_window_title = false;
137  static bool show_app_custom_rendering = false;
138  static bool show_app_style_editor = false;
139 
140  static bool show_app_metrics = false;
141  static bool show_app_about = false;
142 
143  if (show_app_main_menu_bar) ShowExampleAppMainMenuBar();
144  if (show_app_console) ShowExampleAppConsole(&show_app_console);
145  if (show_app_log) ShowExampleAppLog(&show_app_log);
146  if (show_app_layout) ShowExampleAppLayout(&show_app_layout);
147  if (show_app_property_editor) ShowExampleAppPropertyEditor(&show_app_property_editor);
148  if (show_app_long_text) ShowExampleAppLongText(&show_app_long_text);
149  if (show_app_auto_resize) ShowExampleAppAutoResize(&show_app_auto_resize);
150  if (show_app_constrained_resize) ShowExampleAppConstrainedResize(&show_app_constrained_resize);
151  if (show_app_fixed_overlay) ShowExampleAppFixedOverlay(&show_app_fixed_overlay);
152  if (show_app_manipulating_window_title) ShowExampleAppManipulatingWindowTitle(&show_app_manipulating_window_title);
153  if (show_app_custom_rendering) ShowExampleAppCustomRendering(&show_app_custom_rendering);
154 
155  if (show_app_metrics) ImGui::ShowMetricsWindow(&show_app_metrics);
156  if (show_app_style_editor) { ImGui::Begin("Style Editor", &show_app_style_editor); ImGui::ShowStyleEditor(); ImGui::End(); }
157  if (show_app_about)
158  {
159  ImGui::Begin("About ImGui", &show_app_about, ImGuiWindowFlags_AlwaysAutoResize);
160  ImGui::Text("dear imgui, %s", ImGui::GetVersion());
162  ImGui::Text("By Omar Cornut and all github contributors.");
163  ImGui::Text("ImGui is licensed under the MIT License, see LICENSE for more information.");
164  ImGui::End();
165  }
166 
167  static bool no_titlebar = false;
168  static bool no_border = true;
169  static bool no_resize = false;
170  static bool no_move = false;
171  static bool no_scrollbar = false;
172  static bool no_collapse = false;
173  static bool no_menu = false;
174 
175  // Demonstrate the various window flags. Typically you would just use the default.
176  ImGuiWindowFlags window_flags = 0;
177  if (no_titlebar) window_flags |= ImGuiWindowFlags_NoTitleBar;
178  if (!no_border) window_flags |= ImGuiWindowFlags_ShowBorders;
179  if (no_resize) window_flags |= ImGuiWindowFlags_NoResize;
180  if (no_move) window_flags |= ImGuiWindowFlags_NoMove;
181  if (no_scrollbar) window_flags |= ImGuiWindowFlags_NoScrollbar;
182  if (no_collapse) window_flags |= ImGuiWindowFlags_NoCollapse;
183  if (!no_menu) window_flags |= ImGuiWindowFlags_MenuBar;
185  if (!ImGui::Begin("ImGui Demo", p_open, window_flags))
186  {
187  // Early out if the window is collapsed, as an optimization.
188  ImGui::End();
189  return;
190  }
191 
192  //ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.65f); // 2/3 of the space for widget and 1/3 for labels
193  ImGui::PushItemWidth(-140); // Right align, keep 140 pixels for labels
194 
195  ImGui::Text("dear imgui says hello. (%s)", IMGUI_VERSION);
196 
197  // Menu
198  if (ImGui::BeginMenuBar())
199  {
200  if (ImGui::BeginMenu("Menu"))
201  {
202  ShowExampleMenuFile();
203  ImGui::EndMenu();
204  }
205  if (ImGui::BeginMenu("Examples"))
206  {
207  ImGui::MenuItem("Main menu bar", NULL, &show_app_main_menu_bar);
208  ImGui::MenuItem("Console", NULL, &show_app_console);
209  ImGui::MenuItem("Log", NULL, &show_app_log);
210  ImGui::MenuItem("Simple layout", NULL, &show_app_layout);
211  ImGui::MenuItem("Property editor", NULL, &show_app_property_editor);
212  ImGui::MenuItem("Long text display", NULL, &show_app_long_text);
213  ImGui::MenuItem("Auto-resizing window", NULL, &show_app_auto_resize);
214  ImGui::MenuItem("Constrained-resizing window", NULL, &show_app_constrained_resize);
215  ImGui::MenuItem("Simple overlay", NULL, &show_app_fixed_overlay);
216  ImGui::MenuItem("Manipulating window title", NULL, &show_app_manipulating_window_title);
217  ImGui::MenuItem("Custom rendering", NULL, &show_app_custom_rendering);
218  ImGui::EndMenu();
219  }
220  if (ImGui::BeginMenu("Help"))
221  {
222  ImGui::MenuItem("Metrics", NULL, &show_app_metrics);
223  ImGui::MenuItem("Style Editor", NULL, &show_app_style_editor);
224  ImGui::MenuItem("About ImGui", NULL, &show_app_about);
225  ImGui::EndMenu();
226  }
228  }
229 
230  ImGui::Spacing();
231  if (ImGui::CollapsingHeader("Help"))
232  {
233  ImGui::TextWrapped("This window is being created by the ShowTestWindow() function. Please refer to the code for programming reference.\n\nUser Guide:");
235  }
236 
237  if (ImGui::CollapsingHeader("Window options"))
238  {
239  ImGui::Checkbox("No titlebar", &no_titlebar); ImGui::SameLine(150);
240  ImGui::Checkbox("No border", &no_border); ImGui::SameLine(300);
241  ImGui::Checkbox("No resize", &no_resize);
242  ImGui::Checkbox("No move", &no_move); ImGui::SameLine(150);
243  ImGui::Checkbox("No scrollbar", &no_scrollbar); ImGui::SameLine(300);
244  ImGui::Checkbox("No collapse", &no_collapse);
245  ImGui::Checkbox("No menu", &no_menu);
246 
247  if (ImGui::TreeNode("Style"))
248  {
250  ImGui::TreePop();
251  }
252 
253  if (ImGui::TreeNode("Logging"))
254  {
255  ImGui::TextWrapped("The logging API redirects all text output so you can easily capture the content of a window or a block. Tree nodes can be automatically expanded. You can also call ImGui::LogText() to output directly to the log without a visual output.");
257  ImGui::TreePop();
258  }
259  }
260 
261  if (ImGui::CollapsingHeader("Widgets"))
262  {
263  if (ImGui::TreeNode("Basic"))
264  {
265  static int clicked = 0;
266  if (ImGui::Button("Button"))
267  clicked++;
268  if (clicked & 1)
269  {
270  ImGui::SameLine();
271  ImGui::Text("Thanks for clicking me!");
272  }
273 
274  static bool check = true;
275  ImGui::Checkbox("checkbox", &check);
276 
277  static int e = 0;
278  ImGui::RadioButton("radio a", &e, 0); ImGui::SameLine();
279  ImGui::RadioButton("radio b", &e, 1); ImGui::SameLine();
280  ImGui::RadioButton("radio c", &e, 2);
281 
282  // Color buttons, demonstrate using PushID() to add unique identifier in the ID stack, and changing style.
283  for (int i = 0; i < 7; i++)
284  {
285  if (i > 0) ImGui::SameLine();
286  ImGui::PushID(i);
290  ImGui::Button("Click");
292  ImGui::PopID();
293  }
294 
295  ImGui::Text("Hover over me");
296  if (ImGui::IsItemHovered())
297  ImGui::SetTooltip("I am a tooltip");
298 
299  ImGui::SameLine();
300  ImGui::Text("- or me");
301  if (ImGui::IsItemHovered())
302  {
304  ImGui::Text("I am a fancy tooltip");
305  static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f };
306  ImGui::PlotLines("Curve", arr, IM_ARRAYSIZE(arr));
308  }
309 
310  // Testing ImGuiOnceUponAFrame helper.
311  //static ImGuiOnceUponAFrame once;
312  //for (int i = 0; i < 5; i++)
313  // if (once)
314  // ImGui::Text("This will be displayed only once.");
315 
317 
318  ImGui::LabelText("label", "Value");
319 
320  static int item = 1;
321  ImGui::Combo("combo", &item, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0"); // Combo using values packed in a single constant string (for really quick combo)
322 
323  const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK" };
324  static int item2 = -1;
325  ImGui::Combo("combo scroll", &item2, items, IM_ARRAYSIZE(items)); // Combo using proper array. You can also pass a callback to retrieve array value, no need to create/copy an array just for that.
326 
327  {
328  static char str0[128] = "Hello, world!";
329  static int i0=123;
330  static float f0=0.001f;
331  ImGui::InputText("input text", str0, IM_ARRAYSIZE(str0));
332  ImGui::SameLine(); ShowHelpMarker("Hold SHIFT or use mouse to select text.\n" "CTRL+Left/Right to word jump.\n" "CTRL+A or double-click to select all.\n" "CTRL+X,CTRL+C,CTRL+V clipboard.\n" "CTRL+Z,CTRL+Y undo/redo.\n" "ESCAPE to revert.\n");
333 
334  ImGui::InputInt("input int", &i0);
335  ImGui::SameLine(); ShowHelpMarker("You can apply arithmetic operators +,*,/ on numerical values.\n e.g. [ 100 ], input \'*2\', result becomes [ 200 ]\nUse +- to subtract.\n");
336 
337  ImGui::InputFloat("input float", &f0, 0.01f, 1.0f);
338 
339  static float vec4a[4] = { 0.10f, 0.20f, 0.30f, 0.44f };
340  ImGui::InputFloat3("input float3", vec4a);
341  }
342 
343  {
344  static int i1=50, i2=42;
345  ImGui::DragInt("drag int", &i1, 1);
346  ImGui::SameLine(); ShowHelpMarker("Click and drag to edit value.\nHold SHIFT/ALT for faster/slower edit.\nDouble-click or CTRL+click to input value.");
347 
348  ImGui::DragInt("drag int 0..100", &i2, 1, 0, 100, "%.0f%%");
349 
350  static float f1=1.00f, f2=0.0067f;
351  ImGui::DragFloat("drag float", &f1, 0.005f);
352  ImGui::DragFloat("drag small float", &f2, 0.0001f, 0.0f, 0.0f, "%.06f ns");
353  }
354 
355  {
356  static int i1=0;
357  ImGui::SliderInt("slider int", &i1, -1, 3);
358  ImGui::SameLine(); ShowHelpMarker("CTRL+click to input value.");
359 
360  static float f1=0.123f, f2=0.0f;
361  ImGui::SliderFloat("slider float", &f1, 0.0f, 1.0f, "ratio = %.3f");
362  ImGui::SliderFloat("slider log float", &f2, -10.0f, 10.0f, "%.4f", 3.0f);
363  static float angle = 0.0f;
364  ImGui::SliderAngle("slider angle", &angle);
365  }
366 
367  static float col1[3] = { 1.0f,0.0f,0.2f };
368  static float col2[4] = { 0.4f,0.7f,0.0f,0.5f };
369  ImGui::ColorEdit3("color 1", col1);
370  ImGui::SameLine(); ShowHelpMarker("Click on the colored square to open a color picker.\nRight-click on the colored square to show options.\nCTRL+click on individual component to input value.\n");
371 
372  ImGui::ColorEdit4("color 2", col2);
373 
374  const char* listbox_items[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" };
375  static int listbox_item_current = 1;
376  ImGui::ListBox("listbox\n(single select)", &listbox_item_current, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
377 
378  //static int listbox_item_current2 = 2;
379  //ImGui::PushItemWidth(-1);
380  //ImGui::ListBox("##listbox2", &listbox_item_current2, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
381  //ImGui::PopItemWidth();
382 
383  ImGui::TreePop();
384  }
385 
386  if (ImGui::TreeNode("Trees"))
387  {
388  if (ImGui::TreeNode("Basic trees"))
389  {
390  for (int i = 0; i < 5; i++)
391  if (ImGui::TreeNode((void*)(intptr_t)i, "Child %d", i))
392  {
393  ImGui::Text("blah blah");
394  ImGui::SameLine();
395  if (ImGui::SmallButton("print")) printf("Child %d pressed", i);
396  ImGui::TreePop();
397  }
398  ImGui::TreePop();
399  }
400 
401  if (ImGui::TreeNode("Advanced, with Selectable nodes"))
402  {
403  ShowHelpMarker("This is a more standard looking tree with selectable nodes.\nClick to select, CTRL+Click to toggle, click on arrows or double-click to open.");
404  static bool align_label_with_current_x_position = false;
405  ImGui::Checkbox("Align label with current X position)", &align_label_with_current_x_position);
406  ImGui::Text("Hello!");
407  if (align_label_with_current_x_position)
409 
410  static int selection_mask = (1 << 2); // Dumb representation of what may be user-side selection state. You may carry selection state inside or outside your objects in whatever format you see fit.
411  int node_clicked = -1; // Temporary storage of what node we have clicked to process selection at the end of the loop. May be a pointer to your own node type, etc.
412  ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, ImGui::GetFontSize()*3); // Increase spacing to differentiate leaves from expanded contents.
413  for (int i = 0; i < 6; i++)
414  {
415  // Disable the default open on single-click behavior and pass in Selected flag according to our selection state.
417  if (i < 3)
418  {
419  // Node
420  bool node_open = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Node %d", i);
421  if (ImGui::IsItemClicked())
422  node_clicked = i;
423  if (node_open)
424  {
425  ImGui::Text("Blah blah\nBlah Blah");
426  ImGui::TreePop();
427  }
428  }
429  else
430  {
431  // Leaf: The only reason we have a TreeNode at all is to allow selection of the leaf. Otherwise we can use BulletText() or TreeAdvanceToLabelPos()+Text().
432  ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags | ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen, "Selectable Leaf %d", i);
433  if (ImGui::IsItemClicked())
434  node_clicked = i;
435  }
436  }
437  if (node_clicked != -1)
438  {
439  // Update selection state. Process outside of tree loop to avoid visual inconsistencies during the clicking-frame.
440  if (ImGui::GetIO().KeyCtrl)
441  selection_mask ^= (1 << node_clicked); // CTRL+click to toggle
442  else //if (!(selection_mask & (1 << node_clicked))) // Depending on selection behavior you want, this commented bit preserve selection when clicking on item that is part of the selection
443  selection_mask = (1 << node_clicked); // Click to single-select
444  }
446  if (align_label_with_current_x_position)
448  ImGui::TreePop();
449  }
450  ImGui::TreePop();
451  }
452 
453  if (ImGui::TreeNode("Collapsing Headers"))
454  {
455  static bool closable_group = true;
456  if (ImGui::CollapsingHeader("Header"))
457  {
458  ImGui::Checkbox("Enable extra group", &closable_group);
459  for (int i = 0; i < 5; i++)
460  ImGui::Text("Some content %d", i);
461  }
462  if (ImGui::CollapsingHeader("Header with a close button", &closable_group))
463  {
464  for (int i = 0; i < 5; i++)
465  ImGui::Text("More content %d", i);
466  }
467  ImGui::TreePop();
468  }
469 
470  if (ImGui::TreeNode("Bullets"))
471  {
472  ImGui::BulletText("Bullet point 1");
473  ImGui::BulletText("Bullet point 2\nOn multiple lines");
474  ImGui::Bullet(); ImGui::Text("Bullet point 3 (two calls)");
475  ImGui::Bullet(); ImGui::SmallButton("Button");
476  ImGui::TreePop();
477  }
478 
479  if (ImGui::TreeNode("Text"))
480  {
481  if (ImGui::TreeNode("Colored Text"))
482  {
483  // Using shortcut. You can use PushStyleColor()/PopStyleColor() for more flexibility.
484  ImGui::TextColored(ImVec4(1.0f,0.0f,1.0f,1.0f), "Pink");
485  ImGui::TextColored(ImVec4(1.0f,1.0f,0.0f,1.0f), "Yellow");
486  ImGui::TextDisabled("Disabled");
487  ImGui::SameLine(); ShowHelpMarker("The TextDisabled color is stored in ImGuiStyle.");
488  ImGui::TreePop();
489  }
490 
491  if (ImGui::TreeNode("Word Wrapping"))
492  {
493  // Using shortcut. You can use PushTextWrapPos()/PopTextWrapPos() for more flexibility.
494  ImGui::TextWrapped("This text should automatically wrap on the edge of the window. The current implementation for text wrapping follows simple rules suitable for English and possibly other languages.");
495  ImGui::Spacing();
496 
497  static float wrap_width = 200.0f;
498  ImGui::SliderFloat("Wrap width", &wrap_width, -20, 600, "%.0f");
499 
500  ImGui::Text("Test paragraph 1:");
502  ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(pos.x + wrap_width, pos.y), ImVec2(pos.x + wrap_width + 10, pos.y + ImGui::GetTextLineHeight()), IM_COL32(255,0,255,255));
504  ImGui::Text("The lazy dog is a good dog. This paragraph is made to fit within %.0f pixels. Testing a 1 character word. The quick brown fox jumps over the lazy dog.", wrap_width);
507 
508  ImGui::Text("Test paragraph 2:");
510  ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(pos.x + wrap_width, pos.y), ImVec2(pos.x + wrap_width + 10, pos.y + ImGui::GetTextLineHeight()), IM_COL32(255,0,255,255));
512  ImGui::Text("aaaaaaaa bbbbbbbb, c cccccccc,dddddddd. d eeeeeeee ffffffff. gggggggg!hhhhhhhh");
515 
516  ImGui::TreePop();
517  }
518 
519  if (ImGui::TreeNode("UTF-8 Text"))
520  {
521  // UTF-8 test with Japanese characters
522  // (needs a suitable font, try Arial Unicode or M+ fonts http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/index-en.html)
523  // - From C++11 you can use the u8"my text" syntax to encode literal strings as UTF-8
524  // - For earlier compiler, you may be able to encode your sources as UTF-8 (e.g. Visual Studio save your file as 'UTF-8 without signature')
525  // - HOWEVER, FOR THIS DEMO FILE, BECAUSE WE WANT TO SUPPORT COMPILER, WE ARE *NOT* INCLUDING RAW UTF-8 CHARACTERS IN THIS SOURCE FILE.
526  // Instead we are encoding a few string with hexadecimal constants. Don't do this in your application!
527  // Note that characters values are preserved even by InputText() if the font cannot be displayed, so you can safely copy & paste garbled characters into another application.
528  ImGui::TextWrapped("CJK text will only appears if the font was loaded with the appropriate CJK character ranges. Call io.Font->LoadFromFileTTF() manually to load extra character ranges.");
529  ImGui::Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)");
530  ImGui::Text("Kanjis: \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e (nihongo)");
531  static char buf[32] = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e"; // "nihongo"
532  ImGui::InputText("UTF-8 input", buf, IM_ARRAYSIZE(buf));
533  ImGui::TreePop();
534  }
535  ImGui::TreePop();
536  }
537 
538  if (ImGui::TreeNode("Images"))
539  {
540  ImGui::TextWrapped("Below we are displaying the font texture (which is the only texture we have access to in this demo). Use the 'ImTextureID' type as storage to pass pointers or identifier to your own texture data. Hover the texture for a zoomed view!");
541  ImVec2 tex_screen_pos = ImGui::GetCursorScreenPos();
542  float tex_w = (float)ImGui::GetIO().Fonts->TexWidth;
543  float tex_h = (float)ImGui::GetIO().Fonts->TexHeight;
544  ImTextureID tex_id = ImGui::GetIO().Fonts->TexID;
545  ImGui::Text("%.0fx%.0f", tex_w, tex_h);
546  ImGui::Image(tex_id, ImVec2(tex_w, tex_h), ImVec2(0,0), ImVec2(1,1), ImColor(255,255,255,255), ImColor(255,255,255,128));
547  if (ImGui::IsItemHovered())
548  {
550  float focus_sz = 32.0f;
551  float focus_x = ImGui::GetMousePos().x - tex_screen_pos.x - focus_sz * 0.5f; if (focus_x < 0.0f) focus_x = 0.0f; else if (focus_x > tex_w - focus_sz) focus_x = tex_w - focus_sz;
552  float focus_y = ImGui::GetMousePos().y - tex_screen_pos.y - focus_sz * 0.5f; if (focus_y < 0.0f) focus_y = 0.0f; else if (focus_y > tex_h - focus_sz) focus_y = tex_h - focus_sz;
553  ImGui::Text("Min: (%.2f, %.2f)", focus_x, focus_y);
554  ImGui::Text("Max: (%.2f, %.2f)", focus_x + focus_sz, focus_y + focus_sz);
555  ImVec2 uv0 = ImVec2((focus_x) / tex_w, (focus_y) / tex_h);
556  ImVec2 uv1 = ImVec2((focus_x + focus_sz) / tex_w, (focus_y + focus_sz) / tex_h);
557  ImGui::Image(tex_id, ImVec2(128,128), uv0, uv1, ImColor(255,255,255,255), ImColor(255,255,255,128));
559  }
560  ImGui::TextWrapped("And now some textured buttons..");
561  static int pressed_count = 0;
562  for (int i = 0; i < 8; i++)
563  {
564  ImGui::PushID(i);
565  int frame_padding = -1 + i; // -1 = uses default padding
566  if (ImGui::ImageButton(tex_id, ImVec2(32,32), ImVec2(0,0), ImVec2(32.0f/tex_w,32/tex_h), frame_padding, ImColor(0,0,0,255)))
567  pressed_count += 1;
568  ImGui::PopID();
569  ImGui::SameLine();
570  }
571  ImGui::NewLine();
572  ImGui::Text("Pressed %d times.", pressed_count);
573  ImGui::TreePop();
574  }
575 
576  if (ImGui::TreeNode("Selectables"))
577  {
578  if (ImGui::TreeNode("Basic"))
579  {
580  static bool selected[4] = { false, true, false, false };
581  ImGui::Selectable("1. I am selectable", &selected[0]);
582  ImGui::Selectable("2. I am selectable", &selected[1]);
583  ImGui::Text("3. I am not selectable");
584  ImGui::Selectable("4. I am selectable", &selected[2]);
585  if (ImGui::Selectable("5. I am double clickable", selected[3], ImGuiSelectableFlags_AllowDoubleClick))
587  selected[3] = !selected[3];
588  ImGui::TreePop();
589  }
590  if (ImGui::TreeNode("Rendering more text into the same block"))
591  {
592  static bool selected[3] = { false, false, false };
593  ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
594  ImGui::Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(300); ImGui::Text("12,345 bytes");
595  ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
596  ImGui::TreePop();
597  }
598  if (ImGui::TreeNode("In columns"))
599  {
600  ImGui::Columns(3, NULL, false);
601  static bool selected[16] = { 0 };
602  for (int i = 0; i < 16; i++)
603  {
604  char label[32]; sprintf(label, "Item %d", i);
605  if (ImGui::Selectable(label, &selected[i])) {}
607  }
608  ImGui::Columns(1);
609  ImGui::TreePop();
610  }
611  if (ImGui::TreeNode("Grid"))
612  {
613  static bool selected[16] = { true, false, false, false, false, true, false, false, false, false, true, false, false, false, false, true };
614  for (int i = 0; i < 16; i++)
615  {
616  ImGui::PushID(i);
617  if (ImGui::Selectable("Sailor", &selected[i], 0, ImVec2(50,50)))
618  {
619  int x = i % 4, y = i / 4;
620  if (x > 0) selected[i - 1] ^= 1;
621  if (x < 3) selected[i + 1] ^= 1;
622  if (y > 0) selected[i - 4] ^= 1;
623  if (y < 3) selected[i + 4] ^= 1;
624  }
625  if ((i % 4) < 3) ImGui::SameLine();
626  ImGui::PopID();
627  }
628  ImGui::TreePop();
629  }
630  ImGui::TreePop();
631  }
632 
633  if (ImGui::TreeNode("Filtered Text Input"))
634  {
635  static char buf1[64] = ""; ImGui::InputText("default", buf1, 64);
636  static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal);
637  static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
638  static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase);
639  static char buf5[64] = ""; ImGui::InputText("no blank", buf5, 64, ImGuiInputTextFlags_CharsNoBlank);
640  struct TextFilters { static int FilterImGuiLetters(ImGuiTextEditCallbackData* data) { if (data->EventChar < 256 && strchr("imgui", (char)data->EventChar)) return 0; return 1; } };
641  static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters);
642 
643  ImGui::Text("Password input");
644  static char bufpass[64] = "password123";
646  ImGui::SameLine(); ShowHelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n");
647  ImGui::InputText("password (clear)", bufpass, 64, ImGuiInputTextFlags_CharsNoBlank);
648 
649  ImGui::TreePop();
650  }
651 
652  if (ImGui::TreeNode("Multi-line Text Input"))
653  {
654  static bool read_only = false;
655  static char text[1024*16] =
656  "/*\n"
657  " The Pentium F00F bug, shorthand for F0 0F C7 C8,\n"
658  " the hexadecimal encoding of one offending instruction,\n"
659  " more formally, the invalid operand with locked CMPXCHG8B\n"
660  " instruction bug, is a design flaw in the majority of\n"
661  " Intel Pentium, Pentium MMX, and Pentium OverDrive\n"
662  " processors (all in the P5 microarchitecture).\n"
663  "*/\n\n"
664  "label:\n"
665  "\tlock cmpxchg8b eax\n";
666 
668  ImGui::Checkbox("Read-only", &read_only);
671  ImGui::TreePop();
672  }
673 
674 
675  if (ImGui::TreeNode("Plots widgets"))
676  {
677  static bool animate = true;
678  ImGui::Checkbox("Animate", &animate);
679 
680  static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f };
681  ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr));
682 
683  // Create a dummy array of contiguous float values to plot
684  // Tip: If your float aren't contiguous but part of a structure, you can pass a pointer to your first float and the sizeof() of your structure in the Stride parameter.
685  static float values[90] = { 0 };
686  static int values_offset = 0;
687  static float refresh_time = 0.0f;
688  if (!animate || refresh_time == 0.0f)
689  refresh_time = ImGui::GetTime();
690  while (refresh_time < ImGui::GetTime()) // Create dummy data at fixed 60 hz rate for the demo
691  {
692  static float phase = 0.0f;
693  values[values_offset] = cosf(phase);
694  values_offset = (values_offset+1) % IM_ARRAYSIZE(values);
695  phase += 0.10f*values_offset;
696  refresh_time += 1.0f/60.0f;
697  }
698  ImGui::PlotLines("Lines", values, IM_ARRAYSIZE(values), values_offset, "avg 0.0", -1.0f, 1.0f, ImVec2(0,80));
699  ImGui::PlotHistogram("Histogram", arr, IM_ARRAYSIZE(arr), 0, NULL, 0.0f, 1.0f, ImVec2(0,80));
700 
701  // Use functions to generate output
702  // FIXME: This is rather awkward because current plot API only pass in indices. We probably want an API passing floats and user provide sample rate/count.
703  struct Funcs
704  {
705  static float Sin(void*, int i) { return sinf(i * 0.1f); }
706  static float Saw(void*, int i) { return (i & 1) ? 1.0f : -1.0f; }
707  };
708  static int func_type = 0, display_count = 70;
710  ImGui::PushItemWidth(100); ImGui::Combo("func", &func_type, "Sin\0Saw\0"); ImGui::PopItemWidth();
711  ImGui::SameLine();
712  ImGui::SliderInt("Sample count", &display_count, 1, 400);
713  float (*func)(void*, int) = (func_type == 0) ? Funcs::Sin : Funcs::Saw;
714  ImGui::PlotLines("Lines", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0,80));
715  ImGui::PlotHistogram("Histogram", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0,80));
717 
718  // Animate a simple progress bar
719  static float progress = 0.0f, progress_dir = 1.0f;
720  if (animate)
721  {
722  progress += progress_dir * 0.4f * ImGui::GetIO().DeltaTime;
723  if (progress >= +1.1f) { progress = +1.1f; progress_dir *= -1.0f; }
724  if (progress <= -0.1f) { progress = -0.1f; progress_dir *= -1.0f; }
725  }
726 
727  // Typically we would use ImVec2(-1.0f,0.0f) to use all available width, or ImVec2(width,0.0f) for a specified width. ImVec2(0.0f,0.0f) uses ItemWidth.
728  ImGui::ProgressBar(progress, ImVec2(0.0f,0.0f));
729  ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
730  ImGui::Text("Progress Bar");
731 
732  float progress_saturated = (progress < 0.0f) ? 0.0f : (progress > 1.0f) ? 1.0f : progress;
733  char buf[32];
734  sprintf(buf, "%d/%d", (int)(progress_saturated*1753), 1753);
735  ImGui::ProgressBar(progress, ImVec2(0.f,0.f), buf);
736  ImGui::TreePop();
737  }
738 
739  if (ImGui::TreeNode("Color/Picker Widgets"))
740  {
741  static ImVec4 color = ImColor(114, 144, 154, 200);
742 
743  static bool hdr = false;
744  static bool alpha_preview = true;
745  static bool alpha_half_preview = false;
746  static bool options_menu = true;
747  ImGui::Checkbox("With HDR", &hdr); ImGui::SameLine(); ShowHelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets.");
748  ImGui::Checkbox("With Alpha Preview", &alpha_preview);
749  ImGui::Checkbox("With Half Alpha Preview", &alpha_half_preview);
750  ImGui::Checkbox("With Options Menu", &options_menu); ImGui::SameLine(); ShowHelpMarker("Right-click on the individual color widget to show options.");
751  int misc_flags = (hdr ? ImGuiColorEditFlags_HDR : 0) | (alpha_half_preview ? ImGuiColorEditFlags_AlphaPreviewHalf : (alpha_preview ? ImGuiColorEditFlags_AlphaPreview : 0)) | (options_menu ? 0 : ImGuiColorEditFlags_NoOptions);
752 
753  ImGui::Text("Color widget:");
754  ImGui::SameLine(); ShowHelpMarker("Click on the colored square to open a color picker.\nCTRL+click on individual component to input value.\n");
755  ImGui::ColorEdit3("MyColor##1", (float*)&color, misc_flags);
756 
757  ImGui::Text("Color widget HSV with Alpha:");
758  ImGui::ColorEdit4("MyColor##2", (float*)&color, ImGuiColorEditFlags_HSV | misc_flags);
759 
760  ImGui::Text("Color widget with Float Display:");
761  ImGui::ColorEdit4("MyColor##2f", (float*)&color, ImGuiColorEditFlags_Float | misc_flags);
762 
763  ImGui::Text("Color button with Picker:");
764  ImGui::SameLine(); ShowHelpMarker("With the ImGuiColorEditFlags_NoInputs flag you can hide all the slider/text inputs.\nWith the ImGuiColorEditFlags_NoLabel flag you can pass a non-empty label which will only be used for the tooltip and picker popup.");
765  ImGui::ColorEdit4("MyColor##3", (float*)&color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | misc_flags);
766 
767  ImGui::Text("Color button with Custom Picker Popup:");
768  static bool saved_palette_inited = false;
769  static ImVec4 saved_palette[32];
770  static ImVec4 backup_color;
771  if (!saved_palette_inited)
772  for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++)
773  ImGui::ColorConvertHSVtoRGB(n / 31.0f, 0.8f, 0.8f, saved_palette[n].x, saved_palette[n].y, saved_palette[n].z);
774  bool open_popup = ImGui::ColorButton("MyColor##3b", color, misc_flags);
775  ImGui::SameLine();
776  open_popup |= ImGui::Button("Palette");
777  if (open_popup)
778  {
779  ImGui::OpenPopup("mypicker");
780  backup_color = color;
781  }
782  if (ImGui::BeginPopup("mypicker"))
783  {
784  // FIXME: Adding a drag and drop example here would be perfect!
785  ImGui::Text("MY CUSTOM COLOR PICKER WITH AN AMAZING PALETTE!");
788  ImGui::SameLine();
790  ImGui::Text("Current");
792  ImGui::Text("Previous");
794  color = backup_color;
796  ImGui::Text("Palette");
797  for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++)
798  {
799  ImGui::PushID(n);
800  if ((n % 8) != 0)
801  ImGui::SameLine(0.0f, ImGui::GetStyle().ItemSpacing.y);
802  if (ImGui::ColorButton("##palette", saved_palette[n], ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoTooltip, ImVec2(20,20)))
803  color = ImVec4(saved_palette[n].x, saved_palette[n].y, saved_palette[n].z, color.w); // Preserve alpha!
804  ImGui::PopID();
805  }
806  ImGui::EndGroup();
807  ImGui::EndPopup();
808  }
809 
810  ImGui::Text("Color button only:");
811  ImGui::ColorButton("MyColor##3c", *(ImVec4*)&color, misc_flags, ImVec2(80,80));
812 
813  ImGui::Text("Color picker:");
814  static bool alpha = true;
815  static bool alpha_bar = true;
816  static bool side_preview = true;
817  static bool ref_color = false;
818  static ImVec4 ref_color_v(1.0f,0.0f,1.0f,0.5f);
819  static int inputs_mode = 2;
820  static int picker_mode = 0;
821  ImGui::Checkbox("With Alpha", &alpha);
822  ImGui::Checkbox("With Alpha Bar", &alpha_bar);
823  ImGui::Checkbox("With Side Preview", &side_preview);
824  if (side_preview)
825  {
826  ImGui::SameLine();
827  ImGui::Checkbox("With Ref Color", &ref_color);
828  if (ref_color)
829  {
830  ImGui::SameLine();
831  ImGui::ColorEdit4("##RefColor", &ref_color_v.x, ImGuiColorEditFlags_NoInputs | misc_flags);
832  }
833  }
834  ImGui::Combo("Inputs Mode", &inputs_mode, "All Inputs\0No Inputs\0RGB Input\0HSV Input\0HEX Input\0");
835  ImGui::Combo("Picker Mode", &picker_mode, "Auto/Current\0Hue bar + SV rect\0Hue wheel + SV triangle\0");
836  ImGui::SameLine(); ShowHelpMarker("User can right-click the picker to change mode.");
837  ImGuiColorEditFlags flags = misc_flags;
838  if (!alpha) flags |= ImGuiColorEditFlags_NoAlpha; // This is by default if you call ColorPicker3() instead of ColorPicker4()
839  if (alpha_bar) flags |= ImGuiColorEditFlags_AlphaBar;
840  if (!side_preview) flags |= ImGuiColorEditFlags_NoSidePreview;
841  if (picker_mode == 1) flags |= ImGuiColorEditFlags_PickerHueBar;
842  if (picker_mode == 2) flags |= ImGuiColorEditFlags_PickerHueWheel;
843  if (inputs_mode == 1) flags |= ImGuiColorEditFlags_NoInputs;
844  if (inputs_mode == 2) flags |= ImGuiColorEditFlags_RGB;
845  if (inputs_mode == 3) flags |= ImGuiColorEditFlags_HSV;
846  if (inputs_mode == 4) flags |= ImGuiColorEditFlags_HEX;
847  ImGui::ColorPicker4("MyColor##4", (float*)&color, flags, ref_color ? &ref_color_v.x : NULL);
848 
849  ImGui::Text("Programmatically set defaults/options:");
850  ImGui::SameLine(); ShowHelpMarker("SetColorEditOptions() is designed to allow you to set boot-time default.\nWe don't have Push/Pop functions because you can force options on a per-widget basis if needed, and the user can change non-forced ones with the options menu.\nWe don't have a getter to avoid encouraging you to persistently save values that aren't forward-compatible.");
851  if (ImGui::Button("Uint8 + HSV"))
853  ImGui::SameLine();
854  if (ImGui::Button("Float + HDR"))
856 
857  ImGui::TreePop();
858  }
859 
860  if (ImGui::TreeNode("Range Widgets"))
861  {
862  static float begin = 10, end = 90;
863  static int begin_i = 100, end_i = 1000;
864  ImGui::DragFloatRange2("range", &begin, &end, 0.25f, 0.0f, 100.0f, "Min: %.1f %%", "Max: %.1f %%");
865  ImGui::DragIntRange2("range int (no bounds)", &begin_i, &end_i, 5, 0, 0, "Min: %.0f units", "Max: %.0f units");
866  ImGui::TreePop();
867  }
868 
869  if (ImGui::TreeNode("Multi-component Widgets"))
870  {
871  static float vec4f[4] = { 0.10f, 0.20f, 0.30f, 0.44f };
872  static int vec4i[4] = { 1, 5, 100, 255 };
873 
874  ImGui::InputFloat2("input float2", vec4f);
875  ImGui::DragFloat2("drag float2", vec4f, 0.01f, 0.0f, 1.0f);
876  ImGui::SliderFloat2("slider float2", vec4f, 0.0f, 1.0f);
877  ImGui::DragInt2("drag int2", vec4i, 1, 0, 255);
878  ImGui::InputInt2("input int2", vec4i);
879  ImGui::SliderInt2("slider int2", vec4i, 0, 255);
880  ImGui::Spacing();
881 
882  ImGui::InputFloat3("input float3", vec4f);
883  ImGui::DragFloat3("drag float3", vec4f, 0.01f, 0.0f, 1.0f);
884  ImGui::SliderFloat3("slider float3", vec4f, 0.0f, 1.0f);
885  ImGui::DragInt3("drag int3", vec4i, 1, 0, 255);
886  ImGui::InputInt3("input int3", vec4i);
887  ImGui::SliderInt3("slider int3", vec4i, 0, 255);
888  ImGui::Spacing();
889 
890  ImGui::InputFloat4("input float4", vec4f);
891  ImGui::DragFloat4("drag float4", vec4f, 0.01f, 0.0f, 1.0f);
892  ImGui::SliderFloat4("slider float4", vec4f, 0.0f, 1.0f);
893  ImGui::InputInt4("input int4", vec4i);
894  ImGui::DragInt4("drag int4", vec4i, 1, 0, 255);
895  ImGui::SliderInt4("slider int4", vec4i, 0, 255);
896 
897  ImGui::TreePop();
898  }
899 
900  if (ImGui::TreeNode("Vertical Sliders"))
901  {
902  const float spacing = 4;
904 
905  static int int_value = 0;
906  ImGui::VSliderInt("##int", ImVec2(18,160), &int_value, 0, 5);
907  ImGui::SameLine();
908 
909  static float values[7] = { 0.0f, 0.60f, 0.35f, 0.9f, 0.70f, 0.20f, 0.0f };
910  ImGui::PushID("set1");
911  for (int i = 0; i < 7; i++)
912  {
913  if (i > 0) ImGui::SameLine();
914  ImGui::PushID(i);
919  ImGui::VSliderFloat("##v", ImVec2(18,160), &values[i], 0.0f, 1.0f, "");
921  ImGui::SetTooltip("%.3f", values[i]);
923  ImGui::PopID();
924  }
925  ImGui::PopID();
926 
927  ImGui::SameLine();
928  ImGui::PushID("set2");
929  static float values2[4] = { 0.20f, 0.80f, 0.40f, 0.25f };
930  const int rows = 3;
931  const ImVec2 small_slider_size(18, (160.0f-(rows-1)*spacing)/rows);
932  for (int nx = 0; nx < 4; nx++)
933  {
934  if (nx > 0) ImGui::SameLine();
936  for (int ny = 0; ny < rows; ny++)
937  {
938  ImGui::PushID(nx*rows+ny);
939  ImGui::VSliderFloat("##v", small_slider_size, &values2[nx], 0.0f, 1.0f, "");
941  ImGui::SetTooltip("%.3f", values2[nx]);
942  ImGui::PopID();
943  }
944  ImGui::EndGroup();
945  }
946  ImGui::PopID();
947 
948  ImGui::SameLine();
949  ImGui::PushID("set3");
950  for (int i = 0; i < 4; i++)
951  {
952  if (i > 0) ImGui::SameLine();
953  ImGui::PushID(i);
955  ImGui::VSliderFloat("##v", ImVec2(40,160), &values[i], 0.0f, 1.0f, "%.2f\nsec");
957  ImGui::PopID();
958  }
959  ImGui::PopID();
961  ImGui::TreePop();
962  }
963  }
964 
965  if (ImGui::CollapsingHeader("Layout"))
966  {
967  if (ImGui::TreeNode("Child regions"))
968  {
969  ImGui::Text("Without border");
970  static int line = 50;
971  bool goto_line = ImGui::Button("Goto");
972  ImGui::SameLine();
974  goto_line |= ImGui::InputInt("##Line", &line, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue);
977  for (int i = 0; i < 100; i++)
978  {
979  ImGui::Text("%04d: scrollable region", i);
980  if (goto_line && line == i)
982  }
983  if (goto_line && line >= 100)
985  ImGui::EndChild();
986 
987  ImGui::SameLine();
988 
990  ImGui::BeginChild("Sub2", ImVec2(0,300), true);
991  ImGui::Text("With border");
992  ImGui::Columns(2);
993  for (int i = 0; i < 100; i++)
994  {
995  if (i == 50)
997  char buf[32];
998  sprintf(buf, "%08x", i*5731);
999  ImGui::Button(buf, ImVec2(-1.0f, 0.0f));
1000  }
1001  ImGui::EndChild();
1003 
1004  ImGui::TreePop();
1005  }
1006 
1007  if (ImGui::TreeNode("Widgets Width"))
1008  {
1009  static float f = 0.0f;
1010  ImGui::Text("PushItemWidth(100)");
1011  ImGui::SameLine(); ShowHelpMarker("Fixed width.");
1012  ImGui::PushItemWidth(100);
1013  ImGui::DragFloat("float##1", &f);
1015 
1016  ImGui::Text("PushItemWidth(GetWindowWidth() * 0.5f)");
1017  ImGui::SameLine(); ShowHelpMarker("Half of window width.");
1019  ImGui::DragFloat("float##2", &f);
1021 
1022  ImGui::Text("PushItemWidth(GetContentRegionAvailWidth() * 0.5f)");
1023  ImGui::SameLine(); ShowHelpMarker("Half of available width.\n(~ right-cursor_pos)\n(works within a column set)");
1025  ImGui::DragFloat("float##3", &f);
1027 
1028  ImGui::Text("PushItemWidth(-100)");
1029  ImGui::SameLine(); ShowHelpMarker("Align to right edge minus 100");
1030  ImGui::PushItemWidth(-100);
1031  ImGui::DragFloat("float##4", &f);
1033 
1034  ImGui::Text("PushItemWidth(-1)");
1035  ImGui::SameLine(); ShowHelpMarker("Align to right edge");
1037  ImGui::DragFloat("float##5", &f);
1039 
1040  ImGui::TreePop();
1041  }
1042 
1043  if (ImGui::TreeNode("Basic Horizontal Layout"))
1044  {
1045  ImGui::TextWrapped("(Use ImGui::SameLine() to keep adding items to the right of the preceding item)");
1046 
1047  // Text
1048  ImGui::Text("Two items: Hello"); ImGui::SameLine();
1049  ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
1050 
1051  // Adjust spacing
1052  ImGui::Text("More spacing: Hello"); ImGui::SameLine(0, 20);
1053  ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
1054 
1055  // Button
1057  ImGui::Text("Normal buttons"); ImGui::SameLine();
1058  ImGui::Button("Banana"); ImGui::SameLine();
1059  ImGui::Button("Apple"); ImGui::SameLine();
1060  ImGui::Button("Corniflower");
1061 
1062  // Button
1063  ImGui::Text("Small buttons"); ImGui::SameLine();
1064  ImGui::SmallButton("Like this one"); ImGui::SameLine();
1065  ImGui::Text("can fit within a text block.");
1066 
1067  // Aligned to arbitrary position. Easy/cheap column.
1068  ImGui::Text("Aligned");
1069  ImGui::SameLine(150); ImGui::Text("x=150");
1070  ImGui::SameLine(300); ImGui::Text("x=300");
1071  ImGui::Text("Aligned");
1072  ImGui::SameLine(150); ImGui::SmallButton("x=150");
1073  ImGui::SameLine(300); ImGui::SmallButton("x=300");
1074 
1075  // Checkbox
1076  static bool c1=false,c2=false,c3=false,c4=false;
1077  ImGui::Checkbox("My", &c1); ImGui::SameLine();
1078  ImGui::Checkbox("Tailor", &c2); ImGui::SameLine();
1079  ImGui::Checkbox("Is", &c3); ImGui::SameLine();
1080  ImGui::Checkbox("Rich", &c4);
1081 
1082  // Various
1083  static float f0=1.0f, f1=2.0f, f2=3.0f;
1085  const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD" };
1086  static int item = -1;
1087  ImGui::Combo("Combo", &item, items, IM_ARRAYSIZE(items)); ImGui::SameLine();
1088  ImGui::SliderFloat("X", &f0, 0.0f,5.0f); ImGui::SameLine();
1089  ImGui::SliderFloat("Y", &f1, 0.0f,5.0f); ImGui::SameLine();
1090  ImGui::SliderFloat("Z", &f2, 0.0f,5.0f);
1092 
1094  ImGui::Text("Lists:");
1095  static int selection[4] = { 0, 1, 2, 3 };
1096  for (int i = 0; i < 4; i++)
1097  {
1098  if (i > 0) ImGui::SameLine();
1099  ImGui::PushID(i);
1100  ImGui::ListBox("", &selection[i], items, IM_ARRAYSIZE(items));
1101  ImGui::PopID();
1102  //if (ImGui::IsItemHovered()) ImGui::SetTooltip("ListBox %d hovered", i);
1103  }
1105 
1106  // Dummy
1107  ImVec2 sz(30,30);
1108  ImGui::Button("A", sz); ImGui::SameLine();
1110  ImGui::Button("B", sz);
1111 
1112  ImGui::TreePop();
1113  }
1114 
1115  if (ImGui::TreeNode("Groups"))
1116  {
1117  ImGui::TextWrapped("(Using ImGui::BeginGroup()/EndGroup() to layout items. BeginGroup() basically locks the horizontal position. EndGroup() bundles the whole group so that you can use functions such as IsItemHovered() on it.)");
1119  {
1121  ImGui::Button("AAA");
1122  ImGui::SameLine();
1123  ImGui::Button("BBB");
1124  ImGui::SameLine();
1126  ImGui::Button("CCC");
1127  ImGui::Button("DDD");
1128  ImGui::EndGroup();
1129  ImGui::SameLine();
1130  ImGui::Button("EEE");
1131  ImGui::EndGroup();
1132  if (ImGui::IsItemHovered())
1133  ImGui::SetTooltip("First group hovered");
1134  }
1135  // Capture the group size and create widgets using the same size
1136  ImVec2 size = ImGui::GetItemRectSize();
1137  const float values[5] = { 0.5f, 0.20f, 0.80f, 0.60f, 0.25f };
1138  ImGui::PlotHistogram("##values", values, IM_ARRAYSIZE(values), 0, NULL, 0.0f, 1.0f, size);
1139 
1140  ImGui::Button("ACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x)*0.5f,size.y));
1141  ImGui::SameLine();
1142  ImGui::Button("REACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x)*0.5f,size.y));
1143  ImGui::EndGroup();
1144  ImGui::SameLine();
1145 
1146  ImGui::Button("LEVERAGE\nBUZZWORD", size);
1147  ImGui::SameLine();
1148 
1149  ImGui::ListBoxHeader("List", size);
1150  ImGui::Selectable("Selected", true);
1151  ImGui::Selectable("Not Selected", false);
1153 
1154  ImGui::TreePop();
1155  }
1156 
1157  if (ImGui::TreeNode("Text Baseline Alignment"))
1158  {
1159  ImGui::TextWrapped("(This is testing the vertical alignment that occurs on text to keep it at the same baseline as widgets. Lines only composed of text or \"small\" widgets fit in less vertical spaces than lines with normal widgets)");
1160 
1161  ImGui::Text("One\nTwo\nThree"); ImGui::SameLine();
1162  ImGui::Text("Hello\nWorld"); ImGui::SameLine();
1163  ImGui::Text("Banana");
1164 
1165  ImGui::Text("Banana"); ImGui::SameLine();
1166  ImGui::Text("Hello\nWorld"); ImGui::SameLine();
1167  ImGui::Text("One\nTwo\nThree");
1168 
1169  ImGui::Button("HOP##1"); ImGui::SameLine();
1170  ImGui::Text("Banana"); ImGui::SameLine();
1171  ImGui::Text("Hello\nWorld"); ImGui::SameLine();
1172  ImGui::Text("Banana");
1173 
1174  ImGui::Button("HOP##2"); ImGui::SameLine();
1175  ImGui::Text("Hello\nWorld"); ImGui::SameLine();
1176  ImGui::Text("Banana");
1177 
1178  ImGui::Button("TEST##1"); ImGui::SameLine();
1179  ImGui::Text("TEST"); ImGui::SameLine();
1180  ImGui::SmallButton("TEST##2");
1181 
1182  ImGui::AlignFirstTextHeightToWidgets(); // If your line starts with text, call this to align it to upcoming widgets.
1183  ImGui::Text("Text aligned to Widget"); ImGui::SameLine();
1184  ImGui::Button("Widget##1"); ImGui::SameLine();
1185  ImGui::Text("Widget"); ImGui::SameLine();
1186  ImGui::SmallButton("Widget##2"); ImGui::SameLine();
1187  ImGui::Button("Widget##3");
1188 
1189  // Tree
1190  const float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
1191  ImGui::Button("Button##1");
1192  ImGui::SameLine(0.0f, spacing);
1193  if (ImGui::TreeNode("Node##1")) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
1194 
1195  ImGui::AlignFirstTextHeightToWidgets(); // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. Otherwise you can use SmallButton (smaller fit).
1196  bool node_open = ImGui::TreeNode("Node##2"); // Engine mistake to avoid: if we want to SameLine after TreeNode we need to do it before we add child content.
1197  ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##2");
1198  if (node_open) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
1199 
1200  // Bullet
1201  ImGui::Button("Button##3");
1202  ImGui::SameLine(0.0f, spacing);
1203  ImGui::BulletText("Bullet text");
1204 
1206  ImGui::BulletText("Node");
1207  ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##4");
1208 
1209  ImGui::TreePop();
1210  }
1211 
1212  if (ImGui::TreeNode("Scrolling"))
1213  {
1214  ImGui::TextWrapped("(Use SetScrollHere() or SetScrollFromPosY() to scroll to a given position.)");
1215  static bool track = true;
1216  static int track_line = 50, scroll_to_px = 200;
1217  ImGui::Checkbox("Track", &track);
1218  ImGui::PushItemWidth(100);
1219  ImGui::SameLine(130); track |= ImGui::DragInt("##line", &track_line, 0.25f, 0, 99, "Line = %.0f");
1220  bool scroll_to = ImGui::Button("Scroll To Pos");
1221  ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "Y = %.0f px");
1223  if (scroll_to) track = false;
1224 
1225  for (int i = 0; i < 5; i++)
1226  {
1227  if (i > 0) ImGui::SameLine();
1229  ImGui::Text("%s", i == 0 ? "Top" : i == 1 ? "25%" : i == 2 ? "Center" : i == 3 ? "75%" : "Bottom");
1230  ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(ImGui::GetWindowWidth() * 0.17f, 200.0f), true);
1231  if (scroll_to)
1232  ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_px, i * 0.25f);
1233  for (int line = 0; line < 100; line++)
1234  {
1235  if (track && line == track_line)
1236  {
1237  ImGui::TextColored(ImColor(255,255,0), "Line %d", line);
1238  ImGui::SetScrollHere(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
1239  }
1240  else
1241  {
1242  ImGui::Text("Line %d", line);
1243  }
1244  }
1245  float scroll_y = ImGui::GetScrollY(), scroll_max_y = ImGui::GetScrollMaxY();
1246  ImGui::EndChild();
1247  ImGui::Text("%.0f/%0.f", scroll_y, scroll_max_y);
1248  ImGui::EndGroup();
1249  }
1250  ImGui::TreePop();
1251  }
1252 
1253  if (ImGui::TreeNode("Horizontal Scrolling"))
1254  {
1255  ImGui::Bullet(); ImGui::TextWrapped("Horizontal scrolling for a window has to be enabled explicitly via the ImGuiWindowFlags_HorizontalScrollbar flag.");
1256  ImGui::Bullet(); ImGui::TextWrapped("You may want to explicitly specify content width by calling SetNextWindowContentWidth() before Begin().");
1257  static int lines = 7;
1258  ImGui::SliderInt("Lines", &lines, 1, 15);
1262  for (int line = 0; line < lines; line++)
1263  {
1264  // Display random stuff (for the sake of this trivial demo we are using basic Button+SameLine. If you want to create your own time line for a real application you may be better off
1265  // manipulating the cursor position yourself, aka using SetCursorPos/SetCursorScreenPos to position the widgets yourself. You may also want to use the lower-level ImDrawList API)
1266  int num_buttons = 10 + ((line & 1) ? line * 9 : line * 3);
1267  for (int n = 0; n < num_buttons; n++)
1268  {
1269  if (n > 0) ImGui::SameLine();
1270  ImGui::PushID(n + line * 1000);
1271  char num_buf[16];
1272  const char* label = (!(n%15)) ? "FizzBuzz" : (!(n%3)) ? "Fizz" : (!(n%5)) ? "Buzz" : (sprintf(num_buf, "%d", n), num_buf);
1273  float hue = n*0.05f;
1277  ImGui::Button(label, ImVec2(40.0f + sinf((float)(line + n)) * 20.0f, 0.0f));
1279  ImGui::PopID();
1280  }
1281  }
1282  float scroll_x = ImGui::GetScrollX(), scroll_max_x = ImGui::GetScrollMaxX();
1283  ImGui::EndChild();
1284  ImGui::PopStyleVar(2);
1285  float scroll_x_delta = 0.0f;
1286  ImGui::SmallButton("<<"); if (ImGui::IsItemActive()) scroll_x_delta = -ImGui::GetIO().DeltaTime * 1000.0f; ImGui::SameLine();
1287  ImGui::Text("Scroll from code"); ImGui::SameLine();
1288  ImGui::SmallButton(">>"); if (ImGui::IsItemActive()) scroll_x_delta = +ImGui::GetIO().DeltaTime * 1000.0f; ImGui::SameLine();
1289  ImGui::Text("%.0f/%.0f", scroll_x, scroll_max_x);
1290  if (scroll_x_delta != 0.0f)
1291  {
1292  ImGui::BeginChild("scrolling"); // Demonstrate a trick: you can use Begin to set yourself in the context of another window (here we are already out of your child window)
1293  ImGui::SetScrollX(ImGui::GetScrollX() + scroll_x_delta);
1294  ImGui::End();
1295  }
1296  ImGui::TreePop();
1297  }
1298 
1299  if (ImGui::TreeNode("Clipping"))
1300  {
1301  static ImVec2 size(100, 100), offset(50, 20);
1302  ImGui::TextWrapped("On a per-widget basis we are occasionally clipping text CPU-side if it won't fit in its frame. Otherwise we are doing coarser clipping + passing a scissor rectangle to the renderer. The system is designed to try minimizing both execution and CPU/GPU rendering cost.");
1303  ImGui::DragFloat2("size", (float*)&size, 0.5f, 0.0f, 200.0f, "%.0f");
1304  ImGui::TextWrapped("(Click and drag)");
1306  ImVec4 clip_rect(pos.x, pos.y, pos.x+size.x, pos.y+size.y);
1307  ImGui::InvisibleButton("##dummy", size);
1309  ImGui::GetWindowDrawList()->AddRectFilled(pos, ImVec2(pos.x+size.x,pos.y+size.y), ImColor(90,90,120,255));
1310  ImGui::GetWindowDrawList()->AddText(ImGui::GetFont(), ImGui::GetFontSize()*2.0f, ImVec2(pos.x+offset.x,pos.y+offset.y), ImColor(255,255,255,255), "Line 1 hello\nLine 2 clip me!", NULL, 0.0f, &clip_rect);
1311  ImGui::TreePop();
1312  }
1313  }
1314 
1315  if (ImGui::CollapsingHeader("Popups & Modal windows"))
1316  {
1317  if (ImGui::TreeNode("Popups"))
1318  {
1319  ImGui::TextWrapped("When a popup is active, it inhibits interacting with windows that are behind the popup. Clicking outside the popup closes it.");
1320 
1321  static int selected_fish = -1;
1322  const char* names[] = { "Bream", "Haddock", "Mackerel", "Pollock", "Tilefish" };
1323  static bool toggles[] = { true, false, false, false, false };
1324 
1325  // Simple selection popup
1326  // (If you want to show the current selection inside the Button itself, you may want to build a string using the "###" operator to preserve a constant ID with a variable label)
1327  if (ImGui::Button("Select.."))
1328  ImGui::OpenPopup("select");
1329  ImGui::SameLine();
1330  ImGui::Text(selected_fish == -1 ? "<None>" : names[selected_fish]);
1331  if (ImGui::BeginPopup("select"))
1332  {
1333  ImGui::Text("Aquarium");
1334  ImGui::Separator();
1335  for (int i = 0; i < IM_ARRAYSIZE(names); i++)
1336  if (ImGui::Selectable(names[i]))
1337  selected_fish = i;
1338  ImGui::EndPopup();
1339  }
1340 
1341  // Showing a menu with toggles
1342  if (ImGui::Button("Toggle.."))
1343  ImGui::OpenPopup("toggle");
1344  if (ImGui::BeginPopup("toggle"))
1345  {
1346  for (int i = 0; i < IM_ARRAYSIZE(names); i++)
1347  ImGui::MenuItem(names[i], "", &toggles[i]);
1348  if (ImGui::BeginMenu("Sub-menu"))
1349  {
1350  ImGui::MenuItem("Click me");
1351  ImGui::EndMenu();
1352  }
1353 
1354  ImGui::Separator();
1355  ImGui::Text("Tooltip here");
1356  if (ImGui::IsItemHovered())
1357  ImGui::SetTooltip("I am a tooltip over a popup");
1358 
1359  if (ImGui::Button("Stacked Popup"))
1360  ImGui::OpenPopup("another popup");
1361  if (ImGui::BeginPopup("another popup"))
1362  {
1363  for (int i = 0; i < IM_ARRAYSIZE(names); i++)
1364  ImGui::MenuItem(names[i], "", &toggles[i]);
1365  if (ImGui::BeginMenu("Sub-menu"))
1366  {
1367  ImGui::MenuItem("Click me");
1368  ImGui::EndMenu();
1369  }
1370  ImGui::EndPopup();
1371  }
1372  ImGui::EndPopup();
1373  }
1374 
1375  if (ImGui::Button("Popup Menu.."))
1376  ImGui::OpenPopup("FilePopup");
1377  if (ImGui::BeginPopup("FilePopup"))
1378  {
1379  ShowExampleMenuFile();
1380  ImGui::EndPopup();
1381  }
1382 
1383  ImGui::Spacing();
1384  ImGui::TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!");
1385  ImGui::Separator();
1386  // NB: As a quirk in this very specific example, we want to differentiate the parent of this menu from the parent of the various popup menus above.
1387  // To do so we are encloding the items in a PushID()/PopID() block to make them two different menusets. If we don't, opening any popup above and hovering our menu here
1388  // would open it. This is because once a menu is active, we allow to switch to a sibling menu by just hovering on it, which is the desired behavior for regular menus.
1389  ImGui::PushID("foo");
1390  ImGui::MenuItem("Menu item", "CTRL+M");
1391  if (ImGui::BeginMenu("Menu inside a regular window"))
1392  {
1393  ShowExampleMenuFile();
1394  ImGui::EndMenu();
1395  }
1396  ImGui::PopID();
1397  ImGui::Separator();
1398 
1399  ImGui::TreePop();
1400  }
1401 
1402  if (ImGui::TreeNode("Context menus"))
1403  {
1404  static float value = 0.5f;
1405  ImGui::Text("Value = %.3f (<-- right-click here)", value);
1406  if (ImGui::BeginPopupContextItem("item context menu"))
1407  {
1408  if (ImGui::Selectable("Set to zero")) value = 0.0f;
1409  if (ImGui::Selectable("Set to PI")) value = 3.1415f;
1410  ImGui::DragFloat("Value", &value, 0.1f, 0.0f, 0.0f);
1411  ImGui::EndPopup();
1412  }
1413 
1414  static char name[32] = "Label1";
1415  char buf[64]; sprintf(buf, "Button: %s###Button", name); // ### operator override ID ignoring the preceeding label
1416  ImGui::Button(buf);
1417  if (ImGui::BeginPopupContextItem("rename context menu"))
1418  {
1419  ImGui::Text("Edit name:");
1420  ImGui::InputText("##edit", name, IM_ARRAYSIZE(name));
1421  if (ImGui::Button("Close"))
1423  ImGui::EndPopup();
1424  }
1425  ImGui::SameLine(); ImGui::Text("(<-- right-click here)");
1426 
1427  ImGui::TreePop();
1428  }
1429 
1430  if (ImGui::TreeNode("Modals"))
1431  {
1432  ImGui::TextWrapped("Modal windows are like popups but the user cannot close them by clicking outside the window.");
1433 
1434  if (ImGui::Button("Delete.."))
1435  ImGui::OpenPopup("Delete?");
1437  {
1438  ImGui::Text("All those beautiful files will be deleted.\nThis operation cannot be undone!\n\n");
1439  ImGui::Separator();
1440 
1441  //static int dummy_i = 0;
1442  //ImGui::Combo("Combo", &dummy_i, "Delete\0Delete harder\0");
1443 
1444  static bool dont_ask_me_next_time = false;
1446  ImGui::Checkbox("Don't ask me next time", &dont_ask_me_next_time);
1448 
1449  if (ImGui::Button("OK", ImVec2(120,0))) { ImGui::CloseCurrentPopup(); }
1450  ImGui::SameLine();
1451  if (ImGui::Button("Cancel", ImVec2(120,0))) { ImGui::CloseCurrentPopup(); }
1452  ImGui::EndPopup();
1453  }
1454 
1455  if (ImGui::Button("Stacked modals.."))
1456  ImGui::OpenPopup("Stacked 1");
1457  if (ImGui::BeginPopupModal("Stacked 1"))
1458  {
1459  ImGui::Text("Hello from Stacked The First\nUsing style.Colors[ImGuiCol_ModalWindowDarkening] for darkening.");
1460  static int item = 1;
1461  ImGui::Combo("Combo", &item, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
1462 
1463  if (ImGui::Button("Add another modal.."))
1464  ImGui::OpenPopup("Stacked 2");
1465  if (ImGui::BeginPopupModal("Stacked 2"))
1466  {
1467  ImGui::Text("Hello from Stacked The Second");
1468  if (ImGui::Button("Close"))
1470  ImGui::EndPopup();
1471  }
1472 
1473  if (ImGui::Button("Close"))
1475  ImGui::EndPopup();
1476  }
1477 
1478  ImGui::TreePop();
1479  }
1480  }
1481 
1482  if (ImGui::CollapsingHeader("Columns"))
1483  {
1484  ImGui::PushID("Columns");
1485 
1486  // Basic columns
1487  if (ImGui::TreeNode("Basic"))
1488  {
1489  ImGui::Text("Without border:");
1490  ImGui::Columns(3, "mycolumns3", false); // 3-ways, no border
1491  ImGui::Separator();
1492  for (int n = 0; n < 14; n++)
1493  {
1494  char label[32];
1495  sprintf(label, "Item %d", n);
1496  if (ImGui::Selectable(label)) {}
1497  //if (ImGui::Button(label, ImVec2(-1,0))) {}
1499  }
1500  ImGui::Columns(1);
1501  ImGui::Separator();
1502 
1503  ImGui::Text("With border:");
1504  ImGui::Columns(4, "mycolumns"); // 4-ways, with border
1505  ImGui::Separator();
1506  ImGui::Text("ID"); ImGui::NextColumn();
1507  ImGui::Text("Name"); ImGui::NextColumn();
1508  ImGui::Text("Path"); ImGui::NextColumn();
1509  ImGui::Text("Hovered"); ImGui::NextColumn();
1510  ImGui::Separator();
1511  const char* names[3] = { "One", "Two", "Three" };
1512  const char* paths[3] = { "/path/one", "/path/two", "/path/three" };
1513  static int selected = -1;
1514  for (int i = 0; i < 3; i++)
1515  {
1516  char label[32];
1517  sprintf(label, "%04d", i);
1518  if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
1519  selected = i;
1520  bool hovered = ImGui::IsItemHovered();
1522  ImGui::Text(names[i]); ImGui::NextColumn();
1523  ImGui::Text(paths[i]); ImGui::NextColumn();
1524  ImGui::Text("%d", hovered); ImGui::NextColumn();
1525  }
1526  ImGui::Columns(1);
1527  ImGui::Separator();
1528  ImGui::TreePop();
1529  }
1530 
1531  // Create multiple items in a same cell before switching to next column
1532  if (ImGui::TreeNode("Mixed items"))
1533  {
1534  ImGui::Columns(3, "mixed");
1535  ImGui::Separator();
1536 
1537  ImGui::Text("Hello");
1538  ImGui::Button("Banana");
1540 
1541  ImGui::Text("ImGui");
1542  ImGui::Button("Apple");
1543  static float foo = 1.0f;
1544  ImGui::InputFloat("red", &foo, 0.05f, 0, 3);
1545  ImGui::Text("An extra line here.");
1547 
1548  ImGui::Text("Sailor");
1549  ImGui::Button("Corniflower");
1550  static float bar = 1.0f;
1551  ImGui::InputFloat("blue", &bar, 0.05f, 0, 3);
1553 
1554  if (ImGui::CollapsingHeader("Category A")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
1555  if (ImGui::CollapsingHeader("Category B")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
1556  if (ImGui::CollapsingHeader("Category C")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
1557  ImGui::Columns(1);
1558  ImGui::Separator();
1559  ImGui::TreePop();
1560  }
1561 
1562  // Word wrapping
1563  if (ImGui::TreeNode("Word-wrapping"))
1564  {
1565  ImGui::Columns(2, "word-wrapping");
1566  ImGui::Separator();
1567  ImGui::TextWrapped("The quick brown fox jumps over the lazy dog.");
1568  ImGui::TextWrapped("Hello Left");
1570  ImGui::TextWrapped("The quick brown fox jumps over the lazy dog.");
1571  ImGui::TextWrapped("Hello Right");
1572  ImGui::Columns(1);
1573  ImGui::Separator();
1574  ImGui::TreePop();
1575  }
1576 
1577  if (ImGui::TreeNode("Borders"))
1578  {
1579  // NB: Future columns API should allow automatic horizontal borders.
1580  static bool h_borders = true;
1581  static bool v_borders = true;
1582  ImGui::Checkbox("horizontal", &h_borders);
1583  ImGui::SameLine();
1584  ImGui::Checkbox("vertical", &v_borders);
1585  ImGui::Columns(4, NULL, v_borders);
1586  for (int i = 0; i < 4*3; i++)
1587  {
1588  if (h_borders && ImGui::GetColumnIndex() == 0)
1589  ImGui::Separator();
1590  ImGui::Text("%c%c%c", 'a'+i, 'a'+i, 'a'+i);
1591  ImGui::Text("Width %.2f\nOffset %.2f", ImGui::GetColumnWidth(), ImGui::GetColumnOffset());
1593  }
1594  ImGui::Columns(1);
1595  if (h_borders)
1596  ImGui::Separator();
1597  ImGui::TreePop();
1598  }
1599 
1600  // Scrolling columns
1601  /*
1602  if (ImGui::TreeNode("Vertical Scrolling"))
1603  {
1604  ImGui::BeginChild("##header", ImVec2(0, ImGui::GetTextLineHeightWithSpacing()+ImGui::GetStyle().ItemSpacing.y));
1605  ImGui::Columns(3);
1606  ImGui::Text("ID"); ImGui::NextColumn();
1607  ImGui::Text("Name"); ImGui::NextColumn();
1608  ImGui::Text("Path"); ImGui::NextColumn();
1609  ImGui::Columns(1);
1610  ImGui::Separator();
1611  ImGui::EndChild();
1612  ImGui::BeginChild("##scrollingregion", ImVec2(0, 60));
1613  ImGui::Columns(3);
1614  for (int i = 0; i < 10; i++)
1615  {
1616  ImGui::Text("%04d", i); ImGui::NextColumn();
1617  ImGui::Text("Foobar"); ImGui::NextColumn();
1618  ImGui::Text("/path/foobar/%04d/", i); ImGui::NextColumn();
1619  }
1620  ImGui::Columns(1);
1621  ImGui::EndChild();
1622  ImGui::TreePop();
1623  }
1624  */
1625 
1626  if (ImGui::TreeNode("Horizontal Scrolling"))
1627  {
1629  ImGui::BeginChild("##scrollingregion", ImVec2(0, 120), false, ImGuiWindowFlags_HorizontalScrollbar);
1630  ImGui::Columns(10);
1631  for (int i = 0; i < 20; i++)
1632  for (int j = 0; j < 10; j++)
1633  {
1634  ImGui::Text("Line %d Column %d...", i, j);
1636  }
1637  ImGui::Columns(1);
1638  ImGui::EndChild();
1639  ImGui::TreePop();
1640  }
1641 
1642  bool node_open = ImGui::TreeNode("Tree within single cell");
1643  ImGui::SameLine(); ShowHelpMarker("NB: Tree node must be poped before ending the cell. There's no storage of state per-cell.");
1644  if (node_open)
1645  {
1646  ImGui::Columns(2, "tree items");
1647  ImGui::Separator();
1648  if (ImGui::TreeNode("Hello")) { ImGui::BulletText("Sailor"); ImGui::TreePop(); } ImGui::NextColumn();
1649  if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Marin"); ImGui::TreePop(); } ImGui::NextColumn();
1650  ImGui::Columns(1);
1651  ImGui::Separator();
1652  ImGui::TreePop();
1653  }
1654  ImGui::PopID();
1655  }
1656 
1657  if (ImGui::CollapsingHeader("Filtering"))
1658  {
1659  static ImGuiTextFilter filter;
1660  ImGui::Text("Filter usage:\n"
1661  " \"\" display all lines\n"
1662  " \"xxx\" display lines containing \"xxx\"\n"
1663  " \"xxx,yyy\" display lines containing \"xxx\" or \"yyy\"\n"
1664  " \"-xxx\" hide lines containing \"xxx\"");
1665  filter.Draw();
1666  const char* lines[] = { "aaa1.c", "bbb1.c", "ccc1.c", "aaa2.cpp", "bbb2.cpp", "ccc2.cpp", "abc.h", "hello, world" };
1667  for (int i = 0; i < IM_ARRAYSIZE(lines); i++)
1668  if (filter.PassFilter(lines[i]))
1669  ImGui::BulletText("%s", lines[i]);
1670  }
1671 
1672  if (ImGui::CollapsingHeader("Inputs & Focus"))
1673  {
1674  ImGuiIO& io = ImGui::GetIO();
1675  ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor);
1676  ImGui::SameLine(); ShowHelpMarker("Request ImGui to render a mouse cursor for you in software. Note that a mouse cursor rendered via regular GPU rendering will feel more laggy than hardware cursor, but will be more in sync with your other visuals.");
1677 
1678  ImGui::Text("WantCaptureMouse: %d", io.WantCaptureMouse);
1679  ImGui::Text("WantCaptureKeyboard: %d", io.WantCaptureKeyboard);
1680  ImGui::Text("WantTextInput: %d", io.WantTextInput);
1681  ImGui::Text("WantMoveMouse: %d", io.WantMoveMouse);
1682 
1683  if (ImGui::TreeNode("Keyboard & Mouse State"))
1684  {
1685  ImGui::Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y);
1686  ImGui::Text("Mouse down:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (io.MouseDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]); }
1687  ImGui::Text("Mouse clicked:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); }
1688  ImGui::Text("Mouse dbl-clicked:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseDoubleClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); }
1689  ImGui::Text("Mouse released:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseReleased(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); }
1690  ImGui::Text("Mouse wheel: %.1f", io.MouseWheel);
1691 
1692  ImGui::Text("Keys down:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (io.KeysDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("%d (%.02f secs)", i, io.KeysDownDuration[i]); }
1693  ImGui::Text("Keys pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyPressed(i)) { ImGui::SameLine(); ImGui::Text("%d", i); }
1694  ImGui::Text("Keys release:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyReleased(i)) { ImGui::SameLine(); ImGui::Text("%d", i); }
1695  ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
1696 
1697 
1698  ImGui::Button("Hovering me sets the\nkeyboard capture flag");
1699  if (ImGui::IsItemHovered())
1701  ImGui::SameLine();
1702  ImGui::Button("Holding me clears the\nthe keyboard capture flag");
1703  if (ImGui::IsItemActive())
1705 
1706  ImGui::TreePop();
1707  }
1708 
1709  if (ImGui::TreeNode("Tabbing"))
1710  {
1711  ImGui::Text("Use TAB/SHIFT+TAB to cycle through keyboard editable fields.");
1712  static char buf[32] = "dummy";
1713  ImGui::InputText("1", buf, IM_ARRAYSIZE(buf));
1714  ImGui::InputText("2", buf, IM_ARRAYSIZE(buf));
1715  ImGui::InputText("3", buf, IM_ARRAYSIZE(buf));
1717  ImGui::InputText("4 (tab skip)", buf, IM_ARRAYSIZE(buf));
1718  //ImGui::SameLine(); ShowHelperMarker("Use ImGui::PushAllowKeyboardFocus(bool)\nto disable tabbing through certain widgets.");
1720  ImGui::InputText("5", buf, IM_ARRAYSIZE(buf));
1721  ImGui::TreePop();
1722  }
1723 
1724  if (ImGui::TreeNode("Focus from code"))
1725  {
1726  bool focus_1 = ImGui::Button("Focus on 1"); ImGui::SameLine();
1727  bool focus_2 = ImGui::Button("Focus on 2"); ImGui::SameLine();
1728  bool focus_3 = ImGui::Button("Focus on 3");
1729  int has_focus = 0;
1730  static char buf[128] = "click on a button to set focus";
1731 
1732  if (focus_1) ImGui::SetKeyboardFocusHere();
1733  ImGui::InputText("1", buf, IM_ARRAYSIZE(buf));
1734  if (ImGui::IsItemActive()) has_focus = 1;
1735 
1736  if (focus_2) ImGui::SetKeyboardFocusHere();
1737  ImGui::InputText("2", buf, IM_ARRAYSIZE(buf));
1738  if (ImGui::IsItemActive()) has_focus = 2;
1739 
1741  if (focus_3) ImGui::SetKeyboardFocusHere();
1742  ImGui::InputText("3 (tab skip)", buf, IM_ARRAYSIZE(buf));
1743  if (ImGui::IsItemActive()) has_focus = 3;
1745  if (has_focus)
1746  ImGui::Text("Item with focus: %d", has_focus);
1747  else
1748  ImGui::Text("Item with focus: <none>");
1749  ImGui::TextWrapped("Cursor & selection are preserved when refocusing last used item in code.");
1750  ImGui::TreePop();
1751  }
1752 
1753  if (ImGui::TreeNode("Dragging"))
1754  {
1755  ImGui::TextWrapped("You can use ImGui::GetMouseDragDelta(0) to query for the dragged amount on any widget.");
1756  ImGui::Button("Drag Me");
1757  if (ImGui::IsItemActive())
1758  {
1759  // Draw a line between the button and the mouse cursor
1760  ImDrawList* draw_list = ImGui::GetWindowDrawList();
1761  draw_list->PushClipRectFullScreen();
1762  draw_list->AddLine(ImGui::CalcItemRectClosestPoint(io.MousePos, true, -2.0f), io.MousePos, ImColor(ImGui::GetStyle().Colors[ImGuiCol_Button]), 4.0f);
1763  draw_list->PopClipRect();
1764  ImVec2 value_raw = ImGui::GetMouseDragDelta(0, 0.0f);
1765  ImVec2 value_with_lock_threshold = ImGui::GetMouseDragDelta(0);
1766  ImVec2 mouse_delta = io.MouseDelta;
1767  ImGui::SameLine(); ImGui::Text("Raw (%.1f, %.1f), WithLockThresold (%.1f, %.1f), MouseDelta (%.1f, %.1f)", value_raw.x, value_raw.y, value_with_lock_threshold.x, value_with_lock_threshold.y, mouse_delta.x, mouse_delta.y);
1768  }
1769  ImGui::TreePop();
1770  }
1771 
1772  if (ImGui::TreeNode("Mouse cursors"))
1773  {
1774  ImGui::Text("Hover to see mouse cursors:");
1775  ImGui::SameLine(); ShowHelpMarker("Your application can render a different mouse cursor based on what ImGui::GetMouseCursor() returns. If software cursor rendering (io.MouseDrawCursor) is set ImGui will draw the right cursor for you, otherwise your backend needs to handle it.");
1776  for (int i = 0; i < ImGuiMouseCursor_Count_; i++)
1777  {
1778  char label[32];
1779  sprintf(label, "Mouse cursor %d", i);
1780  ImGui::Bullet(); ImGui::Selectable(label, false);
1781  if (ImGui::IsItemHovered())
1783  }
1784  ImGui::TreePop();
1785  }
1786  }
1787 
1788  ImGui::End();
1789 }
1790 
1792 {
1793  ImGuiStyle& style = ImGui::GetStyle();
1794 
1795  // You can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it compares to the default style)
1796  const ImGuiStyle default_style; // Default style
1797  if (ImGui::Button("Revert Style"))
1798  style = ref ? *ref : default_style;
1799 
1800  if (ref)
1801  {
1802  ImGui::SameLine();
1803  if (ImGui::Button("Save Style"))
1804  *ref = style;
1805  }
1806 
1808 
1809  if (ImGui::TreeNode("Rendering"))
1810  {
1811  ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines); ImGui::SameLine(); ShowHelpMarker("When disabling anti-aliasing lines, you'll probably want to disable borders in your style as well.");
1812  ImGui::Checkbox("Anti-aliased shapes", &style.AntiAliasedShapes);
1813  ImGui::PushItemWidth(100);
1814  ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, NULL, 2.0f);
1815  if (style.CurveTessellationTol < 0.0f) style.CurveTessellationTol = 0.10f;
1816  ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero.
1818  ImGui::TreePop();
1819  }
1820 
1821  if (ImGui::TreeNode("Settings"))
1822  {
1823  ImGui::SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f");
1824  ImGui::SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 16.0f, "%.0f");
1825  ImGui::SliderFloat("ChildWindowRounding", &style.ChildWindowRounding, 0.0f, 16.0f, "%.0f");
1826  ImGui::SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f");
1827  ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 16.0f, "%.0f");
1828  ImGui::SliderFloat2("ItemSpacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f");
1829  ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f");
1830  ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f");
1831  ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f");
1832  ImGui::SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f");
1833  ImGui::SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 16.0f, "%.0f");
1834  ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f");
1835  ImGui::SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 16.0f, "%.0f");
1836  ImGui::Text("Alignment");
1837  ImGui::SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f");
1838  ImGui::SliderFloat2("ButtonTextAlign", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f"); ImGui::SameLine(); ShowHelpMarker("Alignment applies when a button is larger than its text content.");
1839  ImGui::TreePop();
1840  }
1841 
1842  if (ImGui::TreeNode("Colors"))
1843  {
1844  static int output_dest = 0;
1845  static bool output_only_modified = false;
1846  if (ImGui::Button("Copy Colors"))
1847  {
1848  if (output_dest == 0)
1850  else
1851  ImGui::LogToTTY();
1852  ImGui::LogText("ImVec4* colors = ImGui::GetStyle().Colors;" IM_NEWLINE);
1853  for (int i = 0; i < ImGuiCol_COUNT; i++)
1854  {
1855  const ImVec4& col = style.Colors[i];
1856  const char* name = ImGui::GetStyleColorName(i);
1857  if (!output_only_modified || memcmp(&col, (ref ? &ref->Colors[i] : &default_style.Colors[i]), sizeof(ImVec4)) != 0)
1858  ImGui::LogText("colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 23-(int)strlen(name), "", col.x, col.y, col.z, col.w);
1859  }
1860  ImGui::LogFinish();
1861  }
1862  ImGui::SameLine(); ImGui::PushItemWidth(120); ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0"); ImGui::PopItemWidth();
1863  ImGui::SameLine(); ImGui::Checkbox("Only Modified Fields", &output_only_modified);
1864 
1865  ImGui::Text("Tip: Left-click on colored square to open color picker,\nRight-click to open edit options menu.");
1866 
1867  static ImGuiTextFilter filter;
1868  filter.Draw("Filter colors", 200);
1869 
1870  static ImGuiColorEditFlags alpha_flags = 0;
1871  ImGui::RadioButton("Opaque", &alpha_flags, 0); ImGui::SameLine();
1874 
1876  ImGui::PushItemWidth(-160);
1877  for (int i = 0; i < ImGuiCol_COUNT; i++)
1878  {
1879  const char* name = ImGui::GetStyleColorName(i);
1880  if (!filter.PassFilter(name))
1881  continue;
1882  ImGui::PushID(i);
1883  ImGui::ColorEdit4(name, (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags);
1884  if (memcmp(&style.Colors[i], (ref ? &ref->Colors[i] : &default_style.Colors[i]), sizeof(ImVec4)) != 0)
1885  {
1886  ImGui::SameLine(); if (ImGui::Button("Revert")) style.Colors[i] = ref ? ref->Colors[i] : default_style.Colors[i];
1887  if (ref) { ImGui::SameLine(); if (ImGui::Button("Save")) ref->Colors[i] = style.Colors[i]; }
1888  }
1889  ImGui::PopID();
1890  }
1892  ImGui::EndChild();
1893 
1894  ImGui::TreePop();
1895  }
1896 
1897  bool fonts_opened = ImGui::TreeNode("Fonts", "Fonts (%d)", ImGui::GetIO().Fonts->Fonts.Size);
1898  ImGui::SameLine(); ShowHelpMarker("Tip: Load fonts with io.Fonts->AddFontFromFileTTF()\nbefore calling io.Fonts->GetTex* functions.");
1899  if (fonts_opened)
1900  {
1901  ImFontAtlas* atlas = ImGui::GetIO().Fonts;
1902  if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
1903  {
1904  ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0,0), ImVec2(1,1), ImColor(255,255,255,255), ImColor(255,255,255,128));
1905  ImGui::TreePop();
1906  }
1907  ImGui::PushItemWidth(100);
1908  for (int i = 0; i < atlas->Fonts.Size; i++)
1909  {
1910  ImFont* font = atlas->Fonts[i];
1911  bool font_details_opened = ImGui::TreeNode(font, "Font %d: \'%s\', %.2f px, %d glyphs", i, font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size);
1912  ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) ImGui::GetIO().FontDefault = font;
1913  if (font_details_opened)
1914  {
1915  ImGui::PushFont(font);
1916  ImGui::Text("The quick brown fox jumps over the lazy dog");
1917  ImGui::PopFont();
1918  ImGui::DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); // Scale only this font
1919  ImGui::SameLine(); ShowHelpMarker("Note than the default embedded font is NOT meant to be scaled.\n\nFont are currently rendered into bitmaps at a given size at the time of building the atlas. You may oversample them to get some flexibility with scaling. You can also render at multiple sizes and select which one to use at runtime.\n\n(Glimmer of hope: the atlas system should hopefully be rewritten in the future to make scaling more natural and automatic.)");
1920  ImGui::Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent);
1921  ImGui::Text("Fallback character: '%c' (%d)", font->FallbackChar, font->FallbackChar);
1922  ImGui::Text("Texture surface: %d pixels (approx) ~ %dx%d", font->MetricsTotalSurface, (int)sqrtf((float)font->MetricsTotalSurface), (int)sqrtf((float)font->MetricsTotalSurface));
1923  for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
1924  {
1925  ImFontConfig* cfg = &font->ConfigData[config_i];
1926  ImGui::BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d", config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH);
1927  }
1928  if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
1929  {
1930  // Display all glyphs of the fonts in separate pages of 256 characters
1931  const ImFontGlyph* glyph_fallback = font->FallbackGlyph; // Forcefully/dodgily make FindGlyph() return NULL on fallback, which isn't the default behavior.
1932  font->FallbackGlyph = NULL;
1933  for (int base = 0; base < 0x10000; base += 256)
1934  {
1935  int count = 0;
1936  for (int n = 0; n < 256; n++)
1937  count += font->FindGlyph((ImWchar)(base + n)) ? 1 : 0;
1938  if (count > 0 && ImGui::TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base+255, count, count > 1 ? "glyphs" : "glyph"))
1939  {
1940  float cell_spacing = style.ItemSpacing.y;
1941  ImVec2 cell_size(font->FontSize * 1, font->FontSize * 1);
1942  ImVec2 base_pos = ImGui::GetCursorScreenPos();
1943  ImDrawList* draw_list = ImGui::GetWindowDrawList();
1944  for (int n = 0; n < 256; n++)
1945  {
1946  ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size.x + cell_spacing), base_pos.y + (n / 16) * (cell_size.y + cell_spacing));
1947  ImVec2 cell_p2(cell_p1.x + cell_size.x, cell_p1.y + cell_size.y);
1948  const ImFontGlyph* glyph = font->FindGlyph((ImWchar)(base+n));;
1949  draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255,255,255,100) : IM_COL32(255,255,255,50));
1950  font->RenderChar(draw_list, cell_size.x, cell_p1, ImGui::GetColorU32(ImGuiCol_Text), (ImWchar)(base+n)); // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions available to generate a string.
1951  if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2))
1952  {
1954  ImGui::Text("Codepoint: U+%04X", base+n);
1955  ImGui::Separator();
1956  ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX);
1957  ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1);
1958  ImGui::Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1);
1960  }
1961  }
1962  ImGui::Dummy(ImVec2((cell_size.x + cell_spacing) * 16, (cell_size.y + cell_spacing) * 16));
1963  ImGui::TreePop();
1964  }
1965  }
1966  font->FallbackGlyph = glyph_fallback;
1967  ImGui::TreePop();
1968  }
1969  ImGui::TreePop();
1970  }
1971  }
1972  static float window_scale = 1.0f;
1973  ImGui::DragFloat("this window scale", &window_scale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale only this window
1974  ImGui::DragFloat("global scale", &ImGui::GetIO().FontGlobalScale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale everything
1976  ImGui::SetWindowFontScale(window_scale);
1977  ImGui::TreePop();
1978  }
1979 
1981 }
1982 
1983 // Demonstrate creating a fullscreen menu bar and populating it.
1984 static void ShowExampleAppMainMenuBar()
1985 {
1987  {
1988  if (ImGui::BeginMenu("File"))
1989  {
1990  ShowExampleMenuFile();
1991  ImGui::EndMenu();
1992  }
1993  if (ImGui::BeginMenu("Edit"))
1994  {
1995  if (ImGui::MenuItem("Undo", "CTRL+Z")) {}
1996  if (ImGui::MenuItem("Redo", "CTRL+Y", false, false)) {} // Disabled item
1997  ImGui::Separator();
1998  if (ImGui::MenuItem("Cut", "CTRL+X")) {}
1999  if (ImGui::MenuItem("Copy", "CTRL+C")) {}
2000  if (ImGui::MenuItem("Paste", "CTRL+V")) {}
2001  ImGui::EndMenu();
2002  }
2004  }
2005 }
2006 
2007 static void ShowExampleMenuFile()
2008 {
2009  ImGui::MenuItem("(dummy menu)", NULL, false, false);
2010  if (ImGui::MenuItem("New")) {}
2011  if (ImGui::MenuItem("Open", "Ctrl+O")) {}
2012  if (ImGui::BeginMenu("Open Recent"))
2013  {
2014  ImGui::MenuItem("fish_hat.c");
2015  ImGui::MenuItem("fish_hat.inl");
2016  ImGui::MenuItem("fish_hat.h");
2017  if (ImGui::BeginMenu("More.."))
2018  {
2019  ImGui::MenuItem("Hello");
2020  ImGui::MenuItem("Sailor");
2021  if (ImGui::BeginMenu("Recurse.."))
2022  {
2023  ShowExampleMenuFile();
2024  ImGui::EndMenu();
2025  }
2026  ImGui::EndMenu();
2027  }
2028  ImGui::EndMenu();
2029  }
2030  if (ImGui::MenuItem("Save", "Ctrl+S")) {}
2031  if (ImGui::MenuItem("Save As..")) {}
2032  ImGui::Separator();
2033  if (ImGui::BeginMenu("Options"))
2034  {
2035  static bool enabled = true;
2036  ImGui::MenuItem("Enabled", "", &enabled);
2037  ImGui::BeginChild("child", ImVec2(0, 60), true);
2038  for (int i = 0; i < 10; i++)
2039  ImGui::Text("Scrolling Text %d", i);
2040  ImGui::EndChild();
2041  static float f = 0.5f;
2042  static int n = 0;
2043  static bool b = true;
2044  ImGui::SliderFloat("Value", &f, 0.0f, 1.0f);
2045  ImGui::InputFloat("Input", &f, 0.1f);
2046  ImGui::Combo("Combo", &n, "Yes\0No\0Maybe\0\0");
2047  ImGui::Checkbox("Check", &b);
2048  ImGui::EndMenu();
2049  }
2050  if (ImGui::BeginMenu("Colors"))
2051  {
2052  for (int i = 0; i < ImGuiCol_COUNT; i++)
2054  ImGui::EndMenu();
2055  }
2056  if (ImGui::BeginMenu("Disabled", false)) // Disabled
2057  {
2058  IM_ASSERT(0);
2059  }
2060  if (ImGui::MenuItem("Checked", NULL, true)) {}
2061  if (ImGui::MenuItem("Quit", "Alt+F4")) {}
2062 }
2063 
2064 // Demonstrate creating a window which gets auto-resized according to its content.
2065 static void ShowExampleAppAutoResize(bool* p_open)
2066 {
2067  if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize))
2068  {
2069  ImGui::End();
2070  return;
2071  }
2072 
2073  static int lines = 10;
2074  ImGui::Text("Window will resize every-frame to the size of its content.\nNote that you probably don't want to query the window size to\noutput your content because that would create a feedback loop.");
2075  ImGui::SliderInt("Number of lines", &lines, 1, 20);
2076  for (int i = 0; i < lines; i++)
2077  ImGui::Text("%*sThis is line %d", i*4, "", i); // Pad with space to extend size horizontally
2078  ImGui::End();
2079 }
2080 
2081 // Demonstrate creating a window with custom resize constraints.
2082 static void ShowExampleAppConstrainedResize(bool* p_open)
2083 {
2084  struct CustomConstraints // Helper functions to demonstrate programmatic constraints
2085  {
2086  static void Square(ImGuiSizeConstraintCallbackData* data) { data->DesiredSize = ImVec2(IM_MAX(data->DesiredSize.x, data->DesiredSize.y), IM_MAX(data->DesiredSize.x, data->DesiredSize.y)); }
2087  static void Step(ImGuiSizeConstraintCallbackData* data) { float step = (float)(int)(intptr_t)data->UserData; data->DesiredSize = ImVec2((int)(data->DesiredSize.x / step + 0.5f) * step, (int)(data->DesiredSize.y / step + 0.5f) * step); }
2088  };
2089 
2090  static int type = 0;
2091  if (type == 0) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 0), ImVec2(-1, FLT_MAX)); // Vertical only
2092  if (type == 1) ImGui::SetNextWindowSizeConstraints(ImVec2(0, -1), ImVec2(FLT_MAX, -1)); // Horizontal only
2093  if (type == 2) ImGui::SetNextWindowSizeConstraints(ImVec2(100, 100), ImVec2(FLT_MAX, FLT_MAX)); // Width > 100, Height > 100
2094  if (type == 3) ImGui::SetNextWindowSizeConstraints(ImVec2(300, 0), ImVec2(400, FLT_MAX)); // Width 300-400
2095  if (type == 4) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Square); // Always Square
2096  if (type == 5) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Step, (void*)100);// Fixed Step
2097 
2098  if (ImGui::Begin("Example: Constrained Resize", p_open))
2099  {
2100  const char* desc[] =
2101  {
2102  "Resize vertical only",
2103  "Resize horizontal only",
2104  "Width > 100, Height > 100",
2105  "Width 300-400",
2106  "Custom: Always Square",
2107  "Custom: Fixed Steps (100)",
2108  };
2109  ImGui::Combo("Constraint", &type, desc, IM_ARRAYSIZE(desc));
2110  if (ImGui::Button("200x200")) { ImGui::SetWindowSize(ImVec2(200,200)); } ImGui::SameLine();
2111  if (ImGui::Button("500x500")) { ImGui::SetWindowSize(ImVec2(500,500)); } ImGui::SameLine();
2112  if (ImGui::Button("800x200")) { ImGui::SetWindowSize(ImVec2(800,200)); }
2113  for (int i = 0; i < 10; i++)
2114  ImGui::Text("Hello, sailor! Making this line long enough for the example.");
2115  }
2116  ImGui::End();
2117 }
2118 
2119 // Demonstrate creating a simple static window with no decoration + a context-menu to choose which corner of the screen to use.
2120 static void ShowExampleAppFixedOverlay(bool* p_open)
2121 {
2122  const float DISTANCE = 10.0f;
2123  static int corner = 0;
2124  ImVec2 window_pos = ImVec2((corner & 1) ? ImGui::GetIO().DisplaySize.x - DISTANCE : DISTANCE, (corner & 2) ? ImGui::GetIO().DisplaySize.y - DISTANCE : DISTANCE);
2125  ImVec2 window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f);
2126  ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
2127  ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0f, 0.0f, 0.0f, 0.3f));
2129  {
2130  ImGui::Text("Simple overlay\nin the corner of the screen.\n(right-click to change position)");
2131  ImGui::Separator();
2132  ImGui::Text("Mouse Position: (%.1f,%.1f)", ImGui::GetIO().MousePos.x, ImGui::GetIO().MousePos.y);
2134  {
2135  if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0;
2136  if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1;
2137  if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2;
2138  if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3;
2139  ImGui::EndPopup();
2140  }
2141  ImGui::End();
2142  }
2144 }
2145 
2146 // Demonstrate using "##" and "###" in identifiers to manipulate ID generation.
2147 // Read section "How can I have multiple widgets with the same label? Can I have widget without a label? (Yes). A primer on the purpose of labels/IDs." about ID.
2148 static void ShowExampleAppManipulatingWindowTitle(bool*)
2149 {
2150  // By default, Windows are uniquely identified by their title.
2151  // You can use the "##" and "###" markers to manipulate the display/ID.
2152 
2153  // Using "##" to display same title but have unique identifier.
2155  ImGui::Begin("Same title as another window##1");
2156  ImGui::Text("This is window 1.\nMy title is the same as window 2, but my identifier is unique.");
2157  ImGui::End();
2158 
2160  ImGui::Begin("Same title as another window##2");
2161  ImGui::Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique.");
2162  ImGui::End();
2163 
2164  // Using "###" to display a changing title but keep a static identifier "AnimatedTitle"
2165  char buf[128];
2166  sprintf(buf, "Animated title %c %d###AnimatedTitle", "|/-\\"[(int)(ImGui::GetTime()/0.25f)&3], rand());
2168  ImGui::Begin(buf);
2169  ImGui::Text("This window has a changing title.");
2170  ImGui::End();
2171 }
2172 
2173 // Demonstrate using the low-level ImDrawList to draw custom shapes.
2174 static void ShowExampleAppCustomRendering(bool* p_open)
2175 {
2177  if (!ImGui::Begin("Example: Custom rendering", p_open))
2178  {
2179  ImGui::End();
2180  return;
2181  }
2182 
2183  // Tip: If you do a lot of custom rendering, you probably want to use your own geometrical types and benefit of overloaded operators, etc.
2184  // Define IM_VEC2_CLASS_EXTRA in imconfig.h to create implicit conversions between your types and ImVec2/ImVec4.
2185  // ImGui defines overloaded operators but they are internal to imgui.cpp and not exposed outside (to avoid messing with your types)
2186  // In this example we are not using the maths operators!
2187  ImDrawList* draw_list = ImGui::GetWindowDrawList();
2188 
2189  // Primitives
2190  ImGui::Text("Primitives");
2191  static float sz = 36.0f;
2192  static ImVec4 col = ImVec4(1.0f,1.0f,0.4f,1.0f);
2193  ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f");
2194  ImGui::ColorEdit3("Color", &col.x);
2195  {
2196  const ImVec2 p = ImGui::GetCursorScreenPos();
2197  const ImU32 col32 = ImColor(col);
2198  float x = p.x + 4.0f, y = p.y + 4.0f, spacing = 8.0f;
2199  for (int n = 0; n < 2; n++)
2200  {
2201  float thickness = (n == 0) ? 1.0f : 4.0f;
2202  draw_list->AddCircle(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 20, thickness); x += sz+spacing;
2203  draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 0.0f, ~0, thickness); x += sz+spacing;
2204  draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ~0, thickness); x += sz+spacing;
2205  draw_list->AddTriangle(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32, thickness); x += sz+spacing;
2206  draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y ), col32, thickness); x += sz+spacing;
2207  draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, thickness); x += sz+spacing;
2208  draw_list->AddLine(ImVec2(x, y), ImVec2(x, y+sz), col32, thickness); x += spacing;
2209  draw_list->AddBezierCurve(ImVec2(x, y), ImVec2(x+sz*1.3f,y+sz*0.3f), ImVec2(x+sz-sz*1.3f,y+sz-sz*0.3f), ImVec2(x+sz, y+sz), col32, thickness);
2210  x = p.x + 4;
2211  y += sz+spacing;
2212  }
2213  draw_list->AddCircleFilled(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 32); x += sz+spacing;
2214  draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32); x += sz+spacing;
2215  draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f); x += sz+spacing;
2216  draw_list->AddTriangleFilled(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32); x += sz+spacing;
2217  draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x+sz, y+sz), ImColor(0,0,0), ImColor(255,0,0), ImColor(255,255,0), ImColor(0,255,0));
2218  ImGui::Dummy(ImVec2((sz+spacing)*8, (sz+spacing)*3));
2219  }
2220  ImGui::Separator();
2221  {
2222  static ImVector<ImVec2> points;
2223  static bool adding_line = false;
2224  ImGui::Text("Canvas example");
2225  if (ImGui::Button("Clear")) points.clear();
2226  if (points.Size >= 2) { ImGui::SameLine(); if (ImGui::Button("Undo")) { points.pop_back(); points.pop_back(); } }
2227  ImGui::Text("Left-click and drag to add lines,\nRight-click to undo");
2228 
2229  // Here we are using InvisibleButton() as a convenience to 1) advance the cursor and 2) allows us to use IsItemHovered()
2230  // However you can draw directly and poll mouse/keyboard by yourself. You can manipulate the cursor using GetCursorPos() and SetCursorPos().
2231  // If you only use the ImDrawList API, you can notify the owner window of its extends by using SetCursorPos(max).
2232  ImVec2 canvas_pos = ImGui::GetCursorScreenPos(); // ImDrawList API uses screen coordinates!
2233  ImVec2 canvas_size = ImGui::GetContentRegionAvail(); // Resize canvas to what's available
2234  if (canvas_size.x < 50.0f) canvas_size.x = 50.0f;
2235  if (canvas_size.y < 50.0f) canvas_size.y = 50.0f;
2236  draw_list->AddRectFilledMultiColor(canvas_pos, ImVec2(canvas_pos.x + canvas_size.x, canvas_pos.y + canvas_size.y), ImColor(50,50,50), ImColor(50,50,60), ImColor(60,60,70), ImColor(50,50,60));
2237  draw_list->AddRect(canvas_pos, ImVec2(canvas_pos.x + canvas_size.x, canvas_pos.y + canvas_size.y), ImColor(255,255,255));
2238 
2239  bool adding_preview = false;
2240  ImGui::InvisibleButton("canvas", canvas_size);
2241  ImVec2 mouse_pos_in_canvas = ImVec2(ImGui::GetIO().MousePos.x - canvas_pos.x, ImGui::GetIO().MousePos.y - canvas_pos.y);
2242  if (adding_line)
2243  {
2244  adding_preview = true;
2245  points.push_back(mouse_pos_in_canvas);
2246  if (!ImGui::GetIO().MouseDown[0])
2247  adding_line = adding_preview = false;
2248  }
2249  if (ImGui::IsItemHovered())
2250  {
2251  if (!adding_line && ImGui::IsMouseClicked(0))
2252  {
2253  points.push_back(mouse_pos_in_canvas);
2254  adding_line = true;
2255  }
2256  if (ImGui::IsMouseClicked(1) && !points.empty())
2257  {
2258  adding_line = adding_preview = false;
2259  points.pop_back();
2260  points.pop_back();
2261  }
2262  }
2263  draw_list->PushClipRect(canvas_pos, ImVec2(canvas_pos.x+canvas_size.x, canvas_pos.y+canvas_size.y)); // clip lines within the canvas (if we resize it, etc.)
2264  for (int i = 0; i < points.Size - 1; i += 2)
2265  draw_list->AddLine(ImVec2(canvas_pos.x + points[i].x, canvas_pos.y + points[i].y), ImVec2(canvas_pos.x + points[i+1].x, canvas_pos.y + points[i+1].y), IM_COL32(255,255,0,255), 2.0f);
2266  draw_list->PopClipRect();
2267  if (adding_preview)
2268  points.pop_back();
2269  }
2270  ImGui::End();
2271 }
2272 
2273 // Demonstrating creating a simple console window, with scrolling, filtering, completion and history.
2274 // For the console example, here we are using a more C++ like approach of declaring a class to hold the data and the functions.
2276 {
2277  char InputBuf[256];
2281  int HistoryPos; // -1: new line, 0..History.Size-1 browsing history.
2283 
2285  {
2286  ClearLog();
2287  memset(InputBuf, 0, sizeof(InputBuf));
2288  HistoryPos = -1;
2289  Commands.push_back("HELP");
2290  Commands.push_back("HISTORY");
2291  Commands.push_back("CLEAR");
2292  Commands.push_back("CLASSIFY"); // "classify" is here to provide an example of "C"+[tab] completing to "CL" and displaying matches.
2293  AddLog("Welcome to ImGui!");
2294  }
2296  {
2297  ClearLog();
2298  for (int i = 0; i < History.Size; i++)
2299  free(History[i]);
2300  }
2301 
2302  // Portable helpers
2303  static int Stricmp(const char* str1, const char* str2) { int d; while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; } return d; }
2304  static int Strnicmp(const char* str1, const char* str2, int n) { int d = 0; while (n > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; n--; } return d; }
2305  static char* Strdup(const char *str) { size_t len = strlen(str) + 1; void* buff = malloc(len); return (char*)memcpy(buff, (const void*)str, len); }
2306 
2307  void ClearLog()
2308  {
2309  for (int i = 0; i < Items.Size; i++)
2310  free(Items[i]);
2311  Items.clear();
2312  ScrollToBottom = true;
2313  }
2314 
2315  void AddLog(const char* fmt, ...) IM_FMTARGS(2)
2316  {
2317  char buf[1024];
2318  va_list args;
2319  va_start(args, fmt);
2320  vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
2321  buf[IM_ARRAYSIZE(buf)-1] = 0;
2322  va_end(args);
2323  Items.push_back(Strdup(buf));
2324  ScrollToBottom = true;
2325  }
2326 
2327  void Draw(const char* title, bool* p_open)
2328  {
2330  if (!ImGui::Begin(title, p_open))
2331  {
2332  ImGui::End();
2333  return;
2334  }
2335 
2336  ImGui::TextWrapped("This example implements a console with basic coloring, completion and history. A more elaborate implementation may want to store entries along with extra data such as timestamp, emitter, etc.");
2337  ImGui::TextWrapped("Enter 'HELP' for help, press TAB to use text completion.");
2338 
2339  // TODO: display items starting from the bottom
2340 
2341  if (ImGui::SmallButton("Add Dummy Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } ImGui::SameLine();
2342  if (ImGui::SmallButton("Add Dummy Error")) { AddLog("[error] something went wrong"); } ImGui::SameLine();
2343  if (ImGui::SmallButton("Clear")) { ClearLog(); } ImGui::SameLine();
2344  bool copy_to_clipboard = ImGui::SmallButton("Copy"); ImGui::SameLine();
2345  if (ImGui::SmallButton("Scroll to bottom")) ScrollToBottom = true;
2346  //static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); }
2347 
2348  ImGui::Separator();
2349 
2351  static ImGuiTextFilter filter;
2352  filter.Draw("Filter (\"incl,-excl\") (\"error\")", 180);
2354  ImGui::Separator();
2355 
2358  {
2359  if (ImGui::Selectable("Clear")) ClearLog();
2360  ImGui::EndPopup();
2361  }
2362 
2363  // Display every line as a separate entry so we can change their color or add custom widgets. If you only want raw text you can use ImGui::TextUnformatted(log.begin(), log.end());
2364  // NB- if you have thousands of entries this approach may be too inefficient and may require user-side clipping to only process visible items.
2365  // You can seek and display only the lines that are visible using the ImGuiListClipper helper, if your elements are evenly spaced and you have cheap random access to the elements.
2366  // To use the clipper we could replace the 'for (int i = 0; i < Items.Size; i++)' loop with:
2367  // ImGuiListClipper clipper(Items.Size);
2368  // while (clipper.Step())
2369  // for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
2370  // However take note that you can not use this code as is if a filter is active because it breaks the 'cheap random-access' property. We would need random-access on the post-filtered list.
2371  // A typical application wanting coarse clipping and filtering may want to pre-compute an array of indices that passed the filtering test, recomputing this array when user changes the filter,
2372  // and appending newly elements as they are inserted. This is left as a task to the user until we can manage to improve this example code!
2373  // If your items are of variable size you may want to implement code similar to what ImGuiListClipper does. Or split your data into fixed height items to allow random-seeking into your list.
2374  ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4,1)); // Tighten spacing
2375  if (copy_to_clipboard)
2377  for (int i = 0; i < Items.Size; i++)
2378  {
2379  const char* item = Items[i];
2380  if (!filter.PassFilter(item))
2381  continue;
2382  ImVec4 col = ImVec4(1.0f,1.0f,1.0f,1.0f); // A better implementation may store a type per-item. For the sample let's just parse the text.
2383  if (strstr(item, "[error]")) col = ImColor(1.0f,0.4f,0.4f,1.0f);
2384  else if (strncmp(item, "# ", 2) == 0) col = ImColor(1.0f,0.78f,0.58f,1.0f);
2386  ImGui::TextUnformatted(item);
2388  }
2389  if (copy_to_clipboard)
2390  ImGui::LogFinish();
2391  if (ScrollToBottom)
2393  ScrollToBottom = false;
2395  ImGui::EndChild();
2396  ImGui::Separator();
2397 
2398  // Command-line
2400  {
2401  char* input_end = InputBuf+strlen(InputBuf);
2402  while (input_end > InputBuf && input_end[-1] == ' ') { input_end--; } *input_end = 0;
2403  if (InputBuf[0])
2404  ExecCommand(InputBuf);
2405  strcpy(InputBuf, "");
2406  }
2407 
2408  // Demonstrate keeping auto focus on the input box
2410  ImGui::SetKeyboardFocusHere(-1); // Auto focus previous widget
2411 
2412  ImGui::End();
2413  }
2414 
2415  void ExecCommand(const char* command_line)
2416  {
2417  AddLog("# %s\n", command_line);
2418 
2419  // Insert into history. First find match and delete it so it can be pushed to the back. This isn't trying to be smart or optimal.
2420  HistoryPos = -1;
2421  for (int i = History.Size-1; i >= 0; i--)
2422  if (Stricmp(History[i], command_line) == 0)
2423  {
2424  free(History[i]);
2425  History.erase(History.begin() + i);
2426  break;
2427  }
2428  History.push_back(Strdup(command_line));
2429 
2430  // Process command
2431  if (Stricmp(command_line, "CLEAR") == 0)
2432  {
2433  ClearLog();
2434  }
2435  else if (Stricmp(command_line, "HELP") == 0)
2436  {
2437  AddLog("Commands:");
2438  for (int i = 0; i < Commands.Size; i++)
2439  AddLog("- %s", Commands[i]);
2440  }
2441  else if (Stricmp(command_line, "HISTORY") == 0)
2442  {
2443  int first = History.Size - 10;
2444  for (int i = first > 0 ? first : 0; i < History.Size; i++)
2445  AddLog("%3d: %s\n", i, History[i]);
2446  }
2447  else
2448  {
2449  AddLog("Unknown command: '%s'\n", command_line);
2450  }
2451  }
2452 
2453  static int TextEditCallbackStub(ImGuiTextEditCallbackData* data) // In C++11 you are better off using lambdas for this sort of forwarding callbacks
2454  {
2455  ExampleAppConsole* console = (ExampleAppConsole*)data->UserData;
2456  return console->TextEditCallback(data);
2457  }
2458 
2460  {
2461  //AddLog("cursor: %d, selection: %d-%d", data->CursorPos, data->SelectionStart, data->SelectionEnd);
2462  switch (data->EventFlag)
2463  {
2465  {
2466  // Example of TEXT COMPLETION
2467 
2468  // Locate beginning of current word
2469  const char* word_end = data->Buf + data->CursorPos;
2470  const char* word_start = word_end;
2471  while (word_start > data->Buf)
2472  {
2473  const char c = word_start[-1];
2474  if (c == ' ' || c == '\t' || c == ',' || c == ';')
2475  break;
2476  word_start--;
2477  }
2478 
2479  // Build a list of candidates
2480  ImVector<const char*> candidates;
2481  for (int i = 0; i < Commands.Size; i++)
2482  if (Strnicmp(Commands[i], word_start, (int)(word_end-word_start)) == 0)
2483  candidates.push_back(Commands[i]);
2484 
2485  if (candidates.Size == 0)
2486  {
2487  // No match
2488  AddLog("No match for \"%.*s\"!\n", (int)(word_end-word_start), word_start);
2489  }
2490  else if (candidates.Size == 1)
2491  {
2492  // Single match. Delete the beginning of the word and replace it entirely so we've got nice casing
2493  data->DeleteChars((int)(word_start-data->Buf), (int)(word_end-word_start));
2494  data->InsertChars(data->CursorPos, candidates[0]);
2495  data->InsertChars(data->CursorPos, " ");
2496  }
2497  else
2498  {
2499  // Multiple matches. Complete as much as we can, so inputing "C" will complete to "CL" and display "CLEAR" and "CLASSIFY"
2500  int match_len = (int)(word_end - word_start);
2501  for (;;)
2502  {
2503  int c = 0;
2504  bool all_candidates_matches = true;
2505  for (int i = 0; i < candidates.Size && all_candidates_matches; i++)
2506  if (i == 0)
2507  c = toupper(candidates[i][match_len]);
2508  else if (c == 0 || c != toupper(candidates[i][match_len]))
2509  all_candidates_matches = false;
2510  if (!all_candidates_matches)
2511  break;
2512  match_len++;
2513  }
2514 
2515  if (match_len > 0)
2516  {
2517  data->DeleteChars((int)(word_start - data->Buf), (int)(word_end-word_start));
2518  data->InsertChars(data->CursorPos, candidates[0], candidates[0] + match_len);
2519  }
2520 
2521  // List matches
2522  AddLog("Possible matches:\n");
2523  for (int i = 0; i < candidates.Size; i++)
2524  AddLog("- %s\n", candidates[i]);
2525  }
2526 
2527  break;
2528  }
2530  {
2531  // Example of HISTORY
2532  const int prev_history_pos = HistoryPos;
2533  if (data->EventKey == ImGuiKey_UpArrow)
2534  {
2535  if (HistoryPos == -1)
2536  HistoryPos = History.Size - 1;
2537  else if (HistoryPos > 0)
2538  HistoryPos--;
2539  }
2540  else if (data->EventKey == ImGuiKey_DownArrow)
2541  {
2542  if (HistoryPos != -1)
2543  if (++HistoryPos >= History.Size)
2544  HistoryPos = -1;
2545  }
2546 
2547  // A better implementation would preserve the data on the current input line along with cursor position.
2548  if (prev_history_pos != HistoryPos)
2549  {
2550  data->CursorPos = data->SelectionStart = data->SelectionEnd = data->BufTextLen = (int)snprintf(data->Buf, (size_t)data->BufSize, "%s", (HistoryPos >= 0) ? History[HistoryPos] : "");
2551  data->BufDirty = true;
2552  }
2553  }
2554  }
2555  return 0;
2556  }
2557 };
2558 
2559 static void ShowExampleAppConsole(bool* p_open)
2560 {
2561  static ExampleAppConsole console;
2562  console.Draw("Example: Console", p_open);
2563 }
2564 
2565 // Usage:
2566 // static ExampleAppLog my_log;
2567 // my_log.AddLog("Hello %d world\n", 123);
2568 // my_log.Draw("title");
2570 {
2573  ImVector<int> LineOffsets; // Index to lines offset
2575 
2576  void Clear() { Buf.clear(); LineOffsets.clear(); }
2577 
2578  void AddLog(const char* fmt, ...) IM_FMTARGS(2)
2579  {
2580  int old_size = Buf.size();
2581  va_list args;
2582  va_start(args, fmt);
2583  Buf.appendv(fmt, args);
2584  va_end(args);
2585  for (int new_size = Buf.size(); old_size < new_size; old_size++)
2586  if (Buf[old_size] == '\n')
2587  LineOffsets.push_back(old_size);
2588  ScrollToBottom = true;
2589  }
2590 
2591  void Draw(const char* title, bool* p_open = NULL)
2592  {
2594  ImGui::Begin(title, p_open);
2595  if (ImGui::Button("Clear")) Clear();
2596  ImGui::SameLine();
2597  bool copy = ImGui::Button("Copy");
2598  ImGui::SameLine();
2599  Filter.Draw("Filter", -100.0f);
2600  ImGui::Separator();
2602  if (copy) ImGui::LogToClipboard();
2603 
2604  if (Filter.IsActive())
2605  {
2606  const char* buf_begin = Buf.begin();
2607  const char* line = buf_begin;
2608  for (int line_no = 0; line != NULL; line_no++)
2609  {
2610  const char* line_end = (line_no < LineOffsets.Size) ? buf_begin + LineOffsets[line_no] : NULL;
2611  if (Filter.PassFilter(line, line_end))
2612  ImGui::TextUnformatted(line, line_end);
2613  line = line_end && line_end[1] ? line_end + 1 : NULL;
2614  }
2615  }
2616  else
2617  {
2619  }
2620 
2621  if (ScrollToBottom)
2622  ImGui::SetScrollHere(1.0f);
2623  ScrollToBottom = false;
2624  ImGui::EndChild();
2625  ImGui::End();
2626  }
2627 };
2628 
2629 // Demonstrate creating a simple log window with basic filtering.
2630 static void ShowExampleAppLog(bool* p_open)
2631 {
2632  static ExampleAppLog log;
2633 
2634  // Demo: add random items (unless Ctrl is held)
2635  static float last_time = -1.0f;
2636  float time = ImGui::GetTime();
2637  if (time - last_time >= 0.20f && !ImGui::GetIO().KeyCtrl)
2638  {
2639  const char* random_words[] = { "system", "info", "warning", "error", "fatal", "notice", "log" };
2640  log.AddLog("[%s] Hello, time is %.1f, rand() %d\n", random_words[rand() % IM_ARRAYSIZE(random_words)], time, (int)rand());
2641  last_time = time;
2642  }
2643 
2644  log.Draw("Example: Log", p_open);
2645 }
2646 
2647 // Demonstrate create a window with multiple child windows.
2648 static void ShowExampleAppLayout(bool* p_open)
2649 {
2651  if (ImGui::Begin("Example: Layout", p_open, ImGuiWindowFlags_MenuBar))
2652  {
2653  if (ImGui::BeginMenuBar())
2654  {
2655  if (ImGui::BeginMenu("File"))
2656  {
2657  if (ImGui::MenuItem("Close")) *p_open = false;
2658  ImGui::EndMenu();
2659  }
2661  }
2662 
2663  // left
2664  static int selected = 0;
2665  ImGui::BeginChild("left pane", ImVec2(150, 0), true);
2666  for (int i = 0; i < 100; i++)
2667  {
2668  char label[128];
2669  sprintf(label, "MyObject %d", i);
2670  if (ImGui::Selectable(label, selected == i))
2671  selected = i;
2672  }
2673  ImGui::EndChild();
2674  ImGui::SameLine();
2675 
2676  // right
2678  ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetItemsLineHeightWithSpacing())); // Leave room for 1 line below us
2679  ImGui::Text("MyObject: %d", selected);
2680  ImGui::Separator();
2681  ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ");
2682  ImGui::EndChild();
2683  ImGui::BeginChild("buttons");
2684  if (ImGui::Button("Revert")) {}
2685  ImGui::SameLine();
2686  if (ImGui::Button("Save")) {}
2687  ImGui::EndChild();
2688  ImGui::EndGroup();
2689  }
2690  ImGui::End();
2691 }
2692 
2693 // Demonstrate create a simple property editor.
2694 static void ShowExampleAppPropertyEditor(bool* p_open)
2695 {
2697  if (!ImGui::Begin("Example: Property editor", p_open))
2698  {
2699  ImGui::End();
2700  return;
2701  }
2702 
2703  ShowHelpMarker("This example shows how you may implement a property editor using two columns.\nAll objects/fields data are dummies here.\nRemember that in many simple cases, you can use ImGui::SameLine(xxx) to position\nyour cursor horizontally instead of using the Columns() API.");
2704 
2706  ImGui::Columns(2);
2707  ImGui::Separator();
2708 
2709  struct funcs
2710  {
2711  static void ShowDummyObject(const char* prefix, int uid)
2712  {
2713  ImGui::PushID(uid); // Use object uid as identifier. Most commonly you could also use the object pointer as a base ID.
2714  ImGui::AlignFirstTextHeightToWidgets(); // Text and Tree nodes are less high than regular widgets, here we add vertical spacing to make the tree lines equal high.
2715  bool node_open = ImGui::TreeNode("Object", "%s_%u", prefix, uid);
2718  ImGui::Text("my sailor is rich");
2720  if (node_open)
2721  {
2722  static float dummy_members[8] = { 0.0f,0.0f,1.0f,3.1416f,100.0f,999.0f };
2723  for (int i = 0; i < 8; i++)
2724  {
2725  ImGui::PushID(i); // Use field index as identifier.
2726  if (i < 2)
2727  {
2728  ShowDummyObject("Child", 424242);
2729  }
2730  else
2731  {
2733  // Here we use a Selectable (instead of Text) to highlight on hover
2734  //ImGui::Text("Field_%d", i);
2735  char label[32];
2736  sprintf(label, "Field_%d", i);
2737  ImGui::Bullet();
2738  ImGui::Selectable(label);
2741  if (i >= 5)
2742  ImGui::InputFloat("##value", &dummy_members[i], 1.0f);
2743  else
2744  ImGui::DragFloat("##value", &dummy_members[i], 0.01f);
2747  }
2748  ImGui::PopID();
2749  }
2750  ImGui::TreePop();
2751  }
2752  ImGui::PopID();
2753  }
2754  };
2755 
2756  // Iterate dummy objects with dummy members (all the same data)
2757  for (int obj_i = 0; obj_i < 3; obj_i++)
2758  funcs::ShowDummyObject("Object", obj_i);
2759 
2760  ImGui::Columns(1);
2761  ImGui::Separator();
2763  ImGui::End();
2764 }
2765 
2766 // Demonstrate/test rendering huge amount of text, and the incidence of clipping.
2767 static void ShowExampleAppLongText(bool* p_open)
2768 {
2770  if (!ImGui::Begin("Example: Long text display", p_open))
2771  {
2772  ImGui::End();
2773  return;
2774  }
2775 
2776  static int test_type = 0;
2777  static ImGuiTextBuffer log;
2778  static int lines = 0;
2779  ImGui::Text("Printing unusually long amount of text.");
2780  ImGui::Combo("Test type", &test_type, "Single call to TextUnformatted()\0Multiple calls to Text(), clipped manually\0Multiple calls to Text(), not clipped\0");
2781  ImGui::Text("Buffer contents: %d lines, %d bytes", lines, log.size());
2782  if (ImGui::Button("Clear")) { log.clear(); lines = 0; }
2783  ImGui::SameLine();
2784  if (ImGui::Button("Add 1000 lines"))
2785  {
2786  for (int i = 0; i < 1000; i++)
2787  log.append("%i The quick brown fox jumps over the lazy dog\n", lines+i);
2788  lines += 1000;
2789  }
2790  ImGui::BeginChild("Log");
2791  switch (test_type)
2792  {
2793  case 0:
2794  // Single call to TextUnformatted() with a big buffer
2795  ImGui::TextUnformatted(log.begin(), log.end());
2796  break;
2797  case 1:
2798  {
2799  // Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper.
2801  ImGuiListClipper clipper(lines);
2802  while (clipper.Step())
2803  for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
2804  ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
2806  break;
2807  }
2808  case 2:
2809  // Multiple calls to Text(), not clipped (slow)
2811  for (int i = 0; i < lines; i++)
2812  ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
2814  break;
2815  }
2816  ImGui::EndChild();
2817  ImGui::End();
2818 }
2819 
2820 // End of Demo code
2821 #else
2822 
2823 void ImGui::ShowTestWindow(bool*) {}
2824 void ImGui::ShowUserGuide() {}
2826 
2827 #endif
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val)
Definition: imgui.cpp:4888
IMGUI_API void SetNextWindowSize(const ImVec2 &size, ImGuiCond cond=0)
Definition: imgui.cpp:5190
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))
Definition: imgui.cpp:5860
ImVector< char * > History
IMGUI_API ImVec2 GetCursorStartPos()
Definition: imgui.cpp:5361
unsigned int ImU32
Definition: imgui.h:66
IMGUI_API void SetTooltip(const char *fmt,...) IM_FMTARGS(1)
Definition: imgui.cpp:3459
IMGUI_API bool IsMouseReleased(int button)
Definition: imgui.cpp:3270
bool MouseDrawCursor
Definition: imgui.h:839
IMGUI_API bool RadioButton(const char *label, bool active)
Definition: imgui.cpp:7490
IMGUI_API ImVec2 GetCursorPos()
Definition: imgui.cpp:5322
IMGUI_API bool BeginPopupContextItem(const char *str_id, int mouse_button=1)
Definition: imgui.cpp:3679
IMGUI_API void SetScrollFromPosY(float pos_y, float center_y_ratio=0.5f)
Definition: imgui.cpp:5416
IMGUI_API float GetFontSize()
Definition: imgui.cpp:5302
IMGUI_API void AddCircle(const ImVec2 &centre, float radius, ImU32 col, int num_segments=12, float thickness=1.0f)
Definition: imgui_draw.cpp:902
ImGuiTextBuffer Buf
IMGUI_API void AddRectFilledMultiColor(const ImVec2 &a, const ImVec2 &b, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left)
Definition: imgui_draw.cpp:841
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, 0), const ImVec4 &tint_col=ImVec4(1, 1, 1, 1))
Definition: imgui.cpp:5888
float U1
Definition: imgui.h:1355
IMGUI_API void ProgressBar(float fraction, const ImVec2 &size_arg=ImVec2(-1, 0), const char *overlay=NULL)
Definition: imgui.cpp:7392
int TextEditCallback(ImGuiTextEditCallbackData *data)
ImVec2 MousePos
Definition: imgui.h:836
IMGUI_API void PopClipRect()
Definition: imgui_draw.cpp:259
IMGUI_API void DeleteChars(int pos, int bytes_count)
Definition: imgui.cpp:7719
IMGUI_API bool InputTextMultiline(const char *label, char *buf, size_t buf_size, const ImVec2 &size=ImVec2(0, 0), ImGuiInputTextFlags flags=0, ImGuiTextEditCallback callback=NULL, void *user_data=NULL)
Definition: imgui.cpp:8402
IMGUI_API bool InputInt3(const char *label, int v[3], ImGuiInputTextFlags extra_flags=0)
Definition: imgui.cpp:8563
Definition: imgui.h:96
int TexHeight
Definition: imgui.h:1452
IMGUI_API bool IsMouseClicked(int button, bool repeat=false)
Definition: imgui.cpp:3252
IMGUI_API bool IsItemClicked(int mouse_button=0)
Definition: imgui.cpp:3369
IMGUI_API bool IsKeyPressed(int user_key_index, bool repeat=true)
Definition: imgui.cpp:3222
float CurveTessellationTol
Definition: imgui.h:769
IMGUI_API void PopTextWrapPos()
Definition: imgui.cpp:4819
ImVec2 DisplaySize
Definition: imgui.h:783
float V1
Definition: imgui.h:1355
IMGUI_API const ImFontGlyph * FindGlyph(ImWchar c) const
IMGUI_API void AddBezierCurve(const ImVec2 &pos0, const ImVec2 &cp0, const ImVec2 &cp1, const ImVec2 &pos1, ImU32 col, float thickness, int num_segments=0)
Definition: imgui_draw.cpp:922
char Name[32]
Definition: imgui.h:1344
ImVector< ImFontGlyph > Glyphs
Definition: imgui.h:1468
ImVec2 ItemSpacing
Definition: imgui.h:755
IMGUI_API ImVec2 GetItemRectMin()
Definition: imgui.cpp:3400
IMGUI_API bool IsItemActive()
Definition: imgui.cpp:3358
IMGUI_API bool ColorPicker4(const char *label, float col[4], ImGuiColorEditFlags flags=0, const float *ref_col=NULL)
Definition: imgui.cpp:9601
IMGUI_API void append(const char *fmt,...) IM_FMTARGS(2)
Definition: imgui.cpp:1633
#define IM_FMTARGS(FMT)
Definition: imgui.h:38
IMGUI_API ImVec2 GetMouseDragDelta(int button=0, float lock_threshold=-1.0f)
Definition: imgui.cpp:3318
int ImGuiTreeNodeFlags
Definition: imgui.h:83
IMGUI_API void EndTooltip()
Definition: imgui.cpp:3472
IMGUI_API bool InputInt4(const char *label, int v[4], ImGuiInputTextFlags extra_flags=0)
Definition: imgui.cpp:8568
IMGUI_API void LogButtons()
Definition: imgui.cpp:6004
int ImGuiColorEditFlags
Definition: imgui.h:76
int size() const
Definition: imgui.h:1006
ImVec2 ItemInnerSpacing
Definition: imgui.h:756
float Descent
Definition: imgui.h:1479
IMGUI_API void SetScrollHere(float center_y_ratio=0.5f)
Definition: imgui.cpp:5428
IMGUI_API void PopAllowKeyboardFocus()
Definition: imgui.cpp:4797
IMGUI_API bool SmallButton(const char *label)
Definition: imgui.cpp:5804
IMGUI_API bool IsMouseHoveringRect(const ImVec2 &r_min, const ImVec2 &r_max, bool clip=true)
Definition: imgui.cpp:3162
IMGUI_API bool BeginChild(const char *str_id, const ImVec2 &size=ImVec2(0, 0), bool border=false, ImGuiWindowFlags extra_flags=0)
Definition: imgui.cpp:3736
IMGUI_API void ShowMetricsWindow(bool *p_open=NULL)
Definition: imgui.cpp:10557
IMGUI_API bool Draw(const char *label="Filter (inc,-exc)", float width=0.0f)
Definition: imgui.cpp:1520
IMGUI_API void BeginTooltip()
Definition: imgui.cpp:3467
IMGUI_API bool TreeNodeEx(const char *label, ImGuiTreeNodeFlags flags=0)
Definition: imgui.cpp:6217
float KeysDownDuration[512]
Definition: imgui.h:881
const ImFontGlyph * FallbackGlyph
Definition: imgui.h:1471
IMGUI_API void Indent(float indent_w=0.0f)
Definition: imgui.cpp:10370
IMGUI_API void AddTriangleFilled(const ImVec2 &a, const ImVec2 &b, const ImVec2 &c, ImU32 col)
Definition: imgui_draw.cpp:891
ImGuiTextFilter Filter
IMGUI_API void PushTextWrapPos(float wrap_pos_x=0.0f)
Definition: imgui.cpp:4812
IMGUI_API float GetColumnOffset(int column_index=-1)
Definition: imgui.cpp:10162
IMGUI_API void AddLine(const ImVec2 &a, const ImVec2 &b, ImU32 col, float thickness=1.0f)
Definition: imgui_draw.cpp:807
IMGUI_API void PushClipRect(ImVec2 clip_rect_min, ImVec2 clip_rect_max, bool intersect_with_current_clip_rect=false)
Definition: imgui_draw.cpp:235
float FrameRounding
Definition: imgui.h:754
const char * end() const
Definition: imgui.h:1005
bool WantCaptureKeyboard
Definition: imgui.h:857
IMGUI_API bool InputText(const char *label, char *buf, size_t buf_size, ImGuiInputTextFlags flags=0, ImGuiTextEditCallback callback=NULL, void *user_data=NULL)
Definition: imgui.cpp:8396
bool empty() const
Definition: imgui.h:908
ImVector< ImFont * > Fonts
Definition: imgui.h:1454
int MetricsTotalSurface
Definition: imgui.h:1480
IMGUI_API ImVec2 GetItemRectSize()
Definition: imgui.cpp:3412
IMGUI_API float GetWindowWidth()
Definition: imgui.cpp:5020
IMGUI_API bool TreeNode(const char *label)
Definition: imgui.cpp:6294
iterator begin()
Definition: imgui.h:916
IMGUI_API bool ColorEdit4(const char *label, float col[4], ImGuiColorEditFlags flags=0)
Definition: imgui.cpp:9374
IMGUI_API bool BeginMenuBar()
Definition: imgui.cpp:8992
IMGUI_API void AlignFirstTextHeightToWidgets()
Definition: imgui.cpp:5627
float DeltaTime
Definition: imgui.h:784
bool WantCaptureMouse
Definition: imgui.h:856
IMGUI_API 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), int stride=sizeof(float))
Definition: imgui.cpp:7380
IMGUI_API ImVec2 GetMousePos()
Definition: imgui.cpp:3295
IMGUI_API void Bullet()
Definition: imgui.cpp:6368
IMGUI_API bool InputFloat3(const char *label, float v[3], int decimal_precision=-1, ImGuiInputTextFlags extra_flags=0)
Definition: imgui.cpp:8520
unsigned short ImWchar
Definition: imgui.h:71
IMGUI_API bool PassFilter(const char *text, const char *text_end=NULL) const
Definition: imgui.cpp:1567
void AddLog(const char *fmt,...) IM_FMTARGS(2)
IMGUI_API bool BeginPopup(const char *str_id)
Definition: imgui.cpp:3610
IMGUI_API void SameLine(float pos_x=0.0f, float spacing_w=-1.0f)
Definition: imgui.cpp:10051
void pop_back()
Definition: imgui.h:942
IMGUI_API void SetMouseCursor(ImGuiMouseCursor type)
Definition: imgui.cpp:3343
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)
Definition: imgui.cpp:6904
IMGUI_API ImVec2 GetContentRegionAvail()
Definition: imgui.cpp:5243
int Size
Definition: imgui.h:897
IMGUI_API void CaptureKeyboardFromApp(bool capture=true)
Definition: imgui.cpp:3348
ImGuiInputTextFlags EventFlag
Definition: imgui.h:1063
IMGUI_API float GetScrollMaxY()
Definition: imgui.cpp:5396
IMGUI_API ImDrawList * GetWindowDrawList()
Definition: imgui.cpp:5291
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:3988
#define IM_ASSERT(_EXPR)
Definition: imgui.h:30
IMGUI_API bool InputInt2(const char *label, int v[2], ImGuiInputTextFlags extra_flags=0)
Definition: imgui.cpp:8558
int ImGuiWindowFlags
Definition: imgui.h:78
void Draw(const char *title, bool *p_open)
IMGUI_API void PopStyleVar(int count=1)
Definition: imgui.cpp:4916
float FontSize
Definition: imgui.h:1465
ImVector< const char * > Commands
float Alpha
Definition: imgui.h:747
IMGUI_API bool CollapsingHeader(const char *label, ImGuiTreeNodeFlags flags=0)
Definition: imgui.cpp:6185
IMGUI_API void AddTriangle(const ImVec2 &a, const ImVec2 &b, const ImVec2 &c, ImU32 col, float thickness=1.0f)
Definition: imgui_draw.cpp:880
IMGUI_API bool BeginPopupContextWindow(const char *str_id=NULL, int mouse_button=1, bool also_over_items=true)
Definition: imgui.cpp:3686
IMGUI_API bool ListBoxHeader(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui.cpp:8838
IMGUI_API void Dummy(const ImVec2 &size)
Definition: imgui.cpp:9959
IMGUI_API void BulletText(const char *fmt,...) IM_FMTARGS(1)
Definition: imgui.cpp:6415
float w
Definition: imgui.h:108
IMGUI_API const char * GetStyleColorName(ImGuiCol idx)
Definition: imgui.cpp:4931
IMGUI_API bool IsMouseDragging(int button=0, float lock_threshold=-1.0f)
Definition: imgui.cpp:3284
int DisplayStart
Definition: imgui.h:1155
float X0
Definition: imgui.h:1354
IMGUI_API bool Step()
Definition: imgui.cpp:1732
int TexWidth
Definition: imgui.h:1451
IMGUI_API void TextUnformatted(const char *text, const char *text_end=NULL)
Definition: imgui.cpp:5520
IMGUI_API bool DragFloat4(const char *label, float v[4], float v_speed=1.0f, float v_min=0.0f, float v_max=0.0f, const char *display_format="%.3f", float power=1.0f)
Definition: imgui.cpp:7137
float MouseDownDuration[5]
Definition: imgui.h:878
IMGUI_API void SetNextWindowContentWidth(float width)
Definition: imgui.cpp:5213
static char * Strdup(const char *str)
IMGUI_API void Unindent(float indent_w=0.0f)
Definition: imgui.cpp:10378
#define IM_COL32(R, G, B, A)
Definition: imgui.h:1112
IMGUI_API bool SliderAngle(const char *label, float *v_rad, float v_degrees_min=-360.0f, float v_degrees_max=+360.0f)
Definition: imgui.cpp:6848
IMGUI_API bool ColorEdit3(const char *label, float col[3], ImGuiColorEditFlags flags=0)
Definition: imgui.cpp:9280
IMGUI_API void AddText(const ImVec2 &pos, ImU32 col, const char *text_begin, const char *text_end=NULL)
Definition: imgui_draw.cpp:962
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)
Definition: imgui.cpp:6909
float GrabMinSize
Definition: imgui.h:762
IMGUI_API ImGuiIO & GetIO()
Definition: imgui.cpp:2144
ImVector< char * > Items
IMGUI_API bool DragInt4(const char *label, int v[4], float v_speed=1.0f, int v_min=0, int v_max=0, const char *display_format="%.0f")
Definition: imgui.cpp:7215
IMGUI_API bool InputFloat2(const char *label, float v[2], int decimal_precision=-1, ImGuiInputTextFlags extra_flags=0)
Definition: imgui.cpp:8515
IMGUI_API bool IsRootWindowOrAnyChildFocused()
Definition: imgui.cpp:5008
float z
Definition: imgui.h:108
IMGUI_API bool InputFloat4(const char *label, float v[4], int decimal_precision=-1, ImGuiInputTextFlags extra_flags=0)
Definition: imgui.cpp:8525
IMGUI_API ImFont * GetFont()
Definition: imgui.cpp:5297
IMGUI_API void EndGroup()
Definition: imgui.cpp:10006
IMGUI_API float GetTime()
Definition: imgui.cpp:2160
static int Strnicmp(const char *str1, const char *str2, int n)
bool KeysDown[512]
Definition: imgui.h:844
IMGUI_API int GetColumnIndex()
Definition: imgui.cpp:10123
IMGUI_API bool IsKeyReleased(int user_key_index)
Definition: imgui.cpp:3235
IMGUI_API void Spacing()
Definition: imgui.cpp:9951
IMGUI_API void SetNextWindowSizeConstraints(const ImVec2 &size_min, const ImVec2 &size_max, ImGuiSizeConstraintCallback custom_callback=NULL, void *custom_callback_data=NULL)
Definition: imgui.cpp:5197
IMGUI_API bool InputFloat(const char *label, float *v, float step=0.0f, float step_fast=0.0f, int decimal_precision=-1, ImGuiInputTextFlags extra_flags=0)
Definition: imgui.cpp:8470
IMGUI_API void ShowTestWindow(bool *p_open=NULL)
Definition: imgui_demo.cpp:124
float ScrollbarRounding
Definition: imgui.h:761
IMGUI_API void ShowStyleEditor(ImGuiStyle *ref=NULL)
IMGUI_API float GetContentRegionAvailWidth()
Definition: imgui.cpp:5249
#define IMGUI_VERSION
Definition: imgui.h:20
bool KeyShift
Definition: imgui.h:841
IMGUI_API void PushItemWidth(float item_width)
Definition: imgui.cpp:4698
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui.cpp:5798
IMGUI_API float GetItemsLineHeightWithSpacing()
Definition: imgui.cpp:5285
IMGUI_API void Separator()
Definition: imgui.cpp:9885
#define IM_NEWLINE
Definition: imgui_demo.cpp:63
IMGUI_API void End()
Definition: imgui.cpp:4537
void clear()
Definition: imgui.h:915
Definition: imgui.h:106
IMGUI_API void BeginGroup()
Definition: imgui.cpp:9983
IMGUI_API bool DragFloatRange2(const char *label, float *v_current_min, float *v_current_max, float v_speed=1.0f, float v_min=0.0f, float v_max=0.0f, const char *display_format="%.3f", const char *display_format_max=NULL, float power=1.0f)
Definition: imgui.cpp:7142
IMGUI_API bool SliderFloat4(const char *label, float v[4], float v_min, float v_max, const char *display_format="%.3f", float power=1.0f)
Definition: imgui.cpp:6914
IMGUI_API void AddCircleFilled(const ImVec2 &centre, float radius, ImU32 col, int num_segments=12)
Definition: imgui_draw.cpp:912
IMGUI_API float GetScrollX()
Definition: imgui.cpp:5380
ImTextureID TexID
Definition: imgui.h:1443
bool MouseDown[5]
Definition: imgui.h:837
IMGUI_API bool SliderInt4(const char *label, int v[4], int v_min, int v_max, const char *display_format="%.0f")
Definition: imgui.cpp:6956
IMGUI_API bool DragFloat(const char *label, float *v, float v_speed=1.0f, float v_min=0.0f, float v_max=0.0f, const char *display_format="%.3f", float power=1.0f)
Definition: imgui.cpp:7041
IMGUI_API float GetColumnWidth(int column_index=-1)
Definition: imgui.cpp:10208
#define IM_MAX(_A, _B)
Definition: imgui_demo.cpp:67
IMGUI_API void EndPopup()
Definition: imgui.cpp:3661
IMGUI_API void appendv(const char *fmt, va_list args) IM_FMTLIST(2)
Definition: imgui.cpp:1612
IMGUI_API float GetTreeNodeToLabelSpacing()
Definition: imgui.cpp:6309
bool KeyCtrl
Definition: imgui.h:840
bool AntiAliasedShapes
Definition: imgui.h:768
IMGUI_API void NextColumn()
Definition: imgui.cpp:10090
IMGUI_API bool ColorButton(const char *desc_id, const ImVec4 &col, ImGuiColorEditFlags flags=0, ImVec2 size=ImVec2(0, 0))
Definition: imgui.cpp:9232
float x
Definition: imgui.h:108
float IndentSpacing
Definition: imgui.h:758
IMGUI_API bool DragFloat2(const char *label, float v[2], float v_speed=1.0f, float v_min=0.0f, float v_max=0.0f, const char *display_format="%.3f", float power=1.0f)
Definition: imgui.cpp:7127
IMGUI_API bool BeginMainMenuBar()
Definition: imgui.cpp:8967
IMGUI_API void PushFont(ImFont *font)
Definition: imgui.cpp:4757
IMGUI_API void SetNextWindowPos(const ImVec2 &pos, ImGuiCond cond=0, const ImVec2 &pivot=ImVec2(0, 0))
Definition: imgui.cpp:5175
IMGUI_API bool InvisibleButton(const char *str_id, const ImVec2 &size)
Definition: imgui.cpp:5816
float y
Definition: imgui.h:98
IMGUI_API void EndChild()
Definition: imgui.cpp:3747
IMGUI_API float GetWindowContentRegionWidth()
Definition: imgui.cpp:5267
IMGUI_API float GetScrollMaxX()
Definition: imgui.cpp:5390
ImVec2 FramePadding
Definition: imgui.h:753
bool IsActive() const
Definition: imgui.h:993
IMGUI_API bool BeginMenu(const char *label, bool enabled=true)
Definition: imgui.cpp:9029
IMGUI_API void TextWrapped(const char *fmt,...) IM_FMTARGS(1)
Definition: imgui.cpp:5512
IMGUI_API void ListBoxFooter()
Definition: imgui.cpp:8879
IMGUI_API void TextColored(const ImVec4 &col, const char *fmt,...) IM_FMTARGS(2)
Definition: imgui.cpp:5481
ImVec4 Colors[ImGuiCol_COUNT]
Definition: imgui.h:770
IMGUI_API void Text(const char *fmt,...) IM_FMTARGS(1)
Definition: imgui.cpp:5466
IMGUI_API void LogToTTY(int max_depth=-1)
Definition: imgui.cpp:5924
float GrabRounding
Definition: imgui.h:763
IMGUI_API ImVec2 GetCursorScreenPos()
Definition: imgui.cpp:5367
bool KeySuper
Definition: imgui.h:843
IMGUI_API bool SliderInt3(const char *label, int v[3], int v_min, int v_max, const char *display_format="%.0f")
Definition: imgui.cpp:6951
IMGUI_API void RenderChar(ImDrawList *draw_list, float size, ImVec2 pos, ImU32 col, unsigned short c) const
IMGUI_API bool SliderInt(const char *label, int *v, int v_min, int v_max, const char *display_format="%.0f")
Definition: imgui.cpp:6856
void push_back(const value_type &v)
Definition: imgui.h:941
IMGUI_API void PopItemWidth()
Definition: imgui.cpp:4719
static int Stricmp(const char *str1, const char *str2)
IMGUI_API void TreePop()
Definition: imgui.cpp:10410
iterator erase(const_iterator it)
Definition: imgui.h:944
int OversampleV
Definition: imgui.h:1334
float U0
Definition: imgui.h:1355
bool AntiAliasedLines
Definition: imgui.h:767
IMGUI_API void LogText(const char *fmt,...) IM_FMTARGS(1)
Definition: imgui.cpp:2850
Definition: imgui.h:1462
void ExecCommand(const char *command_line)
IMGUI_API float GetTextLineHeight()
Definition: imgui.cpp:5273
IMGUI_API bool SliderInt2(const char *label, int v[2], int v_min, int v_max, const char *display_format="%.0f")
Definition: imgui.cpp:6946
IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col)
Definition: imgui.cpp:4827
IMGUI_API void LabelText(const char *label, const char *fmt,...) IM_FMTARGS(2)
Definition: imgui.cpp:5665
IMGUI_API bool MenuItem(const char *label, const char *shortcut=NULL, bool selected=false, bool enabled=true)
Definition: imgui.cpp:8929
ImWchar FallbackChar
Definition: imgui.h:1473
int OversampleH
Definition: imgui.h:1334
IMGUI_API bool BeginPopupModal(const char *name, bool *p_open=NULL, ImGuiWindowFlags extra_flags=0)
Definition: imgui.cpp:3633
IMGUI_API bool Selectable(const char *label, bool selected=false, ImGuiSelectableFlags flags=0, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui.cpp:8748
static int TextEditCallbackStub(ImGuiTextEditCallbackData *data)
Definition: imgui.h:777
bool WantTextInput
Definition: imgui.h:858
IMGUI_API bool Checkbox(const char *label, bool *v)
Definition: imgui.cpp:7427
float Ascent
Definition: imgui.h:1479
bool PixelSnapH
Definition: imgui.h:1335
ImVec2 WindowTitleAlign
Definition: imgui.h:751
IMGUI_API bool VSliderInt(const char *label, const ImVec2 &size, int *v, int v_min, int v_max, const char *display_format="%.0f")
Definition: imgui.cpp:6866
ImVec2 MouseDelta
Definition: imgui.h:865
IMGUI_API ImVec2 GetItemRectMax()
Definition: imgui.cpp:3406
IMGUI_API float GetScrollY()
Definition: imgui.cpp:5385
IMGUI_API void LogToClipboard(int max_depth=-1)
Definition: imgui.cpp:5966
const char * begin() const
Definition: imgui.h:1004
IMGUI_API void EndMenuBar()
Definition: imgui.cpp:9012
void clear()
Definition: imgui.h:1008
ImVec2 ButtonTextAlign
Definition: imgui.h:764
IMGUI_API const char * GetVersion()
Definition: imgui.cpp:2104
float MouseWheel
Definition: imgui.h:838
IMGUI_API void PushID(const char *str_id)
Definition: imgui.cpp:6322
bool WantMoveMouse
Definition: imgui.h:859
IMGUI_API bool DragIntRange2(const char *label, int *v_current_min, int *v_current_max, float v_speed=1.0f, int v_min=0, int v_max=0, const char *display_format="%.0f", const char *display_format_max=NULL)
Definition: imgui.cpp:7220
IMGUI_API ImGuiID GetID(const char *str_id)
Definition: imgui.cpp:6353
bool KeyAlt
Definition: imgui.h:842
ImVector< int > LineOffsets
IMGUI_API void PushAllowKeyboardFocus(bool allow_keyboard_focus)
Definition: imgui.cpp:4792
float Y0
Definition: imgui.h:1354
IMGUI_API bool ListBox(const char *label, int *current_item, const char *const *items, int items_count, int height_in_items=-1)
Definition: imgui.cpp:8895
ImVec2 TouchExtraPadding
Definition: imgui.h:757
IMGUI_API bool DragInt2(const char *label, int v[2], float v_speed=1.0f, int v_min=0, int v_max=0, const char *display_format="%.0f")
Definition: imgui.cpp:7205
IMGUI_API ImGuiStyle & GetStyle()
Definition: imgui.cpp:2149
int ImGuiCol
Definition: imgui.h:73
IMGUI_API bool Combo(const char *label, int *current_item, const char *const *items, int items_count, int height_in_items=-1)
Definition: imgui.cpp:8602
IMGUI_API void CloseCurrentPopup()
Definition: imgui.cpp:3563
IMGUI_API void PushClipRectFullScreen()
Definition: imgui_draw.cpp:253
IMGUI_API void OpenPopup(const char *str_id)
Definition: imgui.cpp:3497
float Y1
Definition: imgui.h:1354
void AddLog(const char *fmt,...) IM_FMTARGS(2)
IMGUI_API bool DragInt3(const char *label, int v[3], float v_speed=1.0f, int v_min=0, int v_max=0, const char *display_format="%.0f")
Definition: imgui.cpp:7210
IMGUI_API bool DragFloat3(const char *label, float v[3], float v_speed=1.0f, float v_min=0.0f, float v_max=0.0f, const char *display_format="%.3f", float power=1.0f)
Definition: imgui.cpp:7132
IMGUI_API bool SliderFloat(const char *label, float *v, float v_min, float v_max, const char *display_format="%.3f", float power=1.0f)
Definition: imgui.cpp:6747
float X1
Definition: imgui.h:1354
IMGUI_API void AddRectFilled(const ImVec2 &a, const ImVec2 &b, ImU32 col, float rounding=0.0f, int rounding_corners_flags=~0)
Definition: imgui_draw.cpp:825
IMGUI_API void AddRect(const ImVec2 &a, const ImVec2 &b, ImU32 col, float rounding=0.0f, int rounding_corners_flags=~0, float thickness=1.0f)
Definition: imgui_draw.cpp:817
float Scale
Definition: imgui.h:1466
IMGUI_API void TextDisabled(const char *fmt,...) IM_FMTARGS(1)
Definition: imgui.cpp:5496
float V0
Definition: imgui.h:1355
IMGUI_API void ShowUserGuide()
Definition: imgui_demo.cpp:101
ImFontConfig * ConfigData
Definition: imgui.h:1477
IMGUI_API void Columns(int count=1, const char *id=NULL, bool border=true)
Definition: imgui.cpp:10356
IMGUI_API void SetWindowFontScale(float scale)
Definition: imgui.cpp:5312
#define IM_ARRAYSIZE(_ARR)
Definition: imgui_demo.cpp:66
IMGUI_API void InsertChars(int pos, const char *text, const char *text_end=NULL)
Definition: imgui.cpp:7737
IMGUI_API bool DragInt(const char *label, int *v, float v_speed=1.0f, int v_min=0, int v_max=0, const char *display_format="%.0f")
Definition: imgui.cpp:7168
IMGUI_API bool IsMouseDoubleClicked(int button)
Definition: imgui.cpp:3277
ImFontAtlas * Fonts
Definition: imgui.h:796
ImFont * FontDefault
Definition: imgui.h:799
IMGUI_API bool IsAnyItemActive()
Definition: imgui.cpp:3379
float ChildWindowRounding
Definition: imgui.h:752
ImVec2 WindowPadding
Definition: imgui.h:748
IMGUI_API void EndMenu()
Definition: imgui.cpp:9139
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float &out_r, float &out_g, float &out_b)
Definition: imgui.cpp:1279
IMGUI_API void PopID()
Definition: imgui.cpp:6347
float WindowRounding
Definition: imgui.h:750
short ConfigDataCount
Definition: imgui.h:1476
IMGUI_API 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), int stride=sizeof(float))
Definition: imgui.cpp:7369
IMGUI_API void SetColorEditOptions(ImGuiColorEditFlags flags)
Definition: imgui.cpp:9214
IMGUI_API bool IsItemHovered()
Definition: imgui.cpp:1968
IMGUI_API void SetKeyboardFocusHere(int offset=0)
Definition: imgui.cpp:5436
float ScrollbarSize
Definition: imgui.h:760
void * ImTextureID
Definition: imgui.h:72
IMGUI_API void LogFinish()
Definition: imgui.cpp:5980
static ImColor HSV(float h, float s, float v, float a=1.0f)
Definition: imgui.h:1135
float AdvanceX
Definition: imgui.h:1353
IMGUI_API void SetScrollX(float scroll_x)
Definition: imgui.cpp:5402
IMGUI_API void PopFont()
Definition: imgui.cpp:4767
float y
Definition: imgui.h:108
void Draw(const char *title, bool *p_open=NULL)
float x
Definition: imgui.h:98
IMGUI_API bool InputInt(const char *label, int *v, int step=1, int step_fast=100, ImGuiInputTextFlags extra_flags=0)
Definition: imgui.cpp:8480
IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul=1.0f)
Definition: imgui.cpp:1223
IMGUI_API void PopStyleColor(int count=1)
Definition: imgui.cpp:4847
IMGUI_API void EndMainMenuBar()
Definition: imgui.cpp:8985
IMGUI_API bool VSliderFloat(const char *label, const ImVec2 &size, float *v, float v_min, float v_max, const char *display_format="%.3f", float power=1.0f)
Definition: imgui.cpp:6805
IMGUI_API void NewLine()
Definition: imgui.cpp:10074
IMGUI_API ImVec2 CalcItemRectClosestPoint(const ImVec2 &pos, bool on_edge=false, float outward=+0.0f)
Definition: imgui.cpp:3418
IMGUI_API void SetWindowSize(const ImVec2 &size, ImGuiCond cond=0)
Definition: imgui.cpp:5110