|
|
@@ -40,7 +40,7 @@ DOCUMENTATION
|
|
|
- READ FIRST
|
|
|
- HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI
|
|
|
- GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE
|
|
|
- - HOW A SIMPLE APPLICATION MAY LOOK LIKE (2 variations)
|
|
|
+ - HOW A SIMPLE APPLICATION MAY LOOK LIKE
|
|
|
- HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE
|
|
|
- USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS
|
|
|
- API BREAKING CHANGES (read me when you update!)
|
|
|
@@ -139,7 +139,7 @@ CODE
|
|
|
- Call and read ImGui::ShowDemoWindow() for demo code demonstrating most features.
|
|
|
- The library is designed to be built from sources. Avoid pre-compiled binaries and packaged versions. See imconfig.h to configure your build.
|
|
|
- Dear ImGui is an implementation of the IMGUI paradigm (immediate-mode graphical user interface, a term coined by Casey Muratori).
|
|
|
- You can learn about IMGUI principles at http://www.johno.se/book/imgui.html, http://mollyrocket.com/861 & more links docs/README.md.
|
|
|
+ You can learn about IMGUI principles at http://www.johno.se/book/imgui.html, http://mollyrocket.com/861 & more links in the FAQ.
|
|
|
- Dear ImGui is a "single pass" rasterizing implementation of the IMGUI paradigm, aimed at ease of use and high-performances.
|
|
|
For every application frame your UI code will be called only once. This is in contrast to e.g. Unity's own implementation of an IMGUI,
|
|
|
where the UI code is called multiple times ("multiple passes") from a single entry point. There are pros and cons to both approaches.
|
|
|
@@ -153,6 +153,7 @@ CODE
|
|
|
However, imgui_internal.h can optionally export math operators for ImVec2/ImVec4, which we use in this codebase.
|
|
|
- C++: pay attention that ImVector<> manipulates plain-old-data and does not honor construction/destruction (avoid using it in your code!).
|
|
|
|
|
|
+
|
|
|
HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI
|
|
|
----------------------------------------------
|
|
|
- Overwrite all the sources files except for imconfig.h (if you have made modification to your copy of imconfig.h)
|
|
|
@@ -163,6 +164,7 @@ CODE
|
|
|
likely be a comment about it. Please report any issue to the GitHub page!
|
|
|
- Try to keep your copy of dear imgui reasonably up to date.
|
|
|
|
|
|
+
|
|
|
GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE
|
|
|
---------------------------------------------------------------
|
|
|
- Run and study the examples and demo in imgui_demo.cpp to get acquainted with the library.
|
|
|
@@ -177,9 +179,11 @@ CODE
|
|
|
- Refer to the bindings and demo applications in the examples/ folder for instruction on how to setup your code.
|
|
|
- If you are running over a standard OS with a common graphics API, you should be able to use unmodified imgui_impl_*** files from the examples/ folder.
|
|
|
|
|
|
+
|
|
|
HOW A SIMPLE APPLICATION MAY LOOK LIKE
|
|
|
--------------------------------------
|
|
|
- EXHIBIT 1: USING THE EXAMPLE BINDINGS (imgui_impl_XXX.cpp files from the examples/ folder).
|
|
|
+ EXHIBIT 1: USING THE EXAMPLE BINDINGS (= imgui_impl_XXX.cpp files from the examples/ folder).
|
|
|
+ The sub-folders in examples/ contains examples applications following this structure.
|
|
|
|
|
|
// Application init: create a dear imgui context, setup some options, load fonts
|
|
|
ImGui::CreateContext();
|
|
|
@@ -268,8 +272,15 @@ CODE
|
|
|
// Shutdown
|
|
|
ImGui::DestroyContext();
|
|
|
|
|
|
+ To decide whether to dispatch mouse/keyboard inputs to Dear ImGui to the rest your application,
|
|
|
+ you should read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags!
|
|
|
+ Please read the FAQ and example applications for details about this!
|
|
|
+
|
|
|
+
|
|
|
HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE
|
|
|
---------------------------------------------
|
|
|
+ The bindings in impl_impl_XXX.cpp files contains many working implementations of a rendering function.
|
|
|
+
|
|
|
void void MyImGuiRenderFunction(ImDrawData* draw_data)
|
|
|
{
|
|
|
// TODO: Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled
|
|
|
@@ -314,11 +325,6 @@ CODE
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- - The examples/ folders contains many actual implementation of the pseudo-codes above.
|
|
|
- - When calling NewFrame(), the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags are updated.
|
|
|
- They tell you if Dear ImGui intends to use your inputs. When a flag is set you want to hide the corresponding inputs from the
|
|
|
- rest of your application. In every cases you need to pass on the inputs to Dear ImGui.
|
|
|
- - Refer to the FAQ for more information. Amusingly, it is called a FAQ because people frequently run into the same issues!
|
|
|
|
|
|
USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS
|
|
|
------------------------------------------
|
|
|
@@ -367,7 +373,7 @@ CODE
|
|
|
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
|
|
|
|
|
- 2020/01/22 (1.75) - ImDrawList::AddCircle()/AddCircleFilled() functions don't accept negative radius any more.
|
|
|
- - 2019/12/17 (1.75) - made Columns() limited to 64 columns by asserting above that limit. While the current code technically supports it, future code may not so we're putting the restriction ahead.
|
|
|
+ - 2019/12/17 (1.75) - [undid this change in 1.76] made Columns() limited to 64 columns by asserting above that limit. While the current code technically supports it, future code may not so we're putting the restriction ahead.
|
|
|
- 2019/12/13 (1.75) - [imgui_internal.h] changed ImRect() default constructor initializes all fields to 0.0f instead of (FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX). If you used ImRect::Add() to create bounding boxes by adding multiple points into it, you may need to fix your initial value.
|
|
|
- 2019/12/08 (1.75) - removed redirecting functions/enums that were marked obsolete in 1.53 (December 2017):
|
|
|
- ShowTestWindow() -> use ShowDemoWindow()
|
|
|
@@ -2228,7 +2234,9 @@ void ImGui::CalcListClipping(int items_count, float items_height, int* out_items
|
|
|
// We create the union of the ClipRect and the NavScoringRect which at worst should be 1 page away from ClipRect
|
|
|
ImRect unclipped_rect = window->ClipRect;
|
|
|
if (g.NavMoveRequest)
|
|
|
- unclipped_rect.Add(g.NavScoringRectScreen);
|
|
|
+ unclipped_rect.Add(g.NavScoringRect);
|
|
|
+ if (g.NavJustMovedToId && window->NavLastIds[0] == g.NavJustMovedToId)
|
|
|
+ unclipped_rect.Add(ImRect(window->Pos + window->NavRectRel[0].Min, window->Pos + window->NavRectRel[0].Max));
|
|
|
|
|
|
const ImVec2 pos = window->DC.CursorPos;
|
|
|
int start = (int)((unclipped_rect.Min.y - pos.y) / items_height);
|
|
|
@@ -3144,7 +3152,7 @@ bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
if (!bb.Overlaps(window->ClipRect))
|
|
|
- if (id == 0 || id != g.ActiveId)
|
|
|
+ if (id == 0 || (id != g.ActiveId && id != g.NavId))
|
|
|
if (clip_even_when_logged || !g.LogEnabled)
|
|
|
return true;
|
|
|
return false;
|
|
|
@@ -3679,7 +3687,7 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
|
|
|
g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;
|
|
|
}
|
|
|
|
|
|
-static ImGuiKeyModFlags GetMergedKeyModFlags()
|
|
|
+ImGuiKeyModFlags ImGui::GetMergedKeyModFlags()
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiKeyModFlags key_mod_flags = ImGuiKeyModFlags_None;
|
|
|
@@ -3797,7 +3805,7 @@ void ImGui::NewFrame()
|
|
|
for (int i = 0; i < IM_ARRAYSIZE(g.IO.KeysDown); i++)
|
|
|
g.IO.KeysDownDuration[i] = g.IO.KeysDown[i] ? (g.IO.KeysDownDuration[i] < 0.0f ? 0.0f : g.IO.KeysDownDuration[i] + g.IO.DeltaTime) : -1.0f;
|
|
|
|
|
|
- // Update gamepad/keyboard directional navigation
|
|
|
+ // Update gamepad/keyboard navigation
|
|
|
NavUpdate();
|
|
|
|
|
|
// Update mouse input state
|
|
|
@@ -7982,7 +7990,7 @@ static void inline NavClampRectToVisibleAreaForMoveDir(ImGuiDir move_dir, ImRect
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// Scoring function for directional navigation. Based on https://gist.github.com/rygorous/6981057
|
|
|
+// Scoring function for gamepad/keyboard directional navigation. Based on https://gist.github.com/rygorous/6981057
|
|
|
static bool ImGui::NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
@@ -7990,7 +7998,7 @@ static bool ImGui::NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
|
|
|
if (g.NavLayer != window->DC.NavLayerCurrent)
|
|
|
return false;
|
|
|
|
|
|
- const ImRect& curr = g.NavScoringRectScreen; // Current modified source rect (NB: we've applied Max.x = Min.x in NavUpdate() to inhibit the effect of having varied item width)
|
|
|
+ const ImRect& curr = g.NavScoringRect; // Current modified source rect (NB: we've applied Max.x = Min.x in NavUpdate() to inhibit the effect of having varied item width)
|
|
|
g.NavScoringCount++;
|
|
|
|
|
|
// When entering through a NavFlattened border, we consider child window items as fully clipped for scoring
|
|
|
@@ -8571,6 +8579,7 @@ static void ImGui::NavUpdate()
|
|
|
if (g.NavMoveDir != ImGuiDir_None)
|
|
|
{
|
|
|
g.NavMoveRequest = true;
|
|
|
+ g.NavMoveRequestKeyMods = g.IO.KeyMods;
|
|
|
g.NavMoveDirLast = g.NavMoveDir;
|
|
|
}
|
|
|
if (g.NavMoveRequest && g.NavId == 0)
|
|
|
@@ -8634,11 +8643,11 @@ static void ImGui::NavUpdate()
|
|
|
|
|
|
// For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items)
|
|
|
ImRect nav_rect_rel = (g.NavWindow && !g.NavWindow->NavRectRel[g.NavLayer].IsInverted()) ? g.NavWindow->NavRectRel[g.NavLayer] : ImRect(0,0,0,0);
|
|
|
- g.NavScoringRectScreen = g.NavWindow ? ImRect(g.NavWindow->Pos + nav_rect_rel.Min, g.NavWindow->Pos + nav_rect_rel.Max) : GetViewportRect();
|
|
|
- g.NavScoringRectScreen.TranslateY(nav_scoring_rect_offset_y);
|
|
|
- g.NavScoringRectScreen.Min.x = ImMin(g.NavScoringRectScreen.Min.x + 1.0f, g.NavScoringRectScreen.Max.x);
|
|
|
- g.NavScoringRectScreen.Max.x = g.NavScoringRectScreen.Min.x;
|
|
|
- IM_ASSERT(!g.NavScoringRectScreen.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allows us to remove extraneous ImFabs() calls in NavScoreItem().
|
|
|
+ g.NavScoringRect = g.NavWindow ? ImRect(g.NavWindow->Pos + nav_rect_rel.Min, g.NavWindow->Pos + nav_rect_rel.Max) : GetViewportRect();
|
|
|
+ g.NavScoringRect.TranslateY(nav_scoring_rect_offset_y);
|
|
|
+ g.NavScoringRect.Min.x = ImMin(g.NavScoringRect.Min.x + 1.0f, g.NavScoringRect.Max.x);
|
|
|
+ g.NavScoringRect.Max.x = g.NavScoringRect.Min.x;
|
|
|
+ IM_ASSERT(!g.NavScoringRect.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allows us to remove extraneous ImFabs() calls in NavScoreItem().
|
|
|
//GetForegroundDrawList()->AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG]
|
|
|
g.NavScoringCount = 0;
|
|
|
#if IMGUI_DEBUG_NAV_RECTS
|
|
|
@@ -8708,7 +8717,7 @@ static void ImGui::NavUpdateMoveResult()
|
|
|
// Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId)
|
|
|
g.NavJustMovedToId = result->ID;
|
|
|
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
|
|
-
|
|
|
+ g.NavJustMovedToKeyMods = g.NavMoveRequestKeyMods;
|
|
|
}
|
|
|
SetNavIDWithRectRel(result->ID, g.NavLayer, result->FocusScopeId, result->RectRel);
|
|
|
g.NavMoveFromClampedRefRect = false;
|