]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/tooltip.cpp
Qt: iconView delegate: encode PLModel::IsCurrent(QModelIndex) into cache key
[vlc] / modules / gui / skins2 / src / tooltip.cpp
index 2378f42c0d82963a3fbe9b50dec76b8563dc28ae..644ef7950d14590bff8bdbbbfad0249e37149810 100644 (file)
@@ -5,7 +5,7 @@
  * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
- *          Olivier Teulière <ipkiss@via.ecp.fr>
+ *          Olivier Teulière <ipkiss@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #include "tooltip.hpp"
 
 Tooltip::Tooltip( intf_thread_t *pIntf, const GenericFont &rFont, int delay ):
     SkinObject( pIntf ), m_rFont( rFont ), m_delay( delay ), m_pImage( NULL ),
-    m_xPos( -1 ), m_yPos( -1 )
+    m_xPos( -1 ), m_yPos( -1 ), m_cmdShow( this )
 {
     OSFactory *pOsFactory = OSFactory::instance( pIntf );
-    m_pTimer = pOsFactory->createOSTimer( Callback( this, &doShow ) );
+    m_pTimer = pOsFactory->createOSTimer( m_cmdShow );
     m_pOsTooltip = pOsFactory->createOSTooltip();
 
     // Observe the tooltip text variable
@@ -49,12 +49,9 @@ Tooltip::Tooltip( intf_thread_t *pIntf, const GenericFont &rFont, int delay ):
 Tooltip::~Tooltip()
 {
     VarManager::instance( getIntf() )->getTooltipText().delObserver( this );
-    SKINS_DELETE( m_pTimer );
-    SKINS_DELETE( m_pOsTooltip );
-    if( m_pImage )
-    {
-        delete m_pImage;
-    }
+    delete m_pTimer;
+    delete m_pOsTooltip;
+    delete m_pImage;
 }
 
 
@@ -74,7 +71,7 @@ void Tooltip::hide()
 }
 
 
-void Tooltip::onUpdate( Subject<VarText> &rVariable )
+void Tooltip::onUpdate( Subject<VarText> &rVariable , void *arg)
 {
     // Redisplay the tooltip
     displayText( ((VarText&)rVariable).get() );
@@ -106,10 +103,7 @@ void Tooltip::makeImage( const UString &rText )
     int h = m_rFont.getSize() + 8;
 
     // Create the image of the tooltip
-    if( m_pImage )
-    {
-        delete m_pImage;
-    }
+    delete m_pImage;
     m_pImage = OSFactory::instance( getIntf() )->createOSGraphics( w, h );
     m_pImage->fillRect( 0, 0, w, h, 0xffffd0 );
     m_pImage->drawRect( 0, 0, w, h, 0x000000 );
@@ -119,22 +113,20 @@ void Tooltip::makeImage( const UString &rText )
 }
 
 
-void Tooltip::doShow( SkinObject *pObj )
+void Tooltip::CmdShow::execute()
 {
-    Tooltip *pThis = (Tooltip*)pObj;
-
-    if( pThis->m_pImage )
+    if( m_pParent->m_pImage )
     {
-        if( pThis->m_xPos == -1 )
+        if( m_pParent->m_xPos == -1 )
         {
             // Get the mouse coordinates and the image size
-            OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
+            OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
             int x, y;
             pOsFactory->getMousePos( x, y );
             int scrWidth = pOsFactory->getScreenWidth();
             int scrHeight = pOsFactory->getScreenHeight();
-            int w = pThis->m_pImage->getWidth();
-            int h = pThis->m_pImage->getHeight();
+            int w = m_pParent->m_pImage->getWidth();
+            int h = m_pParent->m_pImage->getHeight();
 
             // Compute the position of the tooltip
             x -= (w / 2 + 4);
@@ -146,13 +138,13 @@ void Tooltip::doShow( SkinObject *pObj )
             if( y + h > scrHeight )
                 y -= (2 * h + 20);
 
-            pThis->m_xPos = x;
-            pThis->m_yPos = y;
+            m_pParent->m_xPos = x;
+            m_pParent->m_yPos = y;
         }
 
         // Show the tooltip window
-        pThis->m_pOsTooltip->show( pThis->m_xPos, pThis->m_yPos,
-                                   *(pThis->m_pImage) );
+        m_pParent->m_pOsTooltip->show( m_pParent->m_xPos, m_pParent->m_yPos,
+                                   *(m_pParent->m_pImage) );
     }
 }