Hi Samuel,

basically, what you can do in that particular case is to connect to the
Viewport "configure-event" signal, and change the size of the Canvas to
reflect the size of the Viewport.  You can do that by affecting the new
Viewport size to the Canvas size.  You will also need to adapt the
position and size of all the Drawables inside the Canvas to fit your
needs.

Regarding the "configure-event" signal, this one is emitted when the
viewport is resized or moved.  So if you want to avoid doing the
expensive operation described above when the viewport is moved, you have
to implement a simple system to cache the viewport size, so that you can
test in the configure callback if the signal have been emitted after a
resize or not.

On Wed, 2007-07-18 at 19:04 +0200, Samuel Abels wrote:
> Hi,
> 
> I have written a small UI using Pigment from SVN. When the application starts,
> the windows has a size of 800x600. When expanding the window (e.g. to
> 1920x1200), Pigment automatically resizes the canvas such that the 
> height/width
> ration stays the same (1600*1200). So it draws black borders.
> 
> I tried to work around that by using code like this:
> 
> ----------
> def on_resize(gl, visible_size, content):
>     canvas.height = 3.0
>     canvas.width  = float(canvas.height) * float(gl.width) / float(gl.height)
>     content.size  = canvas.size
> 
> # OpenGL viewport creation
> factory = pgm.ViewportFactory('opengl')
> gl      = factory.create()
> canvas  = pgm.Canvas()
> gl.set_canvas(canvas)
> 
> # MyContent is derived from Group
> content = MyContent(canvas, pgm.DRAWABLE_MIDDLE)
> content.visible = True
> 
> on_resize(gl, canvas, canvas, content) # Triggers update.
> gobject.timeout_add(15, gl.update)
> gl.connect('configure-event', on_resize, canvas, content)
> ----------
> 
> This has a number of unwanted side effects where the children of content 
> render
> differently. I still got it to work half way with a lot of pain, but when 
> there
> are a lot of expose events (e.g. when you move the window with the mouse) it
> still fails.
> 
> Is there a better way to resize the canvas?

Regards,
-- 
Loïc Molinari <[EMAIL PROTECTED]>

Reply via email to