diff --git a/include/eepp/system/scopedop.hpp b/include/eepp/system/scopedop.hpp index 07bb05bc1..df73ef22f 100644 --- a/include/eepp/system/scopedop.hpp +++ b/include/eepp/system/scopedop.hpp @@ -23,6 +23,25 @@ class ScopedOp { std::function mEndOp; }; +class ScopedOpOptional { + public: + explicit ScopedOpOptional( bool cond, std::function startOp, + std::function endOp = nullptr ) : + cond( cond ), mEndOp( endOp ) { + if ( cond && startOp ) + startOp(); + } + + ~ScopedOpOptional() { + if ( cond && mEndOp ) + mEndOp(); + } + + private: + bool cond; + std::function mEndOp; +}; + class BoolScopedOp { public: explicit BoolScopedOp( bool& boolRef ) : boolRef( boolRef ) {} diff --git a/include/eepp/ui/models/modelindex.hpp b/include/eepp/ui/models/modelindex.hpp index 0efe6a650..7072e615b 100644 --- a/include/eepp/ui/models/modelindex.hpp +++ b/include/eepp/ui/models/modelindex.hpp @@ -49,6 +49,8 @@ class EE_API ModelIndex { ModelIndex siblingAtColumn( int column ) const; + std::string toString() const; + protected: friend class Model; const Model* mModel{ nullptr }; diff --git a/include/eepp/ui/uiscenenode.hpp b/include/eepp/ui/uiscenenode.hpp index 63a86fff4..bb4b3bd1a 100644 --- a/include/eepp/ui/uiscenenode.hpp +++ b/include/eepp/ui/uiscenenode.hpp @@ -99,9 +99,9 @@ class EE_API UISceneNode : public SceneNode { UIWidget* getRoot() const; - void invalidateStyle( UIWidget* widget ); + void invalidateStyle( UIWidget* widget, bool tryReinsert = false ); - void invalidateStyleState( UIWidget* widget, bool disableCSSAnimations = false ); + void invalidateStyleState( UIWidget* widget, bool disableCSSAnimations = false, bool tryReinsert = false ); void invalidateLayout( UILayout* widget ); diff --git a/src/eepp/system/platform/win/clockimpl.cpp b/src/eepp/system/platform/win/clockimpl.cpp index 1e13f72b0..21c5604b9 100644 --- a/src/eepp/system/platform/win/clockimpl.cpp +++ b/src/eepp/system/platform/win/clockimpl.cpp @@ -81,10 +81,6 @@ unsigned long ClockImpl::getElapsedTime() { return newMicro; } -bool ClockImpl::isPO2( Uint32 n ) { - return ( n & ( n - 1 ) ) == 0; -} - }}} // namespace EE::System::Platform #endif diff --git a/src/eepp/system/platform/win/clockimpl.hpp b/src/eepp/system/platform/win/clockimpl.hpp index 12ebc5bd4..be8a700cb 100644 --- a/src/eepp/system/platform/win/clockimpl.hpp +++ b/src/eepp/system/platform/win/clockimpl.hpp @@ -33,9 +33,8 @@ class ClockImpl { LARGE_INTEGER mStartTime; LARGE_INTEGER mFrequency; unsigned long mTimerMask; - - bool isPO2( Uint32 n ); }; + }}} // namespace EE::System::Platform #endif diff --git a/src/eepp/ui/models/modelindex.cpp b/src/eepp/ui/models/modelindex.cpp index 8a3db6c3c..d23bc777b 100644 --- a/src/eepp/ui/models/modelindex.cpp +++ b/src/eepp/ui/models/modelindex.cpp @@ -16,6 +16,11 @@ ModelIndex ModelIndex::siblingAtColumn( int column ) const { return sibling( row(), column ); } +std::string ModelIndex::toString() const { + return String::format( "ModelIndex{col: %ld - row: %ld, internalId: %ld}", mColumn, mRow, + mInternalId ); +} + Variant ModelIndex::data( ModelRole role ) const { if ( !isValid() ) return {}; diff --git a/src/eepp/ui/uiscenenode.cpp b/src/eepp/ui/uiscenenode.cpp index 50608e4fb..606cdc4ca 100644 --- a/src/eepp/ui/uiscenenode.cpp +++ b/src/eepp/ui/uiscenenode.cpp @@ -664,14 +664,18 @@ UIWidget* UISceneNode::getRoot() const { return mRoot; } -void UISceneNode::invalidateStyle( UIWidget* node ) { +void UISceneNode::invalidateStyle( UIWidget* node, bool tryReinsert ) { eeASSERT( NULL != node ); if ( node->isClosing() ) return; - if ( mDirtyStyle.count( node ) > 0 ) - return; + if ( mDirtyStyle.count( node ) > 0 ) { + if ( !tryReinsert ) + return; + else + mDirtyStyle.erase( node ); + } for ( auto& dirtyNode : mDirtyStyle ) if ( NULL != dirtyNode && dirtyNode->isParentOf( node ) ) @@ -689,14 +693,19 @@ void UISceneNode::invalidateStyle( UIWidget* node ) { mDirtyStyle.insert( node ); } -void UISceneNode::invalidateStyleState( UIWidget* node, bool disableCSSAnimations ) { +void UISceneNode::invalidateStyleState( UIWidget* node, bool disableCSSAnimations, + bool tryReinsert ) { eeASSERT( NULL != node ); if ( node->isClosing() ) return; - if ( mDirtyStyleState.count( node ) > 0 ) - return; + if ( mDirtyStyleState.count( node ) > 0 ) { + if ( !tryReinsert ) + return; + else + mDirtyStyleState.erase( node ); + } for ( auto& dirtyNode : mDirtyStyleState ) if ( NULL != dirtyNode && dirtyNode->isParentOf( node ) ) diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index 0279822fb..0ad716668 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -994,8 +994,8 @@ void UIWidget::onThemeLoaded() {} void UIWidget::onParentChange() { if ( !isSceneNodeLoading() && !isLoadingState() ) { - getUISceneNode()->invalidateStyle( this ); - getUISceneNode()->invalidateStyleState( this, true ); + getUISceneNode()->invalidateStyle( this, true ); + getUISceneNode()->invalidateStyleState( this, true, true ); } }