Re: Can this be done with goocanvas?



On Tue, 2008-10-21 at 20:32 +0200, Till Harbaum / Lists wrote:
> Hi,
> 
> Am Dienstag 21 Oktober 2008 schrieb Gustavo J. A. M. Carneiro:
> > Without looking at the code I am guessing that goocanvas is also
> > connecting to the same adjustment signals ("changed", "value-changed")
> > and so my signal handler comes after goocanvas.  If that is so, it would
> > help if goocanvas used connect_after instead of connect...
> Wouldn't you then have the same problem? You'd be moving items on the
> layer which might visible before goocanvas does the scrolling to move them
> back to their original position?

Not if I pay attention to the adjustment new value in my signal handler,
instead of whatever the canvas thinks are its visible bounds.  Which I
do.

Also I think I was imagining that goocanvas would draw on an idle
handler or expose event, and so it would draw later, after I had time to
adjust my item's coordinates.

Now looking at the code:

static void
goo_canvas_adjustment_value_changed (GtkAdjustment *adjustment,
				     GooCanvas     *canvas)
{
  AtkObject *accessible;

  if (!canvas->freeze_count && GTK_WIDGET_REALIZED (canvas))
    {
      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);

      /* Notify any accessibility modules that the view has changed. */
      accessible = gtk_widget_get_accessible (GTK_WIDGET (canvas));
      g_signal_emit_by_name (accessible, "visible_data_changed");
    }
}

I think I see the problem. gdk_window_process_updates forces the widget
to draw immediately to screen, before I have the chance to do
anything...

So, in summary, I really do get the feeling that goocanvas using
g_signal_connect_after for the scrolled window adjustments would solve
my problem.  But I did not try it yet to make sure.

> You'd basically have to make sure that any rendering is interrupted until both
> operations have been done. 

If updating a canvas items coordinates does not trigger an immediate
redrawing, only queue a redrawing, then there should be no problem.

-- 
Gustavo J. A. M. Carneiro
<gjc inescporto pt> <gustavo users sourceforge net>
"The universe is always one step beyond logic" -- Frank Herbert



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]