On Thu, 2013-06-13 at 21:32 -0700, Andrew Potter wrote: > What you can't do is allocate additional height to yourself in > do_size_allocate(). So if you have a short wide image and are allocated > more width than the height at your aspect ratio allows, you _shouldn't_ > scale up or else your image will be clipped; the toolkit knows what it > allocated to you and will not let you draw outside of that region.
Ok, fair enough. > What you can do to (try to) prevent that situation is to set the widget to > do "height for width" allocation, and override > get_preferred_height_for_width() to honor your aspect ratio. In some > situations of course the toolkit won't be able to perfectly honor the > allocation request, so be sure not to scale out of bounds no matter what. Right. What I will do is resize to exactly what is passed into my do_size_allocate() override since that size should theoretically meet the aspect ratio I am maintaining via my do_get_preferred_height_for_width() override. > I'm not sure on how to set the widget to do "height for width" allocation, > it seems you may have to override get_request_mode()? What I did was > override all the size request methods instead. Here's what I did... def do_get_preferred_height_for_width(self, width): return (width / self._aspectRatio) def do_get_request_mode(self): return Gtk.SizeRequestMode.HEIGHT_FOR_WIDTH ...but something very interesting happens immediately after the return in do_get_preferred_height_for_width(). I get an assertion fail buried deep somewhere in python-gi... ERROR:../../gi/pygi-closure.c:494:_pygi_closure_set_out_arguments: code should not be reached One thing is clear. The latter do_get_request_mode() is in fact being queried. -- Kip Warner -- Software Engineer OpenPGP encrypted/signed mail preferred http://www.thevertigo.com _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list