mirror of
https://github.com/ocornut/imgui.git
synced 2025-12-20 05:15:36 +00:00
Merge branch 'master' into docking
This commit is contained in:
76
imgui.cpp
76
imgui.cpp
@@ -1,27 +1,28 @@
|
||||
// dear imgui, v1.92.5 WIP
|
||||
// dear imgui, v1.92.5
|
||||
// (main code and documentation)
|
||||
|
||||
// Help:
|
||||
// - See links below.
|
||||
// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp. All applications in examples/ are doing that.
|
||||
// - Read top of imgui.cpp for more details, links and comments.
|
||||
// - Add '#define IMGUI_DEFINE_MATH_OPERATORS' before including imgui.h (or in imconfig.h) to access courtesy maths operators for ImVec2 and ImVec4.
|
||||
|
||||
// Resources:
|
||||
// - FAQ ........................ https://dearimgui.com/faq (in repository as docs/FAQ.md)
|
||||
// - Homepage ................... https://github.com/ocornut/imgui
|
||||
// - Releases & changelog ....... https://github.com/ocornut/imgui/releases
|
||||
// - Releases & Changelog ....... https://github.com/ocornut/imgui/releases
|
||||
// - Gallery .................... https://github.com/ocornut/imgui/issues?q=label%3Agallery (please post your screenshots/video there!)
|
||||
// - Wiki ....................... https://github.com/ocornut/imgui/wiki (lots of good stuff there)
|
||||
// - Getting Started https://github.com/ocornut/imgui/wiki/Getting-Started (how to integrate in an existing app by adding ~25 lines of code)
|
||||
// - Third-party Extensions https://github.com/ocornut/imgui/wiki/Useful-Extensions (ImPlot & many more)
|
||||
// - Bindings/Backends https://github.com/ocornut/imgui/wiki/Bindings (language bindings, backends for various tech/engines)
|
||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||
// - Bindings/Backends https://github.com/ocornut/imgui/wiki/Bindings (language bindings + backends for various tech/engines)
|
||||
// - Debug Tools https://github.com/ocornut/imgui/wiki/Debug-Tools
|
||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||
// - Software using Dear ImGui https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui
|
||||
// - Issues & support ........... https://github.com/ocornut/imgui/issues
|
||||
// - Test Engine & Automation ... https://github.com/ocornut/imgui_test_engine (test suite, test engine to automate your apps)
|
||||
// - Web version of the Demo .... https://pthom.github.io/imgui_manual_online/manual/imgui_manual.html (w/ source code browser)
|
||||
|
||||
// For first-time users having issues compiling/linking/running:
|
||||
// For FIRST-TIME users having issues compiling/linking/running:
|
||||
// please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above.
|
||||
// Everything else should be asked in 'Issues'! We are building a database of cross-linked knowledge there.
|
||||
// Since 1.92, we encourage font loading questions to also be posted in 'Issues'.
|
||||
@@ -123,7 +124,7 @@ CODE
|
||||
Designed primarily for developers and content-creators, not the typical end-user!
|
||||
Some of the current weaknesses (which we aim to address in the future) includes:
|
||||
|
||||
- Doesn't look fancy.
|
||||
- Doesn't look fancy by default.
|
||||
- Limited layout features, intricate layouts are typically crafted in code.
|
||||
|
||||
|
||||
@@ -148,7 +149,8 @@ CODE
|
||||
- Ctrl+Z Undo.
|
||||
- Ctrl+Y or Ctrl+Shift+Z: Redo.
|
||||
- ESCAPE: Revert text to its original value.
|
||||
- On OSX, controls are automatically adjusted to match standard OSX text editing 2ts and behaviors.
|
||||
- On macOS, controls are automatically adjusted to match standard macOS text editing and behaviors.
|
||||
(for 99% of shortcuts, Ctrl is replaced by Cmd on macOS).
|
||||
|
||||
- KEYBOARD CONTROLS
|
||||
- Basic:
|
||||
@@ -201,7 +203,7 @@ CODE
|
||||
|
||||
READ FIRST
|
||||
----------
|
||||
- Remember to check the wonderful Wiki (https://github.com/ocornut/imgui/wiki)
|
||||
- Remember to check the wonderful Wiki: https://github.com/ocornut/imgui/wiki
|
||||
- Your code creates the UI every frame of your application loop, if your code doesn't run the UI is gone!
|
||||
The UI can be highly dynamic, there are no construction or destruction steps, less superfluous
|
||||
data retention on your side, less state duplication, less state synchronization, fewer bugs.
|
||||
@@ -5720,22 +5722,6 @@ void ImGui::NewFrame()
|
||||
g.HoverItemDelayTimer = g.HoverItemDelayClearTimer = 0.0f; // May want a decaying timer, in which case need to clamp at max first, based on max of caller last requested timer.
|
||||
}
|
||||
|
||||
// Drag and drop
|
||||
g.DragDropAcceptIdPrev = g.DragDropAcceptIdCurr;
|
||||
g.DragDropAcceptIdCurr = 0;
|
||||
g.DragDropAcceptFlagsPrev = g.DragDropAcceptFlagsCurr;
|
||||
g.DragDropAcceptFlagsCurr = ImGuiDragDropFlags_None;
|
||||
g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
|
||||
g.DragDropWithinSource = false;
|
||||
g.DragDropWithinTarget = false;
|
||||
g.DragDropHoldJustPressedId = 0;
|
||||
if (g.DragDropActive && IsKeyPressed(ImGuiKey_Escape, ImGuiInputFlags_None, g.ActiveId)) // Also works when g.ActiveId==0 (aka leftover payload in progress, no active id)
|
||||
{
|
||||
ClearActiveID();
|
||||
ClearDragDrop();
|
||||
}
|
||||
g.TooltipPreviousWindow = NULL;
|
||||
|
||||
// Close popups on focus lost (currently wip/opt-in)
|
||||
//if (g.IO.AppFocusLost)
|
||||
// ClosePopupsExceptModals();
|
||||
@@ -5748,6 +5734,30 @@ void ImGui::NewFrame()
|
||||
//IM_ASSERT(g.IO.KeyAlt == IsKeyDown(ImGuiKey_LeftAlt) || IsKeyDown(ImGuiKey_RightAlt));
|
||||
//IM_ASSERT(g.IO.KeySuper == IsKeyDown(ImGuiKey_LeftSuper) || IsKeyDown(ImGuiKey_RightSuper));
|
||||
|
||||
// Drag and drop
|
||||
g.DragDropAcceptIdPrev = g.DragDropAcceptIdCurr;
|
||||
g.DragDropAcceptIdCurr = 0;
|
||||
g.DragDropAcceptFlagsPrev = g.DragDropAcceptFlagsCurr;
|
||||
g.DragDropAcceptFlagsCurr = ImGuiDragDropFlags_None;
|
||||
g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
|
||||
g.DragDropWithinSource = false;
|
||||
g.DragDropWithinTarget = false;
|
||||
g.DragDropHoldJustPressedId = 0;
|
||||
if (g.DragDropActive)
|
||||
{
|
||||
// Also works when g.ActiveId==0 (aka leftover payload in progress, no active id)
|
||||
// You may disable this externally by hijacking the input route:
|
||||
// 'if (GetDragDropPayload() != NULL) { Shortcut(ImGuiKey_Escape, ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverActive); }
|
||||
// but you will not get a return value from Shortcut() due to ActiveIdUsingAllKeyboardKeys logic. You can however poll IsKeyPressed(ImGuiKey_Escape) afterwards.
|
||||
ImGuiID owner_id = g.ActiveId ? g.ActiveId : ImHashStr("##DragDropCancelHandler");
|
||||
if (Shortcut(ImGuiKey_Escape, ImGuiInputFlags_RouteGlobal, owner_id))
|
||||
{
|
||||
ClearActiveID();
|
||||
ClearDragDrop();
|
||||
}
|
||||
}
|
||||
g.TooltipPreviousWindow = NULL;
|
||||
|
||||
// Update keyboard/gamepad navigation
|
||||
NavUpdate();
|
||||
|
||||
@@ -14596,11 +14606,17 @@ void ImGui::NavUpdateCreateMoveRequest()
|
||||
{
|
||||
ImRect nav_rect_rel = !window->NavRectRel[g.NavLayer].IsInverted() ? window->NavRectRel[g.NavLayer] : ImRect(0, 0, 0, 0);
|
||||
scoring_rect = WindowRectRelToAbs(window, nav_rect_rel);
|
||||
if (scoring_page_offset_y != 0.0f)
|
||||
|
||||
if (g.NavMoveFlags & ImGuiNavMoveFlags_IsPageMove)
|
||||
{
|
||||
// When we start from a visible location, score visible items and prioritize this result.
|
||||
if (window->InnerRect.Contains(scoring_rect))
|
||||
g.NavMoveFlags |= ImGuiNavMoveFlags_AlsoScoreVisibleSet;
|
||||
g.NavScoringNoClipRect = scoring_rect;
|
||||
scoring_rect.TranslateY(scoring_page_offset_y);
|
||||
if (scoring_page_offset_y != 0.0f)
|
||||
scoring_rect.TranslateY(scoring_page_offset_y);
|
||||
g.NavScoringNoClipRect.Add(scoring_rect);
|
||||
}
|
||||
|
||||
//GetForegroundDrawList()->AddRectFilled(scoring_rect.Min - ImVec2(1, 1), scoring_rect.Max + ImVec2(1, 1), IM_COL32(255, 100, 0, 80)); // [DEBUG] Pre-bias
|
||||
if (g.NavMoveSubmitted)
|
||||
NavBiasScoringRect(scoring_rect, window->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer], g.NavMoveDir, g.NavMoveFlags);
|
||||
@@ -14852,14 +14868,14 @@ static float ImGui::NavUpdatePageUpPageDown()
|
||||
nav_scoring_rect_offset_y = -page_offset_y;
|
||||
g.NavMoveDir = ImGuiDir_Down; // Because our scoring rect is offset up, we request the down direction (so we can always land on the last item)
|
||||
g.NavMoveClipDir = ImGuiDir_Up;
|
||||
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet | ImGuiNavMoveFlags_IsPageMove;
|
||||
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_IsPageMove; // ImGuiNavMoveFlags_AlsoScoreVisibleSet may be added later
|
||||
}
|
||||
else if (IsKeyPressed(ImGuiKey_PageDown, true))
|
||||
{
|
||||
nav_scoring_rect_offset_y = +page_offset_y;
|
||||
g.NavMoveDir = ImGuiDir_Up; // Because our scoring rect is offset down, we request the up direction (so we can always land on the last item)
|
||||
g.NavMoveClipDir = ImGuiDir_Down;
|
||||
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet | ImGuiNavMoveFlags_IsPageMove;
|
||||
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_IsPageMove; // ImGuiNavMoveFlags_AlsoScoreVisibleSet may be added later
|
||||
}
|
||||
else if (home_pressed)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user