Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

having indent only in first column #414

Closed
damqui opened this issue Nov 26, 2015 · 6 comments
Closed

having indent only in first column #414

damqui opened this issue Nov 26, 2015 · 6 comments

Comments

@damqui
Copy link

damqui commented Nov 26, 2015

hi,

I'm trying to implement a "property view" (like http://www.openrtm.org/openrtm/sites/default/files/697/fig473TypePropertyView_en.png).
With this naive code :

ImGui::Begin("PropView");
ImGui::Columns(2);
ImGui::Text("name1");
ImGui::NextColumn();
ImGui::Text("value1");
ImGui::NextColumn();
bool Tree = ImGui::TreeNode("tree1");
ImGui::NextColumn();
ImGui::NextColumn();
if (Tree) {
    ImGui::Text("name2");
    ImGui::NextColumn();
    ImGui::Text("value2");
    ImGui::NextColumn();
    ImGui::TreePop();
}
ImGui::End();

i got this result :
imgui_column_indent

How to remove the indent in the second column ?
(didn't find any nice way of doing it)

thanks !

@ocornut
Copy link
Owner

ocornut commented Nov 26, 2015

I'll have to think about the best fix, but it probably involve the confusedly named ColumnsStartX (should be renamed to IndentX?) in the context be a per-column thing.

For now a possible workaround would be, after calling NextColumn() on the right column to to do:

#include <imgui_internal.h>
ImGuiWindow* window = GetCurrentWindow();
window->DC.CursorPos.x -= window->window->DC.ColumnsStartX;

@damqui
Copy link
Author

damqui commented Nov 26, 2015

ok.
tried the workaround, but it unindents too much.
btw, the indent is okay while dragging the column separator.

@Flix01
Copy link

Flix01 commented Nov 26, 2015

Maybe something like:

ImGui::Columns(2);
ImGui::Text("name1");
ImGui::NextColumn();
ImGui::Text("value1");
ImGui::NextColumn();
bool Tree = false;
if ((Tree=ImGui::TreeNode("tree1"))) ImGui::TreePop();
ImGui::NextColumn();
ImGui::NextColumn();
if (Tree) {
    ImGui::Text("\tname2"); // indent
    ImGui::NextColumn();
    ImGui::Text("value2");
    ImGui::NextColumn();
}
ImGui::End();

@ocornut
Copy link
Owner

ocornut commented Nov 26, 2015

Try

#include <imgui_internal.h>
ImGuiWindow* window = GetCurrentWindow();
window->DC.CursorPos.x -= window->window->DC.ColumnsStartX + window->WindowPadding.x;

(not tested. obviously this is just workaround)

@ocornut
Copy link
Owner

ocornut commented Nov 28, 2015

I've fixed the bug and added an example on a way to do a property editor using the columns api.

property_editor

There are a few subtle/minor issues with tree node rendering that I'm working on (related to #324, #282), but nothing really problematic.

ocornut added a commit that referenced this issue Nov 29, 2015
@ocornut ocornut closed this as completed Nov 29, 2015
@damqui
Copy link
Author

damqui commented Nov 30, 2015

Cool ! thanks !

ocornut added a commit that referenced this issue Dec 13, 2015
…ly for widget sized line height). (followup to #414, #282)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants