]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/controls/ctrl_generic.cpp
skins2: cosmetic
[vlc] / modules / gui / skins2 / controls / ctrl_generic.cpp
index 00c9ba0162dd032b8366789e7251f87fa4ccf02a..7bded8c3b29bb64679013df125ba8a2b8ef0a608 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 "ctrl_generic.hpp"
 #include "../utils/position.hpp"
 #include "../utils/var_bool.hpp"
 
+#include <assert.h>
+
 
 CtrlGeneric::CtrlGeneric( intf_thread_t *pIntf, const UString &rHelp,
                           VarBool *pVisible):
-    SkinObject( pIntf ), m_pLayout( NULL ), m_pPosition( NULL ),
-    m_help( rHelp ), m_pVisible( pVisible )
+    SkinObject( pIntf ), m_pLayout( NULL ), m_pVisible( pVisible ),
+    m_pPosition( NULL ), m_help( rHelp )
 {
     // Observe the visibility variable
     if( m_pVisible )
@@ -45,10 +47,6 @@ CtrlGeneric::CtrlGeneric( intf_thread_t *pIntf, const UString &rHelp,
 
 CtrlGeneric::~CtrlGeneric()
 {
-    if( m_pPosition )
-    {
-        delete m_pPosition;
-    }
     if( m_pVisible )
     {
         m_pVisible->delObserver( this );
@@ -59,19 +57,28 @@ CtrlGeneric::~CtrlGeneric()
 void CtrlGeneric::setLayout( GenericLayout *pLayout,
                              const Position &rPosition )
 {
+    assert( !m_pLayout && pLayout);
+
     m_pLayout = pLayout;
-    if( m_pPosition )
-    {
-        delete m_pPosition;
-    }
     m_pPosition = new Position( rPosition );
     onPositionChange();
 }
 
+void CtrlGeneric::unsetLayout()
+{
+    assert( m_pLayout );
+
+    delete m_pPosition;
+    m_pPosition = NULL;
+    m_pLayout = NULL;
+}
 
 void CtrlGeneric::notifyLayout( int width, int height,
-                                int xOffSet, int yOffSet ) const
+                                int xOffSet, int yOffSet )
 {
+    width = ( width > 0 ) ? width : m_pPosition->getWidth();
+    height = ( height > 0 ) ? height : m_pPosition->getHeight();
+
     // Notify the layout
     if( m_pLayout )
     {
@@ -155,8 +162,9 @@ bool CtrlGeneric::isVisible() const
 }
 
 
-void CtrlGeneric::onUpdate( Subject<VarBool, void*> &rVariable, void *arg  )
+void CtrlGeneric::onUpdate( Subject<VarBool> &rVariable, void *arg  )
 {
+    (void)arg;
     // Is it the visibility variable ?
     if( &rVariable == m_pVisible )
     {