diff --git a/include/eepp/ui/doc/documentview.hpp b/include/eepp/ui/doc/documentview.hpp index 92ea5a360..29d3f0441 100644 --- a/include/eepp/ui/doc/documentview.hpp +++ b/include/eepp/ui/doc/documentview.hpp @@ -63,7 +63,7 @@ class EE_API DocumentView { void updateCache( Int64 fromLine, Int64 toLine, Int64 numLines ); - Config getConfig() const { return mConfig; } + const Config& getConfig() const { return mConfig; } void setConfig( Config config ); diff --git a/include/eepp/ui/uicodeeditor.hpp b/include/eepp/ui/uicodeeditor.hpp index edea80312..1eaba28d8 100644 --- a/include/eepp/ui/uicodeeditor.hpp +++ b/include/eepp/ui/uicodeeditor.hpp @@ -1219,6 +1219,8 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client { virtual void onAutoSize(); virtual void onClassChange(); + + inline bool needsHorizontalLength() const; }; }} // namespace EE::UI diff --git a/src/eepp/graphics/fonttruetype.cpp b/src/eepp/graphics/fonttruetype.cpp index 84a4fa08b..61eea539f 100644 --- a/src/eepp/graphics/fonttruetype.cpp +++ b/src/eepp/graphics/fonttruetype.cpp @@ -657,7 +657,6 @@ Glyph FontTrueType::getGlyphByIndex( Uint32 index, unsigned int characterSize, b GlyphDrawable* FontTrueType::getGlyphDrawable( Uint32 codePoint, unsigned int characterSize, bool bold, bool italic, Float outlineThickness ) const { - // mKeyCache Page& page = getPage( characterSize ); GlyphDrawableTable& drawables = page.drawables; diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index c86c22e9b..8755f2c04 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -488,7 +488,7 @@ void UICodeEditor::scheduledUpdate( const Time& ) { invalidateDraw(); } - if ( mDoc && !mDoc->isLoading() && mHorizontalScrollBarEnabled && isVisible() && + if ( mDoc && !mDoc->isLoading() && needsHorizontalLength() && isVisible() && mLongestLineWidthDirty && mLongestLineWidthLastUpdate.getElapsedTime() > mFindLongestLineWidthUpdateFrequency ) { updateLongestLineWidth(); @@ -499,8 +499,7 @@ void UICodeEditor::scheduledUpdate( const Time& ) { } void UICodeEditor::updateLongestLineWidth() { - if ( mHorizontalScrollBarEnabled && mDoc && !mDoc->isLoading() && - !mDoc->isRunningTransaction() ) { + if ( needsHorizontalLength() && mDoc && !mDoc->isLoading() && !mDoc->isRunningTransaction() ) { Float maxWidth = mLongestLineWidth; findLongestLine(); mLongestLineWidthLastUpdate.restart(); @@ -2060,7 +2059,7 @@ void UICodeEditor::onPaddingChange() { std::pair UICodeEditor::findLongestLineInRange( const TextRange& range ) { std::pair curRange{ mLongestLineIndex, mLongestLineWidth }; - if ( mHorizontalScrollBarEnabled ) { + if ( needsHorizontalLength() ) { Float longestLineWidth = 0; for ( Int64 lineIndex = range.start().line(); lineIndex <= range.end().line(); lineIndex++ ) { @@ -2076,7 +2075,7 @@ std::pair UICodeEditor::findLongestLineInRange( const TextRange& } void UICodeEditor::findLongestLine() { - if ( mHorizontalScrollBarEnabled ) { + if ( needsHorizontalLength() ) { auto range = findLongestLineInRange( mDoc->getDocRange() ); mLongestLineIndex = range.first; mLongestLineWidth = range.second; @@ -5727,4 +5726,8 @@ void UICodeEditor::onClassChange() { } } +bool UICodeEditor::needsHorizontalLength() const { + return mDocView.getConfig().mode == LineWrapMode::NoWrap; +} + }} // namespace EE::UI