goocanvas r28 - in trunk: . demo src
- From: damon svn gnome org
- To: svn-commits-list gnome org
- Subject: goocanvas r28 - in trunk: . demo src
- Date: Mon, 17 Nov 2008 10:28:07 +0000 (UTC)
Author: damon
Date: Mon Nov 17 10:28:07 2008
New Revision: 28
URL: http://svn.gnome.org/viewvc/goocanvas?rev=28&view=rev
Log:
2008-11-17 Damon Chaplin <damon gnome org>
* src/goocanvas.c: added "redraw-when-scrolled" boolean property,
which makes the canvas redraw the entire window when scrolled. This
is useful for static items to reduce flicker, but is slower.
(goo_canvas_adjustment_value_changed): map/unmap the temporary window
to implement "redraw-when-scrolled".
Modified:
trunk/ChangeLog
trunk/demo/demo.c
trunk/src/goocanvas.c
trunk/src/goocanvas.h
Modified: trunk/demo/demo.c
==============================================================================
--- trunk/demo/demo.c (original)
+++ trunk/demo/demo.c Mon Nov 17 10:28:07 2008
@@ -473,6 +473,9 @@
"bounds-from-origin", FALSE,
"bounds-padding", 4.0,
"background-color-rgb", 0xC3C3FF,
+#if 0
+ "redraw-when-scrolled", TRUE,
+#endif
NULL);
goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 604, 454);
Modified: trunk/src/goocanvas.c
==============================================================================
--- trunk/src/goocanvas.c (original)
+++ trunk/src/goocanvas.c Mon Nov 17 10:28:07 2008
@@ -136,7 +136,8 @@
PROP_BACKGROUND_COLOR,
PROP_BACKGROUND_COLOR_RGB,
PROP_INTEGER_LAYOUT,
- PROP_CLEAR_BACKGROUND
+ PROP_CLEAR_BACKGROUND,
+ PROP_REDRAW_WHEN_SCROLLED
};
enum {
@@ -410,6 +411,13 @@
TRUE,
G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_REDRAW_WHEN_SCROLLED,
+ g_param_spec_boolean ("redraw-when-scrolled",
+ _("Redraw When Scrolled"),
+ _("If the canvas is completely redrawn when scrolled, to reduce the flicker of static items"),
+ FALSE,
+ G_PARAM_READWRITE));
+
/**
* GooCanvas::set-scroll-adjustments
* @canvas: the canvas.
@@ -474,6 +482,7 @@
canvas->crossing_event.type = GDK_LEAVE_NOTIFY;
canvas->anchor = GTK_ANCHOR_NORTH_WEST;
canvas->clear_background = TRUE;
+ canvas->redraw_when_scrolled = FALSE;
/* Set the default bounds to a reasonable size. */
canvas->bounds.x1 = 0.0;
@@ -743,6 +752,9 @@
case PROP_CLEAR_BACKGROUND:
g_value_set_boolean (value, canvas->clear_background);
break;
+ case PROP_REDRAW_WHEN_SCROLLED:
+ g_value_set_boolean (value, canvas->redraw_when_scrolled);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -846,6 +858,9 @@
case PROP_CLEAR_BACKGROUND:
canvas->clear_background = g_value_get_boolean (value);
break;
+ case PROP_REDRAW_WHEN_SCROLLED:
+ canvas->redraw_when_scrolled = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1897,46 +1912,52 @@
if (!canvas->freeze_count && GTK_WIDGET_REALIZED (canvas))
{
- /* Request a redraw of the bounds of the static items. */
- request_all_static_redraws (canvas);
+ if (canvas->redraw_when_scrolled)
+ {
+ /* Map the temporary window to stop the canvas window being scrolled.
+ When it is unmapped the entire canvas will be redrawn. */
+ if (GTK_WIDGET_MAPPED (canvas))
+ gdk_window_show (canvas->tmp_window);
+ }
+ else
+ {
+ /* Request a redraw of the bounds of the static items. */
+ request_all_static_redraws (canvas);
- /* Move the static items to the new position. */
- priv->window_x = -canvas->hadjustment->value;
- priv->window_y = -canvas->vadjustment->value;
-
- /* Now do the redraw. This makes sure the static items don't get dragged when the rest
- of the window is scrolled. */
- if (adjustment)
- gdk_window_process_updates (canvas->canvas_window, TRUE);
-
- /* To avoid flicker of static items completely we could redraw the entire canvas whenever
- it is scrolled, by mapping the temporary window as we do when zooming. Though of course
- it is a lot slower. We could make this an option. (If this code is used we don't need
- to redraw the static items and process updates afterwards.) */
-#if 0
- if (GTK_WIDGET_MAPPED (canvas))
- gdk_window_show (canvas->tmp_window);
-#endif
+ /* Move the static items to the new position. */
+ priv->window_x = -canvas->hadjustment->value;
+ priv->window_y = -canvas->vadjustment->value;
+
+ /* Now do the redraw. This makes sure the static items don't get
+ dragged when the rest of the window is scrolled. */
+ if (adjustment)
+ gdk_window_process_updates (canvas->canvas_window, TRUE);
+ }
gdk_window_move (canvas->canvas_window,
- canvas->hadjustment->value,
- canvas->vadjustment->value);
- /* If this is callback from a signal for one of the scrollbars, process
- updates here for smoother scrolling. */
- if (adjustment)
- gdk_window_process_updates (canvas->canvas_window, TRUE);
-
- /* Now make sure the static items are redrawn in their new position. */
- request_all_static_redraws (canvas);
-
- if (adjustment)
- gdk_window_process_updates (canvas->canvas_window, TRUE);
-
-#if 0
- if (GTK_WIDGET_MAPPED (canvas))
- gdk_window_hide (canvas->tmp_window);
-#endif
+ if (canvas->redraw_when_scrolled)
+ {
+ /* Unmap the temporary window, causing the entire canvas to be
+ redrawn. */
+ if (GTK_WIDGET_MAPPED (canvas))
+ gdk_window_hide (canvas->tmp_window);
+ }
+ else
+ {
+ /* If this is callback from a signal for one of the scrollbars,
+ process updates here for smoother scrolling. */
+ if (adjustment)
+ gdk_window_process_updates (canvas->canvas_window, TRUE);
+
+ /* Now ensure the static items are redrawn in their new position. */
+ request_all_static_redraws (canvas);
+
+ if (adjustment)
+ gdk_window_process_updates (canvas->canvas_window, TRUE);
+ }
/* Notify any accessibility modules that the view has changed. */
accessible = gtk_widget_get_accessible (GTK_WIDGET (canvas));
Modified: trunk/src/goocanvas.h
==============================================================================
--- trunk/src/goocanvas.h (original)
+++ trunk/src/goocanvas.h Mon Nov 17 10:28:07 2008
@@ -84,6 +84,10 @@
/* This is TRUE if the background is cleared before painting the canvas. */
guint clear_background : 1;
+ /* This is TRUE if the canvas is completely redrawn when scrolled. It is
+ useful when there are sticky items to reduce flicker, but is slower. */
+ guint redraw_when_scrolled : 1;
+
/* This is the padding around the automatic bounds. */
gdouble bounds_padding;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]