From d6df777ff2c52b5afaac2b9837c2ec1b71b6edc6 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 3 Jun 2019 17:07:43 +0200 Subject: [PATCH] TextWrapped, PushTextWrapPos(0.0f) within a window with horizontal scrolling from not covering the full horizontal area (previously only worked with an explicit contents size). --- imgui.cpp | 2 +- imgui_demo.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index c871445f..4c8812bc 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2997,7 +2997,7 @@ float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x) ImGuiWindow* window = GImGui->CurrentWindow; if (wrap_pos_x == 0.0f) - wrap_pos_x = GetContentRegionMaxAbs().x; + wrap_pos_x = window->WorkRect.Max.x; else if (wrap_pos_x > 0.0f) wrap_pos_x += window->Pos.x - window->Scroll.x; // wrap_pos_x is provided is window local space diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 294e6f03..c8d7b83f 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -2154,6 +2154,7 @@ static void ShowDemoWindowLayout() static bool show_h_scrollbar = true; static bool show_button = true; static bool show_tree_nodes = true; + static bool show_text_wrapped = false; static bool show_columns = true; static bool show_tab_bar = true; static bool explicit_content_size = false; @@ -2167,6 +2168,7 @@ static void ShowDemoWindowLayout() ImGui::Checkbox("H-scrollbar", &show_h_scrollbar); ImGui::Checkbox("Button", &show_button); // Will grow contents size (unless explicitly overwritten) ImGui::Checkbox("Tree nodes", &show_tree_nodes); // Will grow contents size and display highlight over full width + ImGui::Checkbox("Text wrapped", &show_text_wrapped);// Will grow and use contents size ImGui::Checkbox("Columns", &show_columns); // Will use contents size ImGui::Checkbox("Tab bar", &show_tab_bar); // Will use contents size ImGui::Checkbox("Explicit content size", &explicit_content_size); @@ -2200,6 +2202,10 @@ static void ShowDemoWindowLayout() } ImGui::CollapsingHeader("CollapsingHeader", &open); } + if (show_text_wrapped) + { + ImGui::TextWrapped("This text should automatically wrap on the edge of the work rectangle."); + } if (show_columns) { ImGui::Columns(4);