Commit 81717b48 authored by Erwan Tulou's avatar Erwan Tulou

skins2: implement a new 'focus' attribute for text control

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.
parent f4266f31
......@@ -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>
......
......@@ -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:
......
......@@ -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;
......
......@@ -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();
......
......@@ -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
......
......@@ -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;
......
......@@ -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 );
......
......@@ -257,6 +257,7 @@
color CDATA "#000000"
scrolling CDATA "auto"
alignment CDATA "left"
focus CDATA "true"
help CDATA ""
>
<!ELEMENT Playlist (Slider)?>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment