Un-kludged Decorator::GetFootprint. Much more elegant now. :)

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4732 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-09-17 17:14:22 +00:00
parent 4ff18eccb5
commit 3231b95ed8
5 changed files with 22 additions and 27 deletions

View File

@ -541,17 +541,12 @@ void Decorator::_SetColors(void)
/*!
\brief Returns the "footprint" of the entire window, including decorator
\return Region representing the window's screen footprint
This function should generate a new BRegion allocated on the heap which represents
the entire area occupied by the window decorator on the screen. For example, a BeOS
decorator would return _tabrect + _borderrect.
\param region Region to be changed to represent the window's screen footprint
This function is required by all subclasses.
*/
BRegion *Decorator::GetFootprint(void)
void Decorator::GetFootprint(BRegion *region)
{
return NULL;
}
/*!

View File

@ -293,16 +293,17 @@ STRACE(("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y));
bottomborder.OffsetBy(pt);
}
BRegion * DefaultDecorator::GetFootprint(void)
void DefaultDecorator::GetFootprint(BRegion *region)
{
STRACE(("DefaultDecorator: Get Footprint\n"));
// This function calculates the decorator's footprint in coordinates
// relative to the layer. This is most often used to set a WinBorder
// object's visible region.
if(!region)
return;
BRegion *reg=new BRegion(_borderrect);
reg->Include(_tabrect);
return reg;
region->Set(_borderrect);
region->Include(_tabrect);
}
BRect DefaultDecorator::SlideTab(float dx, float dy=0){

View File

@ -40,7 +40,7 @@ public:
virtual void MoveBy(BPoint pt);
virtual void Draw(BRect r);
virtual void Draw(void);
virtual BRegion *GetFootprint(void);
virtual void GetFootprint(BRegion *region);
virtual BRect SlideTab(float dx, float dy);
virtual click_type Clicked(BPoint pt, int32 buttons, int32 modifiers);
protected:

View File

@ -436,10 +436,14 @@ WinBorder* Screen::GetWindowAt( BPoint pt ){
{
if(child->_hidden)
continue;
wb = dynamic_cast<WinBorder*>( child );
if (wb)
if(wb->GetDecorator()->GetFootprint()->Contains(pt))
wb = dynamic_cast<WinBorder*>(child);
if(wb)
{
BRegion reg;
wb->GetDecorator()->GetFootprint(&reg);
if(reg.Contains(pt))
return wb;
}
}
return NULL;
}

View File

@ -110,13 +110,8 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i
_vresizewin = false;
_driver = GetGfxDriver(ActiveScreen());
_decorator = new_decorator(r,name,look,feel,flags,GetGfxDriver(ActiveScreen()));
_decorator->GetFootprint(_visible);
// We need to do this because GetFootprint is supposed to generate a new BRegion.
// I suppose the call probably ought to be void GetFootprint(BRegion *recipient), but we can
// change that later.
delete _visible; // it was initialized in Layer's constructor.
_visible = _decorator->GetFootprint();
*_full = *_visible;
*_invalid = *_visible;
_frame = _visible->Frame();
@ -314,21 +309,22 @@ STRACE_CLICK(("ClickMove: Drag\n"));
// by the new location so we know what areas to invalidate.
// The original location
BRegion *reg=_decorator->GetFootprint();
BRegion reg;
_decorator->GetFootprint(&reg);
// The new location
BRegion reg2(*reg);
BRegion reg2(reg);
reg2.OffsetBy((int32)dx, (int32)dy);
MoveBy(dx,dy);
_decorator->MoveBy(BPoint(dx, dy));
// 3) quickly move the window
_driver->CopyRegion(reg,reg2.Frame().LeftTop());
_driver->CopyRegion(&reg,reg2.Frame().LeftTop());
// 4) Invalidate only the areas which we can't redraw directly
for(int32 i=0; i<reg2.CountRects();i++)
reg->Exclude(reg2.RectAt(i));
reg.Exclude(reg2.RectAt(i));
// TODO: DW's notes to self
// As of right now, dragging the window is extremely slow despite the use
@ -344,12 +340,11 @@ STRACE_CLICK(("ClickMove: Drag\n"));
// layer's coordinates, etc) and set things right. Secondly, nuke the invalid region
// in this call so that when RequestDraw is called, this WinBorder doesn't redraw itself
_parent->Invalidate(*reg);
_parent->Invalidate(reg);
_parent->RebuildRegions();
_parent->RequestDraw();
delete reg;
unlock_layers();
}
}