2004-09-21 02:50:02 +04:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Copyright (c) 2001-2002, Haiku, Inc.
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
//
|
|
|
|
// File Name: Layer.cpp
|
|
|
|
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
// Adi Oanca <adioanca@myrealbox.com>
|
|
|
|
// Description: Class used for rendering to the frame buffer. One layer per
|
|
|
|
// view on screen and also for window decorators
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
2003-02-07 15:53:57 +03:00
|
|
|
#include <View.h>
|
2003-09-25 16:25:13 +04:00
|
|
|
#include <Message.h>
|
|
|
|
#include <AppDefs.h>
|
2004-01-13 03:56:36 +03:00
|
|
|
#include <Region.h>
|
2003-02-07 15:53:57 +03:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2004-02-24 15:02:47 +03:00
|
|
|
#include <stdlib.h>
|
2003-01-24 18:19:27 +03:00
|
|
|
#include "Layer.h"
|
2003-02-07 15:53:57 +03:00
|
|
|
#include "ServerWindow.h"
|
2004-03-28 19:01:27 +04:00
|
|
|
#include "WinBorder.h"
|
2003-11-14 03:15:29 +03:00
|
|
|
#include "RGBColor.h"
|
2004-03-28 19:01:27 +04:00
|
|
|
#include "RootLayer.h"
|
2004-02-24 15:02:47 +03:00
|
|
|
#include "DisplayDriver.h"
|
|
|
|
#include "LayerData.h"
|
2005-01-23 02:25:41 +03:00
|
|
|
#include "PortLink.h"
|
|
|
|
#include "ServerProtocol.h"
|
2003-02-07 15:53:57 +03:00
|
|
|
|
2004-06-18 15:50:17 +04:00
|
|
|
//#define DEBUG_LAYER
|
2003-09-25 16:25:13 +04:00
|
|
|
#ifdef DEBUG_LAYER
|
|
|
|
# define STRACE(x) printf x
|
|
|
|
#else
|
|
|
|
# define STRACE(x) ;
|
|
|
|
#endif
|
|
|
|
|
2005-03-17 20:41:00 +03:00
|
|
|
//#define DEBUG_LAYER_REBUILD
|
2004-06-03 00:44:46 +04:00
|
|
|
#ifdef DEBUG_LAYER_REBUILD
|
|
|
|
# define RBTRACE(x) printf x
|
|
|
|
#else
|
|
|
|
# define RBTRACE(x) ;
|
|
|
|
#endif
|
|
|
|
|
2005-01-23 00:51:39 +03:00
|
|
|
enum {
|
|
|
|
B_LAYER_ACTION_NONE = 0,
|
|
|
|
B_LAYER_ACTION_MOVE,
|
|
|
|
B_LAYER_ACTION_RESIZE
|
|
|
|
};
|
|
|
|
|
2003-09-25 21:25:14 +04:00
|
|
|
Layer::Layer(BRect frame, const char *name, int32 token, uint32 resize,
|
2004-02-24 15:02:47 +03:00
|
|
|
uint32 flags, DisplayDriver *driver)
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
// frame is in fParent coordinates
|
2003-01-24 18:19:27 +03:00
|
|
|
if(frame.IsValid())
|
2004-06-11 22:21:57 +04:00
|
|
|
fFrame = frame;
|
2003-01-24 18:19:27 +03:00
|
|
|
else
|
2003-11-14 03:15:29 +03:00
|
|
|
// TODO: Decorator class should have a method witch returns the minimum frame width.
|
2004-06-11 22:21:57 +04:00
|
|
|
fFrame.Set(0.0f, 0.0f, 5.0f, 5.0f);
|
2003-09-15 23:11:52 +04:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
fBoundsLeftTop.Set( 0.0f, 0.0f );
|
2003-01-24 18:19:27 +03:00
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
fName = new BString(name ? name : B_EMPTY_STRING);
|
2004-06-11 22:21:57 +04:00
|
|
|
fLayerData = new LayerData();
|
2004-02-24 15:02:47 +03:00
|
|
|
|
|
|
|
// driver init
|
|
|
|
if (!driver)
|
|
|
|
debugger("You MUST have a valid driver to init a Layer object\n");
|
|
|
|
fDriver = driver;
|
2003-09-17 23:28:31 +04:00
|
|
|
|
2003-01-24 18:19:27 +03:00
|
|
|
// Layer does not start out as a part of the tree
|
2005-03-21 23:29:24 +03:00
|
|
|
fOwner = NULL;
|
2004-06-16 10:40:26 +04:00
|
|
|
fParent = NULL;
|
|
|
|
fUpperSibling = NULL;
|
|
|
|
fLowerSibling = NULL;
|
|
|
|
fTopChild = NULL;
|
|
|
|
fBottomChild = NULL;
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
fCurrent = NULL;
|
|
|
|
fRootLayer = NULL;
|
2004-02-24 15:02:47 +03:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
fFlags = flags;
|
|
|
|
fAdFlags = 0;
|
2004-07-05 19:23:29 +04:00
|
|
|
fClassID = AS_LAYER_CLASS;
|
2005-01-23 00:51:39 +03:00
|
|
|
fFrameAction = B_LAYER_ACTION_NONE;
|
2004-06-16 10:40:26 +04:00
|
|
|
fResizeMode = resize;
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2005-03-21 23:29:24 +03:00
|
|
|
fHidden = false;
|
|
|
|
fEventMask = 0UL;
|
|
|
|
fEventOptions = 0UL;
|
2004-06-16 10:40:26 +04:00
|
|
|
fIsTopLayer = false;
|
2005-02-28 23:23:51 +03:00
|
|
|
fLevel = -100;
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
fViewToken = token;
|
2004-06-11 22:21:57 +04:00
|
|
|
fServerWin = NULL;
|
|
|
|
clipToPicture = NULL;
|
|
|
|
|
|
|
|
// NOW all regions (fVisible, fFullVisible, fFull) are empty
|
2004-07-06 00:37:13 +04:00
|
|
|
fClipReg = &fVisible;
|
2004-06-03 00:44:46 +04:00
|
|
|
STRACE(("Layer(%s) successfuly created\n", GetName()));
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2003-02-07 15:53:57 +03:00
|
|
|
//! Destructor frees all allocated heap space
|
2003-01-24 18:19:27 +03:00
|
|
|
Layer::~Layer(void)
|
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
if(fLayerData)
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
delete fLayerData;
|
|
|
|
fLayerData = NULL;
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2005-03-13 20:07:40 +03:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
if(fName)
|
2004-02-24 15:02:47 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
delete fName;
|
|
|
|
fName = NULL;
|
2004-02-24 15:02:47 +03:00
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
// TODO: uncomment!
|
2004-02-24 15:02:47 +03:00
|
|
|
//PruneTree();
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
// fServerWin->RemoveChild(fDriver);
|
2004-02-24 15:02:47 +03:00
|
|
|
// delete fDriver;
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2003-11-14 03:15:29 +03:00
|
|
|
if (clipToPicture)
|
|
|
|
{
|
|
|
|
delete clipToPicture;
|
|
|
|
clipToPicture = NULL;
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
// TODO: allocate and release a ServerPicture Object.
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
/*!
|
|
|
|
\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.
|
|
|
|
*/
|
2004-06-16 10:40:26 +04:00
|
|
|
void Layer::AddChild(Layer *layer, ServerWindow *serverWin)
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
STRACE(("Layer(%s)::AddChild(%s) START\n", GetName(), layer->GetName()));
|
|
|
|
|
|
|
|
if( layer->fParent != NULL )
|
|
|
|
{
|
|
|
|
printf("ERROR: AddChild(): Layer already has a parent\n");
|
2003-01-24 18:19:27 +03:00
|
|
|
return;
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
// 1) attach layer to the tree structure
|
2004-06-11 22:21:57 +04:00
|
|
|
layer->fParent = this;
|
2004-09-09 04:54:21 +04:00
|
|
|
|
|
|
|
// if we have children already, bump the current front child back one and
|
|
|
|
// make the new child the frontmost layer
|
2004-06-11 22:21:57 +04:00
|
|
|
if( fBottomChild )
|
|
|
|
{
|
|
|
|
layer->fUpperSibling = fBottomChild;
|
|
|
|
fBottomChild->fLowerSibling = layer;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
fTopChild = layer;
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
fBottomChild = layer;
|
2003-11-14 03:15:29 +03:00
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
// if we have no RootLayer yet, then there is no need to set any parameters --
|
|
|
|
// they will be set when the RootLayer for this tree will be added
|
2004-06-16 10:40:26 +04:00
|
|
|
// to the main tree structure.
|
2004-09-09 04:54:21 +04:00
|
|
|
if (!fRootLayer)
|
|
|
|
{
|
2004-06-17 18:39:21 +04:00
|
|
|
STRACE(("Layer(%s)::AddChild(%s) END\n", GetName(), layer->GetName()));
|
2004-06-16 10:40:26 +04:00
|
|
|
return;
|
2004-06-17 18:39:21 +04:00
|
|
|
}
|
2003-11-14 03:15:29 +03:00
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
// 2) Iterate over the newly-added layer and all its children, setting the
|
|
|
|
// root layer and server window and also rebuilding the full-size region
|
|
|
|
// for every descendant of the newly-added layer
|
|
|
|
|
|
|
|
//c = short for: current
|
|
|
|
Layer *c = layer;
|
|
|
|
Layer *stop = layer;
|
|
|
|
while( true )
|
|
|
|
{
|
2004-06-16 10:40:26 +04:00
|
|
|
// action block
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
// 2.1) set the RootLayer for this object.
|
|
|
|
c->SetRootLayer(c->fParent->fRootLayer);
|
|
|
|
|
|
|
|
// 2.2) this Layer must know if it has a ServerWindow object attached.
|
2005-02-28 23:23:51 +03:00
|
|
|
c->fServerWin=serverWin;
|
2004-09-09 04:54:21 +04:00
|
|
|
|
|
|
|
// 2.3) we are attached to the main tree so build our full region.
|
|
|
|
c->RebuildFullRegion();
|
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
// tree parsing algorithm
|
2004-09-09 04:54:21 +04:00
|
|
|
if( c->fTopChild )
|
|
|
|
{
|
|
|
|
// go deep
|
2004-06-16 10:40:26 +04:00
|
|
|
c = c->fTopChild;
|
|
|
|
}
|
2004-09-09 04:54:21 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// go right or up
|
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
if (c == stop) // out trip is over
|
|
|
|
break;
|
2004-09-09 04:54:21 +04:00
|
|
|
|
|
|
|
if( c->fLowerSibling )
|
|
|
|
{
|
|
|
|
// go right
|
2004-06-16 10:40:26 +04:00
|
|
|
c = c->fLowerSibling;
|
2004-02-24 15:02:47 +03:00
|
|
|
}
|
2004-09-09 04:54:21 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// go up
|
2004-06-16 10:40:26 +04:00
|
|
|
while( !c->fParent->fLowerSibling && c->fParent != stop )
|
|
|
|
c = c->fParent;
|
2004-09-09 04:54:21 +04:00
|
|
|
|
|
|
|
if( c->fParent == stop ) // that's enough!
|
2004-06-16 10:40:26 +04:00
|
|
|
break;
|
2004-09-09 04:54:21 +04:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
c = c->fParent->fLowerSibling;
|
2004-06-11 22:21:57 +04:00
|
|
|
}
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
|
|
|
}
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
STRACE(("Layer(%s)::AddChild(%s) END\n", GetName(), layer->GetName()));
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
/*!
|
|
|
|
\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
|
|
|
|
*/
|
2003-11-14 03:15:29 +03:00
|
|
|
void Layer::RemoveChild(Layer *layer)
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
STRACE(("Layer(%s)::RemoveChild(%s) START\n", GetName(), layer->GetName()));
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
if(!layer->fParent)
|
2004-06-11 22:21:57 +04:00
|
|
|
{
|
|
|
|
printf("ERROR: RemoveChild(): Layer doesn't have a fParent\n");
|
2003-01-24 18:19:27 +03:00
|
|
|
return;
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
if(layer->fParent != this)
|
2004-06-11 22:21:57 +04:00
|
|
|
{
|
2004-01-13 03:56:36 +03:00
|
|
|
printf("ERROR: RemoveChild(): Layer is not a child of this layer\n");
|
2003-01-24 18:19:27 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
// 1) remove this layer from the main tree.
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
// Take care of fParent
|
2004-09-09 04:54:21 +04:00
|
|
|
layer->fParent = NULL;
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
if( fTopChild == layer )
|
2004-09-09 04:54:21 +04:00
|
|
|
fTopChild = layer->fLowerSibling;
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
if( fBottomChild == layer )
|
2004-09-09 04:54:21 +04:00
|
|
|
fBottomChild = layer->fUpperSibling;
|
|
|
|
|
2003-01-24 18:19:27 +03:00
|
|
|
// Take care of siblings
|
2004-06-11 22:21:57 +04:00
|
|
|
if( layer->fUpperSibling != NULL )
|
|
|
|
layer->fUpperSibling->fLowerSibling = layer->fLowerSibling;
|
2004-09-09 04:54:21 +04:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
if( layer->fLowerSibling != NULL )
|
|
|
|
layer->fLowerSibling->fUpperSibling = layer->fUpperSibling;
|
2004-09-09 04:54:21 +04:00
|
|
|
|
|
|
|
layer->fUpperSibling = NULL;
|
|
|
|
layer->fLowerSibling = NULL;
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
// 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 )
|
|
|
|
{
|
2004-06-16 10:40:26 +04:00
|
|
|
// action block
|
2004-06-11 22:21:57 +04:00
|
|
|
{
|
2004-06-16 10:40:26 +04:00
|
|
|
// 2.1) set the RootLayer for this object.
|
|
|
|
c->SetRootLayer(NULL);
|
|
|
|
// 2.2) this Layer must know if it has a ServerWindow object attached.
|
2005-02-28 23:23:51 +03:00
|
|
|
c->fServerWin=NULL;
|
2004-06-16 10:40:26 +04:00
|
|
|
// 2.3) we were removed from the main tree so clear our full region.
|
|
|
|
c->fFull.MakeEmpty();
|
|
|
|
// 2.4) clear fullVisible region.
|
|
|
|
c->fFullVisible.MakeEmpty();
|
|
|
|
// 2.5) we don't have a visible region anymore.
|
|
|
|
c->fVisible.MakeEmpty();
|
|
|
|
}
|
2003-11-14 03:15:29 +03:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
// tree parsing algorithm
|
2004-09-09 04:54:21 +04:00
|
|
|
if( c->fTopChild )
|
|
|
|
{
|
|
|
|
// go deep
|
2004-06-16 10:40:26 +04:00
|
|
|
c = c->fTopChild;
|
|
|
|
}
|
2004-09-09 04:54:21 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// go right or up
|
2004-06-16 10:40:26 +04:00
|
|
|
if (c == stop) // out trip is over
|
|
|
|
break;
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
if( c->fLowerSibling )
|
|
|
|
{
|
|
|
|
// go right
|
2004-06-16 10:40:26 +04:00
|
|
|
c = c->fLowerSibling;
|
2004-02-24 15:02:47 +03:00
|
|
|
}
|
2004-09-09 04:54:21 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// go up
|
2004-06-16 10:40:26 +04:00
|
|
|
while( !c->fParent->fLowerSibling && c->fParent != stop )
|
|
|
|
c = c->fParent;
|
2004-09-09 04:54:21 +04:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
if( c->fParent == stop ) // that enough!
|
|
|
|
break;
|
2004-09-09 04:54:21 +04:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
c = c->fParent->fLowerSibling;
|
2004-06-11 22:21:57 +04:00
|
|
|
}
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
}
|
2004-09-09 04:54:21 +04:00
|
|
|
STRACE(("Layer(%s)::RemoveChild(%s) END\n", GetName(), layer->GetName()));
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Removes the calling layer from the tree
|
2003-11-14 03:15:29 +03:00
|
|
|
void Layer::RemoveSelf()
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2003-02-07 15:53:57 +03:00
|
|
|
// A Layer removes itself from the tree (duh)
|
2004-06-11 22:21:57 +04:00
|
|
|
if( fParent == NULL )
|
|
|
|
{
|
|
|
|
printf("ERROR: RemoveSelf(): Layer doesn't have a fParent\n");
|
2003-01-24 18:19:27 +03:00
|
|
|
return;
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
fParent->RemoveChild(this);
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
/*!
|
|
|
|
\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
|
|
|
|
*/
|
2004-06-11 22:21:57 +04:00
|
|
|
bool Layer::HasChild(Layer* layer)
|
|
|
|
{
|
|
|
|
for(Layer *lay = VirtualTopChild(); lay; lay = VirtualLowerSibling())
|
|
|
|
{
|
2004-01-13 03:56:36 +03:00
|
|
|
if(lay == layer)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2004-01-12 01:12:55 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
/*!
|
|
|
|
\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
|
|
|
|
*/
|
2004-01-13 03:56:36 +03:00
|
|
|
Layer* Layer::LayerAt(const BPoint &pt)
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
if (fVisible.Contains(pt))
|
2003-11-14 03:15:29 +03:00
|
|
|
return this;
|
2005-03-13 20:07:40 +03:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
if (fFullVisible.Contains(pt))
|
|
|
|
{
|
|
|
|
Layer *lay = NULL;
|
|
|
|
for ( Layer* child = VirtualBottomChild(); child; child = VirtualUpperSibling() )
|
|
|
|
{
|
|
|
|
lay = child->LayerAt( pt );
|
|
|
|
if (lay)
|
2003-11-14 03:15:29 +03:00
|
|
|
return lay;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2003-02-07 15:53:57 +03:00
|
|
|
return NULL;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Matches the BView call of the same name
|
2003-11-14 03:15:29 +03:00
|
|
|
BRect Layer::Bounds(void) const
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
BRect r(fFrame);
|
|
|
|
r.OffsetTo( fBoundsLeftTop );
|
2003-11-14 03:15:29 +03:00
|
|
|
return r;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Matches the BView call of the same name
|
2003-11-14 03:15:29 +03:00
|
|
|
BRect Layer::Frame(void) const
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
return fFrame;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Recursively deletes all children of the calling layer
|
2003-01-24 18:19:27 +03:00
|
|
|
void Layer::PruneTree(void)
|
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
Layer *lay;
|
|
|
|
Layer *nextlay;
|
|
|
|
|
|
|
|
lay = fTopChild;
|
|
|
|
fTopChild = NULL;
|
2003-01-24 18:19:27 +03:00
|
|
|
|
2003-11-14 03:15:29 +03:00
|
|
|
while(lay != NULL)
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
if(lay->fTopChild != NULL)
|
2003-01-24 18:19:27 +03:00
|
|
|
lay->PruneTree();
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
nextlay = lay->fLowerSibling;
|
|
|
|
lay->fLowerSibling = NULL;
|
|
|
|
|
2003-01-24 18:19:27 +03:00
|
|
|
delete lay;
|
2004-06-11 22:21:57 +04:00
|
|
|
lay = nextlay;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
// Man, this thing is short. Elegant, ain't it? :P
|
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
/*!
|
|
|
|
\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
|
|
|
|
*/
|
2004-06-11 22:21:57 +04:00
|
|
|
Layer *Layer::FindLayer(const int32 token)
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2003-02-07 15:53:57 +03:00
|
|
|
// recursive search for a layer based on its view token
|
2004-06-11 22:21:57 +04:00
|
|
|
Layer *lay;
|
|
|
|
Layer *trylay;
|
|
|
|
|
2003-01-24 18:19:27 +03:00
|
|
|
// Search child layers first
|
2004-02-24 15:02:47 +03:00
|
|
|
for(lay = VirtualTopChild(); lay; lay = VirtualLowerSibling())
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
if(lay->fViewToken == token)
|
2003-01-24 18:19:27 +03:00
|
|
|
return lay;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hmmm... not in this layer's children. Try lower descendants
|
2004-02-24 15:02:47 +03:00
|
|
|
for(lay = VirtualTopChild(); lay != NULL; lay = VirtualLowerSibling())
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
trylay = lay->FindLayer(token);
|
2003-01-24 18:19:27 +03:00
|
|
|
if(trylay)
|
|
|
|
return trylay;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Well, we got this far in the function, so apparently there is no match to be found
|
2003-02-07 15:53:57 +03:00
|
|
|
return NULL;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
/*!
|
|
|
|
\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()
|
2004-06-11 22:21:57 +04:00
|
|
|
{
|
2004-09-09 04:54:21 +04:00
|
|
|
if(!fServerWin)
|
|
|
|
fServerWin=fParent->SearchForServerWindow();
|
|
|
|
|
|
|
|
return fServerWin;
|
2003-09-17 23:28:31 +04:00
|
|
|
}
|
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
void Layer::FullInvalidate(const BRect &rect)
|
|
|
|
{
|
|
|
|
FullInvalidate( BRegion(rect) );
|
|
|
|
}
|
2003-11-14 03:15:29 +03:00
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
void Layer::FullInvalidate(const BRegion& region)
|
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
STRACE(("Layer(%s)::FullInvalidate():\n", GetName()));
|
2004-09-09 04:54:21 +04:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
#ifdef DEBUG_LAYER
|
2004-06-26 06:15:48 +04:00
|
|
|
region.PrintToStream();
|
|
|
|
printf("\n");
|
2004-06-11 22:21:57 +04:00
|
|
|
#endif
|
2003-11-14 03:15:29 +03:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
BPoint pt(0,0);
|
2004-02-24 15:02:47 +03:00
|
|
|
StartRebuildRegions(region, NULL,/* B_LAYER_INVALIDATE, pt); */B_LAYER_NONE, pt);
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2005-01-24 20:18:19 +03:00
|
|
|
Redraw(fRootLayer->fRedrawReg);
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
EmptyGlobals();
|
|
|
|
}
|
2003-11-14 03:15:29 +03:00
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
void Layer::Invalidate(const BRegion& region)
|
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
STRACE(("Layer(%s)::Invalidate():\n", GetName()));
|
|
|
|
#ifdef DEBUG_LAYER
|
2004-06-26 06:15:48 +04:00
|
|
|
region.PrintToStream();
|
|
|
|
printf("\n");
|
2004-06-11 22:21:57 +04:00
|
|
|
#endif
|
|
|
|
|
2005-01-24 20:18:19 +03:00
|
|
|
fRootLayer->fRedrawReg = region;
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2005-01-24 20:18:19 +03:00
|
|
|
Redraw(fRootLayer->fRedrawReg);
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
EmptyGlobals();
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
void Layer::Redraw(const BRegion& reg, Layer *startFrom)
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
STRACE(("Layer(%s)::Redraw();\n", GetName()));
|
2004-06-16 10:40:26 +04:00
|
|
|
if (IsHidden())
|
|
|
|
// this layer has nothing visible on screen, so bail out.
|
|
|
|
return;
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
BRegion *pReg = const_cast<BRegion*>(®);
|
2004-02-24 15:02:47 +03:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
if (pReg->CountRects() > 0)
|
|
|
|
RequestDraw(reg, startFrom);
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2004-06-17 18:39:21 +04:00
|
|
|
STRACE(("Layer(%s)::Redraw() ENDED\n", GetName()));
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
void Layer::RequestDraw(const BRegion ®, Layer *startFrom)
|
2004-06-11 22:21:57 +04:00
|
|
|
{
|
2004-06-16 10:40:26 +04:00
|
|
|
STRACE(("Layer(%s)::RequestDraw()\n", GetName()));
|
2003-11-14 03:15:29 +03:00
|
|
|
|
2004-07-05 19:23:29 +04:00
|
|
|
// do not redraw any child until you must
|
2004-06-16 10:40:26 +04:00
|
|
|
int redraw = false;
|
2004-09-09 04:54:21 +04:00
|
|
|
if (!startFrom)
|
2004-06-16 10:40:26 +04:00
|
|
|
redraw = true;
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2005-03-31 20:48:51 +04:00
|
|
|
if (HasClient() && IsTopLayer())
|
2004-06-11 22:21:57 +04:00
|
|
|
{
|
2005-03-31 20:48:51 +04:00
|
|
|
// calculate the minimum region/rectangle to be updated with
|
|
|
|
// a single message to the client.
|
2005-04-06 00:03:07 +04:00
|
|
|
BRegion updateReg(fFullVisible);
|
2005-03-31 20:48:51 +04:00
|
|
|
if (fFlags & B_FULL_UPDATE_ON_RESIZE
|
|
|
|
&& fFrameAction == B_LAYER_ACTION_RESIZE)
|
|
|
|
{
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-04-06 00:03:07 +04:00
|
|
|
updateReg.IntersectWith(®);
|
2005-03-31 20:48:51 +04:00
|
|
|
}
|
2005-04-06 00:03:07 +04:00
|
|
|
if (updateReg.CountRects() > 0)
|
2004-07-05 19:23:29 +04:00
|
|
|
{
|
2005-04-06 00:03:07 +04:00
|
|
|
fOwner->zUpdateReg.Include(&updateReg);
|
2005-04-07 00:56:46 +04:00
|
|
|
if (!fOwner->fInUpdate && !fOwner->fRequestSent)
|
2004-07-05 19:23:29 +04:00
|
|
|
{
|
2005-04-06 00:03:07 +04:00
|
|
|
fOwner->fUpdateReg = fOwner->zUpdateReg;
|
2005-04-07 00:56:46 +04:00
|
|
|
fOwner->cnt++;
|
|
|
|
if (fOwner->cnt != 1)
|
|
|
|
debugger("Adi: Not Allowed!");
|
2005-04-06 00:03:07 +04:00
|
|
|
fOwner->zUpdateReg.MakeEmpty();
|
|
|
|
SendUpdateMsg(fOwner->fUpdateReg);
|
2005-04-07 00:56:46 +04:00
|
|
|
fOwner->fRequestSent = true;
|
2004-07-05 19:23:29 +04:00
|
|
|
}
|
2005-03-31 20:48:51 +04:00
|
|
|
}
|
|
|
|
}
|
2004-07-05 19:23:29 +04:00
|
|
|
|
2005-03-31 20:48:51 +04:00
|
|
|
if (fVisible.CountRects() > 0)
|
|
|
|
{
|
2005-04-06 00:03:07 +04:00
|
|
|
BRegion updateReg(fVisible);
|
|
|
|
// calculate the update region
|
|
|
|
if (fFlags & B_FULL_UPDATE_ON_RESIZE
|
|
|
|
&& fFrameAction == B_LAYER_ACTION_RESIZE)
|
2005-03-31 20:48:51 +04:00
|
|
|
{
|
2005-04-06 00:03:07 +04:00
|
|
|
// do nothing
|
2004-07-05 19:23:29 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-04-06 00:03:07 +04:00
|
|
|
updateReg.IntersectWith(®);
|
|
|
|
}
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2005-04-06 00:03:07 +04:00
|
|
|
if (updateReg.CountRects() > 0)
|
|
|
|
{
|
|
|
|
fDriver->ConstrainClippingRegion(&updateReg);
|
|
|
|
Draw(updateReg.Frame());
|
|
|
|
fDriver->ConstrainClippingRegion(NULL);
|
2004-02-24 15:02:47 +03:00
|
|
|
}
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
for (Layer *lay = VirtualBottomChild(); lay != NULL; lay = VirtualUpperSibling())
|
2004-06-11 22:21:57 +04:00
|
|
|
{
|
2004-06-16 10:40:26 +04:00
|
|
|
if (lay == startFrom)
|
|
|
|
redraw = true;
|
|
|
|
|
|
|
|
if (redraw && !(lay->IsHidden()))
|
2004-06-18 23:13:06 +04:00
|
|
|
{
|
|
|
|
// no need to go deeper if not even the FullVisible region intersects
|
|
|
|
// Update one.
|
2004-09-09 04:54:21 +04:00
|
|
|
|
2004-06-18 23:13:06 +04:00
|
|
|
BRegion common(lay->fFullVisible);
|
|
|
|
common.IntersectWith(®);
|
2004-09-09 04:54:21 +04:00
|
|
|
|
|
|
|
if (common.CountRects() > 0)
|
2004-06-18 23:13:06 +04:00
|
|
|
lay->RequestDraw(reg, NULL);
|
|
|
|
}
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2003-03-31 01:09:39 +04:00
|
|
|
}
|
|
|
|
|
2003-11-14 03:15:29 +03:00
|
|
|
void Layer::Draw(const BRect &r)
|
2003-03-31 01:09:39 +04:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
// TODO/NOTE: this should be an empty method! the next lines are for testing only
|
2004-07-30 19:16:59 +04:00
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
#ifdef DEBUG_LAYER
|
2005-04-06 00:03:07 +04:00
|
|
|
printf("Layer(%s)::Draw: ", GetName());
|
2004-09-09 04:54:21 +04:00
|
|
|
r.PrintToStream();
|
|
|
|
#endif
|
|
|
|
|
2005-03-13 20:07:40 +03:00
|
|
|
fDriver->FillRect(r, fLayerData->viewcolor);
|
|
|
|
// RGBColor c(rand()%255,rand()%255,rand()%255);
|
|
|
|
// fDriver->FillRect(r, c);
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2003-11-14 03:15:29 +03:00
|
|
|
// empty HOOK function.
|
2003-03-31 01:09:39 +04:00
|
|
|
}
|
|
|
|
|
2004-07-06 00:37:13 +04:00
|
|
|
void Layer::UpdateStart()
|
|
|
|
{
|
2004-09-09 04:54:21 +04:00
|
|
|
// During updates we only want to draw what's in the update region
|
2005-03-31 00:06:50 +04:00
|
|
|
if (fClassID == AS_WINBORDER_CLASS)
|
|
|
|
{
|
2005-03-31 02:13:26 +04:00
|
|
|
// NOTE: don't worry, RooLayer is locked here.
|
2005-03-31 00:06:50 +04:00
|
|
|
WinBorder *wb = (WinBorder*)this;
|
2005-04-06 00:03:07 +04:00
|
|
|
|
|
|
|
wb->fInUpdate = true;
|
2005-04-07 00:56:46 +04:00
|
|
|
wb->fRequestSent = false;
|
2005-04-06 00:03:07 +04:00
|
|
|
wb->yUpdateReg = wb->fUpdateReg;
|
|
|
|
wb->fUpdateReg.MakeEmpty();
|
2005-04-07 00:56:46 +04:00
|
|
|
wb->cnt--;
|
|
|
|
if (wb->cnt != 0)
|
|
|
|
debugger("Adi2: Not Allowed!");
|
2005-03-31 00:06:50 +04:00
|
|
|
}
|
2004-07-06 00:37:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Layer::UpdateEnd()
|
|
|
|
{
|
2004-09-09 04:54:21 +04:00
|
|
|
// The usual case. Drawing is permitted in the whole visible area.
|
2005-03-31 00:06:50 +04:00
|
|
|
if (fClassID == AS_WINBORDER_CLASS)
|
|
|
|
{
|
|
|
|
WinBorder *wb = (WinBorder*)this;
|
2005-04-06 00:03:07 +04:00
|
|
|
|
2005-03-31 00:06:50 +04:00
|
|
|
wb->yUpdateReg.MakeEmpty();
|
2005-04-06 00:03:07 +04:00
|
|
|
|
|
|
|
wb->fInUpdate = false;
|
|
|
|
|
2005-03-31 02:13:26 +04:00
|
|
|
if (wb->zUpdateReg.CountRects() > 0)
|
|
|
|
{
|
2005-03-31 20:48:51 +04:00
|
|
|
BRegion reg(wb->zUpdateReg);
|
|
|
|
wb->RequestDraw(reg, NULL);
|
2005-03-31 02:13:26 +04:00
|
|
|
}
|
2005-03-31 00:06:50 +04:00
|
|
|
}
|
2004-07-06 00:37:13 +04:00
|
|
|
}
|
2004-02-24 15:02:47 +03:00
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
/*!
|
|
|
|
\brief Shows the layer
|
|
|
|
\param invalidate Invalidate the region when showing the layer. defaults to true
|
|
|
|
*/
|
2004-06-11 22:21:57 +04:00
|
|
|
void Layer::Show(bool invalidate)
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
STRACE(("Layer(%s)::Show()\n", GetName()));
|
2004-02-24 15:02:47 +03:00
|
|
|
if( !IsHidden() )
|
2003-03-31 01:09:39 +04:00
|
|
|
return;
|
2003-09-09 01:18:39 +04:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
fHidden = false;
|
|
|
|
|
|
|
|
if(invalidate)
|
2005-01-22 23:51:12 +03:00
|
|
|
GetRootLayer()->GoInvalidate(this, fFull);
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
/*!
|
|
|
|
\brief Shows the layer
|
|
|
|
\param invalidate Invalidate the region when hiding the layer. defaults to true
|
|
|
|
*/
|
2004-06-11 22:21:57 +04:00
|
|
|
void Layer::Hide(bool invalidate)
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
STRACE(("Layer(%s)::Hide()\n", GetName()));
|
2004-02-24 15:02:47 +03:00
|
|
|
if ( IsHidden() )
|
2003-09-09 01:18:39 +04:00
|
|
|
return;
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
fHidden = true;
|
|
|
|
|
|
|
|
if(invalidate)
|
2005-01-22 23:51:12 +03:00
|
|
|
GetRootLayer()->GoInvalidate(this, fFullVisible);
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Returns true if the layer is hidden
|
2003-11-14 03:15:29 +03:00
|
|
|
bool Layer::IsHidden(void) const
|
2003-02-24 18:47:06 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
if (fHidden)
|
2004-02-24 15:02:47 +03:00
|
|
|
return true;
|
|
|
|
else
|
2004-06-11 22:21:57 +04:00
|
|
|
{
|
|
|
|
if (fParent)
|
|
|
|
return fParent->IsHidden();
|
|
|
|
}
|
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
return false;
|
2003-02-24 18:47:06 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Returns the number of children
|
2003-11-14 03:15:29 +03:00
|
|
|
uint32 Layer::CountChildren(void) const
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
uint32 i = 0;
|
|
|
|
Layer *lay = VirtualTopChild();
|
2004-02-24 15:02:47 +03:00
|
|
|
while(lay != NULL)
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
lay = VirtualLowerSibling();
|
2003-01-24 18:19:27 +03:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Rebuilds the layer's "completely visible" region
|
|
|
|
void Layer::RebuildFullRegion(void)
|
2004-06-11 22:21:57 +04:00
|
|
|
{
|
|
|
|
STRACE(("Layer(%s)::RebuildFullRegion()\n", GetName()));
|
|
|
|
|
|
|
|
if (fParent)
|
2005-02-28 23:23:51 +03:00
|
|
|
fFull.Set(fParent->ConvertToTop(fFrame ));
|
2004-02-24 15:02:47 +03:00
|
|
|
else
|
2005-02-28 23:23:51 +03:00
|
|
|
fFull.Set(fFrame);
|
2005-04-06 00:03:07 +04:00
|
|
|
|
2004-06-26 06:15:48 +04:00
|
|
|
// TODO: restrict to screen coordinates
|
2004-09-09 04:54:21 +04:00
|
|
|
|
|
|
|
// TODO: Convert to screen coordinates
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
LayerData *ld;
|
|
|
|
ld = fLayerData;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
// clip to user region
|
2004-05-20 05:31:28 +04:00
|
|
|
if(ld->clipReg)
|
2004-06-11 22:21:57 +04:00
|
|
|
fFull.IntersectWith( ld->clipReg );
|
2004-09-09 04:54:21 +04:00
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
} while( (ld = ld->prevState) );
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
// clip to user picture region
|
2004-03-28 19:01:27 +04:00
|
|
|
if(clipToPicture)
|
2004-06-11 22:21:57 +04:00
|
|
|
{
|
|
|
|
if(clipToPictureInverse)
|
|
|
|
fFull.Exclude( clipToPicture );
|
|
|
|
else
|
|
|
|
fFull.IntersectWith( clipToPicture );
|
|
|
|
}
|
2004-02-24 15:02:47 +03:00
|
|
|
}
|
2003-09-04 01:43:09 +04:00
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
void Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOffset)
|
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
STRACE(("Layer(%s)::RebuildRegions() START\n", GetName()));
|
2005-03-17 20:41:00 +03:00
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
// TODO:/NOTE: this method must be executed as quickly as possible.
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
// Currently SendView[Moved/Resized]Msg() simply constructs a message and calls
|
2004-06-11 22:21:57 +04:00
|
|
|
// ServerWindow::SendMessageToClient(). This involves the alternative use of
|
|
|
|
// kernel and this code in the CPU, so there are a lot of context switches.
|
|
|
|
// This is NOT good at all!
|
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
// One alternative would be the use of a BMessageQueue per ServerWindows OR only
|
2004-06-11 22:21:57 +04:00
|
|
|
// one for app_server which will be emptied as soon as this critical operation ended.
|
2004-02-24 15:02:47 +03:00
|
|
|
// Talk to DW, Gabe.
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
BRegion oldRegion;
|
|
|
|
uint32 newAction = action;
|
|
|
|
BPoint newPt = pt;
|
|
|
|
BPoint newOffset = ptOffset; // used for resizing only
|
|
|
|
|
|
|
|
BPoint dummyNewLocation;
|
2004-02-24 15:02:47 +03:00
|
|
|
|
|
|
|
RRLabel1:
|
2004-06-11 22:21:57 +04:00
|
|
|
switch(action)
|
|
|
|
{
|
|
|
|
case B_LAYER_NONE:
|
|
|
|
{
|
2005-03-14 23:59:00 +03:00
|
|
|
RBTRACE(("1) Layer(%s): Action B_LAYER_NONE\n", GetName()));
|
2004-06-11 22:21:57 +04:00
|
|
|
oldRegion = fVisible;
|
2004-02-24 15:02:47 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
case B_LAYER_MOVE:
|
|
|
|
{
|
2005-03-14 23:59:00 +03:00
|
|
|
RBTRACE(("1) Layer(%s): Action B_LAYER_MOVE\n", GetName()));
|
2004-06-11 22:21:57 +04:00
|
|
|
oldRegion = fFullVisible;
|
|
|
|
fFrame.OffsetBy(pt.x, pt.y);
|
|
|
|
fFull.OffsetBy(pt.x, pt.y);
|
|
|
|
|
|
|
|
// TODO: uncomment later when you'll implement a queue in ServerWindow::SendMessgeToClient()
|
2004-02-24 15:02:47 +03:00
|
|
|
//SendViewMovedMsg();
|
|
|
|
|
|
|
|
newAction = B_LAYER_SIMPLE_MOVE;
|
|
|
|
break;
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
case B_LAYER_SIMPLE_MOVE:
|
|
|
|
{
|
2005-03-14 23:59:00 +03:00
|
|
|
RBTRACE(("1) Layer(%s): Action B_LAYER_SIMPLE_MOVE\n", GetName()));
|
2004-06-11 22:21:57 +04:00
|
|
|
fFull.OffsetBy(pt.x, pt.y);
|
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
case B_LAYER_RESIZE:
|
|
|
|
{
|
2005-03-14 23:59:00 +03:00
|
|
|
RBTRACE(("1) Layer(%s): Action B_LAYER_RESIZE\n", GetName()));
|
2004-06-11 22:21:57 +04:00
|
|
|
oldRegion = fVisible;
|
|
|
|
|
|
|
|
fFrame.right += pt.x;
|
|
|
|
fFrame.bottom += pt.y;
|
2004-02-24 15:02:47 +03:00
|
|
|
RebuildFullRegion();
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
// TODO: uncomment later when you'll implement a queue in ServerWindow::SendMessgeToClient()
|
2004-02-24 15:02:47 +03:00
|
|
|
//SendViewResizedMsg();
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
newAction = B_LAYER_MASK_RESIZE;
|
2004-02-24 15:02:47 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
case B_LAYER_MASK_RESIZE:
|
|
|
|
{
|
2005-03-14 23:59:00 +03:00
|
|
|
RBTRACE(("1) Layer(%s): Action B_LAYER_MASK_RESIZE\n", GetName()));
|
2004-06-11 22:21:57 +04:00
|
|
|
oldRegion = fVisible;
|
|
|
|
|
|
|
|
BPoint offset, rSize;
|
|
|
|
BPoint coords[2];
|
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
ResizeOthers(pt.x, pt.y, coords, NULL);
|
2004-06-11 22:21:57 +04:00
|
|
|
offset = coords[0];
|
|
|
|
rSize = coords[1];
|
|
|
|
newOffset = offset + ptOffset;
|
|
|
|
|
|
|
|
if(!(rSize.x == 0.0f && rSize.y == 0.0f))
|
|
|
|
{
|
|
|
|
fFrame.OffsetBy(offset);
|
|
|
|
fFrame.right += rSize.x;
|
|
|
|
fFrame.bottom += rSize.y;
|
2004-02-24 15:02:47 +03:00
|
|
|
RebuildFullRegion();
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
// TODO: uncomment later when you'll implement a queue in ServerWindow::SendMessgeToClient()
|
2004-02-24 15:02:47 +03:00
|
|
|
//SendViewResizedMsg();
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
newAction = B_LAYER_MASK_RESIZE;
|
|
|
|
newPt = rSize;
|
2004-02-24 15:02:47 +03:00
|
|
|
dummyNewLocation = newOffset;
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!(offset.x == 0.0f && offset.y == 0.0f))
|
|
|
|
{
|
|
|
|
pt = newOffset;
|
|
|
|
action = B_LAYER_MOVE;
|
|
|
|
newPt = pt;
|
|
|
|
goto RRLabel1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pt = ptOffset;
|
|
|
|
action = B_LAYER_MOVE;
|
|
|
|
newPt = pt;
|
|
|
|
goto RRLabel1;
|
|
|
|
}
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2004-02-24 15:02:47 +03:00
|
|
|
break;
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
|
|
|
}
|
2004-02-24 15:02:47 +03:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
if (!IsHidden())
|
|
|
|
{
|
2004-09-09 04:54:21 +04:00
|
|
|
#ifdef DEBUG_LAYER_REBUILD
|
2005-03-14 23:59:00 +03:00
|
|
|
printf("Layer(%s) real action START\n", GetName());
|
2004-09-09 04:54:21 +04:00
|
|
|
fFull.PrintToStream();
|
|
|
|
#endif
|
2005-03-17 20:41:00 +03:00
|
|
|
fFullVisible.MakeEmpty();
|
|
|
|
fVisible = fFull;
|
2004-09-09 04:54:21 +04:00
|
|
|
|
|
|
|
if (fParent && fVisible.CountRects() > 0)
|
|
|
|
{
|
2004-06-16 10:40:26 +04:00
|
|
|
// not the usual case, but support fot this is needed.
|
2004-09-09 04:54:21 +04:00
|
|
|
if (fParent->fAdFlags & B_LAYER_CHILDREN_DEPENDANT)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_LAYER_REBUILD
|
2005-03-14 23:59:00 +03:00
|
|
|
printf(" B_LAYER_CHILDREN_DEPENDANT Parent\n");
|
2004-09-09 04:54:21 +04:00
|
|
|
#endif
|
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
// because we're skipping one level, we need to do out
|
|
|
|
// parent business as well.
|
2004-09-09 04:54:21 +04:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
// our visible area is relative to our parent's parent.
|
|
|
|
if (fParent->fParent)
|
|
|
|
fVisible.IntersectWith(&(fParent->fParent->fVisible));
|
2004-09-09 04:54:21 +04:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
// exclude parent's visible area which could be composed by
|
|
|
|
// prior siblings' visible areas.
|
|
|
|
if (fVisible.CountRects() > 0)
|
|
|
|
fVisible.Exclude(&(fParent->fVisible));
|
2004-09-09 04:54:21 +04:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
// we have a final visible area. Include it to our parent's one,
|
|
|
|
// exclude from parent's parent.
|
2004-09-09 04:54:21 +04:00
|
|
|
if (fVisible.CountRects() > 0)
|
|
|
|
{
|
2004-06-16 10:40:26 +04:00
|
|
|
fParent->fFullVisible.Include(&fVisible);
|
2004-09-09 04:54:21 +04:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
if (fParent->fParent)
|
|
|
|
fParent->fParent->fVisible.Exclude(&fVisible);
|
|
|
|
}
|
|
|
|
}
|
2004-09-09 04:54:21 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// for 95+% of cases
|
|
|
|
|
|
|
|
#ifdef DEBUG_LAYER_REBUILD
|
2005-03-14 23:59:00 +03:00
|
|
|
printf(" (!)B_LAYER_CHILDREN_DEPENDANT Parent\n");
|
2004-09-09 04:54:21 +04:00
|
|
|
#endif
|
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
// the visible area is the one common with parent's one.
|
|
|
|
fVisible.IntersectWith(&(fParent->fVisible));
|
2004-09-09 04:54:21 +04:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
// exclude from parent's visible area. we're the owners now.
|
|
|
|
if (fVisible.CountRects() > 0)
|
|
|
|
fParent->fVisible.Exclude(&fVisible);
|
|
|
|
}
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
fFullVisible = fVisible;
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
// Rebuild regions for children...
|
2004-02-24 15:02:47 +03:00
|
|
|
for(Layer *lay = VirtualBottomChild(); lay != NULL; lay = VirtualUpperSibling())
|
2004-06-11 22:21:57 +04:00
|
|
|
lay->RebuildRegions(reg, newAction, newPt, newOffset);
|
2005-03-14 23:59:00 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG_LAYER_REBUILD
|
|
|
|
printf("\nLayer(%s) ALMOST done regions:\n", GetName());
|
|
|
|
printf("\tVisible Region:\n");
|
|
|
|
fVisible.PrintToStream();
|
|
|
|
printf("\tFull Visible Region:\n");
|
|
|
|
fFullVisible.PrintToStream();
|
|
|
|
#endif
|
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
if(!IsHidden())
|
2004-06-11 22:21:57 +04:00
|
|
|
{
|
|
|
|
switch(action)
|
|
|
|
{
|
|
|
|
case B_LAYER_NONE:
|
|
|
|
{
|
2005-03-14 23:59:00 +03:00
|
|
|
RBTRACE(("2) Layer(%s): Action B_LAYER_NONE\n", GetName()));
|
2004-06-11 22:21:57 +04:00
|
|
|
BRegion r(fVisible);
|
|
|
|
if (oldRegion.CountRects() > 0)
|
|
|
|
r.Exclude(&oldRegion);
|
|
|
|
|
|
|
|
if(r.CountRects() > 0)
|
2005-01-24 20:18:19 +03:00
|
|
|
fRootLayer->fRedrawReg.Include(&r);
|
2004-06-11 22:21:57 +04:00
|
|
|
break;
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
case B_LAYER_MOVE:
|
|
|
|
{
|
2005-03-14 23:59:00 +03:00
|
|
|
RBTRACE(("2) Layer(%s): Action B_LAYER_MOVE\n", GetName()));
|
2004-06-11 22:21:57 +04:00
|
|
|
BRegion redrawReg;
|
|
|
|
BRegion *copyReg = new BRegion();
|
|
|
|
BRegion screenReg(fRootLayer->Bounds());
|
|
|
|
|
|
|
|
oldRegion.OffsetBy(pt.x, pt.y);
|
|
|
|
oldRegion.IntersectWith(&fFullVisible);
|
|
|
|
|
|
|
|
*copyReg = oldRegion;
|
|
|
|
copyReg->IntersectWith(&screenReg);
|
|
|
|
if(copyReg->CountRects() > 0 && !(pt.x == 0.0f && pt.y == 0.0f) )
|
|
|
|
{
|
|
|
|
copyReg->OffsetBy(-pt.x, -pt.y);
|
|
|
|
BPoint *point = new BPoint(pt);
|
2005-01-24 20:18:19 +03:00
|
|
|
fRootLayer->fCopyRegList.AddItem(copyReg);
|
|
|
|
fRootLayer->fCopyList.AddItem(point);
|
2004-06-11 22:21:57 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delete copyReg;
|
|
|
|
}
|
|
|
|
|
|
|
|
redrawReg = fFullVisible;
|
|
|
|
redrawReg.Exclude(&oldRegion);
|
|
|
|
if(redrawReg.CountRects() > 0 && !(pt.x == 0.0f && pt.y == 0.0f) )
|
|
|
|
{
|
2005-01-24 20:18:19 +03:00
|
|
|
fRootLayer->fRedrawReg.Include(&redrawReg);
|
2004-06-11 22:21:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2003-07-05 20:03:54 +04:00
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
case B_LAYER_RESIZE:
|
|
|
|
{
|
2005-03-14 23:59:00 +03:00
|
|
|
RBTRACE(("2) Layer(%s): Action B_LAYER_RESIZE\n", GetName()));
|
2004-06-11 22:21:57 +04:00
|
|
|
BRegion redrawReg;
|
|
|
|
|
|
|
|
redrawReg = fVisible;
|
|
|
|
redrawReg.Exclude(&oldRegion);
|
|
|
|
if(redrawReg.CountRects() > 0)
|
2005-01-24 20:18:19 +03:00
|
|
|
fRootLayer->fRedrawReg.Include(&redrawReg);
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
break;
|
2004-02-24 15:02:47 +03:00
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
case B_LAYER_MASK_RESIZE:
|
2003-11-14 03:15:29 +03:00
|
|
|
{
|
2005-03-14 23:59:00 +03:00
|
|
|
RBTRACE(("2) Layer(%s): Action B_LAYER_MASK_RESIZE\n", GetName()));
|
2004-06-11 22:21:57 +04:00
|
|
|
BRegion redrawReg;
|
|
|
|
BRegion *copyReg = new BRegion();
|
|
|
|
|
|
|
|
oldRegion.OffsetBy(dummyNewLocation.x, dummyNewLocation.y);
|
|
|
|
|
|
|
|
redrawReg = fVisible;
|
|
|
|
redrawReg.Exclude(&oldRegion);
|
|
|
|
if(redrawReg.CountRects() > 0)
|
|
|
|
{
|
2005-01-24 20:18:19 +03:00
|
|
|
fRootLayer->fRedrawReg.Include(&redrawReg);
|
2004-06-11 22:21:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
*copyReg = fVisible;
|
|
|
|
copyReg->IntersectWith(&oldRegion);
|
|
|
|
copyReg->OffsetBy(-dummyNewLocation.x, -dummyNewLocation.y);
|
|
|
|
if(copyReg->CountRects() > 0
|
|
|
|
&& !(dummyNewLocation.x == 0.0f && dummyNewLocation.y == 0.0f))
|
|
|
|
{
|
2005-01-24 20:18:19 +03:00
|
|
|
fRootLayer->fCopyRegList.AddItem(copyReg);
|
|
|
|
fRootLayer->fCopyList.AddItem(new BPoint(dummyNewLocation));
|
2004-06-11 22:21:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
default:
|
2004-02-24 15:02:47 +03:00
|
|
|
{
|
2005-03-14 23:59:00 +03:00
|
|
|
RBTRACE(("2) Layer(%s): Action default\n", GetName()));
|
2004-06-11 22:21:57 +04:00
|
|
|
break;
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2004-02-24 15:02:47 +03:00
|
|
|
}
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
/* if (IsHidden())
|
|
|
|
{
|
|
|
|
fFullVisible.MakeEmpty();
|
|
|
|
fVisible.MakeEmpty();
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
STRACE(("Layer(%s)::RebuildRegions() END\n", GetName()));
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
void Layer::StartRebuildRegions( const BRegion& reg, Layer *target, uint32 action, BPoint& pt)
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
STRACE(("Layer(%s)::StartRebuildRegions() START\n", GetName()));
|
2005-03-14 23:59:00 +03:00
|
|
|
RBTRACE(("\n\nLayer(%s)::StartRebuildRegions() START\n", GetName()));
|
2004-06-11 22:21:57 +04:00
|
|
|
if(!fParent)
|
|
|
|
fFullVisible = fFull;
|
|
|
|
|
|
|
|
BRegion oldVisible = fVisible;
|
|
|
|
|
|
|
|
fVisible = fFullVisible;
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
// Rebuild regions for children...
|
2005-02-28 23:23:51 +03:00
|
|
|
for(Layer *lay = VirtualBottomChild(); lay; lay = VirtualUpperSibling())
|
2003-01-24 18:19:27 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
if (lay == target)
|
2004-02-24 15:02:47 +03:00
|
|
|
lay->RebuildRegions(reg, action, pt, BPoint(0.0f, 0.0f));
|
2004-06-11 22:21:57 +04:00
|
|
|
else
|
2004-02-24 15:02:47 +03:00
|
|
|
lay->RebuildRegions(reg, B_LAYER_NONE, pt, BPoint(0.0f, 0.0f));
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_LAYER_REBUILD
|
2005-03-14 23:59:00 +03:00
|
|
|
printf("\nSRR: Layer(%s) ALMOST done regions:\n", GetName());
|
|
|
|
printf("\tVisible Region:\n");
|
|
|
|
fVisible.PrintToStream();
|
|
|
|
printf("\tFull Visible Region:\n");
|
|
|
|
fFullVisible.PrintToStream();
|
2004-06-11 22:21:57 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
BRegion redrawReg(fVisible);
|
|
|
|
|
|
|
|
// if this is the first time
|
|
|
|
if (oldVisible.CountRects() > 0)
|
2004-02-24 15:02:47 +03:00
|
|
|
redrawReg.Exclude(&oldVisible);
|
2004-06-16 10:40:26 +04:00
|
|
|
|
|
|
|
if (redrawReg.CountRects() > 0)
|
2005-01-24 20:18:19 +03:00
|
|
|
fRootLayer->fRedrawReg.Include(&redrawReg);
|
2004-06-03 00:44:46 +04:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
#ifdef DEBUG_LAYER_REBUILD
|
2005-03-14 23:59:00 +03:00
|
|
|
printf("\nLayer(%s)::StartRebuildRegions() DONE. Results:\n", GetName());
|
|
|
|
printf("\tRedraw Region:\n");
|
|
|
|
fRootLayer->fRedrawReg.PrintToStream();
|
|
|
|
printf("\tCopy Region:\n");
|
|
|
|
for(int32 k=0; k<fRootLayer->fCopyRegList.CountItems(); k++)
|
|
|
|
{
|
|
|
|
((BRegion*)(fRootLayer->fCopyRegList.ItemAt(k)))->PrintToStream();
|
|
|
|
((BPoint*)(fRootLayer->fCopyList.ItemAt(k)))->PrintToStream();
|
|
|
|
}
|
|
|
|
printf("\n");
|
2004-06-11 22:21:57 +04:00
|
|
|
#endif
|
2004-02-24 15:02:47 +03:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
STRACE(("Layer(%s)::StartRebuildRegions() END\n", GetName()));
|
2005-03-14 23:59:00 +03:00
|
|
|
RBTRACE(("Layer(%s)::StartRebuildRegions() END\n", GetName()));
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Moves the layer by specified values, complete with redraw
|
2004-02-24 15:02:47 +03:00
|
|
|
void Layer::MoveBy(float x, float y)
|
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
STRACE(("Layer(%s)::MoveBy() START\n", GetName()));
|
|
|
|
if(!fParent)
|
|
|
|
{
|
2004-02-24 15:02:47 +03:00
|
|
|
debugger("ERROR: in Layer::MoveBy()! - No parent!\n");
|
2003-11-14 03:15:29 +03:00
|
|
|
return;
|
|
|
|
}
|
2005-01-23 00:51:39 +03:00
|
|
|
|
2005-01-23 02:25:41 +03:00
|
|
|
BPortLink msg(-1, -1);
|
|
|
|
msg.StartMessage(AS_ROOTLAYER_LAYER_MOVE);
|
|
|
|
msg.Attach<Layer*>(this);
|
|
|
|
msg.Attach<float>(x);
|
|
|
|
msg.Attach<float>(y);
|
|
|
|
GetRootLayer()->EnqueueMessage(msg);
|
|
|
|
|
|
|
|
STRACE(("Layer(%s)::MoveBy() END\n", GetName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Layer::move_layer(float x, float y)
|
|
|
|
{
|
2005-01-23 00:51:39 +03:00
|
|
|
fFrameAction = B_LAYER_ACTION_MOVE;
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
BPoint pt(x,y);
|
|
|
|
BRect rect(fFull.Frame().OffsetByCopy(pt));
|
2005-03-31 20:48:51 +04:00
|
|
|
if (fClassID == AS_WINBORDER_CLASS)
|
|
|
|
{
|
|
|
|
WinBorder *wb = (WinBorder*)this;
|
2005-04-06 00:03:07 +04:00
|
|
|
wb->zUpdateReg.OffsetBy(x, y);
|
|
|
|
wb->yUpdateReg.OffsetBy(x, y);
|
|
|
|
wb->fUpdateReg.OffsetBy(x, y);
|
2005-03-31 20:48:51 +04:00
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
fParent->StartRebuildRegions(BRegion(rect), this, B_LAYER_MOVE, pt);
|
2005-03-30 20:05:05 +04:00
|
|
|
fDriver->CopyRegionList(&fRootLayer->fCopyRegList,
|
|
|
|
&fRootLayer->fCopyList,
|
|
|
|
fRootLayer->fCopyRegList.CountItems(),
|
|
|
|
&fFullVisible);
|
2005-01-24 20:18:19 +03:00
|
|
|
fParent->Redraw(fRootLayer->fRedrawReg, this);
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
EmptyGlobals();
|
2005-01-23 00:51:39 +03:00
|
|
|
|
|
|
|
fFrameAction = B_LAYER_ACTION_NONE;
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
void Layer::EmptyGlobals()
|
|
|
|
{
|
|
|
|
void *item;
|
|
|
|
|
2005-01-24 20:18:19 +03:00
|
|
|
fRootLayer->fRedrawReg.MakeEmpty();
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2005-01-24 20:18:19 +03:00
|
|
|
while((item = fRootLayer->fCopyRegList.RemoveItem((int32)0)))
|
2004-02-24 15:02:47 +03:00
|
|
|
delete (BRegion*)item;
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2005-01-24 20:18:19 +03:00
|
|
|
while((item = fRootLayer->fCopyList.RemoveItem((int32)0)))
|
2004-02-24 15:02:47 +03:00
|
|
|
delete (BPoint*)item;
|
|
|
|
}
|
2003-11-14 03:15:29 +03:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
uint32 Layer::ResizeOthers(float x, float y, BPoint coords[], BPoint *ptOffset)
|
|
|
|
{
|
|
|
|
STRACE(("Layer(%s)::ResizeOthers() START\n", GetName()));
|
|
|
|
uint32 rmask = fResizeMode;
|
|
|
|
|
|
|
|
// offset
|
|
|
|
coords[0].x = 0.0f;
|
|
|
|
coords[0].y = 0.0f;
|
|
|
|
|
|
|
|
// resize by width/height
|
|
|
|
coords[1].x = 0.0f;
|
|
|
|
coords[1].y = 0.0f;
|
2004-02-24 15:02:47 +03:00
|
|
|
|
|
|
|
if ((rmask & 0x00000f00UL)>>8 == _VIEW_LEFT_
|
2004-06-11 22:21:57 +04:00
|
|
|
&& (rmask & 0x0000000fUL)>>0 == _VIEW_RIGHT_)
|
|
|
|
{
|
2004-02-24 15:02:47 +03:00
|
|
|
coords[1].x = x;
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
else
|
|
|
|
if ((rmask & 0x00000f00UL)>>8 == _VIEW_LEFT_)
|
|
|
|
{
|
2004-02-24 15:02:47 +03:00
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
else
|
|
|
|
if ((rmask & 0x0000000fUL)>>0 == _VIEW_RIGHT_)
|
|
|
|
{
|
2004-02-24 15:02:47 +03:00
|
|
|
coords[0].x = x;
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
else
|
|
|
|
if ((rmask & 0x00000f00UL)>>8 == _VIEW_CENTER_)
|
|
|
|
{
|
2004-02-24 15:02:47 +03:00
|
|
|
coords[0].x = x/2;
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// illegal flag. Do nothing.
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
|
|
|
|
if ((rmask & 0x0000f000UL)>>12 == _VIEW_TOP_
|
2004-06-11 22:21:57 +04:00
|
|
|
&& (rmask & 0x000000f0UL)>>4 == _VIEW_BOTTOM_)
|
|
|
|
{
|
2004-02-24 15:02:47 +03:00
|
|
|
coords[1].y = y;
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
else
|
|
|
|
if ((rmask & 0x0000f000UL)>>12 == _VIEW_TOP_)
|
|
|
|
{
|
2004-02-24 15:02:47 +03:00
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
else
|
|
|
|
if ((rmask & 0x000000f0UL)>>4 == _VIEW_BOTTOM_)
|
|
|
|
{
|
2004-02-24 15:02:47 +03:00
|
|
|
coords[0].y = y;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
else
|
|
|
|
if ((rmask & 0x0000f000UL)>>12 == _VIEW_CENTER_)
|
|
|
|
{
|
2004-02-24 15:02:47 +03:00
|
|
|
coords[0].y = y/2;
|
|
|
|
}
|
2004-06-11 22:21:57 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// illegal flag. Do nothing.
|
2004-02-24 15:02:47 +03:00
|
|
|
}
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
STRACE(("Layer(%s)::ResizeOthers() END\n", GetName()));
|
2004-02-24 15:02:47 +03:00
|
|
|
return 0UL;
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Resize the layer by the specified amount, complete with redraw
|
2004-02-24 15:02:47 +03:00
|
|
|
void Layer::ResizeBy(float x, float y)
|
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
STRACE(("Layer(%s)::ResizeBy() START\n", GetName()));
|
|
|
|
|
|
|
|
if(!fParent)
|
|
|
|
{
|
2004-02-24 15:02:47 +03:00
|
|
|
printf("ERROR: in Layer::MoveBy()! - No parent!\n");
|
|
|
|
return;
|
2004-01-13 03:56:36 +03:00
|
|
|
}
|
2005-01-23 00:51:39 +03:00
|
|
|
|
2005-01-23 02:25:41 +03:00
|
|
|
BPortLink msg(-1, -1);
|
|
|
|
msg.StartMessage(AS_ROOTLAYER_LAYER_RESIZE);
|
|
|
|
msg.Attach<Layer*>(this);
|
|
|
|
msg.Attach<float>(x);
|
|
|
|
msg.Attach<float>(y);
|
|
|
|
GetRootLayer()->EnqueueMessage(msg);
|
|
|
|
|
|
|
|
STRACE(("Layer(%s)::ResizeBy() END\n", GetName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Layer::resize_layer(float x, float y)
|
|
|
|
{
|
2005-01-23 00:51:39 +03:00
|
|
|
fFrameAction = B_LAYER_ACTION_RESIZE;
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
BPoint pt(x,y);
|
|
|
|
BRect rect(fFull.Frame());
|
|
|
|
rect.right += x;
|
|
|
|
rect.bottom += y;
|
|
|
|
|
|
|
|
fParent->StartRebuildRegions(BRegion(rect), this, B_LAYER_RESIZE, pt);
|
|
|
|
|
2005-01-24 20:18:19 +03:00
|
|
|
fDriver->CopyRegionList(&fRootLayer->fCopyRegList, &fRootLayer->fCopyList, fRootLayer->fCopyRegList.CountItems(), &fFullVisible);
|
|
|
|
fParent->Redraw(fRootLayer->fRedrawReg, this);
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2004-02-24 15:02:47 +03:00
|
|
|
EmptyGlobals();
|
2005-01-23 00:51:39 +03:00
|
|
|
|
|
|
|
fFrameAction = B_LAYER_ACTION_NONE;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Prints information about the layer's current state
|
2003-01-24 18:19:27 +03:00
|
|
|
void Layer::PrintToStream(void)
|
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
printf("\n----------- Layer %s -----------\n",fName->String());
|
|
|
|
printf("\t Parent: %s\n", fParent? fParent->GetName():"NULL");
|
2004-04-03 19:08:09 +04:00
|
|
|
printf("\t us: %s\t ls: %s\n",
|
2004-06-11 22:21:57 +04:00
|
|
|
fUpperSibling? fUpperSibling->GetName():"NULL",
|
|
|
|
fLowerSibling? fLowerSibling->GetName():"NULL");
|
2004-04-03 19:08:09 +04:00
|
|
|
printf("\t topChild: %s\t bottomChild: %s\n",
|
2004-06-11 22:21:57 +04:00
|
|
|
fTopChild? fTopChild->GetName():"NULL",
|
|
|
|
fBottomChild? fBottomChild->GetName():"NULL");
|
|
|
|
|
|
|
|
printf("Frame: (%f, %f, %f, %f)", fFrame.left, fFrame.top, fFrame.right, fFrame.bottom);
|
|
|
|
printf("Token: %ld\n",fViewToken);
|
2004-07-30 19:16:59 +04:00
|
|
|
printf("Hidden - direct: %s\n", fHidden?"true":"false");
|
2004-02-24 15:02:47 +03:00
|
|
|
printf("Hidden - indirect: %s\n", IsHidden()?"true":"false");
|
2004-06-11 22:21:57 +04:00
|
|
|
printf("ResizingMode: %lx\n", fResizeMode);
|
|
|
|
printf("Flags: %lx\n", fFlags);
|
|
|
|
|
|
|
|
if (fLayerData)
|
|
|
|
fLayerData->PrintToStream();
|
2004-04-03 19:08:09 +04:00
|
|
|
else
|
|
|
|
printf(" NO LayerData valid pointer\n");
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Prints pointer info kept by the current layer
|
2003-01-24 18:19:27 +03:00
|
|
|
void Layer::PrintNode(void)
|
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
printf("-----------\nLayer %s\n",fName->String());
|
|
|
|
if(fParent)
|
|
|
|
printf("Parent: %s (%p)\n",fParent->GetName(), fParent);
|
2003-01-24 18:19:27 +03:00
|
|
|
else
|
|
|
|
printf("Parent: NULL\n");
|
2004-06-11 22:21:57 +04:00
|
|
|
if(fUpperSibling)
|
|
|
|
printf("Upper sibling: %s (%p)\n",fUpperSibling->GetName(), fUpperSibling);
|
2003-01-24 18:19:27 +03:00
|
|
|
else
|
|
|
|
printf("Upper sibling: NULL\n");
|
2004-06-11 22:21:57 +04:00
|
|
|
if(fLowerSibling)
|
|
|
|
printf("Lower sibling: %s (%p)\n",fLowerSibling->GetName(), fLowerSibling);
|
2003-01-24 18:19:27 +03:00
|
|
|
else
|
|
|
|
printf("Lower sibling: NULL\n");
|
2004-06-11 22:21:57 +04:00
|
|
|
if(fTopChild)
|
|
|
|
printf("Top child: %s (%p)\n",fTopChild->GetName(), fTopChild);
|
2003-01-24 18:19:27 +03:00
|
|
|
else
|
|
|
|
printf("Top child: NULL\n");
|
2004-06-11 22:21:57 +04:00
|
|
|
if(fBottomChild)
|
|
|
|
printf("Bottom child: %s (%p)\n",fBottomChild->GetName(), fBottomChild);
|
2003-01-24 18:19:27 +03:00
|
|
|
else
|
|
|
|
printf("Bottom child: NULL\n");
|
2004-06-11 22:21:57 +04:00
|
|
|
printf("Visible Areas: "); fVisible.PrintToStream();
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Prints the tree hierarchy from the current layer down
|
2004-06-11 22:21:57 +04:00
|
|
|
void Layer::PrintTree()
|
|
|
|
{
|
2004-02-24 15:02:47 +03:00
|
|
|
printf("\n Tree structure:\n");
|
|
|
|
printf("\t%s\t%s\n", GetName(), IsHidden()? "Hidden": "NOT hidden");
|
|
|
|
for(Layer *lay = VirtualBottomChild(); lay != NULL; lay = VirtualUpperSibling())
|
|
|
|
printf("\t%s\t%s\n", lay->GetName(), lay->IsHidden()? "Hidden": "NOT hidden");
|
2003-09-15 23:11:52 +04:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Converts the passed rectangle to parent coordinates
|
2003-01-24 18:19:27 +03:00
|
|
|
BRect Layer::ConvertToParent(BRect rect)
|
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
return (rect.OffsetByCopy(fFrame.LeftTop()));
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Converts the passed region to parent coordinates
|
2003-01-24 18:19:27 +03:00
|
|
|
BRegion Layer::ConvertToParent(BRegion *reg)
|
|
|
|
{
|
|
|
|
BRegion newreg;
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2003-09-25 16:25:13 +04:00
|
|
|
for(int32 i=0; i<reg->CountRects(); i++)
|
2004-06-11 22:21:57 +04:00
|
|
|
newreg.Include( (reg->RectAt(i)).OffsetByCopy(fFrame.LeftTop()) );
|
|
|
|
|
2003-09-25 16:25:13 +04:00
|
|
|
return newreg;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2005-04-06 00:03:07 +04:00
|
|
|
//! Converts the passed rectangle from parent coordinates
|
|
|
|
BPoint Layer::ConvertFromParent(BPoint pt)
|
|
|
|
{
|
|
|
|
return (pt - fFrame.LeftTop());
|
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Converts the passed rectangle from parent coordinates
|
2003-01-24 18:19:27 +03:00
|
|
|
BRect Layer::ConvertFromParent(BRect rect)
|
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
return (rect.OffsetByCopy(fFrame.left*-1,fFrame.top*-1));
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Converts the passed region from parent coordinates
|
2003-01-24 18:19:27 +03:00
|
|
|
BRegion Layer::ConvertFromParent(BRegion *reg)
|
|
|
|
{
|
|
|
|
BRegion newreg;
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2003-01-24 18:19:27 +03:00
|
|
|
for(int32 i=0; i<reg->CountRects();i++)
|
2004-06-11 22:21:57 +04:00
|
|
|
newreg.Include((reg->RectAt(i)).OffsetByCopy(fFrame.left*-1,fFrame.top*-1));
|
|
|
|
|
2003-09-25 16:25:13 +04:00
|
|
|
return newreg;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-14 04:51:51 +04:00
|
|
|
BPoint Layer::ConvertToTop(BPoint pt)
|
|
|
|
{
|
|
|
|
if (fParent!=NULL)
|
|
|
|
{
|
|
|
|
return(fParent->ConvertToTop(pt+fFrame.LeftTop()));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return(pt);
|
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Converts the passed region to screen coordinates
|
2003-01-24 18:19:27 +03:00
|
|
|
BRegion Layer::ConvertToTop(BRegion *reg)
|
|
|
|
{
|
|
|
|
BRegion newreg;
|
|
|
|
for(int32 i=0; i<reg->CountRects();i++)
|
|
|
|
newreg.Include(ConvertToTop(reg->RectAt(i)));
|
2003-11-14 03:15:29 +03:00
|
|
|
return newreg;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Converts the passed rectangle to screen coordinates
|
2003-01-24 18:19:27 +03:00
|
|
|
BRect Layer::ConvertToTop(BRect rect)
|
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
if (fParent)
|
2004-06-11 22:21:57 +04:00
|
|
|
return(fParent->ConvertToTop(rect.OffsetByCopy(fFrame.LeftTop())) );
|
2003-01-24 18:19:27 +03:00
|
|
|
else
|
|
|
|
return(rect);
|
|
|
|
}
|
|
|
|
|
2004-09-14 04:51:51 +04:00
|
|
|
BPoint Layer::ConvertFromTop(BPoint pt)
|
|
|
|
{
|
2005-02-28 23:23:51 +03:00
|
|
|
if (fParent)
|
2004-09-14 04:51:51 +04:00
|
|
|
{
|
|
|
|
return(fParent->ConvertFromTop(pt-fFrame.LeftTop()));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return(pt);
|
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Converts the passed region from screen coordinates
|
2003-01-24 18:19:27 +03:00
|
|
|
BRegion Layer::ConvertFromTop(BRegion *reg)
|
|
|
|
{
|
|
|
|
BRegion newreg;
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2003-01-24 18:19:27 +03:00
|
|
|
for(int32 i=0; i<reg->CountRects();i++)
|
|
|
|
newreg.Include(ConvertFromTop(reg->RectAt(i)));
|
2004-06-11 22:21:57 +04:00
|
|
|
|
2003-11-14 03:15:29 +03:00
|
|
|
return newreg;
|
2003-01-24 18:19:27 +03:00
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Converts the passed rectangle from screen coordinates
|
2003-01-24 18:19:27 +03:00
|
|
|
BRect Layer::ConvertFromTop(BRect rect)
|
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
if (fParent!=NULL)
|
|
|
|
return(fParent->ConvertFromTop(rect.OffsetByCopy(fFrame.LeftTop().x*-1,
|
|
|
|
fFrame.LeftTop().y*-1)) );
|
2003-01-24 18:19:27 +03:00
|
|
|
else
|
|
|
|
return(rect);
|
|
|
|
}
|
2003-04-05 05:51:35 +04:00
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Sends a B_VIEW_RESIZE message to the client BWindow
|
2004-06-11 22:21:57 +04:00
|
|
|
void Layer::SendViewResizedMsg()
|
|
|
|
{
|
|
|
|
if( fServerWin && fFlags & B_FRAME_EVENTS )
|
2004-02-24 15:02:47 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
BMessage msg;
|
|
|
|
msg.what = B_VIEW_RESIZED;
|
2004-02-24 15:02:47 +03:00
|
|
|
msg.AddInt64( "when", real_time_clock_usecs() );
|
2004-06-11 22:21:57 +04:00
|
|
|
msg.AddInt32( "_token", fViewToken );
|
|
|
|
msg.AddFloat( "width", fFrame.Width() );
|
|
|
|
msg.AddFloat( "height", fFrame.Height() );
|
2004-02-24 15:02:47 +03:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
// no need for that... it's here because of backward compatibility
|
|
|
|
msg.AddPoint( "where", fFrame.LeftTop() );
|
|
|
|
|
|
|
|
fServerWin->SendMessageToClient( &msg );
|
2004-02-24 15:02:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Sends a B_VIEW_MOVED message to the client BWindow
|
2004-06-11 22:21:57 +04:00
|
|
|
void Layer::SendViewMovedMsg()
|
|
|
|
{
|
|
|
|
if( fServerWin && fFlags & B_FRAME_EVENTS )
|
2004-02-24 15:02:47 +03:00
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
BMessage msg;
|
|
|
|
msg.what = B_VIEW_MOVED;
|
2004-02-24 15:02:47 +03:00
|
|
|
msg.AddInt64( "when", real_time_clock_usecs() );
|
2004-06-11 22:21:57 +04:00
|
|
|
msg.AddInt32( "_token", fViewToken );
|
|
|
|
msg.AddPoint( "where", fFrame.LeftTop() );
|
|
|
|
|
|
|
|
fServerWin->SendMessageToClient( &msg );
|
2004-02-24 15:02:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Sends an _UPDATE_ message to the client BWindow
|
2005-04-06 00:03:07 +04:00
|
|
|
void Layer::SendUpdateMsg(BRegion ®)
|
2004-07-05 19:23:29 +04:00
|
|
|
{
|
2005-03-31 20:48:51 +04:00
|
|
|
BMessage msg;
|
|
|
|
msg.what = _UPDATE_;
|
2005-04-06 00:03:07 +04:00
|
|
|
msg.AddRect("_rect", ConvertFromTop(reg.Frame()) );
|
|
|
|
msg.AddRect("debug_rect", reg.Frame() );
|
|
|
|
// msg.AddInt32("_token",fViewToken);
|
2004-07-05 19:23:29 +04:00
|
|
|
|
2005-03-31 20:48:51 +04:00
|
|
|
fOwner->Window()->SendMessageToClient(&msg);
|
2004-07-05 19:23:29 +04:00
|
|
|
}
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
Layer *Layer::VirtualTopChild() const
|
|
|
|
{
|
|
|
|
fCurrent = fTopChild;
|
2004-02-24 15:02:47 +03:00
|
|
|
return fCurrent;
|
2003-04-05 05:51:35 +04:00
|
|
|
}
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
Layer *Layer::VirtualLowerSibling() const
|
|
|
|
{
|
|
|
|
fCurrent = fCurrent->fLowerSibling;
|
2004-02-24 15:02:47 +03:00
|
|
|
return fCurrent;
|
2003-04-05 05:51:35 +04:00
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
Layer *Layer::VirtualUpperSibling() const
|
|
|
|
{
|
|
|
|
fCurrent = fCurrent->fUpperSibling;
|
2004-02-24 15:02:47 +03:00
|
|
|
return fCurrent;
|
|
|
|
}
|
2004-01-13 03:56:36 +03:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
Layer* Layer::VirtualBottomChild() const
|
|
|
|
{
|
|
|
|
fCurrent = fBottomChild;
|
2004-02-24 15:02:47 +03:00
|
|
|
return fCurrent;
|
|
|
|
}
|