"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "imgui_demo.cpp" between
imgui-1.86.tar.gz and imgui-1.87.tar.gz

About: Dear ImGui is a bloat-free Graphical User Interface for C++ with minimal dependencies.

imgui_demo.cpp  (imgui-1.86):imgui_demo.cpp  (imgui-1.87)
// dear imgui, v1.86 // dear imgui, v1.87
// (demo code) // (demo code)
// Help: // Help:
// - Read FAQ at http://dearimgui.org/faq // - Read FAQ at http://dearimgui.org/faq
// - Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup D ear ImGui in your codebase. // - Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup D ear ImGui in your codebase.
// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp. All applications i n examples/ are doing that. // - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp. All applications i n examples/ are doing that.
// Read imgui.cpp for more details, documentation and comments. // Read imgui.cpp for more details, documentation and comments.
// Get the latest version at https://github.com/ocornut/imgui // Get the latest version at https://github.com/ocornut/imgui
// Message to the person tempted to delete this file when integrating Dear ImGui into their codebase: // Message to the person tempted to delete this file when integrating Dear ImGui into their codebase:
skipping to change at line 95 skipping to change at line 95
#include <stdio.h> // vsnprintf, sscanf, printf #include <stdio.h> // vsnprintf, sscanf, printf
#include <stdlib.h> // NULL, malloc, free, atoi #include <stdlib.h> // NULL, malloc, free, atoi
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier #if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
#include <stddef.h> // intptr_t #include <stddef.h> // intptr_t
#else #else
#include <stdint.h> // intptr_t #include <stdint.h> // intptr_t
#endif #endif
// Visual Studio warnings // Visual Studio warnings
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning (disable: 4127) // condition expression is constant
#pragma warning (disable: 4996) // 'This function or variable may be unsafe' : strcpy, strdup, sprintf, vsnprintf, sscanf, fopen #pragma warning (disable: 4996) // 'This function or variable may be unsafe' : strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : U sing operator 'xxx' on a 4 byte value and then casting the result to a 8 byte va lue. Cast the value to the wider type before calling operator 'xxx' to avoid ove rflow(io.2). #pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : U sing operator 'xxx' on a 4 byte value and then casting the result to a 8 byte va lue. Cast the value to the wider type before calling operator 'xxx' to avoid ove rflow(io.2).
#endif #endif
// Clang/GCC warnings with -Weverything // Clang/GCC warnings with -Weverything
#if defined(__clang__) #if defined(__clang__)
#if __has_warning("-Wunknown-warning-option") #if __has_warning("-Wunknown-warning-option")
#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings trig gers new warnings on some configuration. Great! #pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings trig gers new warnings on some configuration. Great!
#endif #endif
#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx' #pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx'
skipping to change at line 231 skipping to change at line 232
ImGui::BulletText("CTRL+Tab to select a window."); ImGui::BulletText("CTRL+Tab to select a window.");
if (io.FontAllowUserScaling) if (io.FontAllowUserScaling)
ImGui::BulletText("CTRL+Mouse Wheel to zoom window contents."); ImGui::BulletText("CTRL+Mouse Wheel to zoom window contents.");
ImGui::BulletText("While inputing text:\n"); ImGui::BulletText("While inputing text:\n");
ImGui::Indent(); ImGui::Indent();
ImGui::BulletText("CTRL+Left/Right to word jump."); ImGui::BulletText("CTRL+Left/Right to word jump.");
ImGui::BulletText("CTRL+A or double-click to select all."); ImGui::BulletText("CTRL+A or double-click to select all.");
ImGui::BulletText("CTRL+X/C/V to use clipboard cut/copy/paste."); ImGui::BulletText("CTRL+X/C/V to use clipboard cut/copy/paste.");
ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo."); ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo.");
ImGui::BulletText("ESCAPE to revert."); ImGui::BulletText("ESCAPE to revert.");
ImGui::BulletText("You can apply arithmetic operators +,*,/ on numerical val ues.\nUse +- to subtract.");
ImGui::Unindent(); ImGui::Unindent();
ImGui::BulletText("With keyboard navigation enabled:"); ImGui::BulletText("With keyboard navigation enabled:");
ImGui::Indent(); ImGui::Indent();
ImGui::BulletText("Arrow keys to navigate."); ImGui::BulletText("Arrow keys to navigate.");
ImGui::BulletText("Space to activate a widget."); ImGui::BulletText("Space to activate a widget.");
ImGui::BulletText("Return to input text into a widget."); ImGui::BulletText("Return to input text into a widget.");
ImGui::BulletText("Escape to deactivate a widget, close popup, exit child wi ndow."); ImGui::BulletText("Escape to deactivate a widget, close popup, exit child wi ndow.");
ImGui::BulletText("Alt to jump to the menu layer of a window."); ImGui::BulletText("Alt to jump to the menu layer of a window.");
ImGui::Unindent(); ImGui::Unindent();
} }
skipping to change at line 457 skipping to change at line 457
ImGui::SameLine(); HelpMarker("Instruct navigation to move the mouse cursor. See comment for ImGuiConfigFlags_NavEnableSetMousePos."); ImGui::SameLine(); HelpMarker("Instruct navigation to move the mouse cursor. See comment for ImGuiConfigFlags_NavEnableSetMousePos.");
ImGui::CheckboxFlags("io.ConfigFlags: NoMouse", &io.Con figFlags, ImGuiConfigFlags_NoMouse); ImGui::CheckboxFlags("io.ConfigFlags: NoMouse", &io.Con figFlags, ImGuiConfigFlags_NoMouse);
if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) if (io.ConfigFlags & ImGuiConfigFlags_NoMouse)
{ {
// The "NoMouse" option can get us stuck with a disabled mouse! Let's provide an alternative way to fix it: // The "NoMouse" option can get us stuck with a disabled mouse! Let's provide an alternative way to fix it:
if (fmodf((float)ImGui::GetTime(), 0.40f) < 0.20f) if (fmodf((float)ImGui::GetTime(), 0.40f) < 0.20f)
{ {
ImGui::SameLine(); ImGui::SameLine();
ImGui::Text("<<PRESS SPACE TO DISABLE>>"); ImGui::Text("<<PRESS SPACE TO DISABLE>>");
} }
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Space))) if (ImGui::IsKeyPressed(ImGuiKey_Space))
io.ConfigFlags &= ~ImGuiConfigFlags_NoMouse; io.ConfigFlags &= ~ImGuiConfigFlags_NoMouse;
} }
ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", &io.Conf igFlags, ImGuiConfigFlags_NoMouseCursorChange); ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", &io.Conf igFlags, ImGuiConfigFlags_NoMouseCursorChange);
ImGui::SameLine(); HelpMarker("Instruct backend to not alter mouse c ursor shape and visibility."); ImGui::SameLine(); HelpMarker("Instruct backend to not alter mouse c ursor shape and visibility.");
ImGui::Checkbox("io.ConfigInputTrickleEventQueue", &io.ConfigInputTr
ickleEventQueue);
ImGui::SameLine(); HelpMarker("Enable input queue trickling: some ty
pes of events submitted during the same frame (e.g. button down + up) will be sp
read over multiple frames, improving interactions with low framerates.");
ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputText CursorBlink); ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputText CursorBlink);
ImGui::SameLine(); HelpMarker("Enable blinking cursor (optional as s ome users consider it to be distracting)"); ImGui::SameLine(); HelpMarker("Enable blinking cursor (optional as s ome users consider it to be distracting).");
ImGui::Checkbox("io.ConfigDragClickToInputText", &io.ConfigDragClick ToInputText); ImGui::Checkbox("io.ConfigDragClickToInputText", &io.ConfigDragClick ToInputText);
ImGui::SameLine(); HelpMarker("Enable turning DragXXX widgets into t ext input with a simple mouse click-release (without moving)."); ImGui::SameLine(); HelpMarker("Enable turning DragXXX widgets into t ext input with a simple mouse click-release (without moving).");
ImGui::Checkbox("io.ConfigWindowsResizeFromEdges", &io.ConfigWindows ResizeFromEdges); ImGui::Checkbox("io.ConfigWindowsResizeFromEdges", &io.ConfigWindows ResizeFromEdges);
ImGui::SameLine(); HelpMarker("Enable resizing of windows from their edges and from the lower-left corner.\nThis requires (io.BackendFlags & ImGuiBa ckendFlags_HasMouseCursors) because it needs mouse cursor feedback."); ImGui::SameLine(); HelpMarker("Enable resizing of windows from their edges and from the lower-left corner.\nThis requires (io.BackendFlags & ImGuiBa ckendFlags_HasMouseCursors) because it needs mouse cursor feedback.");
ImGui::Checkbox("io.ConfigWindowsMoveFromTitleBarOnly", &io.ConfigWi ndowsMoveFromTitleBarOnly); ImGui::Checkbox("io.ConfigWindowsMoveFromTitleBarOnly", &io.ConfigWi ndowsMoveFromTitleBarOnly);
ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor); ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor);
ImGui::SameLine(); HelpMarker("Instruct Dear ImGui to render a mouse cursor itself. Note that a mouse cursor rendered via your application GPU rende ring path will feel more laggy than hardware cursor, but will be more in sync wi th your other visuals.\n\nSome desktop applications may use both kinds of cursor s (e.g. enable software cursor only when resizing/dragging something)."); ImGui::SameLine(); HelpMarker("Instruct Dear ImGui to render a mouse cursor itself. Note that a mouse cursor rendered via your application GPU rende ring path will feel more laggy than hardware cursor, but will be more in sync wi th your other visuals.\n\nSome desktop applications may use both kinds of cursor s (e.g. enable software cursor only when resizing/dragging something).");
ImGui::Text("Also see Style->Rendering for rendering options."); ImGui::Text("Also see Style->Rendering for rendering options.");
ImGui::TreePop(); ImGui::TreePop();
ImGui::Separator(); ImGui::Separator();
} }
IMGUI_DEMO_MARKER("Configuration/Backend Flags"); IMGUI_DEMO_MARKER("Configuration/Backend Flags");
if (ImGui::TreeNode("Backend Flags")) if (ImGui::TreeNode("Backend Flags"))
{ {
HelpMarker( HelpMarker(
"Those flags are set by the backends (imgui_impl_xxx files) to s pecify their capabilities.\n" "Those flags are set by the backends (imgui_impl_xxx files) to s pecify their capabilities.\n"
"Here we expose them as read-only fields to avoid breaking inter actions with your backend."); "Here we expose them as read-only fields to avoid breaking inter actions with your backend.");
// Make a local copy to avoid modifying actual backend flags. // Make a local copy to avoid modifying actual backend flags.
// FIXME: We don't use BeginDisabled() to keep label bright, maybe w e need a BeginReadonly() equivalent..
ImGuiBackendFlags backend_flags = io.BackendFlags; ImGuiBackendFlags backend_flags = io.BackendFlags;
ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", &backe nd_flags, ImGuiBackendFlags_HasGamepad); ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", &backe nd_flags, ImGuiBackendFlags_HasGamepad);
ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", &backe nd_flags, ImGuiBackendFlags_HasMouseCursors); ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", &backe nd_flags, ImGuiBackendFlags_HasMouseCursors);
ImGui::CheckboxFlags("io.BackendFlags: HasSetMousePos", &backe nd_flags, ImGuiBackendFlags_HasSetMousePos); ImGui::CheckboxFlags("io.BackendFlags: HasSetMousePos", &backe nd_flags, ImGuiBackendFlags_HasSetMousePos);
ImGui::CheckboxFlags("io.BackendFlags: RendererHasVtxOffset", &backe nd_flags, ImGuiBackendFlags_RendererHasVtxOffset); ImGui::CheckboxFlags("io.BackendFlags: RendererHasVtxOffset", &backe nd_flags, ImGuiBackendFlags_RendererHasVtxOffset);
ImGui::TreePop(); ImGui::TreePop();
ImGui::Separator(); ImGui::Separator();
} }
IMGUI_DEMO_MARKER("Configuration/Style"); IMGUI_DEMO_MARKER("Configuration/Style");
skipping to change at line 676 skipping to change at line 679
"You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputText() " "You 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 ex ample (this is not demonstrated " "to a dynamic string type. See misc/cpp/imgui_stdlib.h for an ex ample (this is not demonstrated "
"in imgui_demo.cpp)."); "in imgui_demo.cpp).");
static char str1[128] = ""; static char str1[128] = "";
ImGui::InputTextWithHint("input text (w/ hint)", "enter text here", str1, IM_ARRAYSIZE(str1)); ImGui::InputTextWithHint("input text (w/ hint)", "enter text here", str1, IM_ARRAYSIZE(str1));
IMGUI_DEMO_MARKER("Widgets/Basic/InputInt, InputFloat"); IMGUI_DEMO_MARKER("Widgets/Basic/InputInt, InputFloat");
static int i0 = 123; static int i0 = 123;
ImGui::InputInt("input int", &i0); ImGui::InputInt("input int", &i0);
ImGui::SameLine(); HelpMarker(
"You can apply arithmetic operators +,*,/ on numerical values.\n
"
" e.g. [ 100 ], input \'*2\', result becomes [ 200 ]\n"
"Use +- to subtract.");
static float f0 = 0.001f; static float f0 = 0.001f;
ImGui::InputFloat("input float", &f0, 0.01f, 1.0f, "%.3f"); ImGui::InputFloat("input float", &f0, 0.01f, 1.0f, "%.3f");
static double d0 = 999999.00000001; static double d0 = 999999.00000001;
ImGui::InputDouble("input double", &d0, 0.01f, 1.0f, "%.8f"); ImGui::InputDouble("input double", &d0, 0.01f, 1.0f, "%.8f");
static float f1 = 1.e10f; static float f1 = 1.e10f;
ImGui::InputFloat("input scientific", &f1, 0.0f, 0.0f, "%e"); ImGui::InputFloat("input scientific", &f1, 0.0f, 0.0f, "%e");
ImGui::SameLine(); HelpMarker( ImGui::SameLine(); HelpMarker(
skipping to change at line 5642 skipping to change at line 5641
ImGui::TreePop(); ImGui::TreePop();
} }
} }
ImGui::Columns(1); ImGui::Columns(1);
ImGui::TreePop(); ImGui::TreePop();
} }
ImGui::TreePop(); ImGui::TreePop();
} }
namespace ImGui { extern ImGuiKeyData* GetKeyData(ImGuiKey key); }
static void ShowDemoWindowMisc() static void ShowDemoWindowMisc()
{ {
IMGUI_DEMO_MARKER("Filtering"); IMGUI_DEMO_MARKER("Filtering");
if (ImGui::CollapsingHeader("Filtering")) if (ImGui::CollapsingHeader("Filtering"))
{ {
// Helper class to easy setup a text filter. // Helper class to easy setup a text filter.
// You may want to implement a more feature-full filtering scheme in you r own application. // You may want to implement a more feature-full filtering scheme in you r own application.
static ImGuiTextFilter filter; static ImGuiTextFilter filter;
ImGui::Text("Filter usage:\n" ImGui::Text("Filter usage:\n"
" \"\" display all lines\n" " \"\" display all lines\n"
skipping to change at line 5695 skipping to change at line 5696
int count = IM_ARRAYSIZE(io.MouseDown); int count = IM_ARRAYSIZE(io.MouseDown);
ImGui::Text("Mouse down:"); for (int i = 0; i < count; i++) if (ImGui::IsMouseDown(i)) { ImGui::SameLine(); ImGui::Text("b%d (%.02f sec s)", i, io.MouseDownDuration[i]); } ImGui::Text("Mouse down:"); for (int i = 0; i < count; i++) if (ImGui::IsMouseDown(i)) { ImGui::SameLine(); ImGui::Text("b%d (%.02f sec s)", i, io.MouseDownDuration[i]); }
ImGui::Text("Mouse clicked:"); for (int i = 0; i < count; i++) if (ImGui::IsMouseClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d (%d)", i, ImGui::GetMouseClickedCount(i)); } ImGui::Text("Mouse clicked:"); for (int i = 0; i < count; i++) if (ImGui::IsMouseClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d (%d)", i, ImGui::GetMouseClickedCount(i)); }
ImGui::Text("Mouse released:"); for (int i = 0; i < count; i++) if (ImGui::IsMouseReleased(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); } ImGui::Text("Mouse released:"); for (int i = 0; i < count; i++) if (ImGui::IsMouseReleased(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); }
ImGui::Text("Mouse wheel: %.1f", io.MouseWheel); ImGui::Text("Mouse wheel: %.1f", io.MouseWheel);
ImGui::Text("Pen Pressure: %.1f", io.PenPressure); // Note: currentl y unused ImGui::Text("Pen Pressure: %.1f", io.PenPressure); // Note: currentl y unused
ImGui::TreePop(); ImGui::TreePop();
} }
// Display Keyboard/Mouse state // Display Keyboard/Mouse state
IMGUI_DEMO_MARKER("Inputs, Navigation & Focus/Keyboard & Navigation Stat IMGUI_DEMO_MARKER("Inputs, Navigation & Focus/Keyboard, Gamepad & Naviga
e"); tion State");
if (ImGui::TreeNode("Keyboard & Navigation State")) if (ImGui::TreeNode("Keyboard, Gamepad & Navigation State"))
{ {
ImGui::Text("Keys down:"); for (int i = 0; i < IM_ARRAYSIZE // We iterate both legacy native range and named ImGuiKey ranges, wh
(io.KeysDown); i++) if (ImGui::IsKeyDown(i)) { ImGui::SameLine(); ImGui:: ich is a little odd but this allow displaying the data for old/new backends.
Text("%d (0x%X) (%.02f secs)", i, i, io.KeysDownDuration[i]); } // User code should never have to go through such hoops: old code ma
ImGui::Text("Keys pressed:"); for (int i = 0; i < IM_ARRAYSIZE y use native keycodes, new code may use ImGuiKey codes.
(io.KeysDown); i++) if (ImGui::IsKeyPressed(i)) { ImGui::SameLine(); ImGui:: #ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
Text("%d (0x%X)", i, i); } struct funcs { static bool IsLegacyNativeDupe(ImGuiKey) { return fal
ImGui::Text("Keys release:"); for (int i = 0; i < IM_ARRAYSIZE se; } };
(io.KeysDown); i++) if (ImGui::IsKeyReleased(i)) { ImGui::SameLine(); ImGui:: const ImGuiKey key_first = ImGuiKey_NamedKey_BEGIN;
Text("%d (0x%X)", i, i); } #else
struct funcs { static bool IsLegacyNativeDupe(ImGuiKey key) { return
key < 512 && ImGui::GetIO().KeyMap[key] != -1; } }; // Hide Native<>ImGuiKey du
plicates when both exists in the array
const ImGuiKey key_first = 0;
#endif
ImGui::Text("Keys down:"); for (ImGuiKey key = key_first; k
ey < ImGuiKey_COUNT; key++) { if (funcs::IsLegacyNativeDupe(key)) continue; if (
ImGui::IsKeyDown(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d (%.02f secs)"
, ImGui::GetKeyName(key), key, ImGui::GetKeyData(key)->DownDuration); } }
ImGui::Text("Keys pressed:"); for (ImGuiKey key = key_first; k
ey < ImGuiKey_COUNT; key++) { if (funcs::IsLegacyNativeDupe(key)) continue; if (
ImGui::IsKeyPressed(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d", ImGui::G
etKeyName(key), key); } }
ImGui::Text("Keys released:"); for (ImGuiKey key = key_first; k
ey < ImGuiKey_COUNT; key++) { if (funcs::IsLegacyNativeDupe(key)) continue; if (
ImGui::IsKeyReleased(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d", ImGui::
GetKeyName(key), key); } }
ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.Key Shift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : ""); ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.Key Shift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
ImGui::Text("Chars queue:"); for (int i = 0; i < io.InputQueu eCharacters.Size; i++) { ImWchar c = io.InputQueueCharacters[i]; ImGui::SameLine (); ImGui::Text("\'%c\' (0x%04X)", (c > ' ' && c <= 255) ? (char)c : '?', c); } // FIXME: We should convert 'c' to UTF-8 here but the functions are not public. ImGui::Text("Chars queue:"); for (int i = 0; i < io.InputQueu eCharacters.Size; i++) { ImWchar c = io.InputQueueCharacters[i]; ImGui::SameLine (); ImGui::Text("\'%c\' (0x%04X)", (c > ' ' && c <= 255) ? (char)c : '?', c); } // FIXME: We should convert 'c' to UTF-8 here but the functions are not public.
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 (%.02f secs)", i, io.NavInputs[i], io.NavInputsDownDur ation[i]); } 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 (%.02f secs)", i, io.NavInputs[i], io.NavInputsDownDur ation[i]); }
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); } 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); }
// Draw an arbitrary US keyboard layout to visualize translated keys
{
const ImVec2 key_size = ImVec2(35.0f, 35.0f);
const float key_rounding = 3.0f;
const ImVec2 key_face_size = ImVec2(25.0f, 25.0f);
const ImVec2 key_face_pos = ImVec2(5.0f, 3.0f);
const float key_face_rounding = 2.0f;
const ImVec2 key_label_pos = ImVec2(7.0f, 4.0f);
const ImVec2 key_step = ImVec2(key_size.x - 1.0f, key_size.y - 1
.0f);
const float key_row_offset = 9.0f;
ImVec2 board_min = ImGui::GetCursorScreenPos();
ImVec2 board_max = ImVec2(board_min.x + 3 * key_step.x + 2 * key
_row_offset + 10.0f, board_min.y + 3 * key_step.y + 10.0f);
ImVec2 start_pos = ImVec2(board_min.x + 5.0f - key_step.x, board
_min.y);
struct KeyLayoutData { int Row, Col; const char* Label; ImGuiKey
Key; };
const KeyLayoutData keys_to_display[] =
{
{ 0, 0, "", ImGuiKey_Tab }, { 0, 1, "Q", ImGuiKey_Q },
{ 0, 2, "W", ImGuiKey_W }, { 0, 3, "E", ImGuiKey_E }, { 0, 4, "R", ImGuiKey_R },
{ 1, 0, "", ImGuiKey_CapsLock }, { 1, 1, "A", ImGuiKey_A },
{ 1, 2, "S", ImGuiKey_S }, { 1, 3, "D", ImGuiKey_D }, { 1, 4, "F", ImGuiKey_F },
{ 2, 0, "", ImGuiKey_LeftShift },{ 2, 1, "Z", ImGuiKey_Z },
{ 2, 2, "X", ImGuiKey_X }, { 2, 3, "C", ImGuiKey_C }, { 2, 4, "V", ImGuiKey_V }
};
ImDrawList* draw_list = ImGui::GetWindowDrawList();
draw_list->PushClipRect(board_min, board_max, true);
for (int n = 0; n < IM_ARRAYSIZE(keys_to_display); n++)
{
const KeyLayoutData* key_data = &keys_to_display[n];
ImVec2 key_min = ImVec2(start_pos.x + key_data->Col * key_st
ep.x + key_data->Row * key_row_offset, start_pos.y + key_data->Row * key_step.y)
;
ImVec2 key_max = ImVec2(key_min.x + key_size.x, key_min.y +
key_size.y);
draw_list->AddRectFilled(key_min, key_max, IM_COL32(204, 204
, 204, 255), key_rounding);
draw_list->AddRect(key_min, key_max, IM_COL32(24, 24, 24, 25
5), key_rounding);
ImVec2 face_min = ImVec2(key_min.x + key_face_pos.x, key_min
.y + key_face_pos.y);
ImVec2 face_max = ImVec2(face_min.x + key_face_size.x, face_
min.y + key_face_size.y);
draw_list->AddRect(face_min, face_max, IM_COL32(193, 193, 19
3, 255), key_face_rounding, ImDrawFlags_None, 2.0f);
draw_list->AddRectFilled(face_min, face_max, IM_COL32(252, 2
52, 252, 255), key_face_rounding);
ImVec2 label_min = ImVec2(key_min.x + key_label_pos.x, key_m
in.y + key_label_pos.y);
draw_list->AddText(label_min, IM_COL32(64, 64, 64, 255), key
_data->Label);
if (ImGui::IsKeyDown(key_data->Key))
draw_list->AddRectFilled(key_min, key_max, IM_COL32(255,
0, 0, 128), key_rounding);
}
draw_list->PopClipRect();
ImGui::Dummy(ImVec2(board_max.x - board_min.x, board_max.y - boa
rd_min.y));
}
ImGui::TreePop();
}
if (ImGui::TreeNode("Capture override"))
{
ImGui::Button("Hovering me sets the\nkeyboard capture flag"); ImGui::Button("Hovering me sets the\nkeyboard capture flag");
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())
ImGui::CaptureKeyboardFromApp(true); ImGui::CaptureKeyboardFromApp(true);
ImGui::SameLine(); ImGui::SameLine();
ImGui::Button("Holding me clears the\nthe keyboard capture flag"); ImGui::Button("Holding me clears the\nthe keyboard capture flag");
if (ImGui::IsItemActive()) if (ImGui::IsItemActive())
ImGui::CaptureKeyboardFromApp(false); ImGui::CaptureKeyboardFromApp(false);
ImGui::TreePop(); ImGui::TreePop();
} }
skipping to change at line 5871 skipping to change at line 5929
ImGui::LogText("```\n"); // Back quotes will make text appears witho ut formatting when pasting on GitHub ImGui::LogText("```\n"); // Back quotes will make text appears witho ut formatting when pasting on GitHub
} }
ImGui::Text("Dear ImGui %s (%d)", IMGUI_VERSION, IMGUI_VERSION_NUM); ImGui::Text("Dear ImGui %s (%d)", IMGUI_VERSION, IMGUI_VERSION_NUM);
ImGui::Separator(); ImGui::Separator();
ImGui::Text("sizeof(size_t): %d, sizeof(ImDrawIdx): %d, sizeof(ImDrawVer t): %d", (int)sizeof(size_t), (int)sizeof(ImDrawIdx), (int)sizeof(ImDrawVert)); ImGui::Text("sizeof(size_t): %d, sizeof(ImDrawIdx): %d, sizeof(ImDrawVer t): %d", (int)sizeof(size_t), (int)sizeof(ImDrawIdx), (int)sizeof(ImDrawVert));
ImGui::Text("define: __cplusplus=%d", (int)__cplusplus); ImGui::Text("define: __cplusplus=%d", (int)__cplusplus);
#ifdef IMGUI_DISABLE_OBSOLETE_FUNCTIONS #ifdef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
ImGui::Text("define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS"); ImGui::Text("define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS");
#endif #endif
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
ImGui::Text("define: IMGUI_DISABLE_OBSOLETE_KEYIO");
#endif
#ifdef IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS #ifdef IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS
ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS"); ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS");
#endif #endif
#ifdef IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS #ifdef IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS
ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS"); ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS");
#endif #endif
#ifdef IMGUI_DISABLE_WIN32_FUNCTIONS #ifdef IMGUI_DISABLE_WIN32_FUNCTIONS
ImGui::Text("define: IMGUI_DISABLE_WIN32_FUNCTIONS"); ImGui::Text("define: IMGUI_DISABLE_WIN32_FUNCTIONS");
#endif #endif
#ifdef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS #ifdef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
skipping to change at line 5984 skipping to change at line 6045
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// - ShowFontSelector() // - ShowFontSelector()
// - ShowStyleSelector() // - ShowStyleSelector()
// - ShowStyleEditor() // - ShowStyleEditor()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Forward declare ShowFontAtlas() which isn't worth putting in public API yet // Forward declare ShowFontAtlas() which isn't worth putting in public API yet
namespace ImGui { IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas); } namespace ImGui { IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas); }
// Demo helper function to select among loaded fonts. // Demo helper function to select among loaded fonts.
// Here we use the regular BeginCombo()/EndCombo() api which is more the more fl exible one. // Here we use the regular BeginCombo()/EndCombo() api which is the more flexibl e one.
void ImGui::ShowFontSelector(const char* label) void ImGui::ShowFontSelector(const char* label)
{ {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImFont* font_current = ImGui::GetFont(); ImFont* font_current = ImGui::GetFont();
if (ImGui::BeginCombo(label, font_current->GetDebugName())) if (ImGui::BeginCombo(label, font_current->GetDebugName()))
{ {
for (int n = 0; n < io.Fonts->Fonts.Size; n++) for (int n = 0; n < io.Fonts->Fonts.Size; n++)
{ {
ImFont* font = io.Fonts->Fonts[n]; ImFont* font = io.Fonts->Fonts[n];
ImGui::PushID((void*)font); ImGui::PushID((void*)font);
skipping to change at line 7512 skipping to change at line 7573
// You may decide to make that threshold dynamic based on whether th e mouse is hovering something etc. // You may decide to make that threshold dynamic based on whether th e mouse is hovering something etc.
const float mouse_threshold_for_pan = opt_enable_context_menu ? -1.0 f : 0.0f; const float mouse_threshold_for_pan = opt_enable_context_menu ? -1.0 f : 0.0f;
if (is_active && ImGui::IsMouseDragging(ImGuiMouseButton_Right, mous e_threshold_for_pan)) if (is_active && ImGui::IsMouseDragging(ImGuiMouseButton_Right, mous e_threshold_for_pan))
{ {
scrolling.x += io.MouseDelta.x; scrolling.x += io.MouseDelta.x;
scrolling.y += io.MouseDelta.y; scrolling.y += io.MouseDelta.y;
} }
// Context menu (under default mouse threshold) // Context menu (under default mouse threshold)
ImVec2 drag_delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Right) ; ImVec2 drag_delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Right) ;
if (opt_enable_context_menu && ImGui::IsMouseReleased(ImGuiMouseButt if (opt_enable_context_menu && drag_delta.x == 0.0f && drag_delta.y
on_Right) && drag_delta.x == 0.0f && drag_delta.y == 0.0f) == 0.0f)
ImGui::OpenPopupOnItemClick("context"); ImGui::OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButt
onRight);
if (ImGui::BeginPopup("context")) if (ImGui::BeginPopup("context"))
{ {
if (adding_line) if (adding_line)
points.resize(points.size() - 2); points.resize(points.size() - 2);
adding_line = false; adding_line = false;
if (ImGui::MenuItem("Remove one", NULL, false, points.Size > 0)) { points.resize(points.size() - 2); } if (ImGui::MenuItem("Remove one", NULL, false, points.Size > 0)) { points.resize(points.size() - 2); }
if (ImGui::MenuItem("Remove all", NULL, false, points.Size > 0)) { points.clear(); } if (ImGui::MenuItem("Remove all", NULL, false, points.Size > 0)) { points.clear(); }
ImGui::EndPopup(); ImGui::EndPopup();
} }
 End of changes. 16 change blocks. 
26 lines changed or deleted 118 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)