From b6893fe7ca71c477320ba676d3805e8561d393ad Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Fri, 27 Apr 2007 02:17:18 +0000 Subject: [PATCH] 2007-04-26 Jim Evins * src/mini-preview-pixbuf.c: (draw_paper), (draw_label_outlines), (draw_label_outline): * src/print.c: (print_crop_marks), (draw_outline): * src/view-object.c: (gl_view_object_draw_handles): * src/view.c: (draw_bg_layer), (draw_grid_layer), (draw_markup_layer), (draw_fg_layer), (draw_select_region_layer): * src/wdgt-mini-preview.c: (draw_paper), (draw_labels): * src/wdgt-rotate-label.c: (drawingarea_update): Added defines for various magic numbers. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@654 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/ChangeLog | 12 +++++++++ glabels2/src/mini-preview-pixbuf.c | 24 +++++++++++++----- glabels2/src/print.c | 12 ++++++--- glabels2/src/view-object.c | 10 +++++--- glabels2/src/view.c | 40 +++++++++++++++--------------- glabels2/src/wdgt-mini-preview.c | 16 +++++++++--- glabels2/src/wdgt-rotate-label.c | 4 ++- 7 files changed, 80 insertions(+), 38 deletions(-) diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index 1afaa2cf..0d94463a 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,15 @@ +2007-04-26 Jim Evins + + * src/mini-preview-pixbuf.c: (draw_paper), (draw_label_outlines), + (draw_label_outline): + * src/print.c: (print_crop_marks), (draw_outline): + * src/view-object.c: (gl_view_object_draw_handles): + * src/view.c: (draw_bg_layer), (draw_grid_layer), + (draw_markup_layer), (draw_fg_layer), (draw_select_region_layer): + * src/wdgt-mini-preview.c: (draw_paper), (draw_labels): + * src/wdgt-rotate-label.c: (drawingarea_update): + Added defines for various magic numbers. + 2007-04-25 Jim Evins * src/label-text.c: (get_size), (draw_object), (draw_shadow): diff --git a/glabels2/src/mini-preview-pixbuf.c b/glabels2/src/mini-preview-pixbuf.c index 1fd467d1..b83afbc0 100644 --- a/glabels2/src/mini-preview-pixbuf.c +++ b/glabels2/src/mini-preview-pixbuf.c @@ -32,6 +32,18 @@ #include "debug.h" +/*===========================================*/ +/* Private macros and constants. */ +/*===========================================*/ + +#define PAPER_RGB_ARGS 0.95, 0.95, 0.95 +#define PAPER_OUTLINE_RGB_ARGS 0.0, 0.0, 0.0 +#define LABEL_RGB_ARGS 1.0, 1.0, 1.0 +#define LABEL_OUTLINE_RGB_ARGS 0.25, 0.25, 0.25 + +#define PAPER_OUTLINE_WIDTH_PIXELS 1.0 +#define LABEL_OUTLINE_WIDTH_PIXELS 1.0 + /*===========================================*/ /* Private types */ /*===========================================*/ @@ -136,10 +148,10 @@ draw_paper (cairo_t *cr, cairo_save (cr); cairo_rectangle (cr, 0.0, 0.0, template->page_width, template->page_height); - cairo_set_source_rgb (cr, 0.95, 0.95, 0.95); + cairo_set_source_rgb (cr, PAPER_RGB_ARGS); cairo_fill_preserve (cr); - cairo_set_line_width (cr, 1/scale); - cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); + cairo_set_line_width (cr, PAPER_OUTLINE_WIDTH_PIXELS/scale); + cairo_set_source_rgb (cr, PAPER_OUTLINE_RGB_ARGS); cairo_stroke (cr); cairo_restore (cr); @@ -162,7 +174,7 @@ draw_label_outlines (cairo_t *cr, cairo_save (cr); - cairo_set_line_width (cr, 1.0/scale); + cairo_set_line_width (cr, LABEL_OUTLINE_WIDTH_PIXELS/scale); label_type = gl_template_get_first_label_type (template); @@ -199,11 +211,11 @@ draw_label_outline (cairo_t *cr, gl_cairo_label_path (cr, template, FALSE, FALSE); - cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); + cairo_set_source_rgb (cr, LABEL_RGB_ARGS); 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_set_source_rgb (cr, LABEL_OUTLINE_RGB_ARGS); cairo_stroke (cr); cairo_restore (cr); diff --git a/glabels2/src/print.c b/glabels2/src/print.c index 15f07135..b4310017 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -40,6 +40,10 @@ /* Private macros and constants. */ /*===========================================*/ +#define OUTLINE_RGB_ARGS 0.0, 0.0, 0.0 + +#define OUTLINE_WIDTH 0.25 + #define TICK_OFFSET 2.25 #define TICK_LENGTH 18.0 @@ -391,8 +395,8 @@ print_crop_marks (PrintInfo *pi) cairo_save (pi->cr); - cairo_set_source_rgba (pi->cr, 0.0, 0.0, 0.0, 1.0); - cairo_set_line_width (pi->cr, 0.25); + cairo_set_source_rgb (pi->cr, OUTLINE_RGB_ARGS); + cairo_set_line_width (pi->cr, OUTLINE_WIDTH); for (p=label_type->layouts; p != NULL; p=p->next) { @@ -532,8 +536,8 @@ draw_outline (PrintInfo *pi, cairo_save (pi->cr); - cairo_set_source_rgba (pi->cr, 0.0, 0.0, 0.0, 1.0); - cairo_set_line_width (pi->cr, 0.25); + cairo_set_source_rgb (pi->cr, OUTLINE_RGB_ARGS); + cairo_set_line_width (pi->cr, OUTLINE_WIDTH); gl_cairo_label_path (pi->cr, label->template, FALSE, FALSE); diff --git a/glabels2/src/view-object.c b/glabels2/src/view-object.c index 5a7f9aa9..cfbe92b1 100644 --- a/glabels2/src/view-object.c +++ b/glabels2/src/view-object.c @@ -33,6 +33,10 @@ /* Private constants and macros. */ /*========================================================*/ +#define HANDLE_FILL_RGBA_ARGS 0.0, 0.75, 0.0, 0.4 +#define HANDLE_OUTLINE_RGBA_ARGS 0.0, 0.0, 0.0, 0.8 + +#define HANDLE_OUTLINE_WIDTH_PIXELS 1.0 #define HANDLE_PIXELS 7 /*========================================================*/ @@ -396,11 +400,11 @@ gl_view_object_draw_handles (glViewObject *view_object, break; } - cairo_set_source_rgba (cr, 0, 0.75, 0, 0.4); + cairo_set_source_rgba (cr, HANDLE_FILL_RGBA_ARGS); cairo_fill_preserve (cr); - cairo_set_line_width (cr, 1/scale); - cairo_set_source_rgba (cr, 0, 0, 0, 0.8); + cairo_set_line_width (cr, HANDLE_OUTLINE_WIDTH_PIXELS/scale); + cairo_set_source_rgba (cr, HANDLE_OUTLINE_RGBA_ARGS); cairo_stroke (cr); cairo_restore (cr); diff --git a/glabels2/src/view.c b/glabels2/src/view.c index 79e768f5..18312ca2 100644 --- a/glabels2/src/view.c +++ b/glabels2/src/view.c @@ -57,23 +57,23 @@ /*==========================================================================*/ #define BG_COLOR GL_COLOR (192, 192, 192) -#define OUTLINE_COLOR GL_COLOR (173, 216, 230) -#define PAPER_COLOR GL_COLOR (255, 255, 255) -#define GRID_COLOR BG_COLOR -#define MARKUP_COLOR GL_COLOR (240, 100, 100) -#define SEL_LINE_COLOR GL_COLOR_A (0, 0, 255, 128) -#define SEL_FILL_COLOR GL_COLOR_A (192, 192, 255, 128) +#define PAPER_RGB_ARGS 1.0, 1.0, 1.0 +#define GRID_RGB_ARGS 0.753, 0.753, 0.753 +#define MARKUP_RGB_ARGS 0.94, 0.39, 0.39 +#define OUTLINE_RGB_ARGS 0.68, 0.85, 0.90 +#define SELECT_LINE_RGBA_ARGS 0.0, 0.0, 1.0, 0.5 +#define SELECT_FILL_RGBA_ARGS 0.75, 0.75, 1.0, 0.5 -#define ARC_FINE 2 /* Resolution in degrees of large arcs */ -#define ARC_COURSE 5 /* Resolution in degrees of small arcs */ +#define GRID_LINE_WIDTH_PIXELS 1.0 +#define MARKUP_LINE_WIDTH_PIXELS 1.0 +#define OUTLINE_WIDTH_PIXELS 3.0 +#define SELECT_LINE_WIDTH_PIXELS 3.0 #define ZOOMTOFIT_PAD 16 #define POINTS_PER_MM 2.83464566929 -#define DELTA 0.01 - /*==========================================================================*/ /* Private types. */ /*==========================================================================*/ @@ -754,7 +754,7 @@ draw_bg_layer (glView *view, 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_source_rgb (cr, PAPER_RGB_ARGS); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_fill (cr); } @@ -796,8 +796,8 @@ draw_grid_layer (glView *view, cairo_save (cr); cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); - cairo_set_line_width (cr, 1.0/(view->home_scale * view->zoom)); - cairo_set_source_rgb (cr, 0.753, 0.753, 0.753); + cairo_set_line_width (cr, GRID_LINE_WIDTH_PIXELS/(view->home_scale * view->zoom)); + cairo_set_source_rgb (cr, GRID_RGB_ARGS); for ( x=x0+view->grid_spacing; x < w; x += view->grid_spacing ) { @@ -843,8 +843,8 @@ draw_markup_layer (glView *view, cairo_save (cr); - cairo_set_line_width (cr, 1.0/(view->home_scale * view->zoom)); - cairo_set_source_rgb (cr, 0.94, 0.39, 0.39); + cairo_set_line_width (cr, MARKUP_LINE_WIDTH_PIXELS/(view->home_scale * view->zoom)); + cairo_set_source_rgb (cr, MARKUP_RGB_ARGS); for ( p=label_type->markups; p != NULL; p=p->next ) { @@ -882,8 +882,8 @@ draw_fg_layer (glView *view, 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); + cairo_set_line_width (cr, OUTLINE_WIDTH_PIXELS/(view->home_scale * view->zoom)); + cairo_set_source_rgb (cr, OUTLINE_RGB_ARGS); cairo_stroke (cr); } @@ -934,11 +934,11 @@ draw_select_region_layer (glView *view, cairo_rectangle (cr, x1, y1, w, h); - cairo_set_source_rgba (cr, 0.75, 0.75, 1.0, 0.5); + cairo_set_source_rgba (cr, SELECT_FILL_RGBA_ARGS); cairo_fill_preserve (cr); - cairo_set_line_width (cr, 3.0/(view->home_scale * view->zoom)); - cairo_set_source_rgba (cr, 0, 0, 1.0, 0.5); + cairo_set_line_width (cr, SELECT_LINE_WIDTH_PIXELS/(view->home_scale * view->zoom)); + cairo_set_source_rgba (cr, SELECT_LINE_RGBA_ARGS); cairo_stroke (cr); } } diff --git a/glabels2/src/wdgt-mini-preview.c b/glabels2/src/wdgt-mini-preview.c index 49e4a472..abd1c501 100644 --- a/glabels2/src/wdgt-mini-preview.c +++ b/glabels2/src/wdgt-mini-preview.c @@ -34,6 +34,14 @@ #include "debug.h" +/*===========================================*/ +/* Private macros and constants. */ +/*===========================================*/ + +#define PAPER_RGB_ARGS 1.0, 1.0, 1.0 +#define PAPER_OUTLINE_RGB_ARGS 0.0, 0.0, 0.0 +#define LABEL_OUTLINE_RGB_ARGS 0.5, 0.5, 0.5 + #define SHADOW_X_OFFSET 5 #define SHADOW_Y_OFFSET 5 @@ -647,10 +655,10 @@ draw_paper (glWdgtMiniPreview *preview, cairo_rectangle (cr, 0.0, 0.0, width, height); - cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); + cairo_set_source_rgb (cr, PAPER_RGB_ARGS); cairo_fill_preserve (cr); - cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); + cairo_set_source_rgb (cr, PAPER_OUTLINE_RGB_ARGS); cairo_set_line_width (cr, line_width); cairo_stroke (cr); @@ -701,13 +709,13 @@ draw_labels (glWdgtMiniPreview *preview, } else { - cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); + cairo_set_source_rgb (cr, PAPER_RGB_ARGS); } cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_fill_preserve (cr); cairo_set_line_width (cr, line_width); - cairo_set_source_rgb (cr, 0.5, 0.5, 0.5); + cairo_set_source_rgb (cr, LABEL_OUTLINE_RGB_ARGS); cairo_stroke (cr); cairo_restore (cr); diff --git a/glabels2/src/wdgt-rotate-label.c b/glabels2/src/wdgt-rotate-label.c index dbeb8150..a4226006 100644 --- a/glabels2/src/wdgt-rotate-label.c +++ b/glabels2/src/wdgt-rotate-label.c @@ -49,6 +49,8 @@ #define LINE_COLOR GL_COLOR(0,0,0) #define FILL_COLOR GL_COLOR(255,255,255) +#define LINE_WIDTH_PIXELS 1.0 + #define SHADOW_X_OFFSET 3 #define SHADOW_Y_OFFSET 3 @@ -310,7 +312,7 @@ drawingarea_update (GtkDrawingArea *drawing_area, cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_fill_preserve (cr); - cairo_set_line_width (cr, 1.0/scale); + cairo_set_line_width (cr, LINE_WIDTH_PIXELS/scale); cairo_set_source_rgb (cr, GL_COLOR_F_RED(line_color), GL_COLOR_F_GREEN(line_color), -- 2.39.5