On Thu, Jun 13, 2013 at 8:42 PM, Kip Warner <k...@thevertigo.com> wrote:
> That makes sense, but should the allocation passed to the base class's > do_size_allocate() be the original allocation parameter that was passed > into the override, or the one that I modified to contain the new image > dimensions adjusted to maintain the aspect ratio? > > If I use the allocation passed into the override, the pixels in the > image appear to rescale appropriately, but the image as a whole does > not. It grows horizontally, but the height of the widget remains fixed. Yes, you should pass in the same allocation you received. A really proper way to do this would be to scale the image to less than the full allocation depending on the margins/padding/border etc., and then the base class could do the right job with honoring that stuff after you set the pixbuf. But by default that stuff is 0 and you don't have to worry about it in this case. 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. 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. 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. _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list