瀏覽代碼

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).

omar 6 年之前
父節點
當前提交
d6df777ff2
共有 2 個文件被更改,包括 7 次插入1 次删除
  1. 1 1
      imgui.cpp
  2. 6 0
      imgui_demo.cpp

+ 1 - 1
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
 

+ 6 - 0
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);