| 680 | } |
| 681 | |
| 682 | void UISceneNode::update( const Time& elapsed ) { |
| 683 | UISceneNode* uiSceneNode = SceneManager::instance()->getUISceneNode(); |
| 684 | |
| 685 | if ( mFirstUpdate && mVerbose ) { |
| 686 | mClock.restart(); |
| 687 | } |
| 688 | |
| 689 | SceneManager::instance()->setCurrentUISceneNode( this ); |
| 690 | |
| 691 | updateDirtyStyles(); |
| 692 | updateDirtyStyleStates(); |
| 693 | updateDirtyLayouts(); |
| 694 | |
| 695 | if ( mFirstUpdate && mVerbose ) { |
| 696 | Log::debug( "UISceneNode::update first update dirty took: %.2f ms", |
| 697 | mClock.getElapsedTime().asMilliseconds() ); |
| 698 | } |
| 699 | |
| 700 | SceneNode::update( elapsed ); |
| 701 | |
| 702 | if ( mFirstUpdate && mVerbose ) { |
| 703 | Log::debug( "UISceneNode::update first SceneNode::update update took: %.2f ms", |
| 704 | mClock.getElapsedTime().asMilliseconds() ); |
| 705 | } |
| 706 | |
| 707 | // We process again all the dirty states since the update could have created new dirty states |
| 708 | // that we want to process BEFORE drawing the scene, since we can avoid some resizes/animations |
| 709 | // glitches. Also after the SceneNode::update (having run updated the actions, responded to |
| 710 | // events, and updating the nodes means that new nodes could have been added and need to be |
| 711 | // ready before being drawn. Also the reverse case could happen, we need to have the styles and |
| 712 | // layouts updated before and after the update to avoid weird issues. The cost of doing this is |
| 713 | // minimal and the benefit is huge and simplifies implementation. |
| 714 | // invalidationDepth allows to retry to apply any pending state as many times as set. |
| 715 | // This is required in some very edge cases where widgets are being created during the update |
| 716 | // of any of these 3 steps. Usually during the layout update, this could trigger resizes that |
| 717 | // provokes the creation of dynamic elements. This is the case of the UIListBox for example |
| 718 | // that creates children dynamically only when they are visible. |
| 719 | int invalidationDepth = mMaxInvalidationDepth; |
| 720 | while ( ( !mDirtyStyle.empty() || !mDirtyStyleState.empty() || !mDirtyLayouts.empty() ) && |
| 721 | invalidationDepth > 0 ) { |
| 722 | updateDirtyStyles(); |
| 723 | updateDirtyStyleStates(); |
| 724 | updateDirtyLayouts(); |
| 725 | invalidationDepth--; |
| 726 | } |
| 727 | |
| 728 | SceneManager::instance()->setCurrentUISceneNode( uiSceneNode ); |
| 729 | |
| 730 | if ( mFirstUpdate && mVerbose ) { |
| 731 | mFirstUpdate = false; |
| 732 | Log::debug( "UISceneNode::update first update took: %.2f ms", |
| 733 | mClock.getElapsedTime().asMilliseconds() ); |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | void UISceneNode::onWidgetDelete( Node* node ) { |
| 738 | if ( node->isWidget() ) { |
no test coverage detected