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-02-06 21:11:06 +0100
commit6cf35931c8c78fbe55fc7dc341b7538e222c8799 (patch)
tree292751b7ca7c972a631273fadc500efd14c3f16e /plugins
parentb44e529f207e8bdca89aec0f44898e8f2f54a390 (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 23e89ec2..8cff479e 100644
--- a/plugins/gtkui/ddblistview.c
+++ b/plugins/gtkui/ddblistview.c
@@ -607,6 +607,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) {
@@ -647,7 +669,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;
@@ -1433,7 +1455,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;
@@ -1448,7 +1474,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;
@@ -1560,6 +1586,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 3e7d24d1..372bcb3c 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;
@@ -293,6 +298,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];