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

Bug with AddRectFilled/WindowDrawList? #811

Closed
edin-purkovic opened this issue Aug 30, 2016 · 7 comments
Closed

Bug with AddRectFilled/WindowDrawList? #811

edin-purkovic opened this issue Aug 30, 2016 · 7 comments

Comments

@edin-purkovic
Copy link

edin-purkovic commented Aug 30, 2016

Hi Omar, thanks for this awesome gui lib.. started using it few days ago for writing my 3D editor so its maybe my lack of knowledge and done by design or possible bug?

im rendering 2 imgui windows, one for titlebar and one for workspace so it draws only one part of the red square using:
ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(), ImVec2(100,110), ImGui::ColorConvertFloat4ToU32(ImVec4(1, .15, .15, 1)));

and thats fine but there is an offset in x as you can see in the picture and its always half of ImGuiStyleVar_WindowPadding..
if its by design is there a way to draw the rect from 0,0?
I used 24,0 just for debuging for ImGuiStyleVar_WindowPadding and the child is drawn at 24 but the AddRectFilled at 12..

Another question is how to force GetWindowDrawList to draw on top of everything? it draws on top of buttons but behind child windows as in the pic even if the AddRectFilled is called after everything else..

13892348_949422815167907_7483109795979410214_n

@ocornut
Copy link
Owner

ocornut commented Aug 30, 2016

By default the window pushes a clipping rectangle (ImGui::PushClipRect / ImDrawList::PushClipRect) with that amount of padding. The half WindowPadding match the amount that e.g. CollapsingHeader uses to extend itself slightly

If you want to draw fullscreen or go off the current clipping rectangle you can call ImGui::PushClipRect() setting the third parameter as false.

Another question is how to force GetWindowDrawList to draw on top of everything?

Drawing commands are processed in order within a window (there's a channel split api for out of order rendering but it isn't what you want there), and then child window are drawn after their parent. There's no explicit finer control of z-ordering yet, but if you have child windows and you want your rectangle to draw over them, a workaround is to create a final child window, push a fullscreen clip rectangle and draw there. There's an OverlayDrawList in imgui_internal.h (not exposed yet) which is basically just a ImDrawList that drawn last. Or you can either create your own ImDrawList.

You can inspect the draw order in the metrics window (call ShowMetricsWindow()).

@edin-purkovic
Copy link
Author

Thank you! That worked!
Im gonna close this now, and before that a pic of my current progress :) working on docking, imgui makes it quite easy and looking beautiful...

13892348_949422815167907_7483109795979410214_n
..

@ocornut
Copy link
Owner

ocornut commented Aug 30, 2016

Nice! Please don't hesitate to post shots in #772
There's some docking code in #351 which I never had the time to look at myself, but the intent would be to make docking an official feature/extension at some point.

@edin-purkovic
Copy link
Author

Will do today, after i update it a little.. as for docking ImWindow looks nice but too complex and lumix does look nice too but doesnt allow docking out of platform window like imWindow does, does have one frame lag to compute dock sizes i guess which i dont like xD and they both lack more control about initial positioning and sizing.. so i wrote my docking, currently around 500loc and when finished around 600 combined for header+source file and have a lot more of control over layout

@nem0
Copy link
Contributor

nem0 commented Aug 30, 2016

is your docking code available?

@ocornut
Copy link
Owner

ocornut commented Aug 30, 2016

Please move this to the other thread as well, so people can find it :)

@edin-purkovic
Copy link
Author

@nem0 not yet, its not ready, after i finish it i will release it on my github and link it in #351 , used simple buttons for prototyping for tabbar so have to rewrite that and have to figure how to dock from one platform window to another, then clean the code a little.. but it wont be too hard i guess/hope, also to mention it does not follow imgui style, docks are not resubmited every frame for example and i use std::function but that could be easily changed to function pointers.. now.. moving to the other thread :)

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