]> git.sesse.net Git - vlc/commitdiff
skins2: implement a new 'focus' attribute for text control
authorErwan Tulou <erwan10@videolan.org>
Sat, 11 Dec 2010 10:56:14 +0000 (11:56 +0100)
committerErwan Tulou <erwan10@videolan.org>
Sat, 11 Dec 2010 14:24:33 +0000 (15:24 +0100)
Up to now, text control could but be focusable, and this focus was used
to scroll text, should it be too long for full display.

From a user viewpoint, this behavior is often counterintuitive :
 - Most of the time, the control is designed to fit the text anyway, and
   scrolling is not expected.
 - On the other hand, an underlying control may be used to move the window
   (for instance, the title bar), and a text control is expected not to
   interact in this endeavor. Same goes for popupmenu, that is expected
   to work if one happens to right-click on a text control.

This patch adds a 'focus' attribute to the text control, and leave it to the
skins developper to decide which behavior is most desirable on a per-control
basis. focus still defaults to true to maintain skins current behavior.

doc/skins/skins2-howto.xml
modules/gui/skins2/controls/ctrl_text.cpp
modules/gui/skins2/controls/ctrl_text.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 20d05f4145d3527b0fe3dc8f655ff9c53209c56e..cacdffd5d60be66a88f9e31cd29e9537fad3eff2 100644 (file)
@@ -642,6 +642,11 @@ difficulty to understand how VLC skins work.</para>
     <para>Alignment of the text inside the control. Possible values are 'left', 'center' and 'right'. The 'width' and 'center' alignments are computed using the width of the control (as given by the <link linkend="textwidth">width</link> attribute). Available since VLC 0.8.5.</para>
     <para>Default value: left</para>
   </sect3>
+  <sect3 id="focus">
+    <title>focus</title>
+    <para>indicates if the control is eligible for mouse focus or not. If focus is set to false, it is as though the control did not exist when it comes to mouse focus. This allows for instance displaying a dynamic text in the title bar, yet opting for being able to move the window rather than manage scrolling of lengthy text. Available in VLC 1.2.0.</para>
+    <para>Default value: true</para>
+  </sect3>
   <sect3 id="textscrolling">
     <title>scrolling</title>
     <para>Scrolling behaviour of the text (only when it doesn't fit in the <link linkend="textwidth">width</link> of the control). Possible values are 'auto', 'manual' and 'none'. If this attribute is set to 'auto', the text automatically starts scrolling. The user can drag the text, and click on it to start/stop the scrolling. If this attribute is set to 'manual', the text only scrolls when dragged by the user. If this attribute is set to 'none', no scrolling is possible at all. Available since VLC 0.8.5.</para>
index 513028fe7cd91a58e6e1d6f6b1f8acd019e50688..4a0859029a266c71b7b24c4e2e4b37912fad7d87 100644 (file)
@@ -42,9 +42,9 @@
 
 CtrlText::CtrlText( intf_thread_t *pIntf, VarText &rVariable,
                     const GenericFont &rFont, const UString &rHelp,
-                    uint32_t color, VarBool *pVisible, Scrolling_t scrollMode,
-                    Align_t alignment ):
-    CtrlGeneric( pIntf, rHelp, pVisible ), m_fsm( pIntf ),
+                    uint32_t color, VarBool *pVisible, VarBool *pFocus,
+                    Scrolling_t scrollMode, Align_t alignment ):
+    CtrlGeneric( pIntf, rHelp, pVisible ), m_pFocus( pFocus), m_fsm( pIntf ),
     m_rVariable( rVariable ), m_cmdToManual( this ),
     m_cmdManualMoving( this ), m_cmdManualStill( this ),
     m_cmdMove( this ), m_pEvt( NULL ), m_rFont( rFont ),
@@ -121,6 +121,9 @@ void CtrlText::handleEvent( EvtGeneric &rEvent )
 
 bool CtrlText::mouseOver( int x, int y ) const
 {
+    if( !m_pFocus->get() )
+        return false;
+
     if( m_pCurrImg )
     {
         // We have 3 different ways of deciding when to return true here:
index c0a35bb61911f5b2fe1604ee3a120d9e0ecaec27..828cb2a9a2cd0ef36409a5a450c60cfe418746af 100644 (file)
@@ -63,8 +63,8 @@ public:
     /// Create a text control with the optional given color
     CtrlText( intf_thread_t *pIntf, VarText &rVariable,
               const GenericFont &rFont, const UString &rHelp,
-              uint32_t color, VarBool *pVisible, Scrolling_t scrollMode,
-              Align_t alignment);
+              uint32_t color, VarBool *pVisible, VarBool *pFocus,
+              Scrolling_t scrollMode, Align_t alignment);
     virtual ~CtrlText();
 
     /// Handle an event
@@ -103,6 +103,8 @@ private:
     Scrolling_t m_scrollMode;
     /// Type of alignment
     Align_t m_alignment;
+    /// indicate if control is focusable
+    VarBool *m_pFocus;
     /// Image of the text
     GenericBitmap *m_pImg;
     /// Image of the text, repeated twice and with some blank between;
index ab4ba9c777318a8185178a2d1e6189f9b6d43b35..d41f6b15e6342f0d621545eebe0c084a26c4303e 100644 (file)
@@ -739,10 +739,11 @@ void Builder::addText( const BuilderData::Text &rData )
     // XXX check when it is null
     Interpreter *pInterpreter = Interpreter::instance( getIntf() );
     VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
+    VarBool *pFocus = pInterpreter->getVarBool( rData.m_focus, m_pTheme );
 
     CtrlText *pText = new CtrlText( getIntf(), *pVar, *pFont,
-        UString( getIntf(), rData.m_help.c_str() ), rData.m_color, pVisible,
-        scrolling, alignment );
+        UString( getIntf(), rData.m_help.c_str() ), rData.m_color,
+        pVisible, pFocus, scrolling, alignment );
     m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pText );
 
     int height = pFont->getSize();
index 3571a32f99c9e83a6ce42ae148f8b8fe294904de..08939c85e865b9c0f18c5d7d436be6ad5f58e780 100644 (file)
@@ -14,7 +14,7 @@ Checkbox id:string xPos:int yPos:int leftTop:string rightBottom:string xKeepRati
 Image id:string xPos:int yPos:int width:int height:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool visible:string bmpId:string actionId:string action2Id:string resize:string help:string art:bool layer:int windowId:string layoutId:string panelId:string
 IniFile id:string file:string
 Panel id:string xPos:int yPos:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool width:int height:int layer:int windowId:string layoutId:string panelId:string
-Text id:string xPos:int yPos:int visible:string fontId:string text:string width:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool color:uint32_t scrolling:string alignment:string help:string layer:int windowId:string layoutId:string panelId:string
+Text id:string xPos:int yPos:int visible:string fontId:string text:string width:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool color:uint32_t scrolling:string alignment:string focus:string help:string layer:int windowId:string layoutId:string panelId:string
 RadialSlider id:string visible:string xPos:int yPos:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool sequence:string nbImages:int minAngle:float maxAngle:float value:string tooltip:string help:string layer:int windowId:string layoutId:string panelId:string
 Slider id:string visible:string xPos:int yPos:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool 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 panelId:string
 List id:string xPos:int yPos:int visible:string width:int height:int leftTop:string rightBottom:string xKeepRatio:bool yKeepRatio:bool fontId:string var:string bgImageId:string fgColor:string playColor:string bgColor1:string bgColor2:string selColor:string help:string layer:int windowId:string layoutId:string panelId:string
index e9243bc283ec557308bdb5ee40a4270d1f4cdd16..a14bdf52cd308fe234a07001695f56e9a8980fab 100644 (file)
@@ -337,8 +337,8 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom(
     /// Type definition
     struct Text
     {
-        Text( const string & id, int xPos, int yPos, const string & visible, const string & fontId, const string & text, int width, const string & leftTop, const string & rightBottom, bool xKeepRatio, bool yKeepRatio, uint32_t color, const string & scrolling, const string & alignment, const string & help, int layer, const string & windowId, const string & layoutId, const string & panelId ):
-m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_fontId( fontId ), m_text( text ), m_width( width ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_xKeepRatio( xKeepRatio ), m_yKeepRatio( yKeepRatio ), m_color( color ), m_scrolling( scrolling ), m_alignment( alignment ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ), m_panelId( panelId ) {}
+        Text( const string & id, int xPos, int yPos, const string & visible, const string & fontId, const string & text, int width, const string & leftTop, const string & rightBottom, bool xKeepRatio, bool yKeepRatio, uint32_t color, const string & scrolling, const string & alignment, const string & focus, const string & help, int layer, const string & windowId, const string & layoutId, const string & panelId ):
+m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_fontId( fontId ), m_text( text ), m_width( width ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_xKeepRatio( xKeepRatio ), m_yKeepRatio( yKeepRatio ), m_color( color ), m_scrolling( scrolling ), m_alignment( alignment ), m_focus( focus ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ), m_panelId( panelId ) {}
 
         string m_id;
         int m_xPos;
@@ -354,6 +354,7 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_fontId( font
         uint32_t m_color;
         string m_scrolling;
         string m_alignment;
+        string m_focus;
         string m_help;
         int m_layer;
         string m_windowId;
index 3e18e6083bb280763a264408a357ea427c37273e..7be0cd9d518400ed8e1ed15bf36b251ad39e4c6c 100644 (file)
@@ -625,6 +625,7 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
         DefaultAttr( attr, "color", "#000000" );
         DefaultAttr( attr, "scrolling", "auto" );
         DefaultAttr( attr, "alignment", "left" );
+        DefaultAttr( attr, "focus", "true" );
         DefaultAttr( attr, "width", "0" );
         DefaultAttr( attr, "lefttop", "lefttop" );
         DefaultAttr( attr, "rightbottom", "lefttop" );
@@ -649,7 +650,8 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
                 convertBoolean( attr["ykeepratio"] ),
                 convertColor( attr["color"] ),
                 attr["scrolling"], attr["alignment"],
-                attr["help"], m_curLayer, m_curWindowId, m_curLayoutId,
+                attr["focus"], attr["help"],
+                m_curLayer, m_curWindowId, m_curLayoutId,
                 m_panelStack.back() );
         m_curLayer++;
         m_pData->m_listText.push_back( textData );
index de0227eff0797a9f993a4e5bd13cbed80c9b3d57..f1c05f77f4eb80367c72305f56a4689ee32cfe91 100644 (file)
         color       CDATA   "#000000"
         scrolling   CDATA   "auto"
         alignment   CDATA   "left"
+        focus       CDATA   "true"
         help        CDATA   ""
     >
 <!ELEMENT Playlist (Slider)?>