Re: Image resizing



On Sun, 2013-06-09 at 00:12 -0700, Andrew Potter wrote:
One approach is ditching the ScrolledWindow and overriding the
 get_preferred_width_for_height/width() vfuncs to return the full image
width, and then in size_allocate() set the image to a scaled pixbuf of the
allocated width.

This involves making a subclass which is a little bit of work if you've
never done it before (especially in straight C).

The only example I have on hand [1] is in Gtkmm and does quite a bit more
than you need (Animated image support, toggling between thumbnail and full
size). But overriding these functions  should be enough:
size_allocate()
get_preferred_height()
get_preferred_width_for_height()
get_preferred_width()
get_preferred_height_for_width()

[1] https://github.com/talisein/Horizon/blob/master/src/horizon_image.cpp

Hey Andrew,

Sadly I haven't really much experience with Gtk+ in C or Gtkmm with C++.
I think it might be easier at this point if I just fixed the Python code
I've written thus far rather than refactoring it with custom overrides.
The code mostly works, it's just the scrollbar issue that's really
annoying. Any help really appreciated.

-- 
Kip Warner -- Software Engineer
OpenPGP encrypted/signed mail preferred
http://www.thevertigo.com


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