From 42efc29def2606f77ea655996fa16973f3f3fabc Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 2 Jul 2015 21:03:15 -0600 Subject: [PATCH] SetScrollFromCursorPos() -> SetScrollHere() (#150) final call ! --- imgui.cpp | 12 ++++++------ imgui.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index d6a84c18..40b1f15a 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4845,7 +4845,7 @@ void ImGui::SetScrollFromPosY(float pos_y, float center_y_ratio) window->ScrollTargetCenterRatioY = center_y_ratio; } -void ImGui::SetScrollFromCursorPos(float center_y_ratio) +void ImGui::SetScrollHere(float center_y_ratio) { ImGuiWindow* window = GetCurrentWindow(); float target_y = window->DC.CursorPosPrevLine.y + (window->DC.PrevLineHeight * center_y_ratio) + (GImGui->Style.ItemSpacing.y * (center_y_ratio - 0.5f) * 2.0f); // Precisely aim above, in the middle or below the last line. @@ -7762,7 +7762,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi *current_item = i; } if (item_selected && menu_toggled) - ImGui::SetScrollFromCursorPos(); + ImGui::SetScrollHere(); ImGui::PopID(); } ImGui::EndPopup(); @@ -11311,10 +11311,10 @@ void ImGui::ShowTestWindow(bool* opened) { ImGui::Text("%04d: scrollable region", i); if (goto_line && line == i) - ImGui::SetScrollFromCursorPos(); + ImGui::SetScrollHere(); } if (goto_line && line >= 100) - ImGui::SetScrollFromCursorPos(); + ImGui::SetScrollHere(); ImGui::EndChild(); ImGui::SameLine(); @@ -11529,7 +11529,7 @@ void ImGui::ShowTestWindow(bool* opened) { ImGui::Text("Line %d", line); if (track && line == track_line) - ImGui::SetScrollFromCursorPos(i * 0.50f); // 0.0f:top, 0.5f:center, 1.0f:bottom + ImGui::SetScrollHere(i * 0.50f); // 0.0f:top, 0.5f:center, 1.0f:bottom } ImGui::EndChild(); ImGui::EndGroup(); @@ -12288,7 +12288,7 @@ struct ExampleAppConsole ImGui::PopStyleColor(); } if (ScrollToBottom) - ImGui::SetScrollFromCursorPos(); + ImGui::SetScrollHere(); ScrollToBottom = false; ImGui::PopStyleVar(); ImGui::EndChild(); diff --git a/imgui.h b/imgui.h index 56ff0676..4e12c4ec 100644 --- a/imgui.h +++ b/imgui.h @@ -138,7 +138,7 @@ namespace ImGui IMGUI_API float GetScrollY(); // get scrolling amount [0..GetScrollMaxY()] IMGUI_API float GetScrollMaxY(); // get maximum scrolling amount == ContentSize.Y - WindowSize.Y IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()] - IMGUI_API void SetScrollFromCursorPos(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. + IMGUI_API void SetScrollHere(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. IMGUI_API void SetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position valid. use GetCursorPos() or GetCursorStartPos()+offset to get valid positions. IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget IMGUI_API void SetStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it) @@ -411,7 +411,7 @@ namespace ImGui static inline bool IsClipped(const ImVec2& size) { return !IsRectVisible(size); } // OBSOLETE 1.38+ static inline bool IsRectClipped(const ImVec2& size) { return !IsRectVisible(size); } // OBSOLETE 1.39+ static inline bool IsMouseHoveringBox(const ImVec2& rect_min, const ImVec2& rect_max) { return IsMouseHoveringRect(rect_min, rect_max); } // OBSOLETE 1.36+ - static inline void SetScrollPosHere() { SetScrollFromCursorPos(); } // OBSOLETE 1.42+ + static inline void SetScrollPosHere() { SetScrollHere(); } // OBSOLETE 1.42+ #endif } // namespace ImGui