fix for redraw unused space between scrollbar and listbox entries
[enigma2.git] / lib / gui / elistbox.cpp
index d9f95c4b5b7c914fac756e2a6d8bcec1b0d22f26..cfb3d5b456a90280f9f631d3601bdba8fcffc5d3 100644 (file)
@@ -157,6 +157,41 @@ void eListbox::moveSelection(int dir)
                break;
        }
        
+       if (m_content->cursorValid() && !m_content->currentCursorSelectable())
+       {
+                       /* ok, our cursor position is valid (i.e. in list), but not selectable. */
+                       
+                       /* when moving up, continue until we found a valid position. */
+               if ((dir == moveUp) || (dir == pageDown))
+               {
+                       while (m_content->cursorGet())
+                       {
+                               m_content->cursorMove(-1);
+                               if (m_content->currentCursorSelectable())
+                               {
+                                       break;
+                               }
+                       }
+               } else
+               {
+                               /* else move down */
+                       while (m_content->cursorValid())
+                       {
+                               m_content->cursorMove(+1);
+                               if (m_content->currentCursorSelectable())
+                               {
+                                       break;
+                               }
+                       }
+                       
+                       if (!m_content->cursorValid())
+                               m_content->cursorMove(-1);
+               }
+               
+               if (!m_content->currentCursorSelectable())
+                       m_content->cursorSet(oldsel);
+       }
+       
                /* note that we could be on an invalid cursor position, but we don't
                   care. this only happens on empty lists, and should have almost no
                   side effects. */
@@ -275,14 +310,29 @@ int eListbox::event(int event, void *data, void *data2)
                m_content->cursorSave();
                m_content->cursorMove(m_top - m_selected);
                
+               gRegion entryrect = eRect(0, 0, size().width(), m_itemheight);
+               const gRegion &paint_region = *(gRegion*)data;
+               
                for (int y = 0, i = 0; i <= m_items_per_page; y += m_itemheight, ++i)
                {
-                       m_content->paint(painter, *style, ePoint(0, y), m_selected == m_content->cursorGet() && m_content->size() && m_selection_enabled);
+                       gRegion entry_clip_rect = paint_region & entryrect;
+
+                       if (!entry_clip_rect.empty())
+                               m_content->paint(painter, *style, ePoint(0, y), m_selected == m_content->cursorGet() && m_content->size() && m_selection_enabled);
+
+                               /* (we could clip with entry_clip_rect, but 
+                                  this shouldn't change the behaviour of any
+                                  well behaving content, so it would just
+                                  degrade performance without any gain.) */
+
                        m_content->cursorMove(+1);
+                       entryrect.moveBy(ePoint(0, m_itemheight));
                }
 
+               // clear/repaint empty/unused space between scrollbar and listboxentrys
                if (m_scrollbar && m_scrollbar->isVisible())
                {
+                       style->setStyle(painter, eWindowStyle::styleListboxNormal);
                        painter.clip(eRect(m_scrollbar->position() - ePoint(5,0), eSize(5,m_scrollbar->size().height())));
                        painter.clear();
                        painter.clippop();
@@ -292,6 +342,7 @@ int eListbox::event(int event, void *data, void *data2)
 
                return 0;
        }
+
        case evtChangedSize:
                recalcSize();
                return eWidget::event(event, data, data2);