]> git.sesse.net Git - vlc/commitdiff
* skins2: The Image control now supports the "action2" attribute (feel free to
authorOlivier Teulière <ipkiss@videolan.org>
Mon, 28 Nov 2005 21:01:07 +0000 (21:01 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Mon, 28 Nov 2005 21:01:07 +0000 (21:01 +0000)
   suggest a better name :)), triggered by a double click.
   Very kewl to change the layout...

modules/gui/skins2/controls/ctrl_image.cpp
modules/gui/skins2/controls/ctrl_image.hpp
modules/gui/skins2/parser/builder.cpp
modules/gui/skins2/parser/builder_data.def
modules/gui/skins2/parser/builder_data.hpp
modules/gui/skins2/parser/skin_parser.cpp
share/skins2/skin.dtd

index 99abb95995cf7d7c097ef1d0decc9bf422d9a7c3..2d5dbe3afedec6e27d5bd0bf4d5fbaf8768ede3d 100644 (file)
 
 
 CtrlImage::CtrlImage( intf_thread_t *pIntf, const GenericBitmap &rBitmap,
-                      resize_t resizeMethod, const UString &rHelp,
-                      VarBool *pVisible ):
+                      CmdGeneric &rCommand, resize_t resizeMethod,
+                      const UString &rHelp, VarBool *pVisible ):
     CtrlFlat( pIntf, rHelp, pVisible ), m_rBitmap( rBitmap ),
-    m_resizeMethod( resizeMethod )
+    m_rCommand( rCommand ), m_resizeMethod( resizeMethod )
 {
     OSFactory *pOsFactory = OSFactory::instance( pIntf );
     // Create an initial unscaled image in the buffer
@@ -64,7 +64,10 @@ void CtrlImage::handleEvent( EvtGeneric &rEvent )
         CmdDlgHidePopupMenu cmd( getIntf() );
         cmd.execute();
     }
-
+    else if( rEvent.getAsString() == "mouse:left:dblclick:none" )
+    {
+        m_rCommand.execute();
+    }
 }
 
 
@@ -97,8 +100,8 @@ void CtrlImage::draw( OSGraphics &rImage, int xDest, int yDest )
         if( m_resizeMethod == kScale )
         {
             // Use scaling method
-            if(  width != m_pImage->getWidth() ||
-                 height != m_pImage->getHeight() )
+            if( width != m_pImage->getWidth() ||
+                height != m_pImage->getHeight() )
             {
                 OSFactory *pOsFactory = OSFactory::instance( getIntf() );
                 // Rescale the image with the actual size of the control
index effb253d7c4633b7eaead36a619f0853c6050822..0b821fd4b2d7c5e3dc814ad379d7ca9d525d6350 100644 (file)
@@ -30,6 +30,7 @@
 
 class GenericBitmap;
 class OSGraphics;
+class CmdGeneric;
 
 
 /// Control image
@@ -45,8 +46,8 @@ class CtrlImage: public CtrlFlat
 
         // Create an image with the given bitmap (which is NOT copied)
         CtrlImage( intf_thread_t *pIntf, const GenericBitmap &rBitmap,
-                   resize_t resizeMethod, const UString &rHelp,
-                   VarBool *pVisible );
+                   CmdGeneric &rCommand, resize_t resizeMethod,
+                   const UString &rHelp, VarBool *pVisible );
         virtual ~CtrlImage();
 
         /// Handle an event on the control
@@ -66,6 +67,8 @@ class CtrlImage: public CtrlFlat
         const GenericBitmap &m_rBitmap;
         /// Buffer to stored the rendered bitmap
         OSGraphics *m_pImage;
+        /// Command triggered by a double-click on the image
+        CmdGeneric &m_rCommand;
         /// Resize method
         resize_t m_resizeMethod;
 };
index 4692337e4fa6684ce74b7db8b33210c2de0c4494..555b97a90a6beb2db1e364857d63c16aa2a044a1 100644 (file)
@@ -461,6 +461,13 @@ void Builder::addImage( const BuilderData::Image &rData )
         return;
     }
 
+    CmdGeneric *pCommand = parseAction( rData.m_action2Id );
+    if( pCommand == NULL )
+    {
+        msg_Err( getIntf(), "Invalid action: %s", rData.m_action2Id.c_str() );
+        return;
+    }
+
     // Get the visibility variable
     // XXX check when it is null
     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
@@ -468,8 +475,8 @@ void Builder::addImage( const BuilderData::Image &rData )
 
     CtrlImage::resize_t resizeMethod =
         (rData.m_resize == "scale" ? CtrlImage::kScale : CtrlImage::kMosaic);
-    CtrlImage *pImage = new CtrlImage( getIntf(), *pBmp, resizeMethod,
-        UString( getIntf(), rData.m_help.c_str() ), pVisible );
+    CtrlImage *pImage = new CtrlImage( getIntf(), *pBmp, *pCommand,
+        resizeMethod, UString( getIntf(), rData.m_help.c_str() ), pVisible );
 
     // Compute the position of the control
     const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
index 0f0cfe9c6e01ebe66afab6afffbcf9d526c97528..2fc2f6e67ed0aa4bea09fa4f8cef1f355da17541 100644 (file)
@@ -8,7 +8,7 @@ Layout id:string width:int height:int minWidth:int maxWidth:int minHeight:int ma
 Anchor xPos:int yPos:int range:int priority:int points:string layoutId:string
 Button id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string upId:string downId:string overId:string actionId:string tooltip:string help:string layer:int windowId:string layoutId:string
 Checkbox id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string up1Id:string down1Id:string over1Id:string up2Id:string down2Id:string over2Id:string state:string action1:string action2:string tooltip1:string tooltip2:string help:string layer:int windowId:string layoutId:string
-Image id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string bmpId:string actionId:string resize:string help:string layer:int windowId:string layoutId:string
+Image id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string bmpId:string actionId:string action2Id:string resize:string help:string layer:int windowId:string layoutId:string
 Text id:string xPos:int yPos:int visible:string fontId:string text:string width:int leftTop:string rightBottom:string color:uint32_t scrolling:string alignment:string help:string layer:int windowId:string layoutId:string
 RadialSlider id:string visible:string xPos:int yPos:int leftTop:string rightBottom:string sequence:string nbImages:int minAngle:float maxAngle:float value:string tooltip:string help:string layer:int windowId:string layoutId:string
 Slider id:string visible:string xPos:int yPos:int leftTop:string rightBottom:string upId:string downId:string overId:string points:string thickness:int value:string imageId:string nbHoriz:int nbVert:int padHoriz:int padVert:int tooltip:string help:string layer:int windowId:string layoutId:string
index c5cbe5c2d4cc9eb0dc816bb1b3b077bc317b5b11..d75d8afb6f76d3dfcb52d14f6f311db226368433 100644 (file)
@@ -217,8 +217,8 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom(
     /// Type definition
     struct Image
     {
-        Image( const string & id, int xPos, int yPos, const string & leftTop, const string & rightBottom, const string & visible, const string & bmpId, const string & actionId, const string & resize, const string & help, int layer, const string & windowId, const string & layoutId ):
-m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_visible( visible ), m_bmpId( bmpId ), m_actionId( actionId ), m_resize( resize ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {}
+        Image( const string & id, int xPos, int yPos, const string & leftTop, const string & rightBottom, const string & visible, const string & bmpId, const string & actionId, const string & action2Id, const string & resize, const string & help, int layer, const string & windowId, const string & layoutId ):
+m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_visible( visible ), m_bmpId( bmpId ), m_actionId( actionId ), m_action2Id( action2Id ), m_resize( resize ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {}
 
         string m_id;
         int m_xPos;
@@ -228,6 +228,7 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom(
         string m_visible;
         string m_bmpId;
         string m_actionId;
+        string m_action2Id;
         string m_resize;
         string m_help;
         int m_layer;
index 81038e972ef6f81e31c09569be9442996cb2a8cd..575735f4ef66b3d1a4c0e14ad44de1f8fced2f20 100644 (file)
@@ -213,14 +213,15 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
         CheckDefault( "lefttop", "lefttop" );
         CheckDefault( "rightbottom", "lefttop" );
         CheckDefault( "action", "none" );
+        CheckDefault( "action2", "none" );
         CheckDefault( "resize", "mosaic" );
         CheckDefault( "help", "" );
 
         const BuilderData::Image imageData( uniqueId( attr["id"] ),
                 atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
                 attr["lefttop"], attr["rightbottom"], attr["visible"],
-                attr["image"], attr["action"], attr["resize"], attr["help"],
-                m_curLayer, m_curWindowId, m_curLayoutId );
+                attr["image"], attr["action"], attr["action2"], attr["resize"],
+                attr["help"], m_curLayer, m_curWindowId, m_curLayoutId );
         m_curLayer++;
         m_pData->m_listImage.push_back( imageData );
     }
index 8480809d84f16d55dd2a8f0d9d58fbecb57a7b86..b939d718caf1bb9ad9bb712396779ad025bc9cd9 100644 (file)
@@ -96,6 +96,7 @@
         rightbottom CDATA   "lefttop"
         image       CDATA   #REQUIRED
         action      CDATA   "none"
+        action      CDATA   "none2"
         resize      CDATA   "mosaic"
         help        CDATA   ""
     >