haiku/src/servers/app/ViewLayer.h

253 lines
6.5 KiB
C
Raw Normal View History

/*
* Copyright (c) 2001-2006, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Authors:
* DarkWyrm <bpmagic@columbus.rr.com>
* Adi Oanca <adioanca@gmail.com>
* Axel Dörfler, axeld@pinc-software.de
* Stephan Aßmus <superstippi@gmx.de>
*/
#ifndef VIEW_LAYER_H
#define VIEW_LAYER_H
#include "RGBColor.h"
#include <GraphicsDefs.h>
#include <Region.h>
#include <String.h>
class BList;
namespace BPrivate {
class PortLink;
};
class DrawState;
class DrawingEngine;
class WindowLayer;
class ServerBitmap;
class ServerCursor;
class ServerPicture;
class ViewLayer {
public:
ViewLayer(BRect frame, const char* name,
int32 token, uint32 resizeMode,
uint32 flags);
virtual ~ViewLayer();
void SetName(const char* string);
const char* Name() const
{ return fName.String(); }
int32 Token() const
{ return fToken; }
BRect Frame() const
{ return fFrame; }
BRect Bounds() const;
void SetResizeMode(uint32 resizeMode)
{ fResizeMode = resizeMode; }
uint32 Flags() const
{ return fFlags; }
void SetFlags(uint32 flags);
BPoint ScrollingOffset() const;
void SetDrawingOrigin(BPoint origin);
BPoint DrawingOrigin() const;
void SetScale(float scale);
float Scale() const;
void SetUserClipping(const BRegion& region);
// region is expected in layer coordinates
// converts the given frame up the view hierarchy and
// clips to each views bounds
void ConvertToVisibleInTopView(BRect* bounds) const;
void AttachedToWindow(WindowLayer* window);
void DetachedFromWindow();
WindowLayer* Window() const { return fWindow; }
// tree stuff
void AddChild(ViewLayer* layer);
bool RemoveChild(ViewLayer* layer);
inline ViewLayer* Parent() const
{ return fParent; }
ViewLayer* FirstChild() const;
ViewLayer* LastChild() const;
ViewLayer* PreviousSibling() const;
ViewLayer* NextSibling() const;
ViewLayer* TopLayer();
uint32 CountChildren(bool deep = false) const;
void CollectTokensForChildren(BList* tokenMap) const;
ViewLayer* ViewAt(const BPoint& where,
BRegion* windowContentClipping);
// coordinate conversion
void ConvertToParent(BPoint* point) const;
void ConvertToParent(BRect* rect) const;
void ConvertToParent(BRegion* region) const;
void ConvertFromParent(BPoint* point) const;
void ConvertFromParent(BRect* rect) const;
void ConvertFromParent(BRegion* region) const;
void ConvertToScreen(BPoint* point) const;
void ConvertToScreen(BRect* rect) const;
void ConvertToScreen(BRegion* region) const;
void ConvertFromScreen(BPoint* point) const;
void ConvertFromScreen(BRect* rect) const;
void ConvertFromScreen(BRegion* region) const;
void ConvertToScreenForDrawing(BPoint* point) const;
void ConvertToScreenForDrawing(BRect* rect) const;
void ConvertToScreenForDrawing(BRegion* region) const;
void ConvertFromScreenForDrawing(BPoint* point) const;
// used when updating the pen position
void MoveBy(int32 dx, int32 dy,
BRegion* dirtyRegion);
void ResizeBy(int32 dx, int32 dy,
BRegion* dirtyRegion);
void ScrollBy(int32 dx, int32 dy,
BRegion* dirtyRegion);
void ParentResized(int32 dx, int32 dy,
BRegion* dirtyRegion);
void CopyBits(BRect src, BRect dst,
BRegion& windowContentClipping);
const BRegion& LocalClipping() const { return fLocalClipping; }
const RGBColor& ViewColor() const
{ return fViewColor; }
void SetViewColor(const RGBColor& color)
{ fViewColor = color; }
void SetViewBitmap(ServerBitmap* bitmap, BRect sourceRect,
BRect destRect, int32 resizingMode, int32 options);
void PushState();
void PopState();
DrawState* CurrentState() const { return fDrawState; }
void SetEventMask(uint32 eventMask, uint32 options);
uint32 EventMask() const
{ return fEventMask; }
uint32 EventOptions() const
{ return fEventOptions; }
ServerCursor* Cursor() const { return fCursor; }
void SetCursor(ServerCursor* cursor);
ServerPicture* Picture() const;
void SetPicture(ServerPicture* picture);
// for background clearing
virtual void Draw(DrawingEngine* drawingEngine,
BRegion* effectiveClipping,
BRegion* windowContentClipping,
bool deep = false);
void SetHidden(bool hidden);
bool IsHidden() const;
// takes into account parent views hidden status
bool IsVisible() const
{ return fVisible; }
// update visible status for this view and all children
// according to the parents visibility
void UpdateVisibleDeep(bool parentVisible);
void MarkBackgroundDirty();
bool IsBackgroundDirty() const
{ return fBackgroundDirty; }
bool IsDesktopBackground() const
{ return fIsDesktopBackground; }
ServerFont: * fixed weird pointer conversion in SetStyle() * fixed a potential mix up in operator=() in case the other ServerFont has fStyle == NULL ServerWindow: * the WindowLayer fTopLayer cannot be deleted by client request, just for safety reasons * the link is flushed if there is no drawing engine, but this case is theoretical only * deleting the ServerWindow object syncs with the client, so that when BBitmaps are deleted, they can be sure there are no pending messages (which would be executed in a nother thread) * there is no timeout anymore when sending messages to the client, which made absolutely no sense AGGTextRenderer: * renamed fFontManager to fFontCache, because that's what it really is * fLastFamilyAndStyle defaulted to the system plain font and therefor that font was never loaded when the font never changed meanwhile DrawingMode: * I'm not quite sure but I think there was the potential of a division by zero, at least I had crashes with "divide error" HWInterface: * fix update when the cursor shape changed in double buffered mode ViewLayer: * since the top layer is never really deleted before its time has come, it is not necessary to set it to NULL in the ViewLayer destructor ViewLayer/WindowLayer: * added a function to collect the view tokens that are affected by an update session EventDispatcher: * use the importance of the message for the timeout in _SendMessage() * drop mouse moved events in the server if we're lagging behind more than 5 ms (Axel, maybe review) View: * there were some problems with the locking of the BWindow looper in RemoveSelf(), since this is called from the window destructor, also of BWindows from BBitmaps, which have never been run (this might need review), at least I seem to have solved the crashing problems introduced by actually deleting the view hirarchy in the BWindow destructor * fixed _Draw() for being used non-recursively, temporarily disabled DrawAfterChildren, which didn't work yet anyways (because views cannot draw over children in the server yet) Window: * small cleanup when deleting shortcuts * sync with the server when having send AS_DELETE_WINDOW (see ServerWindow above) * fixed locking in Begin/EndViewTransaction() * removed folding of _UPDATE_ messages, since there is only one ever in the queue * set the fInTransaction flag during an update, I plan to use this in BView later to flush the link when drawing outside of an update * BView::_Draw() is now called by view token, this gives the next leap forward in speed, the overhead because of drawing clean views was considerable git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15878 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-01-09 01:04:52 +03:00
void AddTokensForLayersInRegion(BMessage* message,
BRegion& region,
BRegion* windowContentClipping);
void AddTokensForLayersInRegion(BPrivate::PortLink& link,
BRegion& region,
BRegion* windowContentClipping);
// clipping
void RebuildClipping(bool deep);
BRegion& ScreenClipping(BRegion* windowContentClipping,
bool force = false) const;
void InvalidateScreenClipping(bool deep);
bool IsScreenClippingValid() const
{ return fScreenClippingValid; }
// debugging
void PrintToStream() const;
protected:
void _MoveScreenClipping(int32 x, int32 y,
bool deep);
BString fName;
int32 fToken;
// area within parent coordinate space
BRect fFrame;
// scrolling offset
BPoint fScrollingOffset;
RGBColor fViewColor;
DrawState* fDrawState;
ServerBitmap* fViewBitmap;
BRect fBitmapSource;
BRect fBitmapDestination;
int32 fBitmapResizingMode;
int32 fBitmapOptions;
uint32 fResizeMode;
uint32 fFlags;
bool fHidden;
bool fVisible;
bool fBackgroundDirty;
bool fIsDesktopBackground;
uint32 fEventMask;
uint32 fEventOptions;
WindowLayer* fWindow;
ViewLayer* fParent;
ViewLayer* fFirstChild;
ViewLayer* fPreviousSibling;
ViewLayer* fNextSibling;
ViewLayer* fLastChild;
ServerCursor* fCursor;
ServerPicture* fPicture;
// clipping
BRegion fLocalClipping;
mutable BRegion fScreenClipping;
mutable bool fScreenClippingValid;
};
#endif // LAYER_H