From 5df853ea79b44c49eb0722c8e95f422cd2c19b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 14 Nov 2005 17:50:39 +0000 Subject: [PATCH] * Renamed Layer::GetWantedRegion() to GetOnScreenRegion(). * minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14920 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Layer.cpp | 67 +++++++++++++++++--------------- src/servers/app/Layer.h | 2 +- src/servers/app/RootLayer.cpp | 6 +-- src/servers/app/ServerWindow.cpp | 4 +- src/servers/app/WinBorder.cpp | 15 ++++--- src/servers/app/WinBorder.h | 2 +- 6 files changed, 50 insertions(+), 46 deletions(-) diff --git a/src/servers/app/Layer.cpp b/src/servers/app/Layer.cpp index 50aaaaff33..83a45b4372 100644 --- a/src/servers/app/Layer.cpp +++ b/src/servers/app/Layer.cpp @@ -482,7 +482,7 @@ Layer::Show(bool invalidate) if (invalidate) { // compute the region this layer wants for itself BRegion invalid; - GetWantedRegion(invalid); + GetOnScreenRegion(invalid); if (invalid.CountRects() > 0) { fParent->MarkForRebuild(invalid); GetRootLayer()->MarkForRedraw(invalid); @@ -598,7 +598,7 @@ Layer::MoveBy(float x, float y) // we'll invalidate the old position and the new, maxmial one. BRegion invalid; - GetWantedRegion(invalid); + GetOnScreenRegion(invalid); invalid.Include(&fFullVisible2); fParent->MarkForRebuild(invalid); @@ -673,7 +673,7 @@ Layer::ResizeBy(float x, float y) // we'll invalidate the old area and the new, maxmial one. BRegion invalid; - GetWantedRegion(invalid); + GetOnScreenRegion(invalid); invalid.Include(&fFullVisible2); fParent->MarkForRebuild(invalid); @@ -1173,6 +1173,7 @@ Layer::do_Hide() } } + void Layer::do_Show() { @@ -1181,7 +1182,7 @@ Layer::do_Show() if (fParent && !fParent->IsHidden() && GetRootLayer()) { BRegion invalid; - GetWantedRegion(invalid); + GetOnScreenRegion(invalid); if (invalid.CountRects() > 0) { fParent->MarkForRebuild(invalid); @@ -1193,11 +1194,12 @@ Layer::do_Show() } } -inline void + +void Layer::_ResizeLayerFrameBy(float x, float y) { - uint16 rm = fResizeMode & 0x0000FFFF; - BRect newFrame = fFrame; + uint16 rm = fResizeMode & 0x0000FFFF; + BRect newFrame = fFrame; if ((rm & 0x0F00U) == _VIEW_LEFT_ << 8) newFrame.left += 0.0f; @@ -1254,12 +1256,12 @@ Layer::_ResizeLayerFrameBy(float x, float y) // TODO: the above code is CORRECT!!! // It's commented because BView::FrameResized()/Moved() be called twice a given view. FIX THIS! if (newFrame != fFrame) { - float dx, dy; + float dx, dy; - dx = newFrame.Width() - fFrame.Width(); - dy = newFrame.Height() - fFrame.Height(); + dx = newFrame.Width() - fFrame.Width(); + dy = newFrame.Height() - fFrame.Height(); - fFrame = newFrame; + fFrame = newFrame; if (dx != 0.0f || dy != 0.0f) { // call hook function @@ -1272,7 +1274,8 @@ Layer::_ResizeLayerFrameBy(float x, float y) } } -inline void + +void Layer::_RezizeLayerRedrawMore(BRegion ®, float dx, float dy) { if (dx == 0 && dy == 0) @@ -1311,19 +1314,17 @@ Layer::_RezizeLayerRedrawMore(BRegion ®, float dx, float dy) // above, OR this: // reg.Include(&child->fFullVisible2); - } - else - if (((rm & 0x0F0F) == (uint16)B_FOLLOW_RIGHT && dx != 0) || - ((rm & 0x0F0F) == (uint16)B_FOLLOW_H_CENTER && dx != 0) || - ((rm & 0xF0F0) == (uint16)B_FOLLOW_BOTTOM && dy != 0)|| - ((rm & 0xF0F0) == (uint16)B_FOLLOW_V_CENTER && dy != 0)) - { + } else if (((rm & 0x0F0F) == (uint16)B_FOLLOW_RIGHT && dx != 0) + || ((rm & 0x0F0F) == (uint16)B_FOLLOW_H_CENTER && dx != 0) + || ((rm & 0xF0F0) == (uint16)B_FOLLOW_BOTTOM && dy != 0) + || ((rm & 0xF0F0) == (uint16)B_FOLLOW_V_CENTER && dy != 0)) { reg.Include(&child->fFullVisible2); } } } -inline void + +void Layer::_ResizeLayerFullUpdateOnResize(BRegion ®, float dx, float dy) { if (dx == 0 && dy == 0) @@ -1343,17 +1344,21 @@ Layer::_ResizeLayerFullUpdateOnResize(BRegion ®, float dx, float dy) } } + +/*! + \brief Returns the region of the layer that is within the screen region +*/ void -Layer::GetWantedRegion(BRegion ®) +Layer::GetOnScreenRegion(BRegion ®ion) { // 1) set to frame in screen coords - BRect screenFrame(Bounds()); - ConvertToScreen(&screenFrame); - reg.Set(screenFrame); + BRect frame(Bounds()); + ConvertToScreen(&frame); + region.Set(frame); // 2) intersect with screen region - BRegion screenReg(GetRootLayer()->Bounds()); - reg.IntersectWith(&screenReg); + BRegion screenRegion(GetRootLayer()->Bounds()); + region.IntersectWith(&screenRegion); /* // 3) impose user constrained regions @@ -1366,10 +1371,10 @@ Layer::GetWantedRegion(BRegion ®) }*/ } + void -Layer::_RebuildVisibleRegions( const BRegion &invalid, - const BRegion &parentLocalVisible, - const Layer *startFrom) +Layer::_RebuildVisibleRegions(const BRegion &invalid, + const BRegion &parentLocalVisible, const Layer *startFrom) { /* // no point in continuing if this layer is hidden. @@ -1385,7 +1390,7 @@ Layer::_RebuildVisibleRegions( const BRegion &invalid, // intersect maximum wanted region with the invalid region BRegion common; - GetWantedRegion(common); + GetOnScreenRegion(common); common.IntersectWith(&invalid); // if the resulted region is not valid, this layer is not in the catchment area @@ -1437,7 +1442,7 @@ Layer::_RebuildVisibleRegions( const BRegion &invalid, return; BRegion common; - GetWantedRegion(common); + GetOnScreenRegion(common); // see how much you can take common.IntersectWith(&parentLocalVisible); diff --git a/src/servers/app/Layer.h b/src/servers/app/Layer.h index 77b678df00..2bb07c99f0 100644 --- a/src/servers/app/Layer.h +++ b/src/servers/app/Layer.h @@ -203,7 +203,7 @@ class Layer { inline const BRegion& FullVisible() const { return fFullVisible2; } inline const BRegion& DrawingRegion() const { return fDrawingRegion; } - virtual void GetWantedRegion(BRegion& reg); + virtual void GetOnScreenRegion(BRegion& region); void MarkForRebuild(const BRegion &dirty); void TriggerRebuild(); diff --git a/src/servers/app/RootLayer.cpp b/src/servers/app/RootLayer.cpp index a495ebbe39..da50a31160 100644 --- a/src/servers/app/RootLayer.cpp +++ b/src/servers/app/RootLayer.cpp @@ -872,7 +872,7 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState) BRegion invalid; // invalidate the maximum area which this layer/window can occupy. - layer->GetWantedRegion(invalid); + layer->GetOnScreenRegion(invalid); MarkForRebuild(invalid); MarkForRedraw(invalid); @@ -893,7 +893,7 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState) BRegion invalid; // start by invalidating the maximum area which this layer/window can occupy. - layer->GetWantedRegion(invalid); + layer->GetOnScreenRegion(invalid); // no reason to invalidate what's currently visible. invalid.Exclude(&layer->FullVisible()); @@ -1398,7 +1398,7 @@ RootLayer::ClearNotifyLayer() } } -// LayerRemoved + void RootLayer::LayerRemoved(Layer* layer) { diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index b5296b565c..920b20a4ec 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -625,7 +625,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) if (myRootLayer && !newLayer->IsHidden() && parent) { BRegion invalidRegion; - newLayer->GetWantedRegion(invalidRegion); + newLayer->GetOnScreenRegion(invalidRegion); parent->MarkForRebuild(invalidRegion); parent->TriggerRebuild(); if (newLayer->VisibleRegion().Frame().IsValid()) { @@ -1058,7 +1058,7 @@ if (myRootLayer) if (myRootLayer && !(fCurrentLayer->IsHidden()) && !fWinBorder->InUpdate()) { BRegion invalidRegion; - fCurrentLayer->GetWantedRegion(invalidRegion); + fCurrentLayer->GetOnScreenRegion(invalidRegion); // TODO: this is broken! a smaller area may be invalidated! diff --git a/src/servers/app/WinBorder.cpp b/src/servers/app/WinBorder.cpp index 019efef75d..9e4da9776b 100644 --- a/src/servers/app/WinBorder.cpp +++ b/src/servers/app/WinBorder.cpp @@ -798,20 +798,19 @@ WinBorder::_ReserveRegions(BRegion ®) void -WinBorder::GetWantedRegion(BRegion ®) +WinBorder::GetOnScreenRegion(BRegion& region) { if (fRebuildDecRegion) set_decorator_region(Bounds()); - BRect screenFrame(Bounds()); - ConvertToScreen(&screenFrame); - reg.Set(screenFrame); + BRect frame(Bounds()); + ConvertToScreen(&frame); + region.Set(frame); - reg.Include(&fDecRegion); + region.Include(&fDecRegion); - BRegion screenReg(GetRootLayer()->Bounds()); - - reg.IntersectWith(&screenReg); + BRegion screenRegion(GetRootLayer()->Bounds()); + region.IntersectWith(&screenRegion); } diff --git a/src/servers/app/WinBorder.h b/src/servers/app/WinBorder.h index 9b13571031..d48557c886 100644 --- a/src/servers/app/WinBorder.h +++ b/src/servers/app/WinBorder.h @@ -57,7 +57,7 @@ class WinBorder : public Layer { virtual bool IsOffscreenWindow() const { return false; } - virtual void GetWantedRegion(BRegion ®); + virtual void GetOnScreenRegion(BRegion& region); void UpdateStart(); void UpdateEnd();