Re: gtk_widget_set_size_request stopped working with GTK3
- From: Tristan Van Berkom <tvb gnome org>
- To: Steffen Gutmann <muibase yahoo com>
- Cc: "gtk-devel-list gnome org" <gtk-devel-list gnome org>
- Subject: Re: gtk_widget_set_size_request stopped working with GTK3
- Date: Thu, 4 Oct 2012 09:31:14 +0900
On Thu, Oct 4, 2012 at 1:46 AM, Steffen Gutmann <muibase yahoo com> wrote:
> Hi Tristan!
>
>> I suggest you start by filing an enhancement bug against GtkImage for this.
>
> Yes, I can do that. Just to make sure, I file a new bug for component gtk, severity set to enhancement, and put somethign like "Size request of GtkImage" into the title. Is this correct?
Right, the bug might have to do more with cropping/scaling support in
GtkImage, rather than it's size request.
>
>> If you have a patch to propose, here would be a good place to discuss
>> the proposed new apis.
>
> I might also be able to work on this and provide a patch. Before starting on this, how about the following changes:
>
> Regarding size request:
>
> We add a new property of type boolean to GtkImage. If it is set (default), the size request for GtkImage will be the size of the underlying image (or the pixel-size), i.e. the exact same behaviour as it is now. If it is set to FALSE then the minimum size will be (1, 1) and an application can use "width-request" and "height-request" for making the widget size larger. I am not sure what a good name for this new property would be, but maybe you have a suggestion?. Something like "min-size-is-image-size" would probably make the property self-explanatory but is obviously too long compared to other existing property names. Maybe "full-image" or "image-size-request"?
>
> Regading placement:
>
> In GTK2, GtkImage cropped the image such that only the center is shown, i.e. it took off an equal amount of image content on the left and right, and top and bottom. It probably just sets the right clipping mask when drawing the image for achieving this. We could simply use the same policy, or we modify the usage of GtkWidget's "halign" and "valign" properties. Currently the docs reads:
>
> "halign" GtkAlign : Read / Write
While it's true that the align properties make no sense when the
widget's natural size is equal to,
or exceeds the widget's allocation; I'm not exactly sure it's a good
idea to use the GtkWidget's
halign/valign properties directly (i.e. it's like hidden candy, people
wont see it evidently in
the docs/headers for GtkImage and so will probably not discover it).
However I do like the idea of GtkAlign properties for that, where FILL
would mean scale
and CENTER/START/END have the obvious clipping behaviors.
It would have to deal well with situations where the user asked the
image to scale (FILL)
horizontally but to clip vertically ;-)
Also, it should have reasonable behaviors defined for the various
configurations of
a GtkImage (i.e, how does GtkIconSize fit into this ? does it make
sense to allow
the image to try loading the given icon at different sizes to satisfy
the allocation ?
naturally the natural size of the image would have to still be determined by the
user specified icon size, in the case that GtkImage be allocated extra space,
should a larger icon size be tried ? and should the image be upscaled as
a fallback or in situations where the source is a GdkPixbuf ?)
If you're serious about working on this, I would open an enhancement bug
and put your ideas there. You'll be sure to receive more feedback if you do
provide a patch with some test cases showing how it works.
Cheers,
-Tristan
>
> How to distribute horizontal space if widget gets extra space, see GtkAlign
>
> enum GtkAlign
> typedef enum { GTK_ALIGN_FILL, GTK_ALIGN_START, GTK_ALIGN_END, GTK_ALIGN_CENTER
> } GtkAlign;
>
> Controls how a widget deals with extra space in a single (x or y)
> dimension.
>
> Alignment only matters if the widget receives a "too large" allocation,
> for example if you packed the widget with the "expand" flag inside a GtkBox, then the widget might get extra space. If
> you have for example a 16x16 icon inside a 32x32 space, the icon
> could be scaled and stretched, it could be centered, or it could be
> positioned to one side of the space.
>
> Note that in horizontal context GTK_ALIGN_START and GTK_ALIGN_END are interpreted relative to text direction.
> GTK_ALIGN_FILL stretch to fill all space if possible, center if no meaningful way to stretch
> GTK_ALIGN_START snap to left or top side, leaving space on right or bottom
> GTK_ALIGN_END snap to right or bottom side, leaving space on left or top
> GTK_ALIGN_CENTER center natural width of widget inside the allocation
>
> My suggestion is to make halign and valign also deal with the case where the content of the widget is larger than the allocated space. The modified docs would then read:
>
> "halign" GtkAlign : Read / Write
>
> How to distribute horizontal space, see GtkAlign
>
> enum GtkAlign
> typedef enum { GTK_ALIGN_FILL, GTK_ALIGN_START, GTK_ALIGN_END, GTK_ALIGN_CENTER
> } GtkAlign;
>
> Controls how a widget deals with space in a single (x or y)
> dimension.
>
> Alignment only matters if the widget receives a "too large" or "too small" allocation,
> for example if you packed the widget with the "expand" flag inside a GtkBox, then the widget might get extra space. If
> you have for example a 16x16 icon inside a 32x32 space, the icon
> could be scaled and stretched, it could be centered, or it could be
> positioned to one side of the space. Likewise, if you have a 100x100 image inside a 20x20 space
> then the image could be scaled down, only the center part of the image be shown, or it could
> be cropped to the top left or bottom right part.
>
>
> Note that in horizontal context GTK_ALIGN_START and GTK_ALIGN_END are interpreted relative to text direction.
> GTK_ALIGN_FILL stretch or shrink to fill all space if possible, or center if no meaningful way to scale
> GTK_ALIGN_START snap to left or top side, leaving space or cropping widget content on right or bottom
> GTK_ALIGN_END snap to right or bottom side, leaving space or cropping widget content on left or top
> GTK_ALIGN_CENTER center widget inside the allocation
>
> Steffen
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]