mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-13 08:19:55 +02:00
ImRect: Added Translate() helper, removed redundant and misleading Reduce()
This commit is contained in:
@ -4416,7 +4416,7 @@ static ImVec2 FindBestPopupWindowPos(const ImVec2& base_pos, const ImVec2& size,
|
||||
// Clamp into visible area while not overlapping the cursor. Safety padding is optional if our popup size won't fit without it.
|
||||
ImVec2 safe_padding = style.DisplaySafeAreaPadding;
|
||||
ImRect r_outer(GetVisibleRect());
|
||||
r_outer.Reduce(ImVec2((size.x - r_outer.GetWidth() > safe_padding.x*2) ? safe_padding.x : 0.0f, (size.y - r_outer.GetHeight() > safe_padding.y*2) ? safe_padding.y : 0.0f));
|
||||
r_outer.Expand(ImVec2((size.x - r_outer.GetWidth() > safe_padding.x*2) ? -safe_padding.x : 0.0f, (size.y - r_outer.GetHeight() > safe_padding.y*2) ? -safe_padding.y : 0.0f));
|
||||
ImVec2 base_pos_clamped = ImClamp(base_pos, r_outer.Min, r_outer.Max - size);
|
||||
|
||||
for (int n = (*last_dir != -1) ? -1 : 0; n < 4; n++) // Last, Right, down, up, left. (Favor last used direction).
|
||||
@ -5234,7 +5234,7 @@ static void Scrollbar(ImGuiWindow* window, bool horizontal)
|
||||
else
|
||||
window_rounding_corners = (((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) ? 2 : 0) | (other_scrollbar ? 0 : 4);
|
||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_ScrollbarBg), window_rounding, window_rounding_corners);
|
||||
bb.Reduce(ImVec2(ImClamp((float)(int)((bb.Max.x - bb.Min.x - 2.0f) * 0.5f), 0.0f, 3.0f), ImClamp((float)(int)((bb.Max.y - bb.Min.y - 2.0f) * 0.5f), 0.0f, 3.0f)));
|
||||
bb.Expand(ImVec2(-ImClamp((float)(int)((bb.Max.x - bb.Min.x - 2.0f) * 0.5f), 0.0f, 3.0f), -ImClamp((float)(int)((bb.Max.y - bb.Min.y - 2.0f) * 0.5f), 0.0f, 3.0f)));
|
||||
|
||||
// V denote the main axis of the scrollbar
|
||||
float scrollbar_size_v = horizontal ? bb.GetWidth() : bb.GetHeight();
|
||||
@ -8104,7 +8104,7 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over
|
||||
// Render
|
||||
fraction = ImSaturate(fraction);
|
||||
RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||
bb.Reduce(ImVec2(window->BorderSize, window->BorderSize));
|
||||
bb.Expand(ImVec2(-window->BorderSize, -window->BorderSize));
|
||||
const ImVec2 fill_br = ImVec2(ImLerp(bb.Min.x, bb.Max.x, fraction), bb.Max.y);
|
||||
RenderFrame(bb.Min, fill_br, GetColorU32(ImGuiCol_PlotHistogram), false, style.FrameRounding);
|
||||
|
||||
|
Reference in New Issue
Block a user