dia r4047 - in trunk: . lib plug-ins/cairo
- From: hans svn gnome org
- To: svn-commits-list gnome org
- Subject: dia r4047 - in trunk: . lib plug-ins/cairo
- Date: Sun, 25 May 2008 12:59:25 +0000 (UTC)
Author: hans
Date: Sun May 25 12:59:25 2008
New Revision: 4047
URL: http://svn.gnome.org/viewvc/dia?rev=4047&view=rev
Log:
2008-05-18 Hans Breuer <hans breuer org>
* lib/beziershape.c(beziershape_remove_segment): did not store
all information for undo. s/PointChange/BezPointChange/ to help
my debugger.
* lib/object_defaults.c(dia_object_default_create) : the standard
(toolbox visible) properties were overwritten although not set
* plug-ins/cairo/diacairo-interactive.c : draw_pixel_line and
draw_pixel_rect implmented with cairo rather than GDK makes the
line style of the grid visible again
Modified:
trunk/ChangeLog
trunk/lib/object_defaults.c
trunk/plug-ins/cairo/diacairo-interactive.c
Modified: trunk/lib/object_defaults.c
==============================================================================
--- trunk/lib/object_defaults.c (original)
+++ trunk/lib/object_defaults.c Sun May 25 12:59:25 2008
@@ -237,6 +237,14 @@
return obj;
}
+static gboolean
+pdtpp_standard_or_defaults (const PropDescription *pdesc)
+{
+ return ( (pdesc->flags & PROP_FLAG_NO_DEFAULTS) == 0
+ && (pdesc->flags & PROP_FLAG_STANDARD) == 0);
+}
+
+
/**
* dia_object_default_create:
* @param type The objects type
@@ -269,7 +277,7 @@
if (obj)
{
GPtrArray *props = prop_list_from_descs (
- object_get_prop_descriptions(def_obj), pdtpp_defaults);
+ object_get_prop_descriptions(def_obj), pdtpp_standard_or_defaults);
def_obj->ops->get_props(def_obj, props);
obj->ops->set_props(obj, props);
obj->ops->move (obj, startpoint);
Modified: trunk/plug-ins/cairo/diacairo-interactive.c
==============================================================================
--- trunk/plug-ins/cairo/diacairo-interactive.c (original)
+++ trunk/plug-ins/cairo/diacairo-interactive.c Sun May 25 12:59:25 2008
@@ -54,16 +54,6 @@
GdkGC *gc;
GdkRegion *clip_region;
- /* line attributes: */
- int line_width;
- GdkLineStyle line_style;
- GdkCapStyle cap_style;
- GdkJoinStyle join_style;
-
- LineStyle saved_line_style;
- int gdk_dash_length;
- int dot_length;
-
/** If non-NULL, this rendering is a highlighting with the given color. */
Color *highlight_color;
};
@@ -142,15 +132,6 @@
renderer->pixmap = NULL;
- renderer->line_width = 1;
- renderer->line_style = GDK_LINE_SOLID;
- renderer->cap_style = GDK_CAP_BUTT;
- renderer->join_style = GDK_JOIN_ROUND;
-
- renderer->saved_line_style = LINESTYLE_SOLID;
- renderer->gdk_dash_length = 10;
- renderer->dot_length = 2;
-
renderer->highlight_color = NULL;
}
@@ -353,12 +334,6 @@
if (renderer->gc == NULL) {
renderer->gc = gdk_gc_new(renderer->pixmap);
-
- gdk_gc_set_line_attributes(renderer->gc,
- renderer->line_width,
- renderer->line_style,
- renderer->cap_style,
- renderer->join_style);
}
}
@@ -419,79 +394,27 @@
gdk_gc_set_clip_region(renderer->gc, renderer->clip_region);
}
-/** Set the dashes for this renderer.
- * offset determines where in the pattern the dashes will start.
- * It is used by the grid in particular to make the grid dashes line up.
- */
-/*
-static void
-set_dashes(GdkGC *gc, int offset)
-{
- gint8 dash_list[6];
- int hole_width;
- int pattern_length;
-
- switch(renderer->saved_line_style) {
- case LINESTYLE_SOLID:
- break;
- case LINESTYLE_DASHED:
- dash_list[0] = renderer->gdk_dash_length;
- dash_list[1] = renderer->gdk_dash_length;
- pattern_length = renderer->gdk_dash_length*2;
- gdk_gc_set_dashes(renderer->gc, offset, dash_list, 2);
- break;
- case LINESTYLE_DASH_DOT:
- hole_width = (renderer->gdk_dash_length - renderer->dot_length) / 2;
- if (hole_width==0)
- hole_width = 1;
- dash_list[0] = renderer->gdk_dash_length;
- dash_list[1] = hole_width;
- dash_list[2] = renderer->dot_length;
- dash_list[3] = hole_width;
- pattern_length = renderer->gdk_dash_length+renderer->dot_length+2*hole_width;
- gdk_gc_set_dashes(renderer->gc, offset, dash_list, 4);
- break;
- case LINESTYLE_DASH_DOT_DOT:
- hole_width = (renderer->gdk_dash_length - 2*renderer->dot_length) / 3;
- if (hole_width==0)
- hole_width = 1;
- dash_list[0] = renderer->gdk_dash_length;
- dash_list[1] = hole_width;
- dash_list[2] = renderer->dot_length;
- dash_list[3] = hole_width;
- dash_list[4] = renderer->dot_length;
- dash_list[5] = hole_width;
- pattern_length = renderer->gdk_dash_length+2*renderer->dot_length+3*hole_width;
- gdk_gc_set_dashes(renderer->gc, offset, dash_list, 6);
- break;
- case LINESTYLE_DOTTED:
- dash_list[0] = renderer->dot_length;
- dash_list[1] = renderer->dot_length;
- pattern_length = renderer->dot_length;
- gdk_gc_set_dashes(renderer->gc, offset, dash_list, 2);
- break;
- }
-
-}
-*/
-
static void
draw_pixel_line(DiaRenderer *object,
int x1, int y1,
int x2, int y2,
Color *color)
{
- DiaCairoInteractiveRenderer *renderer = DIA_CAIRO_INTERACTIVE_RENDERER (object);
- GdkGC *gc = renderer->gc;
- GdkColor gdkcolor;
-
- /*
- set_dashes(gc, x1+y1);
- */
- color_convert(color, &gdkcolor);
- gdk_gc_set_foreground(gc, &gdkcolor);
+ DiaCairoRenderer *renderer = DIA_CAIRO_RENDERER (object);
+ double x1u = x1 + .5, y1u = y1 + .5, x2u = x2 + .5, y2u = y2 + .5;
+ double lw[2];
+ lw[0] = 1; lw[1] = 0;
- gdk_draw_line(renderer->pixmap, gc, x1, y1, x2, y2);
+ cairo_device_to_user_distance (renderer->cr, &lw[0], &lw[1]);
+ cairo_set_line_width (renderer->cr, lw[0]);
+
+ cairo_device_to_user (renderer->cr, &x1u, &y1u);
+ cairo_device_to_user (renderer->cr, &x2u, &y2u);
+
+ cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+ cairo_move_to (renderer->cr, x1u, y1u);
+ cairo_line_to (renderer->cr, x2u, y2u);
+ cairo_stroke (renderer->cr);
}
static void
@@ -500,19 +423,20 @@
int width, int height,
Color *color)
{
- DiaCairoInteractiveRenderer *renderer = DIA_CAIRO_INTERACTIVE_RENDERER (object);
- GdkGC *gc = renderer->gc;
- GdkColor gdkcolor;
-
- /*
- dia_cairo_renderer_set_dashes(renderer, x+y);
- */
+ DiaCairoRenderer *renderer = DIA_CAIRO_RENDERER (object);
+ double x1u = x + .5, y1u = y + .5, x2u = x + width + .5, y2u = y + height + .5;
+ double lw[2];
+ lw[0] = 1; lw[1] = 0;
+
+ cairo_device_to_user_distance (renderer->cr, &lw[0], &lw[1]);
+ cairo_set_line_width (renderer->cr, lw[0]);
- color_convert(color, &gdkcolor);
- gdk_gc_set_foreground(gc, &gdkcolor);
+ cairo_device_to_user (renderer->cr, &x1u, &y1u);
+ cairo_device_to_user (renderer->cr, &x2u, &y2u);
- gdk_draw_rectangle (renderer->pixmap, gc, FALSE,
- x, y, width, height);
+ cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+ cairo_rectangle (renderer->cr, x1u, y1u, x2u - x1u, y2u - y1u);
+ cairo_stroke (renderer->cr);
}
static void
@@ -521,6 +445,7 @@
int width, int height,
Color *color)
{
+#if 1 /* if we do it with cairo there is something wrong with the clipping? */
DiaCairoInteractiveRenderer *renderer = DIA_CAIRO_INTERACTIVE_RENDERER (object);
GdkGC *gc = renderer->gc;
GdkColor gdkcolor;
@@ -530,4 +455,20 @@
gdk_draw_rectangle (renderer->pixmap, gc, TRUE,
x, y, width, height);
+#else
+ DiaCairoRenderer *renderer = DIA_CAIRO_RENDERER (object);
+ double x1u = x + .5, y1u = y + .5, x2u = x + width + .5, y2u = y + height + .5;
+ double lw[2];
+ lw[0] = 1; lw[1] = 0;
+
+ cairo_device_to_user_distance (renderer->cr, &lw[0], &lw[1]);
+ cairo_set_line_width (renderer->cr, lw[0]);
+
+ cairo_device_to_user (renderer->cr, &x1u, &y1u);
+ cairo_device_to_user (renderer->cr, &x2u, &y2u);
+
+ cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+ cairo_rectangle (renderer->cr, x1u, y1u, x2u - x1u, y2u - y1u);
+ cairo_fill (renderer->cr);
+#endif
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]