[haiku-commits] Re: r40373 - haiku/trunk/src/preferences/filetypes

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 08 Feb 2011 11:06:27 +0100

On 2011-02-07 at 21:14:11 [+0100], Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> 
wrote:
> "Stephan Assmus" <superstippi@xxxxxx> wrote:
> > Von: "Axel Dörfler" <axeld@xxxxxxxxxxxxxxxx>
> > > superstippi@xxxxxx wrote:
> > > > +        rightWeight = 1.0 - leftWeight;
> > > > +    }
> > > > +    fMainSplitView->SetItemWeight(0, leftWeight, false);
> > > > +    fMainSplitView->SetItemWeight(1, rightWeight, true);
> > > Since they will always add to 1, why do you have to remember and
> > > set
> > > them both?
> > That's what I did at first, but in fact I don't know how those weights
> > work and
> > if they always add up to 1 after setting weights with the mouse. It's
> > somewhat
> > transparent to BSplitView. The way I do it now is robust against any
> > surprises.
> 
> Hm, feels a bit like controlling the chaos :-)
> How weights are implemented always depends on the view in question (for
> example, in a layout, it's the programmer's job to divide the weights
> completely). I haven't looked at the split view, but I would expect it
> to work the way that the weights add up to 1.
> Maybe we should start documenting that stuff, so one is not always
> forced to look into the code.

Both the BTwoDimensionalLayout and the BSplitLayout implementations 
consider the weights as weights, not as ratios (hence the naming). For two 
items weights 30 and 10 have the same meaning as 3 and 1 or 3/4 and 1/4. 
The default weight for components is 1. This makes it for instance very 
simple to make single component twice as heavy as others. Weight 0 has the 
special meaning of forcing the item to the minimally possible size (which 
is its minimum size, if the other items can grow sufficiently).

CU, Ingo

Other related posts: