mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-20 01:34:20 +00:00
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_sdl3.cpp # imgui.cpp # imgui_widgets.cpp
This commit is contained in:
commit
0e485a2109
8 changed files with 348 additions and 180 deletions
65
imgui.cpp
65
imgui.cpp
|
|
@ -438,6 +438,9 @@ CODE
|
|||
- likewise io.MousePos and GetMousePos() will use OS coordinates.
|
||||
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
|
||||
|
||||
- 2024/07/15 (1.91.0) - renamed ImGuiSelectableFlags_DontClosePopups to ImGuiSelectableFlags_NoAutoClosePopups. (#1379, #1468, #2200, #4936, #5216, #7302, #7573)
|
||||
(internals: also renamed ImGuiItemFlags_SelectableDontClosePopup into ImGuiItemFlags_AutoClosePopups with inverted behaviors)
|
||||
- 2024/07/15 (1.91.0) - obsoleted PushButtonRepeat()/PopButtonRepeat() in favor of using new PushItemFlag(ImGuiItemFlags_ButtonRepeat, ...)/PopItemFlag().
|
||||
- 2024/07/02 (1.91.0) - commented out obsolete ImGuiModFlags (renamed to ImGuiKeyChord in 1.89). (#4921, #456)
|
||||
- commented out obsolete ImGuiModFlags_XXX values (renamed to ImGuiMod_XXX in 1.89). (#4921, #456)
|
||||
- ImGuiModFlags_Ctrl -> ImGuiMod_Ctrl, ImGuiModFlags_Shift -> ImGuiMod_Shift etc.
|
||||
|
|
@ -1104,7 +1107,7 @@ CODE
|
|||
#endif
|
||||
|
||||
// Debug options
|
||||
#define IMGUI_DEBUG_NAV_SCORING 0 // Display navigation scoring preview when hovering items. Display last moving direction matches when holding CTRL
|
||||
#define IMGUI_DEBUG_NAV_SCORING 0 // Display navigation scoring preview when hovering items. Hold CTRL to display for all candidates. CTRL+Arrow to change last direction.
|
||||
#define IMGUI_DEBUG_NAV_RECTS 0 // Display the reference navigation rectangle for each window
|
||||
|
||||
// When using CTRL+TAB (or Gamepad Square+L/R) we delay the visual a little in order to reduce visual noise doing a fast switch.
|
||||
|
|
@ -2969,15 +2972,6 @@ static void ImGuiListClipper_SeekCursorAndSetupPrevLine(float pos_y, float line_
|
|||
}
|
||||
}
|
||||
|
||||
static void ImGuiListClipper_SeekCursorForItem(ImGuiListClipper* clipper, int item_n)
|
||||
{
|
||||
// StartPosY starts from ItemsFrozen hence the subtraction
|
||||
// Perform the add and multiply with double to allow seeking through larger ranges
|
||||
ImGuiListClipperData* data = (ImGuiListClipperData*)clipper->TempData;
|
||||
float pos_y = (float)((double)clipper->StartPosY + data->LossynessOffset + (double)(item_n - data->ItemsFrozen) * clipper->ItemsHeight);
|
||||
ImGuiListClipper_SeekCursorAndSetupPrevLine(pos_y, clipper->ItemsHeight);
|
||||
}
|
||||
|
||||
ImGuiListClipper::ImGuiListClipper()
|
||||
{
|
||||
memset(this, 0, sizeof(*this));
|
||||
|
|
@ -3014,6 +3008,7 @@ void ImGuiListClipper::Begin(int items_count, float items_height)
|
|||
data->Reset(this);
|
||||
data->LossynessOffset = window->DC.CursorStartPosLossyness.y;
|
||||
TempData = data;
|
||||
StartSeekOffsetY = data->LossynessOffset;
|
||||
}
|
||||
|
||||
void ImGuiListClipper::End()
|
||||
|
|
@ -3024,7 +3019,7 @@ void ImGuiListClipper::End()
|
|||
ImGuiContext& g = *Ctx;
|
||||
IMGUI_DEBUG_LOG_CLIPPER("Clipper: End() in '%s'\n", g.CurrentWindow->Name);
|
||||
if (ItemsCount >= 0 && ItemsCount < INT_MAX && DisplayStart >= 0)
|
||||
ImGuiListClipper_SeekCursorForItem(this, ItemsCount);
|
||||
SeekCursorForItem(ItemsCount);
|
||||
|
||||
// Restore temporary buffer and fix back pointers which may be invalidated when nesting
|
||||
IM_ASSERT(data->ListClipper == this);
|
||||
|
|
@ -3048,6 +3043,17 @@ void ImGuiListClipper::IncludeItemsByIndex(int item_begin, int item_end)
|
|||
data->Ranges.push_back(ImGuiListClipperRange::FromIndices(item_begin, item_end));
|
||||
}
|
||||
|
||||
// This is already called while stepping.
|
||||
// The ONLY reason you may want to call this is if you passed INT_MAX to ImGuiListClipper::Begin() because you couldn't step item count beforehand.
|
||||
void ImGuiListClipper::SeekCursorForItem(int item_n)
|
||||
{
|
||||
// - Perform the add and multiply with double to allow seeking through larger ranges.
|
||||
// - StartPosY starts from ItemsFrozen, by adding SeekOffsetY we generally cancel that out (SeekOffsetY == LossynessOffset - ItemsFrozen * ItemsHeight).
|
||||
// - The reason we store SeekOffsetY instead of inferring it, is because we want to allow user to perform Seek after the last step, where ImGuiListClipperData is already done.
|
||||
float pos_y = (float)((double)StartPosY + StartSeekOffsetY + (double)item_n * ItemsHeight);
|
||||
ImGuiListClipper_SeekCursorAndSetupPrevLine(pos_y, ItemsHeight);
|
||||
}
|
||||
|
||||
static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
|
||||
{
|
||||
ImGuiContext& g = *clipper->Ctx;
|
||||
|
|
@ -3111,6 +3117,9 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
|
|||
const int already_submitted = clipper->DisplayEnd;
|
||||
if (calc_clipping)
|
||||
{
|
||||
// Record seek offset, this is so ImGuiListClipper::Seek() can be called after ImGuiListClipperData is done
|
||||
clipper->StartSeekOffsetY = (double)data->LossynessOffset - data->ItemsFrozen * (double)clipper->ItemsHeight;
|
||||
|
||||
if (g.LogEnabled)
|
||||
{
|
||||
// If logging is active, do not perform any clipping
|
||||
|
|
@ -3158,7 +3167,7 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
|
|||
clipper->DisplayStart = ImMax(data->Ranges[data->StepNo].Min, already_submitted);
|
||||
clipper->DisplayEnd = ImMin(data->Ranges[data->StepNo].Max, clipper->ItemsCount);
|
||||
if (clipper->DisplayStart > already_submitted) //-V1051
|
||||
ImGuiListClipper_SeekCursorForItem(clipper, clipper->DisplayStart);
|
||||
clipper->SeekCursorForItem(clipper->DisplayStart);
|
||||
data->StepNo++;
|
||||
if (clipper->DisplayStart == clipper->DisplayEnd && data->StepNo < data->Ranges.Size)
|
||||
continue;
|
||||
|
|
@ -3168,7 +3177,7 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
|
|||
// After the last step: Let the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd),
|
||||
// Advance the cursor to the end of the list and then returns 'false' to end the loop.
|
||||
if (clipper->ItemsCount < INT_MAX)
|
||||
ImGuiListClipper_SeekCursorForItem(clipper, clipper->ItemsCount);
|
||||
clipper->SeekCursorForItem(clipper->ItemsCount);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -5087,7 +5096,8 @@ void ImGui::NewFrame()
|
|||
g.CurrentWindowStack.resize(0);
|
||||
g.BeginPopupStack.resize(0);
|
||||
g.ItemFlagsStack.resize(0);
|
||||
g.ItemFlagsStack.push_back(ImGuiItemFlags_None);
|
||||
g.ItemFlagsStack.push_back(ImGuiItemFlags_AutoClosePopups); // Default flags
|
||||
g.CurrentItemFlags = g.ItemFlagsStack.back();
|
||||
g.GroupStack.resize(0);
|
||||
|
||||
// Docking
|
||||
|
|
@ -8193,26 +8203,6 @@ void ImGui::EndDisabledOverrideReenable()
|
|||
g.Style.Alpha = g.DisabledAlphaBackup * g.Style.DisabledAlpha;
|
||||
}
|
||||
|
||||
void ImGui::PushTabStop(bool tab_stop)
|
||||
{
|
||||
PushItemFlag(ImGuiItemFlags_NoTabStop, !tab_stop);
|
||||
}
|
||||
|
||||
void ImGui::PopTabStop()
|
||||
{
|
||||
PopItemFlag();
|
||||
}
|
||||
|
||||
void ImGui::PushButtonRepeat(bool repeat)
|
||||
{
|
||||
PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat);
|
||||
}
|
||||
|
||||
void ImGui::PopButtonRepeat()
|
||||
{
|
||||
PopItemFlag();
|
||||
}
|
||||
|
||||
void ImGui::PushTextWrapPos(float wrap_pos_x)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
|
|
@ -12419,6 +12409,9 @@ static bool ImGui::NavScoreItem(ImGuiNavItemData* result)
|
|||
if (dbx != 0.0f || dby != 0.0f)
|
||||
{
|
||||
// For non-overlapping boxes, use distance between boxes
|
||||
// FIXME-NAV: Quadrant may be incorrect because of (1) dbx bias and (2) curr.Max.y bias applied by NavBiasScoringRect() where typically curr.Max.y==curr.Min.y
|
||||
// One typical case where this happens, with style.WindowMenuButtonPosition == ImGuiDir_Right, pressing Left to navigate from Close to Collapse tends to fail.
|
||||
// Also see #6344. Calling ImGetDirQuadrantFromDelta() with unbiased values may be good but side-effects are plenty.
|
||||
dax = dbx;
|
||||
day = dby;
|
||||
dist_axial = dist_box;
|
||||
|
|
@ -14480,10 +14473,10 @@ void ImGui::LogButtons()
|
|||
#endif
|
||||
const bool log_to_file = Button("Log To File"); SameLine();
|
||||
const bool log_to_clipboard = Button("Log To Clipboard"); SameLine();
|
||||
PushTabStop(false);
|
||||
PushItemFlag(ImGuiItemFlags_NoTabStop, true);
|
||||
SetNextItemWidth(80.0f);
|
||||
SliderInt("Default Depth", &g.LogDepthToExpandDefault, 0, 9, NULL);
|
||||
PopTabStop();
|
||||
PopItemFlag();
|
||||
PopID();
|
||||
|
||||
// Start logging at the end of the function so that the buttons don't appear in the log
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue