diff options
-rw-r--r-- | callbacks.c | 40 | ||||
-rw-r--r-- | gtkplaylist.c | 68 | ||||
-rw-r--r-- | gtkplaylist.h | 28 | ||||
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | search.c | 2 |
5 files changed, 104 insertions, 36 deletions
diff --git a/callbacks.c b/callbacks.c index 7fdfe6df..b0d5005e 100644 --- a/callbacks.c +++ b/callbacks.c @@ -116,7 +116,7 @@ on_playlist_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; // draw visible area of playlist gtkpl_expose (ps, event->area.x, event->area.y, event->area.width, event->area.height); @@ -129,7 +129,7 @@ on_playlist_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; if (event->button == 1) { gtkpl_mouse1_pressed (ps, event->state, event->x, event->y, event->time); } @@ -141,7 +141,7 @@ on_playlist_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; if (event->button == 1) { gtkpl_mouse1_released (ps, event->state, event->x, event->y, event->time); } @@ -153,7 +153,7 @@ on_playlist_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; gtkpl_mousemove (ps, event); return FALSE; } @@ -163,7 +163,7 @@ void on_playscroll_value_changed (GtkRange *widget, gpointer user_data) { - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; int newscroll = gtk_range_get_value (GTK_RANGE (widget)); gtkpl_scroll (ps, newscroll); } @@ -355,7 +355,7 @@ on_playlist_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; GdkEventScroll *ev = (GdkEventScroll*)event; gtkpl_handle_scroll_event (ps, ev->direction); return FALSE; @@ -435,7 +435,7 @@ on_playlist_drag_motion (GtkWidget *widget, guint time, gpointer user_data) { - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; gtkpl_track_dragdrop (ps, y); return FALSE; } @@ -508,7 +508,7 @@ on_playlist_drag_data_received (GtkWidget *widget, guint time, gpointer user_data) { - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; gchar *ptr=(char*)data->data; if (target_type == 0) { // uris if (!strncmp(ptr,"file:///",8)) { @@ -547,7 +547,7 @@ on_playlist_drag_leave (GtkWidget *widget, guint time, gpointer user_data) { - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; gtkpl_track_dragdrop (ps, -1); } @@ -846,23 +846,25 @@ seekbar_draw (GtkWidget *widget) { pos *= widget->allocation.width; } // left - cairo_set_source_rgb (cr, 0xf4/255.f, 0x7e/255.f, 0x46/255.f); - cairo_rectangle (cr, 0, widget->allocation.height/2-4, pos, 8); - cairo_clip (cr); - clearlooks_rounded_rectangle (cr, 0, widget->allocation.height/2-4, widget->allocation.width, 8, 4, 0xff); - cairo_fill (cr); - cairo_reset_clip (cr); + if (pos > 0) { + gtkpl_set_cairo_source_rgb (cr, COLO_SEEKBAR_FRONT); + cairo_rectangle (cr, 0, widget->allocation.height/2-4, pos, 8); + cairo_clip (cr); + clearlooks_rounded_rectangle (cr, 0, widget->allocation.height/2-4, widget->allocation.width, 8, 4, 0xff); + cairo_fill (cr); + cairo_reset_clip (cr); + } // right + gtkpl_set_cairo_source_rgb (cr, COLO_SEEKBAR_BACK); cairo_rectangle (cr, pos, widget->allocation.height/2-4, widget->allocation.width-pos, 8); cairo_clip (cr); - cairo_set_source_rgb (cr, 0x21/255.f, 0x23/255.f, 0x1f/255.f); clearlooks_rounded_rectangle (cr, 0, widget->allocation.height/2-4, widget->allocation.width, 8, 4, 0xff); cairo_fill (cr); cairo_reset_clip (cr); if (seekbar_moving) { - cairo_set_source_rgb (cr, 1,1,1); + gtkpl_set_cairo_source_rgb (cr, COLO_SEEKBAR_MARKER); int x = seekbar_move_x; if (x < 0) { x = 0; @@ -955,10 +957,10 @@ volumebar_draw (GtkWidget *widget) { int h = 16; for (int i = 0; i < n; i++) { if (i <= vol) { - cairo_set_source_rgb (cr, 0xf4/255.f, 0x7e/255.f, 0x46/255.f); + gtkpl_set_cairo_source_rgb (cr, COLO_VOLUMEBAR_FRONT); } else { - cairo_set_source_rgb (cr, 0x21/255.f, 0x23/255.f, 0x1f/255.f); + gtkpl_set_cairo_source_rgb (cr, COLO_VOLUMEBAR_BACK); } cairo_rectangle (cr, i * 4, (widget->allocation.height/2-h/2) + h - 1 - (h* i / n), 3, h * i / n); cairo_fill (cr); diff --git a/gtkplaylist.c b/gtkplaylist.c index ab336ddb..d17e2aa6 100644 --- a/gtkplaylist.c +++ b/gtkplaylist.c @@ -41,6 +41,29 @@ #include "streamer.h" #include "search.h" +// orange on dark color scheme +float colo_dark_orange[COLO_COUNT][3] = { + { 0x7f/255.f, 0x7f/255.f, 0x7f/255.f }, // cursor + { 0x1d/255.f, 0x1f/255.f, 0x1b/255.f }, // odd + { 0x21/255.f, 0x23/255.f, 0x1f/255.f }, // even + { 0xaf/255.f, 0xa7/255.f, 0x9e/255.f }, // sel odd + { 0xa7/255.f, 0x9f/255.f, 0x96/255.f }, // sel even + { 0xf4/255.f, 0x7e/255.f, 0x46/255.f }, // text + { 0, 0, 0 }, // sel text + { 0x1d/255.f, 0x1f/255.f, 0x1b/255.f }, // seekbar back + { 0xf4/255.f, 0x7e/255.f, 0x46/255.f }, // seekbar front + { 1, 1, 1 }, // seekbar marker + { 0x1d/255.f, 0x1f/255.f, 0x1b/255.f }, // volumebar back + { 0xf4/255.f, 0x7e/255.f, 0x46/255.f }, // volumebar front + { 0xf4/255.f, 0x7e/255.f, 0x46/255.f }, // dragdrop marker +}; + +// gtk color scheme +float colo_system_gtk[COLO_COUNT][3]; + +// current color scheme +float colo_current[COLO_COUNT][3]; + #define rowheight 17 const char *colnames[pl_ncolumns] = { "Playing", @@ -65,6 +88,16 @@ static cairo_surface_t *pause16_pixmap; // 50, 200, 50, 200, 50 //}; +void +gtkpl_system_colo_init (GtkWidget *widget) { +} + +// that must be called before gtk_init +void +gtkpl_init (void) { + memcpy (colo_current, colo_dark_orange, sizeof (colo_current)); +} + int gtkpl_fit_text (cairo_t *cr, char *out, int *dotpos, int len, const char *in, int width) { int l = strlen (in); @@ -179,6 +212,11 @@ gtkpl_redraw_pl_row (gtkplaylist_t *ps, int row) { } void +gtkpl_set_cairo_source_rgb (cairo_t *cr, int col) { + cairo_set_source_rgb (cr, colo_current[col][0], colo_current[col][1], colo_current[col][2]); +} + +void gtkpl_draw_pl_row_back (gtkplaylist_t *ps, cairo_t *cr, int row, playItem_t *it) { // draw background float w; @@ -189,26 +227,26 @@ gtkpl_draw_pl_row_back (gtkplaylist_t *ps, cairo_t *cr, int row, playItem_t *it) w = width; if (it && ((it->selected && ps->multisel) || (row == ps->row && !ps->multisel))) { if (row % 2) { - cairo_set_source_rgb (cr, 0xa7/255.f, 0x9f/255.f, 0x96/255.f); + gtkpl_set_cairo_source_rgb (cr, COLO_PLAYLIST_SEL_EVEN); } else { - cairo_set_source_rgb (cr, 0xaf/255.f, 0xa7/255.f, 0x9e/255.f); + gtkpl_set_cairo_source_rgb (cr, COLO_PLAYLIST_SEL_ODD); } cairo_rectangle (cr, 0, row * rowheight - ps->scrollpos * rowheight, width, rowheight); cairo_fill (cr); } else { if (row % 2) { - cairo_set_source_rgb (cr, 0x1d/255.f, 0x1f/255.f, 0x1b/255.f); + gtkpl_set_cairo_source_rgb (cr, COLO_PLAYLIST_EVEN); } else { - cairo_set_source_rgb (cr, 0x21/255.f, 0x23/255.f, 0x1f/255.f); + gtkpl_set_cairo_source_rgb (cr, COLO_PLAYLIST_ODD); } cairo_rectangle (cr, 0, row * rowheight - ps->scrollpos * rowheight, width, rowheight); cairo_fill (cr); } if (row == ps->row) { - cairo_set_source_rgb (cr, 0x7f/255.f, 0x7f/255.f, 0x7f/255.f); + gtkpl_set_cairo_source_rgb (cr, COLO_PLAYLIST_CURSOR); cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); cairo_rectangle (cr, 0, row * rowheight - ps->scrollpos * rowheight, width, rowheight-1); cairo_set_line_width (cr, 1); @@ -233,10 +271,10 @@ gtkpl_draw_pl_row (gtkplaylist_t *ps, cairo_t *cr, int row, playItem_t *it) { cairo_reset_clip (cr); } if (it && ((it->selected && ps->multisel) || (row == ps->row && !ps->multisel))) { - cairo_set_source_rgb (cr, 0, 0, 0); + gtkpl_set_cairo_source_rgb (cr, COLO_PLAYLIST_SEL_TEXT); } else { - cairo_set_source_rgb (cr, 0xf4/255.f, 0x7e/255.f, 0x46/255.f); + gtkpl_set_cairo_source_rgb (cr, COLO_PLAYLIST_TEXT); } cairo_set_font_size (cr, rowheight-4); // draw as columns @@ -375,7 +413,7 @@ on_playlist_configure_event (GtkWidget *widget, { extern void main_playlist_init (GtkWidget *widget); main_playlist_init (widget); - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; gtkpl_configure (ps); return FALSE; } @@ -575,7 +613,7 @@ gtkpl_draw_areasel (GtkWidget *widget, int x, int y) { if (!cr) { return; } - cairo_set_source_rgb (cr, 1.f, 1.f, 1.f); + gtkpl_set_cairo_source_rgb (cr, COLO_PLAYLIST_CURSOR); cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); cairo_set_line_width (cr, 1); int sx = min (areaselect_x, x); @@ -871,7 +909,7 @@ gtkpl_track_dragdrop (gtkplaylist_t *ps, int y) { } drag_motion_y = y / rowheight; - cairo_set_source_rgb (cr, 0xf4/255.f, 0x7e/255.f, 0x46/255.f); + gtkpl_set_cairo_source_rgb (cr, COLO_DRAGDROP_MARKER); cairo_rectangle (cr, 0, drag_motion_y * rowheight-1, widget->allocation.width, 3); cairo_rectangle (cr, 0, drag_motion_y * rowheight-3, 3, 7); cairo_rectangle (cr, widget->allocation.width-3, drag_motion_y * rowheight-3, 3, 7); @@ -950,7 +988,7 @@ on_playlist_drag_end (GtkWidget *widget, GdkDragContext *drag_context, gpointer user_data) { - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; // invalidate entire cache - slow, but rare memset (ps->fmtcache, 0, sizeof (int16_t) * 3 * pl_ncolumns * ps->nvisiblerows); gtkpl_draw_playlist (ps, 0, 0, widget->allocation.width, widget->allocation.height); @@ -1137,7 +1175,7 @@ on_header_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; gtkpl_header_draw (ps); return FALSE; } @@ -1175,7 +1213,7 @@ on_header_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; if (header_dragging >= 0) { gdk_window_set_cursor (widget->window, cursor_drag); } @@ -1233,7 +1271,7 @@ on_header_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; if (event->button == 1) { // start sizing/dragging header_dragging = -1; @@ -1264,7 +1302,7 @@ on_header_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; header_dragging = -1; header_sizing = -1; int x = 0; diff --git a/gtkplaylist.h b/gtkplaylist.h index 8cd6aa46..42b06ec7 100644 --- a/gtkplaylist.h +++ b/gtkplaylist.h @@ -23,11 +23,30 @@ #include <assert.h> #include "playlist.h" +// drag and drop targets enum { TARGET_URILIST, TARGET_SAMEWIDGET, }; +// color scheme constants +enum { + COLO_PLAYLIST_CURSOR, + COLO_PLAYLIST_ODD, + COLO_PLAYLIST_EVEN, + COLO_PLAYLIST_SEL_ODD, + COLO_PLAYLIST_SEL_EVEN, + COLO_PLAYLIST_TEXT, + COLO_PLAYLIST_SEL_TEXT, + COLO_SEEKBAR_BACK, + COLO_SEEKBAR_FRONT, + COLO_SEEKBAR_MARKER, + COLO_VOLUMEBAR_BACK, + COLO_VOLUMEBAR_FRONT, + COLO_DRAGDROP_MARKER, + COLO_COUNT +}; + #define pl_ncolumns 5 #define pl_colname_max 100 @@ -63,9 +82,13 @@ typedef struct { int colwidths[pl_ncolumns]; // current column widths } gtkplaylist_t; -#define GTKpl_PROLOGUE \ +#define GTKPL_PROLOGUE \ gtkplaylist_t *ps = (gtkplaylist_t *)gtk_object_get_data (GTK_OBJECT (widget), "ps"); assert (ps); +// that must be called before gtk_init +void +gtkpl_init (void); + void gtkpl_redraw_pl_row (gtkplaylist_t *ps, int row); @@ -170,4 +193,7 @@ gtkpl_pausesong (void); void gtkpl_playsongnum (int idx); +void +gtkpl_set_cairo_source_rgb (cairo_t *cr, int col); + #endif // __GTKPLAYLIST_H @@ -221,6 +221,8 @@ main (int argc, char *argv[]) { snprintf (dbconfdir, 1024, "%s/.config/deadbeef", homedir); mkdir (dbconfdir, 0755); + gtkpl_init (); + messagepump_init (); codec_init_locking (); streamer_init (); @@ -187,7 +187,7 @@ on_searchlist_configure_event (GtkWidget *widget, { extern void search_playlist_init (GtkWidget *widget); search_playlist_init (widget); - GTKpl_PROLOGUE; + GTKPL_PROLOGUE; gtkpl_configure (ps); return FALSE; } |