From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id EF23F138620 for ; Wed, 23 Jan 2013 12:05:46 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C08A2E0686; Wed, 23 Jan 2013 12:05:43 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2835EE0684 for ; Wed, 23 Jan 2013 12:05:32 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 276DB33DB55 for ; Wed, 23 Jan 2013 12:05:31 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 5F477E4097 for ; Wed, 23 Jan 2013 12:05:28 +0000 (UTC) From: "Sven Eden" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sven Eden" Message-ID: <1358941572.bad3db1d1b1e55e8597ea6a0b48d2dbda7a8a41d.yamakuzure@gentoo> Subject: [gentoo-commits] proj/ufed:master commit in: / X-VCS-Repository: proj/ufed X-VCS-Files: ufed-curses.c X-VCS-Directories: / X-VCS-Committer: yamakuzure X-VCS-Committer-Name: Sven Eden X-VCS-Revision: bad3db1d1b1e55e8597ea6a0b48d2dbda7a8a41d X-VCS-Branch: master Date: Wed, 23 Jan 2013 12:05:28 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: af2c301f-4855-4383-a470-6233ecea427c X-Archives-Hash: 3e0740ce7ce292078500819c12ef4d55 commit: bad3db1d1b1e55e8597ea6a0b48d2dbda7a8a41d Author: Sven Eden gmx de> AuthorDate: Wed Jan 23 11:46:12 2013 +0000 Commit: Sven Eden gmx de> CommitDate: Wed Jan 23 11:46:12 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=bad3db1d Fixed scrollbar scaling and movement for filtered lists. --- ufed-curses.c | 52 ++++++++++++++++++++++++++++++++-------------------- 1 files changed, 32 insertions(+), 20 deletions(-) diff --git a/ufed-curses.c b/ufed-curses.c index b9e71b0..0f5e94e 100644 --- a/ufed-curses.c +++ b/ufed-curses.c @@ -22,6 +22,8 @@ struct window window[wCount] = { static const char *subtitle; static const struct key *keys; static struct item *items, *currentitem; +// Needed for the scrollbar and its mouse events +static int listHeight, barStart, barEnd, dispStart, dispEnd; /* external members */ @@ -158,23 +160,30 @@ void drawitems() { line = 0; } + // The display start line might differ from topline: + dispStart = item->listline; + for( ; line < wHeight(List); ) { item->currline = line; // drawitem() and maineventloop() need this line += drawitem(item, item == currentitem ? TRUE : FALSE); - item = item->next; - /* Add blank lines if we reached the end of the - * flag list, but not the end of the display. - */ - if((line < wHeight(List)) && (item == items)) { - char buf[wWidth(List)]; - memset(buf, ' ', wWidth(List)); - buf[wWidth(List)] = '\0'; - wmove(win(List), line, 0); - wattrset(win(List), COLOR_PAIR(3)); - while(line++ < wHeight(List)) - waddstr(win(List), buf); - } + if (line < wHeight(List)) { + item = item->next; + + /* Add blank lines if we reached the end of the + * flag list, but not the end of the display. + */ + if(item == items) { + char buf[wWidth(List)]; + memset(buf, ' ', wWidth(List)); + buf[wWidth(List)] = '\0'; + wmove(win(List), line, 0); + wattrset(win(List), COLOR_PAIR(3)); + while(line++ < wHeight(List)) + waddstr(win(List), buf); + } + } else + dispEnd = item->listline + item->ndescr; } wnoutrefresh(win(List)); } @@ -188,14 +197,19 @@ void drawscrollbar() { /* The scrollbar location differs related to the * current filtering of masked flags. */ - int listHeight = getListHeight(); + listHeight = getListHeight(); // Only show a scrollbar if the list is actually longer than can be displayed: if (listHeight > wHeight(List)) { int sbHeight = wHeight(Scrollbar) - 3; - int barStart = 1 + (currentitem->listline * sbHeight / bottomline); - int barEnd = barStart + (sbHeight * wHeight(List) / listHeight); + barStart = 1 + (dispStart * sbHeight / bottomline); + barEnd = barStart + ((dispEnd - dispStart) * wHeight(List) / bottomline); + // Strongly filtered lists scatter much and must be corrected: + if (barEnd > sbHeight) { + barStart -= barEnd - sbHeight; + barEnd -= barEnd - sbHeight; + } for ( ; barStart <= barEnd; ++barStart) mvwaddch(w, barStart, 0, ACS_BLOCK); } @@ -456,13 +470,9 @@ int maineventloop( } } else if(wmouse_trafo(win(Scrollbar), &event.y, &event.x, FALSE)) { // Only do mouse events if there actually is a scrollbar - int listHeight = getListHeight(); if( (listHeight > wHeight(List)) && (event.bstate & (BUTTON1_PRESSED | BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) && (event.y < wHeight(Scrollbar)-1) ) { - int sbHeight = wHeight(Scrollbar) - 3; - int barStart = 1 + (sbHeight / listHeight); - int barEnd = barStart + (sbHeight * wHeight(List) / listHeight); halfdelay(1); #define SIM(key) \ { \ @@ -489,7 +499,9 @@ int maineventloop( case KEY_MOUSE: if(getmouse(&event)==OK) { event.y -= wTop(Scrollbar) + 1; + int sbHeight = wHeight(Scrollbar) - 3; if( (event.y >= 0) && (event.y < sbHeight) ) { + /// TODO : This needs to be fixed! topline = (event.y * (listHeight - sbHeight + 2) + sbHeight - 1) / sbHeight; // was: topy = (event.y*(items->prev->top+items->prev->height-(wHeight(List)-1))+(wHeight(Scrollbar)-4))/(wHeight(Scrollbar)-3); while( (currentitem != items)