summaryrefslogtreecommitdiff
path: root/gtkplaylist.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-09-13 20:09:25 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-09-13 20:09:25 +0200
commit5644e30666647b94f75f86607e945c3b263ba73b (patch)
tree3f9bb3d9ac2a4018d0ca349d82528bcc97afdcc6 /gtkplaylist.c
parent7e82428d7cd620626e49cf8b269ed70cba4d6770 (diff)
playlist drawing code cleanup
Diffstat (limited to 'gtkplaylist.c')
-rw-r--r--gtkplaylist.c171
1 files changed, 0 insertions, 171 deletions
diff --git a/gtkplaylist.c b/gtkplaylist.c
index 52a9c8b0..a3accbb1 100644
--- a/gtkplaylist.c
+++ b/gtkplaylist.c
@@ -118,96 +118,6 @@ theme_set_bg_color (int col) {
draw_set_bg_color (colo_current[col]);
}
-#if 0
-static int avg_glyph_width = -1;
-static int tridot_len = -1;
-
-int
-gtkpl_fit_text (char *out, int *dotpos, int len, const char *in, int width) {
- if (avg_glyph_width == -1) {
- int h;
- draw_get_text_extents ("a", 1, &avg_glyph_width, &h);
- tridot_len = strlen ("…");
- }
- int l = strlen (in);
- len--;
- l = min (len, l);
- strncpy (out, in, l);
- out[l] = 0;
- int w = 0;
-
- if (dotpos) {
- *dotpos = -1;
- }
- return width;
-#if 1
- // initial approximation
- int u8len = g_utf8_strlen (in, l);
- int apx_len = width / avg_glyph_width;
- char *p;
- if (apx_len >= u8len) {
- int h;
- draw_get_text_extents (out, l, &w, &h);
- if (w <= width) {
- return w;
- }
- // start from end
- p = g_utf8_find_prev_char (out, &out[l]);
- }
- else {
- p = &out[l];
- while (u8len > apx_len) {
- p = g_utf8_find_prev_char (out, p);
- l = p - out;
- if (!p) {
- strcpy (out, "…");
- return tridot_len;
- }
- u8len--;
- }
- for (;;) {
- int h;
- draw_get_text_extents (out, l, &w, &h);
- if (w > width) {
- break;
- }
- char *next = g_utf8_find_next_char (p, NULL);
- if (!next) {
- break;
- }
- if (next - out == l) {
- break;
- }
- l = next - out;
- p = next;
- }
- }
-#else
- char *p = &out[l];
- p = g_utf8_find_prev_char (out, p);
-#endif
- for (;;) {
- int h;
- draw_get_text_extents (out, l, &w, &h);
- if (w <= width) {
- break;
- }
- char *prev = g_utf8_find_prev_char (out, p);
-
- if (!prev) {
- break;
- }
- strcpy (prev, "…");
- l = prev - out + tridot_len;
- p = prev;
- if (dotpos) {
- *dotpos = p-out;
- }
- }
- return w;
-}
-#endif
-
void
gtkpl_setup_scrollbar (gtkplaylist_t *ps) {
GtkWidget *playlist = ps->playlist;
@@ -284,7 +194,6 @@ gtkpl_redraw_pl_row (gtkplaylist_t *ps, int row, playItem_t *it) {
gtkpl_redraw_pl_row_novis (ps, row, it);
gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, x, y, x, y, w, h);
- //gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, 0, 0, 0, 0, widget->allocation.width, widget->allocation.height);
}
void
@@ -387,30 +296,10 @@ gtkpl_draw_pl_row (gtkplaylist_t *ps, int row, playItem_t *it) {
};
int x = -ps->hscrollpos;
for (int i = 0; i < pl_ncolumns; i++) {
-// char str[512];
if (i > 0) {
int dotpos;
int cidx = ((row-ps->scrollpos) * pl_ncolumns + i) * 3;
-#if 0
- if (!ps->fmtcache[cidx + 2]) {
-// gtkpl_set_cairo_font (cr);
- ps->fmtcache[cidx + 1] = gtkpl_fit_text (str, &dotpos, 512, columns[i], ps->colwidths[i]-10);
- ps->fmtcache[cidx + 0] = dotpos;
- ps->fmtcache[cidx + 2] = 1;
-
- }
- else {
- // reconstruct from cache
- dotpos = ps->fmtcache[cidx + 0];
- strncpy (str, columns[i], 512);
- if (dotpos >= 0) {
- strcpy (str+dotpos, "…");
- }
- }
-#endif
- //int w = ps->fmtcache[cidx + 1];
-// printf ("draw %s -> %s\n", columns[i], str);
if (i == 2) {
draw_text_with_colors (x+5, row * rowheight - ps->scrollpos * rowheight + rowheight/2 - draw_get_font_size ()/2, ps->colwidths[i]-10, 1, columns[i]);
}
@@ -429,12 +318,6 @@ gtkpl_draw_playlist (gtkplaylist_t *ps, int x, int y, int w, int h) {
if (!ps->backbuf) {
return;
}
-#if 0
- if (!ps->fmtcache && ps->nvisiblerows > 0 && pl_ncolumns > 0) {
- ps->fmtcache = malloc (ps->nvisiblerows * pl_ncolumns * 3 * sizeof (int16_t));
- memset (ps->fmtcache, 0, ps->nvisiblerows * pl_ncolumns * 3 * sizeof (int16_t));
- }
-#endif
draw_begin ((uintptr_t)ps->backbuf);
int row;
int row1;
@@ -471,12 +354,6 @@ gtkpl_configure (gtkplaylist_t *ps) {
g_object_unref (ps->backbuf);
ps->backbuf = NULL;
}
-#if 0
- if (ps->fmtcache) {
- free (ps->fmtcache);
- ps->fmtcache = NULL;
- }
-#endif
ps->nvisiblerows = ceil (widget->allocation.height / (float)rowheight);
ps->nvisiblefullrows = floor (widget->allocation.height / (float)rowheight);
ps->backbuf = gdk_pixmap_new (widget->window, widget->allocation.width, widget->allocation.height, -1);
@@ -785,37 +662,6 @@ gtkpl_handle_scroll_event (gtkplaylist_t *ps, int direction) {
void
gtkpl_scroll (gtkplaylist_t *ps, int newscroll) {
if (newscroll != ps->scrollpos) {
-#if 0
- int d = abs (newscroll - ps->scrollpos);
- if (d < ps->nvisiblerows) {
- // move untouched cache part
- // and invalidate changed part
- if (newscroll < ps->scrollpos) {
- //printf ("scroll up\n");
- int r;
- for (r = ps->nvisiblerows-1; r >= d; r--) {
- memcpy (&ps->fmtcache[r * pl_ncolumns * 3], &ps->fmtcache[(r - d) * pl_ncolumns * 3], sizeof (int16_t) * 3 * pl_ncolumns);
- }
- for (r = 0; r < d; r++) {
- memset (&ps->fmtcache[r * pl_ncolumns * 3], 0, sizeof (int16_t) * 3 * pl_ncolumns);
- }
- }
- else {
- //printf ("scroll down\n");
- int r;
- for (r = 0; r < ps->nvisiblerows-d; r++) {
- memcpy (&ps->fmtcache[r * pl_ncolumns * 3], &ps->fmtcache[(r + d) * pl_ncolumns * 3], sizeof (int16_t) * 3 * pl_ncolumns);
- }
- for (r = ps->nvisiblerows-d; r < ps->nvisiblerows; r++) {
- memset (&ps->fmtcache[r * pl_ncolumns * 3], 0, sizeof (int16_t) * 3 * pl_ncolumns);
- }
- }
- }
- else {
- // invalidate entire cache
- memset (ps->fmtcache, 0, sizeof (int16_t) * 3 * pl_ncolumns * ps->nvisiblerows);
- }
-#endif
GtkWidget *widget = ps->playlist;
int di = newscroll - ps->scrollpos;
int d = abs (di);
@@ -837,7 +683,6 @@ gtkpl_scroll (gtkplaylist_t *ps, int newscroll) {
}
}
}
-// gtkpl_draw_playlist (ps, 0, 0, widget->allocation.width, widget->allocation.height);
gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, 0, 0, 0, 0, widget->allocation.width, widget->allocation.height);
}
}
@@ -1132,7 +977,6 @@ on_playlist_drag_end (GtkWidget *widget,
{
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);
gtkpl_expose (ps, 0, 0, widget->allocation.width, widget->allocation.height);
}
@@ -1288,12 +1132,6 @@ gtkpl_header_draw (gtkplaylist_t *ps) {
}
w = ps->colwidths[i];
if (w > 0) {
-#if 0
- if (!ps->header_fitted[i]) {
- gtkpl_fit_text (ps->colnames_fitted[i], NULL, pl_colname_max, colnames[i], ps->colwidths[i]-10);
- ps->header_fitted[i] = 1;
- }
-#endif
GdkColor *gdkfg = &widget->style->fg[0];
float fg[3] = {(float)gdkfg->red/0xffff, (float)gdkfg->green/0xffff, (float)gdkfg->blue/0xffff};
draw_set_fg_color (fg);
@@ -1378,14 +1216,6 @@ on_header_motion_notify_event (GtkWidget *widget,
}
int newx = event->x > x + 40 ? event->x : x + 40;
ps->colwidths[header_sizing] = newx - x;
- //printf ("ev->x = %d, w = %d\n", (int)event->x, newx - x - 2);
-#if 0
- ps->header_fitted[header_sizing] = 0;
- for (int k = 0; k < ps->nvisiblerows; k++) {
- int cidx = (k * pl_ncolumns + header_sizing) * 3;
- ps->fmtcache[cidx+2] = 0;
- }
-#endif
gtkpl_setup_hscrollbar (ps);
gtkpl_header_draw (ps);
gtkpl_expose_header (ps, 0, 0, ps->header->allocation.width, ps->header->allocation.height);
@@ -1562,7 +1392,6 @@ void
playlist_refresh (void) {
extern gtkplaylist_t main_playlist;
gtkplaylist_t *ps = &main_playlist;
- //memset (ps->fmtcache, 0, sizeof (int16_t) * 3 * pl_ncolumns * ps->nvisiblerows);
gtkpl_setup_scrollbar (ps);
GtkWidget *widget = ps->playlist;
gtkpl_draw_playlist (ps, 0, 0, widget->allocation.width, widget->allocation.height);