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

CollapsingHeader with clipped headers #1864

Closed
AlessioR opened this issue Jun 6, 2018 · 5 comments
Closed

CollapsingHeader with clipped headers #1864

AlessioR opened this issue Jun 6, 2018 · 5 comments
Labels
tree tree nodes

Comments

@AlessioR
Copy link

AlessioR commented Jun 6, 2018

Hello,

I'm using imgui 1.62 (WIP) under Win7 with dx9 backend.
I've created a CollapsingHeader with clipped headers adding to example following code:

const int count = 10000;
ImGuiListClipper clipper(count, ImGui::GetTextLineHeightWithSpacing());
while ( clipper.Step() ) {
	for ( int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++ ) {
		char buf[32];
		sprintf(buf, "Item no. %05d", i+1);
		if ( ImGui::CollapsingHeader(buf) ) {
			sprintf(buf, "Placeholder no. %05d", i+1);
			ImGui::Text(buf);
		}
	}
}
clipper.End();

the result is ok, but when I scroll to last row going out of the window with mouse button pressed, something awful happens:

clip

As you can see the headers keeps moving fast up and down !
It seems to occurs only at certain window size.

Then, I would to ask:

  • can CollapsingHeader autoscroll when a last row header is collapsed ?
  • there are some guidelines to "subclass" a widget ?

Thank you,
Alessio

ocornut added a commit that referenced this issue Jun 6, 2018
… include ImGuiTreeNodeFlags_NoTreePushOnOpen. The flag was already set by CollapsingHeader(). The only difference is if you were using TreeNodeEx() manually with ImGuiTreeNodeFlags_CollapsingHeader and without ImGuiTreeNodeFlags_NoTreePushOnOpen. In which case you can remove the ImGuiTreeNodeFlags_NoTreePushOnOpen flag from your call (ImGuiTreeNodeFlags_CollapsingHeader & ~ImGuiTreeNodeFlags_NoTreePushOnOpen). (#1864)
@ocornut
Copy link
Owner

ocornut commented Jun 6, 2018

Clipper issue

What you are doing is not correct use of the clipper. The element need to be evenly spaced. The if() + Text() statement breaks this assumption.

can CollapsingHeader autoscroll when a last row header is collapsed ?

Not at the moment. I would like to add that for TreeNode eventually. For CollapsingHeader it isn't trivially possible because there's no delimitation of what constitute the CollapsingHeader "contents" (there's no hierarchy and not explicit "closure").

(PS: I just pushed a small change that makes it possible to use a CollapsingHeader with a TreePush/TreePop. Which will come in handy if we want the scope to be used for auto-scrolling later)

there are some guidelines to "subclass" a widget ?

The question is too vaguely formulated. Please talk in more specific terms.

@ocornut
Copy link
Owner

ocornut commented Jun 6, 2018

A little more commentary on what you are trying to do.

In addition to the complication of solving clipping with uneven elements (which we should still aim to improve), in my experience when you are browsing a large number of nodes, "opening" them directly within the list is not the most practical setup. In this situation I would suggest clicking on a node to browse the content on the side (e.g. child window on the right of the list) or opening a popup to show the content (that's easier to setup if you don't need the data to stay open).

If you use this sort of pattern then you can clip the main list easily.

@AlessioR
Copy link
Author

AlessioR commented Jun 6, 2018

Thank you for fast answer!
I'd admit that I'm lost in translation (greetings from Italy!) and I've not fully understand what evely spaced means.
If means that each rows must have same height, so it is ok, but in my case rows are not collapsed!
If there are no other drawbacks, I'll keep in that way, no problem!

What I'm trying to achieve is a software for a friend to help him to tracks items he has in store.
I'm bored by win32 controls and I've already tried other framework like wxWidgets but it is no suits my need.
Nowadays we have high resolution monitor so we can display many data, so I think to use 3 child window for items, suppliers and orders ( There's a way to have 3 window side by side that resize we resize occurs ? )
I prefer to not use tabbed window because I can display all data he needs in a single window,
so I'll want to rewrite CollapseHeader to change some minimal stuff like dropdown icon but I do not want to modify imgu source so I can keep it updated.

Thank you again,
Alessio

@ocornut
Copy link
Owner

ocornut commented Jun 6, 2018

If means that each rows must have same height,

Yes this is what it means.
If you have a branch and varying size as with the if () Text() they won't have the same height anymore.

There's a way to have 3 window side by side that resize we resize occurs ?

See #319

I prefer to not use tabbed window because I can display all data he needs in a single window,
so I'll want to rewrite CollapseHeader to change some minimal stuff like dropdown icon

I don't understand, sorry.

Let me know if you have other questions or if we can close this later.

@AlessioR
Copy link
Author

AlessioR commented Jun 6, 2018

Thank you for your time,
no more questions for now!

Alessio

@AlessioR AlessioR closed this as completed Jun 6, 2018
@ocornut ocornut added the tree tree nodes label Jun 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tree tree nodes
Projects
None yet
Development

No branches or pull requests

2 participants