mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Basic undocumented/unsupported combination of Child+Tooltip. The full feature needs substancially more work but this is enough for simplest cases. (#1345)
This commit is contained in:
parent
42a612d7c9
commit
e5a6e85f6d
11
imgui.cpp
11
imgui.cpp
@ -4560,10 +4560,12 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
// When reusing window again multiple times a frame, just append content (don't need to setup again)
|
// When reusing window again multiple times a frame, just append content (don't need to setup again)
|
||||||
if (first_begin_of_the_frame)
|
if (first_begin_of_the_frame)
|
||||||
{
|
{
|
||||||
|
const bool is_pinned_child_tooltip = (flags & ImGuiWindowFlags_ChildWindow) && (flags & ImGuiWindowFlags_Tooltip); // FIXME-WIP: Undocumented behavior of Child+Tooltip for pinned tooltip (#1345)
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
window->ParentWindow = parent_window;
|
window->ParentWindow = parent_window;
|
||||||
window->RootWindow = window->RootNonPopupWindow = window;
|
window->RootWindow = window->RootNonPopupWindow = window;
|
||||||
if (parent_window && (flags & ImGuiWindowFlags_ChildWindow))
|
if (parent_window && (flags & ImGuiWindowFlags_ChildWindow) && !is_pinned_child_tooltip)
|
||||||
window->RootWindow = parent_window->RootWindow;
|
window->RootWindow = parent_window->RootWindow;
|
||||||
if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)))
|
if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)))
|
||||||
window->RootNonPopupWindow = parent_window->RootNonPopupWindow;
|
window->RootNonPopupWindow = parent_window->RootNonPopupWindow;
|
||||||
@ -4681,8 +4683,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
{
|
{
|
||||||
window->BeginOrderWithinParent = parent_window->DC.ChildWindows.Size;
|
window->BeginOrderWithinParent = parent_window->DC.ChildWindows.Size;
|
||||||
parent_window->DC.ChildWindows.push_back(window);
|
parent_window->DC.ChildWindows.push_back(window);
|
||||||
|
if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api && !is_pinned_child_tooltip)
|
||||||
if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api)
|
|
||||||
window->Pos = window->PosFloat = parent_window->DC.CursorPos;
|
window->Pos = window->PosFloat = parent_window->DC.CursorPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4713,7 +4714,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Position tooltip (always follows mouse)
|
// Position tooltip (always follows mouse)
|
||||||
if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api)
|
if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !is_pinned_child_tooltip)
|
||||||
{
|
{
|
||||||
ImVec2 ref_pos = g.IO.MousePos;
|
ImVec2 ref_pos = g.IO.MousePos;
|
||||||
ImRect rect_to_avoid(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24, ref_pos.y + 24); // FIXME: Completely hard-coded. Store boxes in mouse cursor data? Scale? Center on cursor hit-point?
|
ImRect rect_to_avoid(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24, ref_pos.y + 24); // FIXME: Completely hard-coded. Store boxes in mouse cursor data? Scale? Center on cursor hit-point?
|
||||||
@ -4771,7 +4772,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
window->DrawList->Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0);
|
window->DrawList->Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0);
|
||||||
window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID);
|
window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID);
|
||||||
ImRect fullscreen_rect(GetVisibleRect());
|
ImRect fullscreen_rect(GetVisibleRect());
|
||||||
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup))
|
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !is_pinned_child_tooltip)
|
||||||
PushClipRect(parent_window->ClipRect.Min, parent_window->ClipRect.Max, true);
|
PushClipRect(parent_window->ClipRect.Min, parent_window->ClipRect.Max, true);
|
||||||
else
|
else
|
||||||
PushClipRect(fullscreen_rect.Min, fullscreen_rect.Max, true);
|
PushClipRect(fullscreen_rect.Min, fullscreen_rect.Max, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user