diff --git a/modules/juce_graphics/detail/juce_JustifiedText.cpp b/modules/juce_graphics/detail/juce_JustifiedText.cpp index c828351e14..10639a634f 100644 --- a/modules/juce_graphics/detail/juce_JustifiedText.cpp +++ b/modules/juce_graphics/detail/juce_JustifiedText.cpp @@ -327,6 +327,9 @@ JustifiedText::JustifiedText (const SimpleShapedText* t, const ShapedTextOptions rangesToDraw.set ({ 0, (int64) shapedText.getGlyphs().size() }, DrawType::normal, ops); + if (options.getDrawLinesInFull()) + return; + //============================================================================== // Everything above this line should work well given none of the lines were too // long. When Options::getMaxNumLines() == 0 this is guaranteed by SimpleShapedText. diff --git a/modules/juce_graphics/detail/juce_SimpleShapedText.h b/modules/juce_graphics/detail/juce_SimpleShapedText.h index 1e5de9614d..439187dd4b 100644 --- a/modules/juce_graphics/detail/juce_SimpleShapedText.h +++ b/modules/juce_graphics/detail/juce_SimpleShapedText.h @@ -179,6 +179,17 @@ public: return withMember (*this, &ShapedTextOptions::ellipsis, std::move (x)); } + /* Draw each line in its entirety even if it goes beyond wordWrapWidth. This means that even + if configured, an ellipsis will never be inserted. + + This is used by the TextEditor where the Viewport guarantees that all text will be viewable + even beyond the word wrap width. + */ + [[nodiscard]] ShapedTextOptions withDrawLinesInFull (bool x = true) const + { + return withMember (*this, &ShapedTextOptions::drawLinesInFull, std::move (x)); + } + [[nodiscard]] ShapedTextOptions withReadingDirection (std::optional x) const { return withMember (*this, &ShapedTextOptions::readingDir, x); @@ -203,6 +214,7 @@ public: const auto& getTrailingWhitespacesShouldFit() const { return trailingWhitespacesShouldFit; } const auto& getMaxNumLines() const { return maxNumLines; } const auto& getEllipsis() const { return ellipsis; } + const auto& getDrawLinesInFull() const { return drawLinesInFull; } const auto& getAllowBreakingInsideWord() const { return allowBreakingInsideWord; } private: @@ -227,6 +239,7 @@ private: bool baselineAtZero = false; bool allowBreakingInsideWord = false; bool trailingWhitespacesShouldFit = true; + bool drawLinesInFull = false; int64 maxNumLines = std::numeric_limits::max(); String ellipsis; }; diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index a79b86ff6c..8baaeb7e51 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -947,6 +947,7 @@ void TextEditor::updateBaseShapedTextOptions() { auto options = detail::ShapedText::Options{}.withTrailingWhitespacesShouldFit (true) .withJustification (getJustificationType().getOnlyHorizontalFlags()) + .withDrawLinesInFull() .withLeading (lineSpacing); if (wordWrap)