- replaced Layer::get_user_regions with _GetWantedRegion()

- replaced Layer::alter_visible_for_children with _ReserveRegions()
- simplified a bit Layer::rebuild_visible_regions()

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14335 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca
2005-10-07 16:05:22 +00:00
parent 994ae14bb5
commit b961b59696
4 changed files with 27 additions and 35 deletions
+15 -27
View File
@@ -960,7 +960,7 @@ RebuildFullRegion();
if (invalidate) { if (invalidate) {
// compute the region this layer wants for itself // compute the region this layer wants for itself
BRegion invalidRegion; BRegion invalidRegion;
get_user_regions(invalidRegion); _GetWantedRegion(invalidRegion);
if (invalidRegion.CountRects() > 0) if (invalidRegion.CountRects() > 0)
GetRootLayer()->GoInvalidate(this, invalidRegion); GetRootLayer()->GoInvalidate(this, invalidRegion);
} }
@@ -1943,7 +1943,7 @@ Layer::GetWantedRegion(BRegion& reg) const
{ {
// this is the same as get_user_region. // this is the same as get_user_region.
// because get_user_region modifies nothing. // because get_user_region modifies nothing.
const_cast<Layer*>(this)->Layer::get_user_regions(reg); const_cast<Layer*>(this)->Layer::_GetWantedRegion(reg);
} }
//! converts a point from local to parent's coordinate system //! converts a point from local to parent's coordinate system
@@ -2129,7 +2129,7 @@ Layer::do_Show()
if (fParent && !fParent->IsHidden() && GetRootLayer()) { if (fParent && !fParent->IsHidden() && GetRootLayer()) {
BRegion invalid; BRegion invalid;
get_user_regions(invalid); _GetWantedRegion(invalid);
if (invalid.CountRects() > 0) if (invalid.CountRects() > 0)
fParent->do_Invalidate(invalid, this); fParent->do_Invalidate(invalid, this);
@@ -2313,7 +2313,7 @@ Layer::do_ResizeBy(float dx, float dy)
// we'll invalidate the old area and the new, maxmial one. // we'll invalidate the old area and the new, maxmial one.
BRegion invalid; BRegion invalid;
get_user_regions(invalid); _GetWantedRegion(invalid);
invalid.Include(&fFullVisible2); invalid.Include(&fFullVisible2);
clear_visible_regions(); clear_visible_regions();
@@ -2370,7 +2370,7 @@ void Layer::do_MoveBy(float dx, float dy)
// we'll invalidate the old position and the new, maxmial one. // we'll invalidate the old position and the new, maxmial one.
BRegion invalid; BRegion invalid;
get_user_regions(invalid); _GetWantedRegion(invalid);
invalid.Include(&fFullVisible2); invalid.Include(&fFullVisible2);
clear_visible_regions(); clear_visible_regions();
@@ -2445,7 +2445,7 @@ Layer::do_ScrollBy(float dx, float dy)
} }
void void
Layer::get_user_regions(BRegion &reg) Layer::_GetWantedRegion(BRegion &reg)
{ {
// 1) set to frame in screen coords // 1) set to frame in screen coords
BRect screenFrame(Bounds()); BRect screenFrame(Bounds());
@@ -2486,8 +2486,7 @@ Layer::rebuild_visible_regions(const BRegion &invalid,
const BRegion &parentLocalVisible, const BRegion &parentLocalVisible,
const Layer *startFrom) const Layer *startFrom)
{ {
// no point in continuing if this layer is hidden. starting from here, all // no point in continuing if this layer is hidden.
// descendants have (and will have) invalid visible regions.
if (fHidden) if (fHidden)
return; return;
@@ -2500,7 +2499,7 @@ Layer::rebuild_visible_regions(const BRegion &invalid,
// intersect maximum wanted region with the invalid region // intersect maximum wanted region with the invalid region
BRegion common; BRegion common;
get_user_regions(common); _GetWantedRegion(common);
common.IntersectWith(&invalid); common.IntersectWith(&invalid);
// if the resulted region is not valid, this layer is not in the catchment area // if the resulted region is not valid, this layer is not in the catchment area
@@ -2518,10 +2517,8 @@ Layer::rebuild_visible_regions(const BRegion &invalid,
// put in what's really visible // put in what's really visible
fFullVisible2.Include(&common); fFullVisible2.Include(&common);
// this is to allow a layer to hide some parts of itself so children // allow this layer to hide some parts from its children
// won't take them. _ReserveRegions(common);
BRegion unalteredVisible(common);
bool altered = alter_visible_for_children(common);
for (Layer *lay = LastChild(); lay; lay = PreviousChild()) { for (Layer *lay = LastChild(); lay; lay = PreviousChild()) {
if (lay == startFrom) if (lay == startFrom)
@@ -2532,25 +2529,16 @@ Layer::rebuild_visible_regions(const BRegion &invalid,
// to let children know much they can take from parent's visible region // to let children know much they can take from parent's visible region
common.Exclude(&lay->fFullVisible2); common.Exclude(&lay->fFullVisible2);
// we've hidden some parts of our visible region from our children,
// and we must be in sysnc with this region too...
if (altered)
unalteredVisible.Exclude(&lay->fFullVisible2);
} }
// the visible region of this layer is what left after all its children took // include what's left after all children took what they could.
// what they could. fVisible2.Include(&common);
if (altered)
fVisible2.Include(&unalteredVisible);
else
fVisible2.Include(&common);
} }
bool void
Layer::alter_visible_for_children(BRegion &reg) Layer::_ReserveRegions(BRegion &reg)
{ {
// Empty Hook function // Empty for Layer objects
return false;
} }
void void
+2 -2
View File
@@ -300,8 +300,8 @@ class Layer {
const BRegion &parentLocalVisible, const BRegion &parentLocalVisible,
const Layer *startFrom); const Layer *startFrom);
virtual bool alter_visible_for_children(BRegion &region); virtual void _ReserveRegions(BRegion &reg);
virtual void get_user_regions(BRegion &reg); virtual void _GetWantedRegion(BRegion &reg);
void clear_visible_regions(); void clear_visible_regions();
void resize_layer_frame_by(float x, float y); void resize_layer_frame_by(float x, float y);
+8 -4
View File
@@ -1005,13 +1005,17 @@ void WinBorder::set_decorator_region(BRect bounds)
} }
} }
bool WinBorder::alter_visible_for_children(BRegion &region) void
WinBorder::_ReserveRegions(BRegion &reg)
{ {
region.Exclude(&fDecRegion); BRegion reserve(reg);
return true; reserve.IntersectWith(&fDecRegion);
fVisible2.Include(&reserve);
reg.Exclude(&reserve);
} }
void WinBorder::get_user_regions(BRegion &reg) void
WinBorder::_GetWantedRegion(BRegion &reg)
{ {
if (fRebuildDecRegion) if (fRebuildDecRegion)
{ {
+2 -2
View File
@@ -126,8 +126,8 @@ class WinBorder : public Layer {
private: private:
void set_decorator_region(BRect frame); void set_decorator_region(BRect frame);
virtual bool alter_visible_for_children(BRegion &region); virtual void _ReserveRegions(BRegion &reg);
virtual void get_user_regions(BRegion &reg); virtual void _GetWantedRegion(BRegion &reg);
BRegion fDecRegion; BRegion fDecRegion;
bool fRebuildDecRegion; bool fRebuildDecRegion;