diff options
author | Carlos Eduardo Rodrigues Diógenes <cerdiogenes@gmail.com> | 2007-12-27 17:47:33 +0000 |
---|---|---|
committer | Carlos Eduardo Rodrigues Diógenes <carlosd@src.gnome.org> | 2007-12-27 17:47:33 +0000 |
commit | feab90788f93477fcc7bd6b9d830d88d754a0b37 (patch) | |
tree | ed5f5a98df4ac643ae970be7591da3d59c6f5042 | |
parent | f80b26d8171ec88c4547b7c235e1fbd2579ddb37 (diff) |
The argument 'f' can be used to set the crosswire size, length and clip.
2007-12-27 Carlos Eduardo Rodrigues Diógenes <cerdiogenes@gmail.com>
* test/control-client.c: The argument 'f' can be used to set the
crosswire size, length and clip.
* magnifier/magnifier.c: Made the necesseary modification to make the
new properties work. Also done some TODOs, where Zoomers must be
notified about cursor/crosswire changes.
* magnifier/zoom-region.c:
(zoom_region_paint_crosswire_cursor): Change the algorithm to consider
the crosswire size.
* magnifier/magnifier.h: Added the crosswire_length variable.
svn path=/trunk/; revision=654
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | magnifier/magnifier.c | 32 | ||||
-rw-r--r-- | magnifier/magnifier.h | 1 | ||||
-rw-r--r-- | magnifier/zoom-region.c | 115 | ||||
-rw-r--r-- | test/control-client.c | 7 |
5 files changed, 113 insertions, 54 deletions
@@ -1,5 +1,17 @@ 2007-12-27 Carlos Eduardo Rodrigues Diógenes <cerdiogenes@gmail.com> + * test/control-client.c: The argument 'f' can be used to set the + crosswire size, length and clip. + * magnifier/magnifier.c: Made the necesseary modification to make the + new properties work. Also done some TODOs, where Zoomers must be + notified about cursor/crosswire changes. + * magnifier/zoom-region.c: + (zoom_region_paint_crosswire_cursor): Change the algorithm to consider + the crosswire size. + * magnifier/magnifier.h: Added the crosswire_length variable. + +2007-12-27 Carlos Eduardo Rodrigues Diógenes <cerdiogenes@gmail.com> + * test/control-client.c: The argument 'k' was modified so the user can use the control-client test application to set each border size (left, top, right and bottom). The 'l' argument was also modified, using the diff --git a/magnifier/magnifier.c b/magnifier/magnifier.c index 6bd328d..57eaa79 100644 --- a/magnifier/magnifier.c +++ b/magnifier/magnifier.c @@ -76,6 +76,7 @@ enum { MAGNIFIER_CURSOR_HOTSPOT_PROP, MAGNIFIER_CURSOR_DEFAULT_SIZE_PROP, MAGNIFIER_CROSSWIRE_SIZE_PROP, + MAGNIFIER_CROSSWIRE_LENGTH_PROP, MAGNIFIER_CROSSWIRE_CLIP_PROP, MAGNIFIER_CROSSWIRE_COLOR_PROP } PropIdx; @@ -111,6 +112,7 @@ gchar* mag_prop_names[MAGNIFIER_CROSSWIRE_COLOR_PROP + 1] = { "CURSOR_HOTSPOT", "CURSOR_DEFAULT_SIZE", "CROSSWIRE_SIZE", + "CROSSWIRE_LENGTH", "CROSSWIRE_CLIP", "CROSSWIRE_COLOR" }; @@ -937,6 +939,9 @@ magnifier_get_property (BonoboPropertyBag *bag, case MAGNIFIER_CROSSWIRE_SIZE_PROP: BONOBO_ARG_SET_INT (arg, magnifier->crosswire_size); break; + case MAGNIFIER_CROSSWIRE_LENGTH_PROP: + BONOBO_ARG_SET_INT (arg, magnifier->crosswire_length); + break; case MAGNIFIER_CROSSWIRE_CLIP_PROP: BONOBO_ARG_SET_BOOLEAN (arg, magnifier->crosswire_clip); break; @@ -964,6 +969,12 @@ magnifier_set_property (BonoboPropertyBag *bag, Magnifier *magnifier = user_data; gchar *full_display_string; + GNOME_Magnifier_RectBounds rect_bounds; + rect_bounds.x1 = 0; + rect_bounds.y1 = 0; + rect_bounds.x2 = 4096; + rect_bounds.y2 = 4096; + switch (arg_id) { case MAGNIFIER_SOURCE_DISPLAY_PROP: full_display_string = BONOBO_ARG_GET_STRING (arg); @@ -1156,11 +1167,20 @@ magnifier_set_property (BonoboPropertyBag *bag, case MAGNIFIER_CROSSWIRE_SIZE_PROP: magnifier->crosswire_size = BONOBO_ARG_GET_INT (arg); DBG (fprintf (stderr, "Setting crosswire size: \t%d\n", magnifier->crosswire_size)); - /* TODO: notify zoomers */ + magnifier_zoom_regions_update_pointer (magnifier); + break; + case MAGNIFIER_CROSSWIRE_LENGTH_PROP: + magnifier->crosswire_length = BONOBO_ARG_GET_INT (arg); + DBG (fprintf (stderr, "Setting crosswire length: \t%d\n", magnifier->crosswire_length)); + /* FIXME: The call below forces the repaint of all the screen, + * but I can't figure a better solution right now to the case + * where the crosswire lenght decrease */ + magnifier_zoom_regions_mark_dirty (magnifier, rect_bounds); break; case MAGNIFIER_CROSSWIRE_CLIP_PROP: magnifier->crosswire_clip = BONOBO_ARG_GET_BOOLEAN (arg); DBG (fprintf (stderr, "Setting crosswire clip: \t%s\n", magnifier->crosswire_clip ? "true" : "false")); + magnifier_zoom_regions_update_pointer (magnifier); break; case MAGNIFIER_CROSSWIRE_COLOR_PROP: magnifier->crosswire_color = BONOBO_ARG_GET_LONG (arg); @@ -1607,6 +1627,15 @@ magnifier_properties_init (Magnifier *magnifier) "thickness of crosswire cursor, in target pixels", Bonobo_PROPERTY_READABLE | Bonobo_PROPERTY_WRITEABLE); + + bonobo_property_bag_add (magnifier->property_bag, + "crosswire-length", + MAGNIFIER_CROSSWIRE_LENGTH_PROP, + BONOBO_ARG_INT, + NULL, + "length of crosswire cursor, in target pixels", + Bonobo_PROPERTY_READABLE | + Bonobo_PROPERTY_WRITEABLE); bonobo_property_bag_add (magnifier->property_bag, "crosswire-color", @@ -1669,6 +1698,7 @@ magnifier_init (Magnifier *magnifier) magnifier->cursor_scale_factor = 1.0F; magnifier->cursor_color = 0xFF000000; magnifier->crosswire_size = 1; + magnifier->crosswire_length = 0; magnifier->crosswire_color = 0; magnifier->crosswire_clip = FALSE; magnifier->cursor_hotspot.x = 0; diff --git a/magnifier/magnifier.h b/magnifier/magnifier.h index 7dd129e..fcd8527 100644 --- a/magnifier/magnifier.h +++ b/magnifier/magnifier.h @@ -60,6 +60,7 @@ typedef struct { GList *zoom_regions; gboolean source_initialized; gint crosswire_size; + gint crosswire_length; guint32 crosswire_color; gboolean crosswire_clip; gchar *cursor_set; diff --git a/magnifier/zoom-region.c b/magnifier/zoom-region.c index f14288e..a113ce0 100644 --- a/magnifier/zoom-region.c +++ b/magnifier/zoom-region.c @@ -820,6 +820,7 @@ zoom_region_paint_crosswire_cursor (ZoomRegion *zoom_region, GdkRectangle *clip_ GdkRectangle rect; GdkDrawable *cursor; GdkColor color = {0, 0, 0, 0}; + int x_start = 0, y_start = 0, x_end = 4096, y_end = 4096; int x_left_clip = 0, x_right_clip = 0, y_top_clip = 0, y_bottom_clip = 0; int csize = 0; @@ -886,6 +887,27 @@ zoom_region_paint_crosswire_cursor (ZoomRegion *zoom_region, GdkRectangle *clip_ if ((cursor = magnifier_get_cursor (magnifier))) { gdk_drawable_get_size (cursor, &csize, &csize); } + + if (magnifier->crosswire_length) { + if (magnifier->crosswire_clip) { + x_start = rect.x - magnifier->cursor_hotspot.x - + magnifier->crosswire_length; + x_end = rect.x + + (csize - magnifier->cursor_hotspot.x) + + magnifier->crosswire_length; + y_start = rect.y - magnifier->cursor_hotspot.y - + magnifier->crosswire_length; + y_end = rect.y + + (csize - magnifier->cursor_hotspot.y) + + magnifier->crosswire_length; + } else { + x_start = rect.x - magnifier->crosswire_length; + x_end = rect.x + magnifier->crosswire_length; + y_start = rect.y - magnifier->crosswire_length; + y_end = rect.y + magnifier->crosswire_length; + } + } + if (magnifier->crosswire_clip) { y_top_clip = rect.y - magnifier->cursor_hotspot.y - @@ -900,37 +922,50 @@ zoom_region_paint_crosswire_cursor (ZoomRegion *zoom_region, GdkRectangle *clip_ magnifier->crosswire_size; } - if (magnifier->crosswire_size == 1) - { - if (magnifier->crosswire_clip) - { - gdk_draw_line (zoom_region->priv->w->window, zoom_region->priv->crosswire_gc, rect.x, 0, - rect.x, y_top_clip); - gdk_draw_line (zoom_region->priv->w->window, zoom_region->priv->crosswire_gc, 0, rect.y, - x_left_clip, rect.y); + if (magnifier->crosswire_size == 1) { + if (magnifier->crosswire_clip) { + gdk_draw_line (zoom_region->priv->w->window, + zoom_region->priv->crosswire_gc, + rect.x, y_top_clip, rect.x, + y_bottom_clip); + gdk_draw_line (zoom_region->priv->w->window, + zoom_region->priv->crosswire_gc, + x_left_clip, rect.y, x_right_clip, + rect.y); } - gdk_draw_line (zoom_region->priv->w->window, zoom_region->priv->crosswire_gc, rect.x, - y_bottom_clip, rect.x, 4096); - gdk_draw_line (zoom_region->priv->w->window, zoom_region->priv->crosswire_gc, x_right_clip, - rect.y, 4096, rect.y); + gdk_draw_line (zoom_region->priv->w->window, + zoom_region->priv->crosswire_gc, + rect.x, y_start, rect.x, y_end); + gdk_draw_line (zoom_region->priv->w->window, + zoom_region->priv->crosswire_gc, + x_start, rect.y, x_end, rect.y); } - else - { - if (magnifier->crosswire_clip ) - { - gdk_draw_rectangle (zoom_region->priv->w->window, zoom_region->priv->crosswire_gc, TRUE, - rect.x - magnifier->crosswire_size / 2, - 0, magnifier->crosswire_size, y_top_clip); - gdk_draw_rectangle (zoom_region->priv->w->window, zoom_region->priv->crosswire_gc, TRUE, 0, - rect.y - magnifier->crosswire_size / 2, - x_left_clip, magnifier->crosswire_size); + else { + if (magnifier->crosswire_clip ) { + gdk_draw_rectangle ( + zoom_region->priv->w->window, + zoom_region->priv->crosswire_gc, TRUE, + rect.x - magnifier->crosswire_size / 2, + y_top_clip, magnifier->crosswire_size, + y_bottom_clip - y_top_clip); + gdk_draw_rectangle ( + zoom_region->priv->w->window, + zoom_region->priv->crosswire_gc, TRUE, + x_left_clip, + rect.y - magnifier->crosswire_size / 2, + x_right_clip - x_left_clip, + magnifier->crosswire_size); } - gdk_draw_rectangle (zoom_region->priv->w->window, zoom_region->priv->crosswire_gc, TRUE, - rect.x - magnifier->crosswire_size / 2, - y_bottom_clip, magnifier->crosswire_size, 4096); - gdk_draw_rectangle (zoom_region->priv->w->window, zoom_region->priv->crosswire_gc, TRUE, x_right_clip, - rect.y - magnifier->crosswire_size / 2, - 4096, magnifier->crosswire_size); + gdk_draw_rectangle ( + zoom_region->priv->w->window, + zoom_region->priv->crosswire_gc, TRUE, + rect.x - magnifier->crosswire_size / 2, y_start, + magnifier->crosswire_size, y_end - y_start); + gdk_draw_rectangle ( + zoom_region->priv->w->window, + zoom_region->priv->crosswire_gc, TRUE, + x_start, rect.y - magnifier->crosswire_size / 2, + x_end - x_start, magnifier->crosswire_size); } } @@ -1427,25 +1462,6 @@ zoom_region_set_cursor_pos (ZoomRegion *zoom_region, int x, int y) } } -static void -zoom_region_repaint_pointer (ZoomRegion *zoom_region) -{ - GdkRectangle paint_area, *clip = NULL; - - if (GTK_IS_WIDGET (zoom_region->priv->w) && - GDK_IS_DRAWABLE (zoom_region->priv->w->window)) { - gdk_drawable_get_size ( - GDK_DRAWABLE (zoom_region->priv->w->window), - &paint_area.width, &paint_area.height); - paint_area.x = 0; - paint_area.y = 0; - clip = &paint_area; - paint_area = zoom_region_clip_to_source (zoom_region, - paint_area); - } - zoom_region_update_cursor (zoom_region, 0, 0, clip); -} - static gboolean zoom_region_update_pointer (ZoomRegion *zoom_region, gboolean draw_cursor) { @@ -1478,7 +1494,8 @@ zoom_region_update_pointer (ZoomRegion *zoom_region, gboolean draw_cursor) mouse_x_return, mouse_y_return); if (draw_cursor) - zoom_region_repaint_pointer (zoom_region); + zoom_region_update_cursor (zoom_region, 0, 0, + NULL); return TRUE; } @@ -3098,7 +3115,7 @@ impl_zoom_region_update_pointer (PortableServer_Servant servant, g_assert (zoom_region->alive); #endif - zoom_region_repaint_pointer (zoom_region); + zoom_region_update_cursor (zoom_region, 0, 0, NULL); } static void diff --git a/test/control-client.c b/test/control-client.c index 6745f57..0e63419 100644 --- a/test/control-client.c +++ b/test/control-client.c @@ -242,10 +242,9 @@ int main(int argc, char ** argv){ break; case 'f': properties = GNOME_Magnifier_Magnifier_getProperties (magnifier, &ev); - bonobo_pbclient_set_long (properties, "crosswire-size", 0, NULL); - bonobo_object_release_unref (properties, NULL); - properties = GNOME_Magnifier_ZoomRegion_getProperties (zoom_region, &ev); - bonobo_pbclient_set_boolean (properties, "draw-cursor", FALSE, NULL); + bonobo_pbclient_set_long (properties, "crosswire-size", atoi (argv[2]), NULL); + bonobo_pbclient_set_long (properties, "crosswire-length", atoi (argv[3]), NULL); + bonobo_pbclient_set_boolean (properties, "crosswire-clip", atoi (argv[4]), NULL); bonobo_object_release_unref (properties, NULL); break; case 'a': |