[vlc-commits] skins2: fix art file failing to display when changing skin theme

Erwan Tulou git at videolan.org
Sun Jan 27 17:53:12 CET 2013


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Sun Jan 27 17:32:02 2013 +0100| [d4f540aa7c663945df64538c09b2c9f4cc098e22] | committer: Erwan Tulou

skins2: fix art file failing to display when changing skin theme

When changing a skin theme on the fly, an input may already be running
 and the art file is expected to display in the new theme.

This patch takes into account a possible art file already kwown
at initialisation of a new image control with art enabled.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d4f540aa7c663945df64538c09b2c9f4cc098e22
---

 modules/gui/skins2/controls/ctrl_image.cpp |   26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/modules/gui/skins2/controls/ctrl_image.cpp b/modules/gui/skins2/controls/ctrl_image.cpp
index cb60e3f..5ffe87a 100644
--- a/modules/gui/skins2/controls/ctrl_image.cpp
+++ b/modules/gui/skins2/controls/ctrl_image.cpp
@@ -41,18 +41,31 @@ CtrlImage::CtrlImage( intf_thread_t *pIntf, GenericBitmap &rBitmap,
     m_rCommand( rCommand ), m_resizeMethod( resizeMethod ), m_art( art ),
     m_x( 0 ), m_y( 0 )
 {
-    // Create an initial unscaled image in the buffer
-    m_pImage = OSFactory::instance( pIntf )->createOSGraphics(
-                                    rBitmap.getWidth(), rBitmap.getHeight() );
-    m_pImage->drawBitmap( *m_pBitmap );
-
-    // Observe the variable
     if( m_art )
     {
+        // art file if any will overwrite the original image
         VlcProc *pVlcProc = VlcProc::instance( getIntf() );
+        ArtManager* pArtManager = ArtManager::instance( getIntf() );
+
+        // add observer
         pVlcProc->getStreamArtVar().addObserver( this );
+
+        // retrieve initial state of art file
+        string str = pVlcProc->getStreamArtVar().get();
+        GenericBitmap* pArt = (GenericBitmap*) pArtManager->getArtBitmap( str );
+        if( pArt )
+        {
+            m_pBitmap = pArt;
+            msg_Dbg( getIntf(), "art file %s to be displayed (wxh = %ix%i)",
+                str.c_str(), m_pBitmap->getWidth(), m_pBitmap->getHeight() );
+        }
     }
 
+    // Create the initial image
+    m_pImage = OSFactory::instance( getIntf() )->createOSGraphics(
+                                    m_pBitmap->getWidth(),
+                                    m_pBitmap->getHeight() );
+    m_pImage->drawBitmap( *m_pBitmap );
 }
 
 
@@ -250,7 +263,6 @@ void CtrlImage::onUpdate( Subject<VarString> &rVariable, void* arg )
         GenericBitmap* pArt = (GenericBitmap*) pArtManager->getArtBitmap( str );
 
         m_pBitmap = pArt ? pArt : m_pOriginalBitmap;
-
         msg_Dbg( getIntf(), "art file %s to be displayed (wxh = %ix%i)",
                             str.c_str(),
                             m_pBitmap->getWidth(),



More information about the vlc-commits mailing list