| 7671 | } |
| 7672 | |
| 7673 | static void BoxSelectScrollWithMouseDrag(ImGuiBoxSelectState* bs, ImGuiWindow* window, const ImRect& inner_r) |
| 7674 | { |
| 7675 | ImGuiContext& g = *GImGui; |
| 7676 | IM_ASSERT(bs->Window == window); |
| 7677 | for (int n = 0; n < 2; n++) // each axis |
| 7678 | { |
| 7679 | const float mouse_pos = g.IO.MousePos[n]; |
| 7680 | const float dist = (mouse_pos > inner_r.Max[n]) ? mouse_pos - inner_r.Max[n] : (mouse_pos < inner_r.Min[n]) ? mouse_pos - inner_r.Min[n] : 0.0f; |
| 7681 | const float scroll_curr = window->Scroll[n]; |
| 7682 | if (dist == 0.0f || (dist < 0.0f && scroll_curr < 0.0f) || (dist > 0.0f && scroll_curr >= window->ScrollMax[n])) |
| 7683 | continue; |
| 7684 | |
| 7685 | const float speed_multiplier = ImLinearRemapClamp(g.FontSize, g.FontSize * 5.0f, 1.0f, 4.0f, ImAbs(dist)); // x1 to x4 depending on distance |
| 7686 | const float scroll_step = g.FontSize * 35.0f * speed_multiplier * ImSign(dist) * g.IO.DeltaTime; |
| 7687 | bs->ScrollAccum[n] += scroll_step; |
| 7688 | |
| 7689 | // Accumulate into a stored value so we can handle high-framerate |
| 7690 | const float scroll_step_i = ImFloor(bs->ScrollAccum[n]); |
| 7691 | if (scroll_step_i == 0.0f) |
| 7692 | continue; |
| 7693 | if (n == 0) |
| 7694 | ImGui::SetScrollX(window, scroll_curr + scroll_step_i); |
| 7695 | else |
| 7696 | ImGui::SetScrollY(window, scroll_curr + scroll_step_i); |
| 7697 | bs->ScrollAccum[n] -= scroll_step_i; |
| 7698 | } |
| 7699 | } |
| 7700 | |
| 7701 | bool ImGui::BeginBoxSelect(const ImRect& scope_rect, ImGuiWindow* window, ImGuiID box_select_id, ImGuiMultiSelectFlags ms_flags) |
| 7702 | { |
no test coverage detected