mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
Tooltips: tooltips have a maximum size corresponding to host display/monitor size.
This commit is contained in:
parent
10a0eb3e1c
commit
415dddf0fa
2 changed files with 11 additions and 4 deletions
11
imgui.cpp
11
imgui.cpp
|
|
@ -6398,16 +6398,19 @@ static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_cont
|
|||
const float decoration_h_without_scrollbars = window->DecoOuterSizeY1 + window->DecoOuterSizeY2 - window->ScrollbarSizes.y;
|
||||
ImVec2 size_pad = window->WindowPadding * 2.0f;
|
||||
ImVec2 size_desired = size_contents + size_pad + ImVec2(decoration_w_without_scrollbars, decoration_h_without_scrollbars);
|
||||
|
||||
// Determine maximum window size
|
||||
// Child windows are layed within their parent (unless they are also popups/menus) and thus have no restriction
|
||||
ImVec2 size_max = ((window->Flags & ImGuiWindowFlags_ChildWindow) && !(window->Flags & ImGuiWindowFlags_Popup)) ? ImVec2(FLT_MAX, FLT_MAX) : ImGui::GetMainViewport()->WorkSize - style.DisplaySafeAreaPadding * 2.0f;
|
||||
|
||||
if (window->Flags & ImGuiWindowFlags_Tooltip)
|
||||
{
|
||||
// Tooltip always resize
|
||||
return size_desired;
|
||||
// Tooltip always resize (up to maximum size)
|
||||
return ImMin(size_desired, size_max);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Maximum window size is determined by the viewport size or monitor size
|
||||
ImVec2 size_min = CalcWindowMinSize(window);
|
||||
ImVec2 size_max = ((window->Flags & ImGuiWindowFlags_ChildWindow) && !(window->Flags & ImGuiWindowFlags_Popup)) ? ImVec2(FLT_MAX, FLT_MAX) : ImGui::GetMainViewport()->WorkSize - style.DisplaySafeAreaPadding * 2.0f;
|
||||
ImVec2 size_auto_fit = ImClamp(size_desired, ImMin(size_min, size_max), size_max);
|
||||
|
||||
// FIXME: CalcWindowAutoFitSize() doesn't take into account that only one axis may be auto-fit when calculating scrollbars,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue