[vlc-commits] commit: skins2: use enum type for better clarity (Erwan Tulou )
git at videolan.org
git at videolan.org
Sun Jan 16 23:05:51 CET 2011
vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Sun Jan 16 17:42:41 2011 +0100| [d9cdd2949ba3193c43670a5842f901b17a0e7d53] | committer: Erwan Tulou
skins2: use enum type for better clarity
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d9cdd2949ba3193c43670a5842f901b17a0e7d53
---
modules/gui/skins2/controls/ctrl_tree.cpp | 15 +++++++++------
modules/gui/skins2/utils/var_tree.hpp | 15 ++++++++++++---
modules/gui/skins2/vars/playtree.cpp | 14 +++++++-------
3 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/modules/gui/skins2/controls/ctrl_tree.cpp b/modules/gui/skins2/controls/ctrl_tree.cpp
index 2b07c9f..ce0cd93 100644
--- a/modules/gui/skins2/controls/ctrl_tree.cpp
+++ b/modules/gui/skins2/controls/ctrl_tree.cpp
@@ -140,21 +140,24 @@ int CtrlTree::maxItems()
void CtrlTree::onUpdate( Subject<VarTree, tree_update> &rTree,
tree_update *arg )
{
- if( arg->i_type == 0 ) // Item update
+ if( arg->type == arg->UpdateItem ) // Item update
{
if( arg->b_active_item )
autoScroll();
- makeImage();
- notifyLayout();
+ if( isItemVisible( arg->i_id ) )
+ {
+ makeImage();
+ notifyLayout();
+ }
}
- else if ( arg->i_type == 1 ) // Global change or deletion
+ else if ( arg->type == arg->ResetAll ) // Global change or deletion
{
m_firstPos = m_flat ? m_rTree.firstLeaf() : m_rTree.begin();
makeImage();
notifyLayout();
}
- else if ( arg->i_type == 2 ) // Item-append
+ else if ( arg->type == arg->AppendItem ) // Item-append
{
if( m_flat && m_firstPos->size() )
{
@@ -169,7 +172,7 @@ void CtrlTree::onUpdate( Subject<VarTree, tree_update> &rTree,
notifyLayout();
}
}
- else if( arg->i_type == 3 ) // item-del
+ else if( arg->type == arg->DeleteItem ) // item-del
{
/* Make sure firstPos is valid */
VarTree::Iterator it_old = m_firstPos;
diff --git a/modules/gui/skins2/utils/var_tree.hpp b/modules/gui/skins2/utils/var_tree.hpp
index bde1ff6..88283af 100644
--- a/modules/gui/skins2/utils/var_tree.hpp
+++ b/modules/gui/skins2/utils/var_tree.hpp
@@ -35,9 +35,18 @@
/// Description of an update to the tree
typedef struct tree_update
{
- int i_type;
- int i_id;
- bool b_active_item;
+ enum type_t
+ {
+ UpdateItem,
+ AppendItem,
+ DeleteItem,
+ ResetAll,
+ };
+
+ enum type_t type;
+ int i_id;
+ bool b_active_item;
+
} tree_update;
/// Tree variable
diff --git a/modules/gui/skins2/vars/playtree.cpp b/modules/gui/skins2/vars/playtree.cpp
index 4d3d67b..4e8ba7b 100644
--- a/modules/gui/skins2/vars/playtree.cpp
+++ b/modules/gui/skins2/vars/playtree.cpp
@@ -57,7 +57,7 @@ void Playtree::delSelected()
}
/// \todo Do this better (handle item-deleted)
tree_update descr;
- descr.i_type = 3;
+ descr.type = tree_update::DeleteItem;
notify( &descr );
it = begin();
while( it != end() )
@@ -114,7 +114,7 @@ void Playtree::onChange()
{
buildTree();
tree_update descr;
- descr.i_type = 1;
+ descr.type = tree_update::ResetAll;
notify( &descr );
}
@@ -129,7 +129,7 @@ void Playtree::onUpdateItem( int id )
it->setString( UStringPtr( pName ) );
tree_update descr;
- descr.i_type = 0;
+ descr.type = tree_update::UpdateItem;
descr.i_id = id;
descr.b_active_item = false;
notify( &descr );
@@ -149,7 +149,7 @@ void Playtree::onUpdateCurrent( bool b_active )
it->setPlaying( false );
tree_update descr;
- descr.i_type = 0;
+ descr.type = tree_update::UpdateItem;
descr.i_id = it->getId();
descr.b_active_item = false;
notify( &descr );
@@ -175,7 +175,7 @@ void Playtree::onUpdateCurrent( bool b_active )
playlist_Unlock( m_pPlaylist );
tree_update descr;
- descr.i_type = 0;
+ descr.type = tree_update::UpdateItem;
descr.i_id = current->i_id;
descr.b_active_item = true;
notify( &descr );
@@ -192,7 +192,7 @@ void Playtree::onDelete( int i_id )
item->setDeleted( true );
tree_update descr;
- descr.i_type = 3;
+ descr.type = tree_update::DeleteItem;
descr.i_id = i_id;
notify( &descr );
@@ -223,7 +223,7 @@ void Playtree::onAppend( playlist_add_t *p_add )
playlist_Unlock( m_pPlaylist );
tree_update descr;
- descr.i_type = 2;
+ descr.type = tree_update::AppendItem;
descr.i_id = p_add->i_item;
notify( &descr );
}
More information about the vlc-commits
mailing list