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

Auto-sizing windows that start collapsed will not show window title #176

Closed
adamdmoss opened this issue Mar 22, 2015 · 12 comments
Closed

Auto-sizing windows that start collapsed will not show window title #176

adamdmoss opened this issue Mar 22, 2015 · 12 comments

Comments

@adamdmoss
Copy link
Contributor

Such windows show merely the header, the collapse-triangle, and a few pixels of padding (in which a few pixels of the actual window title might be visible if lucky :) ).

Expanding and re-collapsing such windows displays them how I'd expect, i.e. the header, the collapse-triangle, and the full window title.

@adamdmoss
Copy link
Contributor Author

(I can provide an example if unclear.)

@ocornut
Copy link
Owner

ocornut commented Mar 22, 2015

Repro.

        ImGui::SetNextWindowCollapsed(true, ImGuiSetCond_Once);
        ImGui::Begin("Long title", NULL, ImVec2(0,0), -1.0f, ImGuiWindowFlags_AlwaysAutoResize);
        ImGui::Text("Hello,\nWorld");
        ImGui::Button("test");
        ImGui::End();

Unfortunately once the size data is saved into the ini file when restored it starts with the previous width and auto-fit doesn't run when a window is collapsed (which is the reason for this issue).

And generally auto-fit does NOT take the title into account.

I'm not sure what is the desirable fix. What would you like to see? Would you like to see the collapsed window have the width of its content? That may be a bit tricky but possible and would be the correct fix (it would require not skipping items in order to measure the size output).
However I'm not sure it would be desirable to have the window content be processed every frame just to get the width of the title bar.

Otherwise we can have a better minimum size for collapsed window, if the problem is only the inability to double-click into it.

@adamdmoss
Copy link
Contributor Author

What I'd expect to see is the restored collapsed autofit window fitted to at least the size of its own title OR at least a fair portion of it.

I don't mind what the fix is, the situation I'd like to avoid is the one where I re-start the app and my collapsed windows are just a sea of anonymous arrows and I have to uncollapse and recollapse each one to find the one I'm looking for. I'd still like to be able to save the collapsed state of the windows, mind. :)

@ocornut
Copy link
Owner

ocornut commented Mar 22, 2015

I made collapsed window process the initial auto-fitting so you should know get a decently sized title bar.

Note that

  • The title bar text width is still ignored in the calculation (that likely could be added an as option).
  • They DON'T honor ImGuiWindowFlags_AlwaysAutoResize so if the content were to change size over time it won't update while the window is collapsed. It would be a waste of CPU. If somebody really wants this behavior we can add a flag later.

7e8f1f1

@adamdmoss
Copy link
Contributor Author

Thank you, that totally solves the sea-of-anonymous-arrows problem. :)

@adamdmoss
Copy link
Contributor Author

Just tried HEAD (2e26196) and sadly the original issue has returned.

@adamdmoss adamdmoss reopened this Mar 27, 2015
@adamdmoss
Copy link
Contributor Author

c9430bb is the commit that broke it.

ocornut added a commit that referenced this issue Mar 27, 2015
@ocornut
Copy link
Owner

ocornut commented Mar 27, 2015

Thanks! fixed. It was a slightly different bug here, reloading saved settings but not updating the size further. c9430bb was correct in many ways, new code is more explicit into enabling auto-resizing when creating a new window that has saved settings.
(This is getting a bit too complex - too many combination, need to consider some form of auto-testing in the future).

@ocornut ocornut closed this as completed Mar 27, 2015
@adamdmoss
Copy link
Contributor Author

Verified - thanks!

@ocornut
Copy link
Owner

ocornut commented Apr 2, 2015

I made a change there was actually another stupid bug and Begin() would always return true in some cases.

The only case it should return true for 1 frame when a window is collapsed:

  • the window doesn't have size information from the ,ini file or an explicit size parameter of SetNextWindowSize().
  • and the window was started collapsed

It sounds logic and fair, but I'm really wary of this because it create a really rare case that is likely to surprise some users. I'm sure they'll be edge cases and bugs. I'll leave it to see what happens and if I can learn some more about this.

@adamdmoss
Copy link
Contributor Author

That sounds logical. FYI b61b311 still works fine.

If the Begin()==true confuses someone, and I agree it's in a hard-to-intuit corner-case, then I think it can go away without hurting my use case at least - I don't programmatically start windows in a collapsed state, so on app startup they're always uncollapsed OR collapsed-but-with-a-.ini-size.

Someone who sets up a new auto-sized window with no explicit size and an initially collapsed state would probably figure out what's going on (and that they should set an explicit size) just by immediately eyeballing the results. Not sure that's less surprising than the magic 1-frame Begin()==true, but it probably is...

@ocornut
Copy link
Owner

ocornut commented May 2, 2015

FYI I reorganised the Begin() functions which was full of traps (subtle ordering dependencies). It should be better and healthier now but there is the possibility that I've created bugs or changes of behavior related to window size. Let me know if you notice anything unusual.

The changes are spread over many commits ending with this
d84b573
(spreading them should make it easier to bissect for bugs shall we need to)

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

2 participants