From b8c6e31c2de36d80ed16af54b80ae8e489964f84 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 15 Jan 2019 15:05:56 +0100 Subject: [PATCH 1/2] Fixed cursor issue caused by 6890e08b when calling BeginChild/EndChild multiple times to reappend into a same child window. (#2282) --- imgui.cpp | 3 ++- imgui_demo.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index ac3580e30..9bdd8eedb 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4276,7 +4276,8 @@ static bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size // Set the cursor to handle case where the user called SetNextWindowPos()+BeginChild() manually. // While this is not really documented/defined, it seems that the expected thing to do. - parent_window->DC.CursorPos = child_window->Pos; + if (child_window->BeginCount == 1) + parent_window->DC.CursorPos = child_window->Pos; // Process navigation-in immediately so NavInit can run on first frame if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayerActiveMask != 0 || child_window->DC.NavHasScroll)) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index d5806401d..c5cd34aa0 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1983,7 +1983,7 @@ static void ShowDemoWindowLayout() { 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) ImGui::SetScrollX(ImGui::GetScrollX() + scroll_x_delta); - ImGui::End(); + ImGui::EndChild(); } ImGui::TreePop(); } From d38d7c6628bebd02692cfdd6fa76b4d992a35b75 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 15 Jan 2019 15:06:24 +0100 Subject: [PATCH 2/2] TODO update + internals: changed order or ImGuiLayoutType enums to allow using them for indexing. --- docs/TODO.txt | 29 +++++++++++++++-------------- imgui_internal.h | 6 ++++-- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/docs/TODO.txt b/docs/TODO.txt index 00eeead98..13c8dbe9c 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -8,16 +8,12 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - doc/test: add a proper documentation+regression testing system (#435) - doc/test: checklist app to verify binding/integration of imgui (test inputs, rendering, callback, etc.). - doc/tips: tips of the day: website? applet in imgui_club? - - project: folder or separate repository with maintained helpers (e.g. imgui_memory_editor.h, imgui_stl.h, maybe imgui_dock would be there?) - window: calling SetNextWindowSize() every frame with <= 0 doesn't do anything, may be useful to allow (particularly when used for a single axis). (#690) - window: add a way for very transient windows (non-saved, temporary overlay over hundreds of objects) to "clean" up from the global window list. perhaps a lightweight explicit cleanup pass. - window: auto-fit feedback loop when user relies on any dynamic layout (window width multiplier, column) appears weird to end-user. clarify. - window: allow resizing of child windows (possibly given min/max for each axis?.) - window: background options for child windows, border option (disable rounding). - - window: resizing from any sides? done. > need backends to honor mouse cursors properly. (#822) - - window: resize from borders: support some form of outer padding to make it easier to grab borders. (#822) - - window: fix resize glitch when collapsing an AlwaysAutoResize window. - window: begin with *p_open == false could return false. - window: get size/pos helpers given names (see discussion in #249) - window: a collapsed window can be stuck behind the main menu bar? @@ -28,9 +24,10 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - window: expose contents size. (#1045) - window: using SetWindowPos() inside Begin() and moving the window with the mouse reacts a very ugly glitch. We should just defer the SetWindowPos() call. - 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. - window: investigate better auto-positioning for new windows. + - window/opt: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate. - window/child: the first draw command of a child window could be moved into the current draw command of the parent window (unless child+tooltip?). + - window/clipping: some form of clipping when DisplaySize (or corresponding viewport) is zero. - scrolling: while holding down a scrollbar, try to keep the same contents visible (at least while not moving mouse) - 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) @@ -99,7 +96,7 @@ 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. reorderable. (#513, #125) + - columns: headers. re-orderable. (#513, #125) - columns: optional sorting modifiers (up/down), sort list so sorting can be done multi-criteria. notify user when sort order changed. - columns: option to alternate background colors on odd/even scanlines. - columns: allow columns to recurse. @@ -126,7 +123,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - splitter/separator: formalize the splitter idiom into an official api (we want to handle n-way split) (#319) - - dock: docking extension + - dock: merge docking branch (#2109) - dock: dock out from a collapsing header? would work nicely but need emitting window to keep submitting the code. - tabs: make EndTabBar fail if users doesn't respect BeginTabBar return value, for consistency/future-proofing. @@ -134,7 +131,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - ext: stl-ish friendly extension (imgui_stl.h) that has wrapper for std::string, std::vector etc. - - button: provide a button that looks framed. + - button: provide a button that looks framed. (?) - image/image button: misalignment on padded/bordered button? - image/image button: parameters are confusing, image() has tint_col,border_col whereas imagebutton() has bg_col/tint_col. Even thou they are different parameters ordering could be more consistent. can we fix that? - image button: not taking an explicit id is odd. @@ -146,7 +143,9 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - slider: step option (#1183) - slider style: fill % of the bar instead of positioning a drag. - knob: rotating knob widget (#942) + - drag float: power/logarithmic slider and drags are weird. (#1316) - drag float: up/down axis + - drag float: power != 0.0f with current value being outside the the range keeps the value stuck. - drag float: added leeway on edge (e.g. a few invisible steps past the clamp limits) - combo: use clipper: make it easier to disable clipper with a single flag. @@ -202,7 +201,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - settings: api for per-tool simple persistent data (bool,int,float,columns sizes,etc.) in .ini file (#437) - stb: add defines to disable stb implementations -!- style: better default styles. (#707) + - style: better default styles. (#707) - style: add a highlighted text color (for headers, etc.) - style: border types: out-screen, in-screen, etc. (#447) - style: add window shadow (fading away from the window. Paint-style calculation of vertices alpha after drawlist would be easier) @@ -223,6 +222,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - filters: handle wild-cards (with implicit leading/trailing *), reg-exprs - filters: fuzzy matches (may use code at blog.forrestthewoods.com/4cffeed33fdb) + - drag and drop: releasing a drop shows the "..." tooltip for one frame - since e13e598 (#1725) - drag and drop: have some way to know when a drag begin from BeginDragDropSource() pov. - drag and drop: allow preview tooltip to be submitted from a different place than the drag source. (#1725) - drag and drop: allow using with other mouse buttons (where activeid won't be set). (#1637) @@ -243,6 +243,8 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - font: finish CustomRectRegister() to allow mapping Unicode codepoint to custom texture data - font: PushFontSize API (#1018) - font: MemoryTTF taking ownership confusing/not obvious, maybe default should be opposite? + - font/demo: add tools to show glyphs used by a text blob, display U16 value, list missing glyphs. + - font/demo: demonstrate use of ImFontGlyphRangesBuilder. - font/atlas: add a missing Glyphs.reserve() - font/atlas: incremental updates - font/atlas: dynamic font atlas to avoid baking huge ranges into bitmap and make scaling easier. @@ -250,7 +252,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - font/draw: vertical and/or rotated text renderer (#705) - vertical is easier clipping wise - font/draw: need to be able to specify wrap start position. - font/draw: better reserve policy for large horizontal block of text (shouldn't reserve for all clipped lines) - - font: optimization: for monospace font (like the default one) we can trim IndexXAdvance as long as trailing value is == FallbackXAdvance (need to make sure TAB is still correct). + - font: optimization: for monospace font (like the default one) we can trim IndexXAdvance as long as trailing value is == FallbackXAdvance (need to make sure TAB is still correct), would save on cache line. - font: add support for kerning, probably optional. A) perhaps default to (32..128)^2 matrix ~ 9K entries = 36KB, then hash for non-ascii?. B) or sparse lookup into per-char list? - font: add a simpler CalcTextSizeA() api? current one ok but not welcome if user needs to call it directly (without going through ImGui::CalcTextSize) - font: fix AddRemapChar() to work before font has been built. @@ -292,13 +294,12 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - inputs/io: backspace and arrows in the context of a text input could use system repeat rate. - inputs/io: clarify/standardize/expose repeat rate and repeat delays (#1808) - - misc: idle refresh: expose cursor blink animation timer for backend to be able to lower framerate. + - misc: idle: expose "woken up" boolean (set by inputs) and/or animation time (for cursor blink) for back-end to be able stop refreshing easily. + - misc: idle: if cursor blink if the _only_ visible animation, core imgui could rewrite vertex alpha to avoid CPU pass on ImGui:: calls. - misc: make the ImGuiCond values linear (non-power-of-two). internal storage for ImGuiWindow can use integers to combine into flags (Why?) - misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL) - misc: PushItemFlag(): add a flag to disable keyboard capture when used with mouse? (#1682) - misc: use more size_t in public api? - - misc: ImVector: erase_unsorted() helper - - misc: imgui_cpp: perhaps a misc/ header file with more friendly helper (e.g. type-infer versions of DragScalar, vector<> variants if appropriate for some functions). - backend: bgfx? https://gist.github.com/RichardGale/6e2b74bc42b3005e08397236e4be0fd0 - web/emscriptem: refactor some examples to facilitate integration with emscripten main loop system. (#1713, #336) @@ -309,7 +310,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - demo: find a way to demonstrate textures in the examples application, as it such a a common issue for new users. - demo: add vertical separator demo - demo: add virtual scrolling example? - - demo: demonstration Plot offset + - demo: demonstrate Plot offset - examples: window minimize, maximize (#583) - examples: provide a zero frame-rate/idle example. - examples: apple: example_apple should be using modern GL3. diff --git a/imgui_internal.h b/imgui_internal.h index 174d1af31..f7137c932 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -364,12 +364,14 @@ enum ImGuiItemStatusFlags_ }; // FIXME: this is in development, not exposed/functional as a generic feature yet. +// Horizontal/Vertical enums are fixed to 0/1 so they may be used to index ImVec2 enum ImGuiLayoutType_ { - ImGuiLayoutType_Vertical = 0, - ImGuiLayoutType_Horizontal = 1 + ImGuiLayoutType_Horizontal = 0, + ImGuiLayoutType_Vertical = 1 }; +// X/Y enums are fixed to 0/1 so they may be used to index ImVec2 enum ImGuiAxis { ImGuiAxis_None = -1,