Commit 1d163084 authored by Antoine Cellerier's avatar Antoine Cellerier

Add attribute flat="true/false" to Playtree. When flat is true, only the

leafs will be displayed (like the old style playlist). Once we're sure
that this works fine, we can ditch the old skins2 playlist code.
parent b8acb8c0
This diff is collapsed.
......@@ -50,7 +50,8 @@ class CtrlTree: public CtrlGeneric, public Observer<VarTree, tree_update*>,
uint32_t bgColor2,
uint32_t selColor,
const UString &rHelp,
VarBool *pVisible );
VarBool *pVisible,
VarBool *pFlat );
virtual ~CtrlTree();
/// Handle an event on the control
......@@ -114,6 +115,9 @@ class CtrlTree: public CtrlGeneric, public Observer<VarTree, tree_update*>,
/// Don't move if the position variable is updated
bool m_dontMove;
/// Do we want to "flaten" the tree ?
bool m_flat;
/// Method called when the tree variable is modified
virtual void onUpdate( Subject<VarTree, tree_update*> &rTree ,
tree_update *);
......
......@@ -871,13 +871,14 @@ void Builder::addTree( const BuilderData::Tree &rData )
// Get the visibility variable
// XXX check when it is null
VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
VarBool *pFlat = pInterpreter->getVarBool( rData.m_flat, m_pTheme );
// Create the list control
CtrlTree *pTree = new CtrlTree( getIntf(), *pVar, *pFont, pBgBmp,
pItemBmp, pOpenBmp, pClosedBmp,
rData.m_fgColor, rData.m_playColor, rData.m_bgColor1,
rData.m_bgColor2, rData.m_selColor,
UString( getIntf(), rData.m_help.c_str() ), pVisible );
UString( getIntf(), rData.m_help.c_str() ), pVisible, pFlat );
// Compute the position of the control
const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
......
......@@ -16,5 +16,5 @@ Text id:string xPos:int yPos:int visible:string fontId:string text:string width:
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
List id:string xPos:int yPos:int visible:string width:int height:int leftTop:string rightBottom:string fontId:string var:string bgImageId:string fgColor:uint32_t playColor:uint32_t bgColor1:uint32_t bgColor2:uint32_t selColor:uint32_t help:string layer:int windowId:string layoutId:string
Tree id:string xPos:int yPos:int visible:string width:int height:int leftTop:string rightBottom:string fontId:string var:string bgImageId:string itemImageId:string openImageId:string closedImageId:string fgColor:uint32_t playColor:uint32_t bgColor1:uint32_t bgColor2:uint32_t selColor:uint32_t help:string layer:int windowId:string layoutId:string
Tree id:string xPos:int yPos:int visible:string flat:string width:int height:int leftTop:string rightBottom:string fontId:string var:string bgImageId:string itemImageId:string openImageId:string closedImageId:string fgColor:uint32_t playColor:uint32_t bgColor1:uint32_t bgColor2:uint32_t selColor:uint32_t help:string layer:int windowId:string layoutId:string
Video id:string xPos:int yPos:int width:int height:int leftTop:string rightBottom:string visible:string autoResize:bool help:string layer:int windowId:string layoutId:string
......@@ -396,13 +396,14 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_width( width
/// Type definition
struct Tree
{
Tree( const string & id, int xPos, int yPos, const string & visible, int width, int height, const string & leftTop, const string & rightBottom, const string & fontId, const string & var, const string & bgImageId, const string & itemImageId, const string & openImageId, const string & closedImageId, uint32_t fgColor, uint32_t playColor, uint32_t bgColor1, uint32_t bgColor2, uint32_t selColor, const string & help, int layer, const string & windowId, const string & layoutId ):
m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_fontId( fontId ), m_var( var ), m_bgImageId( bgImageId ), m_itemImageId( itemImageId ), m_openImageId( openImageId ), m_closedImageId( closedImageId ), m_fgColor( fgColor ), m_playColor( playColor ), m_bgColor1( bgColor1 ), m_bgColor2( bgColor2 ), m_selColor( selColor ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {}
Tree( const string & id, int xPos, int yPos, const string & visible, const string & flat, int width, int height, const string & leftTop, const string & rightBottom, const string & fontId, const string & var, const string & bgImageId, const string & itemImageId, const string & openImageId, const string & closedImageId, uint32_t fgColor, uint32_t playColor, uint32_t bgColor1, uint32_t bgColor2, uint32_t selColor, const string & help, int layer, const string & windowId, const string & layoutId ):
m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_flat( flat ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_fontId( fontId ), m_var( var ), m_bgImageId( bgImageId ), m_itemImageId( itemImageId ), m_openImageId( openImageId ), m_closedImageId( closedImageId ), m_fgColor( fgColor ), m_playColor( playColor ), m_bgColor1( bgColor1 ), m_bgColor2( bgColor2 ), m_selColor( selColor ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {}
string m_id;
int m_xPos;
int m_yPos;
string m_visible;
string m_flat;
int m_width;
int m_height;
string m_leftTop;
......
......@@ -341,6 +341,7 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
m_curTreeId = uniqueId( attr["id"] );
const BuilderData::Tree treeData( m_curTreeId, atoi( attr["x"] ) +
m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["visible"],
attr["flat"],
atoi( attr["width"]), atoi( attr["height"] ),
attr["lefttop"], attr["rightbottom"],
attr["font"], "playtree",
......
......@@ -225,10 +225,12 @@ VarTree::Iterator VarTree::getVisibleItem( int n )
while( it != end() )
{
n--;
if( n <= 0 ) return it;
if( n <= 0 )
return it;
if( it->m_expanded )
{
int i = n - it->visibleItems();
int i;
i = n - it->visibleItems();
if( i <= 0 ) return it->getVisibleItem( n );
n = i;
}
......@@ -237,6 +239,29 @@ VarTree::Iterator VarTree::getVisibleItem( int n )
return end();
}
VarTree::Iterator VarTree::getLeaf( int n )
{
Iterator it = begin();
while( it != end() )
{
if( it->size() )
{
int i;
i = n - it->countLeafs();
if( i <= 0 ) return it->getLeaf( n );
n = i;
}
else
{
n--;
if( n <= 0 )
return it;
}
it++;
}
return end();
}
VarTree::Iterator VarTree::getNextVisibleItem( Iterator it )
{
if( it->m_expanded && it->size() )
......@@ -260,9 +285,7 @@ VarTree::Iterator VarTree::getPrevVisibleItem( Iterator it )
{
VarTree::Iterator it_old = it;
if( it == root()->begin() || it == ++(root()->begin()) ) return it;
if( it->parent() )
{
}
/* Was it the first child of its parent ? */
if( it->parent() && it == it->parent()->begin() )
{
......@@ -300,6 +323,49 @@ VarTree::Iterator VarTree::getNextItem( Iterator it )
return it;
}
VarTree::Iterator VarTree::getPrevItem( Iterator it )
{
VarTree::Iterator it_old = it;
if( it == root()->begin() || it == ++(root()->begin()) ) return it;
/* Was it the first child of its parent ? */
if( it->parent() && it == it->parent()->begin() )
{
/* Yes, get previous uncle */
it = it_old->prev_uncle();
}
else
it--;
/* We have found an expanded uncle, take its last child */
while( it != root()->begin() && it->size() )
{
it = it->end();
it--;
}
return it;
}
VarTree::Iterator VarTree::getNextLeaf( Iterator it )
{
do
{
it = getNextItem( it );
}
while( it != root()->end() && it->size() );
return it;
}
VarTree::Iterator VarTree::getPrevLeaf( Iterator it )
{
do
{
it = getPrevItem( it );
}
while( it != root()->begin() && it->size() ); /* FIXME ? */
if( it == root()->begin() ) it = firstLeaf();
return it;
}
VarTree::Iterator VarTree::findById( int id )
{
......@@ -327,3 +393,25 @@ void VarTree::ensureExpanded( VarTree::Iterator it )
current = current->parent();
}
}
int VarTree::countLeafs()
{
if( size() == 0 ) return 1;
int i_count = 0;
Iterator it = begin();
while( it != end() )
{
i_count += it->countLeafs();
it++;
}
return i_count;
}
VarTree::Iterator VarTree::firstLeaf()
{
Iterator b = root()->begin();
if( b->size() ) return getNextLeaf( b );
return b;
}
......@@ -119,15 +119,8 @@ class VarTree: public Variable, public Subject<VarTree, tree_update*>
return parent;
}
/// Get depth (root depth is 0)
int depth()
{
VarTree *parent = this;
int depth = 0;
while( ( parent = parent->parent() ) != NULL )
depth++;
return depth;
}
/// Get first leaf
Iterator firstLeaf();
void removeChild( VarTree::Iterator item )
{
......@@ -147,9 +140,15 @@ class VarTree: public Variable, public Subject<VarTree, tree_update*>
/// Count the number of items that should be displayed if the playlist window wasn't limited
int visibleItems();
/// Count the number of leafs in the tree
int countLeafs();
/// Return iterator to the n'th visible item
Iterator getVisibleItem( int n );
/// Return iterator to the n'th leaf
Iterator getLeaf( int n );
/// Given an iterator to a visible item, return the next visible item
Iterator getNextVisibleItem( Iterator it );
......@@ -159,12 +158,32 @@ class VarTree: public Variable, public Subject<VarTree, tree_update*>
/// Given an iterator to an item, return the next item
Iterator getNextItem( Iterator it );
/// Given an iterator to an item, return the previous item
Iterator getPrevItem( Iterator it );
/// Given an iterator to an item, return the next leaf
Iterator getNextLeaf( Iterator it );
/// Given an iterator to an item, return the previous leaf
Iterator getPrevLeaf( Iterator it );
/// Find a children node with the given id
Iterator findById( int id );
/// Ensure an item is expanded
void ensureExpanded( VarTree::Iterator );
/// Get depth (root depth is 0)
int depth()
{
VarTree *parent = this;
int depth = 0;
while( ( parent = parent->parent() ) != NULL )
depth++;
return depth;
}
private:
/// List of children
list<VarTree> m_children;
......
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