idlehomescreen/xmluirendering/uiengine/src/xnuiengineimpl.cpp
branchRCL_3
changeset 93 b01126ce0bec
parent 88 3321d3e205b6
child 102 ba63c83f4716
equal deleted inserted replaced
88:3321d3e205b6 93:b01126ce0bec
  7970 
  7970 
  7971 // -----------------------------------------------------------------------------
  7971 // -----------------------------------------------------------------------------
  7972 // -----------------------------------------------------------------------------
  7972 // -----------------------------------------------------------------------------
  7973 //
  7973 //
  7974 static void ReportScreenDeviceChangedL( const CXnPluginData& aPluginData )
  7974 static void ReportScreenDeviceChangedL( const CXnPluginData& aPluginData )
  7975     {    
  7975     {   
  7976     CXnNode* node( NULL );
  7976     CXnNode* node( NULL );
  7977     
  7977     
  7978     if ( aPluginData.Node() )
  7978     if ( aPluginData.Node() )
  7979         {
  7979         {
  7980         node = aPluginData.Node()->LayoutNode();
  7980         node = aPluginData.Node()->LayoutNode();
  8209     iViewManager.RemoveObserver( *this );
  8209     iViewManager.RemoveObserver( *this );
  8210            
  8210            
  8211     delete iEditMode;
  8211     delete iEditMode;
  8212 
  8212 
  8213     iFocusCandidateList.Reset();
  8213     iFocusCandidateList.Reset();
  8214 
       
  8215     if ( iRedrawRegions.Count() )
       
  8216         {
       
  8217         iRedrawRegions.ResetAndDestroy();
       
  8218         }
       
  8219 
       
  8220     iDirtyList.Reset();
       
  8221     }
  8214     }
  8222 
  8215 
  8223 // -----------------------------------------------------------------------------
  8216 // -----------------------------------------------------------------------------
  8224 // CXnUiEngineImpl::AppUiAdapter()
  8217 // CXnUiEngineImpl::AppUiAdapter()
  8225 // -----------------------------------------------------------------------------
  8218 // -----------------------------------------------------------------------------
  8231 
  8224 
  8232 // -----------------------------------------------------------------------------
  8225 // -----------------------------------------------------------------------------
  8233 // CXnUiEngineImpl::LayoutUIL()
  8226 // CXnUiEngineImpl::LayoutUIL()
  8234 // -----------------------------------------------------------------------------
  8227 // -----------------------------------------------------------------------------
  8235 //
  8228 //
  8236 void CXnUiEngineImpl::LayoutUIL( CXnNode* /*aNode*/ )
  8229 void CXnUiEngineImpl::LayoutUIL( CXnNode* aNode )
  8237     {
  8230     {
  8238     if ( IsLayoutDisabled() )
  8231     if( aNode )
       
  8232         {
       
  8233         TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *aNode );
       
  8234         if( dirtyRegion )
       
  8235             {
       
  8236             LayoutL( *dirtyRegion );
       
  8237             }
       
  8238         }
       
  8239     else
       
  8240         {
       
  8241         CXnViewData* viewData = iViewManager.ActiveAppData().ViewData( *iCurrentView );
       
  8242         if( viewData )
       
  8243             {
       
  8244             RPointerArray<TXnDirtyRegion> arr;
       
  8245             CleanupClosePushL( arr );
       
  8246             viewData->GetDirtyRegions( arr );
       
  8247             for( TInt i = 0; i < arr.Count(); i++ )
       
  8248                 {
       
  8249                 LayoutL( *arr[i] );            
       
  8250                 }
       
  8251             CleanupStack::PopAndDestroy( &arr );
       
  8252             }
       
  8253         }
       
  8254     }
       
  8255 
       
  8256 // -----------------------------------------------------------------------------
       
  8257 // CXnUiEngineImpl::LayoutUIL()
       
  8258 // -----------------------------------------------------------------------------
       
  8259 //
       
  8260 void CXnUiEngineImpl::LayoutL( TXnDirtyRegion& aRegion )
       
  8261     {
       
  8262     if ( IsLayoutDisabled( aRegion ) )
  8239         {     
  8263         {     
  8240         iLayoutControl |= XnLayoutControl::ELayoutUI;
  8264         aRegion.iLayoutControl |= XnLayoutControl::ELayoutUI;
  8241         return;
  8265         return;
  8242         }
  8266         }
  8243 
  8267 
  8244     iLayoutControl &= ~XnLayoutControl::ELayoutUI;
  8268     aRegion.iLayoutControl &= ~XnLayoutControl::ELayoutUI;
  8245 
  8269 
  8246     if ( iDirtyList.Count() == 0 )
  8270     if ( aRegion.iDirtyList.Count() == 0 )
  8247         {
  8271         {
  8248         // Nothing to do, layout is up-to-date
  8272         // Nothing to do, layout is up-to-date
  8249         return;
  8273         return;
  8250         }
  8274         }
  8251 
  8275 
  8252     DisableRenderUiLC();
  8276     DisableRenderUiLC();
  8253     CXnNode* candidate( StartLayoutFromL() );
  8277     
  8254     PrepareRunLayoutL();
  8278     CXnNode* candidate( StartLayoutFromL( aRegion ) );
  8255     iDirtyList.Reset();
  8279     if( !candidate )
       
  8280         {
       
  8281         return;
       
  8282         }
       
  8283     
       
  8284     PrepareRunLayoutL( aRegion );
       
  8285     aRegion.iDirtyList.Reset();
  8256 
  8286 
  8257     // Run layout until it is fully calculated
  8287     // Run layout until it is fully calculated
  8258     do
  8288     do
  8259         {
  8289         {
  8260         iLayoutPhase = RunLayoutL( candidate );
  8290         iLayoutPhase = RunLayoutL( aRegion, *candidate );
  8261         }
  8291         }
  8262     while ( iLayoutPhase != XnLayoutPhase::ENone );
  8292     while ( iLayoutPhase != XnLayoutPhase::ENone );
  8263 
  8293 
  8264     CXnNode* focused( FocusedNode() );
  8294     // Run these only if the current view is being layouted
  8265 
  8295     if( iCurrentView == aRegion.iRootNode )
  8266     if ( focused && focused->IsDropped() )
  8296         {  
  8267         {
  8297         CXnNode* focused( FocusedNode() );
  8268         // The currently focused node is dropped, run losevisualization
  8298     
  8269         CXnNode* loseVisualisation =
  8299         if ( focused && focused->IsDropped() )
  8270             BuildTriggerNodeLC( *iUiEngine,
  8300             {
  8271                 XnPropertyNames::action::trigger::name::KLoseVisualisation );
  8301             // The currently focused node is dropped, run losevisualization
  8272 
  8302             CXnNode* loseVisualisation =
  8273         focused->ReportXuikonEventL( *loseVisualisation );
  8303                 BuildTriggerNodeLC( *iUiEngine,
  8274         CleanupStack::PopAndDestroy( loseVisualisation );
  8304                     XnPropertyNames::action::trigger::name::KLoseVisualisation );
  8275 
  8305     
  8276         if ( FocusedNode() == focused )
  8306             focused->ReportXuikonEventL( *loseVisualisation );
  8277             {
  8307             CleanupStack::PopAndDestroy( loseVisualisation );
  8278             // Remove focus as losevisualization trigger didn't
  8308     
  8279             // change focus from dropped node to another one
  8309             if ( FocusedNode() == focused )
  8280             SetFocusedNodeL( NULL );
  8310                 {
  8281             }
  8311                 // Remove focus as losevisualization trigger didn't
  8282         }
  8312                 // change focus from dropped node to another one
  8283 
  8313                 SetFocusedNodeL( NULL );
  8284     if ( !FocusedNode() && iAppUiAdapter.FocusShown() )
  8314                 }
  8285         {
  8315             }
  8286         // No focus, try if some of the focus candidates can be focused
  8316     
  8287         RootNode()->RunFocusChangeL( iFocusCandidateList );
  8317         if ( !FocusedNode() && iAppUiAdapter.FocusShown() )
  8288         }
  8318             {
  8289         
  8319             // No focus, try if some of the focus candidates can be focused
  8290     iFocusCandidateList.Reset();
  8320             RootNode()->RunFocusChangeL( iFocusCandidateList );
  8291 
  8321             }
  8292     iAppUiAdapter.EffectManager()->UiLayouted();
  8322             
       
  8323         iFocusCandidateList.Reset();
       
  8324     
       
  8325         iAppUiAdapter.EffectManager()->UiLayouted();
       
  8326         }
  8293     
  8327     
  8294     // Layout is now recalculated
  8328     // Layout is now recalculated
  8295     CleanupStack::PopAndDestroy(); // anonymous
  8329     CleanupStack::PopAndDestroy(); // anonymous
  8296     }
  8330     }
  8297 
  8331 
  8298 // -----------------------------------------------------------------------------
       
  8299 // CXnUiEngineImpl::LayoutFromNodeL()
       
  8300 // -----------------------------------------------------------------------------
       
  8301 //
       
  8302 void CXnUiEngineImpl::LayoutFromNodeL( CXnNode& aNode )
       
  8303     {
       
  8304     PrepareRunLayoutL( aNode );
       
  8305 
       
  8306     // Run layout until it is fully calculated
       
  8307     do
       
  8308         {
       
  8309         iLayoutPhase = RunLayoutFromNodeL( aNode );
       
  8310         }
       
  8311     while ( iLayoutPhase != XnLayoutPhase::ENone );
       
  8312     }
       
  8313 
  8332 
  8314 // -----------------------------------------------------------------------------
  8333 // -----------------------------------------------------------------------------
  8315 // PrepareRunLayoutL()
  8334 // PrepareRunLayoutL()
  8316 // Set dropped flags of all nodes in the tree to ENone.
  8335 // Set dropped flags of all nodes in the tree to ENone.
  8317 // -----------------------------------------------------------------------------
  8336 // -----------------------------------------------------------------------------
  8318 //
  8337 //
  8319 void CXnUiEngineImpl::PrepareRunLayoutL()
  8338 void CXnUiEngineImpl::PrepareRunLayoutL( TXnDirtyRegion& aDirtyRegion )
  8320     {
  8339     {
  8321     if ( iLayoutPhase == XnLayoutPhase::ENone )
  8340     if ( iLayoutPhase == XnLayoutPhase::ENone )
  8322         {
  8341         {
  8323         iLayoutPhase = XnLayoutPhase::ELayout;
  8342         iLayoutPhase = XnLayoutPhase::ELayout;
  8324 
  8343 
  8325         for ( TInt i = 0; i < iDirtyList.Count(); i++ )
  8344         for ( TInt i = 0; i < aDirtyRegion.iDirtyList.Count(); i++ )
  8326             {
  8345             {
  8327             CXnNode* dirty( iDirtyList[i] );
  8346             CXnNode* dirty( aDirtyRegion.iDirtyList[i] );
  8328 
  8347 
  8329             // Clear dropped flags recursively
  8348             // Clear dropped flags recursively
  8330             SetNodeDroppedL( *dirty, XnNodeLayout::ENone );
  8349             SetNodeDroppedL( *dirty, XnNodeLayout::ENone );
  8331 
  8350 
  8332             if ( SetAdaptivesL( *dirty ) )
  8351             if ( SetAdaptivesL( *dirty ) )
  8337             }
  8356             }
  8338         }
  8357         }
  8339     }
  8358     }
  8340 
  8359 
  8341 // -----------------------------------------------------------------------------
  8360 // -----------------------------------------------------------------------------
  8342 // PrepareRunLayoutL()
       
  8343 // Set dropped flags of all nodes in the tree to ENone.
       
  8344 // -----------------------------------------------------------------------------
       
  8345 //
       
  8346 void CXnUiEngineImpl::PrepareRunLayoutL( CXnNode& aNode )
       
  8347     {
       
  8348     if ( iLayoutPhase == XnLayoutPhase::ENone )
       
  8349         {
       
  8350         iLayoutPhase = XnLayoutPhase::ELayout;
       
  8351 
       
  8352         CXnNode* dirty( &aNode );
       
  8353         dirty->ClearRenderedAndLaidOut();
       
  8354         
       
  8355         // Clear dropped flags recursively
       
  8356         SetNodeDroppedL( *dirty, XnNodeLayout::ENone );
       
  8357 
       
  8358         if ( SetAdaptivesL( *dirty ) )
       
  8359             {
       
  8360             // Adaptive node causes measure phase
       
  8361             iLayoutPhase = XnLayoutPhase::EMeasure;
       
  8362             }
       
  8363         }
       
  8364     }
       
  8365 
       
  8366 // -----------------------------------------------------------------------------
       
  8367 // CXnUiEngineImpl::RunLayoutL()
  8361 // CXnUiEngineImpl::RunLayoutL()
  8368 // -----------------------------------------------------------------------------
  8362 // -----------------------------------------------------------------------------
  8369 //
  8363 //
  8370 TInt CXnUiEngineImpl::RunLayoutL( CXnNode* aNode )
  8364 TInt CXnUiEngineImpl::RunLayoutL( TXnDirtyRegion& aDirtyRegion, CXnNode& aNode )
  8371     {
  8365     {
  8372     TRect clientRect( ClientRect() );
  8366     TRect clientRect( ClientRect() );
  8373     // Move it to 0, 0
  8367     // Move it to 0, 0
  8374     clientRect.Move( -clientRect.iTl.iX, -clientRect.iTl.iY );
  8368     clientRect.Move( -clientRect.iTl.iX, -clientRect.iTl.iY );
  8375 
  8369 
  8376     RPointerArray< CXnNode > laidOutList;
  8370     RPointerArray< CXnNode > laidOutList;
  8377     CleanupClosePushL( laidOutList );
  8371     CleanupClosePushL( laidOutList );
  8378 
  8372 
  8379     if ( IsNodeDisplayedL( *aNode ) )
  8373     if ( IsNodeDisplayedL( aNode ) )
  8380         {
  8374         {
  8381         if ( aNode->ViewNodeImpl() && !aNode ->IsLaidOut() )
  8375         if ( aNode.ViewNodeImpl() && !aNode.IsLaidOut() )
  8382             {
  8376             {
  8383             aNode->SetMarginRect( clientRect );
  8377             aNode.SetMarginRect( clientRect );
  8384             aNode->SetBorderRect( clientRect );
  8378             aNode.SetBorderRect( clientRect );
  8385             aNode->SetNormalFlowBorderRect( clientRect );
  8379             aNode.SetNormalFlowBorderRect( clientRect );
  8386             aNode->SetPaddingRect( clientRect );
  8380             aNode.SetPaddingRect( clientRect );
  8387             aNode->SetRect( clientRect );
  8381             aNode.SetRect( clientRect );
  8388             }
  8382             }
  8389 
  8383 
  8390         // Put areas to place
  8384         // Put areas to place
  8391         PlaceAreasL( *aNode, laidOutList, iLayoutPhase,
  8385         PlaceAreasL( aNode, laidOutList, iLayoutPhase,
  8392             *iCurrentGraphicsDevice, iHorizontalUnitInPixels,
  8386             *iCurrentGraphicsDevice, iHorizontalUnitInPixels,
  8393             iVerticalUnitInPixels );
  8387             iVerticalUnitInPixels );
  8394         }
  8388         }
  8395 
  8389 
  8396     TInt nextPhase;
  8390     TInt nextPhase;
  8400         case XnLayoutPhase::EMeasure:
  8394         case XnLayoutPhase::EMeasure:
  8401             nextPhase = XnLayoutPhase::ELayout;
  8395             nextPhase = XnLayoutPhase::ELayout;
  8402             break;
  8396             break;
  8403         case XnLayoutPhase::ELayout:
  8397         case XnLayoutPhase::ELayout:
  8404             // Layout is now calculated
  8398             // Layout is now calculated
  8405             iCurrentView->SetLaidOutL();
  8399             aDirtyRegion.iRootNode->SetLaidOutL();
  8406             iLayoutControl &= ~XnLayoutControl::EViewDirty;
  8400             aDirtyRegion.iLayoutControl &= ~XnLayoutControl::EViewDirty;
  8407             // Check nodes which dimensions are changed
  8401             // Check nodes which dimensions are changed
  8408             for ( TInt i = 0; i < laidOutList.Count(); i++ )
  8402             for ( TInt i = 0; i < laidOutList.Count(); i++ )
  8409                 {
  8403                 {
  8410                 CXnNode* node( laidOutList[i] );
  8404                 CXnNode* node( laidOutList[i] );
  8411                 if( IsSrollableBox( *node ) && node->ScrollableControl() )
  8405                 if( IsSrollableBox( *node ) && node->ScrollableControl() )
  8433                         rect = node->BorderRect();
  8427                         rect = node->BorderRect();
  8434                         }
  8428                         }
  8435                     
  8429                     
  8436                     if ( adapter->Rect() != rect )
  8430                     if ( adapter->Rect() != rect )
  8437                         {
  8431                         {
  8438                         AddToRedrawListL( node, rect );
  8432                         AddToRedrawListL( aDirtyRegion, *node, rect );
  8439                         
  8433                         
  8440                         adapter->SetRect( rect );                        
  8434                         adapter->SetRect( rect );                        
  8441 
  8435 
  8442                         CXnProperty* prop = node->GetPropertyL(
  8436                         CXnProperty* prop = node->GetPropertyL(
  8443                             XnPropertyNames::common::KSizeAware );
  8437                             XnPropertyNames::common::KSizeAware );
  8462     CleanupStack::PopAndDestroy( &laidOutList );
  8456     CleanupStack::PopAndDestroy( &laidOutList );
  8463     return nextPhase;
  8457     return nextPhase;
  8464     }
  8458     }
  8465 
  8459 
  8466 // -----------------------------------------------------------------------------
  8460 // -----------------------------------------------------------------------------
  8467 // CXnUiEngineImpl::RunLayoutL()
       
  8468 // -----------------------------------------------------------------------------
       
  8469 //
       
  8470 TInt CXnUiEngineImpl::RunLayoutFromNodeL( CXnNode& aNode )
       
  8471     {
       
  8472     TRect clientRect( ClientRect() );
       
  8473     // Move it to 0, 0
       
  8474     clientRect.Move( -clientRect.iTl.iX, -clientRect.iTl.iY );
       
  8475 
       
  8476     RPointerArray< CXnNode > laidOutList;
       
  8477     CleanupClosePushL( laidOutList );
       
  8478 
       
  8479     if ( IsNodeDisplayedL( aNode ) )
       
  8480         {
       
  8481         if ( aNode.ViewNodeImpl() && !aNode.IsLaidOut() )
       
  8482             {
       
  8483             aNode.SetMarginRect( clientRect );
       
  8484             aNode.SetBorderRect( clientRect );
       
  8485             aNode.SetNormalFlowBorderRect( clientRect );
       
  8486             aNode.SetPaddingRect( clientRect );
       
  8487             aNode.SetRect( clientRect );
       
  8488             }
       
  8489 
       
  8490         // Put areas to place
       
  8491         PlaceAreasL( aNode, laidOutList, iLayoutPhase,
       
  8492             *iCurrentGraphicsDevice, iHorizontalUnitInPixels,
       
  8493             iVerticalUnitInPixels );
       
  8494         }
       
  8495 
       
  8496     TInt nextPhase;
       
  8497 
       
  8498     switch ( iLayoutPhase )
       
  8499         {
       
  8500         case XnLayoutPhase::EMeasure:
       
  8501             nextPhase = XnLayoutPhase::ELayout;
       
  8502             break;
       
  8503         case XnLayoutPhase::ELayout:
       
  8504             // Layout is now calculated
       
  8505             aNode.SetLaidOutL();
       
  8506 
       
  8507             // Check nodes which dimensions are changed
       
  8508             for ( TInt i = 0; i < laidOutList.Count(); i++ )
       
  8509                 {
       
  8510                 CXnNode* node( laidOutList[i] );
       
  8511                 if( IsSrollableBox( *node ) && node->ScrollableControl() )
       
  8512                     {
       
  8513                     node->ScrollableControl()->LayoutChangedL();
       
  8514                     }
       
  8515                 if ( !node->IsLaidOut() )
       
  8516                     {
       
  8517                     continue;
       
  8518                     }
       
  8519                 CXnControlAdapter* adapter( node->Control() );
       
  8520                 if ( adapter )
       
  8521                     {
       
  8522                     TRect rect;
       
  8523                     
       
  8524                     if ( node->ViewNodeImpl() )
       
  8525                         {
       
  8526                         rect = ClientRect();
       
  8527                         }
       
  8528                     else
       
  8529                         {
       
  8530                         rect = node->BorderRect();
       
  8531                         }
       
  8532                     if ( adapter->Rect() != rect )
       
  8533                         {
       
  8534                         adapter->SetRect( rect );
       
  8535                         }
       
  8536                     }
       
  8537                 }
       
  8538             /* flow through */
       
  8539         default:
       
  8540             nextPhase = XnLayoutPhase::ENone;
       
  8541             break;
       
  8542         }
       
  8543     CleanupStack::PopAndDestroy( &laidOutList );
       
  8544     return nextPhase;
       
  8545     }
       
  8546 
       
  8547 // -----------------------------------------------------------------------------
       
  8548 // CXnUiEngineImpl::RenderUIL()
  8461 // CXnUiEngineImpl::RenderUIL()
  8549 // -----------------------------------------------------------------------------
  8462 // -----------------------------------------------------------------------------
  8550 //
  8463 //
  8551 void CXnUiEngineImpl::RenderUIL( CXnNode* /*aNode*/ )
  8464 void CXnUiEngineImpl::RenderUIL( CXnNode* aNode )
  8552     {
  8465     {
  8553     if ( IsLayoutDisabled() )
  8466     if( aNode )
       
  8467         {
       
  8468         TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *aNode );
       
  8469         if( dirtyRegion )
       
  8470             {
       
  8471             RenderL( *dirtyRegion );
       
  8472             }
       
  8473         }
       
  8474     else
       
  8475         {
       
  8476         CXnViewData* viewData = iViewManager.ActiveAppData().ViewData( *iCurrentView );
       
  8477         if( viewData )
       
  8478             {
       
  8479             RPointerArray<TXnDirtyRegion> arr;
       
  8480             CleanupClosePushL( arr );
       
  8481             
       
  8482             viewData->GetDirtyRegions( arr );
       
  8483             for( TInt i = 0; i < arr.Count(); i++ )
       
  8484                 {
       
  8485                 RenderL( *arr[i] );            
       
  8486                 }
       
  8487             CleanupStack::PopAndDestroy( &arr );
       
  8488             }
       
  8489         }
       
  8490     }
       
  8491 
       
  8492 // -----------------------------------------------------------------------------
       
  8493 // CXnUiEngineImpl::RenderUIL()
       
  8494 // -----------------------------------------------------------------------------
       
  8495 //
       
  8496 void CXnUiEngineImpl::RenderL( TXnDirtyRegion& aRegion )
       
  8497     {
       
  8498     if ( IsLayoutDisabled( aRegion ) )
  8554         {
  8499         {
  8555         // Layout is not up-to-date
  8500         // Layout is not up-to-date
  8556         iLayoutControl |= XnLayoutControl::ERenderUI;
  8501         aRegion.iLayoutControl |= XnLayoutControl::ERenderUI;
  8557         return;
  8502         return;
  8558         }
  8503         }
  8559     
  8504 
       
  8505     TBool belongsToCurrentView( EFalse );
       
  8506     if( iCurrentView == aRegion.iRootNode )
       
  8507         {
       
  8508         belongsToCurrentView = ETrue;
       
  8509         }
       
  8510         
  8560 #ifdef _XN3_DEBUG_
  8511 #ifdef _XN3_DEBUG_
  8561     TraceTreeL(iCurrentView );
  8512     TraceTreeL( aRegion.RootNode );
  8562 #endif                          
  8513 #endif                          
  8563 
  8514 
  8564     __PRINTS("*** CXnUiEngineImpl::RenderUIL ***");
  8515     __PRINTS("*** CXnUiEngineImpl::RenderUIL ***");
  8565     
  8516     
  8566     for( TInt i=0; i<iRedrawRegions.Count(); i++)
       
  8567         {
       
  8568         CCoeControl* control = iRedrawRegions[i]->iControl;
       
  8569         RRegion& redrawRegion = iRedrawRegions[i]->iRegion;
       
  8570         
  8517         
  8571         if( redrawRegion.CheckError() )
  8518     CCoeControl* control = aRegion.iControl;
  8572             {                
  8519     RRegion& redrawRegion = aRegion.iRegion;
       
  8520     
       
  8521     if( redrawRegion.CheckError() )
       
  8522         {                
       
  8523         // Mark tree rendered
       
  8524         aRegion.iRootNode->SetRenderedL();
       
  8525         // Error occured during dirty set, redraw whole window
       
  8526         control->DrawNow();               
       
  8527         
       
  8528         __PRINTS("* CXnUiEngineImpl::RenderUIL - redraw region error -> full redraw ***");
       
  8529         }                                        
       
  8530     else 
       
  8531         {
       
  8532         if( !redrawRegion.IsEmpty() )                                        
       
  8533             {
  8573             // Mark tree rendered
  8534             // Mark tree rendered
  8574             iCurrentView->SetRenderedL();
  8535             aRegion.iRootNode->SetRenderedL();
  8575             // Error occured during dirty set, redraw whole window
  8536                 
  8576             control->DrawNow();               
  8537             TBool effectOngoing( EFalse );
       
  8538             if ( iAppUiAdapter.EffectManager()->ControlEffectActive( control ) &&
       
  8539                  belongsToCurrentView )
       
  8540                 {
       
  8541                 // control effect is ongoing, no need to draw control yet,
       
  8542                 // if current view in question
       
  8543                 redrawRegion.Clear();
       
  8544                 effectOngoing = ETrue;
       
  8545                 }
  8577             
  8546             
  8578             __PRINTS("* CXnUiEngineImpl::RenderUIL - redraw region error -> full redraw ***");
  8547             if( !effectOngoing )
  8579             }                                        
  8548                 {
  8580         else 
       
  8581             {
       
  8582             if( !redrawRegion.IsEmpty() )                                        
       
  8583                 {
       
  8584                 // Mark tree rendered
       
  8585                 iCurrentView->SetRenderedL();
       
  8586                                 
       
  8587                 if ( iAppUiAdapter.EffectManager()->ControlEffectActive( control ) )
       
  8588                     {
       
  8589                     // control effect is ongoing, no need to draw control yet
       
  8590                     redrawRegion.Clear();
       
  8591                     continue;
       
  8592                     }
       
  8593                 
       
  8594                 TInt count( redrawRegion.Count() );
  8549                 TInt count( redrawRegion.Count() );
  8595                 
  8550                 
  8596                 if( count > 2 )
  8551                 if( count > 2 )
  8597                     {
  8552                     {
  8598                     // Make bounding rect over the dirty areas
  8553                     // Make bounding rect over the dirty areas
  8607                     {
  8562                     {
  8608                     for( TInt i = 0; i < count; i++ )
  8563                     for( TInt i = 0; i < count; i++ )
  8609                         {
  8564                         {
  8610                         // Draw every dirty area separately
  8565                         // Draw every dirty area separately
  8611                         TRect redrawRect( redrawRegion[i] );
  8566                         TRect redrawRect( redrawRegion[i] );
  8612 
  8567     
  8613                         __PRINT( __DBG_FORMAT( "* CXnUiEngineImpl::RenderUIL - redrawing rect iTl.iX: %d, iTl.iY: %d, iBr.iX: %d, iBr.iY: %d" ),          
  8568                         __PRINT( __DBG_FORMAT( "* CXnUiEngineImpl::RenderUIL - redrawing rect iTl.iX: %d, iTl.iY: %d, iBr.iX: %d, iBr.iY: %d" ),          
  8614                                 redrawRect.iTl.iX, redrawRect.iTl.iY, redrawRect.iBr.iX, redrawRect.iBr.iY );                                         
  8569                                 redrawRect.iTl.iX, redrawRect.iTl.iY, redrawRect.iBr.iX, redrawRect.iBr.iY );                                         
  8615                         
  8570                         
  8616                         control->DrawNow( redrawRect );
  8571                         control->DrawNow( redrawRect );
  8617                         }
  8572                         }
  8618                     }  
  8573                     }  
  8619                 }
  8574                 }
  8620             else
  8575             }
  8621                 {
  8576         else
  8622                 __PRINTS("* CXnUiEngineImpl::RenderUIL - nothing to redraw ***");
  8577             {
  8623                 }
  8578             __PRINTS("* CXnUiEngineImpl::RenderUIL - nothing to redraw ***");
  8624             }  
  8579             }
  8625         
  8580         }  
  8626         redrawRegion.Clear();  
       
  8627         }
       
  8628 
       
  8629     RefreshMenuL();
       
  8630 
       
  8631     iLayoutControl &= ~XnLayoutControl::ERenderUI;
       
  8632     
  8581     
  8633     iAppUiAdapter.EffectManager()->UiRendered();
  8582     redrawRegion.Clear();  
       
  8583 
       
  8584     RefreshMenuL( &aRegion );
       
  8585 
       
  8586     aRegion.iLayoutControl &= ~XnLayoutControl::ERenderUI;
       
  8587     
       
  8588     if( belongsToCurrentView )
       
  8589         {
       
  8590         iAppUiAdapter.EffectManager()->UiRendered();
       
  8591         }
  8634     
  8592     
  8635     __PRINTS("*** CXnUiEngineImpl::RenderUIL - done ***");
  8593     __PRINTS("*** CXnUiEngineImpl::RenderUIL - done ***");
  8636     }
       
  8637 
       
  8638 // -----------------------------------------------------------------------------
       
  8639 // CXnUiEngineImpl::RenderFromNodeL()
       
  8640 // -----------------------------------------------------------------------------
       
  8641 //
       
  8642 void CXnUiEngineImpl::RenderFromNodeL( CXnNode& aNode )
       
  8643     {
       
  8644 #ifdef _XN3_DEBUG_
       
  8645     TraceTreeL( &aNode );
       
  8646 #endif 
       
  8647     CCoeControl* control = WindowOwningControl( aNode );
       
  8648     control->DrawNow();                                              
       
  8649     }
  8594     }
  8650 
  8595 
  8651 // -----------------------------------------------------------------------------
  8596 // -----------------------------------------------------------------------------
  8652 // CXnUiEngineImpl::RootNode()
  8597 // CXnUiEngineImpl::RootNode()
  8653 // -----------------------------------------------------------------------------
  8598 // -----------------------------------------------------------------------------
  8911     {
  8856     {
  8912     iCurrentView = iViewManager.ViewNode();
  8857     iCurrentView = iViewManager.ViewNode();
  8913 
  8858 
  8914     iControlAdapterList = &iViewManager.Controls();
  8859     iControlAdapterList = &iViewManager.Controls();
  8915     iCurrentViewControlAdapter = iCurrentView->Control();
  8860     iCurrentViewControlAdapter = iCurrentView->Control();
  8916     
       
  8917     iDirtyList.Reset();
       
  8918 
       
  8919     iRedrawRegions.ResetAndDestroy();
       
  8920        
  8861        
  8921     // Remove previous menubar and stylus popup node
  8862     // Remove previous menubar and stylus popup node
  8922     iMenuNode = NULL;
  8863     iMenuNode = NULL;
  8923     iStylusPopupNode = NULL;
  8864     iStylusPopupNode = NULL;
  8924 
  8865 
  8960     
  8901     
  8961     RootNode()->SetDirtyL();
  8902     RootNode()->SetDirtyL();
  8962            
  8903            
  8963     ForceRenderUIL();
  8904     ForceRenderUIL();
  8964            
  8905            
  8965     iLayoutControl &= ~XnLayoutControl::ERefreshMenu;
  8906     TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *iCurrentView );
       
  8907     if( dirtyRegion )
       
  8908         {
       
  8909         dirtyRegion->iDirtyList.Reset();
       
  8910         dirtyRegion->iLayoutControl &= ~XnLayoutControl::ERefreshMenu;
       
  8911         }
  8966     }
  8912     }
  8967 
  8913 
  8968 // -----------------------------------------------------------------------------
  8914 // -----------------------------------------------------------------------------
  8969 // CXnUiEngineImpl::NotifyViewLoadedL()
  8915 // CXnUiEngineImpl::NotifyViewLoadedL()
  8970 // -----------------------------------------------------------------------------
  8916 // -----------------------------------------------------------------------------
  9177 // Refresh current menu
  9123 // Refresh current menu
  9178 // -----------------------------------------------------------------------------
  9124 // -----------------------------------------------------------------------------
  9179 //
  9125 //
  9180 void CXnUiEngineImpl::RefreshMenuL()
  9126 void CXnUiEngineImpl::RefreshMenuL()
  9181     {
  9127     {
  9182     if ( IsLayoutDisabled() )
  9128     RefreshMenuL( NULL );
       
  9129     }
       
  9130 
       
  9131 // -----------------------------------------------------------------------------
       
  9132 // CXnUiEngineImpl::RefreshMenuL
       
  9133 // Refresh current menu
       
  9134 // -----------------------------------------------------------------------------
       
  9135 //
       
  9136 void CXnUiEngineImpl::RefreshMenuL( TXnDirtyRegion* aDirtyRegion )
       
  9137     {
       
  9138     TXnDirtyRegion* dirtyRegion = aDirtyRegion;
       
  9139     if( !dirtyRegion )
       
  9140         {
       
  9141         dirtyRegion = FindDirtyRegionL( *iCurrentView );
       
  9142         }
       
  9143     
       
  9144     if ( IsLayoutDisabled( *dirtyRegion ) )
  9183         {
  9145         {
  9184         return;
  9146         return;
  9185         }
  9147         }
  9186     
  9148 
  9187     if ( iLayoutControl & XnLayoutControl::ERefreshMenu )         
  9149     if ( dirtyRegion && 
       
  9150          dirtyRegion->iLayoutControl & XnLayoutControl::ERefreshMenu )         
  9188         {
  9151         {
  9189         if ( iKeyEventDispatcher )
  9152         if ( iKeyEventDispatcher )
  9190             {
  9153             {
  9191             iLayoutControl &= ~XnLayoutControl::ERefreshMenu;
  9154             dirtyRegion->iLayoutControl &= ~XnLayoutControl::ERefreshMenu;
  9192             iKeyEventDispatcher->RefreshMenuL();        
  9155             iKeyEventDispatcher->RefreshMenuL();        
  9193             }               
  9156             }               
  9194         }
  9157         }
  9195     }
  9158     }
  9196 
  9159 
  9199 // Add a dirty node. This method must be called via CXnNode SetDirtyL
  9162 // Add a dirty node. This method must be called via CXnNode SetDirtyL
  9200 // -----------------------------------------------------------------------------
  9163 // -----------------------------------------------------------------------------
  9201 //
  9164 //
  9202 void CXnUiEngineImpl::AddDirtyNodeL( CXnNode* aNode, TInt aLevel )
  9165 void CXnUiEngineImpl::AddDirtyNodeL( CXnNode* aNode, TInt aLevel )
  9203     {
  9166     {
  9204     CXnViewData& data( iViewManager.ActiveViewData() );
  9167     if ( !aNode )
       
  9168         {
       
  9169         return;
       
  9170         }    
  9205     
  9171     
  9206     if ( !aNode || ( aNode != RootNode() && !data.Plugin( aNode->Namespace() ) ) )
  9172     if ( aNode == RootNode() )
  9207         {
  9173         {
  9208         // No node, or node doesn't belong to active view namespace
  9174         // Force relayout and redraw from current view
  9209         return;
  9175         iViewManager.ActiveAppData().PluginData();
  9210         }
  9176         if ( !iCurrentView )
  9211 
  9177             {
  9212     if ( aNode->Type()->Type() == KMenuBar )
  9178             iCurrentView = iViewManager.ViewNode();
  9213         {
  9179             }
  9214         iLayoutControl |= XnLayoutControl::ERefreshMenu;
  9180 
  9215         return;
  9181         TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *iCurrentView );
  9216         }
  9182         if( dirtyRegion )
  9217 
  9183             {
  9218     if ( iLayoutControl & XnLayoutControl::EViewDirty )
  9184             dirtyRegion->iRegion.Clear();        
  9219         {
  9185             }
  9220         // nothing to do
  9186         else
  9221         return;
  9187             {
  9222         }
  9188             return;        
  9223 
  9189             }
  9224     if ( aLevel == XnDirtyLevel::ERender )
  9190         
  9225         {
  9191         dirtyRegion->iDirtyList.Reset();
  9226         if( aNode == RootNode() )        
  9192         dirtyRegion->iDirtyList.AppendL( iCurrentView );
  9227             {
  9193 
  9228             TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *iCurrentView );
  9194         dirtyRegion->iLayoutControl |= XnLayoutControl::EViewDirty;
  9229             if( dirtyRegion )
  9195         iCurrentView->ClearRenderedAndLaidOut();
  9230                 {
  9196 
  9231                 dirtyRegion->iRegion.Clear();                
  9197         // Add to draw list for redraw
  9232                 }
  9198         AddToRedrawListL( *dirtyRegion, *iCurrentView );
  9233             aNode = iCurrentView;        
       
  9234             }
       
  9235 
       
  9236         // Add to redraw list
       
  9237         AddToRedrawListL( aNode );
       
  9238         }
  9199         }
  9239     else
  9200     else
  9240         {
  9201         {
  9241         // Add to dirty list for relayout and redraw
  9202         TXnDirtyRegion* dirtyRegion( FindDirtyRegionL( *aNode ) );
  9242         AddToDirtyListL( aNode );
  9203         if( !dirtyRegion )
       
  9204             {
       
  9205             return;
       
  9206             }
       
  9207         
       
  9208         if ( aNode->Type()->Type() == KMenuBar )
       
  9209             {
       
  9210             dirtyRegion->iLayoutControl |= XnLayoutControl::ERefreshMenu;
       
  9211             return;
       
  9212             }
       
  9213     
       
  9214         if ( dirtyRegion->iLayoutControl & XnLayoutControl::EViewDirty )
       
  9215             {
       
  9216             // nothing to do
       
  9217             return;
       
  9218             }
       
  9219     
       
  9220         if ( aLevel == XnDirtyLevel::ERender )
       
  9221             {
       
  9222             if( aNode == RootNode() )        
       
  9223                 {
       
  9224                 TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *iCurrentView );
       
  9225                 if( dirtyRegion )
       
  9226                     {
       
  9227                     dirtyRegion->iRegion.Clear();                
       
  9228                     }
       
  9229                 aNode = iCurrentView;        
       
  9230                 }
       
  9231     
       
  9232             // Add to redraw list
       
  9233             AddToRedrawListL( *dirtyRegion, *aNode );
       
  9234             }
       
  9235         else
       
  9236             {
       
  9237             // Add to dirty list for relayout and redraw
       
  9238             AddToDirtyListL( *dirtyRegion, *aNode );
       
  9239             }    
  9243         }
  9240         }
  9244     }
  9241     }
  9245 
  9242 
  9246 // -----------------------------------------------------------------------------
  9243 // -----------------------------------------------------------------------------
  9247 // CXnUiEngineImpl::ScreenDeviceSize
  9244 // CXnUiEngineImpl::ScreenDeviceSize
  9595 
  9592 
  9596 // -----------------------------------------------------------------------------
  9593 // -----------------------------------------------------------------------------
  9597 // CXnUiEngineImpl::IsLayoutDisabled
  9594 // CXnUiEngineImpl::IsLayoutDisabled
  9598 // -----------------------------------------------------------------------------
  9595 // -----------------------------------------------------------------------------
  9599 //
  9596 //
  9600 TBool CXnUiEngineImpl::IsLayoutDisabled()
  9597 TBool CXnUiEngineImpl::IsLayoutDisabled( TXnDirtyRegion& aDirtyRegion )
  9601     {
  9598     {
  9602     if ( !iCurrentView )
  9599     if ( !iCurrentView )
  9603         {
  9600         {
  9604         return ETrue;
  9601         return ETrue;
  9605         }
  9602         }
  9606     
  9603 
  9607     TBool retval( EFalse );
  9604     TBool retval( EFalse );
  9608     
  9605     
  9609     if ( !( iLayoutControl & XnLayoutControl::EIgnoreState ) )
  9606     if ( !( aDirtyRegion.iLayoutControl & XnLayoutControl::EIgnoreState ) )
  9610         {
  9607         {
  9611         if ( iDisableCount > 0 )
  9608         if ( iDisableCount > 0 )
  9612             {
  9609             {
  9613             retval = ETrue;
  9610             retval = ETrue;
  9614             }
  9611             }
  9620 // -----------------------------------------------------------------------------
  9617 // -----------------------------------------------------------------------------
  9621 // AddToRedrawListL
  9618 // AddToRedrawListL
  9622 // Mark Control's appearance to be redrawn
  9619 // Mark Control's appearance to be redrawn
  9623 // -----------------------------------------------------------------------------    
  9620 // -----------------------------------------------------------------------------    
  9624 //
  9621 //
  9625 void CXnUiEngineImpl::AddToRedrawListL( CXnNode* aNode, TRect aRect )
  9622 void CXnUiEngineImpl::AddToRedrawListL( TXnDirtyRegion& aRegion, 
       
  9623     CXnNode& aNode, TRect aRect )
  9626     {   
  9624     {   
  9627     CXnControlAdapter* aAdapter( aNode->Control() );
  9625     CXnControlAdapter* aAdapter( aNode.Control() );
  9628            
  9626            
  9629     if( !aAdapter ) 
  9627     if( !aAdapter ) 
  9630         {
  9628         {
  9631         return;
  9629         return;
  9632         }
  9630         }
  9633 
  9631 
  9634     if( aRect != TRect::EUninitialized )
  9632     if( aRect != TRect::EUninitialized )
  9635         {
  9633         {
  9636         // This is the new rect which will be set by layout algo
  9634         // This is the new rect which will be set by layout algo
  9637         AddRedrawRectL( aRect, *aNode );
  9635         aRegion.iRegion.AddRect( aRect );
       
  9636         aRegion.iRegion.Tidy();
  9638         }
  9637         }
  9639     
  9638     
  9640     TRect rect( aAdapter->Rect() );
  9639     TRect rect( aAdapter->Rect() );
  9641             
  9640             
  9642     if( rect == TRect::EUninitialized )
  9641     if( rect == TRect::EUninitialized )
  9643         {
  9642         {
  9644         // Don't add uninitialized rect
  9643         // Don't add uninitialized rect
  9645         return;
  9644         return;
  9646         }
  9645         }
  9647 
  9646     
  9648     /*
  9647     GrowIfNeeded( &aNode, rect );   
  9649     if( aNode->IsStateSet( XnPropertyNames::style::common::KFocus ) )
  9648 
  9650         {
  9649     aRegion.iRegion.AddRect( rect );        
  9651         const TDesC8& name( aNode->DomNode()->Name() );
  9650     aRegion.iRegion.Tidy();
  9652 
       
  9653         if( name == KPlugin )
       
  9654             {
       
  9655             rect.Grow( KFocusGrowValue, KFocusGrowValue );
       
  9656             }
       
  9657         else
       
  9658             {
       
  9659             TRect marginRect( aNode->MarginRect() );
       
  9660             
       
  9661             CXnNode* parent( aNode->Parent() );
       
  9662             
       
  9663             for( ; parent; parent = parent->Parent() )
       
  9664                 {
       
  9665                 if( parent->DomNode()->Name() == KPlugin )
       
  9666                     {
       
  9667                     if( parent->Rect() == marginRect )
       
  9668                         {
       
  9669                         rect.Grow( KFocusGrowValue, KFocusGrowValue );
       
  9670                         }
       
  9671                     
       
  9672                     break;
       
  9673                     } 
       
  9674                 }                
       
  9675             }
       
  9676         }
       
  9677         */
       
  9678     GrowIfNeeded(aNode, rect);    
       
  9679     AddRedrawRectL( rect, *aNode );                          
       
  9680     }
  9651     }
  9681 
  9652 
  9682 // -----------------------------------------------------------------------------
  9653 // -----------------------------------------------------------------------------
  9683 // AddToDirtyListL
  9654 // AddToDirtyListL
  9684 // Mark node to dirty list for relayout
  9655 // Mark node to dirty list for relayout
  9685 // -----------------------------------------------------------------------------
  9656 // -----------------------------------------------------------------------------
  9686 //
  9657 //
  9687 void CXnUiEngineImpl::AddToDirtyListL( CXnNode* aNode )
  9658 void CXnUiEngineImpl::AddToDirtyListL( TXnDirtyRegion& aRegion, CXnNode& aNode )
  9688     {
  9659     {
  9689     
  9660     CXnNode* nodeToRedrawList( &aNode );
  9690     if ( aNode )
  9661     CXnNode* nodeToDirtyList( &aNode );
  9691         {
  9662 
  9692         CXnNode* nodeToRedrawList( aNode );
  9663     if ( !IsAbsoluteL( aNode ) && !IsNodeTooltip( aNode ) )
  9693         CXnNode* nodeToDirtyList( aNode );
  9664         {
  9694     
  9665         // Check adaptives in normal flow
  9695         if ( aNode == RootNode() )
  9666         CXnNode* oldest( NULL );
  9696             {
  9667         CXnNode* adaptive( &aNode );
  9697             // Force relayout and redraw from current view
  9668 
  9698             iDirtyList.Reset();
  9669         if ( !aNode.IsAdaptive( ETrue ) )
  9699             if ( !iCurrentView )
  9670             {
  9700                 {
  9671             adaptive = aNode.Parent();
  9701                 iCurrentView = iViewManager.ViewNode();
  9672             }
  9702                 }
  9673 
  9703             iDirtyList.AppendL( iCurrentView );
  9674         for ( ; adaptive && adaptive->IsAdaptive( ETrue );
  9704             TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *iCurrentView );
  9675             adaptive = adaptive->Parent() )
  9705             if( dirtyRegion )
  9676             {
  9706                 {
  9677             oldest = adaptive;
  9707                 dirtyRegion->iRegion.Clear();        
  9678             }
  9708                 }
  9679 
  9709             iLayoutControl |= XnLayoutControl::EViewDirty;
  9680         // Now we have found the oldest adaptive node if present
  9710             nodeToDirtyList = nodeToRedrawList = iCurrentView;
  9681         if ( oldest )
  9711             nodeToDirtyList->ClearRenderedAndLaidOut();
  9682             {
  9712     
  9683             nodeToRedrawList = nodeToDirtyList = adaptive;
  9713             // Add to draw list for redraw
  9684             }
  9714             AddToRedrawListL( nodeToRedrawList );
  9685         }
  9715             }
  9686 
  9716         else
  9687     RPointerArray< CXnNode > dirtyList;
  9717             {
  9688     CleanupClosePushL( dirtyList );
  9718             if ( !IsAbsoluteL( *aNode ) && !IsNodeTooltip( *aNode ) )
  9689     TInt count( aRegion.iDirtyList.Count() );
  9719                 {
  9690     TBool found;
  9720                 // Check adaptives in normal flow
  9691 
  9721                 CXnNode* oldest( NULL );
  9692     // first, check that aNode's children are not in the dirty array
  9722                 CXnNode* adaptive( aNode );
  9693     for ( TInt i = 0; i < count; ++i )
  9723     
  9694         {
  9724                 if ( !aNode->IsAdaptive( ETrue ) )
  9695         found = EFalse;
  9725                     {
  9696         CXnNode* candidate( aRegion.iDirtyList[i] );
  9726                     adaptive = aNode->Parent();
  9697 
  9727                     }
  9698         for ( CXnNode* node = candidate->Parent(); node && !found;
  9728     
  9699             node = node->Parent() )
  9729                 for ( ; adaptive && adaptive->IsAdaptive( ETrue );
  9700             {
  9730                     adaptive = adaptive->Parent() )
  9701             if ( nodeToDirtyList == node )
  9731                     {
  9702                 {
  9732                     oldest = adaptive;
  9703                 found = ETrue;
  9733                     }
  9704                 }
  9734     
  9705             }
  9735                 // Now we have found the oldest adaptive node if present
  9706 
  9736                 if ( oldest )
  9707         if ( !found )
  9737                     {
  9708             {
  9738                     nodeToRedrawList = nodeToDirtyList = adaptive;
  9709             // Put candidate back to list as child is not found
  9739                     }
  9710             dirtyList.AppendL( candidate );
  9740                 }
  9711             }
  9741     
  9712         }
  9742             RPointerArray< CXnNode > dirtyList;
  9713 
  9743             CleanupClosePushL( dirtyList );
  9714     found = EFalse;
  9744             TInt count( iDirtyList.Count() );
  9715 
  9745             TBool found;
  9716     // second, check that aNode's parent is not in dirty array
  9746     
  9717     for ( TInt i = 0; i < count && !found; ++i )
  9747             // first, check that aNode's children are not in the dirty array
  9718         {
  9748             for ( TInt i = 0; i < count; ++i )
  9719         CXnNode* candidate( aRegion.iDirtyList[i] );
  9749                 {
  9720 
  9750                 found = EFalse;
  9721         for ( CXnNode* node = nodeToDirtyList; node && !found;
  9751                 CXnNode* candidate( iDirtyList[i] );
  9722             node = node->Parent() )
  9752     
  9723             {
  9753                 for ( CXnNode* node = candidate->Parent(); node && !found;
  9724             if ( node == candidate )
  9754                     node = node->Parent() )
  9725                 {
  9755                     {
  9726                 found = ETrue;
  9756                     if ( nodeToDirtyList == node )
  9727                 }
  9757                         {
  9728             }
  9758                         found = ETrue;
  9729         }
  9759                         }
  9730 
  9760                     }
  9731     if ( !found && aRegion.iDirtyList.Find( nodeToDirtyList ) == KErrNotFound )
  9761     
  9732         {
  9762                 if ( !found )
  9733         // Add node to dirty list as parent is neither found
  9763                     {
  9734         dirtyList.AppendL( nodeToDirtyList );
  9764                     // Put candidate back to list as child is not found
  9735         nodeToDirtyList->ClearRenderedAndLaidOut();
  9765                     dirtyList.AppendL( candidate );
  9736         
  9766                     }
  9737         // Add to draw list for redraw
  9767                 }
  9738         AddToRedrawListL( aRegion, *nodeToRedrawList );
  9768     
  9739         }
  9769             found = EFalse;
  9740 
  9770     
  9741     // finally update the dirty list
  9771             // second, check that aNode's parent is not in dirty array
  9742     aRegion.iDirtyList.Reset();
  9772             for ( TInt i = 0; i < count && !found; ++i )
  9743     aRegion.iDirtyList = dirtyList;
  9773                 {
  9744 
  9774                 CXnNode* candidate( iDirtyList[i] );
  9745     CleanupStack::Pop( &dirtyList );
  9775     
       
  9776                 for ( CXnNode* node = nodeToDirtyList; node && !found;
       
  9777                     node = node->Parent() )
       
  9778                     {
       
  9779                     if ( node == candidate )
       
  9780                         {
       
  9781                         found = ETrue;
       
  9782                         }
       
  9783                     }
       
  9784                 }
       
  9785     
       
  9786             if ( !found && iDirtyList.Find( nodeToDirtyList ) == KErrNotFound )
       
  9787                 {
       
  9788                 // Add node to dirty list as parent is neither found
       
  9789                 dirtyList.AppendL( nodeToDirtyList );
       
  9790                 nodeToDirtyList->ClearRenderedAndLaidOut();
       
  9791                 
       
  9792                 // Add to draw list for redraw
       
  9793                 AddToRedrawListL( nodeToRedrawList );
       
  9794                 }
       
  9795     
       
  9796             // finally update the dirty list
       
  9797             iDirtyList.Reset();
       
  9798             iDirtyList = dirtyList;
       
  9799     
       
  9800             CleanupStack::Pop( &dirtyList );
       
  9801             }
       
  9802         }
       
  9803     }
  9746     }
  9804 
  9747 
  9805 // -----------------------------------------------------------------------------
  9748 // -----------------------------------------------------------------------------
  9806 // CXnUiEngineImpl::SetClientRectL
  9749 // CXnUiEngineImpl::SetClientRectL
  9807 // -----------------------------------------------------------------------------
  9750 // -----------------------------------------------------------------------------
  9860 
  9803 
  9861 // -----------------------------------------------------------------------------
  9804 // -----------------------------------------------------------------------------
  9862 // CXnUiEngineImpl::StartLayoutFromL
  9805 // CXnUiEngineImpl::StartLayoutFromL
  9863 // -----------------------------------------------------------------------------
  9806 // -----------------------------------------------------------------------------
  9864 //
  9807 //
  9865 CXnNode* CXnUiEngineImpl::StartLayoutFromL()
  9808 CXnNode* CXnUiEngineImpl::StartLayoutFromL( TXnDirtyRegion& aDirtyRegion )
  9866     {
  9809     {
  9867     if ( iLayoutControl & XnLayoutControl::EViewDirty )
  9810     CXnNode* viewNode( aDirtyRegion.iRootNode );
  9868         {
  9811     if( !viewNode )
  9869         return iCurrentView;
  9812         {
       
  9813         return NULL;    
       
  9814         }
       
  9815     
       
  9816     if ( aDirtyRegion.iLayoutControl & XnLayoutControl::EViewDirty )
       
  9817         {
       
  9818         return viewNode;
  9870         }
  9819         }
  9871 
  9820 
  9872     RPointerArray< CXnNode >parentArray;
  9821     RPointerArray< CXnNode >parentArray;
  9873     CleanupClosePushL( parentArray );
  9822     CleanupClosePushL( parentArray );
  9874     TInt dirtyCount = iDirtyList.Count();
  9823     TInt dirtyCount = aDirtyRegion.iDirtyList.Count();
  9875     CXnNode* startNode( NULL );
  9824     CXnNode* startNode( NULL );
  9876 
  9825 
  9877     for ( TInt dirtyIndex = 0; dirtyIndex < dirtyCount; dirtyIndex++ )
  9826     for ( TInt dirtyIndex = 0; dirtyIndex < dirtyCount; dirtyIndex++ )
  9878         {
  9827         {
  9879         startNode = iDirtyList[dirtyIndex];
  9828         startNode = aDirtyRegion.iDirtyList[dirtyIndex];
  9880 
  9829 
  9881         for ( ;startNode && startNode != iCurrentView; )
  9830         for ( ;startNode && startNode != viewNode; )
  9882             {
  9831             {
  9883             parentArray.Append( startNode->Parent() );
  9832             parentArray.Append( startNode->Parent() );
  9884             startNode = startNode->Parent();
  9833             startNode = startNode->Parent();
  9885             }
  9834             }
  9886         }
  9835         }
  9907             }
  9856             }
  9908         }
  9857         }
  9909 
  9858 
  9910     CleanupStack::PopAndDestroy( &parentArray );
  9859     CleanupStack::PopAndDestroy( &parentArray );
  9911 
  9860 
  9912     return iCurrentView;
  9861     return viewNode;
  9913     }
  9862     }
  9914 
  9863 
  9915 // -----------------------------------------------------------------------------
  9864 // -----------------------------------------------------------------------------
  9916 // CXnUiEngineImpl::Plugins
  9865 // CXnUiEngineImpl::Plugins
  9917 // -----------------------------------------------------------------------------
  9866 // -----------------------------------------------------------------------------
  9925 // CXnUiEngineImpl::ForceRenderUIL
  9874 // CXnUiEngineImpl::ForceRenderUIL
  9926 // -----------------------------------------------------------------------------
  9875 // -----------------------------------------------------------------------------
  9927 //
  9876 //
  9928 void CXnUiEngineImpl::ForceRenderUIL( TBool aLayoutOnly )
  9877 void CXnUiEngineImpl::ForceRenderUIL( TBool aLayoutOnly )
  9929     {
  9878     {
  9930     iLayoutControl |= XnLayoutControl::EIgnoreState;
  9879     TXnDirtyRegion* dirtyRegion = FindDirtyRegionL( *iCurrentView );
       
  9880     if( !dirtyRegion )
       
  9881         {
       
  9882         return;
       
  9883         }
       
  9884     
       
  9885     dirtyRegion->iLayoutControl |= XnLayoutControl::EIgnoreState;
       
  9886     
  9931     if ( aLayoutOnly )
  9887     if ( aLayoutOnly )
  9932         {
  9888         {
  9933         LayoutUIL();
  9889         LayoutUIL();
  9934         }
  9890         }
  9935     else
  9891     else
  9936         {
  9892         {
  9937         LayoutUIL();
  9893         LayoutUIL();
  9938         RenderUIL();
  9894         RenderUIL();
  9939         }
  9895         }
  9940     iLayoutControl &= ~XnLayoutControl::EIgnoreState;
  9896     
       
  9897     dirtyRegion->iLayoutControl &= ~XnLayoutControl::EIgnoreState;
  9941     }
  9898     }
  9942 
  9899 
  9943 // -----------------------------------------------------------------------------
  9900 // -----------------------------------------------------------------------------
  9944 // CXnUiEngineImpl::GetThemeResource
  9901 // CXnUiEngineImpl::GetThemeResource
  9945 // -----------------------------------------------------------------------------
  9902 // -----------------------------------------------------------------------------
 10083         {
 10040         {
 10084         self->iDisableCount--;
 10041         self->iDisableCount--;
 10085         
 10042         
 10086         if ( self->iDisableCount == 0 )
 10043         if ( self->iDisableCount == 0 )
 10087             {
 10044             {
 10088             TRAP_IGNORE(                    
 10045             TRAP_IGNORE( self->EnableRenderUiL() );            
       
 10046             }
       
 10047         }
       
 10048     }
       
 10049 
       
 10050 // -----------------------------------------------------------------------------
       
 10051 // -----------------------------------------------------------------------------
       
 10052 //               
       
 10053 void CXnUiEngineImpl::EnableRenderUiL()
       
 10054     {
       
 10055     CXnViewData* viewData = iViewManager.ActiveAppData().ViewData( *iCurrentView );
       
 10056     if( viewData )
       
 10057         {
       
 10058         RPointerArray<TXnDirtyRegion> arr;
       
 10059         CleanupClosePushL( arr );
       
 10060         
       
 10061         viewData->GetDirtyRegions( arr );
       
 10062 
       
 10063         for( TInt i = 0; i < arr.Count(); i++ )
       
 10064             {
       
 10065             TXnDirtyRegion* dirtyRegion = arr[i];
       
 10066 
 10089             // Is menu refresh pending?
 10067             // Is menu refresh pending?
 10090             if ( ( self->iLayoutControl & XnLayoutControl::ERefreshMenu ) &&
 10068             if ( ( dirtyRegion->iLayoutControl & XnLayoutControl::ERefreshMenu ) &&
 10091                    !self->IsMenuDisplaying() )
 10069                    IsMenuDisplaying() )
 10092                 {
 10070                 {
 10093                 // RefreshMenuL will reset the state flag
 10071                 // RefreshMenuL will reset the state flag
 10094                 self->RefreshMenuL();
 10072                 RefreshMenuL( dirtyRegion );
 10095                 }
 10073                 }
 10096 
 10074             
 10097             // Is layout pending?
 10075             // Is layout pending?
 10098             if ( self->iLayoutControl & XnLayoutControl::ELayoutUI )
 10076             if ( dirtyRegion->iLayoutControl & XnLayoutControl::ELayoutUI )
 10099                 {
 10077                 {
 10100                 self->LayoutUIL();
 10078                 LayoutL( *dirtyRegion );
 10101                 }
 10079                 }
 10102 
 10080         
 10103             // Is render pending?
 10081             // Is render pending?
 10104             if ( self->iLayoutControl & XnLayoutControl::ERenderUI )
 10082             if ( dirtyRegion->iLayoutControl & XnLayoutControl::ERenderUI )
 10105                 {
 10083                 {
 10106                 self->RenderUIL();
 10084                 RenderL( *dirtyRegion );
 10107                 }
 10085                 }
 10108                 );
 10086             }
 10109             }
 10087         CleanupStack::PopAndDestroy( &arr);
 10110         }
 10088         }
 10111     }
 10089     }
 10112 
 10090                 
 10113 // -----------------------------------------------------------------------------
 10091 // -----------------------------------------------------------------------------
 10114 // -----------------------------------------------------------------------------
 10092 // -----------------------------------------------------------------------------
 10115 //
 10093 //
 10116 void CXnUiEngineImpl::ReportScreenDeviceChangeL()
 10094 void CXnUiEngineImpl::ReportScreenDeviceChangeL()
 10117     {    
 10095     {    
 10120         iViewManager.ActiveAppData().PluginData() );
 10098         iViewManager.ActiveAppData().PluginData() );
 10121 
 10099 
 10122     for( TInt i = 0; i < plugins.Count(); i++ )
 10100     for( TInt i = 0; i < plugins.Count(); i++ )
 10123         {        
 10101         {        
 10124         ReportScreenDeviceChangedL( *plugins[i] );
 10102         ReportScreenDeviceChangedL( *plugins[i] );
       
 10103         CXnDomNode* domNode( plugins[i]->Node() );
       
 10104         if( domNode )
       
 10105             {
       
 10106             CXnNode* node( domNode->LayoutNode() );
       
 10107             if( node )
       
 10108                 {
       
 10109                 node->SetDirtyL();
       
 10110                 }
       
 10111             }
 10125         }
 10112         }
 10126     }
 10113     }
 10127 
 10114 
 10128 // -----------------------------------------------------------------------------
 10115 // -----------------------------------------------------------------------------
 10129 // CXnUiEngineImpl::HandlePartialTouchInputL()
 10116 // CXnUiEngineImpl::HandlePartialTouchInputL()
 10233         }
 10220         }
 10234     }
 10221     }
 10235 
 10222 
 10236 // -----------------------------------------------------------------------------
 10223 // -----------------------------------------------------------------------------
 10237 // -----------------------------------------------------------------------------
 10224 // -----------------------------------------------------------------------------
 10238 CCoeControl* CXnUiEngineImpl::WindowOwningControl( CXnNode& aNode )
 10225 CXnNode* CXnUiEngineImpl::WindowOwningNode( CXnNode& aNode )
 10239     {
 10226     {
 10240     CXnNode* parent = &aNode;
 10227     CXnNode* parent = &aNode;
 10241     while( parent )
 10228     while( parent )
 10242         {
 10229         {
 10243         CXnControlAdapter* adapter = parent->Control();
 10230         CXnControlAdapter* adapter = parent->Control();
 10244         if( adapter )
 10231         if( adapter )
 10245             {
 10232             {
 10246             if( parent->ViewNodeImpl() && 
 10233             if( parent->ViewNodeImpl() && 
 10247                 adapter == iCurrentViewControlAdapter )
 10234                 adapter == iCurrentViewControlAdapter )
 10248                 {
 10235                 {
 10249                 return adapter;
 10236                 return parent;
 10250                 }
 10237                 }
 10251             else if( adapter->OwnsWindow() )
 10238             else if( adapter->OwnsWindow() )
 10252                 {
 10239                 {
 10253                 if( !IsNodeTooltip( *parent ) )
 10240                 if( !IsNodeTooltip( *parent ) )
 10254                     {
 10241                     {
 10255                     return adapter;
 10242                     return parent;
 10256                     }
 10243                     }
 10257                 else
 10244                 else
 10258                     {
 10245                     {
 10259                     return NULL;
 10246                     return NULL;
 10260                     }                
 10247                     }                
 10267 
 10254 
 10268 // -----------------------------------------------------------------------------
 10255 // -----------------------------------------------------------------------------
 10269 // -----------------------------------------------------------------------------
 10256 // -----------------------------------------------------------------------------
 10270 TXnDirtyRegion* CXnUiEngineImpl::FindDirtyRegionL( CXnNode& aNode )
 10257 TXnDirtyRegion* CXnUiEngineImpl::FindDirtyRegionL( CXnNode& aNode )
 10271     {
 10258     {
 10272     CCoeControl* control = WindowOwningControl( aNode );
 10259     CXnNode* node( WindowOwningNode( aNode ) );
       
 10260     if( !node )
       
 10261         {
       
 10262         return NULL;
       
 10263         }
       
 10264     
       
 10265     CCoeControl* control( node->Control() );  
 10273     if( !control )
 10266     if( !control )
 10274         {
 10267         {
 10275         return NULL;
 10268         return NULL;
 10276         }
 10269         }
 10277     for( TInt i=0; i<iRedrawRegions.Count(); i++ )
 10270 
 10278         {
 10271     TXnDirtyRegion* region( NULL );
 10279         if( iRedrawRegions[i]->iControl == control )
 10272     CXnViewData* viewData = iViewManager.ActiveAppData().ViewData( *node );
 10280             {
 10273     if( viewData )
 10281             return iRedrawRegions[i];
 10274         {
 10282             }
 10275         region = viewData->DirtyRegionL( *node );
 10283         }
 10276         }
 10284     TXnDirtyRegion* region = new (ELeave) TXnDirtyRegion;
 10277     
 10285     CleanupStack::PushL( region );
       
 10286     region->iControl = control;
       
 10287     iRedrawRegions.AppendL( region );
       
 10288     CleanupStack::Pop();
       
 10289     return region;
 10278     return region;
 10290     }
       
 10291 
       
 10292 // -----------------------------------------------------------------------------
       
 10293 // -----------------------------------------------------------------------------
       
 10294 void CXnUiEngineImpl::AddRedrawRectL( TRect aRect, CXnNode& aNode )
       
 10295     {
       
 10296     TXnDirtyRegion* dirtyReg = FindDirtyRegionL( aNode );
       
 10297     if( dirtyReg )
       
 10298         {
       
 10299         dirtyReg->iRegion.AddRect( aRect );        
       
 10300         dirtyReg->iRegion.Tidy();
       
 10301         }
       
 10302     }
 10279     }
 10303 
 10280 
 10304 // -----------------------------------------------------------------------------
 10281 // -----------------------------------------------------------------------------
 10305 // SetEventDispatcher
 10282 // SetEventDispatcher
 10306 // -----------------------------------------------------------------------------
 10283 // -----------------------------------------------------------------------------