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

Drawing underneath scrollbars? #4636

Closed
parbo opened this issue Oct 7, 2021 · 4 comments
Closed

Drawing underneath scrollbars? #4636

parbo opened this issue Oct 7, 2021 · 4 comments

Comments

@parbo
Copy link

parbo commented Oct 7, 2021

Version/Branch of Dear ImGui:

Version: 1.84.1
Branch: docking

Back-end/Renderer/Compiler/OS
OpenGL/GLFW
Windows

My Issue/Question:

I would like to be able to draw underneath the scrollbar (e.g. to have an image or gradient as the background), and have the scrollbar be drawn (with alpha) on top. I tried drawing like that by pushing OuterRectClipped as the clip rect and then filling that with what I want as a background. But the scrollbar is drawn before my content, so it doesn't work.

Is this possible to achieve? Would it e.g. be possible to draw the decorations in ImGui::End instead of in ImGui::Begin?

Screenshots/Video

This is with drawing using InnerRect instead, which doesn't hide the scrollbar, but I get that slightly ugly looking scrollbar.

image

image

I'd like for the image/gradient to extend underneath the scrollbar.

@ocornut
Copy link
Owner

ocornut commented Oct 7, 2021

Is this possible to achieve? Would it e.g. be possible to draw the decorations in ImGui::End instead of in ImGui::Begin?

The problem is that would conflict with drawing over the scrollbar as in #3114

One possible hacky workaround would be specifying ImGuiWindowFlags_NoScrollbar and then before End(), fill in window->ScrollbarSizes[] and call ImGui::Scrollbar() yourself. One issue with that is some code rely on the value of bool ScrollbarX, ScrollbarY (there are 2 instances of checking for ScrollbarX == true in code).

@parbo
Copy link
Author

parbo commented Oct 7, 2021

Thanks, I can give that hack a try!

@parbo
Copy link
Author

parbo commented Oct 7, 2021

This seems to work for me. I ended up copy/pasting the calculations of whether there should be scrollbars to a function that I call right after Begin, and then right before End I draw the scrollbars like you said. I also had to push a bigger clip rect in order for the scrollbar to draw properly. I used ImGui::PushClipRect(window->OuterRectClipped.Min, window->OuterRectClipped.Max, false);

@parbo
Copy link
Author

parbo commented Oct 7, 2021

image

Scrollbars are looking very nice now. 😁

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