First separator not appearing in child region #860

Closed
opened 2016-10-04 19:35:51 +00:00 by ggtucker · 1 comment
ggtucker commented 2016-10-04 19:35:51 +00:00 (Migrated from github.com)

The first Separator after a BeginChild appears to be behaving incorrectly.

Here's the complete code sample without the separator call:

ImGui::Begin("WindowName");
ImGui::BeginChild("OuterRegion", ImVec2(0, -ImGui::GetItemsLineHeightWithSpacing()), false);
ImGui::Columns(2);
for (int i = 0; i < 40; ++i) {
    ImGui::Text("Entry %i", i);
    ImGui::NextColumn();
    ImGui::Text("Value %i", i);
    ImGui::NextColumn();
}
ImGui::Columns();
ImGui::BeginChild("InnerRegion", ImVec2(0, 150), false);

// -------------------------------
ImGui::Columns(2);
// -------------------------------

ImGui::Text("EntryHeader");
ImGui::NextColumn();
ImGui::Text("ValueHeader");
ImGui::NextColumn();
ImGui::Separator();
for (int i = 0; i < 3; ++i) {
    ImGui::Text("InnerEntry %i", i);
    ImGui::NextColumn();
    ImGui::Text("InnerValue %i", i);
    ImGui::NextColumn();
}
ImGui::Columns();
ImGui::EndChild();
ImGui::Columns(2);
ImGui::Separator();
for (int i = 40; i < 80; ++i) {
    ImGui::Text("Entry %i", i);
    ImGui::NextColumn();
    ImGui::Text("Value %i", i);
    ImGui::NextColumn();
}
ImGui::Columns();
ImGui::EndChild();
ImGui::End();

and the corresponding result, which appears correct:

Below I've enumerated the results of doing separator calls before and after the call to ImGui::Columns(2);

// -------------------------------
ImGui::Separator();
ImGui::Columns(2);
// -------------------------------


The separator does not appear at all, and there is a vertical gap that appears between the parent and child column dividers.

// -------------------------------
ImGui::Columns(2);
ImGui::Separator();
// -------------------------------


The separator does not appear at all, and the column headers are misaligned (but there is no vertical gap between parent and child column dividers).

// -------------------------------
ImGui::Separator();
ImGui::Columns(2);
ImGui::Separator();
// -------------------------------


This is the behavior I'm looking for, so for now this is my workaround. The first separator does not appear, but it does some magic to allow for the second separator to work correctly.

The first Separator after a BeginChild appears to be behaving incorrectly. Here's the complete code sample without the separator call: ``` ImGui::Begin("WindowName"); ImGui::BeginChild("OuterRegion", ImVec2(0, -ImGui::GetItemsLineHeightWithSpacing()), false); ImGui::Columns(2); for (int i = 0; i < 40; ++i) { ImGui::Text("Entry %i", i); ImGui::NextColumn(); ImGui::Text("Value %i", i); ImGui::NextColumn(); } ImGui::Columns(); ImGui::BeginChild("InnerRegion", ImVec2(0, 150), false); // ------------------------------- ImGui::Columns(2); // ------------------------------- ImGui::Text("EntryHeader"); ImGui::NextColumn(); ImGui::Text("ValueHeader"); ImGui::NextColumn(); ImGui::Separator(); for (int i = 0; i < 3; ++i) { ImGui::Text("InnerEntry %i", i); ImGui::NextColumn(); ImGui::Text("InnerValue %i", i); ImGui::NextColumn(); } ImGui::Columns(); ImGui::EndChild(); ImGui::Columns(2); ImGui::Separator(); for (int i = 40; i < 80; ++i) { ImGui::Text("Entry %i", i); ImGui::NextColumn(); ImGui::Text("Value %i", i); ImGui::NextColumn(); } ImGui::Columns(); ImGui::EndChild(); ImGui::End(); ``` and the corresponding result, which appears correct: ![](http://i.imgur.com/byOuLgC.png) Below I've enumerated the results of doing separator calls before and after the call to `ImGui::Columns(2);` ``` // ------------------------------- ImGui::Separator(); ImGui::Columns(2); // ------------------------------- ``` ![](http://i.imgur.com/vbBbup3.png) **The separator does not appear at all, and there is a vertical gap that appears between the parent and child column dividers.** ``` // ------------------------------- ImGui::Columns(2); ImGui::Separator(); // ------------------------------- ``` ![](http://i.imgur.com/Kn6AVth.png) **The separator does not appear at all, and the column headers are misaligned (but there is no vertical gap between parent and child column dividers).** ``` // ------------------------------- ImGui::Separator(); ImGui::Columns(2); ImGui::Separator(); // ------------------------------- ``` ![](http://i.imgur.com/WD38RJL.png) **This is the behavior I'm looking for, so for now this is my workaround. The first separator does not appear, but it does some magic to allow for the second separator to work correctly.**
ocornut commented 2016-10-10 20:42:59 +00:00 (Migrated from github.com)

Thank you Geoffrey.
The bug was that Separator() was submitting a bounding box with zero-height. Right after entering a child window with zero-padding the cursor would sit exactly on the edge of the clipping rectangle so with a zero-height it would get clipped by IsClippedEx() called from ItemAdd(). I made Separator() pass in the correct 1-pixel height and it doesn't get clipped anymore.

Here's a simplified repro for reference:

ImGui::Begin("Bug #860");
ImGui::BeginChild("InnerRegion", ImVec2(0, 150), false);
ImGui::Columns(2);
ImGui::Separator();
ImGui::Text("Under Columns(2)");
ImGui::Columns(1);
ImGui::Separator();
ImGui::EndChild();
ImGui::End();

capture

I really feel for us with this usage of columns. They are very impractical at the moment. I hope to dedicate serious time to columns when I have it.

Thank you Geoffrey. The bug was that Separator() was submitting a bounding box with zero-height. Right after entering a child window with zero-padding the cursor would sit exactly on the edge of the clipping rectangle so with a zero-height it would get clipped by `IsClippedEx()` called from `ItemAdd()`. I made Separator() pass in the correct 1-pixel height and it doesn't get clipped anymore. Here's a simplified repro for reference: ``` ImGui::Begin("Bug #860"); ImGui::BeginChild("InnerRegion", ImVec2(0, 150), false); ImGui::Columns(2); ImGui::Separator(); ImGui::Text("Under Columns(2)"); ImGui::Columns(1); ImGui::Separator(); ImGui::EndChild(); ImGui::End(); ``` ![capture](https://cloud.githubusercontent.com/assets/8225057/19250497/d2829e6e-8f3a-11e6-9faf-33560231e21d.PNG) I really feel for us with this usage of columns. They are very impractical at the moment. I hope to dedicate serious time to columns when I have it.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#860
No description provided.