[haiku-development] Re: Can we make BStringView's MaxSize = BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET) by default?

  • From: Alex Wilson <yourpalal2@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 10 Apr 2012 13:04:55 -0600

>
> > To me, composing the horizontal dimension of LayoutAlignment() with the
> > 'alignment' of the string seems to be the best solution, although it's
> still
> > a bit confusing.
>
> This seems like a much simpler solution than what I proposed. +1
>
> The Alignment() and SetAlignment() methods are pre-Layout API legacy
> AFAIK. They are in the BeBook at least. Could we
> SetExplicitAlignment(B_ALIGN_LEFT, B_ALIGN_TOP) like you did in the
> Layout API constructor for BStringView and have the SetAlignment()
> method also SetExplicitAlignment() appropriately if you are using a
> StringView built using a Layout API constructor?
>


Okay, cool, then we should still support these methods to some extent, but
we don't need to worry too much about them. What I'm thinking is to
override LayoutAlignment() like so:

BAlignment
BStringView::LayoutAlignment()
{
     return LayoutUtils::ComposeAlignment(ExplicitAlignment(),
BAlignment(fAlign, B_ALIGN_MIDDLE));
}

The preferred way to set the alignment would be with
SetExplicitAlignment(), but in the absence of an explicit alignment, the
horizontal aspect would fallback to the legacy alignment

It would be nice if I didn't have to call SetExplicitAlignment() for
> the default left-aligned case.


I agree.

--Alex

Other related posts: