+2007-04-11 Jim Evins <evins@snaught.com>
+
+ * src/cairo-label-path.c: (gl_cairo_label_path),
+ (gl_cairo_rect_label_path), (gl_cairo_round_label_path),
+ (gl_cairo_cd_label_path):
+ * src/cairo-label-path.h:
+ * src/mini-preview-pixbuf.c: (draw_paper), (draw_label_outlines),
+ (draw_label_outline):
+ * src/print.c: (draw_outline), (clip_to_outline):
+ * src/view.c: (draw_bg_layer), (draw_fg_layer):
+ * src/wdgt-mini-preview.c: (draw_labels):
+ * src/wdgt-rotate-label.c: (drawingarea_update):
+ Modified to universally use gl_cairo_label_path() to create paths
+ for labels. Added shadow to mini preview in rotate widget.
+
2007-04-10 Jim Evins <evins@snaught.com>
* libglabels/template.h:
/*===========================================*/
static void gl_cairo_rect_label_path (cairo_t *cr,
- glLabel *label,
+ glTemplate *template,
+ gboolean rotate_flag,
gboolean waste_flag);
static void gl_cairo_round_label_path (cairo_t *cr,
- glLabel *label,
+ glTemplate *template,
+ gboolean rotate_flag,
gboolean waste_flag);
static void gl_cairo_cd_label_path (cairo_t *cr,
- glLabel *label,
+ glTemplate *template,
+ gboolean rotate_flag,
gboolean waste_flag);
\f
/*--------------------------------------------------------------------------*/
void
gl_cairo_label_path (cairo_t *cr,
- glLabel *label,
+ glTemplate *template,
+ gboolean rotate_flag,
gboolean waste_flag)
{
const glTemplateLabelType *label_type;
gl_debug (DEBUG_PATH, "START");
- label_type = gl_template_get_first_label_type (label->template);
+ label_type = gl_template_get_first_label_type (template);
switch (label_type->shape) {
case GL_TEMPLATE_SHAPE_RECT:
- gl_cairo_rect_label_path (cr, label, waste_flag);
+ gl_cairo_rect_label_path (cr, template, rotate_flag, waste_flag);
break;
case GL_TEMPLATE_SHAPE_ROUND:
- gl_cairo_round_label_path (cr, label, waste_flag);
+ gl_cairo_round_label_path (cr, template, rotate_flag, waste_flag);
break;
case GL_TEMPLATE_SHAPE_CD:
- gl_cairo_cd_label_path (cr, label, waste_flag);
+ gl_cairo_cd_label_path (cr, template, rotate_flag, waste_flag);
break;
default:
/*--------------------------------------------------------------------------*/
static void
gl_cairo_rect_label_path (cairo_t *cr,
- glLabel *label,
+ glTemplate *template,
+ gboolean rotate_flag,
gboolean waste_flag)
{
const glTemplateLabelType *label_type;
gl_debug (DEBUG_PATH, "START");
- label_type = gl_template_get_first_label_type (label->template);
- gl_label_get_size (label, &w, &h);
+ label_type = gl_template_get_first_label_type (template);
r = label_type->size.rect.r;
- if (waste_flag)
+ x_waste = 0.0;
+ y_waste = 0.0;
+
+ if (rotate_flag)
{
- x_waste = label_type->size.rect.x_waste;
- y_waste = label_type->size.rect.x_waste;
+ gl_template_get_label_size (label_type, &h, &w);
+ if (waste_flag)
+ {
+ x_waste = label_type->size.rect.y_waste;
+ y_waste = label_type->size.rect.x_waste;
+ }
}
else
{
- x_waste = 0.0;
- y_waste = 0.0;
+ gl_template_get_label_size (label_type, &w, &h);
+ if (waste_flag)
+ {
+ x_waste = label_type->size.rect.x_waste;
+ y_waste = label_type->size.rect.y_waste;
+ }
}
+
if ( r == 0.0 )
{
cairo_rectangle (cr, -x_waste, -y_waste, w+x_waste, h+y_waste);
/*--------------------------------------------------------------------------*/
static void
gl_cairo_round_label_path (cairo_t *cr,
- glLabel *label,
+ glTemplate *template,
+ gboolean rotate_flag,
gboolean waste_flag)
{
const glTemplateLabelType *label_type;
gl_debug (DEBUG_PATH, "START");
- label_type = gl_template_get_first_label_type (label->template);
- gl_label_get_size (label, &w, &h);
+ label_type = gl_template_get_first_label_type (template);
+ if (rotate_flag)
+ {
+ gl_template_get_label_size (label_type, &h, &w);
+ }
+ else
+ {
+ gl_template_get_label_size (label_type, &w, &h);
+ }
+
if (waste_flag)
{
waste = label_type->size.round.waste;
/*--------------------------------------------------------------------------*/
static void
gl_cairo_cd_label_path (cairo_t *cr,
- glLabel *label,
+ glTemplate *template,
+ gboolean rotate_flag,
gboolean waste_flag)
{
const glTemplateLabelType *label_type;
gl_debug (DEBUG_PATH, "START");
- label_type = gl_template_get_first_label_type (label->template);
- gl_label_get_size (label, &w, &h);
+ label_type = gl_template_get_first_label_type (template);
+
+ if (rotate_flag)
+ {
+ gl_template_get_label_size (label_type, &h, &w);
+ }
+ else
+ {
+ gl_template_get_label_size (label_type, &w, &h);
+ }
xc = w/2.0;
yc = h/2.0;
#define __CAIRO_LABEL_PATH_H__
#include <cairo.h>
-#include "label.h"
+#include <libglabels/template.h>
G_BEGIN_DECLS
void gl_cairo_label_path (cairo_t *cr,
- glLabel *label,
+ glTemplate *template,
+ gboolean rotate_flag,
gboolean waste_flag);
G_END_DECLS
#include <config.h>
#include "mini-preview-pixbuf.h"
+#include "cairo-label-path.h"
#include <cairo.h>
#include <math.h>
/*===========================================*/
static void draw_paper (cairo_t *cr,
- const glTemplate *template,
+ glTemplate *template,
gdouble scale);
static void draw_label_outlines (cairo_t *cr,
- const glTemplate *template,
+ glTemplate *template,
gdouble scale);
static void draw_label_outline (cairo_t *cr,
- const glTemplate *template,
- gdouble x0,
- gdouble y0);
-
-static void draw_rect_label_outline (cairo_t *cr,
- const glTemplate *template,
- gdouble x0,
- gdouble y0);
-
-static void draw_round_label_outline (cairo_t *cr,
- const glTemplate *template,
- gdouble x0,
- gdouble y0);
-
-static void draw_cd_label_outline (cairo_t *cr,
- const glTemplate *template,
+ glTemplate *template,
gdouble x0,
gdouble y0);
/*--------------------------------------------------------------------------*/
static void
draw_paper (cairo_t *cr,
- const glTemplate *template,
+ glTemplate *template,
gdouble scale)
{
gl_debug (DEBUG_MINI_PREVIEW, "START");
/*--------------------------------------------------------------------------*/
static void
draw_label_outlines (cairo_t *cr,
- const glTemplate *template,
+ glTemplate *template,
gdouble scale)
{
const glTemplateLabelType *label_type;
/*--------------------------------------------------------------------------*/
static void
draw_label_outline (cairo_t *cr,
- const glTemplate *template,
+ glTemplate *template,
gdouble x0,
gdouble y0)
{
- const glTemplateLabelType *label_type;
-
- gl_debug (DEBUG_MINI_PREVIEW, "START");
-
- cairo_save (cr);
-
- label_type = gl_template_get_first_label_type (template);
-
- switch (label_type->shape) {
-
- case GL_TEMPLATE_SHAPE_RECT:
- draw_rect_label_outline (cr, template, x0, y0);
- break;
-
- case GL_TEMPLATE_SHAPE_ROUND:
- draw_round_label_outline (cr, template, x0, y0);
- break;
-
- case GL_TEMPLATE_SHAPE_CD:
- draw_cd_label_outline (cr, template, x0, y0);
- break;
-
- default:
- g_message ("Unknown label style");
- break;
- }
-
- cairo_restore (cr);
-
- gl_debug (DEBUG_MINI_PREVIEW, "END");
-}
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE. Draw rectangular label outline. */
-/*--------------------------------------------------------------------------*/
-static void
-draw_rect_label_outline (cairo_t *cr,
- const glTemplate *template,
- gdouble x0,
- gdouble y0)
-{
- const glTemplateLabelType *label_type;
- gdouble w, h;
-
gl_debug (DEBUG_MINI_PREVIEW, "START");
cairo_save (cr);
- label_type = gl_template_get_first_label_type (template);
- gl_template_get_label_size (label_type, &w, &h);
+ cairo_translate (cr, x0, y0);
- 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);
-
- gl_debug (DEBUG_MINI_PREVIEW, "END");
-}
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE. Draw round label outline. */
-/*--------------------------------------------------------------------------*/
-static void
-draw_round_label_outline (cairo_t *cr,
- const glTemplate *template,
- gdouble x0,
- gdouble y0)
-{
- const glTemplateLabelType *label_type;
- gdouble w, h;
-
- gl_debug (DEBUG_MINI_PREVIEW, "START");
-
- cairo_save (cr);
-
- 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);
-
- gl_debug (DEBUG_MINI_PREVIEW, "END");
-}
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE. Draw cd label outline. */
-/*--------------------------------------------------------------------------*/
-static void
-draw_cd_label_outline (cairo_t *cr,
- const glTemplate *template,
- gdouble x0,
- gdouble y0)
-{
- const glTemplateLabelType *label_type;
- gdouble w, h;
- gdouble xc, yc;
- gdouble r1, r2;
- gdouble theta1, theta2;
-
-
- gl_debug (DEBUG_MINI_PREVIEW, "START");
-
- cairo_save (cr);
-
- label_type = gl_template_get_first_label_type (template);
- gl_template_get_label_size (label_type, &w, &h);
-
- xc = x0 + w/2.0;
- yc = y0 + h/2.0;
-
- r1 = label_type->size.cd.r1;
- r2 = label_type->size.cd.r2;
-
- 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);
+ gl_cairo_label_path (cr, template, FALSE, FALSE);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_set_source_rgb (cr, 0.25, 0.25, 0.25);
cairo_stroke (cr);
-
+
cairo_restore (cr);
gl_debug (DEBUG_MINI_PREVIEW, "END");
}
-
-
cairo_set_source_rgba (pi->cr, 0.0, 0.0, 0.0, 1.0);
cairo_set_line_width (pi->cr, 0.25);
- gl_cairo_label_path (pi->cr, label, FALSE);
+ gl_cairo_label_path (pi->cr, label->template, FALSE, FALSE);
cairo_stroke (pi->cr);
{
gl_debug (DEBUG_PRINT, "START");
- gl_cairo_label_path (pi->cr, label, TRUE);
+ gl_cairo_label_path (pi->cr, label->template, FALSE, TRUE);
cairo_set_fill_rule (pi->cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_clip (pi->cr);
g_return_if_fail (view && GL_IS_VIEW (view));
g_return_if_fail (view->label && GL_IS_LABEL (view->label));
- gl_cairo_label_path (cr, view->label, FALSE);
+ gl_cairo_label_path (cr, view->label->template, view->label->rotate_flag, FALSE);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
g_return_if_fail (view && GL_IS_VIEW (view));
g_return_if_fail (view->label && GL_IS_LABEL (view->label));
- gl_cairo_label_path (cr, view->label, FALSE);
+ gl_cairo_label_path (cr, view->label->template, view->label->rotate_flag, FALSE);
cairo_set_line_width (cr, 3.0/(view->home_scale * view->zoom));
cairo_set_source_rgb (cr, 0.68, 0.85, 0.90);
#include <math.h>
+#include "cairo-label-path.h"
#include "marshal.h"
#include "color.h"
gdouble line_width);
static void draw_labels (glWdgtMiniPreview *preview,
cairo_t *cr,
- const glTemplate *template,
+ glTemplate *template,
gdouble line_width);
-static void create_label_path (cairo_t *cr,
- const glTemplate *template,
- gdouble x0,
- gdouble y0);
-static void create_rect_label_path (cairo_t *cr,
- const glTemplate *template,
- gdouble x0,
- gdouble y0);
-static void create_round_label_path (cairo_t *cr,
- const glTemplate *template,
- gdouble x0,
- gdouble y0);
-static void create_cd_label_path (cairo_t *cr,
- const glTemplate *template,
- gdouble x0,
- gdouble y0);
static gint find_closest_label (glWdgtMiniPreview *preview,
gdouble x,
static void
draw_labels (glWdgtMiniPreview *preview,
cairo_t *cr,
- const glTemplate *template,
+ glTemplate *template,
gdouble line_width)
{
const glTemplateLabelType *label_type;
cairo_save (cr);
- create_label_path (cr, template, origins[i].x, origins[i].y);
+ cairo_translate (cr, origins[i].x, origins[i].y);
+ gl_cairo_label_path (cr, template, FALSE, FALSE);
if ( ((i+1) >= preview->priv->highlight_first) &&
((i+1) <= preview->priv->highlight_last) )
gl_debug (DEBUG_MINI_PREVIEW, "END");
}
-/*--------------------------------------------------------------------------*/
-/* Create label path */
-/*--------------------------------------------------------------------------*/
-static void
-create_label_path (cairo_t *cr,
- const glTemplate *template,
- gdouble x0,
- gdouble y0)
-{
- const glTemplateLabelType *label_type;
-
- gl_debug (DEBUG_MINI_PREVIEW, "START");
-
- label_type = gl_template_get_first_label_type (template);
-
- switch (label_type->shape) {
-
- case GL_TEMPLATE_SHAPE_RECT:
- create_rect_label_path (cr, template, x0, y0);
- break;
-
- case GL_TEMPLATE_SHAPE_ROUND:
- create_round_label_path (cr, template, x0, y0);
- break;
-
- case GL_TEMPLATE_SHAPE_CD:
- create_cd_label_path (cr, template, x0, y0);
- break;
-
- default:
- g_message ("Unknown label style");
- break;
- }
-
- gl_debug (DEBUG_MINI_PREVIEW, "END");
-}
-
-/*--------------------------------------------------------------------------*/
-/* Create rectangular label path */
-/*--------------------------------------------------------------------------*/
-static void
-create_rect_label_path (cairo_t *cr,
- const glTemplate *template,
- gdouble x0,
- gdouble y0)
-{
- const glTemplateLabelType *label_type;
- gdouble w, h;
-
- gl_debug (DEBUG_MINI_PREVIEW, "START");
-
- 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);
-
- gl_debug (DEBUG_MINI_PREVIEW, "END");
-}
-
-/*--------------------------------------------------------------------------*/
-/* Create round label path */
-/*--------------------------------------------------------------------------*/
-static void
-create_round_label_path (cairo_t *cr,
- const glTemplate *template,
- gdouble x0,
- gdouble y0)
-{
- const glTemplateLabelType *label_type;
- gdouble w, h;
-
- gl_debug (DEBUG_MINI_PREVIEW, "START");
-
- 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_close_path (cr);
-
- gl_debug (DEBUG_MINI_PREVIEW, "END");
-}
-
-/*--------------------------------------------------------------------------*/
-/* Create cd label path */
-/*--------------------------------------------------------------------------*/
-static void
-create_cd_label_path (cairo_t *cr,
- const glTemplate *template,
- gdouble x0,
- gdouble y0)
-{
- const glTemplateLabelType *label_type;
- gdouble w, h;
- gdouble xc, yc;
- gdouble r1, r2;
- gdouble theta1, theta2;
-
- gl_debug (DEBUG_MINI_PREVIEW, "START");
-
- label_type = gl_template_get_first_label_type (template);
- gl_template_get_label_size (label_type, &w, &h);
-
- xc = x0 + w/2.0;
- yc = y0 + h/2.0;
-
- r1 = label_type->size.cd.r1;
- r2 = label_type->size.cd.r2;
-
- /*
- * Outer path (may be clipped)
- */
- 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);
-
-
- /* Inner path (hole) */
- cairo_new_sub_path (cr);
- cairo_arc (cr, xc, yc, r2, 0.0, 2*M_PI);
- cairo_close_path (cr);
-
- gl_debug (DEBUG_MINI_PREVIEW, "END");
-}
-
#include "marshal.h"
#include "color.h"
#include <libglabels/template.h>
+#include "cairo-label-path.h"
#include "debug.h"
#define LINE_COLOR GL_COLOR(0,0,0)
#define FILL_COLOR GL_COLOR(255,255,255)
+#define SHADOW_X_OFFSET 3
+#define SHADOW_Y_OFFSET 3
+
+
/*===========================================*/
/* Private types */
/*===========================================*/
glTemplate *template,
gboolean rotate_flag);
-static void draw_rect_label_outline (cairo_t *cr,
- const glTemplate *template,
- guint line_color,
- guint fill_color);
-
-static void draw_round_label_outline (cairo_t *cr,
- const glTemplate *template,
- guint line_color,
- guint fill_color);
-
-
-static void draw_cd_label_outline (cairo_t *cr,
- const glTemplate *template,
- guint line_color,
- guint fill_color);
-
static gboolean expose_cb (GtkWidget *drawingarea,
GdkEventExpose *event,
gpointer user_data);
const glTemplateLabelType *label_type;
gdouble m, m_canvas, w, h, scale;
GtkStyle *style;
- guint line_color, fill_color;
+ guint line_color, fill_color, shadow_color;
cairo_t *cr;
if (!GTK_WIDGET_DRAWABLE (GTK_WIDGET (drawing_area)))
label_type = gl_template_get_first_label_type (template);
- gl_template_get_label_size (label_type, &w, &h);
+ if (rotate_flag)
+ {
+ gl_template_get_label_size (label_type, &h, &w);
+ }
+ else
+ {
+ gl_template_get_label_size (label_type, &w, &h);
+ }
m = MAX (w, h);
scale = MINI_PREVIEW_MAX_PIXELS / m;
m_canvas = MINI_PREVIEW_CANVAS_PIXELS / scale;
+ style = gtk_widget_get_style (GTK_WIDGET (drawing_area));
+
/* Adjust sensitivity (should the canvas be grayed?) */
if (w != h) {
line_color = LINE_COLOR;
fill_color = FILL_COLOR;
} else {
- style = gtk_widget_get_style (GTK_WIDGET (drawing_area));
line_color = gl_color_from_gdk_color (&style->text[GTK_STATE_INSENSITIVE]);
fill_color = gl_color_from_gdk_color (&style->base[GTK_STATE_INSENSITIVE]);
}
+ shadow_color = gl_color_from_gdk_color (&style->bg[GTK_STATE_ACTIVE]);
+
+
cr = gdk_cairo_create (GTK_WIDGET (drawing_area)->window);
cairo_identity_matrix (cr);
cairo_translate (cr, MINI_PREVIEW_CANVAS_PIXELS/2, MINI_PREVIEW_CANVAS_PIXELS/2);
cairo_scale (cr, scale, scale);
- if (rotate_flag)
- {
- cairo_rotate (cr, M_PI/2.0);
- }
-
- cairo_set_line_width (cr, 1.0/scale);
-
- switch (label_type->shape) {
-
- case GL_TEMPLATE_SHAPE_RECT:
- draw_rect_label_outline (cr, template, line_color, fill_color);
- break;
-
- case GL_TEMPLATE_SHAPE_ROUND:
- draw_round_label_outline (cr, template, line_color, fill_color);
- break;
-
- case GL_TEMPLATE_SHAPE_CD:
- draw_cd_label_outline (cr, template, line_color, fill_color);
- break;
-
- default:
- g_message ("Unknown label style");
- break;
- }
-
- cairo_destroy (cr);
-
-}
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE. Draw rectangular label outline. */
-/*--------------------------------------------------------------------------*/
-static void
-draw_rect_label_outline (cairo_t *cr,
- const glTemplate *template,
- guint line_color,
- guint fill_color)
-{
- const glTemplateLabelType *label_type;
- gdouble w, h;
-
- gl_debug (DEBUG_MINI_PREVIEW, "START");
-
- cairo_save (cr);
-
- label_type = gl_template_get_first_label_type (template);
- gl_template_get_label_size (label_type, &w, &h);
-
- cairo_rectangle (cr, -w/2.0, -h/2.0, w, h);
-
- cairo_set_source_rgb (cr,
- GL_COLOR_F_RED(fill_color),
- GL_COLOR_F_GREEN(fill_color),
- GL_COLOR_F_BLUE(fill_color));
- cairo_fill_preserve (cr);
-
- cairo_set_source_rgb (cr,
- GL_COLOR_F_RED(line_color),
- GL_COLOR_F_GREEN(line_color),
- GL_COLOR_F_BLUE(line_color));
- cairo_stroke (cr);
-
- cairo_restore (cr);
-
- gl_debug (DEBUG_MINI_PREVIEW, "END");
-}
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE. Draw round label outline. */
-/*--------------------------------------------------------------------------*/
-static void
-draw_round_label_outline (cairo_t *cr,
- const glTemplate *template,
- guint line_color,
- guint fill_color)
-{
- const glTemplateLabelType *label_type;
- gdouble w, h;
+ cairo_translate (cr, -w/2.0, -h/2.0);
- gl_debug (DEBUG_MINI_PREVIEW, "START");
-
- cairo_save (cr);
-
- label_type = gl_template_get_first_label_type (template);
- gl_template_get_label_size (label_type, &w, &h);
-
- cairo_arc (cr, 0.0, 0.0, w/2, 0.0, 2*M_PI);
+ /*
+ * Shadow
+ */
+ cairo_save (cr);
+ cairo_translate (cr, SHADOW_X_OFFSET/scale, SHADOW_Y_OFFSET/scale);
+ gl_cairo_label_path (cr, template, rotate_flag, FALSE);
cairo_set_source_rgb (cr,
- GL_COLOR_F_RED(fill_color),
- GL_COLOR_F_GREEN(fill_color),
- GL_COLOR_F_BLUE(fill_color));
- cairo_fill_preserve (cr);
-
- cairo_set_source_rgb (cr,
- GL_COLOR_F_RED(line_color),
- GL_COLOR_F_GREEN(line_color),
- GL_COLOR_F_BLUE(line_color));
- cairo_stroke (cr);
-
- cairo_restore (cr);
-
- gl_debug (DEBUG_MINI_PREVIEW, "END");
-}
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE. Draw cd label outline. */
-/*--------------------------------------------------------------------------*/
-static void
-draw_cd_label_outline (cairo_t *cr,
- const glTemplate *template,
- guint line_color,
- guint fill_color)
-{
- const glTemplateLabelType *label_type;
- gdouble w, h;
- gdouble r1, r2;
- gdouble theta1, theta2;
-
- gl_debug (DEBUG_MINI_PREVIEW, "START");
+ GL_COLOR_F_RED(shadow_color),
+ GL_COLOR_F_GREEN(shadow_color),
+ GL_COLOR_F_BLUE(shadow_color));
+ cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+ cairo_fill (cr);
+ cairo_restore (cr);
- cairo_save (cr);
+ /*
+ * Label + outline
+ */
+ gl_cairo_label_path (cr, template, rotate_flag, FALSE);
- label_type = gl_template_get_first_label_type (template);
- gl_template_get_label_size (label_type, &w, &h);
-
- r1 = label_type->size.cd.r1;
- r2 = label_type->size.cd.r2;
-
- /* 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),
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_fill_preserve (cr);
+ cairo_set_line_width (cr, 1.0/scale);
cairo_set_source_rgb (cr,
GL_COLOR_F_RED(line_color),
GL_COLOR_F_GREEN(line_color),
GL_COLOR_F_BLUE(line_color));
cairo_stroke (cr);
- cairo_restore (cr);
- gl_debug (DEBUG_MINI_PREVIEW, "END");
+ cairo_destroy (cr);
+
}
/*--------------------------------------------------------------------------*/
-/* PRIVATE. Draw cd label outline. */
+/* PRIVATE. Expose handler. */
/*--------------------------------------------------------------------------*/
static gboolean
expose_cb (GtkWidget *drawingarea, GdkEventExpose *event, gpointer user_data)