]> git.sesse.net Git - vlc/commitdiff
skins2: optimize refresh of text control
authorErwan Tulou <erwan10@videolan.org>
Thu, 29 Jul 2010 13:58:51 +0000 (15:58 +0200)
committerErwan Tulou <erwan10@videolan.org>
Thu, 29 Jul 2010 14:41:54 +0000 (16:41 +0200)
text controls were far from being optimized
   - a notifyLayout was executed at creation of text control, leading
     to rebuilding the layout twice.
   - the init of the variable was done after the control was created
     which means still more rebuild of the layout.

This patch ensures that no rebuild is done at init since we are already in the
process of rebuilding the entire layout.

modules/gui/skins2/controls/ctrl_text.cpp
modules/gui/skins2/parser/builder.cpp

index a6c90a03886824238f498f019d0dc5135eb0a7e1..867c6612367d814e530e8bbb486b1d412325b6dd 100644 (file)
@@ -207,6 +207,7 @@ void CtrlText::onUpdate( Subject<VarText> &rVariable, void* arg )
     if( isVisible() )
     {
         displayText( m_rVariable.get() );
+        notifyLayout( getPosition()->getWidth(), getPosition()->getHeight() );
     }
 }
 
@@ -219,6 +220,7 @@ void CtrlText::onUpdate( Subject<VarBool> &rVariable, void *arg  )
         if( isVisible() )
         {
             displayText( m_rVariable.get() );
+            notifyLayout( getPosition()->getWidth(), getPosition()->getHeight() );
         }
         else
         {
@@ -278,7 +280,6 @@ void CtrlText::displayText( const UString &rText )
                 m_pTimer->stop();
             }
         }
-        notifyLayout( getPosition()->getWidth(), getPosition()->getHeight() );
     }
 }
 
index 6981757b4cc322cf02aa83a78c995819f58b8f9a..72efbe6840f3faac7ba0ed0f6be974c977a59b12 100644 (file)
@@ -722,6 +722,10 @@ void Builder::addText( const BuilderData::Text &rData )
     VarText *pVar = new VarText( getIntf() );
     m_pTheme->m_vars.push_back( VariablePtr( pVar ) );
 
+    // Set the text of the control
+    UString msg( getIntf(), rData.m_text.c_str() );
+    pVar->set( msg );
+
     // Get the visibility variable
     // XXX check when it is null
     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
@@ -744,9 +748,6 @@ void Builder::addText( const BuilderData::Text &rData )
 
     pLayout->addControl( pText, pos, rData.m_layer );
 
-    // Set the text of the control
-    UString msg( getIntf(), rData.m_text.c_str() );
-    pVar->set( msg );
 }