mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-24 00:26:36 +00:00
Internals: Added SetNextWindowScroll() (#1526)
This commit is contained in:
parent
1fd9e131e4
commit
3233fbff0e
21
imgui.cpp
21
imgui.cpp
@ -5488,6 +5488,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
UpdateWindowParentAndRootLinks(window, flags, parent_window);
|
||||
|
||||
// Process SetNextWindow***() calls
|
||||
// (FIXME: Consider splitting the HasXXX flags into X/Y components
|
||||
bool window_pos_set_by_api = false;
|
||||
bool window_size_x_set_by_api = false, window_size_y_set_by_api = false;
|
||||
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos)
|
||||
@ -5512,6 +5513,19 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window_size_y_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.y > 0.0f);
|
||||
SetWindowSize(window, g.NextWindowData.SizeVal, g.NextWindowData.SizeCond);
|
||||
}
|
||||
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasScroll)
|
||||
{
|
||||
if (g.NextWindowData.ScrollVal.x >= 0.0f)
|
||||
{
|
||||
window->ScrollTarget.x = g.NextWindowData.ScrollVal.x;
|
||||
window->ScrollTargetCenterRatio.x = 0.0f;
|
||||
}
|
||||
if (g.NextWindowData.ScrollVal.y >= 0.0f)
|
||||
{
|
||||
window->ScrollTarget.y = g.NextWindowData.ScrollVal.y;
|
||||
window->ScrollTargetCenterRatio.y = 0.0f;
|
||||
}
|
||||
}
|
||||
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasContentSize)
|
||||
window->ContentSizeExplicit = g.NextWindowData.ContentSizeVal;
|
||||
else if (first_begin_of_the_frame)
|
||||
@ -6513,6 +6527,13 @@ void ImGui::SetNextWindowContentSize(const ImVec2& size)
|
||||
g.NextWindowData.ContentSizeVal = size;
|
||||
}
|
||||
|
||||
void ImGui::SetNextWindowScroll(const ImVec2& scroll)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasScroll;
|
||||
g.NextWindowData.ScrollVal = scroll;
|
||||
}
|
||||
|
||||
void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
@ -948,7 +948,8 @@ enum ImGuiNextWindowDataFlags_
|
||||
ImGuiNextWindowDataFlags_HasCollapsed = 1 << 3,
|
||||
ImGuiNextWindowDataFlags_HasSizeConstraint = 1 << 4,
|
||||
ImGuiNextWindowDataFlags_HasFocus = 1 << 5,
|
||||
ImGuiNextWindowDataFlags_HasBgAlpha = 1 << 6
|
||||
ImGuiNextWindowDataFlags_HasBgAlpha = 1 << 6,
|
||||
ImGuiNextWindowDataFlags_HasScroll = 1 << 7
|
||||
};
|
||||
|
||||
// Storage for SetNexWindow** functions
|
||||
@ -962,6 +963,7 @@ struct ImGuiNextWindowData
|
||||
ImVec2 PosPivotVal;
|
||||
ImVec2 SizeVal;
|
||||
ImVec2 ContentSizeVal;
|
||||
ImVec2 ScrollVal;
|
||||
bool CollapsedVal;
|
||||
ImRect SizeConstraintRect;
|
||||
ImGuiSizeCallback SizeCallback;
|
||||
@ -1703,6 +1705,7 @@ namespace ImGui
|
||||
IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name);
|
||||
|
||||
// Scrolling
|
||||
IMGUI_API void SetNextWindowScroll(const ImVec2& scroll); // Use -1.0f on one axis to leave as-is
|
||||
IMGUI_API void SetScrollX(ImGuiWindow* window, float new_scroll_x);
|
||||
IMGUI_API void SetScrollY(ImGuiWindow* window, float new_scroll_y);
|
||||
IMGUI_API void SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio = 0.5f);
|
||||
|
Loading…
Reference in New Issue
Block a user