From 9912f7eef80a7f8fda21a5c92eb4fcc4e32ee4dd Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 29 Sep 2017 22:19:53 +0200 Subject: [PATCH 1/7] BeginMenu(): fixed logic to distinguish vertical menu from one layed out in a menu bar. Makes MenuItem() in a regular window behave more consistently, and this will be also needed by upcoming menu-navigation changes in the nav branch. (#126, #787) --- imgui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 3d00e84b..849a05f4 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -9076,7 +9076,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled) g.NavWindow = backed_nav_window; bool want_open = false, want_close = false; - if (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu)) + if (window->DC.LayoutType != ImGuiLayoutType_Horizontal) // (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu)) { // Implement http://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown to avoid using timers, so menus feels more reactive. bool moving_within_opened_triangle = false; From cbc9730798b9971794d3c63480aca918f72f857e Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 2 Oct 2017 15:36:52 -0700 Subject: [PATCH 2/7] Metrics: Draw window bounding boxes when hovering Pos/Size. List all draw layers, trimming empty commands like Render() does. --- imgui.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 849a05f4..75c01835 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -10590,6 +10590,8 @@ void ImGui::ShowMetricsWindow(bool* p_open) int elem_offset = 0; for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.begin(); pcmd < draw_list->CmdBuffer.end(); elem_offset += pcmd->ElemCount, pcmd++) { + if (pcmd->UserCallback == NULL && pcmd->ElemCount == 0) + continue; if (pcmd->UserCallback) { ImGui::BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData); @@ -10644,8 +10646,9 @@ void ImGui::ShowMetricsWindow(bool* p_open) if (!ImGui::TreeNode(window, "%s '%s', %d @ 0x%p", label, window->Name, window->Active || window->WasActive, window)) return; NodeDrawList(window->DrawList, "DrawList"); - ImGui::BulletText("Pos: (%.1f,%.1f)", window->Pos.x, window->Pos.y); - ImGui::BulletText("Size: (%.1f,%.1f), SizeContents (%.1f,%.1f)", window->Size.x, window->Size.y, window->SizeContents.x, window->SizeContents.y); + ImGui::BulletText("Pos: (%.1f,%.1f), Size: (%.1f,%.1f), SizeContents (%.1f,%.1f)", window->Pos.x, window->Pos.y, window->Size.x, window->Size.y, window->SizeContents.x, window->SizeContents.y); + if (ImGui::IsItemHovered()) + GImGui->OverlayDrawList.AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255,255,0,255)); ImGui::BulletText("Scroll: (%.2f,%.2f)", window->Scroll.x, window->Scroll.y); ImGui::BulletText("Active: %d, Accessed: %d", window->Active, window->Accessed); if (window->RootWindow != window) NodeWindow(window->RootWindow, "RootWindow"); @@ -10659,8 +10662,9 @@ void ImGui::ShowMetricsWindow(bool* p_open) Funcs::NodeWindows(g.Windows, "Windows"); if (ImGui::TreeNode("DrawList", "Active DrawLists (%d)", g.RenderDrawLists[0].Size)) { - for (int i = 0; i < g.RenderDrawLists[0].Size; i++) - Funcs::NodeDrawList(g.RenderDrawLists[0][i], "DrawList"); + for (int layer = 0; layer < IM_ARRAYSIZE(g.RenderDrawLists); layer++) + for (int i = 0; i < g.RenderDrawLists[layer].Size; i++) + Funcs::NodeDrawList(g.RenderDrawLists[0][i], "DrawList"); ImGui::TreePop(); } if (ImGui::TreeNode("Popups", "Open Popups Stack (%d)", g.OpenPopupStack.Size)) From 7f58bb03c145227ead5e2bfd03ab5f3022fab529 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 2 Oct 2017 15:46:00 -0700 Subject: [PATCH 3/7] Changed the internal name formatting of child windows to use slashes as separator, more readable. --- imgui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 75c01835..4761a542 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3720,9 +3720,9 @@ static bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b char title[256]; if (name) - ImFormatString(title, IM_ARRAYSIZE(title), "%s.%s.%08X", parent_window->Name, name, id); + ImFormatString(title, IM_ARRAYSIZE(title), "%s/%s_%08X", parent_window->Name, name, id); else - ImFormatString(title, IM_ARRAYSIZE(title), "%s.%08X", parent_window->Name, id); + ImFormatString(title, IM_ARRAYSIZE(title), "%s/%08X", parent_window->Name, id); bool ret = ImGui::Begin(title, NULL, size, -1.0f, flags); ImGuiWindow* child_window = ImGui::GetCurrentWindow(); From 6ec50d6bf5f9e4f853a664dcb13357958d9f7f19 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Tue, 3 Oct 2017 11:45:25 -0700 Subject: [PATCH 4/7] Fix binary_to_compressed_c tool to return 0 when successful Returning 1 is seen as an error by many tools, making it tricky to integrate this into build systems as-is. --- extra_fonts/binary_to_compressed_c.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extra_fonts/binary_to_compressed_c.cpp b/extra_fonts/binary_to_compressed_c.cpp index ee160a42..e373e69c 100644 --- a/extra_fonts/binary_to_compressed_c.cpp +++ b/extra_fonts/binary_to_compressed_c.cpp @@ -53,8 +53,7 @@ int main(int argc, char** argv) } } - binary_to_compressed_c(argv[argn], argv[argn+1], use_base85_encoding, use_compression); - return 1; + return binary_to_compressed_c(argv[argn], argv[argn+1], use_base85_encoding, use_compression) ? 0 : 1; } char Encode85Byte(unsigned int x) From b36a043bbfc7c812024a0a02d63b15b134389cbb Mon Sep 17 00:00:00 2001 From: matiTechno Date: Wed, 4 Oct 2017 11:09:21 +0200 Subject: [PATCH 5/7] typo --- imgui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 4761a542..f1fdb508 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -105,7 +105,7 @@ - See examples/ folder for standalone sample applications. To understand the integration process, you can read examples/opengl2_example/ because it is short, then switch to the one more appropriate to your use case. - You may be able to grab and copy a ready made imgui_impl_*** file from the examples/. - - When using Dear ImGui, your programming IDE if your friend: follow the declaration of variables, functions and types to find comments about them. + - When using Dear ImGui, your programming IDE is your friend: follow the declaration of variables, functions and types to find comments about them. - Init: retrieve the ImGuiIO structure with ImGui::GetIO() and fill the fields marked 'Settings': at minimum you need to set io.DisplaySize (application resolution). Later on you will fill your keyboard mapping, clipboard handlers, and other advanced features but for a basic integration you don't need to worry about it all. From 89ab4b5e07d53104917e18929e1e18c1af3d47da Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 4 Oct 2017 11:56:03 -0700 Subject: [PATCH 6/7] TODO update --- TODO.txt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/TODO.txt b/TODO.txt index 92535d08..d2820c75 100644 --- a/TODO.txt +++ b/TODO.txt @@ -25,6 +25,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - window: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon? - window: expose contents size. (#1045) - window: GetWindowSize() returns (0,0) when not calculated? (#1045) + - window: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate. !- scrolling: allow immediately effective change of scroll after Begin() if we haven't appended items yet. - scrolling/clipping: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y). (2017-08-20: can't repro) @@ -55,6 +56,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - input text: flag to disable live update of the user buffer (also applies to float/int text input) (#701) - input text: way to dynamically grow the buffer without forcing the user to initially allocate for worse case, e.g. more natural std::string (follow up on #200) - input text: hover tooltip could show unclamped text + - input text: option to Tab after an Enter validation. - input text: add ImGuiInputTextFlags_EnterToApply? (off #218) - input text: easier ways to update buffer (from source char*) while owned. preserve some sort of cursor position for multi-line text. - input text: add discard flag (e.g. ImGuiInputTextFlags_DiscardActiveBuffer) or make it easier to clear active focus for text replacement during edition (#725) @@ -80,7 +82,9 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - columns: sizing policy (e.g. for each column: fixed size, %, fill, distribute default size among fills) (#513, #125) - columns: add a conditional parameter to SetColumnOffset() (#513, #125) - - columns: headers. with sort op/button. reorderable. (#513, #125) + - columns: headers. reorderable. (#513, #125) + - columns: optional sorting modifiers (up/down), sort list so sorting can be done multi-critera. notify user when sort order changed. + - columns: option to alternate background colors on odd/even scanlines. - columns: allow columns to recurse. - columns: separator function or parameter that works within the column (currently Separator() bypass all columns) (#125) - columns: flag to add horizontal separator above/below? @@ -134,7 +138,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - combo: option for ComboEx to not return true when unchanged (#1182) - combo/listbox: keyboard control. need InputText-like non-active focus + key handling. considering keyboard for custom listbox (pr #203) - listbox: multiple selection. - - listbox: unselect (#1208) + - listbox: unselect option (#1208) - listbox: make it easier/more natural to implement range-select (need some sort of info/ref about the last clicked/focused item that user can translate to an index?) - listbox: user may want to initial scroll to focus on the one selected value? - listbox: expose hovered item for a basic ListBox @@ -142,7 +146,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - listbox: scrolling should track modified selection. !- popups/menus: clarify usage of popups id, how MenuItem/Selectable closing parent popups affects the ID, etc. this is quite fishy needs improvement! (#331, #402) - - popups/nav: esc/enter default behavior for popups. - popups: reopening context menu at new position should be the behavior by default? (equivalent to internal OpenPopupEx() with reopen_existing=true) - popups: if the popup functions took explicit ImGuiID it would allow the user to manage the scope of those ID. (#331) - popups: clicking outside (to close popup) and holding shouldn't drag window below. @@ -217,13 +220,16 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - font: fix AddRemapChar() to work before font has been built. - font: (api breaking) removed "TTF" from symbol names. also because it now supports OTF. -!- keyboard: tooltip & combo boxes are messing up / not honoring keyboard tabbing. - - keyboard: full keyboard navigation and focus. (#323) +!- nav/keyboard: tooltip & combo boxes are messing up / not honoring keyboard tabbing. + - nav: integrate navigation branch into master. (#787) + - nav: integrate/design keyboard controls. + - nav: once tab should go through most/all widgets (in submission order?) + - nav: esc/enter default behavior for popups, e.g. be able to mark an "ok" or "cancel" button that would get triggered by those keys. - focus: preserve ActiveId/focus stack state, e.g. when opening a menu and close it, previously selected InputText() focus gets restored (#622) - focus: SetKeyboardFocusHere() on with >= 0 offset could be done on same frame (else latch and modulate on beginning of next frame) - - focus: unable to use SetKeyboardFocusHere() on clipped widgets. (#343) + - focus: unable to use SetKeyboardFocusHere() on clipped widgets. (#787) - inputs: rework IO system to be able to pass actual ordered/timestamped events. use an event queue? (~#335, #71) - - inputs: allow to decide and pass explicit double-clicks (e.g. for windows by the CS_DBLCLKS style). + - inputs: allow to pass explicit double-clicks if that's the only thing the user's backend can get them. (e.g. for windows by the CS_DBLCLKS style). - inputs: support track pad style scrolling & slider edit. - misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL) From 67ac7da30f2372dbd9c7371ef42114a436f6659d Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 4 Oct 2017 18:13:57 -0700 Subject: [PATCH 7/7] Styles: Added ImGuiStyle::ScaleAllSizes(float) helper to make it easier to have application transition to e.g. High DPI with a matching style. --- imgui.cpp | 23 +++++++++++++++++++++++ imgui.h | 1 + 2 files changed, 24 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index f1fdb508..21aba4eb 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -744,6 +744,29 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst) colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); } +// To scale your entire UI (e.g. if you want your app to use High DPI or generally be DPI aware) you may use this helper function. Scaling the fonts is done separately and is up to you. +// Tips: if you need to change your scale multiple times, prefer calling this on a freshly initialized ImGuiStyle structure rather than scaling multiple times (because floating point multiplications are lossy). +void ImGuiStyle::ScaleAllSizes(float scale_factor) +{ + WindowPadding *= scale_factor; + WindowMinSize *= scale_factor; + WindowRounding *= scale_factor; + ChildWindowRounding *= scale_factor; + FramePadding *= scale_factor; + FrameRounding *= scale_factor; + ItemSpacing *= scale_factor; + ItemInnerSpacing *= scale_factor; + TouchExtraPadding *= scale_factor; + IndentSpacing *= scale_factor; + ColumnsMinSpacing *= scale_factor; + ScrollbarSize *= scale_factor; + ScrollbarRounding *= scale_factor; + GrabMinSize *= scale_factor; + GrabRounding *= scale_factor; + DisplayWindowPadding *= scale_factor; + DisplaySafeAreaPadding *= scale_factor; +} + ImGuiIO::ImGuiIO() { // Most fields are initialized with zero diff --git a/imgui.h b/imgui.h index 0740592f..654e83fc 100644 --- a/imgui.h +++ b/imgui.h @@ -769,6 +769,7 @@ struct ImGuiStyle ImVec4 Colors[ImGuiCol_COUNT]; IMGUI_API ImGuiStyle(); + IMGUI_API void ScaleAllSizes(float scale_factor); }; // This is where your app communicate with ImGui. Access via ImGui::GetIO().