[interfacekit] Re: BRect implementation
- From: "burton666@xxxxxxxxx" <burton666@xxxxxxxxx>
- To: "interfacekit" <interfacekit@xxxxxxxxxxxxx>
- Date: Wed, 15 Oct 2003 16:59:31 +0200
---------- Initial Header -----------
From : interfacekit-bounce@xxxxxxxxxxxxx
To : "interfacekit" interfacekit@xxxxxxxxxxxxx
Cc :
Date : Wed, 15 Oct 2003 13:40:33 +0200
Subject : [interfacekit] BRect implementation
> I guess you already know that our current BRect implementation has a serious
> flaw
> (BRect::Intersects() return false if one rect completely contains the other
> one). I guess it's time to fix it. This is the code: blablabla. Can I commit
> it ?
^^^^^^
Whoops! this "blablabla" isn't exactly the code I wanted to put there... I
guess I should re-read my emails before sending them ;P
I hope that no one felt offended by that :)
The code should look like:
bool
BRect::Intersects(BRect rect)
{
if !(rect.left > right || rect.right < left || rect.top > bottom ||
rect.bottom < top)
return true;
return false;
}
And here I forgot to add the "cleaner" code:
> BRegion Layer::ConvertToParent(BRegion *reg)
> {
> BRegion newreg;
> for(int32 i=0; i<reg->CountRects(); i++)
> newreg.Include( (reg->RectAt(i)).OffsetByCopy(_frame.LeftTop()) );
> return newreg;
> }
>
could look like:
BRegion Layer::ConvertToParent(BRegion *reg)
{
return BRegion(*reg).OffsetBy(_frame.LeftTop());
}
if you passed the BRegion as reference, the code would look even better.
Anyway, that's just a hint :)
- Follow-Ups:
- [interfacekit] Re: BRect implementation
- From: Ingo Weinhold
Other related posts:
- » [interfacekit] BRect implementation
- » [interfacekit] Re: BRect implementation
- » [interfacekit] Re: BRect implementation
- » [interfacekit] Re: BRect implementation
- [interfacekit] Re: BRect implementation
- From: Ingo Weinhold