[haiku-development] Re: Scrolling with child views - bug or feature?

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 17 Jul 2009 17:20:47 +0200

On 2009-07-17 at 16:42:43 [+0200], Ingo Weinhold <ingo_weinhold@xxxxxx> 
wrote:
> 
> -------- Original-Nachricht --------
> > Datum: Fri, 17 Jul 2009 16:12:35 +0200
> > Von: Stephan Assmus <superstippi@xxxxxx>
> 
> > On 2009-07-17 at 14:40:19 [+0200], Rene Gollent <anevilyak@xxxxxxxxx> 
> > wrote:
> > > On Fri, Jul 17, 2009 at 7:27 AM, Axel Dörfler<axeld@xxxxxxxxxxxxxxxx> 
> > > wrote:
> > > > Sure, but isn't that just view->Frame() + 
> > > > parent->Bounds().LeftTop() (ie. its scroll offset)?
> > > 
> > > As far as I can see, no:
> > > 
> > > Child Frame: BRect(l:41.0, t:0.0, r:939.0, b:31214.0) Child Bounds: 
> > > BRect(l:0.0, t:0.0, r:898.0, b:31214.0) Parent Bounds: BRect(l:0.0, 
> > > t:844.0, r:560.0, b:1195.0)
> > 
> > Yes, but this is the correct behaviour. To get the true view port, you 
> > would have to do something like this:
> > 
> > BRect visibleRect = Frame();
> > visibleRect &= parent->Bounds();
> > ConvertFromParent(&visibleRect);
> 
> IMO for this to have any meaning in any other than the "my parent is a 
> child of a scroll view" case, one would have to recursively consider all 
> ancestors up to the window.

If you want to call the method VisibleBounds(), then yes. Alternatively, 
one could pass a BView "lookingFrom". For example, if you pass the parent, 
you would get the visible bounds as seen from the parent. I think 
IsVisible() already works like this.

Best regards,
-Stephan

Other related posts: