2004-08-03 19:17:44 +04:00
|
|
|
//------------------------------------------------------------------------------
|
2004-09-21 02:50:02 +04:00
|
|
|
// Copyright (c) 2001-2002, Haiku, Inc.
|
2004-08-03 19:17:44 +04:00
|
|
|
//
|
|
|
|
// 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.h
|
|
|
|
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
2005-01-17 00:35:02 +03:00
|
|
|
// Adi Oanca <adioanca@cotty.iren.com>
|
2004-08-03 19:17:44 +04:00
|
|
|
// Description: Class used for rendering to the frame buffer. One layer per
|
|
|
|
// view on screen and also for window decorators
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
2003-01-24 18:19:27 +03:00
|
|
|
#ifndef _LAYER_H_
|
|
|
|
#define _LAYER_H_
|
|
|
|
|
|
|
|
#include <GraphicsDefs.h>
|
|
|
|
#include <Rect.h>
|
|
|
|
#include <Region.h>
|
|
|
|
#include <List.h>
|
|
|
|
#include <String.h>
|
|
|
|
#include <OS.h>
|
2003-02-07 20:30:17 +03:00
|
|
|
#include <Locker.h>
|
2004-02-24 15:02:47 +03:00
|
|
|
#include "RGBColor.h"
|
2003-01-24 18:19:27 +03:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
enum
|
|
|
|
{
|
2004-07-09 01:12:53 +04:00
|
|
|
B_LAYER_NONE = 1,
|
|
|
|
B_LAYER_MOVE = 2,
|
|
|
|
B_LAYER_SIMPLE_MOVE = 3,
|
|
|
|
B_LAYER_RESIZE = 4,
|
|
|
|
B_LAYER_MASK_RESIZE = 5,
|
2004-06-18 15:50:17 +04:00
|
|
|
};
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2004-06-18 15:50:17 +04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
B_LAYER_CHILDREN_DEPENDANT = 0x1000U,
|
2004-06-16 10:40:26 +04:00
|
|
|
};
|
|
|
|
|
2004-07-05 19:23:29 +04:00
|
|
|
// easy way to determine class type
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
AS_LAYER_CLASS = 1,
|
|
|
|
AS_WINBORDER_CLASS = 2,
|
|
|
|
AS_ROOTLAYER_CLASS = 3,
|
|
|
|
};
|
|
|
|
|
2003-01-24 18:19:27 +03:00
|
|
|
class ServerWindow;
|
2003-02-12 14:24:26 +03:00
|
|
|
class RootLayer;
|
2003-11-14 03:15:29 +03:00
|
|
|
class DisplayDriver;
|
2004-02-24 15:02:47 +03:00
|
|
|
class LayerData;
|
2003-01-24 18:19:27 +03:00
|
|
|
|
|
|
|
class Layer
|
|
|
|
{
|
|
|
|
public:
|
2004-06-11 22:21:57 +04:00
|
|
|
Layer(BRect frame, const char *name, int32 token, uint32 resize,
|
|
|
|
uint32 flags, DisplayDriver *driver);
|
|
|
|
virtual ~Layer(void);
|
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
void AddChild(Layer *child, ServerWindow *serverWin);
|
2004-06-11 22:21:57 +04:00
|
|
|
void RemoveChild(Layer *child);
|
|
|
|
void RemoveSelf(void);
|
|
|
|
bool HasChild(Layer *layer);
|
|
|
|
RootLayer *GetRootLayer(void) const { return fRootLayer; }
|
|
|
|
|
|
|
|
uint32 CountChildren(void) const;
|
|
|
|
Layer *FindLayer(const int32 token);
|
|
|
|
Layer *LayerAt(const BPoint &pt);
|
|
|
|
bool IsTopLayer(void) { return fIsTopLayer; }
|
|
|
|
|
|
|
|
virtual Layer *VirtualTopChild(void) const;
|
|
|
|
virtual Layer *VirtualLowerSibling(void) const;
|
|
|
|
virtual Layer *VirtualUpperSibling(void) const;
|
|
|
|
virtual Layer *VirtualBottomChild(void) const;
|
|
|
|
|
|
|
|
const char *GetName(void) const { return (fName)?fName->String():NULL; }
|
|
|
|
|
|
|
|
virtual void RebuildFullRegion(void);
|
|
|
|
void StartRebuildRegions( const BRegion& reg, Layer *target, uint32 action, BPoint& pt);
|
|
|
|
void RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOffset);
|
|
|
|
uint32 ResizeOthers(float x, float y, BPoint coords[], BPoint *ptOffset);
|
|
|
|
|
|
|
|
void Redraw(const BRegion& reg, Layer *startFrom=NULL);
|
|
|
|
|
|
|
|
void EmptyGlobals(void);
|
|
|
|
|
|
|
|
virtual void Draw(const BRect &r);
|
|
|
|
|
|
|
|
virtual void Show(bool invalidate=true);
|
|
|
|
virtual void Hide(bool invalidate=true);
|
2004-07-11 15:08:36 +04:00
|
|
|
virtual bool IsHidden(void) const;
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
BRect Bounds(void) const;
|
|
|
|
BRect Frame(void) const;
|
|
|
|
|
|
|
|
virtual void MoveBy(float x, float y);
|
|
|
|
virtual void ResizeBy(float x, float y);
|
|
|
|
|
|
|
|
BRect ConvertToParent(BRect rect);
|
|
|
|
BRegion ConvertToParent(BRegion *reg);
|
|
|
|
BRect ConvertFromParent(BRect rect);
|
|
|
|
BRegion ConvertFromParent(BRegion *reg);
|
2004-09-14 04:51:51 +04:00
|
|
|
|
|
|
|
BPoint ConvertToTop(BPoint pt);
|
2004-06-11 22:21:57 +04:00
|
|
|
BRegion ConvertToTop(BRegion *reg);
|
|
|
|
BRect ConvertToTop(BRect rect);
|
2004-09-14 04:51:51 +04:00
|
|
|
|
|
|
|
BPoint ConvertFromTop(BPoint pt);
|
2004-06-11 22:21:57 +04:00
|
|
|
BRegion ConvertFromTop(BRegion *reg);
|
|
|
|
BRect ConvertFromTop(BRect rect);
|
|
|
|
|
|
|
|
DisplayDriver *GetDisplayDriver(void) const { return fDriver; }
|
2004-06-16 10:40:26 +04:00
|
|
|
ServerWindow *Window(void) const { return fServerWin; }
|
2004-09-09 04:54:21 +04:00
|
|
|
virtual bool HasClient(void) { return true; }
|
2004-07-05 19:23:29 +04:00
|
|
|
bool IsServerLayer() const;
|
2005-01-17 00:35:02 +03:00
|
|
|
int32 Level() const { return fLevel; }
|
2004-06-16 10:40:26 +04:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
void PruneTree(void);
|
|
|
|
|
|
|
|
void PrintToStream(void);
|
|
|
|
void PrintNode(void);
|
|
|
|
void PrintTree(void);
|
2004-01-12 01:12:55 +03:00
|
|
|
|
2004-01-13 03:56:36 +03:00
|
|
|
// server "private" - should not be used
|
2004-06-11 22:21:57 +04:00
|
|
|
void SetRootLayer(RootLayer *rl){ fRootLayer = rl; }
|
|
|
|
void SetAsTopLayer(bool option) { fIsTopLayer = option; }
|
2004-07-05 19:23:29 +04:00
|
|
|
bool IsTopLayer() const { return fIsTopLayer; }
|
|
|
|
|
2004-07-06 00:37:13 +04:00
|
|
|
void UpdateStart();
|
|
|
|
void UpdateEnd();
|
2004-07-05 19:23:29 +04:00
|
|
|
bool InUpdate() const { return fInUpdate; }
|
2004-07-06 00:37:13 +04:00
|
|
|
BRegion* ClippingRegion() const { return fClipReg; }
|
2004-02-24 15:02:47 +03:00
|
|
|
|
2003-01-24 18:19:27 +03:00
|
|
|
protected:
|
2003-06-23 06:54:52 +04:00
|
|
|
friend class RootLayer;
|
|
|
|
friend class WinBorder;
|
2003-09-09 01:18:39 +04:00
|
|
|
friend class ServerWindow;
|
2004-01-13 03:56:36 +03:00
|
|
|
friend class Workspace;
|
2004-02-24 15:02:47 +03:00
|
|
|
|
2005-01-23 02:25:41 +03:00
|
|
|
void move_layer(float x, float y);
|
|
|
|
void resize_layer(float x, float y);
|
|
|
|
|
2005-01-24 23:59:27 +03:00
|
|
|
void FullInvalidate(const BRect &rect);
|
|
|
|
void FullInvalidate(const BRegion ®ion);
|
|
|
|
void Invalidate(const BRegion ®ion);
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
BRect fFrame;
|
|
|
|
BPoint fBoundsLeftTop;
|
|
|
|
Layer *fParent;
|
|
|
|
Layer *fUpperSibling;
|
|
|
|
Layer *fLowerSibling;
|
|
|
|
Layer *fTopChild;
|
|
|
|
Layer *fBottomChild;
|
|
|
|
|
|
|
|
mutable Layer *fCurrent;
|
|
|
|
|
|
|
|
BRegion fVisible;
|
|
|
|
BRegion fFullVisible;
|
|
|
|
BRegion fFull;
|
|
|
|
BRegion fUpdateReg;
|
2004-07-06 00:37:13 +04:00
|
|
|
BRegion *fClipReg;
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
BRegion *clipToPicture;
|
|
|
|
bool clipToPictureInverse;
|
|
|
|
|
|
|
|
ServerWindow *fServerWin;
|
|
|
|
BString *fName;
|
|
|
|
int32 fViewToken;
|
|
|
|
int32 fLevel;
|
|
|
|
uint32 fFlags;
|
|
|
|
uint32 fResizeMode;
|
|
|
|
bool fHidden;
|
2004-07-05 19:23:29 +04:00
|
|
|
bool fInUpdate;
|
2004-06-11 22:21:57 +04:00
|
|
|
bool fIsTopLayer;
|
2004-06-16 10:40:26 +04:00
|
|
|
uint16 fAdFlags;
|
2004-07-05 19:23:29 +04:00
|
|
|
int8 fClassID;
|
2004-07-09 01:12:53 +04:00
|
|
|
int8 fFrameAction;
|
2004-06-11 22:21:57 +04:00
|
|
|
|
|
|
|
DisplayDriver *fDriver;
|
|
|
|
LayerData *fLayerData;
|
|
|
|
//RGBColor fBackColor;
|
|
|
|
|
|
|
|
RootLayer *fRootLayer;
|
2004-01-13 03:56:36 +03:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
private:
|
2004-06-16 10:40:26 +04:00
|
|
|
void RequestDraw(const BRegion ®, Layer *startFrom);
|
2004-09-09 04:54:21 +04:00
|
|
|
ServerWindow *SearchForServerWindow(void);
|
2004-02-24 15:02:47 +03:00
|
|
|
|
2004-07-05 19:23:29 +04:00
|
|
|
void Layer::SendUpdateMsg();
|
|
|
|
void SendViewMovedMsg(void);
|
|
|
|
void SendViewResizedMsg(void);
|
|
|
|
|
2003-01-24 18:19:27 +03:00
|
|
|
};
|
|
|
|
|
2003-02-07 20:30:17 +03:00
|
|
|
#endif
|