Re: clarification on GtkAlignment



Ah that would explain it.  I was expecting the alignment to base
calculations off the total available space, not the total available
space minus the widget's minimum size.

Is that actually useful?  I can't think of what I would use an alignment
for except saying "give this widget 25% of the available space, starting
at the middle (50%) of the available space" only that doesn't work...

-Mark Ivey-

On Tue, 2004-09-28 at 11:10, John Finlay wrote:
Mark Ivey wrote:

Wow, that's unfortunate.  I didn't really want to just pad it...that
almost goes back to the bad days of absolute positioning.

Anyone have any idea why the alignments aren't more "exact" with their
scales?  Is this intended?

-Mark Ivey-

On Tue, 2004-09-28 at 09:58, Stefan Kost wrote:
 

In the GNOME HIG they really suggest to use a label containg spaces for padding
(I don't like that as well).
That means you should put each button in a hbox(2) and put the padding label
into the first slot of the hbox and your button into the second one.
:-(

Stefan

Mark Ivey wrote:
   

I don't understand something about alignments, hopefully someone can
help me out.  My window contains a 4-row vbox filled with alignments. 
Each alignment has the same settings:
  x align: 1.0
  y align: 0.0
  x scale: 0.5
  y scale: 1.0
Each alignment also contains a 1 button.  The buttons have different
labels, like this:
  a
  as
  asd
  asdf

Now, I would expect all the buttons to take exactly half the window, but
they don't.  The buttons with shorter labels are slightly wider.  FWIW,
this happens with labels also, not just buttons

So what's the deal?  

My ultimate goal is to have a layout like this, where all the widgets
are lined up 1/3 of the way out from the left edge:

Section heading
----------------
    widget
    widget
    widget

Another section
----------------
    widget
    widget


...is there a better way to do it?

     

My understanding of aligments is that they deal with the free space 
beyond that required by the child widget. That means the scale factors 
take the fraction of free space and add it to the child widget required 
space. Likewise the align factors determine the fraction of free space 
to be allocated to the left or above the widget. For example:
A GtkButton widget (32 pixels wide by 32 pixels high) is placed inside a 
GtkAlignment widget (256 pixels wide by 128 pixels high) which has 
xalign of 0.25, yalign of 0.25, xscale of 0.25 and yscale of 0.25. The 
horizontal free space is 256-32=224 pixels and the vertical free space 
is 128-32=96 pixels. The button will absorb 0.25x224=56 pixels 
horizontally and 0.25x96=24 pixels vertically since the xscale and 
yscale are 0.25 and become 32+56=88 pixels wide by 32+24=56 pixels high. 
This will leave 256-88=168 pixels of horizontal free space and 128-56=72 
pixels of vertical free space. Since the xalign value is 0.25 the 
horizontal free space will be allocated as 0.25x168=42 pixels to the 
left of the button and 0.72x168=126 pixels to the right. Likewise given 
a yalign value of 0.25 the vertical free space is allocated as 
0.25x72=18 pixels above the button and 0.75*72=54 pixels below.

John






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