Separator(): Altered end-points to use more standard boundaries. (#205, #4787, #1643, #759)

This commit is contained in:
ocornut 2023-10-03 15:26:35 +02:00
parent 330d763477
commit 28b237f94d
3 changed files with 22 additions and 15 deletions

View File

@ -73,6 +73,20 @@ Other changes:
- Nav: Tabbing always enable nav highlight when ImGuiConfigFlags_NavEnableKeyboard is set.
Previously was inconsistent and only enabled when stepping through a non-input item.
(#6802, #3092, #5759, #787)
- Separator(): Altered end-points to use more standard boundaries. (#205, #4787, #1643)
- Left position is always current cursor X position.
- Right position is always work-rect rightmost edge.
- Effectively means that:
- A separator in the root of a window will end up a little more distant from edges
than previously (essentially following WindowPadding instead of clipping edges).
- A separator inside a table cell end up a little distance from edges instead of
touching them (essentially following CellPadding instead of clipping edges).
- Matches tree indentation (was not the case before).
- Matches SeparatorText(). (#1643)
- Makes things correct inside groups without specific/hard-coded handling. (#205)
- Mostly legacy behavior when used inside old Columns(), as we favored that idiom back then,
only different is left position follows indentation level, to match calling a Separator()
inside or outside Columns().
- Tables: Fixed an edge-case when no columns are visible + table scrollbar is visible + user
code is always testing return value of TableSetColumnIndex() to coarse clip. With an active
clipper it would have asserted. Without a clipper, the scrollbar range would be wrong.

View File

@ -126,7 +126,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
- separator: expose flags (#759)
- separator: take indent into consideration (optional)
- separator: width, thickness, centering (#1643)
- separator: width, thickness, centering (#1643, #2657)
- splitter: formalize the splitter idiom into an official api (we want to handle n-way split) (#319)
- docking: merge docking branch (#2109)

View File

@ -1414,26 +1414,19 @@ void ImGui::SeparatorEx(ImGuiSeparatorFlags flags, float thickness)
else if (flags & ImGuiSeparatorFlags_Horizontal)
{
// Horizontal Separator
float x1 = window->Pos.x;
float x2 = window->Pos.x + window->Size.x;
// FIXME-WORKRECT: old hack (#205) until we decide of consistent behavior with WorkRect/Indent and Separator
if (g.GroupStack.Size > 0 && g.GroupStack.back().WindowID == window->ID)
x1 += window->DC.Indent.x;
// FIXME-WORKRECT: In theory we should simply be using WorkRect.Min.x/Max.x everywhere but it isn't aesthetically what we want,
// need to introduce a variant of WorkRect for that purpose. (#4787)
if (ImGuiTable* table = g.CurrentTable)
{
x1 = table->Columns[table->CurrentColumn].MinX;
x2 = table->Columns[table->CurrentColumn].MaxX;
}
float x1 = window->DC.CursorPos.x;
float x2 = window->WorkRect.Max.x;
// Preserve legacy behavior inside Columns()
// Before Tables API happened, we relied on Separator() to span all columns of a Columns() set.
// We currently don't need to provide the same feature for tables because tables naturally have border features.
ImGuiOldColumns* columns = (flags & ImGuiSeparatorFlags_SpanAllColumns) ? window->DC.CurrentColumns : NULL;
if (columns)
{
x1 = window->Pos.x + window->DC.Indent.x; // Used to be Pos.x before 2023/10/03
x2 = window->Pos.x + window->Size.x;
PushColumnsBackground();
}
// We don't provide our width to the layout so that it doesn't get feed back into AutoFit
// FIXME: This prevents ->CursorMaxPos based bounding box evaluation from working (e.g. TableEndCell)