diff --git a/checkin_notes b/checkin_notes index 98643313b9..b37451f7e1 100644 --- a/checkin_notes +++ b/checkin_notes @@ -7284,7 +7284,7 @@ Charlie 8 Sep 2008 progress bars in wrong rows in transfers tab. MGR: Use item attributes to create gray backgroound stripes in List Views instead of overlaying them in CBOINCListCtrl::DrawBarGraphs(); - this eliminates remaining flicker on Windows. + this eliminates most remaining flicker on Windows. clientgui/ BOINCBaseView.cpp,.h @@ -7305,3 +7305,14 @@ David 9 Sept 2008 html/user/ show_user.php + +Charlie 8 Sep 2008 + MGR: Draw only those progress bars which are actually needed, further + reducing flicker and improving efficiency. + + clientgui/ + BOINCBaseView.cpp + BOINCListCtrl.cpp,.h + ViewProjects.cpp + ViewTransfers.cpp + ViewWork.cpp diff --git a/clientgui/BOINCBaseView.cpp b/clientgui/BOINCBaseView.cpp index 8d29d31776..e1309cd87d 100644 --- a/clientgui/BOINCBaseView.cpp +++ b/clientgui/BOINCBaseView.cpp @@ -140,6 +140,7 @@ CBOINCBaseView::~CBOINCBaseView() { } m_arrSelectedKeys1.Empty(); m_arrSelectedKeys2.Empty(); + m_iSortedIndexes.Empty(); if (m_pWhiteBackgroundAttr) { delete m_pWhiteBackgroundAttr; diff --git a/clientgui/BOINCListCtrl.cpp b/clientgui/BOINCListCtrl.cpp index 731ef7bae1..587a803752 100644 --- a/clientgui/BOINCListCtrl.cpp +++ b/clientgui/BOINCListCtrl.cpp @@ -67,6 +67,7 @@ CBOINCListCtrl::CBOINCListCtrl( CBOINCListCtrl::~CBOINCListCtrl() { + m_iRowsNeedingProgressBars.Empty(); } @@ -182,6 +183,20 @@ void CBOINCListCtrl::SelectRow(int row, bool setSelected) { } +void CBOINCListCtrl::AddPendingBarGraph(int row) { + bool duplicate = false; + int n = (int)m_iRowsNeedingProgressBars.GetCount(); + for (int i=0; iGetProgressColumn(); + #if USE_NATIVE_LISTCONTROL wxClientDC dc(this); m_bBarGraphEventPending = false; @@ -252,6 +268,14 @@ void CBOINCListCtrl::DrawBarGraphs() wxClientDC dc(GetMainWin()); // Available only in wxGenericListCtrl #endif + if (progressColumn < 0) { + m_iRowsNeedingProgressBars.Empty(); + return; + } + + int n = (int)m_iRowsNeedingProgressBars.GetCount(); + if (n <= 0) return; + #ifdef __WXMAC__ wxColour progressColor = wxColour( 40, 170, 170, 60); #else @@ -261,7 +285,7 @@ void CBOINCListCtrl::DrawBarGraphs() numItems = GetItemCount(); if (numItems) { - topItem = GetTopItem(); // Doesn't work properly for Mac Native control + topItem = GetTopItem(); // Doesn't work properly for Mac Native control in wxMac-2.8.7 numVisibleItems = GetCountPerPage(); ++numVisibleItems; @@ -269,36 +293,38 @@ void CBOINCListCtrl::DrawBarGraphs() if (numItems <= (topItem + numVisibleItems)) numVisibleItems = numItems - topItem; x = 0; - - if (progressColumn >= 0) { - for (i=0; i< progressColumn; i++) { - x += GetColumnWidth(i); - } - w = GetColumnWidth(progressColumn); + for (i=0; i< progressColumn; i++) { + x += GetColumnWidth(i); } + w = GetColumnWidth(progressColumn); - for (i=0; i (topItem + numVisibleItems -1)) continue; + + + GetItemRect(row, r); #if ! USE_NATIVE_LISTCONTROL r.y = r.y - GetHeaderHeight() - 1; #endif - if (progressColumn < 0) continue; r.x = x; r.width = w; r.Inflate(-1, -1); + dc.SetPen(progressColor); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawRectangle( r ); r.Inflate(-1, 0); dc.DrawRectangle( r ); - r.width = r.width * m_pParentView->GetProgressValue(item); + r.width = r.width * m_pParentView->GetProgressValue(row); dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(progressColor); dc.DrawRectangle( r ); } } + m_iRowsNeedingProgressBars.Empty(); } #if USE_NATIVE_LISTCONTROL diff --git a/clientgui/BOINCListCtrl.h b/clientgui/BOINCListCtrl.h index e72cdebc96..84b5926428 100644 --- a/clientgui/BOINCListCtrl.h +++ b/clientgui/BOINCListCtrl.h @@ -55,6 +55,7 @@ public: long GetFirstSelected() { return GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); } long GetNextSelected(int i) { return GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); } void SelectRow(int row, bool setSelected); + void AddPendingBarGraph(int row); bool m_bIsSingleSelection; @@ -66,6 +67,7 @@ private: virtual wxListItemAttr* OnGetItemAttr(long item) const; CBOINCBaseView* m_pParentView; + wxArrayInt m_iRowsNeedingProgressBars; #if USE_NATIVE_LISTCONTROL public: diff --git a/clientgui/ViewProjects.cpp b/clientgui/ViewProjects.cpp index a89bea16dd..2d7566c9bf 100644 --- a/clientgui/ViewProjects.cpp +++ b/clientgui/ViewProjects.cpp @@ -531,6 +531,8 @@ wxString CViewProjects::OnListGetItemText(long item, long column) const { CProject* project = NULL; wxString strBuffer = wxEmptyString; + m_pListPane->AddPendingBarGraph(item); + try { project = m_ProjectCache.at(m_iSortedIndexes[item]); } catch ( std::out_of_range ) { diff --git a/clientgui/ViewTransfers.cpp b/clientgui/ViewTransfers.cpp index 60ba82108e..6ce0a26a1f 100644 --- a/clientgui/ViewTransfers.cpp +++ b/clientgui/ViewTransfers.cpp @@ -325,6 +325,8 @@ wxString CViewTransfers::OnListGetItemText(long item, long column) const { CTransfer* transfer; wxString strBuffer = wxEmptyString; + m_pListPane->AddPendingBarGraph(item); + try { transfer = m_TransferCache.at(m_iSortedIndexes[item]); } catch ( std::out_of_range ) { diff --git a/clientgui/ViewWork.cpp b/clientgui/ViewWork.cpp index 6ae98ebc8d..ecdf5f954b 100644 --- a/clientgui/ViewWork.cpp +++ b/clientgui/ViewWork.cpp @@ -470,6 +470,8 @@ wxInt32 CViewWork::GetDocCount() { wxString CViewWork::OnListGetItemText(long item, long column) const { CWork* work = NULL; wxString strBuffer = wxEmptyString; + + m_pListPane->AddPendingBarGraph(item); try { work = m_WorkCache.at(m_iSortedIndexes[item]); @@ -477,33 +479,35 @@ wxString CViewWork::OnListGetItemText(long item, long column) const { work = NULL; } - switch(column) { - case COLUMN_PROJECT: - strBuffer = work->m_strProjectName; - break; - case COLUMN_APPLICATION: - strBuffer = work->m_strApplicationName; - break; - case COLUMN_NAME: - strBuffer = work->m_strName; - break; - case COLUMN_CPUTIME: - strBuffer = work->m_strCPUTime; - break; - case COLUMN_PROGRESS: - strBuffer = work->m_strProgress; - break; - case COLUMN_TOCOMPLETION: - strBuffer = work->m_strTimeToCompletion; - break; - case COLUMN_REPORTDEADLINE: - strBuffer = work->m_strReportDeadline; - break; - case COLUMN_STATUS: - strBuffer = work->m_strStatus; - break; + if (work) { + switch(column) { + case COLUMN_PROJECT: + strBuffer = work->m_strProjectName; + break; + case COLUMN_APPLICATION: + strBuffer = work->m_strApplicationName; + break; + case COLUMN_NAME: + strBuffer = work->m_strName; + break; + case COLUMN_CPUTIME: + strBuffer = work->m_strCPUTime; + break; + case COLUMN_PROGRESS: + strBuffer = work->m_strProgress; + break; + case COLUMN_TOCOMPLETION: + strBuffer = work->m_strTimeToCompletion; + break; + case COLUMN_REPORTDEADLINE: + strBuffer = work->m_strReportDeadline; + break; + case COLUMN_STATUS: + strBuffer = work->m_strStatus; + break; + } } - + return strBuffer; }