[vlc-commits] skins2: provide more info to help skin developpers debug their skins

Erwan Tulou git at videolan.org
Thu Apr 4 17:39:56 CEST 2013


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Thu Apr  4 15:13:58 2013 +0200| [b97a3ccfc43a00dfc98bbb28d1596a0aafea1b60] | committer: Erwan Tulou

skins2: provide more info to help skin developpers debug their skins

Many skins are buggy because the bitmap sizes or the resize policy
are inconsistent with button or checkbox constraints (fixed size)

This patch will help skin developers pinpoint which button or
checkbox is at fault. In addition, the resize policy will be
corrected (guessed from the lefttop parameter). This will enable
buggy and often unmaintained skins to work fine nevertheless.

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

 modules/gui/skins2/parser/builder.cpp |   69 ++++++++++++++++++++++++++++-----
 1 file changed, 59 insertions(+), 10 deletions(-)

diff --git a/modules/gui/skins2/parser/builder.cpp b/modules/gui/skins2/parser/builder.cpp
index 288afb1..e5b54a0 100644
--- a/modules/gui/skins2/parser/builder.cpp
+++ b/modules/gui/skins2/parser/builder.cpp
@@ -142,6 +142,27 @@ Theme *Builder::build()
         } \
     }
 
+// macro to check bitmap size consistency for button and checkbox
+#define CHECK_BMP( pBmp, pBmpRef, id) \
+    if( pBmp != pBmpRef ) \
+    { \
+        int w_ref = pBmpRef->getWidth(); \
+        int h_ref = pBmpRef->getHeight() / pBmpRef->getNbFrames(); \
+        int w = pBmp->getWidth(); \
+        int h = pBmp->getHeight() / pBmp->getNbFrames(); \
+        if( w != w_ref || h != h_ref ) \
+            msg_Err( getIntf(), "pls, check bitmap sizes for id: %s", id.c_str() ); \
+    }
+
+// macro to check resize policy of button and checkbox
+#define CHECK_RESIZE_POLICY( lefttop, rightbottom, xkeepratio, ykeepratio, id )\
+    if( (!xkeepratio && lefttop != rightbottom) || \
+        (!ykeepratio && lefttop != rightbottom) ) \
+    { \
+        msg_Err( getIntf(), "pls, check resize policy for id: %s", \
+                            id.c_str() ); \
+        rightbottom = lefttop; \
+    }
 
 // Macro to get the parent box of a control, given the panel ID
 #define GET_BOX( pRect, id, pLayout ) \
@@ -467,15 +488,27 @@ void Builder::addButton( const BuilderData::Button &rData )
         UString( getIntf(), rData.m_help.c_str() ), pVisible );
     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pButton );
 
+    // width and height are set up from the 'up' bitmap size
+    int width = pBmpUp->getWidth();
+    int height = pBmpUp->getHeight() / pBmpUp->getNbFrames();
+    bool xkeepratio = rData.m_xKeepRatio;
+    bool ykeepratio = rData.m_yKeepRatio;
+    string lefttop( rData.m_leftTop );
+    string rightbottom( rData.m_rightBottom );
+
+    // various checks to help skin developers debug their skin
+    CHECK_BMP( pBmpDown, pBmpUp, rData.m_id );
+    CHECK_BMP( pBmpOver, pBmpUp, rData.m_id );
+    CHECK_RESIZE_POLICY( lefttop, rightbottom, xkeepratio, ykeepratio,
+                         rData.m_id );
+
     // Compute the position of the control
     // XXX (we suppose all the images have the same size...)
     const GenericRect *pRect;
     GET_BOX( pRect, rData.m_panelId , pLayout);
-    const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
-                             rData.m_xPos, rData.m_yPos,
-                             pBmpUp->getWidth(),
-                             pBmpUp->getHeight() / pBmpUp->getNbFrames(),
-                             *pRect, rData.m_xKeepRatio, rData.m_yKeepRatio );
+    const Position pos = makePosition( lefttop, rightbottom,
+                             rData.m_xPos, rData.m_yPos, width, height,
+                             *pRect, xkeepratio, ykeepratio );
 
     pLayout->addControl( pButton, pos, rData.m_layer );
 }
@@ -536,6 +569,24 @@ void Builder::addCheckbox( const BuilderData::Checkbox &rData )
     // XXX check when it is null
     VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
 
+    // width and height are set up from the 'up1' bitmap size
+    int width = pBmpUp1->getWidth();
+    int height = pBmpUp1->getHeight() / pBmpUp1->getNbFrames();
+    bool xkeepratio = rData.m_xKeepRatio;
+    bool ykeepratio = rData.m_yKeepRatio;
+    string lefttop( rData.m_leftTop );
+    string rightbottom( rData.m_rightBottom );
+
+
+    // various checks to help skin developers debug their skin
+    CHECK_BMP( pBmpDown1, pBmpUp1, rData.m_id );
+    CHECK_BMP( pBmpOver1, pBmpUp1, rData.m_id );
+    CHECK_BMP( pBmpUp2, pBmpUp1, rData.m_id );
+    CHECK_BMP( pBmpDown2, pBmpUp1, rData.m_id );
+    CHECK_BMP( pBmpOver2, pBmpUp1, rData.m_id );
+    CHECK_RESIZE_POLICY( lefttop, rightbottom, xkeepratio, ykeepratio,
+                         rData.m_id );
+
     // Create the control
     CtrlCheckbox *pCheckbox = new CtrlCheckbox( getIntf(), *pBmpUp1,
         *pBmpOver1, *pBmpDown1, *pBmpUp2, *pBmpOver2, *pBmpDown2, *pCommand1,
@@ -548,11 +599,9 @@ void Builder::addCheckbox( const BuilderData::Checkbox &rData )
     // XXX (we suppose all the images have the same size...)
     const GenericRect *pRect;
     GET_BOX( pRect, rData.m_panelId , pLayout);
-    const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
-                            rData.m_xPos, rData.m_yPos,
-                            pBmpUp1->getWidth(),
-                            pBmpUp1->getHeight() / pBmpUp1->getNbFrames(),
-                            *pRect, rData.m_xKeepRatio, rData.m_yKeepRatio );
+    const Position pos = makePosition( lefttop, rightbottom,
+                             rData.m_xPos, rData.m_yPos, width, height,
+                             *pRect, xkeepratio, ykeepratio );
 
     pLayout->addControl( pCheckbox, pos, rData.m_layer );
 }



More information about the vlc-commits mailing list