diff options
author | Christian Boxdörfer <christian.boxdoerfer@posteo.de> | 2013-11-13 21:57:44 +0100 |
---|---|---|
committer | Alexey Yakovenko <waker@users.sourceforge.net> | 2014-02-06 21:10:35 +0100 |
commit | b44e529f207e8bdca89aec0f44898e8f2f54a390 (patch) | |
tree | 337381832872a484a138c67da9addcff7cdabaa4 /plugins/gtkui | |
parent | 2d43b60ad0d41204424296f3403eaa7eadda73da (diff) |
gtkui: improved performance when resizing album art column
Diffstat (limited to 'plugins/gtkui')
-rw-r--r-- | plugins/gtkui/ddblistview.c | 36 | ||||
-rw-r--r-- | plugins/gtkui/ddblistview.h | 1 |
2 files changed, 36 insertions, 1 deletions
diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c index af9423f6..23e89ec2 100644 --- a/plugins/gtkui/ddblistview.c +++ b/plugins/gtkui/ddblistview.c @@ -79,6 +79,8 @@ static void ddb_listview_destroy(GObject *object); void ddb_listview_build_groups (DdbListview *listview); +static void +ddb_listview_resize_groups (DdbListview *listview); // fwd decls void ddb_listview_free_groups (DdbListview *listview); @@ -2533,7 +2535,7 @@ ddb_listview_header_motion_notify_event (GtkWidget *widget, c->fwidth = (float)c->width / ps->header_width; } if (c->minheight) { - ddb_listview_build_groups (ps); + ddb_listview_resize_groups (ps); } ps->block_redraw_on_scroll = 1; ddb_listview_list_setup_vscroll (ps); @@ -3216,6 +3218,38 @@ ddb_listview_build_groups (DdbListview *listview) { } void +ddb_listview_resize_groups (DdbListview *listview) { + deadbeef->pl_lock (); + int old_height = listview->fullheight; + int grp_height_old = 0; + listview->fullheight = 0; + + int min_height= 0; + DdbListviewColumn *c; + for (c = listview->columns; c; c = c->next) { + if (c->minheight && c->width > min_height) { + min_height = c->width; + } + } + + DdbListviewGroup *grp = listview->groups; + while (grp) { + grp->height = listview->grouptitle_height + grp->num_items * listview->rowheight; + if (grp->height - listview->grouptitle_height < min_height) { + grp_height_old = grp->height; + grp->height = min_height + listview->grouptitle_height; + } + listview->fullheight += grp->height; + grp = grp->next; + } + + deadbeef->pl_unlock (); + if (old_height != listview->fullheight) { + ddb_listview_refresh (listview, DDB_REFRESH_VSCROLL); + } +} + +void ddb_listview_set_vscroll (DdbListview *listview, int scroll) { GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (listview->scrollbar)); gtk_range_set_value (GTK_RANGE (listview->scrollbar), scroll); diff --git a/plugins/gtkui/ddblistview.h b/plugins/gtkui/ddblistview.h index 7dc048da..3e7d24d1 100644 --- a/plugins/gtkui/ddblistview.h +++ b/plugins/gtkui/ddblistview.h @@ -47,6 +47,7 @@ typedef void * DdbPlaylistHandle; struct _DdbListviewGroup { DdbListviewIter head; int32_t height; + int32_t min_height; int32_t num_items; int pinned; struct _DdbListviewGroup *next; |