diff --git a/application/uilayer.cpp b/application/uilayer.cpp index 5443d158c..1b4962e16 100644 --- a/application/uilayer.cpp +++ b/application/uilayer.cpp @@ -404,6 +404,8 @@ bool ui_layer::init(GLFWwindow *Window) if (!gamepadui) gamepadui = ""; auto const viewportsupport{(m_imguiio->BackendFlags & ImGuiBackendFlags_PlatformHasViewports) && (m_imguiio->BackendFlags & ImGuiBackendFlags_RendererHasViewports) && glfwGetPlatform() != GLFW_PLATFORM_WAYLAND && std::string_view{desktop} != "gamescope" && std::string_view{gamepadui} != "1"}; + // a tooltip as long as a paragraph is wrapped: in one line it can run past the screen + m_imguiio->ConfigTooltipsWrapWidth = std::round(Global.ui_fontsize * 40.0f); if (Global.ui_viewports && viewportsupport) { m_imguiio->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; diff --git a/imgui/imgui.cpp b/imgui/imgui.cpp index a9026b408..190f89012 100644 --- a/imgui/imgui.cpp +++ b/imgui/imgui.cpp @@ -1491,6 +1491,7 @@ ImGuiIO::ImGuiIO() ConfigViewportsNoDecoration = true; ConfigViewportsNoDefaultParent = false; ConfigViewportsNoAutoDetach = false; + ConfigTooltipsWrapWidth = 0.0f; // Miscellaneous options MouseDrawCursor = false; @@ -12112,7 +12113,14 @@ void ImGui::SetTooltipV(const char* fmt, va_list args) { if (!BeginTooltipEx(ImGuiTooltipFlags_OverridePrevious, ImGuiWindowFlags_None)) return; + // MaSzyna addition: see io.ConfigTooltipsWrapWidth + ImGuiContext& g = *GImGui; + const bool wrap = g.IO.ConfigTooltipsWrapWidth > 0.0f; + if (wrap) + PushTextWrapPos(GetCursorPosX() + g.IO.ConfigTooltipsWrapWidth); TextV(fmt, args); + if (wrap) + PopTextWrapPos(); EndTooltip(); } @@ -16393,6 +16401,10 @@ static void ImGui::WindowSelectViewport(ImGuiWindow* window) window->ViewportAllowPlatformMonitorExtend = FindPlatformMonitorForPos((use_mouse_ref && mouse_valid) ? mouse_ref : NavCalcPreferredRefPos()); else window->ViewportAllowPlatformMonitorExtend = window->Viewport->PlatformMonitor; + // MaSzyna addition: see io.ConfigViewportsNoAutoDetach. Over the main viewport they stay inside it: the late creation of a + // viewport in Begin() needs the extent of the monitor + if (g.IO.ConfigViewportsNoAutoDetach && window->Viewport == main_viewport) + window->ViewportAllowPlatformMonitorExtend = -1; } else if (window->Viewport && window != window->Viewport->Window && window->Viewport->Window && !(flags & ImGuiWindowFlags_ChildWindow) && window->DockNode == NULL) { diff --git a/imgui/imgui.h b/imgui/imgui.h index 6bbc42dec..85f50b79a 100644 --- a/imgui/imgui.h +++ b/imgui/imgui.h @@ -2360,7 +2360,8 @@ struct ImGuiIO bool ConfigViewportsNoTaskBarIcon; // = false // Disable default OS task bar icon flag for secondary viewports. When a viewport doesn't want a task bar icon, ImGuiViewportFlags_NoTaskBarIcon will be set on it. bool ConfigViewportsNoDecoration; // = true // Disable default OS window decoration flag for secondary viewports. When a viewport doesn't want window decorations, ImGuiViewportFlags_NoDecoration will be set on it. Enabling decoration can create subsequent issues at OS levels (e.g. minimum window size). bool ConfigViewportsNoDefaultParent; // = false // Disable default OS parenting to main viewport for secondary viewports. By default, viewports are marked with ParentViewportId = , expecting the platform backend to setup a parent/child relationship between the OS windows (some backend may ignore this). Set to true if you want the default to be 0, then all viewports will be top-level OS windows. - bool ConfigViewportsNoAutoDetach; // = false // MaSzyna addition: a floating window stays inside its host viewport: a resize stops at its edge, and a window left past it, or too big for it, is moved and shrunk to fit. It gets a viewport of its own only when dragged with the mouse cursor past the host viewport. Popups and tooltips are not affected. + bool ConfigViewportsNoAutoDetach; // = false // MaSzyna addition: a floating window stays inside its host viewport: a resize stops at its edge, and a window left past it, or too big for it, is moved and shrunk to fit. It gets a viewport of its own only when dragged with the mouse cursor past the host viewport. Tooltips and popups shown over the main viewport stay inside it too, moved and shrunk to fit, with no viewport of their own. + float ConfigTooltipsWrapWidth; // = 0.0f // MaSzyna addition: the text of SetTooltip() wraps at this width, in pixels; 0: it doesn't wrap. // Miscellaneous options // (you can visualize and interact with all options in 'Demo->Configuration')