From: Jim Evins Date: Thu, 5 Apr 2007 03:16:38 +0000 (+0000) Subject: 2007-04-04 Jim Evins X-Git-Tag: glabels-2_3_0~347 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b84b6dc42d8058bf402d94381a1c04f000b1eaa5;p=glabels 2007-04-04 Jim Evins * src/mini-preview-pixbuf.c: (gl_mini_preview_pixbuf_new), (draw_paper), (draw_label_outlines), (draw_rect_label_outline), (draw_round_label_outline), (draw_cd_label_outline): * src/wdgt-media-select.c: (load_list): * src/wdgt-rotate-label.c: (draw_cd_label_outline): Cosmetic enhancments to mini previews. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@649 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index abb20f87..01f21220 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,12 @@ +2007-04-04 Jim Evins + + * src/mini-preview-pixbuf.c: (gl_mini_preview_pixbuf_new), + (draw_paper), (draw_label_outlines), (draw_rect_label_outline), + (draw_round_label_outline), (draw_cd_label_outline): + * src/wdgt-media-select.c: (load_list): + * src/wdgt-rotate-label.c: (draw_cd_label_outline): + Cosmetic enhancments to mini previews. + 2007-04-04 Jim Evins * src/ui-property-bar.c: (gl_ui_property_bar_finalize), diff --git a/glabels2/src/mini-preview-pixbuf.c b/glabels2/src/mini-preview-pixbuf.c index 6d2a6fc8..a2159e8f 100644 --- a/glabels2/src/mini-preview-pixbuf.c +++ b/glabels2/src/mini-preview-pixbuf.c @@ -110,7 +110,7 @@ gl_mini_preview_pixbuf_new (glTemplate *template, cairo_paint (cr); cairo_restore (cr); - cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT); + cairo_set_antialias (cr, CAIRO_ANTIALIAS_GRAY); /* Set scale and offset */ w = width - 1; @@ -149,8 +149,9 @@ draw_paper (cairo_t *cr, gl_debug (DEBUG_MINI_PREVIEW, "START"); cairo_save (cr); + //cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); cairo_rectangle (cr, 0.0, 0.0, template->page_width, template->page_height); - cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); + cairo_set_source_rgb (cr, 0.95, 0.95, 0.95); cairo_fill_preserve (cr); cairo_set_line_width (cr, 1/scale); cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); @@ -177,7 +178,6 @@ draw_label_outlines (cairo_t *cr, cairo_save (cr); cairo_set_line_width (cr, 1.0/scale); - cairo_set_source_rgb (cr, 0.5, 0.5, 0.5); label_type = gl_template_get_first_label_type (template); @@ -254,10 +254,17 @@ draw_rect_label_outline (cairo_t *cr, cairo_save (cr); + //cairo_set_antialias (cr, CAIRO_ANTIALIAS_GRAY); + label_type = gl_template_get_first_label_type (template); gl_template_get_label_size (label_type, &w, &h); cairo_rectangle (cr, x0, y0, w, h); + + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); + cairo_fill_preserve (cr); + + cairo_set_source_rgb (cr, 0.25, 0.25, 0.25); cairo_stroke (cr); cairo_restore (cr); @@ -281,10 +288,17 @@ draw_round_label_outline (cairo_t *cr, cairo_save (cr); + //cairo_set_antialias (cr, CAIRO_ANTIALIAS_GRAY); + label_type = gl_template_get_first_label_type (template); gl_template_get_label_size (label_type, &w, &h); cairo_arc (cr, x0+w/2, y0+h/2, w/2, 0.0, 2*M_PI); + + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); + cairo_fill_preserve (cr); + + cairo_set_source_rgb (cr, 0.25, 0.25, 0.25); cairo_stroke (cr); cairo_restore (cr); @@ -305,11 +319,15 @@ draw_cd_label_outline (cairo_t *cr, gdouble w, h; gdouble xc, yc; gdouble r1, r2; + gdouble theta1, theta2; + gl_debug (DEBUG_MINI_PREVIEW, "START"); cairo_save (cr); + //cairo_set_antialias (cr, CAIRO_ANTIALIAS_GRAY); + label_type = gl_template_get_first_label_type (template); gl_template_get_label_size (label_type, &w, &h); @@ -319,31 +337,27 @@ draw_cd_label_outline (cairo_t *cr, r1 = label_type->size.cd.r1; r2 = label_type->size.cd.r2; - if ( w == h ) - { - /* Simple CD */ - cairo_arc (cr, xc, yc, r1, 0.0, 2*M_PI); - cairo_stroke (cr); - } - else - { - /* Credit Card CD (One or both dimensions trucated) */ - gdouble theta1, theta2; - - theta1 = acos (w / (2.0*r1)); - theta2 = asin (h / (2.0*r1)); - - cairo_new_path (cr); - cairo_arc (cr, xc, yc, r1, theta1, theta2); - cairo_arc (cr, xc, yc, r1, M_PI-theta2, M_PI-theta1); - cairo_arc (cr, xc, yc, r1, M_PI+theta1, M_PI+theta2); - cairo_arc (cr, xc, yc, r1, 2*M_PI-theta2, 2*M_PI-theta1); - cairo_close_path (cr); - cairo_stroke (cr); - } + theta1 = acos (w / (2.0*r1)); + theta2 = asin (h / (2.0*r1)); + + /* Outer radius, may be clipped in the case of business card CDs. */ + /* Do as a series of 4 arcs, to account for clipping. */ + cairo_new_path (cr); + cairo_arc (cr, xc, yc, r1, theta1, theta2); + cairo_arc (cr, xc, yc, r1, M_PI-theta2, M_PI-theta1); + cairo_arc (cr, xc, yc, r1, M_PI+theta1, M_PI+theta2); + cairo_arc (cr, xc, yc, r1, 2*M_PI-theta2, 2*M_PI-theta1); + cairo_close_path (cr); /* Hole */ + cairo_new_sub_path (cr); cairo_arc (cr, xc, yc, r2, 0.0, 2*M_PI); + + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); + cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); + cairo_fill_preserve (cr); + + cairo_set_source_rgb (cr, 0.25, 0.25, 0.25); cairo_stroke (cr); cairo_restore (cr); diff --git a/glabels2/src/wdgt-media-select.c b/glabels2/src/wdgt-media-select.c index c9dee67d..a33029a9 100644 --- a/glabels2/src/wdgt-media-select.c +++ b/glabels2/src/wdgt-media-select.c @@ -596,7 +596,7 @@ load_list (GtkListStore *store, template = gl_template_from_name (p->data); - pixbuf = gl_mini_preview_pixbuf_new (template, 64, 64); + pixbuf = gl_mini_preview_pixbuf_new (template, 72, 72); size = get_label_size_desc (template); layout = get_layout_desc (template); diff --git a/glabels2/src/wdgt-rotate-label.c b/glabels2/src/wdgt-rotate-label.c index 3c38a5ee..f0f19ce2 100644 --- a/glabels2/src/wdgt-rotate-label.c +++ b/glabels2/src/wdgt-rotate-label.c @@ -399,6 +399,7 @@ draw_cd_label_outline (cairo_t *cr, const glTemplateLabelType *label_type; gdouble w, h; gdouble r1, r2; + gdouble theta1, theta2; gl_debug (DEBUG_MINI_PREVIEW, "START"); @@ -410,30 +411,27 @@ draw_cd_label_outline (cairo_t *cr, r1 = label_type->size.cd.r1; r2 = label_type->size.cd.r2; - if ( w == h ) - { - /* Simple CD */ - cairo_arc (cr, 0.0, 0.0, r1, 0.0, 2*M_PI); - } - else - { - /* Credit Card CD (One or both dimensions trucated) */ - gdouble theta1, theta2; - - theta1 = acos (w / (2.0*r1)); - theta2 = asin (h / (2.0*r1)); - - cairo_new_path (cr); - cairo_arc (cr, 0.0, 0.0, r1, theta1, theta2); - cairo_arc (cr, 0.0, 0.0, r1, M_PI-theta2, M_PI-theta1); - cairo_arc (cr, 0.0, 0.0, r1, M_PI+theta1, M_PI+theta2); - cairo_arc (cr, 0.0, 0.0, r1, 2*M_PI-theta2, 2*M_PI-theta1); - cairo_close_path (cr); - } + /* Outer radius, may be clipped in the case of business card CDs. */ + /* Do as a series of 4 arcs, to account for clipping. */ + theta1 = acos (w / (2.0*r1)); + theta2 = asin (h / (2.0*r1)); + + cairo_new_path (cr); + cairo_arc (cr, 0.0, 0.0, r1, theta1, theta2); + cairo_arc (cr, 0.0, 0.0, r1, M_PI-theta2, M_PI-theta1); + cairo_arc (cr, 0.0, 0.0, r1, M_PI+theta1, M_PI+theta2); + cairo_arc (cr, 0.0, 0.0, r1, 2*M_PI-theta2, 2*M_PI-theta1); + cairo_close_path (cr); + + /* Hole */ + cairo_new_sub_path (cr); + cairo_arc (cr, 0.0, 0.0, r2, 0.0, 2*M_PI); + cairo_set_source_rgb (cr, GL_COLOR_F_RED(fill_color), GL_COLOR_F_GREEN(fill_color), GL_COLOR_F_BLUE(fill_color)); + cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_fill_preserve (cr); cairo_set_source_rgb (cr, @@ -442,10 +440,6 @@ draw_cd_label_outline (cairo_t *cr, GL_COLOR_F_BLUE(line_color)); cairo_stroke (cr); - /* Hole */ - cairo_arc (cr, 0.0, 0.0, r2, 0.0, 2*M_PI); - cairo_stroke (cr); - cairo_restore (cr); gl_debug (DEBUG_MINI_PREVIEW, "END");