diff options
author | 2013-11-09 02:56:15 +0100 | |
---|---|---|
committer | 2014-02-06 21:04:54 +0100 | |
commit | 2d43b60ad0d41204424296f3403eaa7eadda73da (patch) | |
tree | 1efb4c1d32fd591ad79003ed0809da23c5f5337d /plugins/gtkui | |
parent | c8e23252ef05655cfa55bc02bc1ce4b9e6f33458 (diff) |
gtkui: fixed scrolling when resizing album art column
Diffstat (limited to 'plugins/gtkui')
-rw-r--r-- | plugins/gtkui/ddblistview.c | 42 | ||||
-rw-r--r-- | plugins/gtkui/ddblistview.h | 3 | ||||
-rw-r--r-- | plugins/gtkui/mainplaylist.c | 4 |
3 files changed, 49 insertions, 0 deletions
diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c index af2e65e5..af9423f6 100644 --- a/plugins/gtkui/ddblistview.c +++ b/plugins/gtkui/ddblistview.c @@ -291,6 +291,9 @@ ddb_listview_init(DdbListview *listview) listview->col_movepos = -1; listview->drag_motion_y = -1; + listview->ref_point = -1; + listview->ref_point_offset = -1; + listview->scroll_mode = 0; listview->scroll_pointer_y = -1; listview->scroll_direction = 0; @@ -2587,6 +2590,45 @@ ddb_listview_header_button_press_event (GtkWidget *widget, DdbListview *ps = DDB_LISTVIEW (g_object_get_data (G_OBJECT (widget), "owner")); // ps->active_column = ddb_listview_header_get_column_for_coord (ps, event->x); if (TEST_LEFT_CLICK (event)) { + + ddb_listview_groupcheck (ps); + DdbListviewGroup *grp = ps->groups; + DdbListviewGroup *grp_next; + + if (grp && ps->scrollpos > 0) { + int abs_idx = 0; + int grp_y = 0; + + GtkAllocation a; + gtk_widget_get_allocation (ps->list, &a); + int cursor_pos = ddb_listview_get_row_pos (ps, ps->binding->cursor ()); + ps->ref_point = 0; + ps->ref_point_offset = 0; + + // find 1st group + while (grp && grp_y + grp->height < ps->scrollpos) { + grp_y += grp->height; + abs_idx += grp->num_items; + grp = grp->next; + } + // choose cursor_pos as anchor + if (ps->scrollpos < cursor_pos && cursor_pos < ps->scrollpos + a.height && cursor_pos < ps->fullheight) { + ps->ref_point = ps->binding->cursor (); + ps->ref_point_offset = cursor_pos - ps->scrollpos; + } + // choose first group as anchor + else if (ps->scrollpos < grp_y + ps-> grouptitle_height + (grp->num_items * ps->rowheight) && grp_y + ps-> grouptitle_height + (grp->num_items * ps->rowheight) < ps->scrollpos + a.height) { + ps->ref_point = abs_idx; + ps->ref_point_offset = (grp_y + ps->grouptitle_height) - ps->scrollpos; + } + // choose next group as anchor + else { + grp_y += grp->height; + abs_idx += grp->num_items; + ps->ref_point = abs_idx; + ps->ref_point_offset = (grp_y + ps->grouptitle_height) - ps->scrollpos; + } + } // start sizing/dragging ps->header_dragging = -1; ps->header_sizing = -1; diff --git a/plugins/gtkui/ddblistview.h b/plugins/gtkui/ddblistview.h index 46ae86d7..7dc048da 100644 --- a/plugins/gtkui/ddblistview.h +++ b/plugins/gtkui/ddblistview.h @@ -127,6 +127,9 @@ struct _DdbListview { int drag_motion_y; + int ref_point; // idx of anchor when columns are resized + int ref_point_offset; // y pixel-coordinate of anchor relative to view + // scrolling int scroll_mode; // 0=select, 1=dragndrop int scroll_pointer_y; diff --git a/plugins/gtkui/mainplaylist.c b/plugins/gtkui/mainplaylist.c index cf656d4e..926e6cbb 100644 --- a/plugins/gtkui/mainplaylist.c +++ b/plugins/gtkui/mainplaylist.c @@ -250,6 +250,10 @@ main_column_size_changed (DdbListview *listview, int col) { return; } if (inf->id == DB_COLUMN_ALBUM_ART) { + if (listview->scrollpos > 0) { + int pos = ddb_listview_get_row_pos (listview, listview->ref_point); + gtk_range_set_value (GTK_RANGE (listview->scrollbar), pos - listview->ref_point_offset); + } coverart_reset_queue (); ddb_playlist_t *plt = deadbeef->plt_get_curr (); if (plt) { |