diff --git a/include/eepp/scene/scenenode.hpp b/include/eepp/scene/scenenode.hpp index 3164bf69a..a50b61163 100644 --- a/include/eepp/scene/scenenode.hpp +++ b/include/eepp/scene/scenenode.hpp @@ -108,6 +108,10 @@ class EE_API SceneNode : public Node { const Float& getDPI() const; + bool getVerbose() const; + + void setVerbose( bool verbose ); + protected: friend class Node; typedef UnorderedSet CloseList; @@ -117,6 +121,7 @@ class EE_API SceneNode : public Node { FrameBuffer* mFrameBuffer; EventDispatcher* mEventDispatcher; CloseList mCloseList; + Clock mClock; bool mFrameBufferBound; bool mUseInvalidation; bool mUseGlobalCursors; @@ -127,6 +132,9 @@ class EE_API SceneNode : public Node { bool mHighlightOver; bool mHighlightFocus; bool mHighlightInvalidation; + bool mFirstUpdate{ true }; + bool mFirstFrame{ true }; + bool mVerbose{ false }; Color mHighlightFocusColor; Color mHighlightOverColor; Color mHighlightInvalidationColor; diff --git a/include/eepp/ui/uiscenenode.hpp b/include/eepp/ui/uiscenenode.hpp index 0f6272b85..63a86fff4 100644 --- a/include/eepp/ui/uiscenenode.hpp +++ b/include/eepp/ui/uiscenenode.hpp @@ -99,10 +99,6 @@ class EE_API UISceneNode : public SceneNode { UIWidget* getRoot() const; - bool getVerbose() const; - - void setVerbose( bool verbose ); - void invalidateStyle( UIWidget* widget ); void invalidateStyleState( UIWidget* widget, bool disableCSSAnimations = false ); @@ -179,11 +175,8 @@ class EE_API UISceneNode : public SceneNode { Translator mTranslator; std::vector mWindowsList; CSS::StyleSheet mStyleSheet; - bool mIsLoading; - bool mVerbose; - bool mUpdatingLayouts; - bool mFirstUpdate{ true }; - Clock mClock; + bool mIsLoading{ false }; + bool mUpdatingLayouts{ false }; UIThemeManager* mUIThemeManager{ nullptr }; UIIconThemeManager* mUIIconThemeManager{ nullptr }; std::vector mFontFaces; diff --git a/src/eepp/scene/scenenode.cpp b/src/eepp/scene/scenenode.cpp index eced703e5..054e8d753 100644 --- a/src/eepp/scene/scenenode.cpp +++ b/src/eepp/scene/scenenode.cpp @@ -127,6 +127,12 @@ void SceneNode::draw() { mWindow->setView( prevView ); GlobalBatchRenderer::instance()->draw(); + + if ( mVerbose && mFirstFrame ) { + mFirstFrame = false; + Log::info( "First frame in SceneNode took %.2f ms", + mClock.getElapsedTime().asMilliseconds() ); + } } void SceneNode::update( const Time& time ) { @@ -499,4 +505,12 @@ const Float& SceneNode::getDPI() const { return mDPI; } +bool SceneNode::getVerbose() const { + return mVerbose; +} + +void SceneNode::setVerbose( bool verbose ) { + mVerbose = verbose; +} + }} // namespace EE::Scene diff --git a/src/eepp/ui/abstract/uiabstracttableview.cpp b/src/eepp/ui/abstract/uiabstracttableview.cpp index bbc48864f..ad28a994d 100644 --- a/src/eepp/ui/abstract/uiabstracttableview.cpp +++ b/src/eepp/ui/abstract/uiabstracttableview.cpp @@ -18,9 +18,7 @@ UIAbstractTableView::UIAbstractTableView( const std::string& tag ) : mSortIconSize( PixelDensity::dpToPxI( 20 ) ) { mHeader = UILinearLayout::NewWithTag( mTag + "::header", UIOrientation::Horizontal ); mHeader->setLayoutSizePolicy( SizePolicy::Fixed, SizePolicy::Fixed ); - mHeader->setParent( this ); - mHeader->setVisible( true ); - mHeader->setEnabled( true ); + mHeader->setParent( this )->setVisible( true )->setEnabled( true ); mVScroll->on( Event::OnAlphaChange, [this]( const Event* ) { if ( mVScroll->getAlpha() == 0.f || mVScroll->getAlpha() == 1.f ) updateColumnsWidth(); diff --git a/src/eepp/ui/uiscenenode.cpp b/src/eepp/ui/uiscenenode.cpp index dcd2a831a..50608e4fb 100644 --- a/src/eepp/ui/uiscenenode.cpp +++ b/src/eepp/ui/uiscenenode.cpp @@ -37,7 +37,6 @@ UISceneNode::UISceneNode( EE::Window::Window* window ) : SceneNode( window ), mRoot( NULL ), mIsLoading( false ), - mVerbose( false ), mUpdatingLayouts( false ), mUIThemeManager( UIThemeManager::New() ), mUIIconThemeManager( UIIconThemeManager::New()->setFallbackThemeManager( mUIThemeManager ) ), @@ -665,14 +664,6 @@ UIWidget* UISceneNode::getRoot() const { return mRoot; } -bool UISceneNode::getVerbose() const { - return mVerbose; -} - -void UISceneNode::setVerbose( bool verbose ) { - mVerbose = verbose; -} - void UISceneNode::invalidateStyle( UIWidget* node ) { eeASSERT( NULL != node ); diff --git a/src/eepp/ui/uitableview.cpp b/src/eepp/ui/uitableview.cpp index dfcde5c8f..22d575595 100644 --- a/src/eepp/ui/uitableview.cpp +++ b/src/eepp/ui/uitableview.cpp @@ -4,6 +4,8 @@ #include #include +#include + namespace EE { namespace UI { UITableView* UITableView::New() { @@ -56,13 +58,12 @@ void UITableView::drawChilds() { } Node* UITableView::overFind( const Vector2f& point ) { - mUISceneNode->setIsLoading( true ); - + ScopedOp op( [this] { mUISceneNode->setIsLoading( true ); }, + [this] { mUISceneNode->setIsLoading( false ); } ); Node* pOver = NULL; if ( mEnabled && mVisible ) { ConditionalLock l( getModel() != nullptr, getModel() ? &getModel()->resourceMutex() : nullptr ); - updateWorldPolygon(); if ( mWorldBounds.contains( point ) && mPoly.pointInside( point ) ) { writeNodeFlag( NODE_FLAG_MOUSEOVER_ME_OR_CHILD, 1 ); @@ -103,7 +104,6 @@ Node* UITableView::overFind( const Vector2f& point ) { } } - mUISceneNode->setIsLoading( false ); return pOver; } @@ -112,7 +112,8 @@ Float UITableView::getMaxColumnContentWidth( const size_t& colIndex, bool bestGu ConditionalLock l( getModel() != nullptr, getModel() ? &getModel()->resourceMutex() : nullptr ); if ( getModel()->rowCount() == 0 ) return lWidth; - getUISceneNode()->setIsLoading( true ); + ScopedOp op( [this] { mUISceneNode->setIsLoading( true ); }, + [this] { mUISceneNode->setIsLoading( false ); } ); Float yOffset = getHeaderHeight(); auto worstCaseFunc = [&]( const ModelIndex& index ) { UIWidget* widget = updateCell( index.row(), index, 0, yOffset ); @@ -148,7 +149,6 @@ Float UITableView::getMaxColumnContentWidth( const size_t& colIndex, bool bestGu for ( size_t i = 0; i < getItemCount(); i++ ) worstCaseFunc( getModel()->index( i, colIndex ) ); } - getUISceneNode()->setIsLoading( false ); return lWidth; } diff --git a/src/eepp/ui/uitreeview.cpp b/src/eepp/ui/uitreeview.cpp index c9900fb6b..a3feb9789 100644 --- a/src/eepp/ui/uitreeview.cpp +++ b/src/eepp/ui/uitreeview.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -384,8 +385,8 @@ void UITreeView::drawChilds() { } Node* UITreeView::overFind( const Vector2f& point ) { - mUISceneNode->setIsLoading( true ); - + ScopedOp op( [this] { mUISceneNode->setIsLoading( true ); }, + [this] { mUISceneNode->setIsLoading( false ); } ); Node* pOver = NULL; if ( mEnabled && mVisible ) { updateWorldPolygon(); @@ -416,9 +417,6 @@ Node* UITreeView::overFind( const Vector2f& point ) { pOver = this; } } - - mUISceneNode->setIsLoading( false ); - return pOver; } @@ -509,7 +507,8 @@ void UITreeView::setExpandersAsIcons( bool expandersAsIcons ) { Float UITreeView::getMaxColumnContentWidth( const size_t& colIndex, bool ) { Float lWidth = 0; - getUISceneNode()->setIsLoading( true ); + ScopedOp op( [this] { mUISceneNode->setIsLoading( true ); }, + [this] { mUISceneNode->setIsLoading( false ); } ); traverseTree( [&, colIndex]( const int&, const ModelIndex& index, const size_t& indentLevel, const Float& yOffset ) { UIWidget* widget = updateCell( @@ -521,7 +520,6 @@ Float UITreeView::getMaxColumnContentWidth( const size_t& colIndex, bool ) { } return IterationDecision::Continue; } ); - getUISceneNode()->setIsLoading( false ); return lWidth; }