Re: Brainy person needed for scrolling canvas problem!

2010-07-03 Thread John Emmas

On 3 Jul 2010, at 09:43, jcup...@gmail.com wrote:

 
 You'd link to the configure event to build the offscreen pixmap. The
 scribble example in the tutorial uses pixmaps to improve drawing:
 

I downloaded the Scribble example but interestingly, it seems to have been 
written for an older version of gtk/gdk.  It uses some gdk types (e.g. 
GdkDeviceInfo) which seem to be missing from gtk-2.0 but which look as though 
they used to be present in gtk-1.2.

I guess I could temporarily rename my gtk-2.0 include folders to make gtk-2.0 
inaccessible to the compiler but I'm curious to know if there's a better way to 
revert to the older version?

John
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Brainy person needed for scrolling canvas problem!

2010-07-03 Thread John Emmas

On 3 Jul 2010, at 15:33, John Emmas wrote:

 
 I downloaded the Scribble example but interestingly, it seems to have been 
 written for an older version of gtk/gdk.  It uses some gdk types (e.g. 
 GdkDeviceInfo) which seem to be missing from gtk-2.0 but which look as though 
 they used to be present in gtk-1.2.
 
 I guess I could temporarily rename my gtk-2.0 include folders to make gtk-2.0 
 inaccessible to the compiler but I'm curious to know if there's a better way 
 to revert to the older version?
 

Actually, it's slightly simpler than I thought.  The Scribble project has two 
source files (scribble.c and scribble-xinput.c).  Further investigation reveals 
that they actually compile to two different executables (At first, I thought 
they were both part of the same project which would have been worrying - 
because scribble.c needs gtk-2.0, whereas scribble-xinput.c needs gtk-1.2).
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Brainy person needed for scrolling canvas problem!

2010-07-02 Thread John Emmas
A program I'm working on uses a GTK main window to view an underlying gnome 
canvas object.  The canvas is wider than the part of it that's visible at any 
given time, so a horizontal scrollbar can be used to scroll the canvas, 
leftwards or rightwards.  The effect is similar to a multitrack audio tape.  
Like the tape analogy, the user needs to be able to fast-forward and rewind 
(by dragging the scrollbar) but also, the canvas needs to scroll continuously 
in time (i.e. programatically) to simulate time-based movement (like a tape 
that's playing).  There are two ways to achieve the playing effect:-

1) Every 1/30th second or thereabouts, erase all the objects on the canvas and 
redraw them, slightly to the left of their former positions.  This works quite 
well if the canvas only contains a small number of objects but if too many 
objects need to be redrawn, it soon becomes unwieldy and the movement ends up 
looking very jerky.

2) Draw all the objects onto a very wide canvas.  Every 1/30th second, 
reposition the viewport so that it's slightly to the right of its previous 
position (analogous to programatically setting the current position of the 
scrollbar).  This also works and gives a much smoother scrolling effect.

Now for the problem  when in playback mode, I'd like the viewport to have 
a vertical now line (similar to the play head on a tape recorder).  At the 
moment, this is drawn onto the canvas.  Therefore every 1/30th second, it needs 
to be erased, then the viewport needs to be adjusted, then the now line needs 
to be redrawn.  This produces a very flickery now line.

In an ideal world, I'd like the now line to be a viewport object, rather than a 
canvas object.  The viewport would ideally contain some kind of transparent 
pane (with the now line drawn on it) and the canvas would be viewable through 
the pane's transparent part.  The pane would be treated like a foreground 
object (so as to be permanently visible) with a fixed position, relative to the 
viewport, whereas the canvas would have a variable position, relative to the 
viewport.

Off the top of my head, I can't think of any gtk widget that's designed for 
this purpose.  Has anyone ever seen a project with this kind of feature?  Or 
can anyone suggest a feasible strategy I could try?

Thanks,

John
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Brainy person needed for scrolling canvas problem!

2010-07-02 Thread jcupitt
Hi John,

On 2 July 2010 16:04, John Emmas john...@tiscali.co.uk wrote:
 Now for the problem  when in playback mode, I'd like the viewport to 
 have a vertical now line (similar to the play head on a tape recorder).

I doubt I count as brainy, but one simple technique would be to render
the screen in layers.

You would have an offscreen pixbuf with the current view, minus the
now line. On an expose event, you copy the relevant parts of the
offscreen buffer to the display, then draw the now line over that.
Because of gtk's double-buffering, this will be flicker-free.

To scroll 100 pixels to the right, you blit your offscreen buffer by
100 pixels, draw just the objects in the exposed area of pixels, then
queue an expose for the whole widget.

This means you have to handle all the scrolling yourself, but it's not
so hard. Just connect your 'scroll by x pixels' function to the adjust
signal on a scrollbar.

If you need more speed (though I think it'd be quick enough on most
machines) you'd probably need to use opengl.

John
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Brainy person needed for scrolling canvas problem!

2010-07-02 Thread John Emmas
Thanks for the suggestion John.  Can I assume that you're referring to the 
functionality of gdk-pixbuf?  It didn't occur to me to look there, though I 
suppose it's the most obvious place to find a solution.  I'd been looking for 
layering API's or blitting API's within gtk :-(

So the obvious question is what would I use to obtain a pixbuf object from 
the current viewport / viewable area of a canvas?  Are there some handy API's 
available or would I need to roll my own?

John
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list