imgui_demo.cpp
Go to the documentation of this file.
1 // dear imgui, v1.67 WIP
2 // (demo code)
3 
4 // Message to the person tempted to delete this file when integrating Dear ImGui into their code base:
5 // Do NOT remove this file from your project! Think again! It is the most useful reference code that you and other coders
6 // will want to refer to and call. Have the ImGui::ShowDemoWindow() function wired in an always-available debug menu of
7 // your game/app! Removing this file from your project is hindering access to documentation for everyone in your team,
8 // likely leading you to poorer usage of the library.
9 // Everything in this file will be stripped out by the linker if you don't call ImGui::ShowDemoWindow().
10 // If you want to link core Dear ImGui in your shipped builds but want an easy guarantee that the demo will not be linked,
11 // you can setup your imconfig.h with #define IMGUI_DISABLE_DEMO_WINDOWS and those functions will be empty.
12 // In other situation, whenever you have Dear ImGui available you probably want this to be available for reference.
13 // Thank you,
14 // -Your beloved friend, imgui_demo.cpp (that you won't delete)
15 
16 // Message to beginner C/C++ programmers about the meaning of the 'static' keyword:
17 // In this demo code, we frequently we use 'static' variables inside functions. A static variable persist across calls, so it is
18 // essentially like a global variable but declared inside the scope of the function. We do this as a way to gather code and data
19 // in the same place, to make the demo source code faster to read, faster to write, and smaller in size.
20 // 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
21 // or used in threads. This might be a pattern you will want to use in your code, but most of the real data you would be editing is
22 // likely going to be stored outside your functions.
23 
24 /*
25 
26 Index of this file:
27 
28 // [SECTION] Forward Declarations, Helpers
29 // [SECTION] Demo Window / ShowDemoWindow()
30 // [SECTION] About Window / ShowAboutWindow()
31 // [SECTION] Style Editor / ShowStyleEditor()
32 // [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar()
33 // [SECTION] Example App: Debug Console / ShowExampleAppConsole()
34 // [SECTION] Example App: Debug Log / ShowExampleAppLog()
35 // [SECTION] Example App: Simple Layout / ShowExampleAppLayout()
36 // [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor()
37 // [SECTION] Example App: Long Text / ShowExampleAppLongText()
38 // [SECTION] Example App: Auto Resize / ShowExampleAppAutoResize()
39 // [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize()
40 // [SECTION] Example App: Simple Overlay / ShowExampleAppSimpleOverlay()
41 // [SECTION] Example App: Manipulating Window Titles / ShowExampleAppWindowTitles()
42 // [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
43 // [SECTION] Example App: Documents Handling / ShowExampleAppDocuments()
44 
45 */
46 
47 #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
48 #define _CRT_SECURE_NO_WARNINGS
49 #endif
50 
51 #include "imgui.h"
52 #include <ctype.h> // toupper, isprint
53 #include <limits.h> // INT_MIN, INT_MAX
54 #include <math.h> // sqrtf, powf, cosf, sinf, floorf, ceilf
55 #include <stdio.h> // vsnprintf, sscanf, printf
56 #include <stdlib.h> // NULL, malloc, free, atoi
57 #if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
58 #include <stddef.h> // intptr_t
59 #else
60 #include <stdint.h> // intptr_t
61 #endif
62 
63 #ifdef _MSC_VER
64 #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
65 #define vsnprintf _vsnprintf
66 #endif
67 #ifdef __clang__
68 #pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
69 #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)
70 #pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int'
71 #pragma clang diagnostic ignored "-Wformat-security" // warning : warning: format string is not a string literal
72 #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.
73 #if __has_warning("-Wreserved-id-macro")
74 #pragma clang diagnostic ignored "-Wreserved-id-macro" // warning : macro name is a reserved identifier //
75 #endif
76 #elif defined(__GNUC__)
77 #pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
78 #pragma GCC diagnostic ignored "-Wformat-security" // warning : format string is not a string literal (potentially insecure)
79 #pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
80 #pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
81 #if (__GNUC__ >= 6)
82 #pragma GCC diagnostic ignored "-Wmisleading-indentation" // warning: this 'if' clause does not guard this statement // GCC 6.0+ only. See #883 on GitHub.
83 #endif
84 #endif
85 
86 // Play it nice with Windows users. Notepad in 2017 still doesn't display text data with Unix-style \n.
87 #ifdef _WIN32
88 #define IM_NEWLINE "\r\n"
89 #else
90 #define IM_NEWLINE "\n"
91 #endif
92 
93 #define IM_MAX(_A,_B) (((_A) >= (_B)) ? (_A) : (_B))
94 
95 //-----------------------------------------------------------------------------
96 // [SECTION] Forward Declarations, Helpers
97 //-----------------------------------------------------------------------------
98 
99 #if !defined(IMGUI_DISABLE_OBSOLETE_FUNCTIONS) && defined(IMGUI_DISABLE_TEST_WINDOWS) && !defined(IMGUI_DISABLE_DEMO_WINDOWS) // Obsolete name since 1.53, TEST->DEMO
100 #define IMGUI_DISABLE_DEMO_WINDOWS
101 #endif
102 
103 #if !defined(IMGUI_DISABLE_DEMO_WINDOWS)
104 
105 // Forward Declarations
106 static void ShowExampleAppDocuments(bool* p_open);
107 static void ShowExampleAppMainMenuBar();
108 static void ShowExampleAppConsole(bool* p_open);
109 static void ShowExampleAppLog(bool* p_open);
110 static void ShowExampleAppLayout(bool* p_open);
111 static void ShowExampleAppPropertyEditor(bool* p_open);
112 static void ShowExampleAppLongText(bool* p_open);
113 static void ShowExampleAppAutoResize(bool* p_open);
114 static void ShowExampleAppConstrainedResize(bool* p_open);
115 static void ShowExampleAppSimpleOverlay(bool* p_open);
116 static void ShowExampleAppWindowTitles(bool* p_open);
117 static void ShowExampleAppCustomRendering(bool* p_open);
118 static void ShowExampleMenuFile();
119 
120 // Helper to display a little (?) mark which shows a tooltip when hovered.
121 static void ShowHelpMarker(const char* desc)
122 {
123  ImGui::TextDisabled("(?)");
124  if (ImGui::IsItemHovered())
125  {
131  }
132 }
133 
134 // Helper to display basic user controls.
136 {
137  ImGui::BulletText("Double-click on title bar to collapse window.");
138  ImGui::BulletText("Click and drag on lower right corner to resize window\n(double-click to auto fit window to its contents).");
139  ImGui::BulletText("Click and drag on any empty space to move window.");
140  ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
141  ImGui::BulletText("CTRL+Click on a slider or drag box to input value as text.");
142  if (ImGui::GetIO().FontAllowUserScaling)
143  ImGui::BulletText("CTRL+Mouse Wheel to zoom window contents.");
144  ImGui::BulletText("Mouse Wheel to scroll.");
145  ImGui::BulletText("While editing text:\n");
146  ImGui::Indent();
147  ImGui::BulletText("Hold SHIFT or use mouse to select text.");
148  ImGui::BulletText("CTRL+Left/Right to word jump.");
149  ImGui::BulletText("CTRL+A or double-click to select all.");
150  ImGui::BulletText("CTRL+X,CTRL+C,CTRL+V to use clipboard.");
151  ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo.");
152  ImGui::BulletText("ESCAPE to revert.");
153  ImGui::BulletText("You can apply arithmetic operators +,*,/ on numerical values.\nUse +- to subtract.");
154  ImGui::Unindent();
155 }
156 
157 //-----------------------------------------------------------------------------
158 // [SECTION] Demo Window / ShowDemoWindow()
159 //-----------------------------------------------------------------------------
160 
161 // We split the contents of the big ShowDemoWindow() function into smaller functions (because the link time of very large functions grow non-linearly)
162 static void ShowDemoWindowWidgets();
163 static void ShowDemoWindowLayout();
164 static void ShowDemoWindowPopups();
165 static void ShowDemoWindowColumns();
166 static void ShowDemoWindowMisc();
167 
168 // Demonstrate most Dear ImGui features (this is big function!)
169 // You may execute this function to experiment with the UI and understand what it does. You may then search for keywords in the code when you are interested by a specific feature.
170 void ImGui::ShowDemoWindow(bool* p_open)
171 {
172  // Examples Apps (accessible from the "Examples" menu)
173  static bool show_app_documents = false;
174  static bool show_app_main_menu_bar = false;
175  static bool show_app_console = false;
176  static bool show_app_log = false;
177  static bool show_app_layout = false;
178  static bool show_app_property_editor = false;
179  static bool show_app_long_text = false;
180  static bool show_app_auto_resize = false;
181  static bool show_app_constrained_resize = false;
182  static bool show_app_simple_overlay = false;
183  static bool show_app_window_titles = false;
184  static bool show_app_custom_rendering = false;
185 
186  if (show_app_documents) ShowExampleAppDocuments(&show_app_documents); // Process the Document app next, as it may also use a DockSpace()
187  if (show_app_main_menu_bar) ShowExampleAppMainMenuBar();
188  if (show_app_console) ShowExampleAppConsole(&show_app_console);
189  if (show_app_log) ShowExampleAppLog(&show_app_log);
190  if (show_app_layout) ShowExampleAppLayout(&show_app_layout);
191  if (show_app_property_editor) ShowExampleAppPropertyEditor(&show_app_property_editor);
192  if (show_app_long_text) ShowExampleAppLongText(&show_app_long_text);
193  if (show_app_auto_resize) ShowExampleAppAutoResize(&show_app_auto_resize);
194  if (show_app_constrained_resize) ShowExampleAppConstrainedResize(&show_app_constrained_resize);
195  if (show_app_simple_overlay) ShowExampleAppSimpleOverlay(&show_app_simple_overlay);
196  if (show_app_window_titles) ShowExampleAppWindowTitles(&show_app_window_titles);
197  if (show_app_custom_rendering) ShowExampleAppCustomRendering(&show_app_custom_rendering);
198 
199  // Dear ImGui Apps (accessible from the "Help" menu)
200  static bool show_app_metrics = false;
201  static bool show_app_style_editor = false;
202  static bool show_app_about = false;
203 
204  if (show_app_metrics) { ImGui::ShowMetricsWindow(&show_app_metrics); }
205  if (show_app_style_editor) { ImGui::Begin("Style Editor", &show_app_style_editor); ImGui::ShowStyleEditor(); ImGui::End(); }
206  if (show_app_about) { ImGui::ShowAboutWindow(&show_app_about); }
207 
208  // Demonstrate the various window flags. Typically you would just use the default!
209  static bool no_titlebar = false;
210  static bool no_scrollbar = false;
211  static bool no_menu = false;
212  static bool no_move = false;
213  static bool no_resize = false;
214  static bool no_collapse = false;
215  static bool no_close = false;
216  static bool no_nav = false;
217  static bool no_background = false;
218  static bool no_bring_to_front = false;
219 
220  ImGuiWindowFlags window_flags = 0;
221  if (no_titlebar) window_flags |= ImGuiWindowFlags_NoTitleBar;
222  if (no_scrollbar) window_flags |= ImGuiWindowFlags_NoScrollbar;
223  if (!no_menu) window_flags |= ImGuiWindowFlags_MenuBar;
224  if (no_move) window_flags |= ImGuiWindowFlags_NoMove;
225  if (no_resize) window_flags |= ImGuiWindowFlags_NoResize;
226  if (no_collapse) window_flags |= ImGuiWindowFlags_NoCollapse;
227  if (no_nav) window_flags |= ImGuiWindowFlags_NoNav;
228  if (no_background) window_flags |= ImGuiWindowFlags_NoBackground;
229  if (no_bring_to_front) window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus;
230  if (no_close) p_open = NULL; // Don't pass our bool* to Begin
231 
232  // We specify a default position/size in case there's no data in the .ini file. Typically this isn't required! We only do it to make the Demo applications a little more welcoming.
235 
236  // Main body of the Demo window starts here.
237  if (!ImGui::Begin("ImGui Demo", p_open, window_flags))
238  {
239  // Early out if the window is collapsed, as an optimization.
240  ImGui::End();
241  return;
242  }
243  ImGui::Text("dear imgui says hello. (%s)", IMGUI_VERSION);
244 
245  // Most "big" widgets share a common width settings by default.
246  //ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.65f); // Use 2/3 of the space for widgets and 1/3 for labels (default)
247  ImGui::PushItemWidth(ImGui::GetFontSize() * -12); // Use fixed width for labels (by passing a negative value), the rest goes to widgets. We choose a width proportional to our font size.
248 
249  // Menu
250  if (ImGui::BeginMenuBar())
251  {
252  if (ImGui::BeginMenu("Menu"))
253  {
255  ImGui::EndMenu();
256  }
257  if (ImGui::BeginMenu("Examples"))
258  {
259  ImGui::MenuItem("Main menu bar", NULL, &show_app_main_menu_bar);
260  ImGui::MenuItem("Console", NULL, &show_app_console);
261  ImGui::MenuItem("Log", NULL, &show_app_log);
262  ImGui::MenuItem("Simple layout", NULL, &show_app_layout);
263  ImGui::MenuItem("Property editor", NULL, &show_app_property_editor);
264  ImGui::MenuItem("Long text display", NULL, &show_app_long_text);
265  ImGui::MenuItem("Auto-resizing window", NULL, &show_app_auto_resize);
266  ImGui::MenuItem("Constrained-resizing window", NULL, &show_app_constrained_resize);
267  ImGui::MenuItem("Simple overlay", NULL, &show_app_simple_overlay);
268  ImGui::MenuItem("Manipulating window titles", NULL, &show_app_window_titles);
269  ImGui::MenuItem("Custom rendering", NULL, &show_app_custom_rendering);
270  ImGui::MenuItem("Documents", NULL, &show_app_documents);
271  ImGui::EndMenu();
272  }
273  if (ImGui::BeginMenu("Help"))
274  {
275  ImGui::MenuItem("Metrics", NULL, &show_app_metrics);
276  ImGui::MenuItem("Style Editor", NULL, &show_app_style_editor);
277  ImGui::MenuItem("About Dear ImGui", NULL, &show_app_about);
278  ImGui::EndMenu();
279  }
281  }
282 
283  ImGui::Spacing();
284  if (ImGui::CollapsingHeader("Help"))
285  {
286  ImGui::Text("PROGRAMMER GUIDE:");
287  ImGui::BulletText("Please see the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!");
288  ImGui::BulletText("Please see the comments in imgui.cpp.");
289  ImGui::BulletText("Please see the examples/ in application.");
290  ImGui::BulletText("Enable 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls.");
291  ImGui::BulletText("Enable 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.");
293 
294  ImGui::Text("USER GUIDE:");
296  }
297 
298  if (ImGui::CollapsingHeader("Configuration"))
299  {
300  ImGuiIO& io = ImGui::GetIO();
301 
302  if (ImGui::TreeNode("Configuration##2"))
303  {
304  ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
305  ImGui::CheckboxFlags("io.ConfigFlags: NavEnableGamepad", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad);
306  ImGui::SameLine(); ShowHelpMarker("Required back-end to feed in gamepad inputs in io.NavInputs[] and set io.BackendFlags |= ImGuiBackendFlags_HasGamepad.\n\nRead instructions in imgui.cpp for details.");
307  ImGui::CheckboxFlags("io.ConfigFlags: NavEnableSetMousePos", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableSetMousePos);
308  ImGui::SameLine(); ShowHelpMarker("Instruct navigation to move the mouse cursor. See comment for ImGuiConfigFlags_NavEnableSetMousePos.");
309  ImGui::CheckboxFlags("io.ConfigFlags: NoMouse", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NoMouse);
310  if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) // Create a way to restore this flag otherwise we could be stuck completely!
311  {
312  if (fmodf((float)ImGui::GetTime(), 0.40f) < 0.20f)
313  {
314  ImGui::SameLine();
315  ImGui::Text("<<PRESS SPACE TO DISABLE>>");
316  }
319  }
320  ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange);
321  ImGui::SameLine(); ShowHelpMarker("Instruct back-end to not alter mouse cursor shape and visibility.");
322  ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputTextCursorBlink);
323  ImGui::SameLine(); ShowHelpMarker("Set to false to disable blinking cursor, for users who consider it distracting");
324  ImGui::Checkbox("io.ConfigWindowsResizeFromEdges", &io.ConfigWindowsResizeFromEdges);
325  ImGui::SameLine(); ShowHelpMarker("Enable resizing of windows from their edges and from the lower-left corner.\nThis requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback.");
326  ImGui::Checkbox("io.ConfigWindowsMoveFromTitleBarOnly", &io.ConfigWindowsMoveFromTitleBarOnly);
327  ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor);
328  ImGui::SameLine(); ShowHelpMarker("Instruct Dear ImGui to render a mouse cursor for you. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something).");
329  ImGui::TreePop();
331  }
332 
333  if (ImGui::TreeNode("Backend Flags"))
334  {
335  ImGuiBackendFlags backend_flags = io.BackendFlags; // Make a local copy to avoid modifying the back-end flags.
336  ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasGamepad);
337  ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasMouseCursors);
338  ImGui::CheckboxFlags("io.BackendFlags: HasSetMousePos", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasSetMousePos);
339  ImGui::TreePop();
341  }
342 
343  if (ImGui::TreeNode("Style"))
344  {
346  ImGui::TreePop();
348  }
349 
350  if (ImGui::TreeNode("Capture/Logging"))
351  {
352  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.");
353  ShowHelpMarker("Try opening any of the contents below in this window and then click one of the \"Log To\" button.");
355  ImGui::TextWrapped("You can also call ImGui::LogText() to output directly to the log without a visual output.");
356  if (ImGui::Button("Copy \"Hello, world!\" to clipboard"))
357  {
359  ImGui::LogText("Hello, world!");
361  }
362  ImGui::TreePop();
363  }
364  }
365 
366  if (ImGui::CollapsingHeader("Window options"))
367  {
368  ImGui::Checkbox("No titlebar", &no_titlebar); ImGui::SameLine(150);
369  ImGui::Checkbox("No scrollbar", &no_scrollbar); ImGui::SameLine(300);
370  ImGui::Checkbox("No menu", &no_menu);
371  ImGui::Checkbox("No move", &no_move); ImGui::SameLine(150);
372  ImGui::Checkbox("No resize", &no_resize); ImGui::SameLine(300);
373  ImGui::Checkbox("No collapse", &no_collapse);
374  ImGui::Checkbox("No close", &no_close); ImGui::SameLine(150);
375  ImGui::Checkbox("No nav", &no_nav); ImGui::SameLine(300);
376  ImGui::Checkbox("No background", &no_background);
377  ImGui::Checkbox("No bring to front", &no_bring_to_front);
378  }
379 
380  // All demo contents
386 
387  // End of ShowDemoWindow()
388  ImGui::End();
389 }
390 
392 {
393  if (!ImGui::CollapsingHeader("Widgets"))
394  return;
395 
396  if (ImGui::TreeNode("Basic"))
397  {
398  static int clicked = 0;
399  if (ImGui::Button("Button"))
400  clicked++;
401  if (clicked & 1)
402  {
403  ImGui::SameLine();
404  ImGui::Text("Thanks for clicking me!");
405  }
406 
407  static bool check = true;
408  ImGui::Checkbox("checkbox", &check);
409 
410  static int e = 0;
411  ImGui::RadioButton("radio a", &e, 0); ImGui::SameLine();
412  ImGui::RadioButton("radio b", &e, 1); ImGui::SameLine();
413  ImGui::RadioButton("radio c", &e, 2);
414 
415  // Color buttons, demonstrate using PushID() to add unique identifier in the ID stack, and changing style.
416  for (int i = 0; i < 7; i++)
417  {
418  if (i > 0)
419  ImGui::SameLine();
420  ImGui::PushID(i);
424  ImGui::Button("Click");
426  ImGui::PopID();
427  }
428 
429  // Use AlignTextToFramePadding() to align text baseline to the baseline of framed elements (otherwise a Text+SameLine+Button sequence will have the text a little too high by default)
431  ImGui::Text("Hold to repeat:");
432  ImGui::SameLine();
433 
434  // Arrow buttons with Repeater
435  static int counter = 0;
436  float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
438  if (ImGui::ArrowButton("##left", ImGuiDir_Left)) { counter--; }
439  ImGui::SameLine(0.0f, spacing);
440  if (ImGui::ArrowButton("##right", ImGuiDir_Right)) { counter++; }
442  ImGui::SameLine();
443  ImGui::Text("%d", counter);
444 
445  ImGui::Text("Hover over me");
446  if (ImGui::IsItemHovered())
447  ImGui::SetTooltip("I am a tooltip");
448 
449  ImGui::SameLine();
450  ImGui::Text("- or me");
451  if (ImGui::IsItemHovered())
452  {
454  ImGui::Text("I am a fancy tooltip");
455  static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f };
456  ImGui::PlotLines("Curve", arr, IM_ARRAYSIZE(arr));
458  }
459 
461 
462  ImGui::LabelText("label", "Value");
463 
464  {
465  // Using the _simplified_ one-liner Combo() api here
466  // See "Combo" section for examples of how to use the more complete BeginCombo()/EndCombo() api.
467  const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO" };
468  static int item_current = 0;
469  ImGui::Combo("combo", &item_current, items, IM_ARRAYSIZE(items));
470  ImGui::SameLine(); ShowHelpMarker("Refer to the \"Combo\" section below for an explanation of the full BeginCombo/EndCombo API, and demonstration of various flags.\n");
471  }
472 
473  {
474  static char str0[128] = "Hello, world!";
475  static int i0 = 123;
476  ImGui::InputText("input text", str0, IM_ARRAYSIZE(str0));
477  ImGui::SameLine(); ShowHelpMarker("USER:\nHold 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\nPROGRAMMER:\nYou can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputText() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example (this is not demonstrated in imgui_demo.cpp).");
478 
479  ImGui::InputInt("input int", &i0);
480  ImGui::SameLine(); ShowHelpMarker("You can apply arithmetic operators +,*,/ on numerical values.\n e.g. [ 100 ], input \'*2\', result becomes [ 200 ]\nUse +- to subtract.\n");
481 
482  static float f0 = 0.001f;
483  ImGui::InputFloat("input float", &f0, 0.01f, 1.0f, "%.3f");
484 
485  static double d0 = 999999.00000001;
486  ImGui::InputDouble("input double", &d0, 0.01f, 1.0f, "%.8f");
487 
488  static float f1 = 1.e10f;
489  ImGui::InputFloat("input scientific", &f1, 0.0f, 0.0f, "%e");
490  ImGui::SameLine(); ShowHelpMarker("You can input value using the scientific notation,\n e.g. \"1e+8\" becomes \"100000000\".\n");
491 
492  static float vec4a[4] = { 0.10f, 0.20f, 0.30f, 0.44f };
493  ImGui::InputFloat3("input float3", vec4a);
494  }
495 
496  {
497  static int i1 = 50, i2 = 42;
498  ImGui::DragInt("drag int", &i1, 1);
499  ImGui::SameLine(); ShowHelpMarker("Click and drag to edit value.\nHold SHIFT/ALT for faster/slower edit.\nDouble-click or CTRL+click to input value.");
500 
501  ImGui::DragInt("drag int 0..100", &i2, 1, 0, 100, "%d%%");
502 
503  static float f1=1.00f, f2=0.0067f;
504  ImGui::DragFloat("drag float", &f1, 0.005f);
505  ImGui::DragFloat("drag small float", &f2, 0.0001f, 0.0f, 0.0f, "%.06f ns");
506  }
507 
508  {
509  static int i1=0;
510  ImGui::SliderInt("slider int", &i1, -1, 3);
511  ImGui::SameLine(); ShowHelpMarker("CTRL+click to input value.");
512 
513  static float f1=0.123f, f2=0.0f;
514  ImGui::SliderFloat("slider float", &f1, 0.0f, 1.0f, "ratio = %.3f");
515  ImGui::SliderFloat("slider float (curve)", &f2, -10.0f, 10.0f, "%.4f", 2.0f);
516  static float angle = 0.0f;
517  ImGui::SliderAngle("slider angle", &angle);
518  }
519 
520  {
521  static float col1[3] = { 1.0f,0.0f,0.2f };
522  static float col2[4] = { 0.4f,0.7f,0.0f,0.5f };
523  ImGui::ColorEdit3("color 1", col1);
524  ImGui::SameLine(); ShowHelpMarker("Click on the colored square to open a color picker.\nClick and hold to use drag and drop.\nRight-click on the colored square to show options.\nCTRL+click on individual component to input value.\n");
525 
526  ImGui::ColorEdit4("color 2", col2);
527  }
528 
529  {
530  // List box
531  const char* listbox_items[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" };
532  static int listbox_item_current = 1;
533  ImGui::ListBox("listbox\n(single select)", &listbox_item_current, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
534 
535  //static int listbox_item_current2 = 2;
536  //ImGui::PushItemWidth(-1);
537  //ImGui::ListBox("##listbox2", &listbox_item_current2, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
538  //ImGui::PopItemWidth();
539  }
540 
541  ImGui::TreePop();
542  }
543 
544  // Testing ImGuiOnceUponAFrame helper.
545  //static ImGuiOnceUponAFrame once;
546  //for (int i = 0; i < 5; i++)
547  // if (once)
548  // ImGui::Text("This will be displayed only once.");
549 
550  if (ImGui::TreeNode("Trees"))
551  {
552  if (ImGui::TreeNode("Basic trees"))
553  {
554  for (int i = 0; i < 5; i++)
555  if (ImGui::TreeNode((void*)(intptr_t)i, "Child %d", i))
556  {
557  ImGui::Text("blah blah");
558  ImGui::SameLine();
559  if (ImGui::SmallButton("button")) { };
560  ImGui::TreePop();
561  }
562  ImGui::TreePop();
563  }
564 
565  if (ImGui::TreeNode("Advanced, with Selectable nodes"))
566  {
567  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.");
568  static bool align_label_with_current_x_position = false;
569  ImGui::Checkbox("Align label with current X position)", &align_label_with_current_x_position);
570  ImGui::Text("Hello!");
571  if (align_label_with_current_x_position)
573 
574  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.
575  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.
576  ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, ImGui::GetFontSize()*3); // Increase spacing to differentiate leaves from expanded contents.
577  for (int i = 0; i < 6; i++)
578  {
579  // Disable the default open on single-click behavior and pass in Selected flag according to our selection state.
581  if (i < 3)
582  {
583  // Node
584  bool node_open = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Node %d", i);
585  if (ImGui::IsItemClicked())
586  node_clicked = i;
587  if (node_open)
588  {
589  ImGui::Text("Blah blah\nBlah Blah");
590  ImGui::TreePop();
591  }
592  }
593  else
594  {
595  // 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().
596  node_flags |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen; // ImGuiTreeNodeFlags_Bullet
597  ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Leaf %d", i);
598  if (ImGui::IsItemClicked())
599  node_clicked = i;
600  }
601  }
602  if (node_clicked != -1)
603  {
604  // Update selection state. Process outside of tree loop to avoid visual inconsistencies during the clicking-frame.
605  if (ImGui::GetIO().KeyCtrl)
606  selection_mask ^= (1 << node_clicked); // CTRL+click to toggle
607  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
608  selection_mask = (1 << node_clicked); // Click to single-select
609  }
611  if (align_label_with_current_x_position)
613  ImGui::TreePop();
614  }
615  ImGui::TreePop();
616  }
617 
618  if (ImGui::TreeNode("Collapsing Headers"))
619  {
620  static bool closable_group = true;
621  ImGui::Checkbox("Enable extra group", &closable_group);
622  if (ImGui::CollapsingHeader("Header"))
623  {
624  ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered());
625  for (int i = 0; i < 5; i++)
626  ImGui::Text("Some content %d", i);
627  }
628  if (ImGui::CollapsingHeader("Header with a close button", &closable_group))
629  {
630  ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered());
631  for (int i = 0; i < 5; i++)
632  ImGui::Text("More content %d", i);
633  }
634  ImGui::TreePop();
635  }
636 
637  if (ImGui::TreeNode("Bullets"))
638  {
639  ImGui::BulletText("Bullet point 1");
640  ImGui::BulletText("Bullet point 2\nOn multiple lines");
641  ImGui::Bullet(); ImGui::Text("Bullet point 3 (two calls)");
642  ImGui::Bullet(); ImGui::SmallButton("Button");
643  ImGui::TreePop();
644  }
645 
646  if (ImGui::TreeNode("Text"))
647  {
648  if (ImGui::TreeNode("Colored Text"))
649  {
650  // Using shortcut. You can use PushStyleColor()/PopStyleColor() for more flexibility.
651  ImGui::TextColored(ImVec4(1.0f,0.0f,1.0f,1.0f), "Pink");
652  ImGui::TextColored(ImVec4(1.0f,1.0f,0.0f,1.0f), "Yellow");
653  ImGui::TextDisabled("Disabled");
654  ImGui::SameLine(); ShowHelpMarker("The TextDisabled color is stored in ImGuiStyle.");
655  ImGui::TreePop();
656  }
657 
658  if (ImGui::TreeNode("Word Wrapping"))
659  {
660  // Using shortcut. You can use PushTextWrapPos()/PopTextWrapPos() for more flexibility.
661  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.");
662  ImGui::Spacing();
663 
664  static float wrap_width = 200.0f;
665  ImGui::SliderFloat("Wrap width", &wrap_width, -20, 600, "%.0f");
666 
667  ImGui::Text("Test paragraph 1:");
669  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));
671  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);
674 
675  ImGui::Text("Test paragraph 2:");
677  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));
679  ImGui::Text("aaaaaaaa bbbbbbbb, c cccccccc,dddddddd. d eeeeeeee ffffffff. gggggggg!hhhhhhhh");
682 
683  ImGui::TreePop();
684  }
685 
686  if (ImGui::TreeNode("UTF-8 Text"))
687  {
688  // UTF-8 test with Japanese characters
689  // (Needs a suitable font, try Noto, or Arial Unicode, or M+ fonts. Read misc/fonts/README.txt for details.)
690  // - From C++11 you can use the u8"my text" syntax to encode literal strings as UTF-8
691  // - 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')
692  // - FOR THIS DEMO FILE ONLY, BECAUSE WE WANT TO SUPPORT OLD COMPILERS, WE ARE *NOT* INCLUDING RAW UTF-8 CHARACTERS IN THIS SOURCE FILE.
693  // Instead we are encoding a few strings with hexadecimal constants. Don't do this in your application!
694  // Please use u8"text in any language" in your application!
695  // 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.
696  ImGui::TextWrapped("CJK text will only appears if the font was loaded with the appropriate CJK character ranges. Call io.Font->AddFontFromFileTTF() manually to load extra character ranges. Read misc/fonts/README.txt for details.");
697  ImGui::Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)"); // Normally we would use u8"blah blah" with the proper characters directly in the string.
698  ImGui::Text("Kanjis: \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e (nihongo)");
699  static char buf[32] = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e";
700  //static char buf[32] = u8"NIHONGO"; // <- this is how you would write it with C++11, using real kanjis
701  ImGui::InputText("UTF-8 input", buf, IM_ARRAYSIZE(buf));
702  ImGui::TreePop();
703  }
704  ImGui::TreePop();
705  }
706 
707  if (ImGui::TreeNode("Images"))
708  {
709  ImGuiIO& io = ImGui::GetIO();
710  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!");
711 
712  // Here we are grabbing the font texture because that's the only one we have access to inside the demo code.
713  // Remember that ImTextureID is just storage for whatever you want it to be, it is essentially a value that will be passed to the render function inside the ImDrawCmd structure.
714  // If you use one of the default imgui_impl_XXXX.cpp renderer, they all have comments at the top of their file to specify what they expect to be stored in ImTextureID.
715  // (for example, the imgui_impl_dx11.cpp renderer expect a 'ID3D11ShaderResourceView*' pointer. The imgui_impl_glfw_gl3.cpp renderer expect a GLuint OpenGL texture identifier etc.)
716  // If you decided that ImTextureID = MyEngineTexture*, then you can pass your MyEngineTexture* pointers to ImGui::Image(), and gather width/height through your own functions, etc.
717  // Using ShowMetricsWindow() as a "debugger" to inspect the draw data that are being passed to your render will help you debug issues if you are confused about this.
718  // Consider using the lower-level ImDrawList::AddImage() API, via ImGui::GetWindowDrawList()->AddImage().
719  ImTextureID my_tex_id = io.Fonts->TexID;
720  float my_tex_w = (float)io.Fonts->TexWidth;
721  float my_tex_h = (float)io.Fonts->TexHeight;
722 
723  ImGui::Text("%.0fx%.0f", my_tex_w, my_tex_h);
725  ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), ImVec2(0,0), ImVec2(1,1), ImColor(255,255,255,255), ImColor(255,255,255,128));
726  if (ImGui::IsItemHovered())
727  {
729  float region_sz = 32.0f;
730  float region_x = io.MousePos.x - pos.x - region_sz * 0.5f; if (region_x < 0.0f) region_x = 0.0f; else if (region_x > my_tex_w - region_sz) region_x = my_tex_w - region_sz;
731  float region_y = io.MousePos.y - pos.y - region_sz * 0.5f; if (region_y < 0.0f) region_y = 0.0f; else if (region_y > my_tex_h - region_sz) region_y = my_tex_h - region_sz;
732  float zoom = 4.0f;
733  ImGui::Text("Min: (%.2f, %.2f)", region_x, region_y);
734  ImGui::Text("Max: (%.2f, %.2f)", region_x + region_sz, region_y + region_sz);
735  ImVec2 uv0 = ImVec2((region_x) / my_tex_w, (region_y) / my_tex_h);
736  ImVec2 uv1 = ImVec2((region_x + region_sz) / my_tex_w, (region_y + region_sz) / my_tex_h);
737  ImGui::Image(my_tex_id, ImVec2(region_sz * zoom, region_sz * zoom), uv0, uv1, ImColor(255,255,255,255), ImColor(255,255,255,128));
739  }
740  ImGui::TextWrapped("And now some textured buttons..");
741  static int pressed_count = 0;
742  for (int i = 0; i < 8; i++)
743  {
744  ImGui::PushID(i);
745  int frame_padding = -1 + i; // -1 = uses default padding
746  if (ImGui::ImageButton(my_tex_id, ImVec2(32,32), ImVec2(0,0), ImVec2(32.0f/my_tex_w,32/my_tex_h), frame_padding, ImColor(0,0,0,255)))
747  pressed_count += 1;
748  ImGui::PopID();
749  ImGui::SameLine();
750  }
751  ImGui::NewLine();
752  ImGui::Text("Pressed %d times.", pressed_count);
753  ImGui::TreePop();
754  }
755 
756  if (ImGui::TreeNode("Combo"))
757  {
758  // Expose flags as checkbox for the demo
759  static ImGuiComboFlags flags = 0;
760  ImGui::CheckboxFlags("ImGuiComboFlags_PopupAlignLeft", (unsigned int*)&flags, ImGuiComboFlags_PopupAlignLeft);
761  if (ImGui::CheckboxFlags("ImGuiComboFlags_NoArrowButton", (unsigned int*)&flags, ImGuiComboFlags_NoArrowButton))
762  flags &= ~ImGuiComboFlags_NoPreview; // Clear the other flag, as we cannot combine both
763  if (ImGui::CheckboxFlags("ImGuiComboFlags_NoPreview", (unsigned int*)&flags, ImGuiComboFlags_NoPreview))
764  flags &= ~ImGuiComboFlags_NoArrowButton; // Clear the other flag, as we cannot combine both
765 
766  // General BeginCombo() API, you have full control over your selection data and display type.
767  // (your selection data could be an index, a pointer to the object, an id for the object, a flag stored in the object itself, etc.)
768  const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO" };
769  static const char* item_current = items[0]; // Here our selection is a single pointer stored outside the object.
770  if (ImGui::BeginCombo("combo 1", item_current, flags)) // The second parameter is the label previewed before opening the combo.
771  {
772  for (int n = 0; n < IM_ARRAYSIZE(items); n++)
773  {
774  bool is_selected = (item_current == items[n]);
775  if (ImGui::Selectable(items[n], is_selected))
776  item_current = items[n];
777  if (is_selected)
778  ImGui::SetItemDefaultFocus(); // Set the initial focus when opening the combo (scrolling + for keyboard navigation support in the upcoming navigation branch)
779  }
780  ImGui::EndCombo();
781  }
782 
783  // Simplified one-liner Combo() API, using values packed in a single constant string
784  static int item_current_2 = 0;
785  ImGui::Combo("combo 2 (one-liner)", &item_current_2, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
786 
787  // Simplified one-liner Combo() using an array of const char*
788  static int item_current_3 = -1; // If the selection isn't within 0..count, Combo won't display a preview
789  ImGui::Combo("combo 3 (array)", &item_current_3, items, IM_ARRAYSIZE(items));
790 
791  // Simplified one-liner Combo() using an accessor function
792  struct FuncHolder { static bool ItemGetter(void* data, int idx, const char** out_str) { *out_str = ((const char**)data)[idx]; return true; } };
793  static int item_current_4 = 0;
794  ImGui::Combo("combo 4 (function)", &item_current_4, &FuncHolder::ItemGetter, items, IM_ARRAYSIZE(items));
795 
796  ImGui::TreePop();
797  }
798 
799  if (ImGui::TreeNode("Selectables"))
800  {
801  // Selectable() has 2 overloads:
802  // - The one taking "bool selected" as a read-only selection information. When Selectable() has been clicked is returns true and you can alter selection state accordingly.
803  // - The one taking "bool* p_selected" as a read-write selection information (convenient in some cases)
804  // The earlier is more flexible, as in real application your selection may be stored in a different manner (in flags within objects, as an external list, etc).
805  if (ImGui::TreeNode("Basic"))
806  {
807  static bool selection[5] = { false, true, false, false, false };
808  ImGui::Selectable("1. I am selectable", &selection[0]);
809  ImGui::Selectable("2. I am selectable", &selection[1]);
810  ImGui::Text("3. I am not selectable");
811  ImGui::Selectable("4. I am selectable", &selection[3]);
812  if (ImGui::Selectable("5. I am double clickable", selection[4], ImGuiSelectableFlags_AllowDoubleClick))
814  selection[4] = !selection[4];
815  ImGui::TreePop();
816  }
817  if (ImGui::TreeNode("Selection State: Single Selection"))
818  {
819  static int selected = -1;
820  for (int n = 0; n < 5; n++)
821  {
822  char buf[32];
823  sprintf(buf, "Object %d", n);
824  if (ImGui::Selectable(buf, selected == n))
825  selected = n;
826  }
827  ImGui::TreePop();
828  }
829  if (ImGui::TreeNode("Selection State: Multiple Selection"))
830  {
831  ShowHelpMarker("Hold CTRL and click to select multiple items.");
832  static bool selection[5] = { false, false, false, false, false };
833  for (int n = 0; n < 5; n++)
834  {
835  char buf[32];
836  sprintf(buf, "Object %d", n);
837  if (ImGui::Selectable(buf, selection[n]))
838  {
839  if (!ImGui::GetIO().KeyCtrl) // Clear selection when CTRL is not held
840  memset(selection, 0, sizeof(selection));
841  selection[n] ^= 1;
842  }
843  }
844  ImGui::TreePop();
845  }
846  if (ImGui::TreeNode("Rendering more text into the same line"))
847  {
848  // Using the Selectable() override that takes "bool* p_selected" parameter and toggle your booleans automatically.
849  static bool selected[3] = { false, false, false };
850  ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
851  ImGui::Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(300); ImGui::Text("12,345 bytes");
852  ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
853  ImGui::TreePop();
854  }
855  if (ImGui::TreeNode("In columns"))
856  {
857  ImGui::Columns(3, NULL, false);
858  static bool selected[16] = { 0 };
859  for (int i = 0; i < 16; i++)
860  {
861  char label[32]; sprintf(label, "Item %d", i);
862  if (ImGui::Selectable(label, &selected[i])) {}
864  }
865  ImGui::Columns(1);
866  ImGui::TreePop();
867  }
868  if (ImGui::TreeNode("Grid"))
869  {
870  static bool selected[16] = { true, false, false, false, false, true, false, false, false, false, true, false, false, false, false, true };
871  for (int i = 0; i < 16; i++)
872  {
873  ImGui::PushID(i);
874  if (ImGui::Selectable("Sailor", &selected[i], 0, ImVec2(50,50)))
875  {
876  int x = i % 4, y = i / 4;
877  if (x > 0) selected[i - 1] ^= 1;
878  if (x < 3) selected[i + 1] ^= 1;
879  if (y > 0) selected[i - 4] ^= 1;
880  if (y < 3) selected[i + 4] ^= 1;
881  }
882  if ((i % 4) < 3) ImGui::SameLine();
883  ImGui::PopID();
884  }
885  ImGui::TreePop();
886  }
887  ImGui::TreePop();
888  }
889 
890  if (ImGui::TreeNode("Filtered Text Input"))
891  {
892  static char buf1[64] = ""; ImGui::InputText("default", buf1, 64);
893  static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal);
894  static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
895  static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase);
896  static char buf5[64] = ""; ImGui::InputText("no blank", buf5, 64, ImGuiInputTextFlags_CharsNoBlank);
897  struct TextFilters { static int FilterImGuiLetters(ImGuiInputTextCallbackData* data) { if (data->EventChar < 256 && strchr("imgui", (char)data->EventChar)) return 0; return 1; } };
898  static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters);
899 
900  ImGui::Text("Password input");
901  static char bufpass[64] = "password123";
903  ImGui::SameLine(); ShowHelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n");
904  ImGui::InputText("password (clear)", bufpass, 64, ImGuiInputTextFlags_CharsNoBlank);
905 
906  ImGui::TreePop();
907  }
908 
909  if (ImGui::TreeNode("Multi-line Text Input"))
910  {
911  // Note: we are using a fixed-sized buffer for simplicity here. See ImGuiInputTextFlags_CallbackResize
912  // and the code in misc/cpp/imgui_stdlib.h for how to setup InputText() for dynamically resizing strings.
913  static bool read_only = false;
914  static char text[1024*16] =
915  "/*\n"
916  " The Pentium F00F bug, shorthand for F0 0F C7 C8,\n"
917  " the hexadecimal encoding of one offending instruction,\n"
918  " more formally, the invalid operand with locked CMPXCHG8B\n"
919  " instruction bug, is a design flaw in the majority of\n"
920  " Intel Pentium, Pentium MMX, and Pentium OverDrive\n"
921  " processors (all in the P5 microarchitecture).\n"
922  "*/\n\n"
923  "label:\n"
924  "\tlock cmpxchg8b eax\n";
925 
926  ShowHelpMarker("You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example. (This is not demonstrated in imgui_demo.cpp)");
927  ImGui::Checkbox("Read-only", &read_only);
929  ImGui::InputTextMultiline("##source", text, IM_ARRAYSIZE(text), ImVec2(-1.0f, ImGui::GetTextLineHeight() * 16), flags);
930  ImGui::TreePop();
931  }
932 
933  if (ImGui::TreeNode("Plots Widgets"))
934  {
935  static bool animate = true;
936  ImGui::Checkbox("Animate", &animate);
937 
938  static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f };
939  ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr));
940 
941  // Create a dummy array of contiguous float values to plot
942  // 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.
943  static float values[90] = { 0 };
944  static int values_offset = 0;
945  static double refresh_time = 0.0;
946  if (!animate || refresh_time == 0.0f)
947  refresh_time = ImGui::GetTime();
948  while (refresh_time < ImGui::GetTime()) // Create dummy data at fixed 60 hz rate for the demo
949  {
950  static float phase = 0.0f;
951  values[values_offset] = cosf(phase);
952  values_offset = (values_offset+1) % IM_ARRAYSIZE(values);
953  phase += 0.10f*values_offset;
954  refresh_time += 1.0f/60.0f;
955  }
956  ImGui::PlotLines("Lines", values, IM_ARRAYSIZE(values), values_offset, "avg 0.0", -1.0f, 1.0f, ImVec2(0,80));
957  ImGui::PlotHistogram("Histogram", arr, IM_ARRAYSIZE(arr), 0, NULL, 0.0f, 1.0f, ImVec2(0,80));
958 
959  // Use functions to generate output
960  // 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.
961  struct Funcs
962  {
963  static float Sin(void*, int i) { return sinf(i * 0.1f); }
964  static float Saw(void*, int i) { return (i & 1) ? 1.0f : -1.0f; }
965  };
966  static int func_type = 0, display_count = 70;
968  ImGui::PushItemWidth(100); ImGui::Combo("func", &func_type, "Sin\0Saw\0"); ImGui::PopItemWidth();
969  ImGui::SameLine();
970  ImGui::SliderInt("Sample count", &display_count, 1, 400);
971  float (*func)(void*, int) = (func_type == 0) ? Funcs::Sin : Funcs::Saw;
972  ImGui::PlotLines("Lines", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0,80));
973  ImGui::PlotHistogram("Histogram", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0,80));
975 
976  // Animate a simple progress bar
977  static float progress = 0.0f, progress_dir = 1.0f;
978  if (animate)
979  {
980  progress += progress_dir * 0.4f * ImGui::GetIO().DeltaTime;
981  if (progress >= +1.1f) { progress = +1.1f; progress_dir *= -1.0f; }
982  if (progress <= -0.1f) { progress = -0.1f; progress_dir *= -1.0f; }
983  }
984 
985  // 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.
986  ImGui::ProgressBar(progress, ImVec2(0.0f,0.0f));
987  ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
988  ImGui::Text("Progress Bar");
989 
990  float progress_saturated = (progress < 0.0f) ? 0.0f : (progress > 1.0f) ? 1.0f : progress;
991  char buf[32];
992  sprintf(buf, "%d/%d", (int)(progress_saturated*1753), 1753);
993  ImGui::ProgressBar(progress, ImVec2(0.f,0.f), buf);
994  ImGui::TreePop();
995  }
996 
997  if (ImGui::TreeNode("Color/Picker Widgets"))
998  {
999  static ImVec4 color = ImColor(114, 144, 154, 200);
1000 
1001  static bool alpha_preview = true;
1002  static bool alpha_half_preview = false;
1003  static bool drag_and_drop = true;
1004  static bool options_menu = true;
1005  static bool hdr = false;
1006  ImGui::Checkbox("With Alpha Preview", &alpha_preview);
1007  ImGui::Checkbox("With Half Alpha Preview", &alpha_half_preview);
1008  ImGui::Checkbox("With Drag and Drop", &drag_and_drop);
1009  ImGui::Checkbox("With Options Menu", &options_menu); ImGui::SameLine(); ShowHelpMarker("Right-click on the individual color widget to show options.");
1010  ImGui::Checkbox("With HDR", &hdr); ImGui::SameLine(); ShowHelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets.");
1011  int misc_flags = (hdr ? ImGuiColorEditFlags_HDR : 0) | (drag_and_drop ? 0 : ImGuiColorEditFlags_NoDragDrop) | (alpha_half_preview ? ImGuiColorEditFlags_AlphaPreviewHalf : (alpha_preview ? ImGuiColorEditFlags_AlphaPreview : 0)) | (options_menu ? 0 : ImGuiColorEditFlags_NoOptions);
1012 
1013  ImGui::Text("Color widget:");
1014  ImGui::SameLine(); ShowHelpMarker("Click on the colored square to open a color picker.\nCTRL+click on individual component to input value.\n");
1015  ImGui::ColorEdit3("MyColor##1", (float*)&color, misc_flags);
1016 
1017  ImGui::Text("Color widget HSV with Alpha:");
1018  ImGui::ColorEdit4("MyColor##2", (float*)&color, ImGuiColorEditFlags_HSV | misc_flags);
1019 
1020  ImGui::Text("Color widget with Float Display:");
1021  ImGui::ColorEdit4("MyColor##2f", (float*)&color, ImGuiColorEditFlags_Float | misc_flags);
1022 
1023  ImGui::Text("Color button with Picker:");
1024  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.");
1025  ImGui::ColorEdit4("MyColor##3", (float*)&color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | misc_flags);
1026 
1027  ImGui::Text("Color button with Custom Picker Popup:");
1028 
1029  // Generate a dummy palette
1030  static bool saved_palette_inited = false;
1031  static ImVec4 saved_palette[32];
1032  if (!saved_palette_inited)
1033  for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++)
1034  {
1035  ImGui::ColorConvertHSVtoRGB(n / 31.0f, 0.8f, 0.8f, saved_palette[n].x, saved_palette[n].y, saved_palette[n].z);
1036  saved_palette[n].w = 1.0f; // Alpha
1037  }
1038  saved_palette_inited = true;
1039 
1040  static ImVec4 backup_color;
1041  bool open_popup = ImGui::ColorButton("MyColor##3b", color, misc_flags);
1042  ImGui::SameLine();
1043  open_popup |= ImGui::Button("Palette");
1044  if (open_popup)
1045  {
1046  ImGui::OpenPopup("mypicker");
1047  backup_color = color;
1048  }
1049  if (ImGui::BeginPopup("mypicker"))
1050  {
1051  // FIXME: Adding a drag and drop example here would be perfect!
1052  ImGui::Text("MY CUSTOM COLOR PICKER WITH AN AMAZING PALETTE!");
1053  ImGui::Separator();
1055  ImGui::SameLine();
1057  ImGui::Text("Current");
1059  ImGui::Text("Previous");
1061  color = backup_color;
1062  ImGui::Separator();
1063  ImGui::Text("Palette");
1064  for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++)
1065  {
1066  ImGui::PushID(n);
1067  if ((n % 8) != 0)
1068  ImGui::SameLine(0.0f, ImGui::GetStyle().ItemSpacing.y);
1070  color = ImVec4(saved_palette[n].x, saved_palette[n].y, saved_palette[n].z, color.w); // Preserve alpha!
1071 
1073  {
1075  memcpy((float*)&saved_palette[n], payload->Data, sizeof(float) * 3);
1077  memcpy((float*)&saved_palette[n], payload->Data, sizeof(float) * 4);
1079  }
1080 
1081  ImGui::PopID();
1082  }
1083  ImGui::EndGroup();
1084  ImGui::EndPopup();
1085  }
1086 
1087  ImGui::Text("Color button only:");
1088  ImGui::ColorButton("MyColor##3c", *(ImVec4*)&color, misc_flags, ImVec2(80,80));
1089 
1090  ImGui::Text("Color picker:");
1091  static bool alpha = true;
1092  static bool alpha_bar = true;
1093  static bool side_preview = true;
1094  static bool ref_color = false;
1095  static ImVec4 ref_color_v(1.0f,0.0f,1.0f,0.5f);
1096  static int inputs_mode = 2;
1097  static int picker_mode = 0;
1098  ImGui::Checkbox("With Alpha", &alpha);
1099  ImGui::Checkbox("With Alpha Bar", &alpha_bar);
1100  ImGui::Checkbox("With Side Preview", &side_preview);
1101  if (side_preview)
1102  {
1103  ImGui::SameLine();
1104  ImGui::Checkbox("With Ref Color", &ref_color);
1105  if (ref_color)
1106  {
1107  ImGui::SameLine();
1108  ImGui::ColorEdit4("##RefColor", &ref_color_v.x, ImGuiColorEditFlags_NoInputs | misc_flags);
1109  }
1110  }
1111  ImGui::Combo("Inputs Mode", &inputs_mode, "All Inputs\0No Inputs\0RGB Input\0HSV Input\0HEX Input\0");
1112  ImGui::Combo("Picker Mode", &picker_mode, "Auto/Current\0Hue bar + SV rect\0Hue wheel + SV triangle\0");
1113  ImGui::SameLine(); ShowHelpMarker("User can right-click the picker to change mode.");
1114  ImGuiColorEditFlags flags = misc_flags;
1115  if (!alpha) flags |= ImGuiColorEditFlags_NoAlpha; // This is by default if you call ColorPicker3() instead of ColorPicker4()
1116  if (alpha_bar) flags |= ImGuiColorEditFlags_AlphaBar;
1117  if (!side_preview) flags |= ImGuiColorEditFlags_NoSidePreview;
1118  if (picker_mode == 1) flags |= ImGuiColorEditFlags_PickerHueBar;
1119  if (picker_mode == 2) flags |= ImGuiColorEditFlags_PickerHueWheel;
1120  if (inputs_mode == 1) flags |= ImGuiColorEditFlags_NoInputs;
1121  if (inputs_mode == 2) flags |= ImGuiColorEditFlags_RGB;
1122  if (inputs_mode == 3) flags |= ImGuiColorEditFlags_HSV;
1123  if (inputs_mode == 4) flags |= ImGuiColorEditFlags_HEX;
1124  ImGui::ColorPicker4("MyColor##4", (float*)&color, flags, ref_color ? &ref_color_v.x : NULL);
1125 
1126  ImGui::Text("Programmatically set defaults:");
1127  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.");
1128  if (ImGui::Button("Default: Uint8 + HSV + Hue Bar"))
1130  if (ImGui::Button("Default: Float + HDR + Hue Wheel"))
1132 
1133  ImGui::TreePop();
1134  }
1135 
1136  if (ImGui::TreeNode("Range Widgets"))
1137  {
1138  static float begin = 10, end = 90;
1139  static int begin_i = 100, end_i = 1000;
1140  ImGui::DragFloatRange2("range", &begin, &end, 0.25f, 0.0f, 100.0f, "Min: %.1f %%", "Max: %.1f %%");
1141  ImGui::DragIntRange2("range int (no bounds)", &begin_i, &end_i, 5, 0, 0, "Min: %d units", "Max: %d units");
1142  ImGui::TreePop();
1143  }
1144 
1145  if (ImGui::TreeNode("Data Types"))
1146  {
1147  // The DragScalar/InputScalar/SliderScalar functions allow various data types: signed/unsigned int/long long and float/double
1148  // To avoid polluting the public API with all possible combinations, we use the ImGuiDataType enum to pass the type,
1149  // and passing all arguments by address.
1150  // This is the reason the test code below creates local variables to hold "zero" "one" etc. for each types.
1151  // In practice, if you frequently use a given type that is not covered by the normal API entry points, you can wrap it
1152  // yourself inside a 1 line function which can take typed argument as value instead of void*, and then pass their address
1153  // to the generic function. For example:
1154  // bool MySliderU64(const char *label, u64* value, u64 min = 0, u64 max = 0, const char* format = "%lld")
1155  // {
1156  // return SliderScalar(label, ImGuiDataType_U64, value, &min, &max, format);
1157  // }
1158 
1159  // Limits (as helper variables that we can take the address of)
1160  // Note that the SliderScalar function has a maximum usable range of half the natural type maximum, hence the /2 below.
1161  #ifndef LLONG_MIN
1162  ImS64 LLONG_MIN = -9223372036854775807LL - 1;
1163  ImS64 LLONG_MAX = 9223372036854775807LL;
1164  ImU64 ULLONG_MAX = (2ULL * 9223372036854775807LL + 1);
1165  #endif
1166  const ImS32 s32_zero = 0, s32_one = 1, s32_fifty = 50, s32_min = INT_MIN/2, s32_max = INT_MAX/2, s32_hi_a = INT_MAX/2 - 100, s32_hi_b = INT_MAX/2;
1167  const ImU32 u32_zero = 0, u32_one = 1, u32_fifty = 50, u32_min = 0, u32_max = UINT_MAX/2, u32_hi_a = UINT_MAX/2 - 100, u32_hi_b = UINT_MAX/2;
1168  const ImS64 s64_zero = 0, s64_one = 1, s64_fifty = 50, s64_min = LLONG_MIN/2, s64_max = LLONG_MAX/2, s64_hi_a = LLONG_MAX/2 - 100, s64_hi_b = LLONG_MAX/2;
1169  const ImU64 u64_zero = 0, u64_one = 1, u64_fifty = 50, u64_min = 0, u64_max = ULLONG_MAX/2, u64_hi_a = ULLONG_MAX/2 - 100, u64_hi_b = ULLONG_MAX/2;
1170  const float f32_zero = 0.f, f32_one = 1.f, f32_lo_a = -10000000000.0f, f32_hi_a = +10000000000.0f;
1171  const double f64_zero = 0., f64_one = 1., f64_lo_a = -1000000000000000.0, f64_hi_a = +1000000000000000.0;
1172 
1173  // State
1174  static ImS32 s32_v = -1;
1175  static ImU32 u32_v = (ImU32)-1;
1176  static ImS64 s64_v = -1;
1177  static ImU64 u64_v = (ImU64)-1;
1178  static float f32_v = 0.123f;
1179  static double f64_v = 90000.01234567890123456789;
1180 
1181  const float drag_speed = 0.2f;
1182  static bool drag_clamp = false;
1183  ImGui::Text("Drags:");
1184  ImGui::Checkbox("Clamp integers to 0..50", &drag_clamp); ImGui::SameLine(); ShowHelpMarker("As with every widgets in dear imgui, we never modify values unless there is a user interaction.\nYou can override the clamping limits by using CTRL+Click to input a value.");
1185  ImGui::DragScalar("drag s32", ImGuiDataType_S32, &s32_v, drag_speed, drag_clamp ? &s32_zero : NULL, drag_clamp ? &s32_fifty : NULL);
1186  ImGui::DragScalar("drag u32", ImGuiDataType_U32, &u32_v, drag_speed, drag_clamp ? &u32_zero : NULL, drag_clamp ? &u32_fifty : NULL, "%u ms");
1187  ImGui::DragScalar("drag s64", ImGuiDataType_S64, &s64_v, drag_speed, drag_clamp ? &s64_zero : NULL, drag_clamp ? &s64_fifty : NULL);
1188  ImGui::DragScalar("drag u64", ImGuiDataType_U64, &u64_v, drag_speed, drag_clamp ? &u64_zero : NULL, drag_clamp ? &u64_fifty : NULL);
1189  ImGui::DragScalar("drag float", ImGuiDataType_Float, &f32_v, 0.005f, &f32_zero, &f32_one, "%f", 1.0f);
1190  ImGui::DragScalar("drag float ^2", ImGuiDataType_Float, &f32_v, 0.005f, &f32_zero, &f32_one, "%f", 2.0f); ImGui::SameLine(); ShowHelpMarker("You can use the 'power' parameter to increase tweaking precision on one side of the range.");
1191  ImGui::DragScalar("drag double", ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, NULL, "%.10f grams", 1.0f);
1192  ImGui::DragScalar("drag double ^2", ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, &f64_one, "0 < %.10f < 1", 2.0f);
1193 
1194  ImGui::Text("Sliders");
1195  ImGui::SliderScalar("slider s32 low", ImGuiDataType_S32, &s32_v, &s32_zero, &s32_fifty,"%d");
1196  ImGui::SliderScalar("slider s32 high", ImGuiDataType_S32, &s32_v, &s32_hi_a, &s32_hi_b, "%d");
1197  ImGui::SliderScalar("slider s32 full", ImGuiDataType_S32, &s32_v, &s32_min, &s32_max, "%d");
1198  ImGui::SliderScalar("slider u32 low", ImGuiDataType_U32, &u32_v, &u32_zero, &u32_fifty,"%u");
1199  ImGui::SliderScalar("slider u32 high", ImGuiDataType_U32, &u32_v, &u32_hi_a, &u32_hi_b, "%u");
1200  ImGui::SliderScalar("slider u32 full", ImGuiDataType_U32, &u32_v, &u32_min, &u32_max, "%u");
1201  ImGui::SliderScalar("slider s64 low", ImGuiDataType_S64, &s64_v, &s64_zero, &s64_fifty,"%I64d");
1202  ImGui::SliderScalar("slider s64 high", ImGuiDataType_S64, &s64_v, &s64_hi_a, &s64_hi_b, "%I64d");
1203  ImGui::SliderScalar("slider s64 full", ImGuiDataType_S64, &s64_v, &s64_min, &s64_max, "%I64d");
1204  ImGui::SliderScalar("slider u64 low", ImGuiDataType_U64, &u64_v, &u64_zero, &u64_fifty,"%I64u ms");
1205  ImGui::SliderScalar("slider u64 high", ImGuiDataType_U64, &u64_v, &u64_hi_a, &u64_hi_b, "%I64u ms");
1206  ImGui::SliderScalar("slider u64 full", ImGuiDataType_U64, &u64_v, &u64_min, &u64_max, "%I64u ms");
1207  ImGui::SliderScalar("slider float low", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one);
1208  ImGui::SliderScalar("slider float low^2", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one, "%.10f", 2.0f);
1209  ImGui::SliderScalar("slider float high", ImGuiDataType_Float, &f32_v, &f32_lo_a, &f32_hi_a, "%e");
1210  ImGui::SliderScalar("slider double low", ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f grams", 1.0f);
1211  ImGui::SliderScalar("slider double low^2",ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f", 2.0f);
1212  ImGui::SliderScalar("slider double high", ImGuiDataType_Double, &f64_v, &f64_lo_a, &f64_hi_a, "%e grams", 1.0f);
1213 
1214  static bool inputs_step = true;
1215  ImGui::Text("Inputs");
1216  ImGui::Checkbox("Show step buttons", &inputs_step);
1217  ImGui::InputScalar("input s32", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%d");
1218  ImGui::InputScalar("input s32 hex", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal);
1219  ImGui::InputScalar("input u32", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%u");
1220  ImGui::InputScalar("input u32 hex", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal);
1221  ImGui::InputScalar("input s64", ImGuiDataType_S64, &s64_v, inputs_step ? &s64_one : NULL);
1222  ImGui::InputScalar("input u64", ImGuiDataType_U64, &u64_v, inputs_step ? &u64_one : NULL);
1223  ImGui::InputScalar("input float", ImGuiDataType_Float, &f32_v, inputs_step ? &f32_one : NULL);
1224  ImGui::InputScalar("input double", ImGuiDataType_Double, &f64_v, inputs_step ? &f64_one : NULL);
1225 
1226  ImGui::TreePop();
1227  }
1228 
1229  if (ImGui::TreeNode("Multi-component Widgets"))
1230  {
1231  static float vec4f[4] = { 0.10f, 0.20f, 0.30f, 0.44f };
1232  static int vec4i[4] = { 1, 5, 100, 255 };
1233 
1234  ImGui::InputFloat2("input float2", vec4f);
1235  ImGui::DragFloat2("drag float2", vec4f, 0.01f, 0.0f, 1.0f);
1236  ImGui::SliderFloat2("slider float2", vec4f, 0.0f, 1.0f);
1237  ImGui::InputInt2("input int2", vec4i);
1238  ImGui::DragInt2("drag int2", vec4i, 1, 0, 255);
1239  ImGui::SliderInt2("slider int2", vec4i, 0, 255);
1240  ImGui::Spacing();
1241 
1242  ImGui::InputFloat3("input float3", vec4f);
1243  ImGui::DragFloat3("drag float3", vec4f, 0.01f, 0.0f, 1.0f);
1244  ImGui::SliderFloat3("slider float3", vec4f, 0.0f, 1.0f);
1245  ImGui::InputInt3("input int3", vec4i);
1246  ImGui::DragInt3("drag int3", vec4i, 1, 0, 255);
1247  ImGui::SliderInt3("slider int3", vec4i, 0, 255);
1248  ImGui::Spacing();
1249 
1250  ImGui::InputFloat4("input float4", vec4f);
1251  ImGui::DragFloat4("drag float4", vec4f, 0.01f, 0.0f, 1.0f);
1252  ImGui::SliderFloat4("slider float4", vec4f, 0.0f, 1.0f);
1253  ImGui::InputInt4("input int4", vec4i);
1254  ImGui::DragInt4("drag int4", vec4i, 1, 0, 255);
1255  ImGui::SliderInt4("slider int4", vec4i, 0, 255);
1256 
1257  ImGui::TreePop();
1258  }
1259 
1260  if (ImGui::TreeNode("Vertical Sliders"))
1261  {
1262  const float spacing = 4;
1264 
1265  static int int_value = 0;
1266  ImGui::VSliderInt("##int", ImVec2(18,160), &int_value, 0, 5);
1267  ImGui::SameLine();
1268 
1269  static float values[7] = { 0.0f, 0.60f, 0.35f, 0.9f, 0.70f, 0.20f, 0.0f };
1270  ImGui::PushID("set1");
1271  for (int i = 0; i < 7; i++)
1272  {
1273  if (i > 0) ImGui::SameLine();
1274  ImGui::PushID(i);
1279  ImGui::VSliderFloat("##v", ImVec2(18,160), &values[i], 0.0f, 1.0f, "");
1281  ImGui::SetTooltip("%.3f", values[i]);
1283  ImGui::PopID();
1284  }
1285  ImGui::PopID();
1286 
1287  ImGui::SameLine();
1288  ImGui::PushID("set2");
1289  static float values2[4] = { 0.20f, 0.80f, 0.40f, 0.25f };
1290  const int rows = 3;
1291  const ImVec2 small_slider_size(18, (160.0f-(rows-1)*spacing)/rows);
1292  for (int nx = 0; nx < 4; nx++)
1293  {
1294  if (nx > 0) ImGui::SameLine();
1296  for (int ny = 0; ny < rows; ny++)
1297  {
1298  ImGui::PushID(nx*rows+ny);
1299  ImGui::VSliderFloat("##v", small_slider_size, &values2[nx], 0.0f, 1.0f, "");
1301  ImGui::SetTooltip("%.3f", values2[nx]);
1302  ImGui::PopID();
1303  }
1304  ImGui::EndGroup();
1305  }
1306  ImGui::PopID();
1307 
1308  ImGui::SameLine();
1309  ImGui::PushID("set3");
1310  for (int i = 0; i < 4; i++)
1311  {
1312  if (i > 0) ImGui::SameLine();
1313  ImGui::PushID(i);
1315  ImGui::VSliderFloat("##v", ImVec2(40,160), &values[i], 0.0f, 1.0f, "%.2f\nsec");
1317  ImGui::PopID();
1318  }
1319  ImGui::PopID();
1321  ImGui::TreePop();
1322  }
1323 
1324  if (ImGui::TreeNode("Drag and Drop"))
1325  {
1326  {
1327  // ColorEdit widgets automatically act as drag source and drag target.
1328  // They are using standardized payload strings IMGUI_PAYLOAD_TYPE_COLOR_3F and IMGUI_PAYLOAD_TYPE_COLOR_4F to allow your own widgets
1329  // to use colors in their drag and drop interaction. Also see the demo in Color Picker -> Palette demo.
1330  ImGui::BulletText("Drag and drop in standard widgets");
1331  ImGui::Indent();
1332  static float col1[3] = { 1.0f,0.0f,0.2f };
1333  static float col2[4] = { 0.4f,0.7f,0.0f,0.5f };
1334  ImGui::ColorEdit3("color 1", col1);
1335  ImGui::ColorEdit4("color 2", col2);
1336  ImGui::Unindent();
1337  }
1338 
1339  {
1340  ImGui::BulletText("Drag and drop to copy/swap items");
1341  ImGui::Indent();
1342  enum Mode
1343  {
1344  Mode_Copy,
1345  Mode_Move,
1346  Mode_Swap
1347  };
1348  static int mode = 0;
1349  if (ImGui::RadioButton("Copy", mode == Mode_Copy)) { mode = Mode_Copy; } ImGui::SameLine();
1350  if (ImGui::RadioButton("Move", mode == Mode_Move)) { mode = Mode_Move; } ImGui::SameLine();
1351  if (ImGui::RadioButton("Swap", mode == Mode_Swap)) { mode = Mode_Swap; }
1352  static const char* names[9] = { "Bobby", "Beatrice", "Betty", "Brianna", "Barry", "Bernard", "Bibi", "Blaine", "Bryn" };
1353  for (int n = 0; n < IM_ARRAYSIZE(names); n++)
1354  {
1355  ImGui::PushID(n);
1356  if ((n % 3) != 0)
1357  ImGui::SameLine();
1358  ImGui::Button(names[n], ImVec2(60,60));
1359 
1360  // Our buttons are both drag sources and drag targets here!
1362  {
1363  ImGui::SetDragDropPayload("DND_DEMO_CELL", &n, sizeof(int)); // Set payload to carry the index of our item (could be anything)
1364  if (mode == Mode_Copy) { ImGui::Text("Copy %s", names[n]); } // Display preview (could be anything, e.g. when dragging an image we could decide to display the filename and a small preview of the image, etc.)
1365  if (mode == Mode_Move) { ImGui::Text("Move %s", names[n]); }
1366  if (mode == Mode_Swap) { ImGui::Text("Swap %s", names[n]); }
1368  }
1370  {
1371  if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("DND_DEMO_CELL"))
1372  {
1373  IM_ASSERT(payload->DataSize == sizeof(int));
1374  int payload_n = *(const int*)payload->Data;
1375  if (mode == Mode_Copy)
1376  {
1377  names[n] = names[payload_n];
1378  }
1379  if (mode == Mode_Move)
1380  {
1381  names[n] = names[payload_n];
1382  names[payload_n] = "";
1383  }
1384  if (mode == Mode_Swap)
1385  {
1386  const char* tmp = names[n];
1387  names[n] = names[payload_n];
1388  names[payload_n] = tmp;
1389  }
1390  }
1392  }
1393  ImGui::PopID();
1394  }
1395  ImGui::Unindent();
1396  }
1397 
1398  ImGui::TreePop();
1399  }
1400 
1401  if (ImGui::TreeNode("Querying Status (Active/Focused/Hovered etc.)"))
1402  {
1403  // Display the value of IsItemHovered() and other common item state functions. Note that the flags can be combined.
1404  // (because BulletText is an item itself and that would affect the output of IsItemHovered() we pass all state in a single call to simplify the code).
1405  static int item_type = 1;
1406  static bool b = false;
1407  static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f };
1408  ImGui::RadioButton("Text", &item_type, 0);
1409  ImGui::RadioButton("Button", &item_type, 1);
1410  ImGui::RadioButton("CheckBox", &item_type, 2);
1411  ImGui::RadioButton("SliderFloat", &item_type, 3);
1412  ImGui::RadioButton("ColorEdit4", &item_type, 4);
1413  ImGui::RadioButton("ListBox", &item_type, 5);
1414  ImGui::Separator();
1415  bool ret = false;
1416  if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction
1417  if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button
1418  if (item_type == 2) { ret = ImGui::Checkbox("ITEM: CheckBox", &b); } // Testing checkbox
1419  if (item_type == 3) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item
1420  if (item_type == 4) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
1421  if (item_type == 5) { const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", &current, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
1423  "Return value = %d\n"
1424  "IsItemFocused() = %d\n"
1425  "IsItemHovered() = %d\n"
1426  "IsItemHovered(_AllowWhenBlockedByPopup) = %d\n"
1427  "IsItemHovered(_AllowWhenBlockedByActiveItem) = %d\n"
1428  "IsItemHovered(_AllowWhenOverlapped) = %d\n"
1429  "IsItemHovered(_RectOnly) = %d\n"
1430  "IsItemActive() = %d\n"
1431  "IsItemEdited() = %d\n"
1432  "IsItemDeactivated() = %d\n"
1433  "IsItemDeactivatedEdit() = %d\n"
1434  "IsItemVisible() = %d\n"
1435  "GetItemRectMin() = (%.1f, %.1f)\n"
1436  "GetItemRectMax() = (%.1f, %.1f)\n"
1437  "GetItemRectSize() = (%.1f, %.1f)",
1438  ret,
1453  );
1454 
1455  static bool embed_all_inside_a_child_window = false;
1456  ImGui::Checkbox("Embed everything inside a child window (for additional testing)", &embed_all_inside_a_child_window);
1457  if (embed_all_inside_a_child_window)
1458  ImGui::BeginChild("outer_child", ImVec2(0, ImGui::GetFontSize() * 20), true);
1459 
1460  // Testing IsWindowFocused() function with its various flags. Note that the flags can be combined.
1462  "IsWindowFocused() = %d\n"
1463  "IsWindowFocused(_ChildWindows) = %d\n"
1464  "IsWindowFocused(_ChildWindows|_RootWindow) = %d\n"
1465  "IsWindowFocused(_RootWindow) = %d\n"
1466  "IsWindowFocused(_AnyWindow) = %d\n",
1472 
1473  // Testing IsWindowHovered() function with its various flags. Note that the flags can be combined.
1475  "IsWindowHovered() = %d\n"
1476  "IsWindowHovered(_AllowWhenBlockedByPopup) = %d\n"
1477  "IsWindowHovered(_AllowWhenBlockedByActiveItem) = %d\n"
1478  "IsWindowHovered(_ChildWindows) = %d\n"
1479  "IsWindowHovered(_ChildWindows|_RootWindow) = %d\n"
1480  "IsWindowHovered(_RootWindow) = %d\n"
1481  "IsWindowHovered(_AnyWindow) = %d\n",
1489 
1490  ImGui::BeginChild("child", ImVec2(0, 50), true);
1491  ImGui::Text("This is another child window for testing the _ChildWindows flag.");
1492  ImGui::EndChild();
1493  if (embed_all_inside_a_child_window)
1494  ImGui::EndChild();
1495 
1496  // Calling IsItemHovered() after begin returns the hovered status of the title bar.
1497  // This is useful in particular if you want to create a context menu (with BeginPopupContextItem) associated to the title bar of a window.
1498  static bool test_window = false;
1499  ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window);
1500  if (test_window)
1501  {
1502  ImGui::Begin("Title bar Hovered/Active tests", &test_window);
1503  if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered()
1504  {
1505  if (ImGui::MenuItem("Close")) { test_window = false; }
1506  ImGui::EndPopup();
1507  }
1508  ImGui::Text(
1509  "IsItemHovered() after begin = %d (== is title bar hovered)\n"
1510  "IsItemActive() after begin = %d (== is window being clicked/moved)\n",
1512  ImGui::End();
1513  }
1514 
1515  ImGui::TreePop();
1516  }
1517 }
1518 
1520 {
1521  if (!ImGui::CollapsingHeader("Layout"))
1522  return;
1523 
1524  if (ImGui::TreeNode("Child windows"))
1525  {
1526  ShowHelpMarker("Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window.");
1527  static bool disable_mouse_wheel = false;
1528  static bool disable_menu = false;
1529  ImGui::Checkbox("Disable Mouse Wheel", &disable_mouse_wheel);
1530  ImGui::Checkbox("Disable Menu", &disable_menu);
1531 
1532  static int line = 50;
1533  bool goto_line = ImGui::Button("Goto");
1534  ImGui::SameLine();
1535  ImGui::PushItemWidth(100);
1536  goto_line |= ImGui::InputInt("##Line", &line, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue);
1538 
1539  // Child 1: no border, enable horizontal scrollbar
1540  {
1542  ImGui::BeginChild("Child1", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f, 260), false, window_flags);
1543  for (int i = 0; i < 100; i++)
1544  {
1545  ImGui::Text("%04d: scrollable region", i);
1546  if (goto_line && line == i)
1548  }
1549  if (goto_line && line >= 100)
1551  ImGui::EndChild();
1552  }
1553 
1554  ImGui::SameLine();
1555 
1556  // Child 2: rounded border
1557  {
1558  ImGuiWindowFlags window_flags = (disable_mouse_wheel ? ImGuiWindowFlags_NoScrollWithMouse : 0) | (disable_menu ? 0 : ImGuiWindowFlags_MenuBar);
1560  ImGui::BeginChild("Child2", ImVec2(0, 260), true, window_flags);
1561  if (!disable_menu && ImGui::BeginMenuBar())
1562  {
1563  if (ImGui::BeginMenu("Menu"))
1564  {
1566  ImGui::EndMenu();
1567  }
1569  }
1570  ImGui::Columns(2);
1571  for (int i = 0; i < 100; i++)
1572  {
1573  char buf[32];
1574  sprintf(buf, "%03d", i);
1575  ImGui::Button(buf, ImVec2(-1.0f, 0.0f));
1577  }
1578  ImGui::EndChild();
1580  }
1581 
1582  ImGui::Separator();
1583 
1584  // Demonstrate a few extra things
1585  // - Changing ImGuiCol_ChildBg (which is transparent black in default styles)
1586  // - Using SetCursorPos() to position the child window (because the child window is an item from the POV of the parent window)
1587  // You can also call SetNextWindowPos() to position the child window. The parent window will effectively layout from this position.
1588  // - Using ImGui::GetItemRectMin/Max() to query the "item" state (because the child window is an item from the POV of the parent window)
1589  // See "Widgets" -> "Querying Status (Active/Focused/Hovered etc.)" section for more details about this.
1590  {
1593  ImGui::BeginChild("blah", ImVec2(200, 100), true, ImGuiWindowFlags_None);
1594  for (int n = 0; n < 50; n++)
1595  ImGui::Text("Some test %d", n);
1596  ImGui::EndChild();
1597  ImVec2 child_rect_min = ImGui::GetItemRectMin();
1598  ImVec2 child_rect_max = ImGui::GetItemRectMax();
1600  ImGui::Text("Rect of child window is: (%.0f,%.0f) (%.0f,%.0f)", child_rect_min.x, child_rect_min.y, child_rect_max.x, child_rect_max.y);
1601  }
1602 
1603  ImGui::TreePop();
1604  }
1605 
1606  if (ImGui::TreeNode("Widgets Width"))
1607  {
1608  static float f = 0.0f;
1609  ImGui::Text("PushItemWidth(100)");
1610  ImGui::SameLine(); ShowHelpMarker("Fixed width.");
1611  ImGui::PushItemWidth(100);
1612  ImGui::DragFloat("float##1", &f);
1614 
1615  ImGui::Text("PushItemWidth(GetWindowWidth() * 0.5f)");
1616  ImGui::SameLine(); ShowHelpMarker("Half of window width.");
1618  ImGui::DragFloat("float##2", &f);
1620 
1621  ImGui::Text("PushItemWidth(GetContentRegionAvailWidth() * 0.5f)");
1622  ImGui::SameLine(); ShowHelpMarker("Half of available width.\n(~ right-cursor_pos)\n(works within a column set)");
1624  ImGui::DragFloat("float##3", &f);
1626 
1627  ImGui::Text("PushItemWidth(-100)");
1628  ImGui::SameLine(); ShowHelpMarker("Align to right edge minus 100");
1629  ImGui::PushItemWidth(-100);
1630  ImGui::DragFloat("float##4", &f);
1632 
1633  ImGui::Text("PushItemWidth(-1)");
1634  ImGui::SameLine(); ShowHelpMarker("Align to right edge");
1636  ImGui::DragFloat("float##5", &f);
1638 
1639  ImGui::TreePop();
1640  }
1641 
1642  if (ImGui::TreeNode("Basic Horizontal Layout"))
1643  {
1644  ImGui::TextWrapped("(Use ImGui::SameLine() to keep adding items to the right of the preceding item)");
1645 
1646  // Text
1647  ImGui::Text("Two items: Hello"); ImGui::SameLine();
1648  ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
1649 
1650  // Adjust spacing
1651  ImGui::Text("More spacing: Hello"); ImGui::SameLine(0, 20);
1652  ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
1653 
1654  // Button
1656  ImGui::Text("Normal buttons"); ImGui::SameLine();
1657  ImGui::Button("Banana"); ImGui::SameLine();
1658  ImGui::Button("Apple"); ImGui::SameLine();
1659  ImGui::Button("Corniflower");
1660 
1661  // Button
1662  ImGui::Text("Small buttons"); ImGui::SameLine();
1663  ImGui::SmallButton("Like this one"); ImGui::SameLine();
1664  ImGui::Text("can fit within a text block.");
1665 
1666  // Aligned to arbitrary position. Easy/cheap column.
1667  ImGui::Text("Aligned");
1668  ImGui::SameLine(150); ImGui::Text("x=150");
1669  ImGui::SameLine(300); ImGui::Text("x=300");
1670  ImGui::Text("Aligned");
1671  ImGui::SameLine(150); ImGui::SmallButton("x=150");
1672  ImGui::SameLine(300); ImGui::SmallButton("x=300");
1673 
1674  // Checkbox
1675  static bool c1 = false, c2 = false, c3 = false, c4 = false;
1676  ImGui::Checkbox("My", &c1); ImGui::SameLine();
1677  ImGui::Checkbox("Tailor", &c2); ImGui::SameLine();
1678  ImGui::Checkbox("Is", &c3); ImGui::SameLine();
1679  ImGui::Checkbox("Rich", &c4);
1680 
1681  // Various
1682  static float f0 = 1.0f, f1 = 2.0f, f2 = 3.0f;
1684  const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD" };
1685  static int item = -1;
1686  ImGui::Combo("Combo", &item, items, IM_ARRAYSIZE(items)); ImGui::SameLine();
1687  ImGui::SliderFloat("X", &f0, 0.0f, 5.0f); ImGui::SameLine();
1688  ImGui::SliderFloat("Y", &f1, 0.0f, 5.0f); ImGui::SameLine();
1689  ImGui::SliderFloat("Z", &f2, 0.0f, 5.0f);
1691 
1693  ImGui::Text("Lists:");
1694  static int selection[4] = { 0, 1, 2, 3 };
1695  for (int i = 0; i < 4; i++)
1696  {
1697  if (i > 0) ImGui::SameLine();
1698  ImGui::PushID(i);
1699  ImGui::ListBox("", &selection[i], items, IM_ARRAYSIZE(items));
1700  ImGui::PopID();
1701  //if (ImGui::IsItemHovered()) ImGui::SetTooltip("ListBox %d hovered", i);
1702  }
1704 
1705  // Dummy
1706  ImVec2 button_sz(40, 40);
1707  ImGui::Button("A", button_sz); ImGui::SameLine();
1708  ImGui::Dummy(button_sz); ImGui::SameLine();
1709  ImGui::Button("B", button_sz);
1710 
1711  // Manually wrapping (we should eventually provide this as an automatic layout feature, but for now you can do it manually)
1712  ImGui::Text("Manually wrapping:");
1713  ImGuiStyle& style = ImGui::GetStyle();
1714  int buttons_count = 20;
1715  float window_visible_x2 = ImGui::GetWindowPos().x + ImGui::GetWindowContentRegionMax().x;
1716  for (int n = 0; n < buttons_count; n++)
1717  {
1718  ImGui::PushID(n);
1719  ImGui::Button("Box", button_sz);
1720  float last_button_x2 = ImGui::GetItemRectMax().x;
1721  float next_button_x2 = last_button_x2 + style.ItemSpacing.x + button_sz.x; // Expected position if next button was on same line
1722  if (n + 1 < buttons_count && next_button_x2 < window_visible_x2)
1723  ImGui::SameLine();
1724  ImGui::PopID();
1725  }
1726 
1727  ImGui::TreePop();
1728  }
1729 
1730  if (ImGui::TreeNode("Tabs"))
1731  {
1732  if (ImGui::TreeNode("Basic"))
1733  {
1734  ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_None;
1735  if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
1736  {
1737  if (ImGui::BeginTabItem("Avocado"))
1738  {
1739  ImGui::Text("This is the Avocado tab!\nblah blah blah blah blah");
1741  }
1742  if (ImGui::BeginTabItem("Broccoli"))
1743  {
1744  ImGui::Text("This is the Broccoli tab!\nblah blah blah blah blah");
1746  }
1747  if (ImGui::BeginTabItem("Cucumber"))
1748  {
1749  ImGui::Text("This is the Cucumber tab!\nblah blah blah blah blah");
1751  }
1752  ImGui::EndTabBar();
1753  }
1754  ImGui::Separator();
1755  ImGui::TreePop();
1756  }
1757 
1758  if (ImGui::TreeNode("Advanced & Close Button"))
1759  {
1760  // Expose a couple of the available flags. In most cases you may just call BeginTabBar() with no flags (0).
1761  static ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_Reorderable;
1762  ImGui::CheckboxFlags("ImGuiTabBarFlags_Reorderable", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_Reorderable);
1763  ImGui::CheckboxFlags("ImGuiTabBarFlags_AutoSelectNewTabs", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_AutoSelectNewTabs);
1764  ImGui::CheckboxFlags("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_NoCloseWithMiddleMouseButton);
1765  if ((tab_bar_flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0)
1766  tab_bar_flags |= ImGuiTabBarFlags_FittingPolicyDefault_;
1767  if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown))
1768  tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyResizeDown);
1769  if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_FittingPolicyScroll))
1770  tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyScroll);
1771 
1772  // Tab Bar
1773  const char* names[4] = { "Artichoke", "Beetroot", "Celery", "Daikon" };
1774  static bool opened[4] = { true, true, true, true }; // Persistent user state
1775  for (int n = 0; n < IM_ARRAYSIZE(opened); n++)
1776  {
1777  if (n > 0) { ImGui::SameLine(); }
1778  ImGui::Checkbox(names[n], &opened[n]);
1779  }
1780 
1781  // Passing a bool* to BeginTabItem() is similar to passing one to Begin(): the underlying bool will be set to false when the tab is closed.
1782  if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
1783  {
1784  for (int n = 0; n < IM_ARRAYSIZE(opened); n++)
1785  if (opened[n] && ImGui::BeginTabItem(names[n], &opened[n]))
1786  {
1787  ImGui::Text("This is the %s tab!", names[n]);
1788  if (n & 1)
1789  ImGui::Text("I am an odd tab.");
1791  }
1792  ImGui::EndTabBar();
1793  }
1794  ImGui::Separator();
1795  ImGui::TreePop();
1796  }
1797  ImGui::TreePop();
1798  }
1799 
1800  if (ImGui::TreeNode("Groups"))
1801  {
1802  ShowHelpMarker("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.");
1804  {
1806  ImGui::Button("AAA");
1807  ImGui::SameLine();
1808  ImGui::Button("BBB");
1809  ImGui::SameLine();
1811  ImGui::Button("CCC");
1812  ImGui::Button("DDD");
1813  ImGui::EndGroup();
1814  ImGui::SameLine();
1815  ImGui::Button("EEE");
1816  ImGui::EndGroup();
1817  if (ImGui::IsItemHovered())
1818  ImGui::SetTooltip("First group hovered");
1819  }
1820  // Capture the group size and create widgets using the same size
1821  ImVec2 size = ImGui::GetItemRectSize();
1822  const float values[5] = { 0.5f, 0.20f, 0.80f, 0.60f, 0.25f };
1823  ImGui::PlotHistogram("##values", values, IM_ARRAYSIZE(values), 0, NULL, 0.0f, 1.0f, size);
1824 
1825  ImGui::Button("ACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x)*0.5f, size.y));
1826  ImGui::SameLine();
1827  ImGui::Button("REACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x)*0.5f, size.y));
1828  ImGui::EndGroup();
1829  ImGui::SameLine();
1830 
1831  ImGui::Button("LEVERAGE\nBUZZWORD", size);
1832  ImGui::SameLine();
1833 
1834  if (ImGui::ListBoxHeader("List", size))
1835  {
1836  ImGui::Selectable("Selected", true);
1837  ImGui::Selectable("Not Selected", false);
1839  }
1840 
1841  ImGui::TreePop();
1842  }
1843 
1844  if (ImGui::TreeNode("Text Baseline Alignment"))
1845  {
1846  ShowHelpMarker("This is testing the vertical alignment that gets applied on text to keep it aligned with widgets. Lines only composed of text or \"small\" widgets fit in less vertical spaces than lines with normal widgets.");
1847 
1848  ImGui::Text("One\nTwo\nThree"); ImGui::SameLine();
1849  ImGui::Text("Hello\nWorld"); ImGui::SameLine();
1850  ImGui::Text("Banana");
1851 
1852  ImGui::Text("Banana"); ImGui::SameLine();
1853  ImGui::Text("Hello\nWorld"); ImGui::SameLine();
1854  ImGui::Text("One\nTwo\nThree");
1855 
1856  ImGui::Button("HOP##1"); ImGui::SameLine();
1857  ImGui::Text("Banana"); ImGui::SameLine();
1858  ImGui::Text("Hello\nWorld"); ImGui::SameLine();
1859  ImGui::Text("Banana");
1860 
1861  ImGui::Button("HOP##2"); ImGui::SameLine();
1862  ImGui::Text("Hello\nWorld"); ImGui::SameLine();
1863  ImGui::Text("Banana");
1864 
1865  ImGui::Button("TEST##1"); ImGui::SameLine();
1866  ImGui::Text("TEST"); ImGui::SameLine();
1867  ImGui::SmallButton("TEST##2");
1868 
1869  ImGui::AlignTextToFramePadding(); // If your line starts with text, call this to align it to upcoming widgets.
1870  ImGui::Text("Text aligned to Widget"); ImGui::SameLine();
1871  ImGui::Button("Widget##1"); ImGui::SameLine();
1872  ImGui::Text("Widget"); ImGui::SameLine();
1873  ImGui::SmallButton("Widget##2"); ImGui::SameLine();
1874  ImGui::Button("Widget##3");
1875 
1876  // Tree
1877  const float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
1878  ImGui::Button("Button##1");
1879  ImGui::SameLine(0.0f, spacing);
1880  if (ImGui::TreeNode("Node##1")) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
1881 
1882  ImGui::AlignTextToFramePadding(); // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. Otherwise you can use SmallButton (smaller fit).
1883  bool node_open = ImGui::TreeNode("Node##2"); // Common mistake to avoid: if we want to SameLine after TreeNode we need to do it before we add child content.
1884  ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##2");
1885  if (node_open) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
1886 
1887  // Bullet
1888  ImGui::Button("Button##3");
1889  ImGui::SameLine(0.0f, spacing);
1890  ImGui::BulletText("Bullet text");
1891 
1893  ImGui::BulletText("Node");
1894  ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##4");
1895 
1896  ImGui::TreePop();
1897  }
1898 
1899  if (ImGui::TreeNode("Scrolling"))
1900  {
1901  ShowHelpMarker("Use SetScrollHereY() or SetScrollFromPosY() to scroll to a given position.");
1902 
1903  static bool track = true;
1904  static int track_line = 50, scroll_to_px = 200;
1905  ImGui::Checkbox("Track", &track);
1906  ImGui::PushItemWidth(100);
1907  ImGui::SameLine(130); track |= ImGui::DragInt("##line", &track_line, 0.25f, 0, 99, "Line = %d");
1908  bool scroll_to = ImGui::Button("Scroll To Pos");
1909  ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "Y = %d px");
1911  if (scroll_to) track = false;
1912 
1913  for (int i = 0; i < 5; i++)
1914  {
1915  if (i > 0) ImGui::SameLine();
1917  ImGui::Text("%s", i == 0 ? "Top" : i == 1 ? "25%" : i == 2 ? "Center" : i == 3 ? "75%" : "Bottom");
1918  ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(ImGui::GetWindowWidth() * 0.17f, 200.0f), true);
1919  if (scroll_to)
1920  ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_px, i * 0.25f);
1921  for (int line = 0; line < 100; line++)
1922  {
1923  if (track && line == track_line)
1924  {
1925  ImGui::TextColored(ImVec4(1,1,0,1), "Line %d", line);
1926  ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
1927  }
1928  else
1929  {
1930  ImGui::Text("Line %d", line);
1931  }
1932  }
1933  float scroll_y = ImGui::GetScrollY(), scroll_max_y = ImGui::GetScrollMaxY();
1934  ImGui::EndChild();
1935  ImGui::Text("%.0f/%0.f", scroll_y, scroll_max_y);
1936  ImGui::EndGroup();
1937  }
1938  ImGui::TreePop();
1939  }
1940 
1941  if (ImGui::TreeNode("Horizontal Scrolling"))
1942  {
1943  ShowHelpMarker("Horizontal scrolling for a window has to be enabled explicitly via the ImGuiWindowFlags_HorizontalScrollbar flag.\n\nYou may want to explicitly specify content width by calling SetNextWindowContentWidth() before Begin().");
1944  static int lines = 7;
1945  ImGui::SliderInt("Lines", &lines, 1, 15);
1949  for (int line = 0; line < lines; line++)
1950  {
1951  // 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
1952  // 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)
1953  int num_buttons = 10 + ((line & 1) ? line * 9 : line * 3);
1954  for (int n = 0; n < num_buttons; n++)
1955  {
1956  if (n > 0) ImGui::SameLine();
1957  ImGui::PushID(n + line * 1000);
1958  char num_buf[16];
1959  sprintf(num_buf, "%d", n);
1960  const char* label = (!(n%15)) ? "FizzBuzz" : (!(n%3)) ? "Fizz" : (!(n%5)) ? "Buzz" : num_buf;
1961  float hue = n*0.05f;
1965  ImGui::Button(label, ImVec2(40.0f + sinf((float)(line + n)) * 20.0f, 0.0f));
1967  ImGui::PopID();
1968  }
1969  }
1970  float scroll_x = ImGui::GetScrollX(), scroll_max_x = ImGui::GetScrollMaxX();
1971  ImGui::EndChild();
1972  ImGui::PopStyleVar(2);
1973  float scroll_x_delta = 0.0f;
1974  ImGui::SmallButton("<<"); if (ImGui::IsItemActive()) scroll_x_delta = -ImGui::GetIO().DeltaTime * 1000.0f; ImGui::SameLine();
1975  ImGui::Text("Scroll from code"); ImGui::SameLine();
1976  ImGui::SmallButton(">>"); if (ImGui::IsItemActive()) scroll_x_delta = +ImGui::GetIO().DeltaTime * 1000.0f; ImGui::SameLine();
1977  ImGui::Text("%.0f/%.0f", scroll_x, scroll_max_x);
1978  if (scroll_x_delta != 0.0f)
1979  {
1980  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)
1981  ImGui::SetScrollX(ImGui::GetScrollX() + scroll_x_delta);
1982  ImGui::End();
1983  }
1984  ImGui::TreePop();
1985  }
1986 
1987  if (ImGui::TreeNode("Clipping"))
1988  {
1989  static ImVec2 size(100, 100), offset(50, 20);
1990  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.");
1991  ImGui::DragFloat2("size", (float*)&size, 0.5f, 1.0f, 200.0f, "%.0f");
1992  ImGui::TextWrapped("(Click and drag)");
1994  ImVec4 clip_rect(pos.x, pos.y, pos.x + size.x, pos.y + size.y);
1995  ImGui::InvisibleButton("##dummy", size);
1997  ImGui::GetWindowDrawList()->AddRectFilled(pos, ImVec2(pos.x + size.x, pos.y + size.y), IM_COL32(90, 90, 120, 255));
1998  ImGui::GetWindowDrawList()->AddText(ImGui::GetFont(), ImGui::GetFontSize()*2.0f, ImVec2(pos.x + offset.x, pos.y + offset.y), IM_COL32(255, 255, 255, 255), "Line 1 hello\nLine 2 clip me!", NULL, 0.0f, &clip_rect);
1999  ImGui::TreePop();
2000  }
2001 }
2002 
2004 {
2005  if (!ImGui::CollapsingHeader("Popups & Modal windows"))
2006  return;
2007 
2008  // The properties of popups windows are:
2009  // - They block normal mouse hovering detection outside them. (*)
2010  // - Unless modal, they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
2011  // - Their visibility state (~bool) is held internally by imgui instead of being held by the programmer as we are used to with regular Begin() calls.
2012  // User can manipulate the visibility state by calling OpenPopup().
2013  // (*) One can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even when normally blocked by a popup.
2014  // Those three properties are connected. The library needs to hold their visibility state because it can close popups at any time.
2015 
2016  // Typical use for regular windows:
2017  // bool my_tool_is_active = false; if (ImGui::Button("Open")) my_tool_is_active = true; [...] if (my_tool_is_active) Begin("My Tool", &my_tool_is_active) { [...] } End();
2018  // Typical use for popups:
2019  // if (ImGui::Button("Open")) ImGui::OpenPopup("MyPopup"); if (ImGui::BeginPopup("MyPopup") { [...] EndPopup(); }
2020 
2021  // With popups we have to go through a library call (here OpenPopup) to manipulate the visibility state.
2022  // This may be a bit confusing at first but it should quickly make sense. Follow on the examples below.
2023 
2024  if (ImGui::TreeNode("Popups"))
2025  {
2026  ImGui::TextWrapped("When a popup is active, it inhibits interacting with windows that are behind the popup. Clicking outside the popup closes it.");
2027 
2028  static int selected_fish = -1;
2029  const char* names[] = { "Bream", "Haddock", "Mackerel", "Pollock", "Tilefish" };
2030  static bool toggles[] = { true, false, false, false, false };
2031 
2032  // Simple selection popup
2033  // (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)
2034  if (ImGui::Button("Select.."))
2035  ImGui::OpenPopup("my_select_popup");
2036  ImGui::SameLine();
2037  ImGui::TextUnformatted(selected_fish == -1 ? "<None>" : names[selected_fish]);
2038  if (ImGui::BeginPopup("my_select_popup"))
2039  {
2040  ImGui::Text("Aquarium");
2041  ImGui::Separator();
2042  for (int i = 0; i < IM_ARRAYSIZE(names); i++)
2043  if (ImGui::Selectable(names[i]))
2044  selected_fish = i;
2045  ImGui::EndPopup();
2046  }
2047 
2048  // Showing a menu with toggles
2049  if (ImGui::Button("Toggle.."))
2050  ImGui::OpenPopup("my_toggle_popup");
2051  if (ImGui::BeginPopup("my_toggle_popup"))
2052  {
2053  for (int i = 0; i < IM_ARRAYSIZE(names); i++)
2054  ImGui::MenuItem(names[i], "", &toggles[i]);
2055  if (ImGui::BeginMenu("Sub-menu"))
2056  {
2057  ImGui::MenuItem("Click me");
2058  ImGui::EndMenu();
2059  }
2060 
2061  ImGui::Separator();
2062  ImGui::Text("Tooltip here");
2063  if (ImGui::IsItemHovered())
2064  ImGui::SetTooltip("I am a tooltip over a popup");
2065 
2066  if (ImGui::Button("Stacked Popup"))
2067  ImGui::OpenPopup("another popup");
2068  if (ImGui::BeginPopup("another popup"))
2069  {
2070  for (int i = 0; i < IM_ARRAYSIZE(names); i++)
2071  ImGui::MenuItem(names[i], "", &toggles[i]);
2072  if (ImGui::BeginMenu("Sub-menu"))
2073  {
2074  ImGui::MenuItem("Click me");
2075  ImGui::EndMenu();
2076  }
2077  ImGui::EndPopup();
2078  }
2079  ImGui::EndPopup();
2080  }
2081 
2082  // Call the more complete ShowExampleMenuFile which we use in various places of this demo
2083  if (ImGui::Button("File Menu.."))
2084  ImGui::OpenPopup("my_file_popup");
2085  if (ImGui::BeginPopup("my_file_popup"))
2086  {
2088  ImGui::EndPopup();
2089  }
2090 
2091  ImGui::TreePop();
2092  }
2093 
2094  if (ImGui::TreeNode("Context menus"))
2095  {
2096  // BeginPopupContextItem() is a helper to provide common/simple popup behavior of essentially doing:
2097  // if (IsItemHovered() && IsMouseReleased(0))
2098  // OpenPopup(id);
2099  // return BeginPopup(id);
2100  // For more advanced uses you may want to replicate and cuztomize this code. This the comments inside BeginPopupContextItem() implementation.
2101  static float value = 0.5f;
2102  ImGui::Text("Value = %.3f (<-- right-click here)", value);
2103  if (ImGui::BeginPopupContextItem("item context menu"))
2104  {
2105  if (ImGui::Selectable("Set to zero")) value = 0.0f;
2106  if (ImGui::Selectable("Set to PI")) value = 3.1415f;
2108  ImGui::DragFloat("##Value", &value, 0.1f, 0.0f, 0.0f);
2110  ImGui::EndPopup();
2111  }
2112 
2113  // We can also use OpenPopupOnItemClick() which is the same as BeginPopupContextItem() but without the Begin call.
2114  // So here we will make it that clicking on the text field with the right mouse button (1) will toggle the visibility of the popup above.
2115  ImGui::Text("(You can also right-click me to the same popup as above.)");
2116  ImGui::OpenPopupOnItemClick("item context menu", 1);
2117 
2118  // When used after an item that has an ID (here the Button), we can skip providing an ID to BeginPopupContextItem().
2119  // BeginPopupContextItem() will use the last item ID as the popup ID.
2120  // In addition here, we want to include your editable label inside the button label. We use the ### operator to override the ID (read FAQ about ID for details)
2121  static char name[32] = "Label1";
2122  char buf[64]; sprintf(buf, "Button: %s###Button", name); // ### operator override ID ignoring the preceding label
2123  ImGui::Button(buf);
2125  {
2126  ImGui::Text("Edit name:");
2127  ImGui::InputText("##edit", name, IM_ARRAYSIZE(name));
2128  if (ImGui::Button("Close"))
2130  ImGui::EndPopup();
2131  }
2132  ImGui::SameLine(); ImGui::Text("(<-- right-click here)");
2133 
2134  ImGui::TreePop();
2135  }
2136 
2137  if (ImGui::TreeNode("Modals"))
2138  {
2139  ImGui::TextWrapped("Modal windows are like popups but the user cannot close them by clicking outside the window.");
2140 
2141  if (ImGui::Button("Delete.."))
2142  ImGui::OpenPopup("Delete?");
2143 
2145  {
2146  ImGui::Text("All those beautiful files will be deleted.\nThis operation cannot be undone!\n\n");
2147  ImGui::Separator();
2148 
2149  //static int dummy_i = 0;
2150  //ImGui::Combo("Combo", &dummy_i, "Delete\0Delete harder\0");
2151 
2152  static bool dont_ask_me_next_time = false;
2154  ImGui::Checkbox("Don't ask me next time", &dont_ask_me_next_time);
2156 
2157  if (ImGui::Button("OK", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); }
2159  ImGui::SameLine();
2160  if (ImGui::Button("Cancel", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); }
2161  ImGui::EndPopup();
2162  }
2163 
2164  if (ImGui::Button("Stacked modals.."))
2165  ImGui::OpenPopup("Stacked 1");
2166  if (ImGui::BeginPopupModal("Stacked 1"))
2167  {
2168  ImGui::Text("Hello from Stacked The First\nUsing style.Colors[ImGuiCol_ModalWindowDimBg] behind it.");
2169  static int item = 1;
2170  ImGui::Combo("Combo", &item, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
2171  static float color[4] = { 0.4f,0.7f,0.0f,0.5f };
2172  ImGui::ColorEdit4("color", color); // This is to test behavior of stacked regular popups over a modal
2173 
2174  if (ImGui::Button("Add another modal.."))
2175  ImGui::OpenPopup("Stacked 2");
2176 
2177  // Also demonstrate passing a bool* to BeginPopupModal(), this will create a regular close button which will close the popup.
2178  // Note that the visibility state of popups is owned by imgui, so the input value of the bool actually doesn't matter here.
2179  bool dummy_open = true;
2180  if (ImGui::BeginPopupModal("Stacked 2", &dummy_open))
2181  {
2182  ImGui::Text("Hello from Stacked The Second!");
2183  if (ImGui::Button("Close"))
2185  ImGui::EndPopup();
2186  }
2187 
2188  if (ImGui::Button("Close"))
2190  ImGui::EndPopup();
2191  }
2192 
2193  ImGui::TreePop();
2194  }
2195 
2196  if (ImGui::TreeNode("Menus inside a regular window"))
2197  {
2198  ImGui::TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!");
2199  ImGui::Separator();
2200  // 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.
2201  // 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
2202  // 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.
2203  ImGui::PushID("foo");
2204  ImGui::MenuItem("Menu item", "CTRL+M");
2205  if (ImGui::BeginMenu("Menu inside a regular window"))
2206  {
2208  ImGui::EndMenu();
2209  }
2210  ImGui::PopID();
2211  ImGui::Separator();
2212  ImGui::TreePop();
2213  }
2214 }
2215 
2217 {
2218  if (!ImGui::CollapsingHeader("Columns"))
2219  return;
2220 
2221  ImGui::PushID("Columns");
2222 
2223  // Basic columns
2224  if (ImGui::TreeNode("Basic"))
2225  {
2226  ImGui::Text("Without border:");
2227  ImGui::Columns(3, "mycolumns3", false); // 3-ways, no border
2228  ImGui::Separator();
2229  for (int n = 0; n < 14; n++)
2230  {
2231  char label[32];
2232  sprintf(label, "Item %d", n);
2233  if (ImGui::Selectable(label)) {}
2234  //if (ImGui::Button(label, ImVec2(-1,0))) {}
2236  }
2237  ImGui::Columns(1);
2238  ImGui::Separator();
2239 
2240  ImGui::Text("With border:");
2241  ImGui::Columns(4, "mycolumns"); // 4-ways, with border
2242  ImGui::Separator();
2243  ImGui::Text("ID"); ImGui::NextColumn();
2244  ImGui::Text("Name"); ImGui::NextColumn();
2245  ImGui::Text("Path"); ImGui::NextColumn();
2246  ImGui::Text("Hovered"); ImGui::NextColumn();
2247  ImGui::Separator();
2248  const char* names[3] = { "One", "Two", "Three" };
2249  const char* paths[3] = { "/path/one", "/path/two", "/path/three" };
2250  static int selected = -1;
2251  for (int i = 0; i < 3; i++)
2252  {
2253  char label[32];
2254  sprintf(label, "%04d", i);
2255  if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
2256  selected = i;
2257  bool hovered = ImGui::IsItemHovered();
2259  ImGui::Text(names[i]); ImGui::NextColumn();
2260  ImGui::Text(paths[i]); ImGui::NextColumn();
2261  ImGui::Text("%d", hovered); ImGui::NextColumn();
2262  }
2263  ImGui::Columns(1);
2264  ImGui::Separator();
2265  ImGui::TreePop();
2266  }
2267 
2268  // Create multiple items in a same cell before switching to next column
2269  if (ImGui::TreeNode("Mixed items"))
2270  {
2271  ImGui::Columns(3, "mixed");
2272  ImGui::Separator();
2273 
2274  ImGui::Text("Hello");
2275  ImGui::Button("Banana");
2277 
2278  ImGui::Text("ImGui");
2279  ImGui::Button("Apple");
2280  static float foo = 1.0f;
2281  ImGui::InputFloat("red", &foo, 0.05f, 0, "%.3f");
2282  ImGui::Text("An extra line here.");
2284 
2285  ImGui::Text("Sailor");
2286  ImGui::Button("Corniflower");
2287  static float bar = 1.0f;
2288  ImGui::InputFloat("blue", &bar, 0.05f, 0, "%.3f");
2290 
2291  if (ImGui::CollapsingHeader("Category A")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
2292  if (ImGui::CollapsingHeader("Category B")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
2293  if (ImGui::CollapsingHeader("Category C")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
2294  ImGui::Columns(1);
2295  ImGui::Separator();
2296  ImGui::TreePop();
2297  }
2298 
2299  // Word wrapping
2300  if (ImGui::TreeNode("Word-wrapping"))
2301  {
2302  ImGui::Columns(2, "word-wrapping");
2303  ImGui::Separator();
2304  ImGui::TextWrapped("The quick brown fox jumps over the lazy dog.");
2305  ImGui::TextWrapped("Hello Left");
2307  ImGui::TextWrapped("The quick brown fox jumps over the lazy dog.");
2308  ImGui::TextWrapped("Hello Right");
2309  ImGui::Columns(1);
2310  ImGui::Separator();
2311  ImGui::TreePop();
2312  }
2313 
2314  if (ImGui::TreeNode("Borders"))
2315  {
2316  // NB: Future columns API should allow automatic horizontal borders.
2317  static bool h_borders = true;
2318  static bool v_borders = true;
2319  ImGui::Checkbox("horizontal", &h_borders);
2320  ImGui::SameLine();
2321  ImGui::Checkbox("vertical", &v_borders);
2322  ImGui::Columns(4, NULL, v_borders);
2323  for (int i = 0; i < 4*3; i++)
2324  {
2325  if (h_borders && ImGui::GetColumnIndex() == 0)
2326  ImGui::Separator();
2327  ImGui::Text("%c%c%c", 'a'+i, 'a'+i, 'a'+i);
2328  ImGui::Text("Width %.2f\nOffset %.2f", ImGui::GetColumnWidth(), ImGui::GetColumnOffset());
2330  }
2331  ImGui::Columns(1);
2332  if (h_borders)
2333  ImGui::Separator();
2334  ImGui::TreePop();
2335  }
2336 
2337  // Scrolling columns
2338  /*
2339  if (ImGui::TreeNode("Vertical Scrolling"))
2340  {
2341  ImGui::BeginChild("##header", ImVec2(0, ImGui::GetTextLineHeightWithSpacing()+ImGui::GetStyle().ItemSpacing.y));
2342  ImGui::Columns(3);
2343  ImGui::Text("ID"); ImGui::NextColumn();
2344  ImGui::Text("Name"); ImGui::NextColumn();
2345  ImGui::Text("Path"); ImGui::NextColumn();
2346  ImGui::Columns(1);
2347  ImGui::Separator();
2348  ImGui::EndChild();
2349  ImGui::BeginChild("##scrollingregion", ImVec2(0, 60));
2350  ImGui::Columns(3);
2351  for (int i = 0; i < 10; i++)
2352  {
2353  ImGui::Text("%04d", i); ImGui::NextColumn();
2354  ImGui::Text("Foobar"); ImGui::NextColumn();
2355  ImGui::Text("/path/foobar/%04d/", i); ImGui::NextColumn();
2356  }
2357  ImGui::Columns(1);
2358  ImGui::EndChild();
2359  ImGui::TreePop();
2360  }
2361  */
2362 
2363  if (ImGui::TreeNode("Horizontal Scrolling"))
2364  {
2366  ImGui::BeginChild("##ScrollingRegion", ImVec2(0, ImGui::GetFontSize() * 20), false, ImGuiWindowFlags_HorizontalScrollbar);
2367  ImGui::Columns(10);
2368  int ITEMS_COUNT = 2000;
2369  ImGuiListClipper clipper(ITEMS_COUNT); // Also demonstrate using the clipper for large list
2370  while (clipper.Step())
2371  {
2372  for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
2373  for (int j = 0; j < 10; j++)
2374  {
2375  ImGui::Text("Line %d Column %d...", i, j);
2377  }
2378  }
2379  ImGui::Columns(1);
2380  ImGui::EndChild();
2381  ImGui::TreePop();
2382  }
2383 
2384  bool node_open = ImGui::TreeNode("Tree within single cell");
2385  ImGui::SameLine(); ShowHelpMarker("NB: Tree node must be poped before ending the cell. There's no storage of state per-cell.");
2386  if (node_open)
2387  {
2388  ImGui::Columns(2, "tree items");
2389  ImGui::Separator();
2390  if (ImGui::TreeNode("Hello")) { ImGui::BulletText("Sailor"); ImGui::TreePop(); } ImGui::NextColumn();
2391  if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Marin"); ImGui::TreePop(); } ImGui::NextColumn();
2392  ImGui::Columns(1);
2393  ImGui::Separator();
2394  ImGui::TreePop();
2395  }
2396  ImGui::PopID();
2397 }
2398 
2399 static void ShowDemoWindowMisc()
2400 {
2401  if (ImGui::CollapsingHeader("Filtering"))
2402  {
2403  static ImGuiTextFilter filter;
2404  ImGui::Text("Filter usage:\n"
2405  " \"\" display all lines\n"
2406  " \"xxx\" display lines containing \"xxx\"\n"
2407  " \"xxx,yyy\" display lines containing \"xxx\" or \"yyy\"\n"
2408  " \"-xxx\" hide lines containing \"xxx\"");
2409  filter.Draw();
2410  const char* lines[] = { "aaa1.c", "bbb1.c", "ccc1.c", "aaa2.cpp", "bbb2.cpp", "ccc2.cpp", "abc.h", "hello, world" };
2411  for (int i = 0; i < IM_ARRAYSIZE(lines); i++)
2412  if (filter.PassFilter(lines[i]))
2413  ImGui::BulletText("%s", lines[i]);
2414  }
2415 
2416  if (ImGui::CollapsingHeader("Inputs, Navigation & Focus"))
2417  {
2418  ImGuiIO& io = ImGui::GetIO();
2419 
2420  ImGui::Text("WantCaptureMouse: %d", io.WantCaptureMouse);
2421  ImGui::Text("WantCaptureKeyboard: %d", io.WantCaptureKeyboard);
2422  ImGui::Text("WantTextInput: %d", io.WantTextInput);
2423  ImGui::Text("WantSetMousePos: %d", io.WantSetMousePos);
2424  ImGui::Text("NavActive: %d, NavVisible: %d", io.NavActive, io.NavVisible);
2425 
2426  if (ImGui::TreeNode("Keyboard, Mouse & Navigation State"))
2427  {
2428  if (ImGui::IsMousePosValid())
2429  ImGui::Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y);
2430  else
2431  ImGui::Text("Mouse pos: <INVALID>");
2432  ImGui::Text("Mouse delta: (%g, %g)", io.MouseDelta.x, io.MouseDelta.y);
2433  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]); }
2434  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); }
2435  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); }
2436  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); }
2437  ImGui::Text("Mouse wheel: %.1f", io.MouseWheel);
2438 
2439  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]); }
2440  ImGui::Text("Keys pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyPressed(i)) { ImGui::SameLine(); ImGui::Text("%d", i); }
2441  ImGui::Text("Keys release:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyReleased(i)) { ImGui::SameLine(); ImGui::Text("%d", i); }
2442  ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
2443 
2444  ImGui::Text("NavInputs down:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputs[i] > 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f", i, io.NavInputs[i]); }
2445  ImGui::Text("NavInputs pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputsDownDuration[i] == 0.0f) { ImGui::SameLine(); ImGui::Text("[%d]", i); }
2446  ImGui::Text("NavInputs duration:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputsDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f", i, io.NavInputsDownDuration[i]); }
2447 
2448  ImGui::Button("Hovering me sets the\nkeyboard capture flag");
2449  if (ImGui::IsItemHovered())
2451  ImGui::SameLine();
2452  ImGui::Button("Holding me clears the\nthe keyboard capture flag");
2453  if (ImGui::IsItemActive())
2455 
2456  ImGui::TreePop();
2457  }
2458 
2459  if (ImGui::TreeNode("Tabbing"))
2460  {
2461  ImGui::Text("Use TAB/SHIFT+TAB to cycle through keyboard editable fields.");
2462  static char buf[32] = "dummy";
2463  ImGui::InputText("1", buf, IM_ARRAYSIZE(buf));
2464  ImGui::InputText("2", buf, IM_ARRAYSIZE(buf));
2465  ImGui::InputText("3", buf, IM_ARRAYSIZE(buf));
2467  ImGui::InputText("4 (tab skip)", buf, IM_ARRAYSIZE(buf));
2468  //ImGui::SameLine(); ShowHelperMarker("Use ImGui::PushAllowKeyboardFocus(bool)\nto disable tabbing through certain widgets.");
2470  ImGui::InputText("5", buf, IM_ARRAYSIZE(buf));
2471  ImGui::TreePop();
2472  }
2473 
2474  if (ImGui::TreeNode("Focus from code"))
2475  {
2476  bool focus_1 = ImGui::Button("Focus on 1"); ImGui::SameLine();
2477  bool focus_2 = ImGui::Button("Focus on 2"); ImGui::SameLine();
2478  bool focus_3 = ImGui::Button("Focus on 3");
2479  int has_focus = 0;
2480  static char buf[128] = "click on a button to set focus";
2481 
2482  if (focus_1) ImGui::SetKeyboardFocusHere();
2483  ImGui::InputText("1", buf, IM_ARRAYSIZE(buf));
2484  if (ImGui::IsItemActive()) has_focus = 1;
2485 
2486  if (focus_2) ImGui::SetKeyboardFocusHere();
2487  ImGui::InputText("2", buf, IM_ARRAYSIZE(buf));
2488  if (ImGui::IsItemActive()) has_focus = 2;
2489 
2491  if (focus_3) ImGui::SetKeyboardFocusHere();
2492  ImGui::InputText("3 (tab skip)", buf, IM_ARRAYSIZE(buf));
2493  if (ImGui::IsItemActive()) has_focus = 3;
2495 
2496  if (has_focus)
2497  ImGui::Text("Item with focus: %d", has_focus);
2498  else
2499  ImGui::Text("Item with focus: <none>");
2500 
2501  // Use >= 0 parameter to SetKeyboardFocusHere() to focus an upcoming item
2502  static float f3[3] = { 0.0f, 0.0f, 0.0f };
2503  int focus_ahead = -1;
2504  if (ImGui::Button("Focus on X")) focus_ahead = 0; ImGui::SameLine();
2505  if (ImGui::Button("Focus on Y")) focus_ahead = 1; ImGui::SameLine();
2506  if (ImGui::Button("Focus on Z")) focus_ahead = 2;
2507  if (focus_ahead != -1) ImGui::SetKeyboardFocusHere(focus_ahead);
2508  ImGui::SliderFloat3("Float3", &f3[0], 0.0f, 1.0f);
2509 
2510  ImGui::TextWrapped("NB: Cursor & selection are preserved when refocusing last used item in code.");
2511  ImGui::TreePop();
2512  }
2513 
2514  if (ImGui::TreeNode("Dragging"))
2515  {
2516  ImGui::TextWrapped("You can use ImGui::GetMouseDragDelta(0) to query for the dragged amount on any widget.");
2517  for (int button = 0; button < 3; button++)
2518  ImGui::Text("IsMouseDragging(%d):\n w/ default threshold: %d,\n w/ zero threshold: %d\n w/ large threshold: %d",
2519  button, ImGui::IsMouseDragging(button), ImGui::IsMouseDragging(button, 0.0f), ImGui::IsMouseDragging(button, 20.0f));
2520  ImGui::Button("Drag Me");
2521  if (ImGui::IsItemActive())
2522  {
2523  // Draw a line between the button and the mouse cursor
2524  ImDrawList* draw_list = ImGui::GetWindowDrawList();
2525  draw_list->PushClipRectFullScreen();
2526  draw_list->AddLine(io.MouseClickedPos[0], io.MousePos, ImGui::GetColorU32(ImGuiCol_Button), 4.0f);
2527  draw_list->PopClipRect();
2528 
2529  // Drag operations gets "unlocked" when the mouse has moved past a certain threshold (the default threshold is stored in io.MouseDragThreshold)
2530  // You can request a lower or higher threshold using the second parameter of IsMouseDragging() and GetMouseDragDelta()
2531  ImVec2 value_raw = ImGui::GetMouseDragDelta(0, 0.0f);
2532  ImVec2 value_with_lock_threshold = ImGui::GetMouseDragDelta(0);
2533  ImVec2 mouse_delta = io.MouseDelta;
2534  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);
2535  }
2536  ImGui::TreePop();
2537  }
2538 
2539  if (ImGui::TreeNode("Mouse cursors"))
2540  {
2541  const char* mouse_cursors_names[] = { "Arrow", "TextInput", "Move", "ResizeNS", "ResizeEW", "ResizeNESW", "ResizeNWSE", "Hand" };
2542  IM_ASSERT(IM_ARRAYSIZE(mouse_cursors_names) == ImGuiMouseCursor_COUNT);
2543 
2544  ImGui::Text("Current mouse cursor = %d: %s", ImGui::GetMouseCursor(), mouse_cursors_names[ImGui::GetMouseCursor()]);
2545  ImGui::Text("Hover to see mouse cursors:");
2546  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.");
2547  for (int i = 0; i < ImGuiMouseCursor_COUNT; i++)
2548  {
2549  char label[32];
2550  sprintf(label, "Mouse cursor %d: %s", i, mouse_cursors_names[i]);
2551  ImGui::Bullet(); ImGui::Selectable(label, false);
2554  }
2555  ImGui::TreePop();
2556  }
2557  }
2558 }
2559 
2560 //-----------------------------------------------------------------------------
2561 // [SECTION] About Window / ShowAboutWindow()
2562 // Access from ImGui Demo -> Help -> About
2563 //-----------------------------------------------------------------------------
2564 
2565 void ImGui::ShowAboutWindow(bool* p_open)
2566 {
2567  if (!ImGui::Begin("About Dear ImGui", p_open, ImGuiWindowFlags_AlwaysAutoResize))
2568  {
2569  ImGui::End();
2570  return;
2571  }
2572  ImGui::Text("Dear ImGui %s", ImGui::GetVersion());
2573  ImGui::Separator();
2574  ImGui::Text("By Omar Cornut and all dear imgui contributors.");
2575  ImGui::Text("Dear ImGui is licensed under the MIT License, see LICENSE for more information.");
2576 
2577  static bool show_config_info = false;
2578  ImGui::Checkbox("Config/Build Information", &show_config_info);
2579  if (show_config_info)
2580  {
2581  ImGuiIO& io = ImGui::GetIO();
2582  ImGuiStyle& style = ImGui::GetStyle();
2583 
2584  bool copy_to_clipboard = ImGui::Button("Copy to clipboard");
2586  if (copy_to_clipboard)
2588 
2589  ImGui::Text("Dear ImGui %s (%d)", IMGUI_VERSION, IMGUI_VERSION_NUM);
2590  ImGui::Separator();
2591  ImGui::Text("sizeof(size_t): %d, sizeof(ImDrawIdx): %d, sizeof(ImDrawVert): %d", (int)sizeof(size_t), (int)sizeof(ImDrawIdx), (int)sizeof(ImDrawVert));
2592  ImGui::Text("define: __cplusplus=%d", (int)__cplusplus);
2593 #ifdef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
2594  ImGui::Text("define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS");
2595 #endif
2596 #ifdef IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS
2597  ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS");
2598 #endif
2599 #ifdef IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS
2600  ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS");
2601 #endif
2602 #ifdef IMGUI_DISABLE_WIN32_FUNCTIONS
2603  ImGui::Text("define: IMGUI_DISABLE_WIN32_FUNCTIONS");
2604 #endif
2605 #ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
2606  ImGui::Text("define: IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS");
2607 #endif
2608 #ifdef IMGUI_DISABLE_MATH_FUNCTIONS
2609  ImGui::Text("define: IMGUI_DISABLE_MATH_FUNCTIONS");
2610 #endif
2611 #ifdef IMGUI_DISABLE_DEFAULT_ALLOCATORS
2612  ImGui::Text("define: IMGUI_DISABLE_DEFAULT_ALLOCATORS");
2613 #endif
2614 #ifdef IMGUI_USE_BGRA_PACKED_COLOR
2615  ImGui::Text("define: IMGUI_USE_BGRA_PACKED_COLOR");
2616 #endif
2617 #ifdef _WIN32
2618  ImGui::Text("define: _WIN32");
2619 #endif
2620 #ifdef _WIN64
2621  ImGui::Text("define: _WIN64");
2622 #endif
2623 #ifdef __linux__
2624  ImGui::Text("define: __linux__");
2625 #endif
2626 #ifdef __APPLE__
2627  ImGui::Text("define: __APPLE__");
2628 #endif
2629 #ifdef _MSC_VER
2630  ImGui::Text("define: _MSC_VER=%d", _MSC_VER);
2631 #endif
2632 #ifdef __MINGW32__
2633  ImGui::Text("define: __MINGW32__");
2634 #endif
2635 #ifdef __MINGW64__
2636  ImGui::Text("define: __MINGW64__");
2637 #endif
2638 #ifdef __GNUC__
2639  ImGui::Text("define: __GNUC__=%d", (int)__GNUC__);
2640 #endif
2641 #ifdef __clang_version__
2642  ImGui::Text("define: __clang_version__=%s", __clang_version__);
2643 #endif
2644  ImGui::Separator();
2645  ImGui::Text("io.BackendPlatformName: %s", io.BackendPlatformName ? io.BackendPlatformName : "NULL");
2646  ImGui::Text("io.BackendRendererName: %s", io.BackendRendererName ? io.BackendRendererName : "NULL");
2647  ImGui::Text("io.ConfigFlags: 0x%08X", io.ConfigFlags);
2648  if (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) ImGui::Text(" NavEnableKeyboard");
2649  if (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) ImGui::Text(" NavEnableGamepad");
2650  if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) ImGui::Text(" NavEnableSetMousePos");
2651  if (io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard) ImGui::Text(" NavNoCaptureKeyboard");
2652  if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) ImGui::Text(" NoMouse");
2653  if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) ImGui::Text(" NoMouseCursorChange");
2654  if (io.MouseDrawCursor) ImGui::Text("io.MouseDrawCursor");
2655  if (io.ConfigMacOSXBehaviors) ImGui::Text("io.ConfigMacOSXBehaviors");
2656  if (io.ConfigInputTextCursorBlink) ImGui::Text("io.ConfigInputTextCursorBlink");
2657  if (io.ConfigWindowsResizeFromEdges) ImGui::Text("io.ConfigWindowsResizeFromEdges");
2658  if (io.ConfigWindowsMoveFromTitleBarOnly) ImGui::Text("io.ConfigWindowsMoveFromTitleBarOnly");
2659  ImGui::Text("io.BackendFlags: 0x%08X", io.BackendFlags);
2660  if (io.BackendFlags & ImGuiBackendFlags_HasGamepad) ImGui::Text(" HasGamepad");
2661  if (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) ImGui::Text(" HasMouseCursors");
2662  if (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos) ImGui::Text(" HasSetMousePos");
2663  ImGui::Separator();
2664  ImGui::Text("io.Fonts: %d fonts, Flags: 0x%08X, TexSize: %d,%d", io.Fonts->Fonts.Size, io.Fonts->Flags, io.Fonts->TexWidth, io.Fonts->TexHeight);
2665  ImGui::Text("io.DisplaySize: %.2f,%.2f", io.DisplaySize.x, io.DisplaySize.y);
2666  ImGui::Separator();
2667  ImGui::Text("style.WindowPadding: %.2f,%.2f", style.WindowPadding.x, style.WindowPadding.y);
2668  ImGui::Text("style.WindowBorderSize: %.2f", style.WindowBorderSize);
2669  ImGui::Text("style.FramePadding: %.2f,%.2f", style.FramePadding.x, style.FramePadding.y);
2670  ImGui::Text("style.FrameRounding: %.2f", style.FrameRounding);
2671  ImGui::Text("style.FrameBorderSize: %.2f", style.FrameBorderSize);
2672  ImGui::Text("style.ItemSpacing: %.2f,%.2f", style.ItemSpacing.x, style.ItemSpacing.y);
2673  ImGui::Text("style.ItemInnerSpacing: %.2f,%.2f", style.ItemInnerSpacing.x, style.ItemInnerSpacing.y);
2674 
2675  if (copy_to_clipboard)
2676  ImGui::LogFinish();
2678  }
2679  ImGui::End();
2680 }
2681 
2682 //-----------------------------------------------------------------------------
2683 // [SECTION] Style Editor / ShowStyleEditor()
2684 //-----------------------------------------------------------------------------
2685 
2686 // Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options.
2687 // Here we use the simplified Combo() api that packs items into a single literal string. Useful for quick combo boxes where the choices are known locally.
2688 bool ImGui::ShowStyleSelector(const char* label)
2689 {
2690  static int style_idx = -1;
2691  if (ImGui::Combo(label, &style_idx, "Classic\0Dark\0Light\0"))
2692  {
2693  switch (style_idx)
2694  {
2695  case 0: ImGui::StyleColorsClassic(); break;
2696  case 1: ImGui::StyleColorsDark(); break;
2697  case 2: ImGui::StyleColorsLight(); break;
2698  }
2699  return true;
2700  }
2701  return false;
2702 }
2703 
2704 // Demo helper function to select among loaded fonts.
2705 // Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one.
2706 void ImGui::ShowFontSelector(const char* label)
2707 {
2708  ImGuiIO& io = ImGui::GetIO();
2709  ImFont* font_current = ImGui::GetFont();
2710  if (ImGui::BeginCombo(label, font_current->GetDebugName()))
2711  {
2712  for (int n = 0; n < io.Fonts->Fonts.Size; n++)
2713  if (ImGui::Selectable(io.Fonts->Fonts[n]->GetDebugName(), io.Fonts->Fonts[n] == font_current))
2714  io.FontDefault = io.Fonts->Fonts[n];
2715  ImGui::EndCombo();
2716  }
2717  ImGui::SameLine();
2719  "- Load additional fonts with io.Fonts->AddFontFromFileTTF().\n"
2720  "- The font atlas is built when calling io.Fonts->GetTexDataAsXXXX() or io.Fonts->Build().\n"
2721  "- Read FAQ and documentation in misc/fonts/ for more details.\n"
2722  "- If you need to add/remove fonts at runtime (e.g. for DPI change), do it before calling NewFrame().");
2723 }
2724 
2726 {
2727  // You can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it compares to an internally stored reference)
2728  ImGuiStyle& style = ImGui::GetStyle();
2729  static ImGuiStyle ref_saved_style;
2730 
2731  // Default to using internal storage as reference
2732  static bool init = true;
2733  if (init && ref == NULL)
2734  ref_saved_style = style;
2735  init = false;
2736  if (ref == NULL)
2737  ref = &ref_saved_style;
2738 
2740 
2741  if (ImGui::ShowStyleSelector("Colors##Selector"))
2742  ref_saved_style = style;
2743  ImGui::ShowFontSelector("Fonts##Selector");
2744 
2745  // Simplified Settings
2746  if (ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"))
2747  style.GrabRounding = style.FrameRounding; // Make GrabRounding always the same value as FrameRounding
2748  { bool window_border = (style.WindowBorderSize > 0.0f); if (ImGui::Checkbox("WindowBorder", &window_border)) style.WindowBorderSize = window_border ? 1.0f : 0.0f; }
2749  ImGui::SameLine();
2750  { bool frame_border = (style.FrameBorderSize > 0.0f); if (ImGui::Checkbox("FrameBorder", &frame_border)) style.FrameBorderSize = frame_border ? 1.0f : 0.0f; }
2751  ImGui::SameLine();
2752  { bool popup_border = (style.PopupBorderSize > 0.0f); if (ImGui::Checkbox("PopupBorder", &popup_border)) style.PopupBorderSize = popup_border ? 1.0f : 0.0f; }
2753 
2754  // Save/Revert button
2755  if (ImGui::Button("Save Ref"))
2756  *ref = ref_saved_style = style;
2757  ImGui::SameLine();
2758  if (ImGui::Button("Revert Ref"))
2759  style = *ref;
2760  ImGui::SameLine();
2761  ShowHelpMarker("Save/Revert in local non-persistent storage. Default Colors definition are not affected. Use \"Export Colors\" below to save them somewhere.");
2762 
2763  ImGui::Separator();
2764 
2766  {
2767  if (ImGui::BeginTabItem("Sizes"))
2768  {
2769  ImGui::Text("Main");
2770  ImGui::SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f");
2771  ImGui::SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 16.0f, "%.0f");
2772  ImGui::SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f");
2773  ImGui::SliderFloat2("ItemSpacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f");
2774  ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f");
2775  ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f");
2776  ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f");
2777  ImGui::SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f");
2778  ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f");
2779  ImGui::Text("Borders");
2780  ImGui::SliderFloat("WindowBorderSize", &style.WindowBorderSize, 0.0f, 1.0f, "%.0f");
2781  ImGui::SliderFloat("ChildBorderSize", &style.ChildBorderSize, 0.0f, 1.0f, "%.0f");
2782  ImGui::SliderFloat("PopupBorderSize", &style.PopupBorderSize, 0.0f, 1.0f, "%.0f");
2783  ImGui::SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f, "%.0f");
2784  ImGui::SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f");
2785  ImGui::Text("Rounding");
2786  ImGui::SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 14.0f, "%.0f");
2787  ImGui::SliderFloat("ChildRounding", &style.ChildRounding, 0.0f, 16.0f, "%.0f");
2788  ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f");
2789  ImGui::SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f");
2790  ImGui::SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f");
2791  ImGui::SliderFloat("TabRounding", &style.TabRounding, 0.0f, 12.0f, "%.0f");
2792  ImGui::Text("Alignment");
2793  ImGui::SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f");
2794  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.");
2795  ImGui::Text("Safe Area Padding"); ImGui::SameLine(); ShowHelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).");
2796  ImGui::SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f");
2798  }
2799 
2800  if (ImGui::BeginTabItem("Colors"))
2801  {
2802  static int output_dest = 0;
2803  static bool output_only_modified = true;
2804  if (ImGui::Button("Export Unsaved"))
2805  {
2806  if (output_dest == 0)
2808  else
2809  ImGui::LogToTTY();
2810  ImGui::LogText("ImVec4* colors = ImGui::GetStyle().Colors;" IM_NEWLINE);
2811  for (int i = 0; i < ImGuiCol_COUNT; i++)
2812  {
2813  const ImVec4& col = style.Colors[i];
2814  const char* name = ImGui::GetStyleColorName(i);
2815  if (!output_only_modified || memcmp(&col, &ref->Colors[i], sizeof(ImVec4)) != 0)
2816  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);
2817  }
2818  ImGui::LogFinish();
2819  }
2820  ImGui::SameLine(); ImGui::PushItemWidth(120); ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0"); ImGui::PopItemWidth();
2821  ImGui::SameLine(); ImGui::Checkbox("Only Modified Colors", &output_only_modified);
2822 
2823  static ImGuiTextFilter filter;
2824  filter.Draw("Filter colors", ImGui::GetFontSize() * 16);
2825 
2826  static ImGuiColorEditFlags alpha_flags = 0;
2827  ImGui::RadioButton("Opaque", &alpha_flags, 0); ImGui::SameLine();
2830  ShowHelpMarker("In the color list:\nLeft-click on colored square to open color picker,\nRight-click to open edit options menu.");
2831 
2833  ImGui::PushItemWidth(-160);
2834  for (int i = 0; i < ImGuiCol_COUNT; i++)
2835  {
2836  const char* name = ImGui::GetStyleColorName(i);
2837  if (!filter.PassFilter(name))
2838  continue;
2839  ImGui::PushID(i);
2840  ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags);
2841  if (memcmp(&style.Colors[i], &ref->Colors[i], sizeof(ImVec4)) != 0)
2842  {
2843  // Tips: in a real user application, you may want to merge and use an icon font into the main font, so instead of "Save"/"Revert" you'd use icons.
2844  // Read the FAQ and misc/fonts/README.txt about using icon fonts. It's really easy and super convenient!
2845  ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Save")) ref->Colors[i] = style.Colors[i];
2846  ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Revert")) style.Colors[i] = ref->Colors[i];
2847  }
2848  ImGui::SameLine(0.0f, style.ItemInnerSpacing.x);
2849  ImGui::TextUnformatted(name);
2850  ImGui::PopID();
2851  }
2853  ImGui::EndChild();
2854 
2856  }
2857 
2858  if (ImGui::BeginTabItem("Fonts"))
2859  {
2860  ImFontAtlas* atlas = ImGui::GetIO().Fonts;
2861  ShowHelpMarker("Read FAQ and misc/fonts/README.txt for details on font loading.");
2862  ImGui::PushItemWidth(120);
2863  for (int i = 0; i < atlas->Fonts.Size; i++)
2864  {
2865  ImFont* font = atlas->Fonts[i];
2866  ImGui::PushID(font);
2867  bool font_details_opened = ImGui::TreeNode(font, "Font %d: \"%s\"\n%.2f px, %d glyphs, %d file(s)", i, font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount);
2868  ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) ImGui::GetIO().FontDefault = font;
2869  if (font_details_opened)
2870  {
2871  ImGui::PushFont(font);
2872  ImGui::Text("The quick brown fox jumps over the lazy dog");
2873  ImGui::PopFont();
2874  ImGui::DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); // Scale only this font
2875  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.)");
2876  ImGui::InputFloat("Font offset", &font->DisplayOffset.y, 1, 1, "%.0f");
2877  ImGui::Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent);
2878  ImGui::Text("Fallback character: '%c' (%d)", font->FallbackChar, font->FallbackChar);
2879  ImGui::Text("Texture surface: %d pixels (approx) ~ %dx%d", font->MetricsTotalSurface, (int)sqrtf((float)font->MetricsTotalSurface), (int)sqrtf((float)font->MetricsTotalSurface));
2880  for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
2881  if (ImFontConfig* cfg = &font->ConfigData[config_i])
2882  ImGui::BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d", config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH);
2883  if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
2884  {
2885  // Display all glyphs of the fonts in separate pages of 256 characters
2886  for (int base = 0; base < 0x10000; base += 256)
2887  {
2888  int count = 0;
2889  for (int n = 0; n < 256; n++)
2890  count += font->FindGlyphNoFallback((ImWchar)(base + n)) ? 1 : 0;
2891  if (count > 0 && ImGui::TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph"))
2892  {
2893  float cell_size = font->FontSize * 1;
2894  float cell_spacing = style.ItemSpacing.y;
2895  ImVec2 base_pos = ImGui::GetCursorScreenPos();
2896  ImDrawList* draw_list = ImGui::GetWindowDrawList();
2897  for (int n = 0; n < 256; n++)
2898  {
2899  ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing));
2900  ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
2901  const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n));
2902  draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
2903  if (glyph)
2904  font->RenderChar(draw_list, cell_size, 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.
2905  if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2))
2906  {
2908  ImGui::Text("Codepoint: U+%04X", base + n);
2909  ImGui::Separator();
2910  ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX);
2911  ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1);
2912  ImGui::Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1);
2914  }
2915  }
2916  ImGui::Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
2917  ImGui::TreePop();
2918  }
2919  }
2920  ImGui::TreePop();
2921  }
2922  ImGui::TreePop();
2923  }
2924  ImGui::PopID();
2925  }
2926  if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
2927  {
2928  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));
2929  ImGui::TreePop();
2930  }
2931 
2932  static float window_scale = 1.0f;
2933  if (ImGui::DragFloat("this window scale", &window_scale, 0.005f, 0.3f, 2.0f, "%.1f")) // scale only this window
2934  ImGui::SetWindowFontScale(window_scale);
2935  ImGui::DragFloat("global scale", &ImGui::GetIO().FontGlobalScale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale everything
2937 
2939  }
2940 
2941  if (ImGui::BeginTabItem("Rendering"))
2942  {
2943  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.");
2944  ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill);
2945  ImGui::PushItemWidth(100);
2946  ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, "%.2f", 2.0f);
2947  if (style.CurveTessellationTol < 0.10f) style.CurveTessellationTol = 0.10f;
2948  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.
2950 
2952  }
2953 
2954  ImGui::EndTabBar();
2955  }
2956 
2958 }
2959 
2960 //-----------------------------------------------------------------------------
2961 // [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar()
2962 //-----------------------------------------------------------------------------
2963 
2964 // Demonstrate creating a fullscreen menu bar and populating it.
2966 {
2968  {
2969  if (ImGui::BeginMenu("File"))
2970  {
2972  ImGui::EndMenu();
2973  }
2974  if (ImGui::BeginMenu("Edit"))
2975  {
2976  if (ImGui::MenuItem("Undo", "CTRL+Z")) {}
2977  if (ImGui::MenuItem("Redo", "CTRL+Y", false, false)) {} // Disabled item
2978  ImGui::Separator();
2979  if (ImGui::MenuItem("Cut", "CTRL+X")) {}
2980  if (ImGui::MenuItem("Copy", "CTRL+C")) {}
2981  if (ImGui::MenuItem("Paste", "CTRL+V")) {}
2982  ImGui::EndMenu();
2983  }
2985  }
2986 }
2987 
2988 static void ShowExampleMenuFile()
2989 {
2990  ImGui::MenuItem("(dummy menu)", NULL, false, false);
2991  if (ImGui::MenuItem("New")) {}
2992  if (ImGui::MenuItem("Open", "Ctrl+O")) {}
2993  if (ImGui::BeginMenu("Open Recent"))
2994  {
2995  ImGui::MenuItem("fish_hat.c");
2996  ImGui::MenuItem("fish_hat.inl");
2997  ImGui::MenuItem("fish_hat.h");
2998  if (ImGui::BeginMenu("More.."))
2999  {
3000  ImGui::MenuItem("Hello");
3001  ImGui::MenuItem("Sailor");
3002  if (ImGui::BeginMenu("Recurse.."))
3003  {
3005  ImGui::EndMenu();
3006  }
3007  ImGui::EndMenu();
3008  }
3009  ImGui::EndMenu();
3010  }
3011  if (ImGui::MenuItem("Save", "Ctrl+S")) {}
3012  if (ImGui::MenuItem("Save As..")) {}
3013  ImGui::Separator();
3014  if (ImGui::BeginMenu("Options"))
3015  {
3016  static bool enabled = true;
3017  ImGui::MenuItem("Enabled", "", &enabled);
3018  ImGui::BeginChild("child", ImVec2(0, 60), true);
3019  for (int i = 0; i < 10; i++)
3020  ImGui::Text("Scrolling Text %d", i);
3021  ImGui::EndChild();
3022  static float f = 0.5f;
3023  static int n = 0;
3024  static bool b = true;
3025  ImGui::SliderFloat("Value", &f, 0.0f, 1.0f);
3026  ImGui::InputFloat("Input", &f, 0.1f);
3027  ImGui::Combo("Combo", &n, "Yes\0No\0Maybe\0\0");
3028  ImGui::Checkbox("Check", &b);
3029  ImGui::EndMenu();
3030  }
3031  if (ImGui::BeginMenu("Colors"))
3032  {
3033  float sz = ImGui::GetTextLineHeight();
3034  for (int i = 0; i < ImGuiCol_COUNT; i++)
3035  {
3036  const char* name = ImGui::GetStyleColorName((ImGuiCol)i);
3039  ImGui::Dummy(ImVec2(sz, sz));
3040  ImGui::SameLine();
3041  ImGui::MenuItem(name);
3042  }
3043  ImGui::EndMenu();
3044  }
3045  if (ImGui::BeginMenu("Disabled", false)) // Disabled
3046  {
3047  IM_ASSERT(0);
3048  }
3049  if (ImGui::MenuItem("Checked", NULL, true)) {}
3050  if (ImGui::MenuItem("Quit", "Alt+F4")) {}
3051 }
3052 
3053 //-----------------------------------------------------------------------------
3054 // [SECTION] Example App: Debug Console / ShowExampleAppConsole()
3055 //-----------------------------------------------------------------------------
3056 
3057 // Demonstrate creating a simple console window, with scrolling, filtering, completion and history.
3058 // For the console example, here we are using a more C++ like approach of declaring a class to hold the data and the functions.
3060 {
3061  char InputBuf[256];
3065  int HistoryPos; // -1: new line, 0..History.Size-1 browsing history.
3067 
3069  {
3070  ClearLog();
3071  memset(InputBuf, 0, sizeof(InputBuf));
3072  HistoryPos = -1;
3073  Commands.push_back("HELP");
3074  Commands.push_back("HISTORY");
3075  Commands.push_back("CLEAR");
3076  Commands.push_back("CLASSIFY"); // "classify" is only here to provide an example of "C"+[tab] completing to "CL" and displaying matches.
3077  AddLog("Welcome to Dear ImGui!");
3078  }
3080  {
3081  ClearLog();
3082  for (int i = 0; i < History.Size; i++)
3083  free(History[i]);
3084  }
3085 
3086  // Portable helpers
3087  static int Stricmp(const char* str1, const char* str2) { int d; while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; } return d; }
3088  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; }
3089  static char* Strdup(const char *str) { size_t len = strlen(str) + 1; void* buff = malloc(len); return (char*)memcpy(buff, (const void*)str, len); }
3090  static void Strtrim(char* str) { char* str_end = str + strlen(str); while (str_end > str && str_end[-1] == ' ') str_end--; *str_end = 0; }
3091 
3092  void ClearLog()
3093  {
3094  for (int i = 0; i < Items.Size; i++)
3095  free(Items[i]);
3096  Items.clear();
3097  ScrollToBottom = true;
3098  }
3099 
3100  void AddLog(const char* fmt, ...) IM_FMTARGS(2)
3101  {
3102  // FIXME-OPT
3103  char buf[1024];
3104  va_list args;
3105  va_start(args, fmt);
3106  vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
3107  buf[IM_ARRAYSIZE(buf)-1] = 0;
3108  va_end(args);
3109  Items.push_back(Strdup(buf));
3110  ScrollToBottom = true;
3111  }
3112 
3113  void Draw(const char* title, bool* p_open)
3114  {
3116  if (!ImGui::Begin(title, p_open))
3117  {
3118  ImGui::End();
3119  return;
3120  }
3121 
3122  // As a specific feature guaranteed by the library, after calling Begin() the last Item represent the title bar. So e.g. IsItemHovered() will return true when hovering the title bar.
3123  // Here we create a context menu only available from the title bar.
3125  {
3126  if (ImGui::MenuItem("Close Console"))
3127  *p_open = false;
3128  ImGui::EndPopup();
3129  }
3130 
3131  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.");
3132  ImGui::TextWrapped("Enter 'HELP' for help, press TAB to use text completion.");
3133 
3134  // TODO: display items starting from the bottom
3135 
3136  if (ImGui::SmallButton("Add Dummy Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } ImGui::SameLine();
3137  if (ImGui::SmallButton("Add Dummy Error")) { AddLog("[error] something went wrong"); } ImGui::SameLine();
3138  if (ImGui::SmallButton("Clear")) { ClearLog(); } ImGui::SameLine();
3139  bool copy_to_clipboard = ImGui::SmallButton("Copy"); ImGui::SameLine();
3140  if (ImGui::SmallButton("Scroll to bottom")) ScrollToBottom = true;
3141  //static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); }
3142 
3143  ImGui::Separator();
3144 
3146  static ImGuiTextFilter filter;
3147  filter.Draw("Filter (\"incl,-excl\") (\"error\")", 180);
3149  ImGui::Separator();
3150 
3151  const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); // 1 separator, 1 input text
3152  ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), false, ImGuiWindowFlags_HorizontalScrollbar); // Leave room for 1 separator + 1 InputText
3154  {
3155  if (ImGui::Selectable("Clear")) ClearLog();
3156  ImGui::EndPopup();
3157  }
3158 
3159  // 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());
3160  // NB- if you have thousands of entries this approach may be too inefficient and may require user-side clipping to only process visible items.
3161  // 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.
3162  // To use the clipper we could replace the 'for (int i = 0; i < Items.Size; i++)' loop with:
3163  // ImGuiListClipper clipper(Items.Size);
3164  // while (clipper.Step())
3165  // for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
3166  // However, 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.
3167  // 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,
3168  // 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!
3169  // 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.
3170  ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4,1)); // Tighten spacing
3171  if (copy_to_clipboard)
3173  ImVec4 col_default_text = ImGui::GetStyleColorVec4(ImGuiCol_Text);
3174  for (int i = 0; i < Items.Size; i++)
3175  {
3176  const char* item = Items[i];
3177  if (!filter.PassFilter(item))
3178  continue;
3179  ImVec4 col = col_default_text;
3180  if (strstr(item, "[error]")) col = ImColor(1.0f,0.4f,0.4f,1.0f);
3181  else if (strncmp(item, "# ", 2) == 0) col = ImColor(1.0f,0.78f,0.58f,1.0f);
3183  ImGui::TextUnformatted(item);
3185  }
3186  if (copy_to_clipboard)
3187  ImGui::LogFinish();
3188  if (ScrollToBottom)
3190  ScrollToBottom = false;
3192  ImGui::EndChild();
3193  ImGui::Separator();
3194 
3195  // Command-line
3196  bool reclaim_focus = false;
3198  {
3199  char* s = InputBuf;
3200  Strtrim(s);
3201  if (s[0])
3202  ExecCommand(s);
3203  strcpy(s, "");
3204  reclaim_focus = true;
3205  }
3206 
3207  // Auto-focus on window apparition
3209  if (reclaim_focus)
3210  ImGui::SetKeyboardFocusHere(-1); // Auto focus previous widget
3211 
3212  ImGui::End();
3213  }
3214 
3215  void ExecCommand(const char* command_line)
3216  {
3217  AddLog("# %s\n", command_line);
3218 
3219  // 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.
3220  HistoryPos = -1;
3221  for (int i = History.Size-1; i >= 0; i--)
3222  if (Stricmp(History[i], command_line) == 0)
3223  {
3224  free(History[i]);
3225  History.erase(History.begin() + i);
3226  break;
3227  }
3228  History.push_back(Strdup(command_line));
3229 
3230  // Process command
3231  if (Stricmp(command_line, "CLEAR") == 0)
3232  {
3233  ClearLog();
3234  }
3235  else if (Stricmp(command_line, "HELP") == 0)
3236  {
3237  AddLog("Commands:");
3238  for (int i = 0; i < Commands.Size; i++)
3239  AddLog("- %s", Commands[i]);
3240  }
3241  else if (Stricmp(command_line, "HISTORY") == 0)
3242  {
3243  int first = History.Size - 10;
3244  for (int i = first > 0 ? first : 0; i < History.Size; i++)
3245  AddLog("%3d: %s\n", i, History[i]);
3246  }
3247  else
3248  {
3249  AddLog("Unknown command: '%s'\n", command_line);
3250  }
3251  }
3252 
3253  static int TextEditCallbackStub(ImGuiInputTextCallbackData* data) // In C++11 you are better off using lambdas for this sort of forwarding callbacks
3254  {
3255  ExampleAppConsole* console = (ExampleAppConsole*)data->UserData;
3256  return console->TextEditCallback(data);
3257  }
3258 
3260  {
3261  //AddLog("cursor: %d, selection: %d-%d", data->CursorPos, data->SelectionStart, data->SelectionEnd);
3262  switch (data->EventFlag)
3263  {
3265  {
3266  // Example of TEXT COMPLETION
3267 
3268  // Locate beginning of current word
3269  const char* word_end = data->Buf + data->CursorPos;
3270  const char* word_start = word_end;
3271  while (word_start > data->Buf)
3272  {
3273  const char c = word_start[-1];
3274  if (c == ' ' || c == '\t' || c == ',' || c == ';')
3275  break;
3276  word_start--;
3277  }
3278 
3279  // Build a list of candidates
3280  ImVector<const char*> candidates;
3281  for (int i = 0; i < Commands.Size; i++)
3282  if (Strnicmp(Commands[i], word_start, (int)(word_end-word_start)) == 0)
3283  candidates.push_back(Commands[i]);
3284 
3285  if (candidates.Size == 0)
3286  {
3287  // No match
3288  AddLog("No match for \"%.*s\"!\n", (int)(word_end-word_start), word_start);
3289  }
3290  else if (candidates.Size == 1)
3291  {
3292  // Single match. Delete the beginning of the word and replace it entirely so we've got nice casing
3293  data->DeleteChars((int)(word_start-data->Buf), (int)(word_end-word_start));
3294  data->InsertChars(data->CursorPos, candidates[0]);
3295  data->InsertChars(data->CursorPos, " ");
3296  }
3297  else
3298  {
3299  // Multiple matches. Complete as much as we can, so inputing "C" will complete to "CL" and display "CLEAR" and "CLASSIFY"
3300  int match_len = (int)(word_end - word_start);
3301  for (;;)
3302  {
3303  int c = 0;
3304  bool all_candidates_matches = true;
3305  for (int i = 0; i < candidates.Size && all_candidates_matches; i++)
3306  if (i == 0)
3307  c = toupper(candidates[i][match_len]);
3308  else if (c == 0 || c != toupper(candidates[i][match_len]))
3309  all_candidates_matches = false;
3310  if (!all_candidates_matches)
3311  break;
3312  match_len++;
3313  }
3314 
3315  if (match_len > 0)
3316  {
3317  data->DeleteChars((int)(word_start - data->Buf), (int)(word_end-word_start));
3318  data->InsertChars(data->CursorPos, candidates[0], candidates[0] + match_len);
3319  }
3320 
3321  // List matches
3322  AddLog("Possible matches:\n");
3323  for (int i = 0; i < candidates.Size; i++)
3324  AddLog("- %s\n", candidates[i]);
3325  }
3326 
3327  break;
3328  }
3330  {
3331  // Example of HISTORY
3332  const int prev_history_pos = HistoryPos;
3333  if (data->EventKey == ImGuiKey_UpArrow)
3334  {
3335  if (HistoryPos == -1)
3336  HistoryPos = History.Size - 1;
3337  else if (HistoryPos > 0)
3338  HistoryPos--;
3339  }
3340  else if (data->EventKey == ImGuiKey_DownArrow)
3341  {
3342  if (HistoryPos != -1)
3343  if (++HistoryPos >= History.Size)
3344  HistoryPos = -1;
3345  }
3346 
3347  // A better implementation would preserve the data on the current input line along with cursor position.
3348  if (prev_history_pos != HistoryPos)
3349  {
3350  const char* history_str = (HistoryPos >= 0) ? History[HistoryPos] : "";
3351  data->DeleteChars(0, data->BufTextLen);
3352  data->InsertChars(0, history_str);
3353  }
3354  }
3355  }
3356  return 0;
3357  }
3358 };
3359 
3360 static void ShowExampleAppConsole(bool* p_open)
3361 {
3362  static ExampleAppConsole console;
3363  console.Draw("Example: Console", p_open);
3364 }
3365 
3366 //-----------------------------------------------------------------------------
3367 // [SECTION] Example App: Debug Log / ShowExampleAppLog()
3368 //-----------------------------------------------------------------------------
3369 
3370 // Usage:
3371 // static ExampleAppLog my_log;
3372 // my_log.AddLog("Hello %d world\n", 123);
3373 // my_log.Draw("title");
3375 {
3378  ImVector<int> LineOffsets; // Index to lines offset. We maintain this with AddLog() calls, allowing us to have a random access on lines
3380 
3381  void Clear()
3382  {
3383  Buf.clear();
3384  LineOffsets.clear();
3385  LineOffsets.push_back(0);
3386  }
3387 
3388  void AddLog(const char* fmt, ...) IM_FMTARGS(2)
3389  {
3390  int old_size = Buf.size();
3391  va_list args;
3392  va_start(args, fmt);
3393  Buf.appendfv(fmt, args);
3394  va_end(args);
3395  for (int new_size = Buf.size(); old_size < new_size; old_size++)
3396  if (Buf[old_size] == '\n')
3397  LineOffsets.push_back(old_size + 1);
3398  ScrollToBottom = true;
3399  }
3400 
3401  void Draw(const char* title, bool* p_open = NULL)
3402  {
3403  if (!ImGui::Begin(title, p_open))
3404  {
3405  ImGui::End();
3406  return;
3407  }
3408  if (ImGui::Button("Clear")) Clear();
3409  ImGui::SameLine();
3410  bool copy = ImGui::Button("Copy");
3411  ImGui::SameLine();
3412  Filter.Draw("Filter", -100.0f);
3413  ImGui::Separator();
3415  if (copy)
3417 
3419  const char* buf = Buf.begin();
3420  const char* buf_end = Buf.end();
3421  if (Filter.IsActive())
3422  {
3423  for (int line_no = 0; line_no < LineOffsets.Size; line_no++)
3424  {
3425  const char* line_start = buf + LineOffsets[line_no];
3426  const char* line_end = (line_no + 1 < LineOffsets.Size) ? (buf + LineOffsets[line_no + 1] - 1) : buf_end;
3427  if (Filter.PassFilter(line_start, line_end))
3428  ImGui::TextUnformatted(line_start, line_end);
3429  }
3430  }
3431  else
3432  {
3433  // The simplest and easy way to display the entire buffer:
3434  // ImGui::TextUnformatted(buf_begin, buf_end);
3435  // And it'll just work. TextUnformatted() has specialization for large blob of text and will fast-forward to skip non-visible lines.
3436  // Here we instead demonstrate using the clipper to only process lines that are within the visible area.
3437  // If you have tens of thousands of items and their processing cost is non-negligible, coarse clipping them on your side is recommended.
3438  // Using ImGuiListClipper requires A) random access into your data, and B) items all being the same height,
3439  // both of which we can handle since we an array pointing to the beginning of each line of text.
3440  // When using the filter (in the block of code above) we don't have random access into the data to display anymore, which is why we don't use the clipper.
3441  // Storing or skimming through the search result would make it possible (and would be recommended if you want to search through tens of thousands of entries)
3442  ImGuiListClipper clipper;
3443  clipper.Begin(LineOffsets.Size);
3444  while (clipper.Step())
3445  {
3446  for (int line_no = clipper.DisplayStart; line_no < clipper.DisplayEnd; line_no++)
3447  {
3448  const char* line_start = buf + LineOffsets[line_no];
3449  const char* line_end = (line_no + 1 < LineOffsets.Size) ? (buf + LineOffsets[line_no + 1] - 1) : buf_end;
3450  ImGui::TextUnformatted(line_start, line_end);
3451  }
3452  }
3453  clipper.End();
3454  }
3456 
3457  if (ScrollToBottom)
3459  ScrollToBottom = false;
3460  ImGui::EndChild();
3461  ImGui::End();
3462  }
3463 };
3464 
3465 // Demonstrate creating a simple log window with basic filtering.
3466 static void ShowExampleAppLog(bool* p_open)
3467 {
3468  static ExampleAppLog log;
3469 
3470  // For the demo: add a debug button before the normal log window contents
3471  // We take advantage of the fact that multiple calls to Begin()/End() are appending to the same window.
3473  ImGui::Begin("Example: Log", p_open);
3474  if (ImGui::SmallButton("Add 5 entries"))
3475  {
3476  static int counter = 0;
3477  for (int n = 0; n < 5; n++)
3478  {
3479  const char* categories[3] = { "info", "warn", "error" };
3480  const char* words[] = { "Bumfuzzled", "Cattywampus", "Snickersnee", "Abibliophobia", "Absquatulate", "Nincompoop", "Pauciloquent" };
3481  log.AddLog("[%05d] [%s] Hello, current time is %.1f, here's a word: '%s'\n",
3482  ImGui::GetFrameCount(), categories[counter % IM_ARRAYSIZE(categories)], ImGui::GetTime(), words[counter % IM_ARRAYSIZE(words)]);
3483  counter++;
3484  }
3485  }
3486  ImGui::End();
3487 
3488  log.Draw("Example: Log", p_open);
3489 }
3490 
3491 //-----------------------------------------------------------------------------
3492 // [SECTION] Example App: Simple Layout / ShowExampleAppLayout()
3493 //-----------------------------------------------------------------------------
3494 
3495 // Demonstrate create a window with multiple child windows.
3496 static void ShowExampleAppLayout(bool* p_open)
3497 {
3499  if (ImGui::Begin("Example: Simple layout", p_open, ImGuiWindowFlags_MenuBar))
3500  {
3501  if (ImGui::BeginMenuBar())
3502  {
3503  if (ImGui::BeginMenu("File"))
3504  {
3505  if (ImGui::MenuItem("Close")) *p_open = false;
3506  ImGui::EndMenu();
3507  }
3509  }
3510 
3511  // left
3512  static int selected = 0;
3513  ImGui::BeginChild("left pane", ImVec2(150, 0), true);
3514  for (int i = 0; i < 100; i++)
3515  {
3516  char label[128];
3517  sprintf(label, "MyObject %d", i);
3518  if (ImGui::Selectable(label, selected == i))
3519  selected = i;
3520  }
3521  ImGui::EndChild();
3522  ImGui::SameLine();
3523 
3524  // right
3526  ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us
3527  ImGui::Text("MyObject: %d", selected);
3528  ImGui::Separator();
3530  {
3531  if (ImGui::BeginTabItem("Description"))
3532  {
3533  ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ");
3535  }
3536  if (ImGui::BeginTabItem("Details"))
3537  {
3538  ImGui::Text("ID: 0123456789");
3540  }
3541  ImGui::EndTabBar();
3542  }
3543  ImGui::EndChild();
3544  if (ImGui::Button("Revert")) {}
3545  ImGui::SameLine();
3546  if (ImGui::Button("Save")) {}
3547  ImGui::EndGroup();
3548  }
3549  ImGui::End();
3550 }
3551 
3552 //-----------------------------------------------------------------------------
3553 // [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor()
3554 //-----------------------------------------------------------------------------
3555 
3556 // Demonstrate create a simple property editor.
3557 static void ShowExampleAppPropertyEditor(bool* p_open)
3558 {
3560  if (!ImGui::Begin("Example: Property editor", p_open))
3561  {
3562  ImGui::End();
3563  return;
3564  }
3565 
3566  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.");
3567 
3569  ImGui::Columns(2);
3570  ImGui::Separator();
3571 
3572  struct funcs
3573  {
3574  static void ShowDummyObject(const char* prefix, int uid)
3575  {
3576  ImGui::PushID(uid); // Use object uid as identifier. Most commonly you could also use the object pointer as a base ID.
3577  ImGui::AlignTextToFramePadding(); // Text and Tree nodes are less high than regular widgets, here we add vertical spacing to make the tree lines equal high.
3578  bool node_open = ImGui::TreeNode("Object", "%s_%u", prefix, uid);
3581  ImGui::Text("my sailor is rich");
3583  if (node_open)
3584  {
3585  static float dummy_members[8] = { 0.0f,0.0f,1.0f,3.1416f,100.0f,999.0f };
3586  for (int i = 0; i < 8; i++)
3587  {
3588  ImGui::PushID(i); // Use field index as identifier.
3589  if (i < 2)
3590  {
3591  ShowDummyObject("Child", 424242);
3592  }
3593  else
3594  {
3595  // Here we use a TreeNode to highlight on hover (we could use e.g. Selectable as well)
3600  if (i >= 5)
3601  ImGui::InputFloat("##value", &dummy_members[i], 1.0f);
3602  else
3603  ImGui::DragFloat("##value", &dummy_members[i], 0.01f);
3606  }
3607  ImGui::PopID();
3608  }
3609  ImGui::TreePop();
3610  }
3611  ImGui::PopID();
3612  }
3613  };
3614 
3615  // Iterate dummy objects with dummy members (all the same data)
3616  for (int obj_i = 0; obj_i < 3; obj_i++)
3617  funcs::ShowDummyObject("Object", obj_i);
3618 
3619  ImGui::Columns(1);
3620  ImGui::Separator();
3622  ImGui::End();
3623 }
3624 
3625 //-----------------------------------------------------------------------------
3626 // [SECTION] Example App: Long Text / ShowExampleAppLongText()
3627 //-----------------------------------------------------------------------------
3628 
3629 // Demonstrate/test rendering huge amount of text, and the incidence of clipping.
3630 static void ShowExampleAppLongText(bool* p_open)
3631 {
3633  if (!ImGui::Begin("Example: Long text display", p_open))
3634  {
3635  ImGui::End();
3636  return;
3637  }
3638 
3639  static int test_type = 0;
3640  static ImGuiTextBuffer log;
3641  static int lines = 0;
3642  ImGui::Text("Printing unusually long amount of text.");
3643  ImGui::Combo("Test type", &test_type, "Single call to TextUnformatted()\0Multiple calls to Text(), clipped manually\0Multiple calls to Text(), not clipped (slow)\0");
3644  ImGui::Text("Buffer contents: %d lines, %d bytes", lines, log.size());
3645  if (ImGui::Button("Clear")) { log.clear(); lines = 0; }
3646  ImGui::SameLine();
3647  if (ImGui::Button("Add 1000 lines"))
3648  {
3649  for (int i = 0; i < 1000; i++)
3650  log.appendf("%i The quick brown fox jumps over the lazy dog\n", lines+i);
3651  lines += 1000;
3652  }
3653  ImGui::BeginChild("Log");
3654  switch (test_type)
3655  {
3656  case 0:
3657  // Single call to TextUnformatted() with a big buffer
3658  ImGui::TextUnformatted(log.begin(), log.end());
3659  break;
3660  case 1:
3661  {
3662  // Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper.
3664  ImGuiListClipper clipper(lines);
3665  while (clipper.Step())
3666  for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
3667  ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
3669  break;
3670  }
3671  case 2:
3672  // Multiple calls to Text(), not clipped (slow)
3674  for (int i = 0; i < lines; i++)
3675  ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
3677  break;
3678  }
3679  ImGui::EndChild();
3680  ImGui::End();
3681 }
3682 
3683 //-----------------------------------------------------------------------------
3684 // [SECTION] Example App: Auto Resize / ShowExampleAppAutoResize()
3685 //-----------------------------------------------------------------------------
3686 
3687 // Demonstrate creating a window which gets auto-resized according to its content.
3688 static void ShowExampleAppAutoResize(bool* p_open)
3689 {
3690  if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize))
3691  {
3692  ImGui::End();
3693  return;
3694  }
3695 
3696  static int lines = 10;
3697  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.");
3698  ImGui::SliderInt("Number of lines", &lines, 1, 20);
3699  for (int i = 0; i < lines; i++)
3700  ImGui::Text("%*sThis is line %d", i * 4, "", i); // Pad with space to extend size horizontally
3701  ImGui::End();
3702 }
3703 
3704 //-----------------------------------------------------------------------------
3705 // [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize()
3706 //-----------------------------------------------------------------------------
3707 
3708 // Demonstrate creating a window with custom resize constraints.
3709 static void ShowExampleAppConstrainedResize(bool* p_open)
3710 {
3711  struct CustomConstraints // Helper functions to demonstrate programmatic constraints
3712  {
3713  static void Square(ImGuiSizeCallbackData* data) { data->DesiredSize = ImVec2(IM_MAX(data->DesiredSize.x, data->DesiredSize.y), IM_MAX(data->DesiredSize.x, data->DesiredSize.y)); }
3714  static void Step(ImGuiSizeCallbackData* 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); }
3715  };
3716 
3717  static bool auto_resize = false;
3718  static int type = 0;
3719  static int display_lines = 10;
3720  if (type == 0) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 0), ImVec2(-1, FLT_MAX)); // Vertical only
3721  if (type == 1) ImGui::SetNextWindowSizeConstraints(ImVec2(0, -1), ImVec2(FLT_MAX, -1)); // Horizontal only
3722  if (type == 2) ImGui::SetNextWindowSizeConstraints(ImVec2(100, 100), ImVec2(FLT_MAX, FLT_MAX)); // Width > 100, Height > 100
3723  if (type == 3) ImGui::SetNextWindowSizeConstraints(ImVec2(400, -1), ImVec2(500, -1)); // Width 400-500
3724  if (type == 4) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 400), ImVec2(-1, 500)); // Height 400-500
3725  if (type == 5) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Square); // Always Square
3726  if (type == 6) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Step, (void*)100);// Fixed Step
3727 
3728  ImGuiWindowFlags flags = auto_resize ? ImGuiWindowFlags_AlwaysAutoResize : 0;
3729  if (ImGui::Begin("Example: Constrained Resize", p_open, flags))
3730  {
3731  const char* desc[] =
3732  {
3733  "Resize vertical only",
3734  "Resize horizontal only",
3735  "Width > 100, Height > 100",
3736  "Width 400-500",
3737  "Height 400-500",
3738  "Custom: Always Square",
3739  "Custom: Fixed Steps (100)",
3740  };
3741  if (ImGui::Button("200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine();
3742  if (ImGui::Button("500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine();
3743  if (ImGui::Button("800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); }
3744  ImGui::PushItemWidth(200);
3745  ImGui::Combo("Constraint", &type, desc, IM_ARRAYSIZE(desc));
3746  ImGui::DragInt("Lines", &display_lines, 0.2f, 1, 100);
3748  ImGui::Checkbox("Auto-resize", &auto_resize);
3749  for (int i = 0; i < display_lines; i++)
3750  ImGui::Text("%*sHello, sailor! Making this line long enough for the example.", i * 4, "");
3751  }
3752  ImGui::End();
3753 }
3754 
3755 //-----------------------------------------------------------------------------
3756 // [SECTION] Example App: Simple Overlay / ShowExampleAppSimpleOverlay()
3757 //-----------------------------------------------------------------------------
3758 
3759 // Demonstrate creating a simple static window with no decoration + a context-menu to choose which corner of the screen to use.
3760 static void ShowExampleAppSimpleOverlay(bool* p_open)
3761 {
3762  const float DISTANCE = 10.0f;
3763  static int corner = 0;
3764  ImVec2 window_pos = ImVec2((corner & 1) ? ImGui::GetIO().DisplaySize.x - DISTANCE : DISTANCE, (corner & 2) ? ImGui::GetIO().DisplaySize.y - DISTANCE : DISTANCE);
3765  ImVec2 window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f);
3766  if (corner != -1)
3767  ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
3768  ImGui::SetNextWindowBgAlpha(0.3f); // Transparent background
3770  {
3771  ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)");
3772  ImGui::Separator();
3773  if (ImGui::IsMousePosValid())
3774  ImGui::Text("Mouse Position: (%.1f,%.1f)", ImGui::GetIO().MousePos.x, ImGui::GetIO().MousePos.y);
3775  else
3776  ImGui::Text("Mouse Position: <invalid>");
3778  {
3779  if (ImGui::MenuItem("Custom", NULL, corner == -1)) corner = -1;
3780  if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0;
3781  if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1;
3782  if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2;
3783  if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3;
3784  if (p_open && ImGui::MenuItem("Close")) *p_open = false;
3785  ImGui::EndPopup();
3786  }
3787  }
3788  ImGui::End();
3789 }
3790 
3791 //-----------------------------------------------------------------------------
3792 // [SECTION] Example App: Manipulating Window Titles / ShowExampleAppWindowTitles()
3793 //-----------------------------------------------------------------------------
3794 
3795 // Demonstrate using "##" and "###" in identifiers to manipulate ID generation.
3796 // This apply to all regular items as well. Read FAQ 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." for details.
3797 static void ShowExampleAppWindowTitles(bool*)
3798 {
3799  // By default, Windows are uniquely identified by their title.
3800  // You can use the "##" and "###" markers to manipulate the display/ID.
3801 
3802  // Using "##" to display same title but have unique identifier.
3804  ImGui::Begin("Same title as another window##1");
3805  ImGui::Text("This is window 1.\nMy title is the same as window 2, but my identifier is unique.");
3806  ImGui::End();
3807 
3809  ImGui::Begin("Same title as another window##2");
3810  ImGui::Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique.");
3811  ImGui::End();
3812 
3813  // Using "###" to display a changing title but keep a static identifier "AnimatedTitle"
3814  char buf[128];
3815  sprintf(buf, "Animated title %c %d###AnimatedTitle", "|/-\\"[(int)(ImGui::GetTime() / 0.25f) & 3], ImGui::GetFrameCount());
3817  ImGui::Begin(buf);
3818  ImGui::Text("This window has a changing title.");
3819  ImGui::End();
3820 }
3821 
3822 //-----------------------------------------------------------------------------
3823 // [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
3824 //-----------------------------------------------------------------------------
3825 
3826 // Demonstrate using the low-level ImDrawList to draw custom shapes.
3827 static void ShowExampleAppCustomRendering(bool* p_open)
3828 {
3830  if (!ImGui::Begin("Example: Custom rendering", p_open))
3831  {
3832  ImGui::End();
3833  return;
3834  }
3835 
3836  // Tip: If you do a lot of custom rendering, you probably want to use your own geometrical types and benefit of overloaded operators, etc.
3837  // Define IM_VEC2_CLASS_EXTRA in imconfig.h to create implicit conversions between your types and ImVec2/ImVec4.
3838  // ImGui defines overloaded operators but they are internal to imgui.cpp and not exposed outside (to avoid messing with your types)
3839  // In this example we are not using the maths operators!
3840  ImDrawList* draw_list = ImGui::GetWindowDrawList();
3841 
3842  // Primitives
3843  ImGui::Text("Primitives");
3844  static float sz = 36.0f;
3845  static float thickness = 4.0f;
3846  static ImVec4 col = ImVec4(1.0f, 1.0f, 0.4f, 1.0f);
3847  ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f");
3848  ImGui::DragFloat("Thickness", &thickness, 0.05f, 1.0f, 8.0f, "%.02f");
3849  ImGui::ColorEdit3("Color", &col.x);
3850  {
3851  const ImVec2 p = ImGui::GetCursorScreenPos();
3852  const ImU32 col32 = ImColor(col);
3853  float x = p.x + 4.0f, y = p.y + 4.0f, spacing = 8.0f;
3854  for (int n = 0; n < 2; n++)
3855  {
3856  float curr_thickness = (n == 0) ? 1.0f : thickness;
3857  draw_list->AddCircle(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 20, curr_thickness); x += sz+spacing;
3858  draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 0.0f, ImDrawCornerFlags_All, curr_thickness); x += sz+spacing;
3859  draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_All, curr_thickness); x += sz+spacing;
3860  draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotRight, curr_thickness); x += sz+spacing;
3861  draw_list->AddTriangle(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32, curr_thickness); x += sz+spacing;
3862  draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y ), col32, curr_thickness); x += sz+spacing; // Horizontal line (note: drawing a filled rectangle will be faster!)
3863  draw_list->AddLine(ImVec2(x, y), ImVec2(x, y+sz), col32, curr_thickness); x += spacing; // Vertical line (note: drawing a filled rectangle will be faster!)
3864  draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, curr_thickness); x += sz+spacing; // Diagonal line
3865  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, curr_thickness);
3866  x = p.x + 4;
3867  y += sz+spacing;
3868  }
3869  draw_list->AddCircleFilled(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 32); x += sz+spacing;
3870  draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32); x += sz+spacing;
3871  draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f); x += sz+spacing;
3872  draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotRight); x += sz+spacing;
3873  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;
3874  draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+thickness), col32); x += sz+spacing; // Horizontal line (faster than AddLine, but only handle integer thickness)
3875  draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+thickness, y+sz), col32); x += spacing+spacing; // Vertical line (faster than AddLine, but only handle integer thickness)
3876  draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+1, y+1), col32); x += sz; // Pixel (faster than AddLine)
3877  draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x+sz, y+sz), IM_COL32(0,0,0,255), IM_COL32(255,0,0,255), IM_COL32(255,255,0,255), IM_COL32(0,255,0,255));
3878  ImGui::Dummy(ImVec2((sz+spacing)*8, (sz+spacing)*3));
3879  }
3880  ImGui::Separator();
3881  {
3882  static ImVector<ImVec2> points;
3883  static bool adding_line = false;
3884  ImGui::Text("Canvas example");
3885  if (ImGui::Button("Clear")) points.clear();
3886  if (points.Size >= 2) { ImGui::SameLine(); if (ImGui::Button("Undo")) { points.pop_back(); points.pop_back(); } }
3887  ImGui::Text("Left-click and drag to add lines,\nRight-click to undo");
3888 
3889  // Here we are using InvisibleButton() as a convenience to 1) advance the cursor and 2) allows us to use IsItemHovered()
3890  // But you can also draw directly and poll mouse/keyboard by yourself. You can manipulate the cursor using GetCursorPos() and SetCursorPos().
3891  // If you only use the ImDrawList API, you can notify the owner window of its extends by using SetCursorPos(max).
3892  ImVec2 canvas_pos = ImGui::GetCursorScreenPos(); // ImDrawList API uses screen coordinates!
3893  ImVec2 canvas_size = ImGui::GetContentRegionAvail(); // Resize canvas to what's available
3894  if (canvas_size.x < 50.0f) canvas_size.x = 50.0f;
3895  if (canvas_size.y < 50.0f) canvas_size.y = 50.0f;
3896  draw_list->AddRectFilledMultiColor(canvas_pos, ImVec2(canvas_pos.x + canvas_size.x, canvas_pos.y + canvas_size.y), IM_COL32(50, 50, 50, 255), IM_COL32(50, 50, 60, 255), IM_COL32(60, 60, 70, 255), IM_COL32(50, 50, 60, 255));
3897  draw_list->AddRect(canvas_pos, ImVec2(canvas_pos.x + canvas_size.x, canvas_pos.y + canvas_size.y), IM_COL32(255, 255, 255, 255));
3898 
3899  bool adding_preview = false;
3900  ImGui::InvisibleButton("canvas", canvas_size);
3901  ImVec2 mouse_pos_in_canvas = ImVec2(ImGui::GetIO().MousePos.x - canvas_pos.x, ImGui::GetIO().MousePos.y - canvas_pos.y);
3902  if (adding_line)
3903  {
3904  adding_preview = true;
3905  points.push_back(mouse_pos_in_canvas);
3906  if (!ImGui::IsMouseDown(0))
3907  adding_line = adding_preview = false;
3908  }
3909  if (ImGui::IsItemHovered())
3910  {
3911  if (!adding_line && ImGui::IsMouseClicked(0))
3912  {
3913  points.push_back(mouse_pos_in_canvas);
3914  adding_line = true;
3915  }
3916  if (ImGui::IsMouseClicked(1) && !points.empty())
3917  {
3918  adding_line = adding_preview = false;
3919  points.pop_back();
3920  points.pop_back();
3921  }
3922  }
3923  draw_list->PushClipRect(canvas_pos, ImVec2(canvas_pos.x + canvas_size.x, canvas_pos.y + canvas_size.y), true); // clip lines within the canvas (if we resize it, etc.)
3924  for (int i = 0; i < points.Size - 1; i += 2)
3925  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);
3926  draw_list->PopClipRect();
3927  if (adding_preview)
3928  points.pop_back();
3929  }
3930  ImGui::End();
3931 }
3932 
3933 //-----------------------------------------------------------------------------
3934 // [SECTION] Example App: Documents Handling / ShowExampleAppDocuments()
3935 //-----------------------------------------------------------------------------
3936 
3937 // Simplified structure to mimic a Document model
3939 {
3940  const char* Name; // Document title
3941  bool Open; // Set when the document is open (in this demo, we keep an array of all available documents to simplify the demo)
3942  bool OpenPrev; // Copy of Open from last update.
3943  bool Dirty; // Set when the document has been modified
3944  bool WantClose; // Set when the document
3945  ImVec4 Color; // An arbitrary variable associated to the document
3946 
3947  MyDocument(const char* name, bool open = true, const ImVec4& color = ImVec4(1.0f,1.0f,1.0f,1.0f))
3948  {
3949  Name = name;
3950  Open = OpenPrev = open;
3951  Dirty = false;
3952  WantClose = false;
3953  Color = color;
3954  }
3955  void DoOpen() { Open = true; }
3956  void DoQueueClose() { WantClose = true; }
3957  void DoForceClose() { Open = false; Dirty = false; }
3958  void DoSave() { Dirty = false; }
3959 
3960  // Display dummy contents for the Document
3961  static void DisplayContents(MyDocument* doc)
3962  {
3963  ImGui::PushID(doc);
3964  ImGui::Text("Document \"%s\"", doc->Name);
3966  ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3968  if (ImGui::Button("Modify", ImVec2(100, 0)))
3969  doc->Dirty = true;
3970  ImGui::SameLine();
3971  if (ImGui::Button("Save", ImVec2(100, 0)))
3972  doc->DoSave();
3973  ImGui::ColorEdit3("color", &doc->Color.x); // Useful to test drag and drop and hold-dragged-to-open-tab behavior.
3974  ImGui::PopID();
3975  }
3976 
3977  // Display context menu for the Document
3978  static void DisplayContextMenu(MyDocument* doc)
3979  {
3981  return;
3982 
3983  char buf[256];
3984  sprintf(buf, "Save %s", doc->Name);
3985  if (ImGui::MenuItem(buf, "CTRL+S", false, doc->Open))
3986  doc->DoSave();
3987  if (ImGui::MenuItem("Close", "CTRL+W", false, doc->Open))
3988  doc->DoQueueClose();
3989  ImGui::EndPopup();
3990  }
3991 };
3992 
3994 {
3996 
3998  {
3999  Documents.push_back(MyDocument("Lettuce", true, ImVec4(0.4f, 0.8f, 0.4f, 1.0f)));
4000  Documents.push_back(MyDocument("Eggplant", true, ImVec4(0.8f, 0.5f, 1.0f, 1.0f)));
4001  Documents.push_back(MyDocument("Carrot", true, ImVec4(1.0f, 0.8f, 0.5f, 1.0f)));
4002  Documents.push_back(MyDocument("Tomato", false, ImVec4(1.0f, 0.3f, 0.4f, 1.0f)));
4003  Documents.push_back(MyDocument("A Rather Long Title", false));
4004  Documents.push_back(MyDocument("Some Document", false));
4005  }
4006 };
4007 
4008 // [Optional] Notify the system of Tabs/Windows closure that happened outside the regular tab interface.
4009 // If a tab has been closed programmatically (aka closed from another source such as the Checkbox() in the demo, as opposed
4010 // to clicking on the regular tab closing button) and stops being submitted, it will take a frame for the tab bar to notice its absence.
4011 // During this frame there will be a gap in the tab bar, and if the tab that has disappeared was the selected one, the tab bar
4012 // will report no selected tab during the frame. This will effectively give the impression of a flicker for one frame.
4013 // We call SetTabItemClosed() to manually notify the Tab Bar or Docking system of removed tabs to avoid this glitch.
4014 // Note that this completely optional, and only affect tab bars with the ImGuiTabBarFlags_Reorderable flag.
4016 {
4017  for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
4018  {
4019  MyDocument* doc = &app.Documents[doc_n];
4020  if (!doc->Open && doc->OpenPrev)
4022  doc->OpenPrev = doc->Open;
4023  }
4024 }
4025 
4026 void ShowExampleAppDocuments(bool* p_open)
4027 {
4028  static ExampleAppDocuments app;
4029 
4030  if (!ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar))
4031  {
4032  ImGui::End();
4033  return;
4034  }
4035 
4036  // Options
4037  static bool opt_reorderable = true;
4038  static ImGuiTabBarFlags opt_fitting_flags = ImGuiTabBarFlags_FittingPolicyDefault_;
4039 
4040  // Menu
4041  if (ImGui::BeginMenuBar())
4042  {
4043  if (ImGui::BeginMenu("File"))
4044  {
4045  int open_count = 0;
4046  for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
4047  open_count += app.Documents[doc_n].Open ? 1 : 0;
4048 
4049  if (ImGui::BeginMenu("Open", open_count < app.Documents.Size))
4050  {
4051  for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
4052  {
4053  MyDocument* doc = &app.Documents[doc_n];
4054  if (!doc->Open)
4055  if (ImGui::MenuItem(doc->Name))
4056  doc->DoOpen();
4057  }
4058  ImGui::EndMenu();
4059  }
4060  if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0))
4061  for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
4062  app.Documents[doc_n].DoQueueClose();
4063  if (ImGui::MenuItem("Exit", "Alt+F4")) {}
4064  ImGui::EndMenu();
4065  }
4067  }
4068 
4069  // [Debug] List documents with one checkbox for each
4070  for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
4071  {
4072  MyDocument* doc = &app.Documents[doc_n];
4073  if (doc_n > 0)
4074  ImGui::SameLine();
4075  ImGui::PushID(doc);
4076  if (ImGui::Checkbox(doc->Name, &doc->Open))
4077  if (!doc->Open)
4078  doc->DoForceClose();
4079  ImGui::PopID();
4080  }
4081 
4082  ImGui::Separator();
4083 
4084  // Submit Tab Bar and Tabs
4085  {
4086  ImGuiTabBarFlags tab_bar_flags = (opt_fitting_flags) | (opt_reorderable ? ImGuiTabBarFlags_Reorderable : 0);
4087  if (ImGui::BeginTabBar("##tabs", tab_bar_flags))
4088  {
4089  if (opt_reorderable)
4091 
4092  // [DEBUG] Stress tests
4093  //if ((ImGui::GetFrameCount() % 30) == 0) docs[1].Open ^= 1; // [DEBUG] Automatically show/hide a tab. Test various interactions e.g. dragging with this on.
4094  //if (ImGui::GetIO().KeyCtrl) ImGui::SetTabItemSelected(docs[1].Name); // [DEBUG] Test SetTabItemSelected(), probably not very useful as-is anyway..
4095 
4096  // Submit Tabs
4097  for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
4098  {
4099  MyDocument* doc = &app.Documents[doc_n];
4100  if (!doc->Open)
4101  continue;
4102 
4104  bool visible = ImGui::BeginTabItem(doc->Name, &doc->Open, tab_flags);
4105 
4106  // Cancel attempt to close when unsaved add to save queue so we can display a popup.
4107  if (!doc->Open && doc->Dirty)
4108  {
4109  doc->Open = true;
4110  doc->DoQueueClose();
4111  }
4112 
4114  if (visible)
4115  {
4118  }
4119  }
4120 
4121  ImGui::EndTabBar();
4122  }
4123  }
4124 
4125  // Update closing queue
4126  static ImVector<MyDocument*> close_queue;
4127  if (close_queue.empty())
4128  {
4129  // Close queue is locked once we started a popup
4130  for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++)
4131  {
4132  MyDocument* doc = &app.Documents[doc_n];
4133  if (doc->WantClose)
4134  {
4135  doc->WantClose = false;
4136  close_queue.push_back(doc);
4137  }
4138  }
4139  }
4140 
4141  // Display closing confirmation UI
4142  if (!close_queue.empty())
4143  {
4144  int close_queue_unsaved_documents = 0;
4145  for (int n = 0; n < close_queue.Size; n++)
4146  if (close_queue[n]->Dirty)
4147  close_queue_unsaved_documents++;
4148 
4149  if (close_queue_unsaved_documents == 0)
4150  {
4151  // Close documents when all are unsaved
4152  for (int n = 0; n < close_queue.Size; n++)
4153  close_queue[n]->DoForceClose();
4154  close_queue.clear();
4155  }
4156  else
4157  {
4158  if (!ImGui::IsPopupOpen("Save?"))
4159  ImGui::OpenPopup("Save?");
4160  if (ImGui::BeginPopupModal("Save?"))
4161  {
4162  ImGui::Text("Save change to the following items?");
4163  ImGui::PushItemWidth(-1.0f);
4164  ImGui::ListBoxHeader("##", close_queue_unsaved_documents, 6);
4165  for (int n = 0; n < close_queue.Size; n++)
4166  if (close_queue[n]->Dirty)
4167  ImGui::Text("%s", close_queue[n]->Name);
4169 
4170  if (ImGui::Button("Yes", ImVec2(80, 0)))
4171  {
4172  for (int n = 0; n < close_queue.Size; n++)
4173  {
4174  if (close_queue[n]->Dirty)
4175  close_queue[n]->DoSave();
4176  close_queue[n]->DoForceClose();
4177  }
4178  close_queue.clear();
4180  }
4181  ImGui::SameLine();
4182  if (ImGui::Button("No", ImVec2(80, 0)))
4183  {
4184  for (int n = 0; n < close_queue.Size; n++)
4185  close_queue[n]->DoForceClose();
4186  close_queue.clear();
4188  }
4189  ImGui::SameLine();
4190  if (ImGui::Button("Cancel", ImVec2(80, 0)))
4191  {
4192  close_queue.clear();
4194  }
4195  ImGui::EndPopup();
4196  }
4197  }
4198  }
4199 
4200  ImGui::End();
4201 }
4202 
4203 // End of Demo code
4204 #else
4205 
4206 void ImGui::ShowAboutWindow(bool*) {}
4207 void ImGui::ShowDemoWindow(bool*) {}
4208 void ImGui::ShowUserGuide() {}
4210 
4211 #endif
float NavInputs[ImGuiNavInput_COUNT]
Definition: imgui.h:1350
static void ShowExampleAppConstrainedResize(bool *p_open)
IMGUI_API bool BeginPopupContextItem(const char *str_id=NULL, int mouse_button=1)
Definition: imgui.cpp:6832
d
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 *format="%d", const char *format_max=NULL)
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val)
Definition: imgui.cpp:5697
IMGUI_API void SetNextWindowSize(const ImVec2 &size, ImGuiCond cond=0)
Definition: imgui.cpp:6054
IMGUI_API void ShowFontSelector(const char *label)
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))
bool NavVisible
Definition: imgui.h:1367
IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags=0)
Definition: imgui.cpp:5812
IMGUI_API void CaptureKeyboardFromApp(bool want_capture_keyboard_value=true)
Definition: imgui.cpp:4125
ImVector< char * > History
IMGUI_API bool InputFloat4(const char *label, float v[4], const char *format="%.3f", ImGuiInputTextFlags flags=0)
IMGUI_API ImVec2 GetCursorStartPos()
Definition: imgui.cpp:6233
unsigned int ImU32
Definition: imgui.h:150
IMGUI_API void SetTooltip(const char *fmt,...) IM_FMTARGS(1)
Definition: imgui.cpp:6576
IMGUI_API bool IsMouseReleased(int button)
Definition: imgui.cpp:4044
bool MouseDrawCursor
Definition: imgui.h:1299
T * erase(const T *it)
Definition: imgui.h:1209
IMGUI_API bool RadioButton(const char *label, bool active)
IMGUI_API ImVec2 GetCursorPos()
Definition: imgui.cpp:6194
bool ConfigWindowsResizeFromEdges
Definition: imgui.h:1302
ROSCPP_DECL bool check()
IMGUI_API void RenderChar(ImDrawList *draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const
const char * GetDebugName() const
Definition: imgui.h:2102
IMGUI_API float GetFontSize()
Definition: imgui.cpp:6174
IMGUI_API void AddCircle(const ImVec2 &centre, float radius, ImU32 col, int num_segments=12, float thickness=1.0f)
ImGuiTextBuffer Buf
bool WantSetMousePos
Definition: imgui.h:1364
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)
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))
float U1
Definition: imgui.h:1932
bool ConfigMacOSXBehaviors
Definition: imgui.h:1300
IMGUI_API bool SliderInt3(const char *label, int v[3], int v_min, int v_max, const char *format="%d")
IMGUI_API void SetTabItemClosed(const char *tab_or_docked_window_label)
IMGUI_API void ProgressBar(float fraction, const ImVec2 &size_arg=ImVec2(-1, 0), const char *overlay=NULL)
ImVec2 MousePos
Definition: imgui.h:1341
IMGUI_API void AlignTextToFramePadding()
IMGUI_API void PopClipRect()
Definition: imgui_draw.cpp:500
IMGUI_API bool ArrowButton(const char *str_id, ImGuiDir dir)
IMGUI_API void StyleColorsDark(ImGuiStyle *dst=NULL)
Definition: imgui_draw.cpp:171
TF2SIMD_FORCE_INLINE tf2Scalar angle(const Quaternion &q1, const Quaternion &q2)
IMGUI_API void appendf(const char *fmt,...) IM_FMTARGS(2)
Definition: imgui.cpp:2112
IMGUI_API bool OpenPopupOnItemClick(const char *str_id=NULL, int mouse_button=1)
Definition: imgui.cpp:6662
f
IMGUI_API bool BeginCombo(const char *label, const char *preview_value, ImGuiComboFlags flags=0)
signed long long ImS64
Definition: imgui.h:159
std::vector< double > values
IMGUI_API bool BeginPopupModal(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:6789
bool ConfigInputTextCursorBlink
Definition: imgui.h:1301
IMGUI_API const ImGuiPayload * AcceptDragDropPayload(const char *type, ImGuiDragDropFlags flags=0)
Definition: imgui.cpp:8548
ImGuiInputTextFlags EventFlag
Definition: imgui.h:1414
IMGUI_API bool IsItemDeactivatedAfterEdit()
Definition: imgui.cpp:4153
Definition: imgui.h:164
int TexHeight
Definition: imgui.h:2056
IMGUI_API bool IsMouseClicked(int button, bool repeat=false)
Definition: imgui.cpp:4026
IMGUI_API bool IsItemClicked(int mouse_button=0)
Definition: imgui.cpp:4166
IMGUI_API bool IsKeyPressed(int user_key_index, bool repeat=true)
Definition: imgui.cpp:3989
float CurveTessellationTol
Definition: imgui.h:1256
INLINE Rall1d< T, V, S > log(const Rall1d< T, V, S > &arg)
IMGUI_API void PopTextWrapPos()
Definition: imgui.cpp:5616
void push_back(const T &v)
Definition: imgui.h:1206
float ChildBorderSize
Definition: imgui.h:1233
ImVec2 DisplaySize
Definition: imgui.h:1277
float V1
Definition: imgui.h:1932
IMGUI_API bool IsMouseDown(int button)
Definition: imgui.cpp:4010
IMGUI_API void AddBezierCurve(const ImVec2 &pos0, const ImVec2 &cp0, const ImVec2 &cp1, const ImVec2 &pos1, ImU32 col, float thickness, int num_segments=0)
IMGUI_API bool IsItemEdited()
Definition: imgui.cpp:4195
void init(const M_string &remappings)
ImVector< ImFontGlyph > Glyphs
Definition: imgui.h:2077
MyDocument(const char *name, bool open=true, const ImVec4 &color=ImVec4(1.0f, 1.0f, 1.0f, 1.0f))
ImVec2 ItemSpacing
Definition: imgui.h:1239
IMGUI_API ImVec2 GetItemRectMin()
Definition: imgui.cpp:4211
IMGUI_API bool IsItemActive()
Definition: imgui.cpp:4135
IMGUI_API bool ColorPicker4(const char *label, float col[4], ImGuiColorEditFlags flags=0, const float *ref_col=NULL)
IMGUI_API bool InputFloat3(const char *label, float v[3], const char *format="%.3f", ImGuiInputTextFlags flags=0)
IMGUI_API bool SliderInt4(const char *label, int v[4], int v_min, int v_max, const char *format="%d")
#define IM_FMTARGS(FMT)
Definition: imgui.h:70
IMGUI_API ImVec2 GetMouseDragDelta(int button=0, float lock_threshold=-1.0f)
Definition: imgui.cpp:4095
static void ShowDemoWindowPopups()
static void ShowExampleAppSimpleOverlay(bool *p_open)
IMGUI_API void SetItemDefaultFocus()
Definition: imgui.cpp:6318
int ImGuiTreeNodeFlags
Definition: imgui.h:143
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 *format="%.3f", const char *format_max=NULL, float power=1.0f)
IMGUI_API void EndTooltip()
Definition: imgui.cpp:6559
XmlRpcServer s
IMGUI_API void LogButtons()
Definition: imgui.cpp:8756
ImFontAtlasFlags Flags
Definition: imgui.h:2046
int ImGuiColorEditFlags
Definition: imgui.h:132
IMGUI_API bool InputInt(const char *label, int *v, int step=1, int step_fast=100, ImGuiInputTextFlags flags=0)
ImVec2 ItemInnerSpacing
Definition: imgui.h:1240
float Descent
Definition: imgui.h:2088
IMGUI_API void PopAllowKeyboardFocus()
Definition: imgui.cpp:5594
IMGUI_API bool SmallButton(const char *label)
IMGUI_API bool IsMouseHoveringRect(const ImVec2 &r_min, const ImVec2 &r_max, bool clip=true)
Definition: imgui.cpp:3940
const char * BackendPlatformName
Definition: imgui.h:1311
IMGUI_API bool BeginPopup(const char *str_id, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:6775
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 *format="%.3f", float power=1.0f)
IMGUI_API void ShowMetricsWindow(bool *p_open=NULL)
Definition: imgui.cpp:9112
IMGUI_API bool Draw(const char *label="Filter (inc,-exc)", float width=0.0f)
Definition: imgui.cpp:1984
IMGUI_API void BeginTooltip()
Definition: imgui.cpp:6519
IMGUI_API bool TreeNodeEx(const char *label, ImGuiTreeNodeFlags flags=0)
IMGUI_API bool VSliderFloat(const char *label, const ImVec2 &size, float *v, float v_min, float v_max, const char *format="%.3f", float power=1.0f)
IMGUI_API bool DragScalar(const char *label, ImGuiDataType data_type, void *v, float v_speed, const void *v_min=NULL, const void *v_max=NULL, const char *format=NULL, float power=1.0f)
IMGUI_API bool ListBox(const char *label, int *current_item, const char *const items[], int items_count, int height_in_items=-1)
float KeysDownDuration[512]
Definition: imgui.h:1391
IMGUI_API void SetNextWindowSizeConstraints(const ImVec2 &size_min, const ImVec2 &size_max, ImGuiSizeCallback custom_callback=NULL, void *custom_callback_data=NULL)
Definition: imgui.cpp:6062
static void ShowDemoWindowLayout()
IMGUI_API void Indent(float indent_w=0.0f)
Definition: imgui.cpp:6499
#define IM_ARRAYSIZE(_ARR)
Definition: imgui.h:73
IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags=0)
Definition: imgui.cpp:5853
IMGUI_API void AddTriangleFilled(const ImVec2 &a, const ImVec2 &b, const ImVec2 &c, ImU32 col)
ImGuiTextFilter Filter
IMGUI_API void PushButtonRepeat(bool repeat)
Definition: imgui.cpp:5599
ImVec2 MouseClickedPos[5]
Definition: imgui.h:1381
static void ShowExampleAppWindowTitles(bool *p_open)
IMGUI_API void AddRect(const ImVec2 &a, const ImVec2 &b, ImU32 col, float rounding=0.0f, int rounding_corners_flags=ImDrawCornerFlags_All, float thickness=1.0f)
int TextEditCallback(ImGuiInputTextCallbackData *data)
IMGUI_API ImGuiMouseCursor GetMouseCursor()
Definition: imgui.cpp:4115
int size() const
Definition: imgui.h:1580
IMGUI_API float GetColumnOffset(int column_index=-1)
Definition: imgui.cpp:8070
IMGUI_API void SetScrollHereY(float center_y_ratio=0.5f)
Definition: imgui.cpp:6296
IMGUI_API bool InputTextMultiline(const char *label, char *buf, size_t buf_size, const ImVec2 &size=ImVec2(0, 0), ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=NULL, void *user_data=NULL)
IMGUI_API void AddLine(const ImVec2 &a, const ImVec2 &b, ImU32 col, float thickness=1.0f)
static void DisplayContents(MyDocument *doc)
void DoQueueClose()
IMGUI_API bool PassFilter(const char *text, const char *text_end=NULL) const
Definition: imgui.cpp:2035
char Name[40]
Definition: imgui.h:1921
IMGUI_API void PushClipRect(ImVec2 clip_rect_min, ImVec2 clip_rect_max, bool intersect_with_current_clip_rect=false)
Definition: imgui_draw.cpp:477
ImVec4 Color
IMGUI_API void EndTabItem()
float FrameRounding
Definition: imgui.h:1237
float NavInputsDownDuration[ImGuiNavInput_COUNT]
Definition: imgui.h:1393
bool WantCaptureKeyboard
Definition: imgui.h:1362
IMGUI_API bool IsItemHovered(ImGuiHoveredFlags flags=0)
Definition: imgui.cpp:2757
ImVector< ImFont * > Fonts
Definition: imgui.h:2059
int MetricsTotalSurface
Definition: imgui.h:2090
IMGUI_API bool InputInt4(const char *label, int v[4], ImGuiInputTextFlags flags=0)
IMGUI_API ImVec2 GetItemRectSize()
Definition: imgui.cpp:4223
IMGUI_API float GetWindowWidth()
Definition: imgui.cpp:5882
IMGUI_API bool TreeNode(const char *label)
IMGUI_API bool CheckboxFlags(const char *label, unsigned int *flags, unsigned int flags_value)
const char * Name
IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2 &size, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:4339
IMGUI_API bool InputInt2(const char *label, int v[2], ImGuiInputTextFlags flags=0)
IMGUI_API bool ColorEdit4(const char *label, float col[4], ImGuiColorEditFlags flags=0)
IMGUI_API bool BeginMenuBar()
float DeltaTime
Definition: imgui.h:1278
bool WantCaptureMouse
Definition: imgui.h:1361
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))
unsigned short ImDrawIdx
Definition: imgui.h:1734
IMGUI_API bool IsMousePosValid(const ImVec2 *mouse_pos=NULL)
Definition: imgui.cpp:4084
static void NotifyOfDocumentsClosedElsewhere(ExampleAppDocuments &app)
IMGUI_API void Bullet()
unsigned short ImWchar
Definition: imgui.h:119
bool NavActive
Definition: imgui.h:1366
void AddLog(const char *fmt,...) IM_FMTARGS(2)
IMGUI_API void EndDragDropSource()
Definition: imgui.cpp:8431
static void ShowExampleAppConsole(bool *p_open)
int ImGuiInputTextFlags
Definition: imgui.h:139
static void ShowDemoWindowWidgets()
Definition: imgui_demo.cpp:391
IMGUI_API void EndDragDropTarget()
Definition: imgui.cpp:8598
IMGUI_API void SetMouseCursor(ImGuiMouseCursor type)
Definition: imgui.cpp:4120
IMGUI_API ImVec2 GetContentRegionAvail()
Definition: imgui.cpp:6109
void DoForceClose()
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 *format="%.3f", float power=1.0f)
ImVec2 DisplayOffset
Definition: imgui.h:2076
IMGUI_API float GetScrollMaxY()
Definition: imgui.cpp:6267
static void ShowDemoWindowColumns()
IMGUI_API ImDrawList * GetWindowDrawList()
Definition: imgui.cpp:6163
IMGUI_API void ShowDemoWindow(bool *p_open=NULL)
Definition: imgui_demo.cpp:170
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:4736
#define IM_ASSERT(_EXPR)
Definition: imgui.h:64
void pop_back()
Definition: imgui.h:1207
int ImGuiWindowFlags
Definition: imgui.h:144
void Draw(const char *title, bool *p_open)
IMGUI_API void PopStyleVar(int count=1)
Definition: imgui.cpp:5725
float FontSize
Definition: imgui.h:2074
ImVector< const char * > Commands
float Alpha
Definition: imgui.h:1226
IMGUI_API bool CollapsingHeader(const char *label, ImGuiTreeNodeFlags flags=0)
IMGUI_API void AddTriangle(const ImVec2 &a, const ImVec2 &b, const ImVec2 &c, ImU32 col, float thickness=1.0f)
IMGUI_API bool BeginPopupContextWindow(const char *str_id=NULL, int mouse_button=1, bool also_over_items=true)
Definition: imgui.cpp:6842
IMGUI_API bool ListBoxHeader(const char *label, const ImVec2 &size=ImVec2(0, 0))
IMGUI_API void Dummy(const ImVec2 &size)
IMGUI_API void BulletText(const char *fmt,...) IM_FMTARGS(1)
int ImGuiBackendFlags
Definition: imgui.h:131
static void Strtrim(char *str)
float w
Definition: imgui.h:178
IMGUI_API const char * GetStyleColorName(ImGuiCol idx)
Definition: imgui.cpp:5741
IMGUI_API bool IsMouseDragging(int button=0, float lock_threshold=-1.0f)
Definition: imgui.cpp:4058
IMGUI_API bool BeginChild(const char *str_id, const ImVec2 &size=ImVec2(0, 0), bool border=false, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:4287
int DisplayStart
Definition: imgui.h:1655
IMGUI_API ImVec2 GetWindowContentRegionMax()
Definition: imgui.cpp:6127
float X0
Definition: imgui.h:1931
IMGUI_API bool Step()
Definition: imgui.cpp:2168
IMGUI_API void SetScrollFromPosY(float local_y, float center_y_ratio=0.5f)
Definition: imgui.cpp:6286
IMGUI_API bool SliderFloat4(const char *label, float v[4], float v_min, float v_max, const char *format="%.3f", float power=1.0f)
int TexWidth
Definition: imgui.h:2055
static void DisplayContextMenu(MyDocument *doc)
IMGUI_API void TextUnformatted(const char *text, const char *text_end=NULL)
IMGUI_API bool InputScalar(const char *label, ImGuiDataType data_type, void *v, const void *step=NULL, const void *step_fast=NULL, const char *format=NULL, ImGuiInputTextFlags flags=0)
float MouseDownDuration[5]
Definition: imgui.h:1387
#define IMGUI_PAYLOAD_TYPE_COLOR_3F
Definition: imgui.h:873
static char * Strdup(const char *str)
IMGUI_API void Unindent(float indent_w=0.0f)
Definition: imgui.cpp:6507
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 *format="%d")
#define IM_COL32(R, G, B, A)
Definition: imgui.h:1682
IMGUI_API bool ColorEdit3(const char *label, float col[3], ImGuiColorEditFlags flags=0)
static int TextEditCallbackStub(ImGuiInputTextCallbackData *data)
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 *format="%d")
float ChildRounding
Definition: imgui.h:1232
IMGUI_API void AddText(const ImVec2 &pos, ImU32 col, const char *text_begin, const char *text_end=NULL)
float GrabMinSize
Definition: imgui.h:1246
IMGUI_API const ImFontGlyph * FindGlyphNoFallback(ImWchar c) const
IMGUI_API bool ShowStyleSelector(const char *label)
IMGUI_API ImGuiIO & GetIO()
Definition: imgui.cpp:2975
ImVector< char * > Items
float z
Definition: imgui.h:178
IMGUI_API ImFont * GetFont()
Definition: imgui.cpp:6169
IMGUI_API void EndGroup()
Definition: imgui.cpp:6431
static int Strnicmp(const char *str1, const char *str2, int n)
bool KeysDown[512]
Definition: imgui.h:1349
IMGUI_API int GetColumnIndex()
Definition: imgui.cpp:8029
IMGUI_API bool IsItemDeactivated()
Definition: imgui.cpp:4146
IMGUI_API bool IsKeyReleased(int user_key_index)
Definition: imgui.cpp:4002
IMGUI_API void Spacing()
IMGUI_API bool SliderAngle(const char *label, float *v_rad, float v_degrees_min=-360.0f, float v_degrees_max=+360.0f, const char *format="%.0f deg")
static void ShowExampleAppLayout(bool *p_open)
IMGUI_API void EndCombo()
float ScrollbarRounding
Definition: imgui.h:1245
static void ShowExampleAppDocuments(bool *p_open)
signed int ImS32
Definition: imgui.h:149
IMGUI_API void ShowStyleEditor(ImGuiStyle *ref=NULL)
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 *format="%.3f", float power=1.0f)
IMGUI_API float GetContentRegionAvailWidth()
Definition: imgui.cpp:6115
#define IMGUI_VERSION
Definition: imgui.h:48
bool KeyShift
Definition: imgui.h:1346
IMGUI_API bool VSliderInt(const char *label, const ImVec2 &size, int *v, int v_min, int v_max, const char *format="%d")
float PopupBorderSize
Definition: imgui.h:1235
IMGUI_API void PushItemWidth(float item_width)
Definition: imgui.cpp:5496
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
IMGUI_API bool IsItemFocused()
Definition: imgui.cpp:4159
IMGUI_API void Separator()
#define IM_NEWLINE
Definition: imgui_demo.cpp:90
IMGUI_API void End()
Definition: imgui.cpp:5371
bool ConfigWindowsMoveFromTitleBarOnly
Definition: imgui.h:1303
IMGUI_API bool InputFloat2(const char *label, float v[2], const char *format="%.3f", ImGuiInputTextFlags flags=0)
Definition: imgui.h:176
IMGUI_API void BeginGroup()
Definition: imgui.cpp:6406
int Size
Definition: imgui.h:1168
IMGUI_API void AddCircleFilled(const ImVec2 &centre, float radius, ImU32 col, int num_segments=12)
IMGUI_API float GetScrollX()
Definition: imgui.cpp:6252
IMGUI_API void Begin(int items_count, float items_height=-1.0f)
Definition: imgui.cpp:2141
ImTextureID TexID
Definition: imgui.h:2047
bool MouseDown[5]
Definition: imgui.h:1342
IMGUI_API bool Combo(const char *label, int *current_item, const char *const items[], int items_count, int popup_max_height_in_items=-1)
IMGUI_API void SetCursorPosX(float local_x)
Definition: imgui.cpp:6219
IMGUI_API void SameLine(float local_pos_x=0.0f, float spacing_w=-1.0f)
Definition: imgui.cpp:6476
IMGUI_API float GetColumnWidth(int column_index=-1)
Definition: imgui.cpp:8098
int ImGuiTabBarFlags
Definition: imgui.h:141
int ImGuiTabItemFlags
Definition: imgui.h:142
#define IM_MAX(_A, _B)
Definition: imgui_demo.cpp:93
IMGUI_API void EndPopup()
Definition: imgui.cpp:6817
IMGUI_API float GetTreeNodeToLabelSpacing()
bool KeyCtrl
Definition: imgui.h:1345
int ImGuiComboFlags
Definition: imgui.h:135
bool empty() const
Definition: imgui.h:1183
IMGUI_API void NextColumn()
Definition: imgui.cpp:7995
IMGUI_API bool ColorButton(const char *desc_id, const ImVec4 &col, ImGuiColorEditFlags flags=0, ImVec2 size=ImVec2(0, 0))
float x
Definition: imgui.h:178
IMGUI_API void EndTabBar()
const char * begin() const
Definition: imgui.h:1578
float IndentSpacing
Definition: imgui.h:1242
IMGUI_API bool SliderScalar(const char *label, ImGuiDataType data_type, void *v, const void *v_min, const void *v_max, const char *format=NULL, float power=1.0f)
#define IMGUI_VERSION_NUM
Definition: imgui.h:49
const char * BackendRendererName
Definition: imgui.h:1312
IMGUI_API bool BeginMainMenuBar()
static void ShowHelpMarker(const char *desc)
Definition: imgui_demo.cpp:121
ImVec2 DisplaySafeAreaPadding
Definition: imgui.h:1252
static void ShowExampleAppPropertyEditor(bool *p_open)
IMGUI_API void AddRectFilled(const ImVec2 &a, const ImVec2 &b, ImU32 col, float rounding=0.0f, int rounding_corners_flags=ImDrawCornerFlags_All)
IMGUI_API void PushFont(ImFont *font)
Definition: imgui.cpp:5553
IMGUI_API void SetNextWindowPos(const ImVec2 &pos, ImGuiCond cond=0, const ImVec2 &pivot=ImVec2(0, 0))
Definition: imgui.cpp:6045
IMGUI_API bool InvisibleButton(const char *str_id, const ImVec2 &size)
float y
Definition: imgui.h:166
static void ShowExampleMenuFile()
IMGUI_API void appendfv(const char *fmt, va_list args) IM_FMTLIST(2)
Definition: imgui.cpp:2086
IMGUI_API void EndChild()
Definition: imgui.cpp:4299
IMGUI_API float GetWindowContentRegionWidth()
Definition: imgui.cpp:6133
IMGUI_API float GetScrollMaxX()
Definition: imgui.cpp:6262
ImVec2 FramePadding
Definition: imgui.h:1236
IMGUI_API bool BeginMenu(const char *label, bool enabled=true)
IMGUI_API bool DragInt(const char *label, int *v, float v_speed=1.0f, int v_min=0, int v_max=0, const char *format="%d")
IMGUI_API float GetTextLineHeightWithSpacing()
Definition: imgui.cpp:6145
IMGUI_API void TextWrapped(const char *fmt,...) IM_FMTARGS(1)
ImVector< MyDocument > Documents
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 *format="%d")
static void ShowDemoWindowMisc()
IMGUI_API void ListBoxFooter()
IMGUI_API void TextColored(const ImVec4 &col, const char *fmt,...) IM_FMTARGS(2)
ImVec4 Colors[ImGuiCol_COUNT]
Definition: imgui.h:1257
IMGUI_API bool SliderInt(const char *label, int *v, int v_min, int v_max, const char *format="%d")
void clear()
Definition: imgui.h:1189
IMGUI_API void Text(const char *fmt,...) IM_FMTARGS(1)
IMGUI_API void LogToTTY(int max_depth=-1)
Definition: imgui.cpp:8673
float GrabRounding
Definition: imgui.h:1247
unsigned int step
ImGuiBackendFlags BackendFlags
Definition: imgui.h:1276
IMGUI_API ImVec2 GetCursorScreenPos()
Definition: imgui.cpp:6239
IMGUI_API void PushTextWrapPos(float wrap_local_pos_x=0.0f)
Definition: imgui.cpp:5609
bool KeySuper
Definition: imgui.h:1348
IMGUI_API void EndChildFrame()
Definition: imgui.cpp:4353
IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags=0)
Definition: imgui.cpp:8333
IMGUI_API void ShowAboutWindow(bool *p_open=NULL)
IMGUI_API bool SliderFloat(const char *label, float *v, float v_min, float v_max, const char *format="%.3f", float power=1.0f)
IMGUI_API void PopItemWidth()
Definition: imgui.cpp:5517
IMGUI_API void SetNextWindowBgAlpha(float alpha)
Definition: imgui.cpp:6092
static int Stricmp(const char *str1, const char *str2)
IMGUI_API void TreePop()
float U0
Definition: imgui.h:1932
static void ShowExampleAppAutoResize(bool *p_open)
bool AntiAliasedLines
Definition: imgui.h:1254
static void ShowExampleAppLongText(bool *p_open)
IMGUI_API void LogText(const char *fmt,...) IM_FMTARGS(1)
Definition: imgui.cpp:8617
IMGUI_API bool IsItemVisible()
Definition: imgui.cpp:4189
IMGUI_API bool SliderFloat3(const char *label, float v[3], float v_min, float v_max, const char *format="%.3f", float power=1.0f)
IMGUI_API double GetTime()
Definition: imgui.cpp:2994
IMGUI_API bool BeginDragDropTarget()
Definition: imgui.cpp:8516
Definition: imgui.h:2071
void ExecCommand(const char *command_line)
IMGUI_API float GetTextLineHeight()
Definition: imgui.cpp:6139
IMGUI_API void DeleteChars(int pos, int bytes_count)
IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col)
Definition: imgui.cpp:5624
IMGUI_API void LabelText(const char *label, const char *fmt,...) IM_FMTARGS(2)
float TabBorderSize
Definition: imgui.h:1249
ImGuiConfigFlags ConfigFlags
Definition: imgui.h:1275
IMGUI_API bool MenuItem(const char *label, const char *shortcut=NULL, bool selected=false, bool enabled=true)
bool IsActive() const
Definition: imgui.h:1549
ImWchar FallbackChar
Definition: imgui.h:2082
IMGUI_API int GetFrameCount()
Definition: imgui.cpp:2999
float FrameBorderSize
Definition: imgui.h:1238
IMGUI_API void End()
Definition: imgui.cpp:2157
IMGUI_API void StyleColorsLight(ImGuiStyle *dst=NULL)
Definition: imgui_draw.cpp:282
IMGUI_API bool Selectable(const char *label, bool selected=false, ImGuiSelectableFlags flags=0, const ImVec2 &size=ImVec2(0, 0))
IMGUI_API void SetNextWindowContentSize(const ImVec2 &size)
Definition: imgui.cpp:6071
IMGUI_API int GetKeyIndex(ImGuiKey imgui_key)
Definition: imgui.cpp:3956
IMGUI_API void PopButtonRepeat()
Definition: imgui.cpp:5604
bool WantTextInput
Definition: imgui.h:1363
IMGUI_API bool Checkbox(const char *label, bool *v)
static void ShowExampleAppMainMenuBar()
void DoSave()
float Ascent
Definition: imgui.h:2088
IMGUI_API void InsertChars(int pos, const char *text, const char *text_end=NULL)
ImVec2 WindowTitleAlign
Definition: imgui.h:1231
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 *format="%.3f", float power=1.0f)
ImVec2 MouseDelta
Definition: imgui.h:1374
IMGUI_API ImVec2 GetItemRectMax()
Definition: imgui.cpp:4217
IMGUI_API float GetScrollY()
Definition: imgui.cpp:6257
#define IMGUI_PAYLOAD_TYPE_COLOR_4F
Definition: imgui.h:874
std::optional< LaunchData > app
IMGUI_API void LogToClipboard(int max_depth=-1)
Definition: imgui.cpp:8717
IMGUI_API void EndMenuBar()
void clear()
Definition: imgui.h:1582
ImVec2 ButtonTextAlign
Definition: imgui.h:1250
IMGUI_API const char * GetVersion()
Definition: imgui.cpp:2914
float MouseWheel
Definition: imgui.h:1343
IMGUI_API void PushID(const char *str_id)
Definition: imgui.cpp:6347
IMGUI_API ImGuiID GetID(const char *str_id)
Definition: imgui.cpp:6378
bool KeyAlt
Definition: imgui.h:1347
ImVector< int > LineOffsets
IMGUI_API void PushAllowKeyboardFocus(bool allow_keyboard_focus)
Definition: imgui.cpp:5589
unsigned long long ImU64
Definition: imgui.h:160
float Y0
Definition: imgui.h:1931
static void ShowExampleAppLog(bool *p_open)
ImVec2 TouchExtraPadding
Definition: imgui.h:1241
IMGUI_API ImVec2 GetWindowPos()
Definition: imgui.cpp:5894
IMGUI_API ImGuiStyle & GetStyle()
Definition: imgui.cpp:2981
int ImGuiCol
Definition: imgui.h:120
IMGUI_API bool SliderInt2(const char *label, int v[2], int v_min, int v_max, const char *format="%d")
IMGUI_API bool SliderFloat2(const char *label, float v[2], float v_min, float v_max, const char *format="%.3f", float power=1.0f)
IMGUI_API void CloseCurrentPopup()
Definition: imgui.cpp:6736
IMGUI_API void PushClipRectFullScreen()
Definition: imgui_draw.cpp:495
static void ShowExampleAppCustomRendering(bool *p_open)
IMGUI_API void OpenPopup(const char *str_id)
Definition: imgui.cpp:6610
float Y1
Definition: imgui.h:1931
void AddLog(const char *fmt,...) IM_FMTARGS(2)
float WindowBorderSize
Definition: imgui.h:1229
IMGUI_API bool InputText(const char *label, char *buf, size_t buf_size, ImGuiInputTextFlags flags=0, ImGuiInputTextCallback callback=NULL, void *user_data=NULL)
float TabRounding
Definition: imgui.h:1248
float X1
Definition: imgui.h:1931
float Scale
Definition: imgui.h:2075
IMGUI_API void TextDisabled(const char *fmt,...) IM_FMTARGS(1)
float V0
Definition: imgui.h:1932
IMGUI_API void ShowUserGuide()
Definition: imgui_demo.cpp:135
IMGUI_API const ImVec4 & GetStyleColorVec4(ImGuiCol idx)
Definition: imgui.cpp:1800
ImFontConfig * ConfigData
Definition: imgui.h:2086
IMGUI_API void Columns(int count=1, const char *id=NULL, bool border=true)
Definition: imgui.cpp:8296
bool AntiAliasedFill
Definition: imgui.h:1255
IMGUI_API void SetWindowFontScale(float scale)
Definition: imgui.cpp:6184
IMGUI_API float GetFrameHeightWithSpacing()
Definition: imgui.cpp:6157
IMGUI_API bool IsMouseDoubleClicked(int button)
Definition: imgui.cpp:4051
ImFontAtlas * Fonts
Definition: imgui.h:1290
ImFont * FontDefault
Definition: imgui.h:1293
T * begin()
Definition: imgui.h:1190
IMGUI_API void StyleColorsClassic(ImGuiStyle *dst=NULL)
Definition: imgui_draw.cpp:226
ImVec2 WindowPadding
Definition: imgui.h:1227
IMGUI_API void EndMenu()
IMGUI_API bool BeginTabItem(const char *label, bool *p_open=NULL, ImGuiTabItemFlags flags=0)
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float &out_r, float &out_g, float &out_b)
Definition: imgui.cpp:1757
IMGUI_API void PopID()
Definition: imgui.cpp:6372
float WindowRounding
Definition: imgui.h:1228
short ConfigDataCount
Definition: imgui.h:2085
IMGUI_API bool SetDragDropPayload(const char *type, const void *data, size_t size, ImGuiCond cond=0)
Definition: imgui.cpp:8447
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))
IMGUI_API void SetColorEditOptions(ImGuiColorEditFlags flags)
IMGUI_API void SetKeyboardFocusHere(int offset=0)
Definition: imgui.cpp:6310
float ScrollbarSize
Definition: imgui.h:1244
IMGUI_API bool InputFloat(const char *label, float *v, float step=0.0f, float step_fast=0.0f, const char *format="%.3f", ImGuiInputTextFlags flags=0)
void * ImTextureID
Definition: imgui.h:111
IMGUI_API void LogFinish()
Definition: imgui.cpp:8732
static ImColor HSV(float h, float s, float v, float a=1.0f)
Definition: imgui.h:1705
float AdvanceX
Definition: imgui.h:1930
IMGUI_API void SetScrollX(float scroll_x)
Definition: imgui.cpp:6272
IMGUI_API void PopFont()
Definition: imgui.cpp:5563
IMGUI_API bool InputDouble(const char *label, double *v, double step=0.0f, double step_fast=0.0f, const char *format="%.6f", ImGuiInputTextFlags flags=0)
float y
Definition: imgui.h:178
void Draw(const char *title, bool *p_open=NULL)
float x
Definition: imgui.h:166
IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul=1.0f)
Definition: imgui.cpp:1784
float PopupRounding
Definition: imgui.h:1234
IMGUI_API void PopStyleColor(int count=1)
Definition: imgui.cpp:5644
GLenum type
Definition: gl.h:1033
void DoOpen()
const char * end() const
Definition: imgui.h:1579
IMGUI_API void EndMainMenuBar()
IMGUI_API bool BeginTabBar(const char *str_id, ImGuiTabBarFlags flags=0)
IMGUI_API void NewLine()
IMGUI_API bool IsPopupOpen(const char *str_id)
Definition: imgui.cpp:6594
IMGUI_API void SetWindowSize(const ImVec2 &size, ImGuiCond cond=0)
Definition: imgui.cpp:5982
IMGUI_API bool InputInt3(const char *label, int v[3], ImGuiInputTextFlags flags=0)


mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:21