X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/8d1f62f6525ccfdbcb83c64f701dbbc325c37dbd..41558bc41a72c62a0c9fd4fbf28df23a2fc2fa44:/lib/gui/elistbox.cpp diff --git a/lib/gui/elistbox.cpp b/lib/gui/elistbox.cpp index 747733d3..65b24503 100644 --- a/lib/gui/elistbox.cpp +++ b/lib/gui/elistbox.cpp @@ -78,6 +78,8 @@ bool eListbox::atEnd() void eListbox::moveToEnd() { + if (!m_content) + return; /* move to last existing one ("end" is already invalid) */ m_content->cursorEnd(); m_content->cursorMove(-1); /* current selection invisible? */ @@ -159,49 +161,37 @@ void eListbox::moveSelection(int dir) if (m_content->cursorValid() && !m_content->currentCursorSelectable()) { - eDebug("position not selectable"); /* 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)) { - eDebug("moving up"); while (m_content->cursorGet()) { - eDebug("tick"); m_content->cursorMove(-1); if (m_content->currentCursorSelectable()) { - eDebug("now ok"); break; } } } else { - eDebug("moving down"); + /* else move down */ while (m_content->cursorValid()) { - eDebug("TICK"); m_content->cursorMove(+1); if (m_content->currentCursorSelectable()) { - eDebug("NOW ok"); break; } } if (!m_content->cursorValid()) - { - eDebug("not valid (i.e.: end)"); m_content->cursorMove(-1); - } } if (!m_content->currentCursorSelectable()) - { - eDebug("can't move!"); m_content->cursorSet(oldsel); - } } /* note that we could be on an invalid cursor position, but we don't @@ -322,14 +312,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(); @@ -339,6 +344,7 @@ int eListbox::event(int event, void *data, void *data2) return 0; } + case evtChangedSize: recalcSize(); return eWidget::event(event, data, data2); @@ -359,7 +365,8 @@ void eListbox::recalcSize() { m_content_changed=true; m_prev_scrollbar_page=-1; - m_content->setSize(eSize(size().width(), m_itemheight)); + if (m_content) + m_content->setSize(eSize(size().width(), m_itemheight)); m_items_per_page = size().height() / m_itemheight; if (m_items_per_page < 0) /* TODO: whyever - our size could be invalid, or itemheigh could be wrongly specified. */ @@ -409,7 +416,7 @@ void eListbox::entryAdded(int index) void eListbox::entryRemoved(int index) { - if (index == m_selected) + if (index == m_selected && m_content) m_selected = m_content->cursorGet(); moveSelection(justCheck);