ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
59.67k stars 10.16k forks source link

SameLine doesn't seem to work across multiple columns #508

Closed YukinoHayakawa closed 8 years ago

YukinoHayakawa commented 8 years ago

As a layout like #324 has, it would be more comfortable to look at it if the text of tree node labels align with that in the first widget on the right side. However when I try to achieve that I found that neither call SameLine before nor after NextColumn would work.

ImGui::Columns(2);
ImGui::Text("ABCD");
ImGui::SameLine();
ImGui::NextColumn();
ImGui::Button("Push");
ImGui::Columns(1);

Or

ImGui::Columns(2);
ImGui::Text("ABCD");
ImGui::NextColumn();
ImGui::SameLine();
ImGui::Button("Push");
ImGui::Columns(1);

(In the second case the button is nearly invisible)

ocornut commented 8 years ago

I don't understand what you could even mean or what you are trying to achieve. both SameLine() and NextColumns() are setting the cursor position so it feels contradictory to use them together.

YukinoHayakawa commented 8 years ago

Sorry it might due to my awful use of English...so embarassing Maybe using a picture from #324 to explain would be more clear. image I mean that are there any way to make text of two widgets in different columns in the same line. For example a TreeNode in column 0 and a LabelText in column 1. Thank you very much.

YukinoHayakawa commented 8 years ago

Or just add paddings to / set heights of tree node labels?

ocornut commented 8 years ago

They are already aligned in that picture.. so I'm not sure what you are asking. If you check the Property Editor demo code you will see it is using AlignFirstTextHeightToWidgets as a helper to vertically align a small line of text (normal text or tree node) to a large line of items (widgets).

YukinoHayakawa commented 8 years ago

No I moved them down by 4 pixels....Ok I'll check it out. Thank you.

YukinoHayakawa commented 8 years ago

It works like a charm.

ocornut commented 8 years ago

Cool ! Please have a closer look at the running demo and the demo code when possible, it has answer to a lot of questions :)

YukinoHayakawa commented 8 years ago

I tried but without precious clues from developer it appears to be somewhat difficult...

ocornut commented 8 years ago

No worry. I'll keep improving the demo/docs. Also look at the comment in imgui.h/imgui.cpp when possible. I just want to make sure you are doing your share of homework and research before asking, because all the time I take to answer user questions I'm not putting it into improving the library and time has been limited lately.

YukinoHayakawa commented 8 years ago

Of course :)

YukinoHayakawa commented 8 years ago

I finally found this kind of layout demonstrated in ShowExampleAppPropertyEditor in the demo....