Some minor API cleanups
Documented quite a few functions while refamiliarizing myself with the desktop code git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8896 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+251
-134
@@ -111,6 +111,14 @@ Layer::~Layer(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Adds a child layer to the current one
|
||||||
|
\param layer a new child layer
|
||||||
|
\param serverWin the serverwindow to which the layer will belong
|
||||||
|
|
||||||
|
Unlike the BView version, if the layer already belongs to another, then
|
||||||
|
it spits an error to stdout and returns.
|
||||||
|
*/
|
||||||
void Layer::AddChild(Layer *layer, ServerWindow *serverWin)
|
void Layer::AddChild(Layer *layer, ServerWindow *serverWin)
|
||||||
{
|
{
|
||||||
STRACE(("Layer(%s)::AddChild(%s) START\n", GetName(), layer->GetName()));
|
STRACE(("Layer(%s)::AddChild(%s) START\n", GetName(), layer->GetName()));
|
||||||
@@ -123,6 +131,9 @@ void Layer::AddChild(Layer *layer, ServerWindow *serverWin)
|
|||||||
|
|
||||||
// 1) attach layer to the tree structure
|
// 1) attach layer to the tree structure
|
||||||
layer->fParent = this;
|
layer->fParent = this;
|
||||||
|
|
||||||
|
// if we have children already, bump the current front child back one and
|
||||||
|
// make the new child the frontmost layer
|
||||||
if( fBottomChild )
|
if( fBottomChild )
|
||||||
{
|
{
|
||||||
layer->fUpperSibling = fBottomChild;
|
layer->fUpperSibling = fBottomChild;
|
||||||
@@ -134,43 +145,60 @@ void Layer::AddChild(Layer *layer, ServerWindow *serverWin)
|
|||||||
}
|
}
|
||||||
fBottomChild = layer;
|
fBottomChild = layer;
|
||||||
|
|
||||||
// if no RootLayer, there is no need to set any parameters.
|
// if we have no RootLayer yet, then there is no need to set any parameters --
|
||||||
// they will be set when the root Layer for this tree will be added
|
// they will be set when the RootLayer for this tree will be added
|
||||||
// to the main tree structure.
|
// to the main tree structure.
|
||||||
if (fRootLayer == NULL){
|
if (!fRootLayer)
|
||||||
|
{
|
||||||
STRACE(("Layer(%s)::AddChild(%s) END\n", GetName(), layer->GetName()));
|
STRACE(("Layer(%s)::AddChild(%s) END\n", GetName(), layer->GetName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2) set some fields for this new layer and its children.
|
// 2) Iterate over the newly-added layer and all its children, setting the
|
||||||
Layer *c = layer; //c = short for: current
|
// root layer and server window and also rebuilding the full-size region
|
||||||
Layer *stop = layer;
|
// for every descendant of the newly-added layer
|
||||||
while( true ){
|
|
||||||
|
//c = short for: current
|
||||||
|
Layer *c = layer;
|
||||||
|
Layer *stop = layer;
|
||||||
|
while( true )
|
||||||
|
{
|
||||||
// action block
|
// action block
|
||||||
{
|
|
||||||
// 2.1) set the RootLayer for this object.
|
// 2.1) set the RootLayer for this object.
|
||||||
c->SetRootLayer(c->fParent->fRootLayer);
|
c->SetRootLayer(c->fParent->fRootLayer);
|
||||||
// 2.2) this Layer must know if it has a ServerWindow object attached.
|
|
||||||
c->SetServerWindow(serverWin);//c->fParent->fServerWin);
|
// 2.2) this Layer must know if it has a ServerWindow object attached.
|
||||||
// 2.3) we are attached to the main tree so build our full region.
|
fServerWin=serverWin;
|
||||||
c->RebuildFullRegion();
|
|
||||||
}
|
// 2.3) we are attached to the main tree so build our full region.
|
||||||
|
c->RebuildFullRegion();
|
||||||
|
|
||||||
// tree parsing algorithm
|
// tree parsing algorithm
|
||||||
if( c->fTopChild ){ // go deep
|
if( c->fTopChild )
|
||||||
|
{
|
||||||
|
// go deep
|
||||||
c = c->fTopChild;
|
c = c->fTopChild;
|
||||||
}
|
}
|
||||||
else{ // go right or up
|
else
|
||||||
|
{
|
||||||
|
// go right or up
|
||||||
|
|
||||||
if (c == stop) // out trip is over
|
if (c == stop) // out trip is over
|
||||||
break;
|
break;
|
||||||
if( c->fLowerSibling ){ // go right
|
|
||||||
|
if( c->fLowerSibling )
|
||||||
|
{
|
||||||
|
// go right
|
||||||
c = c->fLowerSibling;
|
c = c->fLowerSibling;
|
||||||
}
|
}
|
||||||
else{ // go up
|
else
|
||||||
|
{
|
||||||
|
// go up
|
||||||
while( !c->fParent->fLowerSibling && c->fParent != stop )
|
while( !c->fParent->fLowerSibling && c->fParent != stop )
|
||||||
c = c->fParent;
|
c = c->fParent;
|
||||||
|
|
||||||
if( c->fParent == stop ) // that enough!
|
if( c->fParent == stop ) // that's enough!
|
||||||
break;
|
break;
|
||||||
|
|
||||||
c = c->fParent->fLowerSibling;
|
c = c->fParent->fLowerSibling;
|
||||||
@@ -178,51 +206,67 @@ void Layer::AddChild(Layer *layer, ServerWindow *serverWin)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STRACE(("Layer(%s)::AddChild(%s) END\n", GetName(), layer->GetName()));
|
STRACE(("Layer(%s)::AddChild(%s) END\n", GetName(), layer->GetName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Removes a child layer from the current one
|
||||||
|
\param layer the layer to remove
|
||||||
|
|
||||||
|
If the layer does not belong to the the current layer, then this function
|
||||||
|
spits out an error to stdout and returns
|
||||||
|
*/
|
||||||
void Layer::RemoveChild(Layer *layer)
|
void Layer::RemoveChild(Layer *layer)
|
||||||
{
|
{
|
||||||
STRACE(("Layer(%s)::RemoveChild(%s) START\n", GetName(), layer->GetName()));
|
STRACE(("Layer(%s)::RemoveChild(%s) START\n", GetName(), layer->GetName()));
|
||||||
|
|
||||||
if( layer->fParent == NULL )
|
if(!layer->fParent)
|
||||||
{
|
{
|
||||||
printf("ERROR: RemoveChild(): Layer doesn't have a fParent\n");
|
printf("ERROR: RemoveChild(): Layer doesn't have a fParent\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( layer->fParent != this )
|
if(layer->fParent != this)
|
||||||
{
|
{
|
||||||
printf("ERROR: RemoveChild(): Layer is not a child of this layer\n");
|
printf("ERROR: RemoveChild(): Layer is not a child of this layer\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1) remove this layer the main tree.
|
// 1) remove this layer from the main tree.
|
||||||
|
|
||||||
// Take care of fParent
|
// Take care of fParent
|
||||||
layer->fParent = NULL;
|
layer->fParent = NULL;
|
||||||
|
|
||||||
if( fTopChild == layer )
|
if( fTopChild == layer )
|
||||||
fTopChild = layer->fLowerSibling;
|
fTopChild = layer->fLowerSibling;
|
||||||
|
|
||||||
if( fBottomChild == layer )
|
if( fBottomChild == layer )
|
||||||
fBottomChild = layer->fUpperSibling;
|
fBottomChild = layer->fUpperSibling;
|
||||||
|
|
||||||
// Take care of siblings
|
// Take care of siblings
|
||||||
if( layer->fUpperSibling != NULL )
|
if( layer->fUpperSibling != NULL )
|
||||||
layer->fUpperSibling->fLowerSibling = layer->fLowerSibling;
|
layer->fUpperSibling->fLowerSibling = layer->fLowerSibling;
|
||||||
|
|
||||||
if( layer->fLowerSibling != NULL )
|
if( layer->fLowerSibling != NULL )
|
||||||
layer->fLowerSibling->fUpperSibling = layer->fUpperSibling;
|
layer->fLowerSibling->fUpperSibling = layer->fUpperSibling;
|
||||||
layer->fUpperSibling = NULL;
|
|
||||||
layer->fLowerSibling = NULL;
|
|
||||||
|
|
||||||
// 2) clear some fields for this layer and its children.
|
layer->fUpperSibling = NULL;
|
||||||
Layer *c = layer; //c = short for: current
|
layer->fLowerSibling = NULL;
|
||||||
Layer *stop = layer;
|
|
||||||
while( true ){
|
// 2) Iterate over all of the removed-layer's descendants and unset the
|
||||||
|
// root layer, server window, and all redraw-related regions
|
||||||
|
|
||||||
|
Layer *c = layer; //c = short for: current
|
||||||
|
Layer *stop = layer;
|
||||||
|
|
||||||
|
while( true )
|
||||||
|
{
|
||||||
// action block
|
// action block
|
||||||
{
|
{
|
||||||
// 2.1) set the RootLayer for this object.
|
// 2.1) set the RootLayer for this object.
|
||||||
c->SetRootLayer(NULL);
|
c->SetRootLayer(NULL);
|
||||||
// 2.2) this Layer must know if it has a ServerWindow object attached.
|
// 2.2) this Layer must know if it has a ServerWindow object attached.
|
||||||
c->SetServerWindow(NULL);
|
fServerWin=NULL;
|
||||||
// 2.3) we were removed from the main tree so clear our full region.
|
// 2.3) we were removed from the main tree so clear our full region.
|
||||||
c->fFull.MakeEmpty();
|
c->fFull.MakeEmpty();
|
||||||
// 2.4) clear fullVisible region.
|
// 2.4) clear fullVisible region.
|
||||||
@@ -232,17 +276,25 @@ void Layer::RemoveChild(Layer *layer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// tree parsing algorithm
|
// tree parsing algorithm
|
||||||
if( c->fTopChild ){ // go deep
|
if( c->fTopChild )
|
||||||
|
{
|
||||||
|
// go deep
|
||||||
c = c->fTopChild;
|
c = c->fTopChild;
|
||||||
}
|
}
|
||||||
else{ // go right or up
|
else
|
||||||
|
{
|
||||||
|
// go right or up
|
||||||
if (c == stop) // out trip is over
|
if (c == stop) // out trip is over
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if( c->fLowerSibling ){ // go right
|
if( c->fLowerSibling )
|
||||||
|
{
|
||||||
|
// go right
|
||||||
c = c->fLowerSibling;
|
c = c->fLowerSibling;
|
||||||
}
|
}
|
||||||
else{ // go up
|
else
|
||||||
|
{
|
||||||
|
// go up
|
||||||
while( !c->fParent->fLowerSibling && c->fParent != stop )
|
while( !c->fParent->fLowerSibling && c->fParent != stop )
|
||||||
c = c->fParent;
|
c = c->fParent;
|
||||||
|
|
||||||
@@ -253,9 +305,10 @@ void Layer::RemoveChild(Layer *layer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
STRACE(("Layer(%s)::RemoveChild(%s) END\n", GetName(), layer->GetName()));
|
STRACE(("Layer(%s)::RemoveChild(%s) END\n", GetName(), layer->GetName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Removes the calling layer from the tree
|
||||||
void Layer::RemoveSelf()
|
void Layer::RemoveSelf()
|
||||||
{
|
{
|
||||||
// A Layer removes itself from the tree (duh)
|
// A Layer removes itself from the tree (duh)
|
||||||
@@ -267,6 +320,10 @@ void Layer::RemoveSelf()
|
|||||||
fParent->RemoveChild(this);
|
fParent->RemoveChild(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Determins if the calling layer has the passed layer as a child
|
||||||
|
\return true if the child is owned by the caller, false if not
|
||||||
|
*/
|
||||||
bool Layer::HasChild(Layer* layer)
|
bool Layer::HasChild(Layer* layer)
|
||||||
{
|
{
|
||||||
for(Layer *lay = VirtualTopChild(); lay; lay = VirtualLowerSibling())
|
for(Layer *lay = VirtualTopChild(); lay; lay = VirtualLowerSibling())
|
||||||
@@ -277,6 +334,11 @@ bool Layer::HasChild(Layer* layer)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Returns the layer at the given point
|
||||||
|
\param pt The point to look the layer at
|
||||||
|
\return The layer containing the point or NULL if no layer found
|
||||||
|
*/
|
||||||
Layer* Layer::LayerAt(const BPoint &pt)
|
Layer* Layer::LayerAt(const BPoint &pt)
|
||||||
{
|
{
|
||||||
if (fVisible.Contains(pt))
|
if (fVisible.Contains(pt))
|
||||||
@@ -296,6 +358,7 @@ Layer* Layer::LayerAt(const BPoint &pt)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Matches the BView call of the same name
|
||||||
BRect Layer::Bounds(void) const
|
BRect Layer::Bounds(void) const
|
||||||
{
|
{
|
||||||
BRect r(fFrame);
|
BRect r(fFrame);
|
||||||
@@ -303,11 +366,13 @@ BRect Layer::Bounds(void) const
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Matches the BView call of the same name
|
||||||
BRect Layer::Frame(void) const
|
BRect Layer::Frame(void) const
|
||||||
{
|
{
|
||||||
return fFrame;
|
return fFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Recursively deletes all children of the calling layer
|
||||||
void Layer::PruneTree(void)
|
void Layer::PruneTree(void)
|
||||||
{
|
{
|
||||||
Layer *lay;
|
Layer *lay;
|
||||||
@@ -330,6 +395,11 @@ void Layer::PruneTree(void)
|
|||||||
// Man, this thing is short. Elegant, ain't it? :P
|
// Man, this thing is short. Elegant, ain't it? :P
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Finds a child of the caller based on its token ID
|
||||||
|
\param token ID of the layer to find
|
||||||
|
\return Pointer to the layer or NULL if not found
|
||||||
|
*/
|
||||||
Layer *Layer::FindLayer(const int32 token)
|
Layer *Layer::FindLayer(const int32 token)
|
||||||
{
|
{
|
||||||
// recursive search for a layer based on its view token
|
// recursive search for a layer based on its view token
|
||||||
@@ -355,20 +425,18 @@ Layer *Layer::FindLayer(const int32 token)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::SetServerWindow(ServerWindow *win)
|
/*!
|
||||||
|
\brief Returns the layer's ServerWindow
|
||||||
|
|
||||||
|
If the layer's ServerWindow has not been assigned, it attempts to find
|
||||||
|
the owning ServerWindow in the tree.
|
||||||
|
*/
|
||||||
|
ServerWindow* Layer::SearchForServerWindow()
|
||||||
{
|
{
|
||||||
fServerWin = win;
|
if(!fServerWin)
|
||||||
}
|
fServerWin=fParent->SearchForServerWindow();
|
||||||
|
|
||||||
ServerWindow* Layer::SearchForServerWindow() const
|
return fServerWin;
|
||||||
{
|
|
||||||
if (fServerWin)
|
|
||||||
return fServerWin;
|
|
||||||
|
|
||||||
if(fParent)
|
|
||||||
return fParent->SearchForServerWindow();
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::RebuildAndForceRedraw(const BRegion& reg, Layer *target)
|
void Layer::RebuildAndForceRedraw(const BRegion& reg, Layer *target)
|
||||||
@@ -394,6 +462,7 @@ void Layer::FullInvalidate(const BRect &rect)
|
|||||||
void Layer::FullInvalidate(const BRegion& region)
|
void Layer::FullInvalidate(const BRegion& region)
|
||||||
{
|
{
|
||||||
STRACE(("Layer(%s)::FullInvalidate():\n", GetName()));
|
STRACE(("Layer(%s)::FullInvalidate():\n", GetName()));
|
||||||
|
|
||||||
#ifdef DEBUG_LAYER
|
#ifdef DEBUG_LAYER
|
||||||
region.PrintToStream();
|
region.PrintToStream();
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@@ -443,21 +512,27 @@ void Layer::RequestDraw(const BRegion ®, Layer *startFrom)
|
|||||||
|
|
||||||
// do not redraw any child until you must
|
// do not redraw any child until you must
|
||||||
int redraw = false;
|
int redraw = false;
|
||||||
if (startFrom == NULL)
|
if (!startFrom)
|
||||||
redraw = true;
|
redraw = true;
|
||||||
|
|
||||||
if (fVisible.CountRects() > 0)
|
if (fVisible.CountRects() > 0)
|
||||||
{
|
{
|
||||||
// client side drawing. Send only one UPDATE message!
|
// client side drawing. Send only one UPDATE message!
|
||||||
if (IsClientLayer())
|
if (HasClient())
|
||||||
{
|
{
|
||||||
if (IsTopLayer())
|
if (IsTopLayer())
|
||||||
{
|
{
|
||||||
// calculate the minimum region/rectangle to be updated with
|
// calculate the minimum region/rectangle to be updated with
|
||||||
// a single message to the client.
|
// a single message to the client.
|
||||||
fUpdateReg = fFullVisible;
|
fUpdateReg = fFullVisible;
|
||||||
if (fFlags & B_FULL_UPDATE_ON_RESIZE){ }
|
if (fFlags & B_FULL_UPDATE_ON_RESIZE)
|
||||||
else { fUpdateReg.IntersectWith(®); }
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fUpdateReg.IntersectWith(®);
|
||||||
|
}
|
||||||
|
|
||||||
if (fUpdateReg.CountRects() > 0)
|
if (fUpdateReg.CountRects() > 0)
|
||||||
{
|
{
|
||||||
@@ -470,8 +545,14 @@ void Layer::RequestDraw(const BRegion ®, Layer *startFrom)
|
|||||||
|
|
||||||
// calculate the update region, then...
|
// calculate the update region, then...
|
||||||
fUpdateReg = fVisible;
|
fUpdateReg = fVisible;
|
||||||
if (fFlags & B_FULL_UPDATE_ON_RESIZE){ }
|
if (fFlags & B_FULL_UPDATE_ON_RESIZE)
|
||||||
else { fUpdateReg.IntersectWith(®); }
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fUpdateReg.IntersectWith(®);
|
||||||
|
}
|
||||||
|
|
||||||
if (fUpdateReg.CountRects() > 0)
|
if (fUpdateReg.CountRects() > 0)
|
||||||
{
|
{
|
||||||
@@ -481,13 +562,20 @@ void Layer::RequestDraw(const BRegion ®, Layer *startFrom)
|
|||||||
fDriver->ConstrainClippingRegion(NULL);
|
fDriver->ConstrainClippingRegion(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// server drawings are immediate.
|
|
||||||
// No IPC is needed so this is done in place.
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// server drawings are immediate.
|
||||||
|
// No IPC is needed so this is done in place.
|
||||||
|
|
||||||
fUpdateReg = fVisible;
|
fUpdateReg = fVisible;
|
||||||
if (fFlags & B_FULL_UPDATE_ON_RESIZE){ }
|
if (fFlags & B_FULL_UPDATE_ON_RESIZE)
|
||||||
else { fUpdateReg.IntersectWith(®); }
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fUpdateReg.IntersectWith(®);
|
||||||
|
}
|
||||||
|
|
||||||
if (fUpdateReg.CountRects() > 0)
|
if (fUpdateReg.CountRects() > 0)
|
||||||
{
|
{
|
||||||
@@ -508,13 +596,18 @@ void Layer::RequestDraw(const BRegion ®, Layer *startFrom)
|
|||||||
{
|
{
|
||||||
// no need to go deeper if not even the FullVisible region intersects
|
// no need to go deeper if not even the FullVisible region intersects
|
||||||
// Update one.
|
// Update one.
|
||||||
|
|
||||||
BRegion common(lay->fFullVisible);
|
BRegion common(lay->fFullVisible);
|
||||||
common.IntersectWith(®);
|
common.IntersectWith(®);
|
||||||
if (common.CountRects() > 0){
|
|
||||||
|
if (common.CountRects() > 0)
|
||||||
|
{
|
||||||
// lock/unlock if we are a winborder
|
// lock/unlock if we are a winborder
|
||||||
if (lay->fClassID == AS_WINBORDER_CLASS)
|
if (lay->fClassID == AS_WINBORDER_CLASS)
|
||||||
lay->Window()->Lock();
|
lay->Window()->Lock();
|
||||||
|
|
||||||
lay->RequestDraw(reg, NULL);
|
lay->RequestDraw(reg, NULL);
|
||||||
|
|
||||||
if (lay->fClassID == AS_WINBORDER_CLASS)
|
if (lay->fClassID == AS_WINBORDER_CLASS)
|
||||||
lay->Window()->Unlock();
|
lay->Window()->Unlock();
|
||||||
}
|
}
|
||||||
@@ -526,15 +619,11 @@ void Layer::Draw(const BRect &r)
|
|||||||
{
|
{
|
||||||
// TODO/NOTE: this should be an empty method! the next lines are for testing only
|
// TODO/NOTE: this should be an empty method! the next lines are for testing only
|
||||||
|
|
||||||
#ifdef DEBUG_LAYER
|
#ifdef DEBUG_LAYER
|
||||||
printf("Layer::Draw: ");
|
printf("Layer::Draw: ");
|
||||||
r.PrintToStream();
|
r.PrintToStream();
|
||||||
#endif
|
#endif
|
||||||
/*
|
|
||||||
RGBColor col(152,102,51);
|
|
||||||
fDriver->FillRect(fUpdateReg.Frame(), col);
|
|
||||||
snooze(1000000);
|
|
||||||
*/
|
|
||||||
fDriver->FillRect(r, fLayerData->viewcolor);
|
fDriver->FillRect(r, fLayerData->viewcolor);
|
||||||
|
|
||||||
// empty HOOK function.
|
// empty HOOK function.
|
||||||
@@ -542,20 +631,23 @@ r.PrintToStream();
|
|||||||
|
|
||||||
void Layer::UpdateStart()
|
void Layer::UpdateStart()
|
||||||
{
|
{
|
||||||
// durring update we are not allowed to draw outside the update region.
|
// During updates we only want to draw what's in the update region
|
||||||
// why should we? we only need that region redrawn!
|
|
||||||
fInUpdate = true;
|
fInUpdate = true;
|
||||||
fClipReg = &fUpdateReg;
|
fClipReg = &fUpdateReg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::UpdateEnd()
|
void Layer::UpdateEnd()
|
||||||
{
|
{
|
||||||
// the usual case. Drawing is permited in the whole visible area.
|
// The usual case. Drawing is permitted in the whole visible area.
|
||||||
fInUpdate = false;
|
fInUpdate = false;
|
||||||
fClipReg = &fVisible;
|
fClipReg = &fVisible;
|
||||||
fUpdateReg.MakeEmpty();
|
fUpdateReg.MakeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Shows the layer
|
||||||
|
\param invalidate Invalidate the region when showing the layer. defaults to true
|
||||||
|
*/
|
||||||
void Layer::Show(bool invalidate)
|
void Layer::Show(bool invalidate)
|
||||||
{
|
{
|
||||||
STRACE(("Layer(%s)::Show()\n", GetName()));
|
STRACE(("Layer(%s)::Show()\n", GetName()));
|
||||||
@@ -573,6 +665,10 @@ void Layer::Show(bool invalidate)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Shows the layer
|
||||||
|
\param invalidate Invalidate the region when hiding the layer. defaults to true
|
||||||
|
*/
|
||||||
void Layer::Hide(bool invalidate)
|
void Layer::Hide(bool invalidate)
|
||||||
{
|
{
|
||||||
STRACE(("Layer(%s)::Hide()\n", GetName()));
|
STRACE(("Layer(%s)::Hide()\n", GetName()));
|
||||||
@@ -590,6 +686,7 @@ void Layer::Hide(bool invalidate)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Returns true if the layer is hidden
|
||||||
bool Layer::IsHidden(void) const
|
bool Layer::IsHidden(void) const
|
||||||
{
|
{
|
||||||
if (fHidden)
|
if (fHidden)
|
||||||
@@ -603,6 +700,7 @@ bool Layer::IsHidden(void) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Returns the number of children
|
||||||
uint32 Layer::CountChildren(void) const
|
uint32 Layer::CountChildren(void) const
|
||||||
{
|
{
|
||||||
uint32 i = 0;
|
uint32 i = 0;
|
||||||
@@ -615,7 +713,8 @@ uint32 Layer::CountChildren(void) const
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::RebuildFullRegion( )
|
//! Rebuilds the layer's "completely visible" region
|
||||||
|
void Layer::RebuildFullRegion(void)
|
||||||
{
|
{
|
||||||
STRACE(("Layer(%s)::RebuildFullRegion()\n", GetName()));
|
STRACE(("Layer(%s)::RebuildFullRegion()\n", GetName()));
|
||||||
|
|
||||||
@@ -625,7 +724,9 @@ void Layer::RebuildFullRegion( )
|
|||||||
fFull.Set( fFrame );
|
fFull.Set( fFrame );
|
||||||
|
|
||||||
// TODO: restrict to screen coordinates
|
// TODO: restrict to screen coordinates
|
||||||
// TODO: Convert to screen coordinates!
|
|
||||||
|
// TODO: Convert to screen coordinates
|
||||||
|
|
||||||
LayerData *ld;
|
LayerData *ld;
|
||||||
ld = fLayerData;
|
ld = fLayerData;
|
||||||
do
|
do
|
||||||
@@ -633,6 +734,7 @@ void Layer::RebuildFullRegion( )
|
|||||||
// clip to user region
|
// clip to user region
|
||||||
if(ld->clipReg)
|
if(ld->clipReg)
|
||||||
fFull.IntersectWith( ld->clipReg );
|
fFull.IntersectWith( ld->clipReg );
|
||||||
|
|
||||||
} while( (ld = ld->prevState) );
|
} while( (ld = ld->prevState) );
|
||||||
|
|
||||||
// clip to user picture region
|
// clip to user picture region
|
||||||
@@ -649,8 +751,7 @@ void Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint
|
|||||||
{
|
{
|
||||||
STRACE(("Layer(%s)::RebuildRegions() START\n", GetName()));
|
STRACE(("Layer(%s)::RebuildRegions() START\n", GetName()));
|
||||||
|
|
||||||
//NOTE: this method must be executed as quickly as possible.
|
// TODO:/NOTE: this method must be executed as quickly as possible.
|
||||||
|
|
||||||
|
|
||||||
// Currently SendView[Moved/Resized]Msg() simply constructs a message and calls
|
// Currently SendView[Moved/Resized]Msg() simply constructs a message and calls
|
||||||
// ServerWindow::SendMessageToClient(). This involves the alternative use of
|
// ServerWindow::SendMessageToClient(). This involves the alternative use of
|
||||||
@@ -764,30 +865,33 @@ void Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint
|
|||||||
{
|
{
|
||||||
fFullVisible.MakeEmpty();
|
fFullVisible.MakeEmpty();
|
||||||
fVisible = fFull;
|
fVisible = fFull;
|
||||||
#ifdef DEBUG_LAYER_REBUILD
|
|
||||||
printf("\n ======= Layer(%s):: RR ****** ======\n", GetName());
|
|
||||||
fFull.PrintToStream();
|
|
||||||
fVisible.PrintToStream();
|
|
||||||
printf("\n ======= Layer(%s):: RR ****** END ======\n", GetName());
|
|
||||||
|
|
||||||
if (!fParent)
|
#ifdef DEBUG_LAYER_REBUILD
|
||||||
printf("\t NO parent\n");
|
printf("\n ======= Layer(%s):: RR ****** ======\n", GetName());
|
||||||
else
|
fFull.PrintToStream();
|
||||||
printf("\t VALID Parent: %s.\n", fParent->GetName());
|
fVisible.PrintToStream();
|
||||||
if (!(fVisible.CountRects() > 0))
|
printf("\n ======= Layer(%s):: RR ****** END ======\n", GetName());
|
||||||
printf("\t NO visible area!\n");
|
|
||||||
else
|
|
||||||
printf("\t VALID visble area\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (fParent && fVisible.CountRects() > 0){
|
if (!fParent)
|
||||||
|
printf("\t NO parent\n");
|
||||||
|
else
|
||||||
|
printf("\t VALID Parent: %s.\n", fParent->GetName());
|
||||||
|
if (!(fVisible.CountRects() > 0))
|
||||||
|
printf("\t NO visible area!\n");
|
||||||
|
else
|
||||||
|
printf("\t VALID visble area\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (fParent && fVisible.CountRects() > 0)
|
||||||
|
{
|
||||||
// not the usual case, but support fot this is needed.
|
// not the usual case, but support fot this is needed.
|
||||||
if (fParent->fAdFlags & B_LAYER_CHILDREN_DEPENDANT){
|
if (fParent->fAdFlags & B_LAYER_CHILDREN_DEPENDANT)
|
||||||
#ifdef DEBUG_LAYER_REBUILD
|
{
|
||||||
printf("\n ======= Layer(%s)::B_LAYER_CHILDREN_DEPENDANT Parent ======\n", GetName());
|
#ifdef DEBUG_LAYER_REBUILD
|
||||||
fFull.PrintToStream();
|
printf("\n ======= Layer(%s)::B_LAYER_CHILDREN_DEPENDANT Parent ======\n", GetName());
|
||||||
fVisible.PrintToStream();
|
fFull.PrintToStream();
|
||||||
#endif
|
fVisible.PrintToStream();
|
||||||
|
#endif
|
||||||
|
|
||||||
// because we're skipping one level, we need to do out
|
// because we're skipping one level, we need to do out
|
||||||
// parent business as well.
|
// parent business as well.
|
||||||
@@ -795,40 +899,51 @@ void Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint
|
|||||||
// our visible area is relative to our parent's parent.
|
// our visible area is relative to our parent's parent.
|
||||||
if (fParent->fParent)
|
if (fParent->fParent)
|
||||||
fVisible.IntersectWith(&(fParent->fParent->fVisible));
|
fVisible.IntersectWith(&(fParent->fParent->fVisible));
|
||||||
#ifdef DEBUG_LAYER_REBUILD
|
|
||||||
fVisible.PrintToStream();
|
#ifdef DEBUG_LAYER_REBUILD
|
||||||
#endif
|
fVisible.PrintToStream();
|
||||||
|
#endif
|
||||||
// exclude parent's visible area which could be composed by
|
// exclude parent's visible area which could be composed by
|
||||||
// prior siblings' visible areas.
|
// prior siblings' visible areas.
|
||||||
if (fVisible.CountRects() > 0)
|
if (fVisible.CountRects() > 0)
|
||||||
fVisible.Exclude(&(fParent->fVisible));
|
fVisible.Exclude(&(fParent->fVisible));
|
||||||
#ifdef DEBUG_LAYER_REBUILD
|
|
||||||
fVisible.PrintToStream();
|
#ifdef DEBUG_LAYER_REBUILD
|
||||||
#endif
|
fVisible.PrintToStream();
|
||||||
|
#endif
|
||||||
|
|
||||||
// we have a final visible area. Include it to our parent's one,
|
// we have a final visible area. Include it to our parent's one,
|
||||||
// exclude from parent's parent.
|
// exclude from parent's parent.
|
||||||
if (fVisible.CountRects() > 0){
|
if (fVisible.CountRects() > 0)
|
||||||
|
{
|
||||||
fParent->fFullVisible.Include(&fVisible);
|
fParent->fFullVisible.Include(&fVisible);
|
||||||
#ifdef DEBUG_LAYER_REBUILD
|
|
||||||
fParent->fFullVisible.PrintToStream();
|
#ifdef DEBUG_LAYER_REBUILD
|
||||||
#endif
|
fParent->fFullVisible.PrintToStream();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (fParent->fParent)
|
if (fParent->fParent)
|
||||||
fParent->fParent->fVisible.Exclude(&fVisible);
|
fParent->fParent->fVisible.Exclude(&fVisible);
|
||||||
#ifdef DEBUG_LAYER_REBUILD
|
|
||||||
fParent->fParent->fVisible.PrintToStream();
|
#ifdef DEBUG_LAYER_REBUILD
|
||||||
#endif
|
fParent->fParent->fVisible.PrintToStream();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_LAYER_REBUILD
|
#ifdef DEBUG_LAYER_REBUILD
|
||||||
printf("\n ======= Layer(%s)::B_LAYER_CHILDREN_DEPENDANT Parent END ======\n", GetName());
|
printf("\n ======= Layer(%s)::B_LAYER_CHILDREN_DEPENDANT Parent END ======\n", GetName());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// for 95+% of cases
|
else
|
||||||
else{
|
{
|
||||||
#ifdef DEBUG_LAYER_REBUILD
|
// for 95+% of cases
|
||||||
printf("\n ======= Layer(%s):: (!)B_LAYER_CHILDREN_DEPENDANT Parent ======\n", GetName());
|
|
||||||
#endif
|
#ifdef DEBUG_LAYER_REBUILD
|
||||||
|
printf("\n ======= Layer(%s):: (!)B_LAYER_CHILDREN_DEPENDANT Parent ======\n", GetName());
|
||||||
|
#endif
|
||||||
|
|
||||||
// the visible area is the one common with parent's one.
|
// the visible area is the one common with parent's one.
|
||||||
fVisible.IntersectWith(&(fParent->fVisible));
|
fVisible.IntersectWith(&(fParent->fVisible));
|
||||||
|
|
||||||
// exclude from parent's visible area. we're the owners now.
|
// exclude from parent's visible area. we're the owners now.
|
||||||
if (fVisible.CountRects() > 0)
|
if (fVisible.CountRects() > 0)
|
||||||
fParent->fVisible.Exclude(&fVisible);
|
fParent->fVisible.Exclude(&fVisible);
|
||||||
@@ -1006,6 +1121,7 @@ void Layer::StartRebuildRegions( const BRegion& reg, Layer *target, uint32 actio
|
|||||||
STRACE(("Layer(%s)::StartRebuildRegions() END\n", GetName()));
|
STRACE(("Layer(%s)::StartRebuildRegions() END\n", GetName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Moves the layer by specified values, complete with redraw
|
||||||
void Layer::MoveBy(float x, float y)
|
void Layer::MoveBy(float x, float y)
|
||||||
{
|
{
|
||||||
STRACE(("Layer(%s)::MoveBy() START\n", GetName()));
|
STRACE(("Layer(%s)::MoveBy() START\n", GetName()));
|
||||||
@@ -1106,6 +1222,7 @@ uint32 Layer::ResizeOthers(float x, float y, BPoint coords[], BPoint *ptOffset)
|
|||||||
return 0UL;
|
return 0UL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Resize the layer by the specified amount, complete with redraw
|
||||||
void Layer::ResizeBy(float x, float y)
|
void Layer::ResizeBy(float x, float y)
|
||||||
{
|
{
|
||||||
STRACE(("Layer(%s)::ResizeBy() START\n", GetName()));
|
STRACE(("Layer(%s)::ResizeBy() START\n", GetName()));
|
||||||
@@ -1131,20 +1248,7 @@ void Layer::ResizeBy(float x, float y)
|
|||||||
STRACE(("Layer(%s)::ResizeBy() END\n", GetName()));
|
STRACE(("Layer(%s)::ResizeBy() END\n", GetName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Layer::IsClientLayer() const {
|
//! Prints information about the layer's current state
|
||||||
switch (fClassID){
|
|
||||||
case AS_WINBORDER_CLASS:
|
|
||||||
case AS_ROOTLAYER_CLASS:
|
|
||||||
return false;
|
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Layer::IsServerLayer() const {
|
|
||||||
return !IsClientLayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Layer::PrintToStream(void)
|
void Layer::PrintToStream(void)
|
||||||
{
|
{
|
||||||
printf("\n----------- Layer %s -----------\n",fName->String());
|
printf("\n----------- Layer %s -----------\n",fName->String());
|
||||||
@@ -1169,6 +1273,7 @@ void Layer::PrintToStream(void)
|
|||||||
printf(" NO LayerData valid pointer\n");
|
printf(" NO LayerData valid pointer\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Prints pointer info kept by the current layer
|
||||||
void Layer::PrintNode(void)
|
void Layer::PrintNode(void)
|
||||||
{
|
{
|
||||||
printf("-----------\nLayer %s\n",fName->String());
|
printf("-----------\nLayer %s\n",fName->String());
|
||||||
@@ -1195,6 +1300,7 @@ void Layer::PrintNode(void)
|
|||||||
printf("Visible Areas: "); fVisible.PrintToStream();
|
printf("Visible Areas: "); fVisible.PrintToStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Prints the tree hierarchy from the current layer down
|
||||||
void Layer::PrintTree()
|
void Layer::PrintTree()
|
||||||
{
|
{
|
||||||
printf("\n Tree structure:\n");
|
printf("\n Tree structure:\n");
|
||||||
@@ -1203,11 +1309,13 @@ void Layer::PrintTree()
|
|||||||
printf("\t%s\t%s\n", lay->GetName(), lay->IsHidden()? "Hidden": "NOT hidden");
|
printf("\t%s\t%s\n", lay->GetName(), lay->IsHidden()? "Hidden": "NOT hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Converts the passed rectangle to parent coordinates
|
||||||
BRect Layer::ConvertToParent(BRect rect)
|
BRect Layer::ConvertToParent(BRect rect)
|
||||||
{
|
{
|
||||||
return (rect.OffsetByCopy(fFrame.LeftTop()));
|
return (rect.OffsetByCopy(fFrame.LeftTop()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Converts the passed region to parent coordinates
|
||||||
BRegion Layer::ConvertToParent(BRegion *reg)
|
BRegion Layer::ConvertToParent(BRegion *reg)
|
||||||
{
|
{
|
||||||
BRegion newreg;
|
BRegion newreg;
|
||||||
@@ -1218,11 +1326,13 @@ BRegion Layer::ConvertToParent(BRegion *reg)
|
|||||||
return newreg;
|
return newreg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Converts the passed rectangle from parent coordinates
|
||||||
BRect Layer::ConvertFromParent(BRect rect)
|
BRect Layer::ConvertFromParent(BRect rect)
|
||||||
{
|
{
|
||||||
return (rect.OffsetByCopy(fFrame.left*-1,fFrame.top*-1));
|
return (rect.OffsetByCopy(fFrame.left*-1,fFrame.top*-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Converts the passed region from parent coordinates
|
||||||
BRegion Layer::ConvertFromParent(BRegion *reg)
|
BRegion Layer::ConvertFromParent(BRegion *reg)
|
||||||
{
|
{
|
||||||
BRegion newreg;
|
BRegion newreg;
|
||||||
@@ -1233,6 +1343,7 @@ BRegion Layer::ConvertFromParent(BRegion *reg)
|
|||||||
return newreg;
|
return newreg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Converts the passed region to screen coordinates
|
||||||
BRegion Layer::ConvertToTop(BRegion *reg)
|
BRegion Layer::ConvertToTop(BRegion *reg)
|
||||||
{
|
{
|
||||||
BRegion newreg;
|
BRegion newreg;
|
||||||
@@ -1241,6 +1352,7 @@ BRegion Layer::ConvertToTop(BRegion *reg)
|
|||||||
return newreg;
|
return newreg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Converts the passed rectangle to screen coordinates
|
||||||
BRect Layer::ConvertToTop(BRect rect)
|
BRect Layer::ConvertToTop(BRect rect)
|
||||||
{
|
{
|
||||||
if (fParent!=NULL)
|
if (fParent!=NULL)
|
||||||
@@ -1249,6 +1361,7 @@ BRect Layer::ConvertToTop(BRect rect)
|
|||||||
return(rect);
|
return(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Converts the passed region from screen coordinates
|
||||||
BRegion Layer::ConvertFromTop(BRegion *reg)
|
BRegion Layer::ConvertFromTop(BRegion *reg)
|
||||||
{
|
{
|
||||||
BRegion newreg;
|
BRegion newreg;
|
||||||
@@ -1259,6 +1372,7 @@ BRegion Layer::ConvertFromTop(BRegion *reg)
|
|||||||
return newreg;
|
return newreg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Converts the passed rectangle from screen coordinates
|
||||||
BRect Layer::ConvertFromTop(BRect rect)
|
BRect Layer::ConvertFromTop(BRect rect)
|
||||||
{
|
{
|
||||||
if (fParent!=NULL)
|
if (fParent!=NULL)
|
||||||
@@ -1268,6 +1382,7 @@ BRect Layer::ConvertFromTop(BRect rect)
|
|||||||
return(rect);
|
return(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Sends a B_VIEW_RESIZE message to the client BWindow
|
||||||
void Layer::SendViewResizedMsg()
|
void Layer::SendViewResizedMsg()
|
||||||
{
|
{
|
||||||
if( fServerWin && fFlags & B_FRAME_EVENTS )
|
if( fServerWin && fFlags & B_FRAME_EVENTS )
|
||||||
@@ -1286,6 +1401,7 @@ void Layer::SendViewResizedMsg()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Sends a B_VIEW_MOVED message to the client BWindow
|
||||||
void Layer::SendViewMovedMsg()
|
void Layer::SendViewMovedMsg()
|
||||||
{
|
{
|
||||||
if( fServerWin && fFlags & B_FRAME_EVENTS )
|
if( fServerWin && fFlags & B_FRAME_EVENTS )
|
||||||
@@ -1300,6 +1416,7 @@ void Layer::SendViewMovedMsg()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Sends an _UPDATE_ message to the client BWindow
|
||||||
void Layer::SendUpdateMsg()
|
void Layer::SendUpdateMsg()
|
||||||
{
|
{
|
||||||
if( fServerWin )
|
if( fServerWin )
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ public:
|
|||||||
|
|
||||||
DisplayDriver *GetDisplayDriver(void) const { return fDriver; }
|
DisplayDriver *GetDisplayDriver(void) const { return fDriver; }
|
||||||
ServerWindow *Window(void) const { return fServerWin; }
|
ServerWindow *Window(void) const { return fServerWin; }
|
||||||
bool IsClientLayer() const;
|
virtual bool HasClient(void) { return true; }
|
||||||
bool IsServerLayer() const;
|
bool IsServerLayer() const;
|
||||||
|
|
||||||
void PruneTree(void);
|
void PruneTree(void);
|
||||||
@@ -138,7 +138,6 @@ public:
|
|||||||
|
|
||||||
// server "private" - should not be used
|
// server "private" - should not be used
|
||||||
void SetRootLayer(RootLayer *rl){ fRootLayer = rl; }
|
void SetRootLayer(RootLayer *rl){ fRootLayer = rl; }
|
||||||
void SetServerWindow(ServerWindow *win);
|
|
||||||
void SetAsTopLayer(bool option) { fIsTopLayer = option; }
|
void SetAsTopLayer(bool option) { fIsTopLayer = option; }
|
||||||
bool IsTopLayer() const { return fIsTopLayer; }
|
bool IsTopLayer() const { return fIsTopLayer; }
|
||||||
|
|
||||||
@@ -195,7 +194,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void RequestDraw(const BRegion ®, Layer *startFrom);
|
void RequestDraw(const BRegion ®, Layer *startFrom);
|
||||||
ServerWindow *SearchForServerWindow(void) const;
|
ServerWindow *SearchForServerWindow(void);
|
||||||
|
|
||||||
void Layer::SendUpdateMsg();
|
void Layer::SendUpdateMsg();
|
||||||
void SendViewMovedMsg(void);
|
void SendViewMovedMsg(void);
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ public:
|
|||||||
void SetBGColor(const RGBColor &col);
|
void SetBGColor(const RGBColor &col);
|
||||||
RGBColor BGColor(void) const;
|
RGBColor BGColor(void) const;
|
||||||
|
|
||||||
|
virtual bool HasClient(void) { return false; }
|
||||||
|
|
||||||
void AddWinBorderToWorkspaces(WinBorder *winBorder, uint32 wks);
|
void AddWinBorderToWorkspaces(WinBorder *winBorder, uint32 wks);
|
||||||
|
|
||||||
void PrintToStream(void);
|
void PrintToStream(void);
|
||||||
|
|||||||
@@ -43,8 +43,6 @@
|
|||||||
#include "RootLayer.h"
|
#include "RootLayer.h"
|
||||||
#include "Workspace.h"
|
#include "Workspace.h"
|
||||||
|
|
||||||
// TODO: Document this file completely
|
|
||||||
|
|
||||||
// Toggle general function call output
|
// Toggle general function call output
|
||||||
//#define DEBUG_WINBORDER
|
//#define DEBUG_WINBORDER
|
||||||
|
|
||||||
@@ -129,6 +127,7 @@ WinBorder::~WinBorder(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Rebuilds the WinBorder's "fully-visible" region based on info from the decorator
|
||||||
void WinBorder::RebuildFullRegion(void)
|
void WinBorder::RebuildFullRegion(void)
|
||||||
{
|
{
|
||||||
STRACE(("WinBorder(%s)::RebuildFullRegion()\n",GetName()));
|
STRACE(("WinBorder(%s)::RebuildFullRegion()\n",GetName()));
|
||||||
@@ -140,6 +139,15 @@ void WinBorder::RebuildFullRegion(void)
|
|||||||
fDecorator->GetFootprint(&fFull);
|
fDecorator->GetFootprint(&fFull);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Handles B_MOUSE_DOWN events and takes appropriate actions
|
||||||
|
\param evt PointerEvent object containing the info from the last B_MOUSE_DOWN message
|
||||||
|
\param sendMessage flag to send a B_MOUSE_DOWN message to the client
|
||||||
|
|
||||||
|
This function searches to see if the B_MOUSE_DOWN message is being sent to the window tab
|
||||||
|
or frame. If it is not, the message is passed on to the appropriate view in the client
|
||||||
|
BWindow. If the WinBorder is the target, then the proper action flag is set.
|
||||||
|
*/
|
||||||
void WinBorder::MouseDown(PointerEvent& evt, bool sendMessage)
|
void WinBorder::MouseDown(PointerEvent& evt, bool sendMessage)
|
||||||
{
|
{
|
||||||
if (!(Window()->IsLocked()))
|
if (!(Window()->IsLocked()))
|
||||||
@@ -229,6 +237,14 @@ void WinBorder::MouseDown(PointerEvent& evt, bool sendMessage)
|
|||||||
fLastMousePosition = evt.where;
|
fLastMousePosition = evt.where;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Handles B_MOUSE_MOVED events and takes appropriate actions
|
||||||
|
\param evt PointerEvent object containing the info from the last B_MOUSE_MOVED message
|
||||||
|
|
||||||
|
This function doesn't do much except test continue any move/resize operations in progress
|
||||||
|
or check to see if the user clicked on a tab button (close, zoom, etc.) and then moused
|
||||||
|
away to prevent the operation from occurring
|
||||||
|
*/
|
||||||
void WinBorder::MouseMoved(PointerEvent& evt)
|
void WinBorder::MouseMoved(PointerEvent& evt)
|
||||||
{
|
{
|
||||||
if (!(Window()->IsLocked()))
|
if (!(Window()->IsLocked()))
|
||||||
@@ -272,9 +288,18 @@ void WinBorder::MouseMoved(PointerEvent& evt)
|
|||||||
fDecorator->DrawMinimize();
|
fDecorator->DrawMinimize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fLastMousePosition = evt.where;
|
fLastMousePosition = evt.where;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Handles B_MOUSE_UP events and takes appropriate actions
|
||||||
|
\param evt PointerEvent object containing the info from the last B_MOUSE_UP message
|
||||||
|
|
||||||
|
This function resets any state objects (is_resizing flag and such) and if resetting a
|
||||||
|
button click flag, takes the appropriate action (i.e. clearing the close button flag also
|
||||||
|
takes steps to close the window).
|
||||||
|
*/
|
||||||
void WinBorder::MouseUp(PointerEvent& evt)
|
void WinBorder::MouseUp(PointerEvent& evt)
|
||||||
{
|
{
|
||||||
if (!(Window()->IsLocked()))
|
if (!(Window()->IsLocked()))
|
||||||
@@ -316,12 +341,14 @@ void WinBorder::MouseUp(PointerEvent& evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Sets the decorator focus to active or inactive colors
|
||||||
void WinBorder::HighlightDecorator(const bool &active)
|
void WinBorder::HighlightDecorator(const bool &active)
|
||||||
{
|
{
|
||||||
STRACE(("Decorator->Highlight\n"));
|
STRACE(("Decorator->Highlight\n"));
|
||||||
fDecorator->SetFocus(active);
|
fDecorator->SetFocus(active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! redraws a certain section of the window border
|
||||||
void WinBorder::Draw(const BRect &r)
|
void WinBorder::Draw(const BRect &r)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_WINBORDER
|
#ifdef DEBUG_WINBORDER
|
||||||
@@ -331,34 +358,10 @@ void WinBorder::Draw(const BRect &r)
|
|||||||
|
|
||||||
// if we have a visible region, it is decorator's one.
|
// if we have a visible region, it is decorator's one.
|
||||||
if(fDecorator)
|
if(fDecorator)
|
||||||
{
|
|
||||||
/*
|
|
||||||
//fUpdateReg.PrintToStream();
|
|
||||||
RGBColor c(128, 56, 98);
|
|
||||||
//fDriver->FillRect(r, c);
|
|
||||||
fDriver->FillRect(fUpdateReg.Frame(), c);
|
|
||||||
snooze(1000000);
|
|
||||||
*/
|
|
||||||
fDecorator->Draw(fUpdateReg.Frame());
|
fDecorator->Draw(fUpdateReg.Frame());
|
||||||
}
|
|
||||||
|
|
||||||
// clear background, *only IF* our view color is different to B_TRANSPARENT_COLOR!
|
|
||||||
// TODO: DO That!
|
|
||||||
// TODO: UNcomment
|
|
||||||
// TODO: UPDATE code
|
|
||||||
/*
|
|
||||||
BMessage msg;
|
|
||||||
msg.what = _UPDATE_;
|
|
||||||
msg.AddInt32("_token", fViewToken);
|
|
||||||
msg.AddRect("_rect", ConvertFromTop(reg.Frame()) );
|
|
||||||
|
|
||||||
// for test purposes only!
|
|
||||||
msg.AddRect("_rect2", reg.Frame());
|
|
||||||
|
|
||||||
fServerWin->SendMessageToClient( &msg );
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Moves the winborder with redraw
|
||||||
void WinBorder::MoveBy(float x, float y)
|
void WinBorder::MoveBy(float x, float y)
|
||||||
{
|
{
|
||||||
STRACE(("WinBorder(%s)::MoveBy()\n", GetName()));
|
STRACE(("WinBorder(%s)::MoveBy()\n", GetName()));
|
||||||
@@ -368,8 +371,11 @@ void WinBorder::MoveBy(float x, float y)
|
|||||||
Layer::MoveBy(x,y);
|
Layer::MoveBy(x,y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Resizes the winborder with redraw
|
||||||
void WinBorder::ResizeBy(float x, float y)
|
void WinBorder::ResizeBy(float x, float y)
|
||||||
{
|
{
|
||||||
|
// TODO: account for size limits
|
||||||
|
|
||||||
STRACE(("WinBorder(%s)::ResizeBy()\n", GetName()));
|
STRACE(("WinBorder(%s)::ResizeBy()\n", GetName()));
|
||||||
if(fDecorator)
|
if(fDecorator)
|
||||||
fDecorator->ResizeBy(x,y);
|
fDecorator->ResizeBy(x,y);
|
||||||
@@ -377,6 +383,7 @@ void WinBorder::ResizeBy(float x, float y)
|
|||||||
Layer::ResizeBy(x,y);
|
Layer::ResizeBy(x,y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Returns true if hidden
|
||||||
bool WinBorder::IsHidden() const
|
bool WinBorder::IsHidden() const
|
||||||
{
|
{
|
||||||
if (fServerHidden)
|
if (fServerHidden)
|
||||||
@@ -395,6 +402,7 @@ void WinBorder::ServerUnhide()
|
|||||||
fServerHidden = false;
|
fServerHidden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Sets the minimum and maximum sizes of the window
|
||||||
void WinBorder::SetSizeLimits(float minwidth, float maxwidth, float minheight, float maxheight)
|
void WinBorder::SetSizeLimits(float minwidth, float maxwidth, float minheight, float maxheight)
|
||||||
{
|
{
|
||||||
if(minwidth<0)
|
if(minwidth<0)
|
||||||
@@ -415,6 +423,7 @@ void WinBorder::SetSizeLimits(float minwidth, float maxwidth, float minheight, f
|
|||||||
fMaxHeight=maxheight;
|
fMaxHeight=maxheight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Returns true if the point is in the WinBorder's screen area
|
||||||
bool WinBorder::HasPoint(const BPoint& pt) const
|
bool WinBorder::HasPoint(const BPoint& pt) const
|
||||||
{
|
{
|
||||||
return fFullVisible.Contains(pt);
|
return fFullVisible.Contains(pt);
|
||||||
@@ -425,11 +434,12 @@ void WinBorder::SetMainWinBorder(WinBorder *newMain)
|
|||||||
fMainWinBorder = newMain;
|
fMainWinBorder = newMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
WinBorder* WinBorder::MainWinBorder() const{
|
WinBorder* WinBorder::MainWinBorder() const
|
||||||
|
{
|
||||||
return fMainWinBorder;
|
return fMainWinBorder;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinBorder::SetLevel()
|
void WinBorder::SetLevel(void)
|
||||||
{
|
{
|
||||||
switch(fServerWin->Feel())
|
switch(fServerWin->Feel())
|
||||||
{
|
{
|
||||||
@@ -470,6 +480,7 @@ void WinBorder::SetLevel()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Makes the calling WinBorder a subset window of another
|
||||||
void WinBorder::AddToSubsetOf(WinBorder* main)
|
void WinBorder::AddToSubsetOf(WinBorder* main)
|
||||||
{
|
{
|
||||||
STRACE(("WinBorder(%s)::AddToSubsetOf()\n", GetName()));
|
STRACE(("WinBorder(%s)::AddToSubsetOf()\n", GetName()));
|
||||||
@@ -532,6 +543,7 @@ void WinBorder::AddToSubsetOf(WinBorder* main)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Removes the calling WinBorder from the subset window of another
|
||||||
void WinBorder::RemoveFromSubsetOf(WinBorder* main)
|
void WinBorder::RemoveFromSubsetOf(WinBorder* main)
|
||||||
{
|
{
|
||||||
STRACE(("WinBorder(%s)::RemoveFromSubsetOf()\n", GetName()));
|
STRACE(("WinBorder(%s)::RemoveFromSubsetOf()\n", GetName()));
|
||||||
@@ -539,6 +551,7 @@ void WinBorder::RemoveFromSubsetOf(WinBorder* main)
|
|||||||
|
|
||||||
desktop->fGeneralLock.Lock();
|
desktop->fGeneralLock.Lock();
|
||||||
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - General lock acquired\n", GetName(), main->GetName()));
|
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - General lock acquired\n", GetName(), main->GetName()));
|
||||||
|
|
||||||
rl->fMainLock.Lock();
|
rl->fMainLock.Lock();
|
||||||
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - Main lock acquired\n", GetName(), main->GetName()));
|
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - Main lock acquired\n", GetName(), main->GetName()));
|
||||||
|
|
||||||
@@ -563,10 +576,11 @@ void WinBorder::RemoveFromSubsetOf(WinBorder* main)
|
|||||||
rl->fMainLock.Unlock();
|
rl->fMainLock.Unlock();
|
||||||
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - Main lock released\n", GetName(), main->GetName()));
|
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - Main lock released\n", GetName(), main->GetName()));
|
||||||
|
|
||||||
desktop->fGeneralLock.Unlock();
|
desktop->fGeneralLock.Unlock();
|
||||||
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - General lock released\n", GetName(), main->GetName()));
|
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - General lock released\n", GetName(), main->GetName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Prints information about the WinBorder's current state
|
||||||
void WinBorder::PrintToStream()
|
void WinBorder::PrintToStream()
|
||||||
{
|
{
|
||||||
printf("\t%s", GetName());
|
printf("\t%s", GetName());
|
||||||
@@ -595,21 +609,25 @@ void WinBorder::PrintToStream()
|
|||||||
printf("\t%s\n", IsHidden() ? "hidden" : "not hidden");
|
printf("\t%s\n", IsHidden() ? "hidden" : "not hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unimplemented. Hook function for handling when system GUI colors change
|
||||||
void WinBorder::UpdateColors(void)
|
void WinBorder::UpdateColors(void)
|
||||||
{
|
{
|
||||||
STRACE(("WinBorder %s: UpdateColors unimplemented\n",GetName()));
|
STRACE(("WinBorder %s: UpdateColors unimplemented\n",GetName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unimplemented. Hook function for handling when the system decorator changes
|
||||||
void WinBorder::UpdateDecorator(void)
|
void WinBorder::UpdateDecorator(void)
|
||||||
{
|
{
|
||||||
STRACE(("WinBorder %s: UpdateDecorator unimplemented\n",GetName()));
|
STRACE(("WinBorder %s: UpdateDecorator unimplemented\n",GetName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unimplemented. Hook function for handling when a system font changes
|
||||||
void WinBorder::UpdateFont(void)
|
void WinBorder::UpdateFont(void)
|
||||||
{
|
{
|
||||||
STRACE(("WinBorder %s: UpdateFont unimplemented\n",GetName()));
|
STRACE(("WinBorder %s: UpdateFont unimplemented\n",GetName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unimplemented. Hook function for handling when the screen resolution changes
|
||||||
void WinBorder::UpdateScreen(void)
|
void WinBorder::UpdateScreen(void)
|
||||||
{
|
{
|
||||||
STRACE(("WinBorder %s: UpdateScreen unimplemented\n",GetName()));
|
STRACE(("WinBorder %s: UpdateScreen unimplemented\n",GetName()));
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ public:
|
|||||||
void UpdateFont(void);
|
void UpdateFont(void);
|
||||||
void UpdateScreen(void);
|
void UpdateScreen(void);
|
||||||
|
|
||||||
|
virtual bool HasClient(void) { return false; }
|
||||||
Decorator *GetDecorator(void) const { return fDecorator; }
|
Decorator *GetDecorator(void) const { return fDecorator; }
|
||||||
WinBorder *MainWinBorder() const;
|
WinBorder *MainWinBorder() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user