Scrollbar tidying up variable names

docking
ocornut 10 years ago
parent d251204564
commit a579d6f521

@ -3042,19 +3042,20 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size, float bg
ButtonBehaviour(scrollbar_bb, scrollbar_id, &hovered, &held, true); ButtonBehaviour(scrollbar_bb, scrollbar_id, &hovered, &held, true);
if (held) if (held)
{ {
// Absolute seeking
g.HoveredId = scrollbar_id; g.HoveredId = scrollbar_id;
const float pos_y_norm = ImSaturate((g.IO.MousePos.y - (scrollbar_bb.Min.y + grab_size_y_pixels*0.5f)) / (scrollbar_height - grab_size_y_pixels)); const float clicked_y_norm = ImSaturate((g.IO.MousePos.y - (scrollbar_bb.Min.y + grab_size_y_pixels*0.5f)) / (scrollbar_height - grab_size_y_pixels));
window->ScrollY = (float)(int)(pos_y_norm * (window->SizeContents.y - window->Size.y)); window->ScrollY = (float)(int)(clicked_y_norm * (window->SizeContents.y - window->Size.y));
window->NextScrollY = window->ScrollY; window->NextScrollY = window->ScrollY;
} }
} }
// Normalized height of the grab // Render
const float pos_y_norm = ImSaturate(window->ScrollY / ImMax(0.0f, window->SizeContents.y - window->Size.y)); const float scroll_y_norm = ImSaturate(window->ScrollY / ImMax(0.0f, window->SizeContents.y - window->Size.y));
const ImU32 grab_col = window->Color(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab); const ImU32 grab_col = window->Color(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab);
window->DrawList->AddRectFilled( window->DrawList->AddRectFilled(
ImVec2(scrollbar_bb.Min.x, ImLerp(scrollbar_bb.Min.y, scrollbar_bb.Max.y - grab_size_y_pixels, pos_y_norm)), ImVec2(scrollbar_bb.Min.x, ImLerp(scrollbar_bb.Min.y, scrollbar_bb.Max.y - grab_size_y_pixels, scroll_y_norm)),
ImVec2(scrollbar_bb.Max.x, ImLerp(scrollbar_bb.Min.y, scrollbar_bb.Max.y - grab_size_y_pixels, pos_y_norm) + grab_size_y_pixels), grab_col); ImVec2(scrollbar_bb.Max.x, ImLerp(scrollbar_bb.Min.y, scrollbar_bb.Max.y - grab_size_y_pixels, scroll_y_norm) + grab_size_y_pixels), grab_col);
} }
// Render resize grip // Render resize grip

Loading…
Cancel
Save