-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Cannot draw over horizontal padding area when child's border size is non zero #3312
Comments
Hello, Background: Whenever the child has a border by default we enable Initially this was designed to be tied to the The
Clipping: The default window clipping rectangle adds that spacing of WindowPadding.x*0.5f horizontally, and no clipping on the vertical axis. I made this choice in 1.0 because we tend to have a bias toward scrolling vertically, having no clipping-padding on the vertical axis tends to make it more noticeable that there's something to scroll to. If we remove it on the horizontal axis that's the effect we'll get everywhere: I think the current look is a little more pleasant and less crampy I agree it's a little arbitrary and I'm tempted to completely remove it, by turning
into
|
I see. Thank you for the explanation. It makes sense to clip the edges in the aspect of presentation - it certainly looks better! - but the solution seems kinda hacky and is a likely pitfall, especially since it depends on the presence of border. A good solution might be to entirely leave it up to the user whether or not they want to use the flag. Clipping could even be the default behavior removed by setting a flag. What do you think about that? |
Only indirectly. Clipping only depends on WindowPadding, and for child windows WindowPadding depends on BorderSize.
Which flag? |
That's what I do at the moment but then I follow it with |
I don't think you need to use SetCursorPos(), you can use |
Either way I managed to work around it, so I think we can close the issue if this is fine and expected. Unless you want to change it. :) |
Unrelated to main topic, but as a general tip, don't do that: #if defined(DRAW_BORDER)
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 1.0f);
#else
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f);
#endif When you can do: if (io.KeyCtrl)
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 1.0f);
else
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f); or static bool enable_border = true;
ImGui::CheckBox("enableborder", &enable_border);
if (enable_border)
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 1.0f);
else
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f); Both are more flexible than a compile-time flag, and make it easier to understand/debug a situation. |
As per #7540 see how we can change the inner cliprect boundaries:
Code (note the neat use of > // .. in Begin()
static ImGuiOnceUponAFrame oaf;
static int padding_mode = 0;
if (oaf)
{
ImGui::Begin("padding mode");
ImGui::RadioButton("0.0", &padding_mode, 0);
ImGui::RadioButton("0.5", &padding_mode, 1);
ImGui::RadioButton("1.0", &padding_mode, 2);
ImGui::End();
}
float window_padding_factor = padding_mode * 0.5f;
window->InnerClipRect.Min.x = ImTrunc(0.5f + window->InnerRect.Min.x + ImMax(ImTrunc(window->WindowPadding.x * window_padding_factor), window->WindowBorderSize));
window->InnerClipRect.Min.y = ImTrunc(0.5f + window->InnerRect.Min.y + top_border_size);
window->InnerClipRect.Max.x = ImTrunc(0.5f + window->InnerRect.Max.x - ImMax(ImTrunc(window->WindowPadding.x * window_padding_factor), window->WindowBorderSize));
window->InnerClipRect.Max.y = ImTrunc(0.5f + window->InnerRect.Max.y - window->WindowBorderSize);
window->InnerClipRect.ClipWithFull(host_rect); it's a little bit frustrating imho because none is perfect, but going for 0.0 seems like the wise and obvious simplification so I am likely going to go for it. |
If some people are reading this could you try with 0.0 and see if any of the difference it introduces feel problematic or detrimental to your app? |
I went and pushed this change, I think it's for the best 0b30947 |
A small nitpick: menu bar text now overflows over the border in the docking branch when the coordinates are negative (#6861). Replacing Line 7305 in 0b30947
|
This looks like an issue indeed but I don't quite comprehend how it could be linked to 0b30947, since afaik nothing in that path rely on |
Ah you're right, it is indeed unrelated. I didn't check/notice that menubars weren't using the window's inner clip rect to begin with... |
Pushed your fix f5d1852 |
Hi!
I noticed something weird related to padding and border size. I tried to find the reason in the sources but gave up after some time without success. Consider the code below.
Depending on whether border size is 0 or non 0, these are the effects I'm seeing.
Somehow when the border is non 0 whatever I draw in the child is not drawn on the left and right side - equal in size to the padding - while top and bottom are unaffected. This doesn't happen if there's no border around the child. It also doesn't seem like an overdraw with - in this case - solid color since when the background is left semi transparent there's no text visible on the sides too, so it's rather a clipping issue.
Is this a bug or am I missing something?
I'm using 1.76 from vcpkg on Windows with custom OpenGL 3 binding and SFML.
The text was updated successfully, but these errors were encountered: