From 31d2d3041bafd8f5301b58e70d8fe8bf269e010b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Fri, 24 Jul 2020 01:28:01 -0300 Subject: [PATCH] UITreeView performance improvement (and fix). --- src/eepp/ui/uitreeview.cpp | 47 +++++++++++++++++------------ src/tools/codeeditor/codeeditor.cpp | 2 +- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/eepp/ui/uitreeview.cpp b/src/eepp/ui/uitreeview.cpp index 1bd6ac3ec..b8ccd4899 100644 --- a/src/eepp/ui/uitreeview.cpp +++ b/src/eepp/ui/uitreeview.cpp @@ -358,7 +358,11 @@ Sizef UITreeView::getContentSize() const { } void UITreeView::drawChilds() { - traverseTree( [&]( const int& rowIndex, const ModelIndex& index, const size_t& indentLevel, + int realIndex = 0; + + mUISceneNode->setIsLoading( true ); + + traverseTree( [&]( const int&, const ModelIndex& index, const size_t& indentLevel, const Float& yOffset ) { if ( yOffset - mScrollOffset.y > mSize.getHeight() ) return IterationDecision::Stop; @@ -367,17 +371,21 @@ void UITreeView::drawChilds() { for ( size_t colIndex = 0; colIndex < getModel()->columnCount(); colIndex++ ) { if ( columnData( colIndex ).visible ) { if ( (Int64)colIndex != index.column() ) { - updateCell( rowIndex, + updateCell( realIndex, getModel()->index( index.row(), colIndex, index.parent() ), indentLevel, yOffset ); } else { - updateCell( rowIndex, index, indentLevel, yOffset ); + updateCell( realIndex, index, indentLevel, yOffset ); } } } - updateRow( rowIndex, index, yOffset )->nodeDraw(); + updateRow( realIndex, index, yOffset )->nodeDraw(); + realIndex++; return IterationDecision::Continue; } ); + + mUISceneNode->setIsLoading( false ); + if ( mHeader && mHeader->isVisible() ) mHeader->nodeDraw(); if ( mHScroll->isVisible() ) @@ -399,17 +407,19 @@ Node* UITreeView::overFind( const Vector2f& point ) { return pOver; if ( mHeader && ( pOver = mHeader->overFind( point ) ) ) return pOver; - traverseTree( [&, point]( int rowIndex, const ModelIndex& index, const size_t&, - const Float& yOffset ) { - if ( yOffset - mScrollOffset.y > mSize.getHeight() ) - return IterationDecision::Stop; - if ( yOffset - mScrollOffset.y + getRowHeight() < 0 ) + int realIndex = 0; + traverseTree( + [&, point]( int, const ModelIndex& index, const size_t&, const Float& yOffset ) { + if ( yOffset - mScrollOffset.y > mSize.getHeight() ) + return IterationDecision::Stop; + if ( yOffset - mScrollOffset.y + getRowHeight() < 0 ) + return IterationDecision::Continue; + pOver = updateRow( realIndex, index, yOffset )->overFind( point ); + realIndex++; + if ( pOver ) + return IterationDecision::Stop; return IterationDecision::Continue; - pOver = updateRow( rowIndex, index, yOffset )->overFind( point ); - if ( pOver ) - return IterationDecision::Stop; - return IterationDecision::Continue; - } ); + } ); if ( !pOver ) pOver = this; } @@ -454,11 +464,10 @@ void UITreeView::setExpandersAsIcons( bool expandersAsIcons ) { Float UITreeView::getMaxColumnContentWidth( const size_t& colIndex ) { Float lWidth = 0; getUISceneNode()->setIsLoading( true ); - traverseTree( [&, colIndex]( const int& rowIndex, const ModelIndex& index, - const size_t& indentLevel, const Float& yOffset ) { - UIWidget* widget = - updateCell( rowIndex, getModel()->index( index.row(), colIndex, index.parent() ), - indentLevel, yOffset ); + traverseTree( [&, colIndex]( const int&, const ModelIndex& index, const size_t& indentLevel, + const Float& yOffset ) { + UIWidget* widget = updateCell( + 0, getModel()->index( index.row(), colIndex, index.parent() ), indentLevel, yOffset ); if ( widget->isType( UI_TYPE_PUSHBUTTON ) ) { Float w = widget->asType()->getContentSize().getWidth(); if ( w > lWidth ) diff --git a/src/tools/codeeditor/codeeditor.cpp b/src/tools/codeeditor/codeeditor.cpp index 2a3e9db16..b29f2f805 100644 --- a/src/tools/codeeditor/codeeditor.cpp +++ b/src/tools/codeeditor/codeeditor.cpp @@ -248,7 +248,7 @@ void App::loadConfig() { std::string recent = mIniState.getValue( "files", "recentfiles", "" ); mRecentFiles = String::split( recent, ';' ); mInitColorScheme = mConfig.editor.colorScheme = - mIni.getValue( "editor", "colorscheme", "lite" ); + mIni.getValue( "editor", "colorscheme", "eepp" ); mConfig.editor.fontSize = mIni.getValue( "editor", "font_size", "11dp" ); mConfig.window.size.setWidth( mIniState.getValueI( "window", "width", mDisplayDPI > 105 ? 1920 : 1280 ) );