[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk-app-devel
Subject:    Re: Invisible GtkImage
From:       Kip Warner <kip () thevertigo ! com>
Date:       2013-07-02 7:28:53
Message-ID: 1372750133.29155.45.camel () rommel
[Download RAW message or body]

On Thu, 2013-06-27 at 16:01 -0700, Andrew Potter wrote:
> Please show the code that deals with the TextView and ScrolledWindow.
> The clipping is almost certainly due to setting the minimum size on
> either the TextView, or the GtkBox the two are contained in. I have
> example GtkAssistant code at the bottom of this email that does not
> exhibit this issue until extraordinarily small window sizes.

Hey Andrew. The code I posted on pastebin was the only GUI related code
for that stuff. The TextView and ScrolledWindow were all created via
GtkBuilder / Glade, so there isn't really anything to show, save the XML
unless you want that too. That's the bad news. 

The good news is by changing the minimum height returned in the
following override for your Gtk.Drawing subclass to 1, the clipping
issue seems solved - well, almost.

    def do_get_preferred_height_for_width(self, width):
        preferredHeight = width / self.get_aspect_ratio()
        return (1, preferredHeight)

> When scaling an image, both its height and width are changing. In
> order to fit the allocated rectangle without clipping, one must figure
> out which dimension is smallest (normalized to the aspect ratio). For
> example, if a 200x100 image is allocated 200x50, the allocation is
> height-limited and the image must be scaled to 100x50. OTOH if
> allocated 100x100, the image is width-limited and must be scaled to
> 100x50.

Right. Makes sense. Thank you for that clarification.

> I'm getting motivated to work on a patch to GtkImage to add scaling support...

I think that given how much work it took for us to figure out how to get
it working, probably a lot of other people might benefit from your
patch, so I applaud your efforts.

> -------------
> 
> Below is an example program with ScalableImage in a GtkAssistant.
> 
> Example 1, start up:
> http://i.imgur.com/ZdqwUZG.jpg
> 
> Example 2, Resized to less height. Notice the TextView/ScrolledWindow
> had plenty of space to "give up" because it has no minimum height
> http://i.imgur.com/wTN5rY9.jpg
> 
> Example 3, Clipping occurs at this very small size due to minimum size
> on the ScalableImage as well as the ScrolledWindow/TextView
> http://i.imgur.com/EAzFYOG.jpg

Yup. That's what I had observed.

> Example 4, ScalableImage is modified to return a 0 minimum size in
> get_preferred_height_for_width(). This means that at very small
> heights the image will not have enough space to fill the allocated
> width, allowing the other widgets get some space in this corner case.
> http://i.imgur.com/ZrOPt75.jpg
> 
> It is your choice whether or not to allow your header image to become
> smaller when the window is pressured for height.

Ok, for the sake of my application, setting it to zero / one vs leaving
it at the preferred height seems to solve the clipping issue, but
creates a new problem. On subsequent assistant pages, the image starts
off too small and is not using the full width available. However on the
first page, it fits the full width. Resizing the assistant makes it fill
the full width, but only after a certain amount is met. 

-- 
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
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic