[vlc-commits] commit: skins2: fix slider position a bit erratic (Erwan Tulou )
git at videolan.org
git at videolan.org
Tue Aug 10 11:34:08 CEST 2010
vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Fri Aug 6 08:56:23 2010 +0200| [54919d68fad96b3c49cd564fbd52146e8afbe938] | committer: Erwan Tulou
skins2: fix slider position a bit erratic
This path simplifies code a bit, makes index consistent throughout the code
(spanned from 0 to n-1), and remove a += maxitems that seems wrong
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=54919d68fad96b3c49cd564fbd52146e8afbe938
---
modules/gui/skins2/controls/ctrl_tree.cpp | 18 +++++++-----------
1 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/modules/gui/skins2/controls/ctrl_tree.cpp b/modules/gui/skins2/controls/ctrl_tree.cpp
index 4c1fff0..dad3e43 100644
--- a/modules/gui/skins2/controls/ctrl_tree.cpp
+++ b/modules/gui/skins2/controls/ctrl_tree.cpp
@@ -608,29 +608,25 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent )
m_rTree.getPositionVar().set( percentage );
}
- /* We changed the nodes, let's fix teh position var */
+ /* We changed the nodes, let's fix the position var */
if( bChangedPosition )
{
VarTree::Iterator it;
- int i = 0;
int iFirst = 0;
for( it = m_flat ? m_rTree.firstLeaf() : m_rTree.begin();
it != m_rTree.end();
it = m_flat ? m_rTree.getNextLeaf( it )
: m_rTree.getNextVisibleItem( it ) )
{
- i++;
if( it == m_firstPos )
- {
- iFirst = i;
break;
- }
+ iFirst++;
}
- iFirst += maxItems();
- if( iFirst >= (m_flat ? m_rTree.countLeafs() : m_rTree.visibleItems()) )
- iFirst = m_flat ? m_rTree.countLeafs() : m_rTree.visibleItems();
- float f_new = (float)iFirst / (float)( m_flat ? m_rTree.countLeafs()
- :m_rTree.visibleItems() );
+
+ int indexMax = ( m_flat ? m_rTree.countLeafs()
+ : m_rTree.visibleItems() ) - 1;
+ float f_new = (float)iFirst / (float)indexMax;
+
m_dontMove = true;
m_rTree.getPositionVar().set( 1.0 - f_new );
m_dontMove = false;
More information about the vlc-commits
mailing list