From cd310b3ca8f391b83139e103633551203904ba17 Mon Sep 17 00:00:00 2001 From: martii Date: Sat, 20 Jul 2013 13:44:09 +0200 Subject: [PATCH] gui/widget/listframe: change page-up/-down scrolling behaviour --- src/gui/widget/listframe.cpp | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/gui/widget/listframe.cpp b/src/gui/widget/listframe.cpp index 0a483ba66..ecf344a40 100644 --- a/src/gui/widget/listframe.cpp +++ b/src/gui/widget/listframe.cpp @@ -584,15 +584,22 @@ void CListFrame::scrollPageDown(const int pages) if(m_nCurrentPage + pages < m_nNrOfPages) { m_nCurrentPage += pages; + m_nCurrentLine += pages * m_nLinesPerPage; + m_nSelectedLine += pages * m_nLinesPerPage; + if(m_nSelectedLine >= m_nNrOfLines - 1) + m_nSelectedLine = m_nNrOfLines - 1; + } + else if (m_nSelectedLine == m_nNrOfLines - 1) + { + m_nCurrentPage = 0; + m_nCurrentLine = 0; + m_nSelectedLine = 0; } else { m_nCurrentPage = m_nNrOfPages - 1; - } - m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage; - if(m_nSelectedLine < m_nCurrentLine || m_nSelectedLine -m_nCurrentLine >= m_nLinesPerPage ) - { - m_nSelectedLine = m_nCurrentLine; + m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage; + m_nSelectedLine = m_nNrOfLines - 1; } //TRACE("[CListFrame] m_nCurrentLine: %d, m_nCurrentPage: %d \r\n",m_nCurrentLine,m_nCurrentPage); refresh(); @@ -605,18 +612,25 @@ void CListFrame::scrollPageUp(const int pages) if( !(m_nMode & SCROLL)) return; if( m_nNrOfLines <= 1) return; - if(m_nCurrentPage - pages > 0) + if(m_nCurrentPage - pages > -1) { m_nCurrentPage -= pages; + m_nCurrentLine -= pages * m_nLinesPerPage; + m_nSelectedLine -= pages * m_nLinesPerPage; + if(m_nSelectedLine < 0) + m_nSelectedLine = 0; + } + else if (m_nSelectedLine == 0) + { + m_nCurrentPage = m_nNrOfPages - 1; + m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage; + m_nSelectedLine = m_nNrOfLines - 1; } else { m_nCurrentPage = 0; - } - m_nCurrentLine = m_nCurrentPage * m_nLinesPerPage; - if(m_nSelectedLine < m_nCurrentLine || m_nSelectedLine - m_nCurrentLine >= m_nLinesPerPage ) - { - m_nSelectedLine = m_nCurrentLine; + m_nCurrentLine = 0; + m_nSelectedLine = 0; } //TRACE("[CListFrame] m_nCurrentLine: %d, m_nCurrentPage: %d \r\n",m_nCurrentLine,m_nCurrentPage); refresh();