Lines Matching refs:ImGui
4 // Message to the person tempted to delete this file when integrating Dear ImGui into their code base:
6 // will want to refer to and call. Have the ImGui::ShowDemoWindow() function wired in an always-available debug menu of
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,
12 // In other situation, whenever you have Dear ImGui available you probably want this to be available for reference.
71 #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.
131 ImGui::TextDisabled("(?)");
132 if (ImGui::IsItemHovered())
134 ImGui::BeginTooltip();
135 ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
136 ImGui::TextUnformatted(desc);
137 ImGui::PopTextWrapPos();
138 ImGui::EndTooltip();
143 void ImGui::ShowUserGuide()
145 ImGui::BulletText("Double-click on title bar to collapse window.");
146 ImGui::BulletText("Click and drag on lower right corner to resize window\n(double-click to auto fit window to its contents).");
147 ImGui::BulletText("Click and drag on any empty space to move window.");
148 ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
149 ImGui::BulletText("CTRL+Click on a slider or drag box to input value as text.");
150 if (ImGui::GetIO().FontAllowUserScaling)
151 ImGui::BulletText("CTRL+Mouse Wheel to zoom window contents.");
152 ImGui::BulletText("Mouse Wheel to scroll.");
153 ImGui::BulletText("While editing text:\n");
154 ImGui::Indent();
155 ImGui::BulletText("Hold SHIFT or use mouse to select text.");
156 ImGui::BulletText("CTRL+Left/Right to word jump.");
157 ImGui::BulletText("CTRL+A or double-click to select all.");
158 ImGui::BulletText("CTRL+X,CTRL+C,CTRL+V to use clipboard.");
159 ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo.");
160 ImGui::BulletText("ESCAPE to revert.");
161 ImGui::BulletText("You can apply arithmetic operators +,*,/ on numerical values.\nUse +- to subtract.");
162 ImGui::Unindent();
176 // Demonstrate most Dear ImGui features (this is big function!)
178 void ImGui::ShowDemoWindow(bool* p_open)
207 // Dear ImGui Apps (accessible from the "Help" menu)
212 if (show_app_metrics) { ImGui::ShowMetricsWindow(&show_app_metrics); }
213 if (show_app_style_editor) { ImGui::Begin("Style Editor", &show_app_style_editor); ImGui::ShowStyleEditor(); ImGui::End(); }
214 if (show_app_about) { ImGui::ShowAboutWindow(&show_app_about); }
241 ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver);
242 ImGui::SetNextWindowSize(ImVec2(550, 680), ImGuiCond_FirstUseEver);
245 if (!ImGui::Begin("ImGui Demo", p_open, window_flags))
248 ImGui::End();
251 ImGui::Text("dear imgui says hello. (%s)", IMGUI_VERSION);
254 //ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.65f); // Use 2/3 of the space for widgets and 1/3 for labels (default)
255 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.
258 if (ImGui::BeginMenuBar())
260 if (ImGui::BeginMenu("Menu"))
263 ImGui::EndMenu();
265 if (ImGui::BeginMenu("Examples"))
267 ImGui::MenuItem("Main menu bar", NULL, &show_app_main_menu_bar);
268 ImGui::MenuItem("Console", NULL, &show_app_console);
269 ImGui::MenuItem("Log", NULL, &show_app_log);
270 ImGui::MenuItem("Simple layout", NULL, &show_app_layout);
271 ImGui::MenuItem("Property editor", NULL, &show_app_property_editor);
272 ImGui::MenuItem("Long text display", NULL, &show_app_long_text);
273 ImGui::MenuItem("Auto-resizing window", NULL, &show_app_auto_resize);
274 ImGui::MenuItem("Constrained-resizing window", NULL, &show_app_constrained_resize);
275 ImGui::MenuItem("Simple overlay", NULL, &show_app_simple_overlay);
276 ImGui::MenuItem("Manipulating window titles", NULL, &show_app_window_titles);
277 ImGui::MenuItem("Custom rendering", NULL, &show_app_custom_rendering);
278 ImGui::MenuItem("Documents", NULL, &show_app_documents);
279 ImGui::EndMenu();
281 if (ImGui::BeginMenu("Help"))
283 ImGui::MenuItem("Metrics", NULL, &show_app_metrics);
284 ImGui::MenuItem("Style Editor", NULL, &show_app_style_editor);
285 ImGui::MenuItem("About Dear ImGui", NULL, &show_app_about);
286 ImGui::EndMenu();
288 ImGui::EndMenuBar();
291 ImGui::Spacing();
292 if (ImGui::CollapsingHeader("Help"))
294 ImGui::Text("PROGRAMMER GUIDE:");
295 ImGui::BulletText("Please see the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!");
296 ImGui::BulletText("Please see the comments in imgui.cpp.");
297 ImGui::BulletText("Please see the examples/ in application.");
298 ImGui::BulletText("Enable 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls.");
299 ImGui::BulletText("Enable 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.");
300 ImGui::Separator();
302 ImGui::Text("USER GUIDE:");
303 ImGui::ShowUserGuide();
306 if (ImGui::CollapsingHeader("Configuration"))
308 ImGuiIO& io = ImGui::GetIO();
310 if (ImGui::TreeNode("Configuration##2"))
312 ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
313 ImGui::CheckboxFlags("io.ConfigFlags: NavEnableGamepad", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad);
314 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.");
315 ImGui::CheckboxFlags("io.ConfigFlags: NavEnableSetMousePos", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableSetMousePos);
316 ImGui::SameLine(); ShowHelpMarker("Instruct navigation to move the mouse cursor. See comment for ImGuiConfigFlags_NavEnableSetMousePos.");
317 ImGui::CheckboxFlags("io.ConfigFlags: NoMouse", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NoMouse);
320 if (fmodf((float)ImGui::GetTime(), 0.40f) < 0.20f)
322 ImGui::SameLine();
323 ImGui::Text("<<PRESS SPACE TO DISABLE>>");
325 if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Space)))
328 ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange);
329 ImGui::SameLine(); ShowHelpMarker("Instruct back-end to not alter mouse cursor shape and visibility.");
330 ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputTextCursorBlink);
331 ImGui::SameLine(); ShowHelpMarker("Set to false to disable blinking cursor, for users who consider it distracting");
332 ImGui::Checkbox("io.ConfigWindowsResizeFromEdges", &io.ConfigWindowsResizeFromEdges);
333 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.");
334 ImGui::Checkbox("io.ConfigWindowsMoveFromTitleBarOnly", &io.ConfigWindowsMoveFromTitleBarOnly);
335 ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor);
336 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).");
337 ImGui::TreePop();
338 ImGui::Separator();
341 if (ImGui::TreeNode("Backend Flags"))
345 ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasGamepad);
346 ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasMouseCursors);
347 ImGui::CheckboxFlags("io.BackendFlags: HasSetMousePos", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasSetMousePos);
348 ImGui::TreePop();
349 ImGui::Separator();
352 if (ImGui::TreeNode("Style"))
354 ImGui::ShowStyleEditor();
355 ImGui::TreePop();
356 ImGui::Separator();
359 if (ImGui::TreeNode("Capture/Logging"))
361 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.");
363 ImGui::LogButtons();
364 ImGui::TextWrapped("You can also call ImGui::LogText() to output directly to the log without a visual output.");
365 if (ImGui::Button("Copy \"Hello, world!\" to clipboard"))
367 ImGui::LogToClipboard();
368 ImGui::LogText("Hello, world!");
369 ImGui::LogFinish();
371 ImGui::TreePop();
375 if (ImGui::CollapsingHeader("Window options"))
377 ImGui::Checkbox("No titlebar", &no_titlebar); ImGui::SameLine(150);
378 ImGui::Checkbox("No scrollbar", &no_scrollbar); ImGui::SameLine(300);
379 ImGui::Checkbox("No menu", &no_menu);
380 ImGui::Checkbox("No move", &no_move); ImGui::SameLine(150);
381 ImGui::Checkbox("No resize", &no_resize); ImGui::SameLine(300);
382 ImGui::Checkbox("No collapse", &no_collapse);
383 ImGui::Checkbox("No close", &no_close); ImGui::SameLine(150);
384 ImGui::Checkbox("No nav", &no_nav); ImGui::SameLine(300);
385 ImGui::Checkbox("No background", &no_background);
386 ImGui::Checkbox("No bring to front", &no_bring_to_front);
397 ImGui::End();
402 if (!ImGui::CollapsingHeader("Widgets"))
405 if (ImGui::TreeNode("Basic"))
408 if (ImGui::Button("Button"))
412 ImGui::SameLine();
413 ImGui::Text("Thanks for clicking me!");
417 ImGui::Checkbox("checkbox", &check);
420 ImGui::RadioButton("radio a", &e, 0); ImGui::SameLine();
421 ImGui::RadioButton("radio b", &e, 1); ImGui::SameLine();
422 ImGui::RadioButton("radio c", &e, 2);
428 ImGui::SameLine();
429 ImGui::PushID(i);
430 ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(i/7.0f, 0.6f, 0.6f));
431 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(i/7.0f, 0.7f, 0.7f));
432 ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(i/7.0f, 0.8f, 0.8f));
433 ImGui::Button("Click");
434 ImGui::PopStyleColor(3);
435 ImGui::PopID();
439 ImGui::AlignTextToFramePadding();
440 ImGui::Text("Hold to repeat:");
441 ImGui::SameLine();
445 float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
446 ImGui::PushButtonRepeat(true);
447 if (ImGui::ArrowButton("##left", ImGuiDir_Left)) { counter--; }
448 ImGui::SameLine(0.0f, spacing);
449 if (ImGui::ArrowButton("##right", ImGuiDir_Right)) { counter++; }
450 ImGui::PopButtonRepeat();
451 ImGui::SameLine();
452 ImGui::Text("%d", counter);
454 ImGui::Text("Hover over me");
455 if (ImGui::IsItemHovered())
456 ImGui::SetTooltip("I am a tooltip");
458 ImGui::SameLine();
459 ImGui::Text("- or me");
460 if (ImGui::IsItemHovered())
462 ImGui::BeginTooltip();
463 ImGui::Text("I am a fancy tooltip");
465 ImGui::PlotLines("Curve", arr, IM_ARRAYSIZE(arr));
466 ImGui::EndTooltip();
469 ImGui::Separator();
471 ImGui::LabelText("label", "Value");
478 ImGui::Combo("combo", &item_current, items, IM_ARRAYSIZE(items));
479 ImGui::SameLine(); ShowHelpMarker("Refer to the \"Combo\" section below for an explanation of the full BeginCombo/EndCombo API, and demonstration of various flags.\n");
485 ImGui::InputText("input text", str0, IM_ARRAYSIZE(str0));
486 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).");
488 ImGui::InputInt("input int", &i0);
489 ImGui::SameLine(); ShowHelpMarker("You can apply arithmetic operators +,*,/ on numerical values.\n e.g. [ 100 ], input \'*2\', result becomes [ 200 ]\nUse +- to subtract.\n");
492 ImGui::InputFloat("input float", &f0, 0.01f, 1.0f, "%.3f");
495 ImGui::InputDouble("input double", &d0, 0.01f, 1.0f, "%.8f");
498 ImGui::InputFloat("input scientific", &f1, 0.0f, 0.0f, "%e");
499 ImGui::SameLine(); ShowHelpMarker("You can input value using the scientific notation,\n e.g. \"1e+8\" becomes \"100000000\".\n");
502 ImGui::InputFloat3("input float3", vec4a);
507 ImGui::DragInt("drag int", &i1, 1);
508 ImGui::SameLine(); ShowHelpMarker("Click and drag to edit value.\nHold SHIFT/ALT for faster/slower edit.\nDouble-click or CTRL+click to input value.");
510 ImGui::DragInt("drag int 0..100", &i2, 1, 0, 100, "%d%%");
513 ImGui::DragFloat("drag float", &f1, 0.005f);
514 ImGui::DragFloat("drag small float", &f2, 0.0001f, 0.0f, 0.0f, "%.06f ns");
519 ImGui::SliderInt("slider int", &i1, -1, 3);
520 ImGui::SameLine(); ShowHelpMarker("CTRL+click to input value.");
523 ImGui::SliderFloat("slider float", &f1, 0.0f, 1.0f, "ratio = %.3f");
524 ImGui::SliderFloat("slider float (curve)", &f2, -10.0f, 10.0f, "%.4f", 2.0f);
526 ImGui::SliderAngle("slider angle", &angle);
532 ImGui::ColorEdit3("color 1", col1);
533 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");
535 ImGui::ColorEdit4("color 2", col2);
542 ImGui::ListBox("listbox\n(single select)", &listbox_item_current, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
545 //ImGui::PushItemWidth(-1);
546 //ImGui::ListBox("##listbox2", &listbox_item_current2, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
547 //ImGui::PopItemWidth();
550 ImGui::TreePop();
557 // ImGui::Text("This will be displayed only once.");
559 if (ImGui::TreeNode("Trees"))
561 if (ImGui::TreeNode("Basic trees"))
564 if (ImGui::TreeNode((void*)(intptr_t)i, "Child %d", i))
566 ImGui::Text("blah blah");
567 ImGui::SameLine();
568 if (ImGui::SmallButton("button")) { };
569 ImGui::TreePop();
571 ImGui::TreePop();
574 if (ImGui::TreeNode("Advanced, with Selectable nodes"))
578 ImGui::Checkbox("Align label with current X position)", &align_label_with_current_x_position);
579 ImGui::Text("Hello!");
581 ImGui::Unindent(ImGui::GetTreeNodeToLabelSpacing());
585 ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, ImGui::GetFontSize()*3); // Increase spacing to differentiate leaves from expanded contents.
593 bool node_open = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Node %d", i);
594 if (ImGui::IsItemClicked())
598 ImGui::Text("Blah blah\nBlah Blah");
599 ImGui::TreePop();
606 ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Leaf %d", i);
607 if (ImGui::IsItemClicked())
614 if (ImGui::GetIO().KeyCtrl)
619 ImGui::PopStyleVar();
621 ImGui::Indent(ImGui::GetTreeNodeToLabelSpacing());
622 ImGui::TreePop();
624 ImGui::TreePop();
627 if (ImGui::TreeNode("Collapsing Headers"))
630 ImGui::Checkbox("Enable extra group", &closable_group);
631 if (ImGui::CollapsingHeader("Header"))
633 ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered());
635 ImGui::Text("Some content %d", i);
637 if (ImGui::CollapsingHeader("Header with a close button", &closable_group))
639 ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered());
641 ImGui::Text("More content %d", i);
643 ImGui::TreePop();
646 if (ImGui::TreeNode("Bullets"))
648 ImGui::BulletText("Bullet point 1");
649 ImGui::BulletText("Bullet point 2\nOn multiple lines");
650 ImGui::Bullet(); ImGui::Text("Bullet point 3 (two calls)");
651 ImGui::Bullet(); ImGui::SmallButton("Button");
652 ImGui::TreePop();
655 if (ImGui::TreeNode("Text"))
657 if (ImGui::TreeNode("Colored Text"))
660 ImGui::TextColored(ImVec4(1.0f,0.0f,1.0f,1.0f), "Pink");
661 ImGui::TextColored(ImVec4(1.0f,1.0f,0.0f,1.0f), "Yellow");
662 ImGui::TextDisabled("Disabled");
663 ImGui::SameLine(); ShowHelpMarker("The TextDisabled color is stored in ImGuiStyle.");
664 ImGui::TreePop();
667 if (ImGui::TreeNode("Word Wrapping"))
670 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.");
671 ImGui::Spacing();
674 ImGui::SliderFloat("Wrap width", &wrap_width, -20, 600, "%.0f");
676 ImGui::Text("Test paragraph 1:");
677 ImVec2 pos = ImGui::GetCursorScreenPos();
678 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::PushTextWrapPos(ImGui::GetCursorPos().x + wrap_width);
680 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);
681 ImGui::GetWindowDrawList()->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(255,255,0,255));
682 ImGui::PopTextWrapPos();
684 ImGui::Text("Test paragraph 2:");
685 pos = ImGui::GetCursorScreenPos();
686 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));
687 ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + wrap_width);
688 ImGui::Text("aaaaaaaa bbbbbbbb, c cccccccc,dddddddd. d eeeeeeee ffffffff. gggggggg!hhhhhhhh");
689 ImGui::GetWindowDrawList()->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(255,255,0,255));
690 ImGui::PopTextWrapPos();
692 ImGui::TreePop();
695 if (ImGui::TreeNode("UTF-8 Text"))
705 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.");
706 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.
707 ImGui::Text("Kanjis: \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e (nihongo)");
710 ImGui::InputText("UTF-8 input", buf, IM_ARRAYSIZE(buf));
711 ImGui::TreePop();
713 ImGui::TreePop();
716 if (ImGui::TreeNode("Images"))
718 ImGuiIO& io = ImGui::GetIO();
719 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!");
725 // 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.
727 // Consider using the lower-level ImDrawList::AddImage() API, via ImGui::GetWindowDrawList()->AddImage().
732 ImGui::Text("%.0fx%.0f", my_tex_w, my_tex_h);
733 ImVec2 pos = ImGui::GetCursorScreenPos();
734 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));
735 if (ImGui::IsItemHovered())
737 ImGui::BeginTooltip();
742 ImGui::Text("Min: (%.2f, %.2f)", region_x, region_y);
743 ImGui::Text("Max: (%.2f, %.2f)", region_x + region_sz, region_y + region_sz);
746 ImGui::Image(my_tex_id, ImVec2(region_sz * zoom, region_sz * zoom), uv0, uv1, ImColor(255,255,255,255), ImColor(255,255,255,128));
747 ImGui::EndTooltip();
749 ImGui::TextWrapped("And now some textured buttons..");
753 ImGui::PushID(i);
755 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)))
757 ImGui::PopID();
758 ImGui::SameLine();
760 ImGui::NewLine();
761 ImGui::Text("Pressed %d times.", pressed_count);
762 ImGui::TreePop();
765 if (ImGui::TreeNode("Combo"))
769 ImGui::CheckboxFlags("ImGuiComboFlags_PopupAlignLeft", (unsigned int*)&flags, ImGuiComboFlags_PopupAlignLeft);
770 if (ImGui::CheckboxFlags("ImGuiComboFlags_NoArrowButton", (unsigned int*)&flags, ImGuiComboFlags_NoArrowButton))
772 if (ImGui::CheckboxFlags("ImGuiComboFlags_NoPreview", (unsigned int*)&flags, ImGuiComboFlags_NoPreview))
779 if (ImGui::BeginCombo("combo 1", item_current, flags)) // The second parameter is the label previewed before opening the combo.
784 if (ImGui::Selectable(items[n], is_selected))
787 ImGui::SetItemDefaultFocus(); // Set the initial focus when opening the combo (scrolling + for keyboard navigation support in the upcoming navigation branch)
789 ImGui::EndCombo();
794 ImGui::Combo("combo 2 (one-liner)", &item_current_2, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
798 ImGui::Combo("combo 3 (array)", &item_current_3, items, IM_ARRAYSIZE(items));
803 ImGui::Combo("combo 4 (function)", &item_current_4, &FuncHolder::ItemGetter, items, IM_ARRAYSIZE(items));
805 ImGui::TreePop();
808 if (ImGui::TreeNode("Selectables"))
814 if (ImGui::TreeNode("Basic"))
817 ImGui::Selectable("1. I am selectable", &selection[0]);
818 ImGui::Selectable("2. I am selectable", &selection[1]);
819 ImGui::Text("3. I am not selectable");
820 ImGui::Selectable("4. I am selectable", &selection[3]);
821 if (ImGui::Selectable("5. I am double clickable", selection[4], ImGuiSelectableFlags_AllowDoubleClick))
822 if (ImGui::IsMouseDoubleClicked(0))
824 ImGui::TreePop();
826 if (ImGui::TreeNode("Selection State: Single Selection"))
833 if (ImGui::Selectable(buf, selected == n))
836 ImGui::TreePop();
838 if (ImGui::TreeNode("Selection State: Multiple Selection"))
846 if (ImGui::Selectable(buf, selection[n]))
848 if (!ImGui::GetIO().KeyCtrl) // Clear selection when CTRL is not held
853 ImGui::TreePop();
855 if (ImGui::TreeNode("Rendering more text into the same line"))
859 ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
860 ImGui::Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(300); ImGui::Text("12,345 bytes");
861 ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
862 ImGui::TreePop();
864 if (ImGui::TreeNode("In columns"))
866 ImGui::Columns(3, NULL, false);
871 if (ImGui::Selectable(label, &selected[i])) {}
872 ImGui::NextColumn();
874 ImGui::Columns(1);
875 ImGui::TreePop();
877 if (ImGui::TreeNode("Grid"))
882 ImGui::PushID(i);
883 if (ImGui::Selectable("Sailor", &selected[i], 0, ImVec2(50,50)))
893 if ((i % 4) < 3) ImGui::SameLine();
894 ImGui::PopID();
896 ImGui::TreePop();
898 if (ImGui::TreeNode("Alignment"))
909 if (x > 0) ImGui::SameLine();
910 ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, alignment);
911 ImGui::Selectable(name, &selected[3*y+x], ImGuiSelectableFlags_None, ImVec2(80,80));
912 ImGui::PopStyleVar();
915 ImGui::TreePop();
917 ImGui::TreePop();
920 if (ImGui::TreeNode("Filtered Text Input"))
922 static char buf1[64] = ""; ImGui::InputText("default", buf1, 64);
923 static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal);
924 static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
925 static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase);
926 static char buf5[64] = ""; ImGui::InputText("no blank", buf5, 64, ImGuiInputTextFlags_CharsNoBlank);
928 static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters);
930 ImGui::Text("Password input");
932 ImGui::InputText("password", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
933 ImGui::SameLine(); ShowHelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n");
934 ImGui::InputText("password (clear)", bufpass, 64, ImGuiInputTextFlags_CharsNoBlank);
936 ImGui::TreePop();
939 if (ImGui::TreeNode("Multi-line Text Input"))
957 ImGui::Checkbox("Read-only", &read_only);
959 ImGui::InputTextMultiline("##source", text, IM_ARRAYSIZE(text), ImVec2(-1.0f, ImGui::GetTextLineHeight() * 16), flags);
960 ImGui::TreePop();
963 if (ImGui::TreeNode("Plots Widgets"))
966 ImGui::Checkbox("Animate", &animate);
969 ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr));
977 refresh_time = ImGui::GetTime();
978 while (refresh_time < ImGui::GetTime()) // Create dummy data at fixed 60 hz rate for the demo
986 ImGui::PlotLines("Lines", values, IM_ARRAYSIZE(values), values_offset, "avg 0.0", -1.0f, 1.0f, ImVec2(0,80));
987 ImGui::PlotHistogram("Histogram", arr, IM_ARRAYSIZE(arr), 0, NULL, 0.0f, 1.0f, ImVec2(0,80));
997 ImGui::Separator();
998 ImGui::PushItemWidth(100); ImGui::Combo("func", &func_type, "Sin\0Saw\0"); ImGui::PopItemWidth();
999 ImGui::SameLine();
1000 ImGui::SliderInt("Sample count", &display_count, 1, 400);
1002 ImGui::PlotLines("Lines", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0,80));
1003 ImGui::PlotHistogram("Histogram", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0,80));
1004 ImGui::Separator();
1010 progress += progress_dir * 0.4f * ImGui::GetIO().DeltaTime;
1016 ImGui::ProgressBar(progress, ImVec2(0.0f,0.0f));
1017 ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
1018 ImGui::Text("Progress Bar");
1023 ImGui::ProgressBar(progress, ImVec2(0.f,0.f), buf);
1024 ImGui::TreePop();
1027 if (ImGui::TreeNode("Color/Picker Widgets"))
1036 ImGui::Checkbox("With Alpha Preview", &alpha_preview);
1037 ImGui::Checkbox("With Half Alpha Preview", &alpha_half_preview);
1038 ImGui::Checkbox("With Drag and Drop", &drag_and_drop);
1039 ImGui::Checkbox("With Options Menu", &options_menu); ImGui::SameLine(); ShowHelpMarker("Right-click on the individual color widget to show options.");
1040 ImGui::Checkbox("With HDR", &hdr); ImGui::SameLine(); ShowHelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets.");
1043 ImGui::Text("Color widget:");
1044 ImGui::SameLine(); ShowHelpMarker("Click on the colored square to open a color picker.\nCTRL+click on individual component to input value.\n");
1045 ImGui::ColorEdit3("MyColor##1", (float*)&color, misc_flags);
1047 ImGui::Text("Color widget HSV with Alpha:");
1048 ImGui::ColorEdit4("MyColor##2", (float*)&color, ImGuiColorEditFlags_HSV | misc_flags);
1050 ImGui::Text("Color widget with Float Display:");
1051 ImGui::ColorEdit4("MyColor##2f", (float*)&color, ImGuiColorEditFlags_Float | misc_flags);
1053 ImGui::Text("Color button with Picker:");
1054 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.");
1055 ImGui::ColorEdit4("MyColor##3", (float*)&color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | misc_flags);
1057 ImGui::Text("Color button with Custom Picker Popup:");
1066 ImGui::ColorConvertHSVtoRGB(n / 31.0f, 0.8f, 0.8f, saved_palette[n].x, saved_palette[n].y, saved_palette[n].z);
1073 bool open_popup = ImGui::ColorButton("MyColor##3b", color, misc_flags);
1074 ImGui::SameLine();
1075 open_popup |= ImGui::Button("Palette");
1078 ImGui::OpenPopup("mypicker");
1081 if (ImGui::BeginPopup("mypicker"))
1083 ImGui::Text("MY CUSTOM COLOR PICKER WITH AN AMAZING PALETTE!");
1084 ImGui::Separator();
1085 ImGui::ColorPicker4("##picker", (float*)&color, misc_flags | ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_NoSmallPreview);
1086 ImGui::SameLine();
1088 ImGui::BeginGroup(); // Lock X position
1089 ImGui::Text("Current");
1090 ImGui::ColorButton("##current", color, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(60,40));
1091 ImGui::Text("Previous");
1092 if (ImGui::ColorButton("##previous", backup_color, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(60,40)))
1094 ImGui::Separator();
1095 ImGui::Text("Palette");
1098 ImGui::PushID(n);
1100 ImGui::SameLine(0.0f, ImGui::GetStyle().ItemSpacing.y);
1101 if (ImGui::ColorButton("##palette", saved_palette[n], ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoTooltip, ImVec2(20,20)))
1106 if (ImGui::BeginDragDropTarget())
1108 if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F))
1110 if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F))
1112 ImGui::EndDragDropTarget();
1115 ImGui::PopID();
1117 ImGui::EndGroup();
1118 ImGui::EndPopup();
1121 ImGui::Text("Color button only:");
1122 ImGui::ColorButton("MyColor##3c", *(ImVec4*)&color, misc_flags, ImVec2(80,80));
1124 ImGui::Text("Color picker:");
1132 ImGui::Checkbox("With Alpha", &alpha);
1133 ImGui::Checkbox("With Alpha Bar", &alpha_bar);
1134 ImGui::Checkbox("With Side Preview", &side_preview);
1137 ImGui::SameLine();
1138 ImGui::Checkbox("With Ref Color", &ref_color);
1141 ImGui::SameLine();
1142 ImGui::ColorEdit4("##RefColor", &ref_color_v.x, ImGuiColorEditFlags_NoInputs | misc_flags);
1145 ImGui::Combo("Inputs Mode", &inputs_mode, "All Inputs\0No Inputs\0RGB Input\0HSV Input\0HEX Input\0");
1146 ImGui::Combo("Picker Mode", &picker_mode, "Auto/Current\0Hue bar + SV rect\0Hue wheel + SV triangle\0");
1147 ImGui::SameLine(); ShowHelpMarker("User can right-click the picker to change mode.");
1158 ImGui::ColorPicker4("MyColor##4", (float*)&color, flags, ref_color ? &ref_color_v.x : NULL);
1160 ImGui::Text("Programmatically set defaults:");
1161 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.");
1162 if (ImGui::Button("Default: Uint8 + HSV + Hue Bar"))
1163 ImGui::SetColorEditOptions(ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_HSV | ImGuiColorEditFlags_PickerHueBar);
1164 if (ImGui::Button("Default: Float + HDR + Hue Wheel"))
1165 ImGui::SetColorEditOptions(ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_PickerHueWheel);
1167 ImGui::TreePop();
1170 if (ImGui::TreeNode("Range Widgets"))
1174 ImGui::DragFloatRange2("range", &begin, &end, 0.25f, 0.0f, 100.0f, "Min: %.1f %%", "Max: %.1f %%");
1175 ImGui::DragIntRange2("range int (no bounds)", &begin_i, &end_i, 5, 0, 0, "Min: %d units", "Max: %d units");
1176 ImGui::TreePop();
1179 if (ImGui::TreeNode("Data Types"))
1217 ImGui::Text("Drags:");
1218 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.");
1219 ImGui::DragScalar("drag s32", ImGuiDataType_S32, &s32_v, drag_speed, drag_clamp ? &s32_zero : NULL, drag_clamp ? &s32_fifty : NULL);
1220 ImGui::DragScalar("drag u32", ImGuiDataType_U32, &u32_v, drag_speed, drag_clamp ? &u32_zero : NULL, drag_clamp ? &u32_fifty : NULL, "%u ms");
1221 ImGui::DragScalar("drag s64", ImGuiDataType_S64, &s64_v, drag_speed, drag_clamp ? &s64_zero : NULL, drag_clamp ? &s64_fifty : NULL);
1222 ImGui::DragScalar("drag u64", ImGuiDataType_U64, &u64_v, drag_speed, drag_clamp ? &u64_zero : NULL, drag_clamp ? &u64_fifty : NULL);
1223 ImGui::DragScalar("drag float", ImGuiDataType_Float, &f32_v, 0.005f, &f32_zero, &f32_one, "%f", 1.0f);
1224 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.");
1225 ImGui::DragScalar("drag double", ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, NULL, "%.10f grams", 1.0f);
1226 ImGui::DragScalar("drag double ^2", ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, &f64_one, "0 < %.10f < 1", 2.0f);
1228 ImGui::Text("Sliders");
1229 ImGui::SliderScalar("slider s32 low", ImGuiDataType_S32, &s32_v, &s32_zero, &s32_fifty,"%d");
1230 ImGui::SliderScalar("slider s32 high", ImGuiDataType_S32, &s32_v, &s32_hi_a, &s32_hi_b, "%d");
1231 ImGui::SliderScalar("slider s32 full", ImGuiDataType_S32, &s32_v, &s32_min, &s32_max, "%d");
1232 ImGui::SliderScalar("slider u32 low", ImGuiDataType_U32, &u32_v, &u32_zero, &u32_fifty,"%u");
1233 ImGui::SliderScalar("slider u32 high", ImGuiDataType_U32, &u32_v, &u32_hi_a, &u32_hi_b, "%u");
1234 ImGui::SliderScalar("slider u32 full", ImGuiDataType_U32, &u32_v, &u32_min, &u32_max, "%u");
1235 ImGui::SliderScalar("slider s64 low", ImGuiDataType_S64, &s64_v, &s64_zero, &s64_fifty,"%I64d");
1236 ImGui::SliderScalar("slider s64 high", ImGuiDataType_S64, &s64_v, &s64_hi_a, &s64_hi_b, "%I64d");
1237 ImGui::SliderScalar("slider s64 full", ImGuiDataType_S64, &s64_v, &s64_min, &s64_max, "%I64d");
1238 ImGui::SliderScalar("slider u64 low", ImGuiDataType_U64, &u64_v, &u64_zero, &u64_fifty,"%I64u ms");
1239 ImGui::SliderScalar("slider u64 high", ImGuiDataType_U64, &u64_v, &u64_hi_a, &u64_hi_b, "%I64u ms");
1240 ImGui::SliderScalar("slider u64 full", ImGuiDataType_U64, &u64_v, &u64_min, &u64_max, "%I64u ms");
1241 ImGui::SliderScalar("slider float low", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one);
1242 ImGui::SliderScalar("slider float low^2", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one, "%.10f", 2.0f);
1243 ImGui::SliderScalar("slider float high", ImGuiDataType_Float, &f32_v, &f32_lo_a, &f32_hi_a, "%e");
1244 ImGui::SliderScalar("slider double low", ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f grams", 1.0f);
1245 ImGui::SliderScalar("slider double low^2",ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f", 2.0f);
1246 ImGui::SliderScalar("slider double high", ImGuiDataType_Double, &f64_v, &f64_lo_a, &f64_hi_a, "%e grams", 1.0f);
1249 ImGui::Text("Inputs");
1250 ImGui::Checkbox("Show step buttons", &inputs_step);
1251 ImGui::InputScalar("input s32", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%d");
1252 ImGui::InputScalar("input s32 hex", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal);
1253 ImGui::InputScalar("input u32", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%u");
1254 ImGui::InputScalar("input u32 hex", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal);
1255 ImGui::InputScalar("input s64", ImGuiDataType_S64, &s64_v, inputs_step ? &s64_one : NULL);
1256 ImGui::InputScalar("input u64", ImGuiDataType_U64, &u64_v, inputs_step ? &u64_one : NULL);
1257 ImGui::InputScalar("input float", ImGuiDataType_Float, &f32_v, inputs_step ? &f32_one : NULL);
1258 ImGui::InputScalar("input double", ImGuiDataType_Double, &f64_v, inputs_step ? &f64_one : NULL);
1260 ImGui::TreePop();
1263 if (ImGui::TreeNode("Multi-component Widgets"))
1268 ImGui::InputFloat2("input float2", vec4f);
1269 ImGui::DragFloat2("drag float2", vec4f, 0.01f, 0.0f, 1.0f);
1270 ImGui::SliderFloat2("slider float2", vec4f, 0.0f, 1.0f);
1271 ImGui::InputInt2("input int2", vec4i);
1272 ImGui::DragInt2("drag int2", vec4i, 1, 0, 255);
1273 ImGui::SliderInt2("slider int2", vec4i, 0, 255);
1274 ImGui::Spacing();
1276 ImGui::InputFloat3("input float3", vec4f);
1277 ImGui::DragFloat3("drag float3", vec4f, 0.01f, 0.0f, 1.0f);
1278 ImGui::SliderFloat3("slider float3", vec4f, 0.0f, 1.0f);
1279 ImGui::InputInt3("input int3", vec4i);
1280 ImGui::DragInt3("drag int3", vec4i, 1, 0, 255);
1281 ImGui::SliderInt3("slider int3", vec4i, 0, 255);
1282 ImGui::Spacing();
1284 ImGui::InputFloat4("input float4", vec4f);
1285 ImGui::DragFloat4("drag float4", vec4f, 0.01f, 0.0f, 1.0f);
1286 ImGui::SliderFloat4("slider float4", vec4f, 0.0f, 1.0f);
1287 ImGui::InputInt4("input int4", vec4i);
1288 ImGui::DragInt4("drag int4", vec4i, 1, 0, 255);
1289 ImGui::SliderInt4("slider int4", vec4i, 0, 255);
1291 ImGui::TreePop();
1294 if (ImGui::TreeNode("Vertical Sliders"))
1297 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(spacing, spacing));
1300 ImGui::VSliderInt("##int", ImVec2(18,160), &int_value, 0, 5);
1301 ImGui::SameLine();
1304 ImGui::PushID("set1");
1307 if (i > 0) ImGui::SameLine();
1308 ImGui::PushID(i);
1309 ImGui::PushStyleColor(ImGuiCol_FrameBg, (ImVec4)ImColor::HSV(i/7.0f, 0.5f, 0.5f));
1310 ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, (ImVec4)ImColor::HSV(i/7.0f, 0.6f, 0.5f));
1311 ImGui::PushStyleColor(ImGuiCol_FrameBgActive, (ImVec4)ImColor::HSV(i/7.0f, 0.7f, 0.5f));
1312 ImGui::PushStyleColor(ImGuiCol_SliderGrab, (ImVec4)ImColor::HSV(i/7.0f, 0.9f, 0.9f));
1313 ImGui::VSliderFloat("##v", ImVec2(18,160), &values[i], 0.0f, 1.0f, "");
1314 if (ImGui::IsItemActive() || ImGui::IsItemHovered())
1315 ImGui::SetTooltip("%.3f", values[i]);
1316 ImGui::PopStyleColor(4);
1317 ImGui::PopID();
1319 ImGui::PopID();
1321 ImGui::SameLine();
1322 ImGui::PushID("set2");
1328 if (nx > 0) ImGui::SameLine();
1329 ImGui::BeginGroup();
1332 ImGui::PushID(nx*rows+ny);
1333 ImGui::VSliderFloat("##v", small_slider_size, &values2[nx], 0.0f, 1.0f, "");
1334 if (ImGui::IsItemActive() || ImGui::IsItemHovered())
1335 ImGui::SetTooltip("%.3f", values2[nx]);
1336 ImGui::PopID();
1338 ImGui::EndGroup();
1340 ImGui::PopID();
1342 ImGui::SameLine();
1343 ImGui::PushID("set3");
1346 if (i > 0) ImGui::SameLine();
1347 ImGui::PushID(i);
1348 ImGui::PushStyleVar(ImGuiStyleVar_GrabMinSize, 40);
1349 ImGui::VSliderFloat("##v", ImVec2(40,160), &values[i], 0.0f, 1.0f, "%.2f\nsec");
1350 ImGui::PopStyleVar();
1351 ImGui::PopID();
1353 ImGui::PopID();
1354 ImGui::PopStyleVar();
1355 ImGui::TreePop();
1358 if (ImGui::TreeNode("Drag and Drop"))
1364 ImGui::BulletText("Drag and drop in standard widgets");
1365 ImGui::Indent();
1368 ImGui::ColorEdit3("color 1", col1);
1369 ImGui::ColorEdit4("color 2", col2);
1370 ImGui::Unindent();
1374 ImGui::BulletText("Drag and drop to copy/swap items");
1375 ImGui::Indent();
1383 if (ImGui::RadioButton("Copy", mode == Mode_Copy)) { mode = Mode_Copy; } ImGui::SameLine();
1384 if (ImGui::RadioButton("Move", mode == Mode_Move)) { mode = Mode_Move; } ImGui::SameLine();
1385 if (ImGui::RadioButton("Swap", mode == Mode_Swap)) { mode = Mode_Swap; }
1389 ImGui::PushID(n);
1391 ImGui::SameLine();
1392 ImGui::Button(names[n], ImVec2(60,60));
1395 if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None))
1397 ImGui::SetDragDropPayload("DND_DEMO_CELL", &n, sizeof(int)); // Set payload to carry the index of our item (could be anything)
1398 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.)
1399 if (mode == Mode_Move) { ImGui::Text("Move %s", names[n]); }
1400 if (mode == Mode_Swap) { ImGui::Text("Swap %s", names[n]); }
1401 ImGui::EndDragDropSource();
1403 if (ImGui::BeginDragDropTarget())
1405 if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("DND_DEMO_CELL"))
1425 ImGui::EndDragDropTarget();
1427 ImGui::PopID();
1429 ImGui::Unindent();
1432 ImGui::TreePop();
1435 if (ImGui::TreeNode("Querying Status (Active/Focused/Hovered etc.)"))
1442 ImGui::RadioButton("Text", &item_type, 0);
1443 ImGui::RadioButton("Button", &item_type, 1);
1444 ImGui::RadioButton("Checkbox", &item_type, 2);
1445 ImGui::RadioButton("SliderFloat", &item_type, 3);
1446 ImGui::RadioButton("ColorEdit4", &item_type, 4);
1447 ImGui::RadioButton("ListBox", &item_type, 5);
1448 ImGui::Separator();
1450 if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction
1451 if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button
1452 if (item_type == 2) { ret = ImGui::Checkbox("ITEM: Checkbox", &b); } // Testing checkbox
1453 if (item_type == 3) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item
1454 if (item_type == 4) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
1455 if (item_type == 5) { const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
1456 ImGui::BulletText(
1474 ImGui::IsItemFocused(),
1475 ImGui::IsItemHovered(),
1476 ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup),
1477 ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem),
1478 ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenOverlapped),
1479 ImGui::IsItemHovered(ImGuiHoveredFlags_RectOnly),
1480 ImGui::IsItemActive(),
1481 ImGui::IsItemEdited(),
1482 ImGui::IsItemActivated(),
1483 ImGui::IsItemDeactivated(),
1484 ImGui::IsItemDeactivatedAfterEdit(),
1485 ImGui::IsItemVisible(),
1486 ImGui::GetItemRectMin().x, ImGui::GetItemRectMin().y,
1487 ImGui::GetItemRectMax().x, ImGui::GetItemRectMax().y,
1488 ImGui::GetItemRectSize().x, ImGui::GetItemRectSize().y
1492 ImGui::Checkbox("Embed everything inside a child window (for additional testing)", &embed_all_inside_a_child_window);
1494 ImGui::BeginChild("outer_child", ImVec2(0, ImGui::GetFontSize() * 20), true);
1497 ImGui::BulletText(
1503 ImGui::IsWindowFocused(),
1504 ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows),
1505 ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow),
1506 ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow),
1507 ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow));
1510 ImGui::BulletText(
1518 ImGui::IsWindowHovered(),
1519 ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup),
1520 ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem),
1521 ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows),
1522 ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow),
1523 ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow),
1524 ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow));
1526 ImGui::BeginChild("child", ImVec2(0, 50), true);
1527 ImGui::Text("This is another child window for testing the _ChildWindows flag.");
1528 ImGui::EndChild();
1530 ImGui::EndChild();
1535 ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window);
1538 ImGui::Begin("Title bar Hovered/Active tests", &test_window);
1539 if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered()
1541 if (ImGui::MenuItem("Close")) { test_window = false; }
1542 ImGui::EndPopup();
1544 ImGui::Text(
1547 ImGui::IsItemHovered(), ImGui::IsItemActive());
1548 ImGui::End();
1551 ImGui::TreePop();
1557 if (!ImGui::CollapsingHeader("Layout"))
1560 if (ImGui::TreeNode("Child windows"))
1565 ImGui::Checkbox("Disable Mouse Wheel", &disable_mouse_wheel);
1566 ImGui::Checkbox("Disable Menu", &disable_menu);
1569 bool goto_line = ImGui::Button("Goto");
1570 ImGui::SameLine();
1571 ImGui::PushItemWidth(100);
1572 goto_line |= ImGui::InputInt("##Line", &line, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue);
1573 ImGui::PopItemWidth();
1578 ImGui::BeginChild("Child1", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f, 260), false, window_flags);
1581 ImGui::Text("%04d: scrollable region", i);
1583 ImGui::SetScrollHereY();
1586 ImGui::SetScrollHereY();
1587 ImGui::EndChild();
1590 ImGui::SameLine();
1595 ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f);
1596 ImGui::BeginChild("Child2", ImVec2(0, 260), true, window_flags);
1597 if (!disable_menu && ImGui::BeginMenuBar())
1599 if (ImGui::BeginMenu("Menu"))
1602 ImGui::EndMenu();
1604 ImGui::EndMenuBar();
1606 ImGui::Columns(2);
1611 ImGui::Button(buf, ImVec2(-1.0f, 0.0f));
1612 ImGui::NextColumn();
1614 ImGui::EndChild();
1615 ImGui::PopStyleVar();
1618 ImGui::Separator();
1624 // - Using ImGui::GetItemRectMin/Max() to query the "item" state (because the child window is an item from the POV of the parent window)
1627 ImGui::SetCursorPosX(50);
1628 ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(255, 0, 0, 100));
1629 ImGui::BeginChild("blah", ImVec2(200, 100), true, ImGuiWindowFlags_None);
1631 ImGui::Text("Some test %d", n);
1632 ImGui::EndChild();
1633 ImVec2 child_rect_min = ImGui::GetItemRectMin();
1634 ImVec2 child_rect_max = ImGui::GetItemRectMax();
1635 ImGui::PopStyleColor();
1636 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);
1639 ImGui::TreePop();
1642 if (ImGui::TreeNode("Widgets Width"))
1645 ImGui::Text("PushItemWidth(100)");
1646 ImGui::SameLine(); ShowHelpMarker("Fixed width.");
1647 ImGui::PushItemWidth(100);
1648 ImGui::DragFloat("float##1", &f);
1649 ImGui::PopItemWidth();
1651 ImGui::Text("PushItemWidth(GetWindowWidth() * 0.5f)");
1652 ImGui::SameLine(); ShowHelpMarker("Half of window width.");
1653 ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.5f);
1654 ImGui::DragFloat("float##2", &f);
1655 ImGui::PopItemWidth();
1657 ImGui::Text("PushItemWidth(GetContentRegionAvailWidth() * 0.5f)");
1658 ImGui::SameLine(); ShowHelpMarker("Half of available width.\n(~ right-cursor_pos)\n(works within a column set)");
1659 ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() * 0.5f);
1660 ImGui::DragFloat("float##3", &f);
1661 ImGui::PopItemWidth();
1663 ImGui::Text("PushItemWidth(-100)");
1664 ImGui::SameLine(); ShowHelpMarker("Align to right edge minus 100");
1665 ImGui::PushItemWidth(-100);
1666 ImGui::DragFloat("float##4", &f);
1667 ImGui::PopItemWidth();
1669 ImGui::Text("PushItemWidth(-1)");
1670 ImGui::SameLine(); ShowHelpMarker("Align to right edge");
1671 ImGui::PushItemWidth(-1);
1672 ImGui::DragFloat("float##5", &f);
1673 ImGui::PopItemWidth();
1675 ImGui::TreePop();
1678 if (ImGui::TreeNode("Basic Horizontal Layout"))
1680 ImGui::TextWrapped("(Use ImGui::SameLine() to keep adding items to the right of the preceding item)");
1683 ImGui::Text("Two items: Hello"); ImGui::SameLine();
1684 ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
1687 ImGui::Text("More spacing: Hello"); ImGui::SameLine(0, 20);
1688 ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
1691 ImGui::AlignTextToFramePadding();
1692 ImGui::Text("Normal buttons"); ImGui::SameLine();
1693 ImGui::Button("Banana"); ImGui::SameLine();
1694 ImGui::Button("Apple"); ImGui::SameLine();
1695 ImGui::Button("Corniflower");
1698 ImGui::Text("Small buttons"); ImGui::SameLine();
1699 ImGui::SmallButton("Like this one"); ImGui::SameLine();
1700 ImGui::Text("can fit within a text block.");
1703 ImGui::Text("Aligned");
1704 ImGui::SameLine(150); ImGui::Text("x=150");
1705 ImGui::SameLine(300); ImGui::Text("x=300");
1706 ImGui::Text("Aligned");
1707 ImGui::SameLine(150); ImGui::SmallButton("x=150");
1708 ImGui::SameLine(300); ImGui::SmallButton("x=300");
1712 ImGui::Checkbox("My", &c1); ImGui::SameLine();
1713 ImGui::Checkbox("Tailor", &c2); ImGui::SameLine();
1714 ImGui::Checkbox("Is", &c3); ImGui::SameLine();
1715 ImGui::Checkbox("Rich", &c4);
1719 ImGui::PushItemWidth(80);
1722 ImGui::Combo("Combo", &item, items, IM_ARRAYSIZE(items)); ImGui::SameLine();
1723 ImGui::SliderFloat("X", &f0, 0.0f, 5.0f); ImGui::SameLine();
1724 ImGui::SliderFloat("Y", &f1, 0.0f, 5.0f); ImGui::SameLine();
1725 ImGui::SliderFloat("Z", &f2, 0.0f, 5.0f);
1726 ImGui::PopItemWidth();
1728 ImGui::PushItemWidth(80);
1729 ImGui::Text("Lists:");
1733 if (i > 0) ImGui::SameLine();
1734 ImGui::PushID(i);
1735 ImGui::ListBox("", &selection[i], items, IM_ARRAYSIZE(items));
1736 ImGui::PopID();
1737 //if (ImGui::IsItemHovered()) ImGui::SetTooltip("ListBox %d hovered", i);
1739 ImGui::PopItemWidth();
1743 ImGui::Button("A", button_sz); ImGui::SameLine();
1744 ImGui::Dummy(button_sz); ImGui::SameLine();
1745 ImGui::Button("B", button_sz);
1748 ImGui::Text("Manually wrapping:");
1749 ImGuiStyle& style = ImGui::GetStyle();
1751 float window_visible_x2 = ImGui::GetWindowPos().x + ImGui::GetWindowContentRegionMax().x;
1754 ImGui::PushID(n);
1755 ImGui::Button("Box", button_sz);
1756 float last_button_x2 = ImGui::GetItemRectMax().x;
1759 ImGui::SameLine();
1760 ImGui::PopID();
1763 ImGui::TreePop();
1766 if (ImGui::TreeNode("Tabs"))
1768 if (ImGui::TreeNode("Basic"))
1771 if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
1773 if (ImGui::BeginTabItem("Avocado"))
1775 ImGui::Text("This is the Avocado tab!\nblah blah blah blah blah");
1776 ImGui::EndTabItem();
1778 if (ImGui::BeginTabItem("Broccoli"))
1780 ImGui::Text("This is the Broccoli tab!\nblah blah blah blah blah");
1781 ImGui::EndTabItem();
1783 if (ImGui::BeginTabItem("Cucumber"))
1785 ImGui::Text("This is the Cucumber tab!\nblah blah blah blah blah");
1786 ImGui::EndTabItem();
1788 ImGui::EndTabBar();
1790 ImGui::Separator();
1791 ImGui::TreePop();
1794 if (ImGui::TreeNode("Advanced & Close Button"))
1798 ImGui::CheckboxFlags("ImGuiTabBarFlags_Reorderable", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_Reorderable);
1799 ImGui::CheckboxFlags("ImGuiTabBarFlags_AutoSelectNewTabs", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_AutoSelectNewTabs);
1800 ImGui::CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_TabListPopupButton);
1801 ImGui::CheckboxFlags("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_NoCloseWithMiddleMouseButton);
1804 if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown))
1806 if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", (unsigned int*)&tab_bar_flags, ImGuiTabBarFlags_FittingPolicyScroll))
1814 if (n > 0) { ImGui::SameLine(); }
1815 ImGui::Checkbox(names[n], &opened[n]);
1819 if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags))
1822 if (opened[n] && ImGui::BeginTabItem(names[n], &opened[n]))
1824 ImGui::Text("This is the %s tab!", names[n]);
1826 ImGui::Text("I am an odd tab.");
1827 ImGui::EndTabItem();
1829 ImGui::EndTabBar();
1831 ImGui::Separator();
1832 ImGui::TreePop();
1834 ImGui::TreePop();
1837 if (ImGui::TreeNode("Groups"))
1839 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.");
1840 ImGui::BeginGroup();
1842 ImGui::BeginGroup();
1843 ImGui::Button("AAA");
1844 ImGui::SameLine();
1845 ImGui::Button("BBB");
1846 ImGui::SameLine();
1847 ImGui::BeginGroup();
1848 ImGui::Button("CCC");
1849 ImGui::Button("DDD");
1850 ImGui::EndGroup();
1851 ImGui::SameLine();
1852 ImGui::Button("EEE");
1853 ImGui::EndGroup();
1854 if (ImGui::IsItemHovered())
1855 ImGui::SetTooltip("First group hovered");
1858 ImVec2 size = ImGui::GetItemRectSize();
1860 ImGui::PlotHistogram("##values", values, IM_ARRAYSIZE(values), 0, NULL, 0.0f, 1.0f, size);
1862 ImGui::Button("ACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x)*0.5f, size.y));
1863 ImGui::SameLine();
1864 ImGui::Button("REACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x)*0.5f, size.y));
1865 ImGui::EndGroup();
1866 ImGui::SameLine();
1868 ImGui::Button("LEVERAGE\nBUZZWORD", size);
1869 ImGui::SameLine();
1871 if (ImGui::ListBoxHeader("List", size))
1873 ImGui::Selectable("Selected", true);
1874 ImGui::Selectable("Not Selected", false);
1875 ImGui::ListBoxFooter();
1878 ImGui::TreePop();
1881 if (ImGui::TreeNode("Text Baseline Alignment"))
1885 ImGui::Text("One\nTwo\nThree"); ImGui::SameLine();
1886 ImGui::Text("Hello\nWorld"); ImGui::SameLine();
1887 ImGui::Text("Banana");
1889 ImGui::Text("Banana"); ImGui::SameLine();
1890 ImGui::Text("Hello\nWorld"); ImGui::SameLine();
1891 ImGui::Text("One\nTwo\nThree");
1893 ImGui::Button("HOP##1"); ImGui::SameLine();
1894 ImGui::Text("Banana"); ImGui::SameLine();
1895 ImGui::Text("Hello\nWorld"); ImGui::SameLine();
1896 ImGui::Text("Banana");
1898 ImGui::Button("HOP##2"); ImGui::SameLine();
1899 ImGui::Text("Hello\nWorld"); ImGui::SameLine();
1900 ImGui::Text("Banana");
1902 ImGui::Button("TEST##1"); ImGui::SameLine();
1903 ImGui::Text("TEST"); ImGui::SameLine();
1904 ImGui::SmallButton("TEST##2");
1906 ImGui::AlignTextToFramePadding(); // If your line starts with text, call this to align it to upcoming widgets.
1907 ImGui::Text("Text aligned to Widget"); ImGui::SameLine();
1908 ImGui::Button("Widget##1"); ImGui::SameLine();
1909 ImGui::Text("Widget"); ImGui::SameLine();
1910 ImGui::SmallButton("Widget##2"); ImGui::SameLine();
1911 ImGui::Button("Widget##3");
1914 const float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
1915 ImGui::Button("Button##1");
1916 ImGui::SameLine(0.0f, spacing);
1917 if (ImGui::TreeNode("Node##1")) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
1919 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).
1920 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.
1921 ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##2");
1922 if (node_open) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
1925 ImGui::Button("Button##3");
1926 ImGui::SameLine(0.0f, spacing);
1927 ImGui::BulletText("Bullet text");
1929 ImGui::AlignTextToFramePadding();
1930 ImGui::BulletText("Node");
1931 ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##4");
1933 ImGui::TreePop();
1936 if (ImGui::TreeNode("Scrolling"))
1942 ImGui::Checkbox("Track", &track);
1943 ImGui::PushItemWidth(100);
1944 ImGui::SameLine(130); track |= ImGui::DragInt("##line", &track_line, 0.25f, 0, 99, "Line = %d");
1945 bool scroll_to = ImGui::Button("Scroll To Pos");
1946 ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "Y = %d px");
1947 ImGui::PopItemWidth();
1952 if (i > 0) ImGui::SameLine();
1953 ImGui::BeginGroup();
1954 ImGui::Text("%s", i == 0 ? "Top" : i == 1 ? "25%" : i == 2 ? "Center" : i == 3 ? "75%" : "Bottom");
1955 ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(ImGui::GetWindowWidth() * 0.17f, 200.0f), true);
1957 ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_px, i * 0.25f);
1962 ImGui::TextColored(ImVec4(1,1,0,1), "Line %d", line);
1963 ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
1967 ImGui::Text("Line %d", line);
1970 float scroll_y = ImGui::GetScrollY(), scroll_max_y = ImGui::GetScrollMaxY();
1971 ImGui::EndChild();
1972 ImGui::Text("%.0f/%0.f", scroll_y, scroll_max_y);
1973 ImGui::EndGroup();
1975 ImGui::TreePop();
1978 if (ImGui::TreeNode("Horizontal Scrolling"))
1982 ImGui::SliderInt("Lines", &lines, 1, 15);
1983 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
1984 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 1.0f));
1985 ImGui::BeginChild("scrolling", ImVec2(0, ImGui::GetFrameHeightWithSpacing() * 7 + 30), true, ImGuiWindowFlags_HorizontalScrollbar);
1993 if (n > 0) ImGui::SameLine();
1994 ImGui::PushID(n + line * 1000);
1999 ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(hue, 0.6f, 0.6f));
2000 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(hue, 0.7f, 0.7f));
2001 ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(hue, 0.8f, 0.8f));
2002 ImGui::Button(label, ImVec2(40.0f + sinf((float)(line + n)) * 20.0f, 0.0f));
2003 ImGui::PopStyleColor(3);
2004 ImGui::PopID();
2007 float scroll_x = ImGui::GetScrollX(), scroll_max_x = ImGui::GetScrollMaxX();
2008 ImGui::EndChild();
2009 ImGui::PopStyleVar(2);
2011 ImGui::SmallButton("<<"); if (ImGui::IsItemActive()) { scroll_x_delta = -ImGui::GetIO().DeltaTime * 1000.0f; } ImGui::SameLine();
2012 ImGui::Text("Scroll from code"); ImGui::SameLine();
2013 ImGui::SmallButton(">>"); if (ImGui::IsItemActive()) { scroll_x_delta = +ImGui::GetIO().DeltaTime * 1000.0f; } ImGui::SameLine();
2014 ImGui::Text("%.0f/%.0f", scroll_x, scroll_max_x);
2017 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)
2018 ImGui::SetScrollX(ImGui::GetScrollX() + scroll_x_delta);
2019 ImGui::EndChild();
2021 ImGui::TreePop();
2024 if (ImGui::TreeNode("Clipping"))
2027 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.");
2028 ImGui::DragFloat2("size", (float*)&size, 0.5f, 1.0f, 200.0f, "%.0f");
2029 ImGui::TextWrapped("(Click and drag)");
2030 ImVec2 pos = ImGui::GetCursorScreenPos();
2032 ImGui::InvisibleButton("##dummy", size);
2033 if (ImGui::IsItemActive() && ImGui::IsMouseDragging()) { offset.x += ImGui::GetIO().MouseDelta.x; offset.y += ImGui::GetIO().MouseDelta.y; }
2034 ImGui::GetWindowDrawList()->AddRectFilled(pos, ImVec2(pos.x + size.x, pos.y + size.y), IM_COL32(90, 90, 120, 255));
2035 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);
2036 ImGui::TreePop();
2042 if (!ImGui::CollapsingHeader("Popups & Modal windows"))
2054 // 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();
2056 // if (ImGui::Button("Open")) ImGui::OpenPopup("MyPopup"); if (ImGui::BeginPopup("MyPopup") { [...] EndPopup(); }
2061 if (ImGui::TreeNode("Popups"))
2063 ImGui::TextWrapped("When a popup is active, it inhibits interacting with windows that are behind the popup. Clicking outside the popup closes it.");
2071 if (ImGui::Button("Select.."))
2072 ImGui::OpenPopup("my_select_popup");
2073 ImGui::SameLine();
2074 ImGui::TextUnformatted(selected_fish == -1 ? "<None>" : names[selected_fish]);
2075 if (ImGui::BeginPopup("my_select_popup"))
2077 ImGui::Text("Aquarium");
2078 ImGui::Separator();
2080 if (ImGui::Selectable(names[i]))
2082 ImGui::EndPopup();
2086 if (ImGui::Button("Toggle.."))
2087 ImGui::OpenPopup("my_toggle_popup");
2088 if (ImGui::BeginPopup("my_toggle_popup"))
2091 ImGui::MenuItem(names[i], "", &toggles[i]);
2092 if (ImGui::BeginMenu("Sub-menu"))
2094 ImGui::MenuItem("Click me");
2095 ImGui::EndMenu();
2098 ImGui::Separator();
2099 ImGui::Text("Tooltip here");
2100 if (ImGui::IsItemHovered())
2101 ImGui::SetTooltip("I am a tooltip over a popup");
2103 if (ImGui::Button("Stacked Popup"))
2104 ImGui::OpenPopup("another popup");
2105 if (ImGui::BeginPopup("another popup"))
2108 ImGui::MenuItem(names[i], "", &toggles[i]);
2109 if (ImGui::BeginMenu("Sub-menu"))
2111 ImGui::MenuItem("Click me");
2112 ImGui::EndMenu();
2114 ImGui::EndPopup();
2116 ImGui::EndPopup();
2120 if (ImGui::Button("File Menu.."))
2121 ImGui::OpenPopup("my_file_popup");
2122 if (ImGui::BeginPopup("my_file_popup"))
2125 ImGui::EndPopup();
2128 ImGui::TreePop();
2131 if (ImGui::TreeNode("Context menus"))
2139 ImGui::Text("Value = %.3f (<-- right-click here)", value);
2140 if (ImGui::BeginPopupContextItem("item context menu"))
2142 if (ImGui::Selectable("Set to zero")) value = 0.0f;
2143 if (ImGui::Selectable("Set to PI")) value = 3.1415f;
2144 ImGui::PushItemWidth(-1);
2145 ImGui::DragFloat("##Value", &value, 0.1f, 0.0f, 0.0f);
2146 ImGui::PopItemWidth();
2147 ImGui::EndPopup();
2152 ImGui::Text("(You can also right-click me to the same popup as above.)");
2153 ImGui::OpenPopupOnItemClick("item context menu", 1);
2160 ImGui::Button(buf);
2161 if (ImGui::BeginPopupContextItem())
2163 ImGui::Text("Edit name:");
2164 ImGui::InputText("##edit", name, IM_ARRAYSIZE(name));
2165 if (ImGui::Button("Close"))
2166 ImGui::CloseCurrentPopup();
2167 ImGui::EndPopup();
2169 ImGui::SameLine(); ImGui::Text("(<-- right-click here)");
2171 ImGui::TreePop();
2174 if (ImGui::TreeNode("Modals"))
2176 ImGui::TextWrapped("Modal windows are like popups but the user cannot close them by clicking outside the window.");
2178 if (ImGui::Button("Delete.."))
2179 ImGui::OpenPopup("Delete?");
2181 if (ImGui::BeginPopupModal("Delete?", NULL, ImGuiWindowFlags_AlwaysAutoResize))
2183 ImGui::Text("All those beautiful files will be deleted.\nThis operation cannot be undone!\n\n");
2184 ImGui::Separator();
2187 //ImGui::Combo("Combo", &dummy_i, "Delete\0Delete harder\0");
2190 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
2191 ImGui::Checkbox("Don't ask me next time", &dont_ask_me_next_time);
2192 ImGui::PopStyleVar();
2194 if (ImGui::Button("OK", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); }
2195 ImGui::SetItemDefaultFocus();
2196 ImGui::SameLine();
2197 if (ImGui::Button("Cancel", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); }
2198 ImGui::EndPopup();
2201 if (ImGui::Button("Stacked modals.."))
2202 ImGui::OpenPopup("Stacked 1");
2203 if (ImGui::BeginPopupModal("Stacked 1", NULL, ImGuiWindowFlags_MenuBar))
2205 if (ImGui::BeginMenuBar())
2207 if (ImGui::BeginMenu("File"))
2209 if (ImGui::MenuItem("Dummy menu item")) {}
2210 ImGui::EndMenu();
2212 ImGui::EndMenuBar();
2214 ImGui::Text("Hello from Stacked The First\nUsing style.Colors[ImGuiCol_ModalWindowDimBg] behind it.");
2219 ImGui::Combo("Combo", &item, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
2220 ImGui::ColorEdit4("color", color);
2222 if (ImGui::Button("Add another modal.."))
2223 ImGui::OpenPopup("Stacked 2");
2228 if (ImGui::BeginPopupModal("Stacked 2", &dummy_open))
2230 ImGui::Text("Hello from Stacked The Second!");
2231 if (ImGui::Button("Close"))
2232 ImGui::CloseCurrentPopup();
2233 ImGui::EndPopup();
2236 if (ImGui::Button("Close"))
2237 ImGui::CloseCurrentPopup();
2238 ImGui::EndPopup();
2241 ImGui::TreePop();
2244 if (ImGui::TreeNode("Menus inside a regular window"))
2246 ImGui::TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!");
2247 ImGui::Separator();
2251 ImGui::PushID("foo");
2252 ImGui::MenuItem("Menu item", "CTRL+M");
2253 if (ImGui::BeginMenu("Menu inside a regular window"))
2256 ImGui::EndMenu();
2258 ImGui::PopID();
2259 ImGui::Separator();
2260 ImGui::TreePop();
2266 if (!ImGui::CollapsingHeader("Columns"))
2269 ImGui::PushID("Columns");
2272 if (ImGui::TreeNode("Basic"))
2274 ImGui::Text("Without border:");
2275 ImGui::Columns(3, "mycolumns3", false); // 3-ways, no border
2276 ImGui::Separator();
2281 if (ImGui::Selectable(label)) {}
2282 //if (ImGui::Button(label, ImVec2(-1,0))) {}
2283 ImGui::NextColumn();
2285 ImGui::Columns(1);
2286 ImGui::Separator();
2288 ImGui::Text("With border:");
2289 ImGui::Columns(4, "mycolumns"); // 4-ways, with border
2290 ImGui::Separator();
2291 ImGui::Text("ID"); ImGui::NextColumn();
2292 ImGui::Text("Name"); ImGui::NextColumn();
2293 ImGui::Text("Path"); ImGui::NextColumn();
2294 ImGui::Text("Hovered"); ImGui::NextColumn();
2295 ImGui::Separator();
2303 if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
2305 bool hovered = ImGui::IsItemHovered();
2306 ImGui::NextColumn();
2307 ImGui::Text(names[i]); ImGui::NextColumn();
2308 ImGui::Text(paths[i]); ImGui::NextColumn();
2309 ImGui::Text("%d", hovered); ImGui::NextColumn();
2311 ImGui::Columns(1);
2312 ImGui::Separator();
2313 ImGui::TreePop();
2317 if (ImGui::TreeNode("Mixed items"))
2319 ImGui::Columns(3, "mixed");
2320 ImGui::Separator();
2322 ImGui::Text("Hello");
2323 ImGui::Button("Banana");
2324 ImGui::NextColumn();
2326 ImGui::Text("ImGui");
2327 ImGui::Button("Apple");
2329 ImGui::InputFloat("red", &foo, 0.05f, 0, "%.3f");
2330 ImGui::Text("An extra line here.");
2331 ImGui::NextColumn();
2333 ImGui::Text("Sailor");
2334 ImGui::Button("Corniflower");
2336 ImGui::InputFloat("blue", &bar, 0.05f, 0, "%.3f");
2337 ImGui::NextColumn();
2339 if (ImGui::CollapsingHeader("Category A")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
2340 if (ImGui::CollapsingHeader("Category B")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
2341 if (ImGui::CollapsingHeader("Category C")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
2342 ImGui::Columns(1);
2343 ImGui::Separator();
2344 ImGui::TreePop();
2348 if (ImGui::TreeNode("Word-wrapping"))
2350 ImGui::Columns(2, "word-wrapping");
2351 ImGui::Separator();
2352 ImGui::TextWrapped("The quick brown fox jumps over the lazy dog.");
2353 ImGui::TextWrapped("Hello Left");
2354 ImGui::NextColumn();
2355 ImGui::TextWrapped("The quick brown fox jumps over the lazy dog.");
2356 ImGui::TextWrapped("Hello Right");
2357 ImGui::Columns(1);
2358 ImGui::Separator();
2359 ImGui::TreePop();
2362 if (ImGui::TreeNode("Borders"))
2367 ImGui::Checkbox("horizontal", &h_borders);
2368 ImGui::SameLine();
2369 ImGui::Checkbox("vertical", &v_borders);
2370 ImGui::Columns(4, NULL, v_borders);
2373 if (h_borders && ImGui::GetColumnIndex() == 0)
2374 ImGui::Separator();
2375 ImGui::Text("%c%c%c", 'a'+i, 'a'+i, 'a'+i);
2376 ImGui::Text("Width %.2f\nOffset %.2f", ImGui::GetColumnWidth(), ImGui::GetColumnOffset());
2377 ImGui::NextColumn();
2379 ImGui::Columns(1);
2381 ImGui::Separator();
2382 ImGui::TreePop();
2387 if (ImGui::TreeNode("Vertical Scrolling"))
2389 ImGui::BeginChild("##header", ImVec2(0, ImGui::GetTextLineHeightWithSpacing()+ImGui::GetStyle().ItemSpacing.y));
2390 ImGui::Columns(3);
2391 ImGui::Text("ID"); ImGui::NextColumn();
2392 ImGui::Text("Name"); ImGui::NextColumn();
2393 ImGui::Text("Path"); ImGui::NextColumn();
2394 ImGui::Columns(1);
2395 ImGui::Separator();
2396 ImGui::EndChild();
2397 ImGui::BeginChild("##scrollingregion", ImVec2(0, 60));
2398 ImGui::Columns(3);
2401 ImGui::Text("%04d", i); ImGui::NextColumn();
2402 ImGui::Text("Foobar"); ImGui::NextColumn();
2403 ImGui::Text("/path/foobar/%04d/", i); ImGui::NextColumn();
2405 ImGui::Columns(1);
2406 ImGui::EndChild();
2407 ImGui::TreePop();
2411 if (ImGui::TreeNode("Horizontal Scrolling"))
2413 ImGui::SetNextWindowContentSize(ImVec2(1500.0f, 0.0f));
2414 ImGui::BeginChild("##ScrollingRegion", ImVec2(0, ImGui::GetFontSize() * 20), false, ImGuiWindowFlags_HorizontalScrollbar);
2415 ImGui::Columns(10);
2423 ImGui::Text("Line %d Column %d...", i, j);
2424 ImGui::NextColumn();
2427 ImGui::Columns(1);
2428 ImGui::EndChild();
2429 ImGui::TreePop();
2432 bool node_open = ImGui::TreeNode("Tree within single cell");
2433 ImGui::SameLine(); ShowHelpMarker("NB: Tree node must be poped before ending the cell. There's no storage of state per-cell.");
2436 ImGui::Columns(2, "tree items");
2437 ImGui::Separator();
2438 if (ImGui::TreeNode("Hello")) { ImGui::BulletText("Sailor"); ImGui::TreePop(); } ImGui::NextColumn();
2439 if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Marin"); ImGui::TreePop(); } ImGui::NextColumn();
2440 ImGui::Columns(1);
2441 ImGui::Separator();
2442 ImGui::TreePop();
2444 ImGui::PopID();
2449 if (ImGui::CollapsingHeader("Filtering"))
2452 ImGui::Text("Filter usage:\n"
2461 ImGui::BulletText("%s", lines[i]);
2464 if (ImGui::CollapsingHeader("Inputs, Navigation & Focus"))
2466 ImGuiIO& io = ImGui::GetIO();
2468 ImGui::Text("WantCaptureMouse: %d", io.WantCaptureMouse);
2469 ImGui::Text("WantCaptureKeyboard: %d", io.WantCaptureKeyboard);
2470 ImGui::Text("WantTextInput: %d", io.WantTextInput);
2471 ImGui::Text("WantSetMousePos: %d", io.WantSetMousePos);
2472 ImGui::Text("NavActive: %d, NavVisible: %d", io.NavActive, io.NavVisible);
2474 if (ImGui::TreeNode("Keyboard, Mouse & Navigation State"))
2476 if (ImGui::IsMousePosValid())
2477 ImGui::Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y);
2479 ImGui::Text("Mouse pos: <INVALID>");
2480 ImGui::Text("Mouse delta: (%g, %g)", io.MouseDelta.x, io.MouseDelta.y);
2481 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]); }
2482 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); }
2483 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); }
2484 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); }
2485 ImGui::Text("Mouse wheel: %.1f", io.MouseWheel);
2487 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]); }
2488 ImGui::Text("Keys pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyPressed(i)) { ImGui::SameLine(); ImGui::Text("%d", i); }
2489 ImGui::Text("Keys release:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyReleased(i)) { ImGui::SameLine(); ImGui::Text("%d", i); }
2490 ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
2492 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]); }
2493 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); }
2494 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]); }
2496 ImGui::Button("Hovering me sets the\nkeyboard capture flag");
2497 if (ImGui::IsItemHovered())
2498 ImGui::CaptureKeyboardFromApp(true);
2499 ImGui::SameLine();
2500 ImGui::Button("Holding me clears the\nthe keyboard capture flag");
2501 if (ImGui::IsItemActive())
2502 ImGui::CaptureKeyboardFromApp(false);
2504 ImGui::TreePop();
2507 if (ImGui::TreeNode("Tabbing"))
2509 ImGui::Text("Use TAB/SHIFT+TAB to cycle through keyboard editable fields.");
2511 ImGui::InputText("1", buf, IM_ARRAYSIZE(buf));
2512 ImGui::InputText("2", buf, IM_ARRAYSIZE(buf));
2513 ImGui::InputText("3", buf, IM_ARRAYSIZE(buf));
2514 ImGui::PushAllowKeyboardFocus(false);
2515 ImGui::InputText("4 (tab skip)", buf, IM_ARRAYSIZE(buf));
2516 //ImGui::SameLine(); ShowHelperMarker("Use ImGui::PushAllowKeyboardFocus(bool)\nto disable tabbing through certain widgets.");
2517 ImGui::PopAllowKeyboardFocus();
2518 ImGui::InputText("5", buf, IM_ARRAYSIZE(buf));
2519 ImGui::TreePop();
2522 if (ImGui::TreeNode("Focus from code"))
2524 bool focus_1 = ImGui::Button("Focus on 1"); ImGui::SameLine();
2525 bool focus_2 = ImGui::Button("Focus on 2"); ImGui::SameLine();
2526 bool focus_3 = ImGui::Button("Focus on 3");
2530 if (focus_1) ImGui::SetKeyboardFocusHere();
2531 ImGui::InputText("1", buf, IM_ARRAYSIZE(buf));
2532 if (ImGui::IsItemActive()) has_focus = 1;
2534 if (focus_2) ImGui::SetKeyboardFocusHere();
2535 ImGui::InputText("2", buf, IM_ARRAYSIZE(buf));
2536 if (ImGui::IsItemActive()) has_focus = 2;
2538 ImGui::PushAllowKeyboardFocus(false);
2539 if (focus_3) ImGui::SetKeyboardFocusHere();
2540 ImGui::InputText("3 (tab skip)", buf, IM_ARRAYSIZE(buf));
2541 if (ImGui::IsItemActive()) has_focus = 3;
2542 ImGui::PopAllowKeyboardFocus();
2545 ImGui::Text("Item with focus: %d", has_focus);
2547 ImGui::Text("Item with focus: <none>");
2552 if (ImGui::Button("Focus on X")) { focus_ahead = 0; } ImGui::SameLine();
2553 if (ImGui::Button("Focus on Y")) { focus_ahead = 1; } ImGui::SameLine();
2554 if (ImGui::Button("Focus on Z")) { focus_ahead = 2; }
2555 if (focus_ahead != -1) ImGui::SetKeyboardFocusHere(focus_ahead);
2556 ImGui::SliderFloat3("Float3", &f3[0], 0.0f, 1.0f);
2558 ImGui::TextWrapped("NB: Cursor & selection are preserved when refocusing last used item in code.");
2559 ImGui::TreePop();
2562 if (ImGui::TreeNode("Dragging"))
2564 ImGui::TextWrapped("You can use ImGui::GetMouseDragDelta(0) to query for the dragged amount on any widget.");
2566 ImGui::Text("IsMouseDragging(%d):\n w/ default threshold: %d,\n w/ zero threshold: %d\n w/ large threshold: %d",
2567 button, ImGui::IsMouseDragging(button), ImGui::IsMouseDragging(button, 0.0f), ImGui::IsMouseDragging(button, 20.0f));
2568 ImGui::Button("Drag Me");
2569 if (ImGui::IsItemActive())
2572 ImDrawList* draw_list = ImGui::GetWindowDrawList();
2574 draw_list->AddLine(io.MouseClickedPos[0], io.MousePos, ImGui::GetColorU32(ImGuiCol_Button), 4.0f);
2579 ImVec2 value_raw = ImGui::GetMouseDragDelta(0, 0.0f);
2580 ImVec2 value_with_lock_threshold = ImGui::GetMouseDragDelta(0);
2582 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);
2584 ImGui::TreePop();
2587 if (ImGui::TreeNode("Mouse cursors"))
2592 ImGui::Text("Current mouse cursor = %d: %s", ImGui::GetMouseCursor(), mouse_cursors_names[ImGui::GetMouseCursor()]);
2593 ImGui::Text("Hover to see mouse cursors:");
2594 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.");
2599 ImGui::Bullet(); ImGui::Selectable(label, false);
2600 if (ImGui::IsItemHovered() || ImGui::IsItemFocused())
2601 ImGui::SetMouseCursor(i);
2603 ImGui::TreePop();
2610 // Access from ImGui Demo -> Help -> About
2613 void ImGui::ShowAboutWindow(bool* p_open)
2615 if (!ImGui::Begin("About Dear ImGui", p_open, ImGuiWindowFlags_AlwaysAutoResize))
2617 ImGui::End();
2620 ImGui::Text("Dear ImGui %s", ImGui::GetVersion());
2621 ImGui::Separator();
2622 ImGui::Text("By Omar Cornut and all dear imgui contributors.");
2623 ImGui::Text("Dear ImGui is licensed under the MIT License, see LICENSE for more information.");
2626 ImGui::Checkbox("Config/Build Information", &show_config_info);
2629 ImGuiIO& io = ImGui::GetIO();
2630 ImGuiStyle& style = ImGui::GetStyle();
2632 bool copy_to_clipboard = ImGui::Button("Copy to clipboard");
2633 ImGui::BeginChildFrame(ImGui::GetID("cfginfos"), ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * 18), ImGuiWindowFlags_NoMove);
2635 ImGui::LogToClipboard();
2637 ImGui::Text("Dear ImGui %s (%d)", IMGUI_VERSION, IMGUI_VERSION_NUM);
2638 ImGui::Separator();
2639 ImGui::Text("sizeof(size_t): %d, sizeof(ImDrawIdx): %d, sizeof(ImDrawVert): %d", (int)sizeof(size_t), (int)sizeof(ImDrawIdx), (int)sizeof(ImDrawVert));
2640 ImGui::Text("define: __cplusplus=%d", (int)__cplusplus);
2642 ImGui::Text("define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS");
2645 ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS");
2648 ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS");
2651 ImGui::Text("define: IMGUI_DISABLE_WIN32_FUNCTIONS");
2654 ImGui::Text("define: IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS");
2657 ImGui::Text("define: IMGUI_DISABLE_MATH_FUNCTIONS");
2660 ImGui::Text("define: IMGUI_DISABLE_DEFAULT_ALLOCATORS");
2663 ImGui::Text("define: IMGUI_USE_BGRA_PACKED_COLOR");
2666 ImGui::Text("define: _WIN32");
2669 ImGui::Text("define: _WIN64");
2672 ImGui::Text("define: __linux__");
2675 ImGui::Text("define: __APPLE__");
2678 ImGui::Text("define: _MSC_VER=%d", _MSC_VER);
2681 ImGui::Text("define: __MINGW32__");
2684 ImGui::Text("define: __MINGW64__");
2687 ImGui::Text("define: __GNUC__=%d", (int)__GNUC__);
2690 ImGui::Text("define: __clang_version__=%s", __clang_version__);
2692 ImGui::Separator();
2693 ImGui::Text("io.BackendPlatformName: %s", io.BackendPlatformName ? io.BackendPlatformName : "NULL");
2694 ImGui::Text("io.BackendRendererName: %s", io.BackendRendererName ? io.BackendRendererName : "NULL");
2695 ImGui::Text("io.ConfigFlags: 0x%08X", io.ConfigFlags);
2696 if (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) ImGui::Text(" NavEnableKeyboard");
2697 if (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) ImGui::Text(" NavEnableGamepad");
2698 if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) ImGui::Text(" NavEnableSetMousePos");
2699 if (io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard) ImGui::Text(" NavNoCaptureKeyboard");
2700 if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) ImGui::Text(" NoMouse");
2701 if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) ImGui::Text(" NoMouseCursorChange");
2702 if (io.MouseDrawCursor) ImGui::Text("io.MouseDrawCursor");
2703 if (io.ConfigMacOSXBehaviors) ImGui::Text("io.ConfigMacOSXBehaviors");
2704 if (io.ConfigInputTextCursorBlink) ImGui::Text("io.ConfigInputTextCursorBlink");
2705 if (io.ConfigWindowsResizeFromEdges) ImGui::Text("io.ConfigWindowsResizeFromEdges");
2706 if (io.ConfigWindowsMoveFromTitleBarOnly) ImGui::Text("io.ConfigWindowsMoveFromTitleBarOnly");
2707 ImGui::Text("io.BackendFlags: 0x%08X", io.BackendFlags);
2708 if (io.BackendFlags & ImGuiBackendFlags_HasGamepad) ImGui::Text(" HasGamepad");
2709 if (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) ImGui::Text(" HasMouseCursors");
2710 if (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos) ImGui::Text(" HasSetMousePos");
2711 ImGui::Separator();
2712 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);
2713 ImGui::Text("io.DisplaySize: %.2f,%.2f", io.DisplaySize.x, io.DisplaySize.y);
2714 ImGui::Text("io.DisplayFramebufferScale: %.2f,%.2f", io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
2715 ImGui::Separator();
2716 ImGui::Text("style.WindowPadding: %.2f,%.2f", style.WindowPadding.x, style.WindowPadding.y);
2717 ImGui::Text("style.WindowBorderSize: %.2f", style.WindowBorderSize);
2718 ImGui::Text("style.FramePadding: %.2f,%.2f", style.FramePadding.x, style.FramePadding.y);
2719 ImGui::Text("style.FrameRounding: %.2f", style.FrameRounding);
2720 ImGui::Text("style.FrameBorderSize: %.2f", style.FrameBorderSize);
2721 ImGui::Text("style.ItemSpacing: %.2f,%.2f", style.ItemSpacing.x, style.ItemSpacing.y);
2722 ImGui::Text("style.ItemInnerSpacing: %.2f,%.2f", style.ItemInnerSpacing.x, style.ItemInnerSpacing.y);
2725 ImGui::LogFinish();
2726 ImGui::EndChildFrame();
2728 ImGui::End();
2737 bool ImGui::ShowStyleSelector(const char* label)
2740 if (ImGui::Combo(label, &style_idx, "Classic\0Dark\0Light\0"))
2744 case 0: ImGui::StyleColorsClassic(); break;
2745 case 1: ImGui::StyleColorsDark(); break;
2746 case 2: ImGui::StyleColorsLight(); break;
2755 void ImGui::ShowFontSelector(const char* label)
2757 ImGuiIO& io = ImGui::GetIO();
2758 ImFont* font_current = ImGui::GetFont();
2759 if (ImGui::BeginCombo(label, font_current->GetDebugName()))
2764 ImGui::PushID((void*)font);
2765 if (ImGui::Selectable(font->GetDebugName(), font == font_current))
2767 ImGui::PopID();
2769 ImGui::EndCombo();
2771 ImGui::SameLine();
2779 void ImGui::ShowStyleEditor(ImGuiStyle* ref)
2782 ImGuiStyle& style = ImGui::GetStyle();
2793 ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.50f);
2795 if (ImGui::ShowStyleSelector("Colors##Selector"))
2797 ImGui::ShowFontSelector("Fonts##Selector");
2800 if (ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"))
2802 { bool window_border = (style.WindowBorderSize > 0.0f); if (ImGui::Checkbox("WindowBorder", &window_border)) style.WindowBorderSize = window_border ? 1.0f : 0.0f; }
2803 ImGui::SameLine();
2804 { bool frame_border = (style.FrameBorderSize > 0.0f); if (ImGui::Checkbox("FrameBorder", &frame_border)) style.FrameBorderSize = frame_border ? 1.0f : 0.0f; }
2805 ImGui::SameLine();
2806 { bool popup_border = (style.PopupBorderSize > 0.0f); if (ImGui::Checkbox("PopupBorder", &popup_border)) style.PopupBorderSize = popup_border ? 1.0f : 0.0f; }
2809 if (ImGui::Button("Save Ref"))
2811 ImGui::SameLine();
2812 if (ImGui::Button("Revert Ref"))
2814 ImGui::SameLine();
2817 ImGui::Separator();
2819 if (ImGui::BeginTabBar("##tabs", ImGuiTabBarFlags_None))
2821 if (ImGui::BeginTabItem("Sizes"))
2823 ImGui::Text("Main");
2824 ImGui::SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f");
2825 ImGui::SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f");
2826 ImGui::SliderFloat2("ItemSpacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f");
2827 ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f");
2828 ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f");
2829 ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f");
2830 ImGui::SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f");
2831 ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f");
2832 ImGui::Text("Borders");
2833 ImGui::SliderFloat("WindowBorderSize", &style.WindowBorderSize, 0.0f, 1.0f, "%.0f");
2834 ImGui::SliderFloat("ChildBorderSize", &style.ChildBorderSize, 0.0f, 1.0f, "%.0f");
2835 ImGui::SliderFloat("PopupBorderSize", &style.PopupBorderSize, 0.0f, 1.0f, "%.0f");
2836 ImGui::SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f, "%.0f");
2837 ImGui::SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f");
2838 ImGui::Text("Rounding");
2839 ImGui::SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 12.0f, "%.0f");
2840 ImGui::SliderFloat("ChildRounding", &style.ChildRounding, 0.0f, 12.0f, "%.0f");
2841 ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f");
2842 ImGui::SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 12.0f, "%.0f");
2843 ImGui::SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f");
2844 ImGui::SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f");
2845 ImGui::SliderFloat("TabRounding", &style.TabRounding, 0.0f, 12.0f, "%.0f");
2846 ImGui::Text("Alignment");
2847 ImGui::SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f");
2848 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.");
2849 ImGui::SliderFloat2("SelectableTextAlign", (float*)&style.SelectableTextAlign, 0.0f, 1.0f, "%.2f"); ImGui::SameLine(); ShowHelpMarker("Alignment applies when a selectable is larger than its text content.");
2850 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).");
2851 ImGui::SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f");
2852 ImGui::EndTabItem();
2855 if (ImGui::BeginTabItem("Colors"))
2859 if (ImGui::Button("Export Unsaved"))
2862 ImGui::LogToClipboard();
2864 ImGui::LogToTTY();
2865 ImGui::LogText("ImVec4* colors = ImGui::GetStyle().Colors;" IM_NEWLINE);
2869 const char* name = ImGui::GetStyleColorName(i);
2871 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);
2873 ImGui::LogFinish();
2875 ImGui::SameLine(); ImGui::PushItemWidth(120); ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0"); ImGui::PopItemWidth();
2876 ImGui::SameLine(); ImGui::Checkbox("Only Modified Colors", &output_only_modified);
2879 filter.Draw("Filter colors", ImGui::GetFontSize() * 16);
2882 ImGui::RadioButton("Opaque", &alpha_flags, 0); ImGui::SameLine();
2883 ImGui::RadioButton("Alpha", &alpha_flags, ImGuiColorEditFlags_AlphaPreview); ImGui::SameLine();
2884 ImGui::RadioButton("Both", &alpha_flags, ImGuiColorEditFlags_AlphaPreviewHalf); ImGui::SameLine();
2887 ImGui::BeginChild("##colors", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened);
2888 ImGui::PushItemWidth(-160);
2891 const char* name = ImGui::GetStyleColorName(i);
2894 ImGui::PushID(i);
2895 ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags);
2900 ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Save")) ref->Colors[i] = style.Colors[i];
2901 ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Revert")) style.Colors[i] = ref->Colors[i];
2903 ImGui::SameLine(0.0f, style.ItemInnerSpacing.x);
2904 ImGui::TextUnformatted(name);
2905 ImGui::PopID();
2907 ImGui::PopItemWidth();
2908 ImGui::EndChild();
2910 ImGui::EndTabItem();
2913 if (ImGui::BeginTabItem("Fonts"))
2915 ImGuiIO& io = ImGui::GetIO();
2918 ImGui::PushItemWidth(120);
2922 ImGui::PushID(font);
2923 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);
2924 ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) { io.FontDefault = font; }
2927 ImGui::PushFont(font);
2928 ImGui::Text("The quick brown fox jumps over the lazy dog");
2929 ImGui::PopFont();
2930 ImGui::DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); // Scale only this font
2931 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.)");
2932 ImGui::InputFloat("Font offset", &font->DisplayOffset.y, 1, 1, "%.0f");
2933 ImGui::Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent);
2934 ImGui::Text("Fallback character: '%c' (%d)", font->FallbackChar, font->FallbackChar);
2936 ImGui::Text("Texture surface: %d pixels (approx) ~ %dx%d", font->MetricsTotalSurface, (int)surface_sqrt, (int)surface_sqrt);
2939 ImGui::BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d", config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH);
2940 if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
2948 if (count > 0 && ImGui::TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph"))
2952 ImVec2 base_pos = ImGui::GetCursorScreenPos();
2953 ImDrawList* draw_list = ImGui::GetWindowDrawList();
2961 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.
2962 if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2))
2964 ImGui::BeginTooltip();
2965 ImGui::Text("Codepoint: U+%04X", base + n);
2966 ImGui::Separator();
2967 ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX);
2968 ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1);
2969 ImGui::Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1);
2970 ImGui::EndTooltip();
2973 ImGui::Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
2974 ImGui::TreePop();
2977 ImGui::TreePop();
2979 ImGui::TreePop();
2981 ImGui::PopID();
2983 if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
2985 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));
2986 ImGui::TreePop();
2990 if (ImGui::DragFloat("this window scale", &window_scale, 0.005f, 0.3f, 2.0f, "%.2f")) // scale only this window
2991 ImGui::SetWindowFontScale(window_scale);
2992 ImGui::DragFloat("global scale", &io.FontGlobalScale, 0.005f, 0.3f, 2.0f, "%.2f"); // scale everything
2993 ImGui::PopItemWidth();
2995 ImGui::EndTabItem();
2998 if (ImGui::BeginTabItem("Rendering"))
3000 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.");
3001 ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill);
3002 ImGui::PushItemWidth(100);
3003 ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, "%.2f", 2.0f);
3005 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.
3006 ImGui::PopItemWidth();
3008 ImGui::EndTabItem();
3011 ImGui::EndTabBar();
3014 ImGui::PopItemWidth();
3024 if (ImGui::BeginMainMenuBar())
3026 if (ImGui::BeginMenu("File"))
3029 ImGui::EndMenu();
3031 if (ImGui::BeginMenu("Edit"))
3033 if (ImGui::MenuItem("Undo", "CTRL+Z")) {}
3034 if (ImGui::MenuItem("Redo", "CTRL+Y", false, false)) {} // Disabled item
3035 ImGui::Separator();
3036 if (ImGui::MenuItem("Cut", "CTRL+X")) {}
3037 if (ImGui::MenuItem("Copy", "CTRL+C")) {}
3038 if (ImGui::MenuItem("Paste", "CTRL+V")) {}
3039 ImGui::EndMenu();
3041 ImGui::EndMainMenuBar();
3047 ImGui::MenuItem("(dummy menu)", NULL, false, false);
3048 if (ImGui::MenuItem("New")) {}
3049 if (ImGui::MenuItem("Open", "Ctrl+O")) {}
3050 if (ImGui::BeginMenu("Open Recent"))
3052 ImGui::MenuItem("fish_hat.c");
3053 ImGui::MenuItem("fish_hat.inl");
3054 ImGui::MenuItem("fish_hat.h");
3055 if (ImGui::BeginMenu("More.."))
3057 ImGui::MenuItem("Hello");
3058 ImGui::MenuItem("Sailor");
3059 if (ImGui::BeginMenu("Recurse.."))
3062 ImGui::EndMenu();
3064 ImGui::EndMenu();
3066 ImGui::EndMenu();
3068 if (ImGui::MenuItem("Save", "Ctrl+S")) {}
3069 if (ImGui::MenuItem("Save As..")) {}
3070 ImGui::Separator();
3071 if (ImGui::BeginMenu("Options"))
3074 ImGui::MenuItem("Enabled", "", &enabled);
3075 ImGui::BeginChild("child", ImVec2(0, 60), true);
3077 ImGui::Text("Scrolling Text %d", i);
3078 ImGui::EndChild();
3082 ImGui::SliderFloat("Value", &f, 0.0f, 1.0f);
3083 ImGui::InputFloat("Input", &f, 0.1f);
3084 ImGui::Combo("Combo", &n, "Yes\0No\0Maybe\0\0");
3085 ImGui::Checkbox("Check", &b);
3086 ImGui::EndMenu();
3088 if (ImGui::BeginMenu("Colors"))
3090 float sz = ImGui::GetTextLineHeight();
3093 const char* name = ImGui::GetStyleColorName((ImGuiCol)i);
3094 ImVec2 p = ImGui::GetCursorScreenPos();
3095 ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x+sz, p.y+sz), ImGui::GetColorU32((ImGuiCol)i));
3096 ImGui::Dummy(ImVec2(sz, sz));
3097 ImGui::SameLine();
3098 ImGui::MenuItem(name);
3100 ImGui::EndMenu();
3102 if (ImGui::BeginMenu("Disabled", false)) // Disabled
3106 if (ImGui::MenuItem("Checked", NULL, true)) {}
3107 if (ImGui::MenuItem("Quit", "Alt+F4")) {}
3138 AddLog("Welcome to Dear ImGui!");
3177 ImGui::SetNextWindowSize(ImVec2(520,600), ImGuiCond_FirstUseEver);
3178 if (!ImGui::Begin(title, p_open))
3180 ImGui::End();
3186 if (ImGui::BeginPopupContextItem())
3188 if (ImGui::MenuItem("Close Console"))
3190 ImGui::EndPopup();
3193 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.");
3194 ImGui::TextWrapped("Enter 'HELP' for help, press TAB to use text completion.");
3198 if (ImGui::SmallButton("Add Dummy Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } ImGui::SameLine();
3199 if (ImGui::SmallButton("Add Dummy Error")) { AddLog("[error] something went wrong"); } ImGui::SameLine();
3200 if (ImGui::SmallButton("Clear")) { ClearLog(); } ImGui::SameLine();
3201 bool copy_to_clipboard = ImGui::SmallButton("Copy"); ImGui::SameLine();
3202 if (ImGui::SmallButton("Scroll to bottom")) ScrollToBottom = true;
3203 //static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); }
3205 ImGui::Separator();
3208 if (ImGui::BeginPopup("Options"))
3210 if (ImGui::Checkbox("Auto-scroll", &AutoScroll))
3213 ImGui::EndPopup();
3217 if (ImGui::Button("Options"))
3218 ImGui::OpenPopup("Options");
3219 ImGui::SameLine();
3221 ImGui::Separator();
3223 const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); // 1 separator, 1 input text
3224 ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), false, ImGuiWindowFlags_HorizontalScrollbar); // Leave room for 1 separator + 1 InputText
3225 if (ImGui::BeginPopupContextWindow())
3227 if (ImGui::Selectable("Clear")) ClearLog();
3228 ImGui::EndPopup();
3231 // 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());
3242 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4,1)); // Tighten spacing
3244 ImGui::LogToClipboard();
3253 if (strstr(item, "[error]")) { ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.4f, 0.4f, 1.0f)); pop_color = true; }
3254 else if (strncmp(item, "# ", 2) == 0) { ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.8f, 0.6f, 1.0f)); pop_color = true; }
3255 ImGui::TextUnformatted(item);
3257 ImGui::PopStyleColor();
3260 ImGui::LogFinish();
3262 ImGui::SetScrollHereY(1.0f);
3264 ImGui::PopStyleVar();
3265 ImGui::EndChild();
3266 ImGui::Separator();
3270 if (ImGui::InputText("Input", InputBuf, IM_ARRAYSIZE(InputBuf), ImGuiInputTextFlags_EnterReturnsTrue|ImGuiInputTextFlags_CallbackCompletion|ImGuiInputTextFlags_CallbackHistory, &TextEditCallbackStub, (void*)this))
3281 ImGui::SetItemDefaultFocus();
3283 ImGui::SetKeyboardFocusHere(-1); // Auto focus previous widget
3285 ImGui::End();
3488 if (!ImGui::Begin(title, p_open))
3490 ImGui::End();
3495 if (ImGui::BeginPopup("Options"))
3497 if (ImGui::Checkbox("Auto-scroll", &AutoScroll))
3500 ImGui::EndPopup();
3504 if (ImGui::Button("Options"))
3505 ImGui::OpenPopup("Options");
3506 ImGui::SameLine();
3507 bool clear = ImGui::Button("Clear");
3508 ImGui::SameLine();
3509 bool copy = ImGui::Button("Copy");
3510 ImGui::SameLine();
3513 ImGui::Separator();
3514 ImGui::BeginChild("scrolling", ImVec2(0,0), false, ImGuiWindowFlags_HorizontalScrollbar);
3519 ImGui::LogToClipboard();
3521 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
3535 ImGui::TextUnformatted(line_start, line_end);
3541 // ImGui::TextUnformatted(buf_begin, buf_end);
3557 ImGui::TextUnformatted(line_start, line_end);
3562 ImGui::PopStyleVar();
3565 ImGui::SetScrollHereY(1.0f);
3567 ImGui::EndChild();
3568 ImGui::End();
3580 ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver);
3581 ImGui::Begin("Example: Log", p_open);
3582 if (ImGui::SmallButton("[Debug] Add 5 entries"))
3590 ImGui::GetFrameCount(), categories[counter % IM_ARRAYSIZE(categories)], ImGui::GetTime(), words[counter % IM_ARRAYSIZE(words)]);
3594 ImGui::End();
3606 ImGui::SetNextWindowSize(ImVec2(500, 440), ImGuiCond_FirstUseEver);
3607 if (ImGui::Begin("Example: Simple layout", p_open, ImGuiWindowFlags_MenuBar))
3609 if (ImGui::BeginMenuBar())
3611 if (ImGui::BeginMenu("File"))
3613 if (ImGui::MenuItem("Close")) *p_open = false;
3614 ImGui::EndMenu();
3616 ImGui::EndMenuBar();
3621 ImGui::BeginChild("left pane", ImVec2(150, 0), true);
3626 if (ImGui::Selectable(label, selected == i))
3629 ImGui::EndChild();
3630 ImGui::SameLine();
3633 ImGui::BeginGroup();
3634 ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us
3635 ImGui::Text("MyObject: %d", selected);
3636 ImGui::Separator();
3637 if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None))
3639 if (ImGui::BeginTabItem("Description"))
3641 ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ");
3642 ImGui::EndTabItem();
3644 if (ImGui::BeginTabItem("Details"))
3646 ImGui::Text("ID: 0123456789");
3647 ImGui::EndTabItem();
3649 ImGui::EndTabBar();
3651 ImGui::EndChild();
3652 if (ImGui::Button("Revert")) {}
3653 ImGui::SameLine();
3654 if (ImGui::Button("Save")) {}
3655 ImGui::EndGroup();
3657 ImGui::End();
3667 ImGui::SetNextWindowSize(ImVec2(430,450), ImGuiCond_FirstUseEver);
3668 if (!ImGui::Begin("Example: Property editor", p_open))
3670 ImGui::End();
3674 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.");
3676 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2,2));
3677 ImGui::Columns(2);
3678 ImGui::Separator();
3684 ImGui::PushID(uid); // Use object uid as identifier. Most commonly you could also use the object pointer as a base ID.
3685 ImGui::AlignTextToFramePadding(); // Text and Tree nodes are less high than regular widgets, here we add vertical spacing to make the tree lines equal high.
3686 bool node_open = ImGui::TreeNode("Object", "%s_%u", prefix, uid);
3687 ImGui::NextColumn();
3688 ImGui::AlignTextToFramePadding();
3689 ImGui::Text("my sailor is rich");
3690 ImGui::NextColumn();
3696 ImGui::PushID(i); // Use field index as identifier.
3704 ImGui::AlignTextToFramePadding();
3705 ImGui::TreeNodeEx("Field", ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_Bullet, "Field_%d", i);
3706 ImGui::NextColumn();
3707 ImGui::PushItemWidth(-1);
3709 ImGui::InputFloat("##value", &dummy_members[i], 1.0f);
3711 ImGui::DragFloat("##value", &dummy_members[i], 0.01f);
3712 ImGui::PopItemWidth();
3713 ImGui::NextColumn();
3715 ImGui::PopID();
3717 ImGui::TreePop();
3719 ImGui::PopID();
3727 ImGui::Columns(1);
3728 ImGui::Separator();
3729 ImGui::PopStyleVar();
3730 ImGui::End();
3740 ImGui::SetNextWindowSize(ImVec2(520,600), ImGuiCond_FirstUseEver);
3741 if (!ImGui::Begin("Example: Long text display", p_open))
3743 ImGui::End();
3750 ImGui::Text("Printing unusually long amount of text.");
3751 ImGui::Combo("Test type", &test_type, "Single call to TextUnformatted()\0Multiple calls to Text(), clipped manually\0Multiple calls to Text(), not clipped (slow)\0");
3752 ImGui::Text("Buffer contents: %d lines, %d bytes", lines, log.size());
3753 if (ImGui::Button("Clear")) { log.clear(); lines = 0; }
3754 ImGui::SameLine();
3755 if (ImGui::Button("Add 1000 lines"))
3761 ImGui::BeginChild("Log");
3766 ImGui::TextUnformatted(log.begin(), log.end());
3771 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
3775 ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
3776 ImGui::PopStyleVar();
3781 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
3783 ImGui::Text("%i The quick brown fox jumps over the lazy dog", i);
3784 ImGui::PopStyleVar();
3787 ImGui::EndChild();
3788 ImGui::End();
3798 if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize))
3800 ImGui::End();
3805 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.");
3806 ImGui::SliderInt("Number of lines", &lines, 1, 20);
3808 ImGui::Text("%*sThis is line %d", i * 4, "", i); // Pad with space to extend size horizontally
3809 ImGui::End();
3828 if (type == 0) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 0), ImVec2(-1, FLT_MAX)); // Vertical only
3829 if (type == 1) ImGui::SetNextWindowSizeConstraints(ImVec2(0, -1), ImVec2(FLT_MAX, -1)); // Horizontal only
3830 if (type == 2) ImGui::SetNextWindowSizeConstraints(ImVec2(100, 100), ImVec2(FLT_MAX, FLT_MAX)); // Width > 100, Height > 100
3831 if (type == 3) ImGui::SetNextWindowSizeConstraints(ImVec2(400, -1), ImVec2(500, -1)); // Width 400-500
3832 if (type == 4) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 400), ImVec2(-1, 500)); // Height 400-500
3833 if (type == 5) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Square); // Always Square
3834 if (type == 6) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Step, (void*)(intptr_t)100); // Fixed Step
3837 if (ImGui::Begin("Example: Constrained Resize", p_open, flags))
3849 if (ImGui::Button("200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine();
3850 if (ImGui::Button("500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine();
3851 if (ImGui::Button("800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); }
3852 ImGui::PushItemWidth(200);
3853 ImGui::Combo("Constraint", &type, desc, IM_ARRAYSIZE(desc));
3854 ImGui::DragInt("Lines", &display_lines, 0.2f, 1, 100);
3855 ImGui::PopItemWidth();
3856 ImGui::Checkbox("Auto-resize", &auto_resize);
3858 ImGui::Text("%*sHello, sailor! Making this line long enough for the example.", i * 4, "");
3860 ImGui::End();
3872 ImGuiIO& io = ImGui::GetIO();
3877 ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
3879 ImGui::SetNextWindowBgAlpha(0.3f); // Transparent background
3880 if (ImGui::Begin("Example: Simple overlay", p_open, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav))
3882 ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)");
3883 ImGui::Separator();
3884 if (ImGui::IsMousePosValid())
3885 ImGui::Text("Mouse Position: (%.1f,%.1f)", io.MousePos.x, io.MousePos.y);
3887 ImGui::Text("Mouse Position: <invalid>");
3888 if (ImGui::BeginPopupContextWindow())
3890 if (ImGui::MenuItem("Custom", NULL, corner == -1)) corner = -1;
3891 if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0;
3892 if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1;
3893 if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2;
3894 if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3;
3895 if (p_open && ImGui::MenuItem("Close")) *p_open = false;
3896 ImGui::EndPopup();
3899 ImGui::End();
3914 ImGui::SetNextWindowPos(ImVec2(100, 100), ImGuiCond_FirstUseEver);
3915 ImGui::Begin("Same title as another window##1");
3916 ImGui::Text("This is window 1.\nMy title is the same as window 2, but my identifier is unique.");
3917 ImGui::End();
3919 ImGui::SetNextWindowPos(ImVec2(100, 200), ImGuiCond_FirstUseEver);
3920 ImGui::Begin("Same title as another window##2");
3921 ImGui::Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique.");
3922 ImGui::End();
3926 sprintf(buf, "Animated title %c %d###AnimatedTitle", "|/-\\"[(int)(ImGui::GetTime() / 0.25f) & 3], ImGui::GetFrameCount());
3927 ImGui::SetNextWindowPos(ImVec2(100, 300), ImGuiCond_FirstUseEver);
3928 ImGui::Begin(buf);
3929 ImGui::Text("This window has a changing title.");
3930 ImGui::End();
3940 ImGui::SetNextWindowSize(ImVec2(350, 560), ImGuiCond_FirstUseEver);
3941 if (!ImGui::Begin("Example: Custom rendering", p_open))
3943 ImGui::End();
3949 // ImGui defines overloaded operators but they are internal to imgui.cpp and not exposed outside (to avoid messing with your types)
3951 ImDrawList* draw_list = ImGui::GetWindowDrawList();
3954 ImGui::Text("Primitives");
3958 ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f");
3959 ImGui::DragFloat("Thickness", &thickness, 0.05f, 1.0f, 8.0f, "%.02f");
3960 ImGui::ColorEdit4("Color", &col.x);
3962 const ImVec2 p = ImGui::GetCursorScreenPos();
3992 ImGui::Dummy(ImVec2((sz+spacing)*8, (sz+spacing)*3));
3994 ImGui::Separator();
3998 ImGui::Text("Canvas example");
3999 if (ImGui::Button("Clear")) points.clear();
4000 if (points.Size >= 2) { ImGui::SameLine(); if (ImGui::Button("Undo")) { points.pop_back(); points.pop_back(); } }
4001 ImGui::Text("Left-click and drag to add lines,\nRight-click to undo");
4006 ImVec2 canvas_pos = ImGui::GetCursorScreenPos(); // ImDrawList API uses screen coordinates!
4007 ImVec2 canvas_size = ImGui::GetContentRegionAvail(); // Resize canvas to what's available
4014 ImGui::InvisibleButton("canvas", canvas_size);
4015 ImVec2 mouse_pos_in_canvas = ImVec2(ImGui::GetIO().MousePos.x - canvas_pos.x, ImGui::GetIO().MousePos.y - canvas_pos.y);
4020 if (!ImGui::IsMouseDown(0))
4023 if (ImGui::IsItemHovered())
4025 if (!adding_line && ImGui::IsMouseClicked(0))
4030 if (ImGui::IsMouseClicked(1) && !points.empty())
4044 ImGui::End();
4077 ImGui::PushID(doc);
4078 ImGui::Text("Document \"%s\"", doc->Name);
4079 ImGui::PushStyleColor(ImGuiCol_Text, doc->Color);
4080 ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
4081 ImGui::PopStyleColor();
4082 if (ImGui::Button("Modify", ImVec2(100, 0)))
4084 ImGui::SameLine();
4085 if (ImGui::Button("Save", ImVec2(100, 0)))
4087 ImGui::ColorEdit3("color", &doc->Color.x); // Useful to test drag and drop and hold-dragged-to-open-tab behavior.
4088 ImGui::PopID();
4094 if (!ImGui::BeginPopupContextItem())
4099 if (ImGui::MenuItem(buf, "CTRL+S", false, doc->Open))
4101 if (ImGui::MenuItem("Close", "CTRL+W", false, doc->Open))
4103 ImGui::EndPopup();
4135 ImGui::SetTabItemClosed(doc->Name);
4144 if (!ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar))
4146 ImGui::End();
4155 if (ImGui::BeginMenuBar())
4157 if (ImGui::BeginMenu("File"))
4163 if (ImGui::BeginMenu("Open", open_count < app.Documents.Size))
4169 if (ImGui::MenuItem(doc->Name))
4172 ImGui::EndMenu();
4174 if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0))
4177 if (ImGui::MenuItem("Exit", "Alt+F4")) {}
4178 ImGui::EndMenu();
4180 ImGui::EndMenuBar();
4188 ImGui::SameLine();
4189 ImGui::PushID(doc);
4190 if (ImGui::Checkbox(doc->Name, &doc->Open))
4193 ImGui::PopID();
4196 ImGui::Separator();
4201 if (ImGui::BeginTabBar("##tabs", tab_bar_flags))
4207 //if ((ImGui::GetFrameCount() % 30) == 0) docs[1].Open ^= 1; // [DEBUG] Automatically show/hide a tab. Test various interactions e.g. dragging with this on.
4208 //if (ImGui::GetIO().KeyCtrl) ImGui::SetTabItemSelected(docs[1].Name); // [DEBUG] Test SetTabItemSelected(), probably not very useful as-is anyway..
4218 bool visible = ImGui::BeginTabItem(doc->Name, &doc->Open, tab_flags);
4231 ImGui::EndTabItem();
4235 ImGui::EndTabBar();
4272 if (!ImGui::IsPopupOpen("Save?"))
4273 ImGui::OpenPopup("Save?");
4274 if (ImGui::BeginPopupModal("Save?"))
4276 ImGui::Text("Save change to the following items?");
4277 ImGui::PushItemWidth(-1.0f);
4278 ImGui::ListBoxHeader("##", close_queue_unsaved_documents, 6);
4281 ImGui::Text("%s", close_queue[n]->Name);
4282 ImGui::ListBoxFooter();
4284 if (ImGui::Button("Yes", ImVec2(80, 0)))
4293 ImGui::CloseCurrentPopup();
4295 ImGui::SameLine();
4296 if (ImGui::Button("No", ImVec2(80, 0)))
4301 ImGui::CloseCurrentPopup();
4303 ImGui::SameLine();
4304 if (ImGui::Button("Cancel", ImVec2(80, 0)))
4307 ImGui::CloseCurrentPopup();
4309 ImGui::EndPopup();
4314 ImGui::End();
4320 void ImGui::ShowAboutWindow(bool*) {}
4321 void ImGui::ShowDemoWindow(bool*) {}
4322 void ImGui::ShowUserGuide() {}
4323 void ImGui::ShowStyleEditor(ImGuiStyle*) {}