summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Christian Boxdörfer <christian.boxdoerfer@posteo.de>2014-02-02 21:21:21 +0100
committerGravatar Alexey Yakovenko <waker@users.sourceforge.net>2014-04-07 08:51:02 +0200
commit32a4716ec730785c9d4948d629b8f864602d616e (patch)
treef06542cd6ebac49a854a4d9e3698d38b12ad236f /plugins
parentae424856f80cffa876fcba36aebc205ac4d7f923 (diff)
gtkui: single click in album art column selects group and double click plays first track of group
Diffstat (limited to 'plugins')
-rw-r--r--plugins/gtkui/ddblistview.c37
-rw-r--r--plugins/gtkui/ddblistview.h8
-rw-r--r--plugins/gtkui/plcommon.h5
3 files changed, 42 insertions, 8 deletions
diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c
index af2e65e5..58656663 100644
--- a/plugins/gtkui/ddblistview.c
+++ b/plugins/gtkui/ddblistview.c
@@ -602,6 +602,28 @@ ddb_listview_groupcheck (DdbListview *listview) {
}
}
+// returns 1 if X coordinate in list belongs to album art column and 0 if not
+int
+ddb_listview_is_album_art_column (DdbListview *listview, int x)
+{
+ int album_art_column = 0;
+ int col_x = 0;
+ int cnt = ddb_listview_column_get_count (listview);
+ for (int i = 0; i < cnt, col_x <= x; i++) {
+ const char *title;
+ int width;
+ int align_right;
+ col_info_t *info;
+ int minheight;
+ int res = ddb_listview_column_get_info (listview, i, &title, &width, &align_right, &minheight, (void **)&info);
+ if (res != -1 && x <= col_x + width && info->id == DB_COLUMN_ALBUM_ART) {
+ return 1;
+ }
+ col_x += width;
+ }
+ return 0;
+}
+
// returns Y coordinate of an item by its index
int
ddb_listview_get_row_pos (DdbListview *listview, int row_idx) {
@@ -642,7 +664,7 @@ ddb_listview_list_pickpoint_y (DdbListview *listview, int y, DdbListviewGroup **
y -= grp_y;
if (y < listview->grouptitle_height) {
*group_idx = -1;
- *global_idx = -1;
+ *global_idx = idx;
}
else if (y >= listview->grouptitle_height + grp->num_items * listview->rowheight) {
*group_idx = (y - listview->grouptitle_height) / listview->rowheight;
@@ -1428,7 +1450,11 @@ ddb_listview_click_selection (DdbListview *ps, int ex, int ey, DdbListviewGroup
deadbeef->pl_lock ();
ps->areaselect = 0;
ddb_listview_groupcheck (ps);
- if (sel == -1 && (!grp || (ey > ps->grouptitle_height && grp_index >= grp->num_items))) {
+
+ // clicked album art column?
+ int album_art_column = ddb_listview_is_album_art_column (ps, ex);
+
+ if (sel == -1 && !album_art_column && (!grp || (ey > ps->grouptitle_height && grp_index >= grp->num_items))) {
// clicked empty space, deselect everything
DdbListviewIter it;
int idx = 0;
@@ -1443,7 +1469,7 @@ ddb_listview_click_selection (DdbListview *ps, int ex, int ey, DdbListviewGroup
it = next;
}
}
- else if ((sel == -1 && grp) || (ey <= ps->grouptitle_height && gtkui_groups_pinned)) {
+ else if ((sel != -1 && grp && grp_index == -1) || (ey <= ps->grouptitle_height && gtkui_groups_pinned) || album_art_column) {
// clicked group title, select group
DdbListviewIter it;
int idx = 0;
@@ -1555,6 +1581,11 @@ ddb_listview_list_mouse1_pressed (DdbListview *ps, int state, int ex, int ey, Gd
int prev = cursor;
if (sel != -1) {
+ // pick 1st item in group in case album art column was clicked
+ if (ddb_listview_is_album_art_column (ps, ex) && grp_index != -1) {
+ sel -= grp_index;
+ }
+
ps->binding->set_cursor (sel);
DdbListviewIter it = ps->binding->get_for_idx (sel);
if (it) {
diff --git a/plugins/gtkui/ddblistview.h b/plugins/gtkui/ddblistview.h
index 46ae86d7..53db2a60 100644
--- a/plugins/gtkui/ddblistview.h
+++ b/plugins/gtkui/ddblistview.h
@@ -38,6 +38,11 @@ G_BEGIN_DECLS
#define DDB_IS_LISTVIEW_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), DDB_TYPE_LISTVIEW))
#define DDB_LISTVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DDB_TYPE_LISTVIEW, DdbListviewClass))
+typedef struct {
+ int id;
+ char *format;
+} col_info_t;
+
typedef struct _DdbListview DdbListview;
typedef struct _DdbListviewClass DdbListviewClass;
@@ -289,6 +294,9 @@ ddb_listview_get_row_pos (DdbListview *listview, int row_idx);
void
ddb_listview_groupcheck (DdbListview *listview);
+int
+ddb_listview_is_album_art_column (DdbListview *listview, int x);
+
G_END_DECLS
#endif // __DDBLISTVIEW_H
diff --git a/plugins/gtkui/plcommon.h b/plugins/gtkui/plcommon.h
index 3f82a732..ed68320d 100644
--- a/plugins/gtkui/plcommon.h
+++ b/plugins/gtkui/plcommon.h
@@ -21,11 +21,6 @@
#include "ddblistview.h"
-typedef struct {
- int id;
- char *format;
-} col_info_t;
-
#define MAX_GROUP_BY_STR 100
extern char group_by_str[MAX_GROUP_BY_STR];