Browse Source

Internals: window->InnerRect includes removal of borders so it'll be easier to use from other locations.

pull/1414/merge
omar 7 years ago
parent
commit
a9b01600ac
  1. 16
      imgui.cpp

16
imgui.cpp

@ -4874,10 +4874,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// Inner rectangle
// We set this up after processing the resize grip so that our clip rectangle doesn't lag by a frame
// Note that if our window is collapsed we will end up with a null clipping rectangle which is the correct behavior.
window->InnerRect.Min.x = title_bar_rect.Min.x;
window->InnerRect.Min.y = title_bar_rect.Max.y + window->MenuBarHeight();
window->InnerRect.Max.x = window->Pos.x + window->Size.x - window->ScrollbarSizes.x;
window->InnerRect.Max.y = window->Pos.y + window->Size.y - window->ScrollbarSizes.y;
window->InnerRect.Min.x = title_bar_rect.Min.x + window->WindowBorderSize;
window->InnerRect.Min.y = title_bar_rect.Max.y + window->MenuBarHeight() + (((flags & ImGuiWindowFlags_MenuBar) || !(flags & ImGuiWindowFlags_NoTitleBar)) ? style.FrameBorderSize : window->WindowBorderSize);
window->InnerRect.Max.x = window->Pos.x + window->Size.x - window->ScrollbarSizes.x - window->WindowBorderSize;
window->InnerRect.Max.y = window->Pos.y + window->Size.y - window->ScrollbarSizes.y - window->WindowBorderSize;
//window->DrawList->AddRect(window->InnerRect.Min, window->InnerRect.Max, IM_COL32_WHITE);
// After Begin() we fill the last item / hovered data using the title bar data. Make that a standard behavior (to allow usage of context menus on title bar only, etc.).
@ -4890,10 +4890,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// Force round operator last to ensure that e.g. (int)(max.x-min.x) in user's render code produce correct result.
const float border_size = window->WindowBorderSize;
ImRect clip_rect;
clip_rect.Min.x = ImFloor(0.5f + window->InnerRect.Min.x + ImMax(border_size, ImFloor(window->WindowPadding.x*0.5f)));
clip_rect.Min.y = ImFloor(0.5f + window->InnerRect.Min.y + border_size);
clip_rect.Max.x = ImFloor(0.5f + window->InnerRect.Max.x - ImMax(border_size, ImFloor(window->WindowPadding.x*0.5f)));
clip_rect.Max.y = ImFloor(0.5f + window->InnerRect.Max.y - border_size);
clip_rect.Min.x = ImFloor(0.5f + window->InnerRect.Min.x + ImMax(0.0f, ImFloor(window->WindowPadding.x*0.5f - border_size)));
clip_rect.Min.y = ImFloor(0.5f + window->InnerRect.Min.y);
clip_rect.Max.x = ImFloor(0.5f + window->InnerRect.Max.x - ImMax(0.0f, ImFloor(window->WindowPadding.x*0.5f - border_size)));
clip_rect.Max.y = ImFloor(0.5f + window->InnerRect.Max.y);
PushClipRect(clip_rect.Min, clip_rect.Max, true);
// Clear 'accessed' flag last thing (After PushClipRect which will set the flag. We want the flag to stay false when the default "Debug" window is unused)

Loading…
Cancel
Save