summaryrefslogtreecommitdiff
path: root/gtkplaylist.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-09-13 20:07:07 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-09-13 20:07:07 +0200
commit7e82428d7cd620626e49cf8b269ed70cba4d6770 (patch)
tree5e0af9bdf100adaa4851b1af82f8383caba9bffa /gtkplaylist.c
parent150e5f2e0436b16afd0d1f7a351ee81881498fba (diff)
optimized vertical scrolling
Diffstat (limited to 'gtkplaylist.c')
-rw-r--r--gtkplaylist.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/gtkplaylist.c b/gtkplaylist.c
index 89a3d6db..52a9c8b0 100644
--- a/gtkplaylist.c
+++ b/gtkplaylist.c
@@ -787,7 +787,7 @@ gtkpl_scroll (gtkplaylist_t *ps, int newscroll) {
if (newscroll != ps->scrollpos) {
#if 0
int d = abs (newscroll - ps->scrollpos);
- if (abs (newscroll - ps->scrollpos) < ps->nvisiblerows) {
+ if (d < ps->nvisiblerows) {
// move untouched cache part
// and invalidate changed part
if (newscroll < ps->scrollpos) {
@@ -816,9 +816,28 @@ gtkpl_scroll (gtkplaylist_t *ps, int newscroll) {
memset (ps->fmtcache, 0, sizeof (int16_t) * 3 * pl_ncolumns * ps->nvisiblerows);
}
#endif
- ps->scrollpos = newscroll;
GtkWidget *widget = ps->playlist;
- gtkpl_draw_playlist (ps, 0, 0, widget->allocation.width, widget->allocation.height);
+ int di = newscroll - ps->scrollpos;
+ int d = abs (di);
+ if (d < ps->nvisiblerows) {
+ if (di > 0) {
+ gdk_draw_drawable (ps->backbuf, widget->style->black_gc, ps->backbuf, 0, d * rowheight, 0, 0, widget->allocation.width, widget->allocation.height-d * rowheight);
+ int i;
+ ps->scrollpos = newscroll;
+ for (i = ps->nvisiblerows-d; i <= ps->nvisiblerows; i++) {
+ gtkpl_redraw_pl_row (ps, i+ps->scrollpos, gtkpl_get_for_idx (ps, i+ps->scrollpos));
+ }
+ }
+ else {
+ gdk_draw_drawable (ps->backbuf, widget->style->black_gc, ps->backbuf, 0, 0, 0, d*rowheight, widget->allocation.width, widget->allocation.height);
+ ps->scrollpos = newscroll;
+ int i;
+ for (i = 0; i <= d; i++) {
+ gtkpl_redraw_pl_row (ps, i+ps->scrollpos, gtkpl_get_for_idx (ps, i+ps->scrollpos));
+ }
+ }
+ }
+// gtkpl_draw_playlist (ps, 0, 0, widget->allocation.width, widget->allocation.height);
gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, 0, 0, 0, 0, widget->allocation.width, widget->allocation.height);
}
}