mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
ImGuiListClipper: Renamed constructor parameters which created an ambiguous alternative to using the ImGuiListClipper::Begin() function, with misleading edge cases.
This commit is contained in:
parent
6469b94304
commit
01cc666039
@ -42,10 +42,14 @@ Breaking Changes:
|
|||||||
It was also getting in the way of better font scaling, so let's get rid of it now!
|
It was also getting in the way of better font scaling, so let's get rid of it now!
|
||||||
If you used DisplayOffset it was probably in association to rasterizing a font at a specific size,
|
If you used DisplayOffset it was probably in association to rasterizing a font at a specific size,
|
||||||
in which case the corresponding offset may be reported into GlyphOffset. (#1619)
|
in which case the corresponding offset may be reported into GlyphOffset. (#1619)
|
||||||
|
- ImGuiListClipper: Renamed constructor parameters which created an ambiguous alternative to using
|
||||||
|
the ImGuiListClipper::Begin() function, with misleading edge cases. Always use ImGuiListClipper::Begin()!
|
||||||
|
Kept inline redirection function (will obsolete).
|
||||||
|
(note: imgui_memory_editor <0.40 from imgui_club/ used this old clipper API. Update your copy if needed).
|
||||||
- Style: Renamed style.TabMinWidthForUnselectedCloseButton to style.TabMinWidthForCloseButton.
|
- Style: Renamed style.TabMinWidthForUnselectedCloseButton to style.TabMinWidthForCloseButton.
|
||||||
- Renamed ImGuiSliderFlags_ClampOnInput to ImGuiSliderFlags_AlwaysClamp. Kept redirection enum (will obsolete).
|
- Renamed ImGuiSliderFlags_ClampOnInput to ImGuiSliderFlags_AlwaysClamp. Kept redirection enum (will obsolete).
|
||||||
- Renamed OpenPopupContextItem() back to OpenPopupOnItemClick(), REVERTED CHANGE FROM 1.77.
|
- Renamed OpenPopupContextItem() back to OpenPopupOnItemClick(), REVERTED CHANGE FROM 1.77.
|
||||||
For variety of reason this is more self-explanatory.
|
For variety of reason this is more self-explanatory. Kept inline redirection function.
|
||||||
- Removed return value from OpenPopupOnItemClick() - returned true on mouse release on item - because it
|
- Removed return value from OpenPopupOnItemClick() - returned true on mouse release on item - because it
|
||||||
is inconsistent with other popups API and makes others misleading. It's also and unnecessary: you can
|
is inconsistent with other popups API and makes others misleading. It's also and unnecessary: you can
|
||||||
use IsWindowAppearing() after BeginPopup() for a similar result.
|
use IsWindowAppearing() after BeginPopup() for a similar result.
|
||||||
|
@ -372,6 +372,7 @@ CODE
|
|||||||
When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
|
When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
|
||||||
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||||
|
|
||||||
|
- 2020/10/05 (1.79) - removed ImGuiListClipper: Renamed constructor parameters which created an ambiguous alternative to using the ImGuiListClipper::Begin() function, with misleading edge cases (note: imgui_memory_editor <0.40 from imgui_club/ used this old clipper API. Update your copy if needed).
|
||||||
- 2020/09/25 (1.79) - renamed ImGuiSliderFlags_ClampOnInput to ImGuiSliderFlags_AlwaysClamp. Kept redirection enum (will obsolete sooner because previous name was added recently).
|
- 2020/09/25 (1.79) - renamed ImGuiSliderFlags_ClampOnInput to ImGuiSliderFlags_AlwaysClamp. Kept redirection enum (will obsolete sooner because previous name was added recently).
|
||||||
- 2020/09/25 (1.79) - renamed style.TabMinWidthForUnselectedCloseButton to style.TabMinWidthForCloseButton.
|
- 2020/09/25 (1.79) - renamed style.TabMinWidthForUnselectedCloseButton to style.TabMinWidthForCloseButton.
|
||||||
- 2020/09/21 (1.79) - renamed OpenPopupContextItem() back to OpenPopupOnItemClick(), reverting the change from 1.77. For varieties of reason this is more self-explanatory.
|
- 2020/09/21 (1.79) - renamed OpenPopupContextItem() back to OpenPopupOnItemClick(), reverting the change from 1.77. For varieties of reason this is more self-explanatory.
|
||||||
@ -2192,13 +2193,10 @@ static void SetCursorPosYAndSetupForPrevLine(float pos_y, float line_height)
|
|||||||
columns->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly
|
columns->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiListClipper::ImGuiListClipper(int items_count, float items_height)
|
ImGuiListClipper::ImGuiListClipper()
|
||||||
{
|
{
|
||||||
DisplayStart = DisplayEnd = 0;
|
memset(this, 0, sizeof(*this));
|
||||||
ItemsCount = -1;
|
ItemsCount = -1;
|
||||||
StepNo = 0;
|
|
||||||
ItemsHeight = StartPosY = 0.0f;
|
|
||||||
Begin(items_count, items_height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiListClipper::~ImGuiListClipper()
|
ImGuiListClipper::~ImGuiListClipper()
|
||||||
|
39
imgui.h
39
imgui.h
@ -1886,38 +1886,45 @@ struct ImGuiStorage
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Helper: Manually clip large list of items.
|
// Helper: Manually clip large list of items.
|
||||||
// If you are submitting lots of evenly spaced items and you have a random access to the list, you can perform coarse clipping based on visibility to save yourself from processing those items at all.
|
// If you are submitting lots of evenly spaced items and you have a random access to the list, you can perform coarse
|
||||||
|
// clipping based on visibility to save yourself from processing those items at all.
|
||||||
// The clipper calculates the range of visible items and advance the cursor to compensate for the non-visible items we have skipped.
|
// The clipper calculates the range of visible items and advance the cursor to compensate for the non-visible items we have skipped.
|
||||||
// ImGui already clip items based on their bounds but it needs to measure text size to do so. Coarse clipping before submission makes this cost and your own data fetching/submission cost null.
|
// (Dear ImGui already clip items based on their bounds but it needs to measure text size to do so, whereas manual coarse clipping before submission makes this cost and your own data fetching/submission cost almost null)
|
||||||
// Usage:
|
// Usage:
|
||||||
// ImGuiListClipper clipper(1000); // we have 1000 elements, evenly spaced.
|
// ImGuiListClipper clipper;
|
||||||
// while (clipper.Step())
|
// clipper.Begin(1000); // We have 1000 elements, evenly spaced.
|
||||||
// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
// while (clipper.Step())
|
||||||
// ImGui::Text("line number %d", i);
|
// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
||||||
// - Step 0: the clipper let you process the first element, regardless of it being visible or not, so we can measure the element height (step skipped if we passed a known height as second arg to constructor).
|
// ImGui::Text("line number %d", i);
|
||||||
// - Step 1: the clipper infer height from first element, calculate the actual range of elements to display, and position the cursor before the first element.
|
// Generally what happens is:
|
||||||
// - (Step 2: empty step only required if an explicit items_height was passed to constructor or Begin() and user call Step(). Does nothing and switch to Step 3.)
|
// - Clipper lets you process the first element (DisplayStart = 0, DisplayEnd = 1) regardless of it being visible or not.
|
||||||
// - Step 3: 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.
|
// - User code submit one element.
|
||||||
|
// - Clipper can measure the height of the first element
|
||||||
|
// - Clipper calculate the actual range of elements to display based on the current clipping rectangle, position the cursor before the first visible element.
|
||||||
|
// - User code submit visible elements.
|
||||||
struct ImGuiListClipper
|
struct ImGuiListClipper
|
||||||
{
|
{
|
||||||
int DisplayStart;
|
int DisplayStart;
|
||||||
int DisplayEnd;
|
int DisplayEnd;
|
||||||
int ItemsCount;
|
|
||||||
|
|
||||||
// [Internal]
|
// [Internal]
|
||||||
|
int ItemsCount;
|
||||||
int StepNo;
|
int StepNo;
|
||||||
float ItemsHeight;
|
float ItemsHeight;
|
||||||
float StartPosY;
|
float StartPosY;
|
||||||
|
|
||||||
// items_count: Use -1 to ignore (you can call Begin later). Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step).
|
IMGUI_API ImGuiListClipper();
|
||||||
// items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing().
|
IMGUI_API ~ImGuiListClipper();
|
||||||
// If you don't specify an items_height, you NEED to call Step(). If you specify items_height you may call the old Begin()/End() api directly, but prefer calling Step().
|
|
||||||
ImGuiListClipper(int items_count = -1, float items_height = -1.0f);
|
|
||||||
~ImGuiListClipper();
|
|
||||||
|
|
||||||
|
// items_count: Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step)
|
||||||
|
// items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing().
|
||||||
IMGUI_API void Begin(int items_count, float items_height = -1.0f); // Automatically called by constructor if you passed 'items_count' or by Step() in Step 1.
|
IMGUI_API void Begin(int items_count, float items_height = -1.0f); // Automatically called by constructor if you passed 'items_count' or by Step() in Step 1.
|
||||||
IMGUI_API void End(); // Automatically called on the last call of Step() that returns false.
|
IMGUI_API void End(); // Automatically called on the last call of Step() that returns false.
|
||||||
IMGUI_API bool Step(); // Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items.
|
IMGUI_API bool Step(); // Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items.
|
||||||
|
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
inline ImGuiListClipper(int items_count, float items_height = -1.0f) { memset(this, 0, sizeof(*this)); ItemsCount = -1; Begin(items_count, items_height); } // [removed in 1.79]
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helpers macros to generate 32-bit encoded colors
|
// Helpers macros to generate 32-bit encoded colors
|
||||||
|
Loading…
Reference in New Issue
Block a user