2005-12-08 15:41:19 +03:00
|
|
|
/*
|
2006-02-02 23:19:29 +03:00
|
|
|
* Copyright (c) 2001-2006, Haiku, Inc.
|
2005-12-08 15:41:19 +03:00
|
|
|
* Distributed under the terms of the MIT license.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
* Adi Oanca <adioanca@gmail.com>
|
2006-02-02 23:19:29 +03:00
|
|
|
* Axel Dörfler, axeld@pinc-software.de
|
2005-12-08 15:41:19 +03:00
|
|
|
* Stephan Aßmus <superstippi@gmx.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "ViewLayer.h"
|
|
|
|
|
2005-12-29 19:46:02 +03:00
|
|
|
#include "BitmapManager.h"
|
2005-12-08 15:41:19 +03:00
|
|
|
#include "Desktop.h"
|
|
|
|
#include "DrawingEngine.h"
|
|
|
|
#include "ServerApp.h"
|
2005-12-29 19:46:02 +03:00
|
|
|
#include "ServerBitmap.h"
|
2006-02-26 21:15:31 +03:00
|
|
|
#include "ServerCursor.h"
|
2006-01-03 13:30:08 +03:00
|
|
|
#include "ServerPicture.h"
|
2005-12-08 15:41:19 +03:00
|
|
|
#include "ServerWindow.h"
|
|
|
|
#include "WindowLayer.h"
|
|
|
|
|
2006-04-19 18:12:57 +04:00
|
|
|
#include "drawing_support.h"
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
#include <List.h>
|
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
|
|
|
#include <Message.h>
|
2006-02-06 13:28:30 +03:00
|
|
|
#include <PortLink.h>
|
2005-12-08 15:41:19 +03:00
|
|
|
#include <View.h> // for resize modes
|
2006-02-13 16:43:30 +03:00
|
|
|
#include <WindowPrivate.h>
|
2005-12-08 15:41:19 +03:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2005-12-10 23:16:41 +03:00
|
|
|
#include <new>
|
|
|
|
|
|
|
|
using std::nothrow;
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2006-04-04 05:51:16 +04:00
|
|
|
|
|
|
|
ViewLayer::ViewLayer(BRect frame, BPoint scrollingOffset, const char* name,
|
2005-12-08 15:41:19 +03:00
|
|
|
int32 token, uint32 resizeMode, uint32 flags)
|
|
|
|
:
|
|
|
|
fName(name),
|
|
|
|
fToken(token),
|
|
|
|
|
|
|
|
fFrame(frame),
|
2006-04-04 05:51:16 +04:00
|
|
|
fScrollingOffset(scrollingOffset),
|
2005-12-08 15:41:19 +03:00
|
|
|
|
|
|
|
fViewColor(RGBColor(255, 255, 255)),
|
|
|
|
fDrawState(new (nothrow) DrawState),
|
2005-12-29 19:46:02 +03:00
|
|
|
fViewBitmap(NULL),
|
2005-12-08 15:41:19 +03:00
|
|
|
|
|
|
|
fResizeMode(resizeMode),
|
|
|
|
fFlags(flags),
|
|
|
|
|
|
|
|
// ViewLayers start visible by default
|
|
|
|
fHidden(false),
|
|
|
|
fVisible(true),
|
2005-12-21 01:31:42 +03:00
|
|
|
fBackgroundDirty(true),
|
2006-02-13 16:43:30 +03:00
|
|
|
fIsDesktopBackground(false),
|
2005-12-08 15:41:19 +03:00
|
|
|
|
|
|
|
fEventMask(0),
|
|
|
|
fEventOptions(0),
|
|
|
|
|
|
|
|
fWindow(NULL),
|
|
|
|
fParent(NULL),
|
|
|
|
|
|
|
|
fFirstChild(NULL),
|
|
|
|
fPreviousSibling(NULL),
|
|
|
|
fNextSibling(NULL),
|
|
|
|
fLastChild(NULL),
|
2006-02-02 23:19:29 +03:00
|
|
|
|
|
|
|
fCursor(NULL),
|
2006-01-03 13:30:08 +03:00
|
|
|
fPicture(NULL),
|
2005-12-08 15:41:19 +03:00
|
|
|
|
|
|
|
fLocalClipping(Bounds()),
|
|
|
|
fScreenClipping(),
|
|
|
|
fScreenClippingValid(false)
|
|
|
|
{
|
|
|
|
fFrame.left = float((int32)fFrame.left);
|
|
|
|
fFrame.top = float((int32)fFrame.top);
|
|
|
|
fFrame.right = float((int32)fFrame.right);
|
|
|
|
fFrame.bottom = float((int32)fFrame.bottom);
|
2005-12-21 14:22:48 +03:00
|
|
|
|
|
|
|
if (fDrawState)
|
|
|
|
fDrawState->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE);
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// destructor
|
|
|
|
ViewLayer::~ViewLayer()
|
|
|
|
{
|
2005-12-29 20:40:18 +03:00
|
|
|
if (fViewBitmap != NULL)
|
|
|
|
gBitmapManager->DeleteBitmap(fViewBitmap);
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
delete fDrawState;
|
|
|
|
|
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
|
|
|
// if (fWindow && this == fWindow->TopLayer())
|
|
|
|
// fWindow->SetTopLayer(NULL);
|
|
|
|
//
|
2006-01-03 13:30:08 +03:00
|
|
|
// TODO: Don't know yet if we should also delete fPicture
|
|
|
|
|
2006-02-26 21:15:31 +03:00
|
|
|
if (fCursor)
|
|
|
|
fCursor->Release();
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
// iterate over children and delete each one
|
|
|
|
ViewLayer* layer = fFirstChild;
|
|
|
|
while (layer) {
|
|
|
|
ViewLayer* toast = layer;
|
|
|
|
layer = layer->fNextSibling;
|
|
|
|
delete toast;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bounds
|
|
|
|
BRect
|
|
|
|
ViewLayer::Bounds() const
|
|
|
|
{
|
|
|
|
BRect bounds(fScrollingOffset.x, fScrollingOffset.y,
|
|
|
|
fScrollingOffset.x + fFrame.Width(),
|
|
|
|
fScrollingOffset.y + fFrame.Height());
|
|
|
|
return bounds;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ConvertToVisibleInTopView
|
|
|
|
void
|
|
|
|
ViewLayer::ConvertToVisibleInTopView(BRect* bounds) const
|
|
|
|
{
|
|
|
|
*bounds = *bounds & Bounds();
|
|
|
|
// NOTE: this step is necessary even if we don't have a parent!
|
|
|
|
ConvertToParent(bounds);
|
|
|
|
|
|
|
|
if (fParent)
|
|
|
|
fParent->ConvertToVisibleInTopView(bounds);
|
|
|
|
}
|
|
|
|
|
|
|
|
// AttachedToWindow
|
|
|
|
void
|
|
|
|
ViewLayer::AttachedToWindow(WindowLayer* window)
|
|
|
|
{
|
|
|
|
fWindow = window;
|
|
|
|
|
2006-02-13 16:43:30 +03:00
|
|
|
// an ugly hack to detect the desktop background
|
|
|
|
if (window->Feel() == kDesktopWindowFeel && Parent() == TopLayer())
|
|
|
|
fIsDesktopBackground = true;
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
// insert view into local token space
|
|
|
|
if (fWindow != NULL)
|
|
|
|
fWindow->ServerWindow()->App()->ViewTokens().SetToken(fToken, B_HANDLER_TOKEN, this);
|
|
|
|
|
|
|
|
// attach child views as well
|
|
|
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling())
|
|
|
|
child->AttachedToWindow(window);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// DetachedFromWindow
|
|
|
|
void
|
|
|
|
ViewLayer::DetachedFromWindow()
|
|
|
|
{
|
|
|
|
// remove view from local token space
|
|
|
|
if (fWindow != NULL)
|
|
|
|
fWindow->ServerWindow()->App()->ViewTokens().RemoveToken(fToken);
|
|
|
|
|
|
|
|
fWindow = NULL;
|
|
|
|
// detach child views as well
|
|
|
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling())
|
|
|
|
child->DetachedFromWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddChild
|
|
|
|
void
|
|
|
|
ViewLayer::AddChild(ViewLayer* layer)
|
|
|
|
{
|
|
|
|
if (layer->fParent) {
|
|
|
|
printf("ViewLayer::AddChild() - ViewLayer already has a parent\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
layer->fParent = this;
|
|
|
|
|
|
|
|
if (!fLastChild) {
|
|
|
|
// no children yet
|
|
|
|
fFirstChild = layer;
|
|
|
|
} else {
|
|
|
|
// append layer to formerly last child
|
|
|
|
fLastChild->fNextSibling = layer;
|
|
|
|
layer->fPreviousSibling = fLastChild;
|
|
|
|
}
|
|
|
|
fLastChild = layer;
|
|
|
|
|
2006-02-06 22:31:02 +03:00
|
|
|
layer->UpdateVisibleDeep(fVisible);
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
if (layer->IsVisible())
|
|
|
|
RebuildClipping(false);
|
|
|
|
|
|
|
|
if (fWindow) {
|
|
|
|
layer->AttachedToWindow(fWindow);
|
|
|
|
|
|
|
|
if (fVisible && layer->IsVisible()) {
|
|
|
|
// trigger redraw
|
|
|
|
BRect clippedFrame = layer->Frame();
|
|
|
|
ConvertToVisibleInTopView(&clippedFrame);
|
2006-04-07 23:14:25 +04:00
|
|
|
BRegion* dirty = fWindow->GetRegion();
|
|
|
|
if (dirty) {
|
|
|
|
dirty->Set(clippedFrame);
|
|
|
|
fWindow->MarkContentDirty(*dirty);
|
|
|
|
fWindow->RecycleRegion(dirty);
|
|
|
|
}
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
ViewLayer::RemoveChild(ViewLayer* layer)
|
|
|
|
{
|
|
|
|
if (layer->fParent != this) {
|
|
|
|
printf("ViewLayer::RemoveChild(%p - %s) - ViewLayer is not child of this (%p) layer!\n", layer, layer ? layer->Name() : NULL, this);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
layer->fParent = NULL;
|
|
|
|
|
|
|
|
if (fLastChild == layer)
|
|
|
|
fLastChild = layer->fPreviousSibling;
|
|
|
|
// layer->fNextSibling would be NULL
|
|
|
|
|
|
|
|
if (fFirstChild == layer )
|
|
|
|
fFirstChild = layer->fNextSibling;
|
|
|
|
// layer->fPreviousSibling would be NULL
|
|
|
|
|
|
|
|
// connect child before and after layer
|
|
|
|
if (layer->fPreviousSibling)
|
|
|
|
layer->fPreviousSibling->fNextSibling = layer->fNextSibling;
|
|
|
|
|
|
|
|
if (layer->fNextSibling)
|
|
|
|
layer->fNextSibling->fPreviousSibling = layer->fPreviousSibling;
|
|
|
|
|
|
|
|
// layer has no siblings anymore
|
|
|
|
layer->fPreviousSibling = NULL;
|
|
|
|
layer->fNextSibling = NULL;
|
|
|
|
|
|
|
|
if (layer->IsVisible())
|
|
|
|
RebuildClipping(false);
|
|
|
|
|
|
|
|
if (fWindow) {
|
|
|
|
layer->DetachedFromWindow();
|
|
|
|
|
|
|
|
if (fVisible && layer->IsVisible()) {
|
|
|
|
// trigger redraw
|
|
|
|
BRect clippedFrame = layer->Frame();
|
|
|
|
ConvertToVisibleInTopView(&clippedFrame);
|
2006-04-07 23:14:25 +04:00
|
|
|
BRegion* dirty = fWindow->GetRegion();
|
|
|
|
if (dirty) {
|
|
|
|
dirty->Set(clippedFrame);
|
|
|
|
fWindow->MarkContentDirty(*dirty);
|
|
|
|
fWindow->RecycleRegion(dirty);
|
|
|
|
}
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ViewLayer*
|
|
|
|
ViewLayer::FirstChild() const
|
|
|
|
{
|
|
|
|
return fFirstChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ViewLayer*
|
|
|
|
ViewLayer::PreviousSibling() const
|
|
|
|
{
|
|
|
|
return fPreviousSibling;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ViewLayer*
|
|
|
|
ViewLayer::NextSibling() const
|
|
|
|
{
|
|
|
|
return fNextSibling;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ViewLayer*
|
|
|
|
ViewLayer::LastChild() const
|
|
|
|
{
|
|
|
|
return fLastChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ViewLayer*
|
|
|
|
ViewLayer::TopLayer()
|
|
|
|
{
|
|
|
|
// returns the top level view of the hirarchy,
|
|
|
|
// it doesn't have to be the top level of a window
|
|
|
|
|
|
|
|
if (fParent)
|
|
|
|
return fParent->TopLayer();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CountChildren
|
|
|
|
uint32
|
|
|
|
ViewLayer::CountChildren(bool deep) const
|
|
|
|
{
|
|
|
|
uint32 count = 0;
|
|
|
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) {
|
|
|
|
count++;
|
|
|
|
if (deep) {
|
|
|
|
count += child->CountChildren(deep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CollectTokensForChildren
|
|
|
|
void
|
|
|
|
ViewLayer::CollectTokensForChildren(BList* tokenMap) const
|
|
|
|
{
|
|
|
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) {
|
|
|
|
tokenMap->AddItem((void*)child);
|
|
|
|
child->CollectTokensForChildren(tokenMap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ViewAt
|
|
|
|
ViewLayer*
|
|
|
|
ViewLayer::ViewAt(const BPoint& where, BRegion* windowContentClipping)
|
|
|
|
{
|
|
|
|
if (!fVisible)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (ScreenClipping(windowContentClipping).Contains(where))
|
|
|
|
return this;
|
|
|
|
|
|
|
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) {
|
|
|
|
ViewLayer* layer = child->ViewAt(where, windowContentClipping);
|
|
|
|
if (layer)
|
|
|
|
return layer;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ViewLayer::SetFlags(uint32 flags)
|
|
|
|
{
|
|
|
|
fFlags = flags;
|
|
|
|
fDrawState->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BPoint
|
|
|
|
ViewLayer::ScrollingOffset() const
|
|
|
|
{
|
|
|
|
return fScrollingOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ViewLayer::SetDrawingOrigin(BPoint origin)
|
|
|
|
{
|
|
|
|
fDrawState->SetOrigin(origin);
|
|
|
|
|
|
|
|
// rebuild clipping
|
|
|
|
if (fDrawState->ClippingRegion())
|
|
|
|
RebuildClipping(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BPoint
|
|
|
|
ViewLayer::DrawingOrigin() const
|
|
|
|
{
|
|
|
|
BPoint origin(fDrawState->Origin());
|
|
|
|
float scale = Scale();
|
|
|
|
|
|
|
|
origin.x *= scale;
|
|
|
|
origin.y *= scale;
|
|
|
|
|
|
|
|
return origin;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ViewLayer::SetScale(float scale)
|
|
|
|
{
|
|
|
|
fDrawState->SetScale(scale);
|
|
|
|
|
|
|
|
// rebuild clipping
|
|
|
|
if (fDrawState->ClippingRegion())
|
|
|
|
RebuildClipping(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float
|
|
|
|
ViewLayer::Scale() const
|
|
|
|
{
|
|
|
|
return CurrentState()->Scale();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-03-08 21:57:44 +03:00
|
|
|
ViewLayer::SetUserClipping(const BRegion* region)
|
2005-12-08 15:41:19 +03:00
|
|
|
{
|
|
|
|
fDrawState->SetClippingRegion(region);
|
|
|
|
|
2005-12-30 22:56:42 +03:00
|
|
|
// rebuild clipping (for just this view)
|
2005-12-08 15:41:19 +03:00
|
|
|
RebuildClipping(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-29 19:46:02 +03:00
|
|
|
void
|
|
|
|
ViewLayer::SetViewBitmap(ServerBitmap* bitmap, BRect sourceRect,
|
|
|
|
BRect destRect, int32 resizingMode, int32 options)
|
|
|
|
{
|
|
|
|
if (fViewBitmap != NULL)
|
|
|
|
gBitmapManager->DeleteBitmap(fViewBitmap);
|
|
|
|
|
|
|
|
// the caller is allowed to delete the bitmap after setting the background
|
|
|
|
if (bitmap != NULL)
|
|
|
|
bitmap->Acquire();
|
|
|
|
|
2005-12-30 22:56:42 +03:00
|
|
|
fViewBitmap = bitmap;
|
2005-12-29 19:46:02 +03:00
|
|
|
fBitmapSource = sourceRect;
|
|
|
|
fBitmapDestination = destRect;
|
|
|
|
fBitmapResizingMode = resizingMode;
|
|
|
|
fBitmapOptions = options;
|
2005-12-30 22:56:42 +03:00
|
|
|
|
|
|
|
// round off destination rect to avoid problems
|
|
|
|
// with drawing the view color around the bitmap
|
|
|
|
fBitmapDestination.OffsetTo(roundf(fBitmapDestination.left),
|
|
|
|
roundf(fBitmapDestination.top));
|
|
|
|
fBitmapDestination.right = roundf(fBitmapDestination.right);
|
|
|
|
fBitmapDestination.bottom = roundf(fBitmapDestination.bottom);
|
2005-12-29 19:46:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
void
|
|
|
|
ViewLayer::ConvertToParent(BPoint* point) const
|
|
|
|
{
|
|
|
|
// remove scrolling offset and convert to parent coordinate space
|
|
|
|
point->x += fFrame.left - fScrollingOffset.x;
|
|
|
|
point->y += fFrame.top - fScrollingOffset.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ConvertToParent
|
|
|
|
void
|
|
|
|
ViewLayer::ConvertToParent(BRect* rect) const
|
|
|
|
{
|
|
|
|
// remove scrolling offset and convert to parent coordinate space
|
|
|
|
rect->OffsetBy(fFrame.left - fScrollingOffset.x,
|
|
|
|
fFrame.top - fScrollingOffset.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ConvertToParent
|
|
|
|
void
|
|
|
|
ViewLayer::ConvertToParent(BRegion* region) const
|
|
|
|
{
|
|
|
|
// remove scrolling offset and convert to parent coordinate space
|
|
|
|
region->OffsetBy(fFrame.left - fScrollingOffset.x,
|
|
|
|
fFrame.top - fScrollingOffset.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ConvertFromParent
|
|
|
|
void
|
|
|
|
ViewLayer::ConvertFromParent(BPoint* point) const
|
|
|
|
{
|
|
|
|
// remove scrolling offset and convert to parent coordinate space
|
|
|
|
point->x += fScrollingOffset.x - fFrame.left;
|
|
|
|
point->y += fScrollingOffset.y - fFrame.top;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ConvertFromParent
|
|
|
|
void
|
|
|
|
ViewLayer::ConvertFromParent(BRect* rect) const
|
|
|
|
{
|
|
|
|
// remove scrolling offset and convert to parent coordinate space
|
|
|
|
rect->OffsetBy(fScrollingOffset.x - fFrame.left,
|
|
|
|
fScrollingOffset.y - fFrame.top);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ConvertFromParent
|
|
|
|
void
|
|
|
|
ViewLayer::ConvertFromParent(BRegion* region) const
|
|
|
|
{
|
|
|
|
// remove scrolling offset and convert to parent coordinate space
|
|
|
|
region->OffsetBy(fScrollingOffset.x - fFrame.left,
|
|
|
|
fScrollingOffset.y - fFrame.top);
|
|
|
|
}
|
|
|
|
|
|
|
|
//! converts a point from local to screen coordinate system
|
|
|
|
void
|
|
|
|
ViewLayer::ConvertToScreen(BPoint* pt) const
|
|
|
|
{
|
|
|
|
ConvertToParent(pt);
|
|
|
|
|
|
|
|
if (fParent)
|
|
|
|
fParent->ConvertToScreen(pt);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! converts a rect from local to screen coordinate system
|
|
|
|
void
|
|
|
|
ViewLayer::ConvertToScreen(BRect* rect) const
|
|
|
|
{
|
2006-02-06 22:31:02 +03:00
|
|
|
BPoint offset(0.0, 0.0);
|
|
|
|
ConvertToScreen(&offset);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2006-02-06 22:31:02 +03:00
|
|
|
rect->OffsetBy(offset);
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! converts a region from local to screen coordinate system
|
|
|
|
void
|
2006-02-06 22:31:02 +03:00
|
|
|
ViewLayer::ConvertToScreen(BRegion* region) const
|
2005-12-08 15:41:19 +03:00
|
|
|
{
|
2006-02-06 22:31:02 +03:00
|
|
|
BPoint offset(0.0, 0.0);
|
|
|
|
ConvertToScreen(&offset);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2006-02-06 22:31:02 +03:00
|
|
|
region->OffsetBy(offset.x, offset.y);
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! converts a point from screen to local coordinate system
|
|
|
|
void
|
|
|
|
ViewLayer::ConvertFromScreen(BPoint* pt) const
|
|
|
|
{
|
|
|
|
ConvertFromParent(pt);
|
|
|
|
|
|
|
|
if (fParent)
|
|
|
|
fParent->ConvertFromScreen(pt);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! converts a rect from screen to local coordinate system
|
|
|
|
void
|
|
|
|
ViewLayer::ConvertFromScreen(BRect* rect) const
|
|
|
|
{
|
2006-02-06 22:31:02 +03:00
|
|
|
BPoint offset(0.0, 0.0);
|
|
|
|
ConvertFromScreen(&offset);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2006-02-06 22:31:02 +03:00
|
|
|
rect->OffsetBy(offset.x, offset.y);
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! converts a region from screen to local coordinate system
|
|
|
|
void
|
2006-02-06 22:31:02 +03:00
|
|
|
ViewLayer::ConvertFromScreen(BRegion* region) const
|
2005-12-08 15:41:19 +03:00
|
|
|
{
|
2006-02-06 22:31:02 +03:00
|
|
|
BPoint offset(0.0, 0.0);
|
|
|
|
ConvertFromScreen(&offset);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
2006-02-06 22:31:02 +03:00
|
|
|
region->OffsetBy(offset.x, offset.y);
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! converts a point from local *drawing* to screen coordinate system
|
|
|
|
void
|
|
|
|
ViewLayer::ConvertToScreenForDrawing(BPoint* point) const
|
|
|
|
{
|
|
|
|
fDrawState->Transform(point);
|
|
|
|
// NOTE: from here on, don't use the
|
|
|
|
// "*ForDrawing()" versions of the parent!
|
|
|
|
ConvertToScreen(point);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! converts a rect from local *drawing* to screen coordinate system
|
|
|
|
void
|
|
|
|
ViewLayer::ConvertToScreenForDrawing(BRect* rect) const
|
|
|
|
{
|
|
|
|
fDrawState->Transform(rect);
|
|
|
|
// NOTE: from here on, don't use the
|
|
|
|
// "*ForDrawing()" versions of the parent!
|
|
|
|
ConvertToScreen(rect);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! converts a region from local *drawing* to screen coordinate system
|
|
|
|
void
|
|
|
|
ViewLayer::ConvertToScreenForDrawing(BRegion* region) const
|
|
|
|
{
|
|
|
|
fDrawState->Transform(region);
|
|
|
|
// NOTE: from here on, don't use the
|
|
|
|
// "*ForDrawing()" versions of the parent!
|
|
|
|
ConvertToScreen(region);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! converts a point from screen to local coordinate system
|
|
|
|
void
|
|
|
|
ViewLayer::ConvertFromScreenForDrawing(BPoint* point) const
|
|
|
|
{
|
|
|
|
ConvertFromScreen(point);
|
|
|
|
fDrawState->InverseTransform(point);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ViewLayer::SetName(const char* string)
|
|
|
|
{
|
|
|
|
fName.SetTo(string);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark -
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ViewLayer::MoveBy(int32 x, int32 y, BRegion* dirtyRegion)
|
|
|
|
{
|
|
|
|
if (x == 0 && y == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
fFrame.OffsetBy(x, y);
|
|
|
|
|
|
|
|
// to move on screen, we must not be hidden and we must have a parent
|
|
|
|
if (fVisible && fParent && dirtyRegion) {
|
2006-02-09 15:42:08 +03:00
|
|
|
#if 1
|
2005-12-08 15:41:19 +03:00
|
|
|
// based on redraw on new location
|
|
|
|
// the place were we are now visible
|
|
|
|
BRect newVisibleBounds = Bounds();
|
|
|
|
// we can use the frame of the old
|
|
|
|
// local clipping to see which parts need invalidation
|
|
|
|
BRect oldVisibleBounds(Bounds());
|
|
|
|
oldVisibleBounds.OffsetBy(-x, -y);
|
|
|
|
ConvertToScreen(&oldVisibleBounds);
|
|
|
|
|
|
|
|
ConvertToVisibleInTopView(&newVisibleBounds);
|
|
|
|
|
|
|
|
dirtyRegion->Include(oldVisibleBounds);
|
|
|
|
// newVisibleBounds already is in screen coords
|
|
|
|
dirtyRegion->Include(newVisibleBounds);
|
|
|
|
#else
|
|
|
|
// blitting version, invalidates
|
|
|
|
// old contents
|
|
|
|
BRect oldVisibleBounds(Bounds());
|
|
|
|
oldVisibleBounds.OffsetBy(-x, -y);
|
|
|
|
ConvertToScreen(&oldVisibleBounds);
|
|
|
|
|
|
|
|
BRect newVisibleBounds(Bounds());
|
|
|
|
// NOTE: using ConvertToVisibleInTopView()
|
|
|
|
// instead of ConvertToScreen()! see below
|
|
|
|
ConvertToVisibleInTopView(&newVisibleBounds);
|
|
|
|
|
|
|
|
newVisibleBounds.OffsetBy(-x, -y);
|
|
|
|
|
|
|
|
// clipping oldVisibleBounds to newVisibleBounds
|
|
|
|
// makes sure we don't copy parts hidden under
|
|
|
|
// parent views
|
2006-04-07 23:14:25 +04:00
|
|
|
BRegion* region = fWindow->GetRegion();
|
|
|
|
if (region) {
|
|
|
|
region->Set(oldVisibleBounds & newVisibleBounds);
|
|
|
|
fWindow->CopyContents(region, x, y);
|
|
|
|
|
|
|
|
region->Set(oldVisibleBounds);
|
|
|
|
newVisibleBounds.OffsetBy(x, y);
|
|
|
|
region->Exclude(newVisibleBounds);
|
|
|
|
dirtyRegion->Include(dirty);
|
|
|
|
|
|
|
|
fWindow->RecycleRegion(region);
|
|
|
|
}
|
2005-12-08 15:41:19 +03:00
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fParent) {
|
|
|
|
// the top view's screen clipping does not change,
|
|
|
|
// because no parts are clipped away from parent
|
|
|
|
// views
|
|
|
|
_MoveScreenClipping(x, y, true);
|
|
|
|
} else {
|
|
|
|
// parts might have been revealed from underneath
|
|
|
|
// the parent, or might now be hidden underneath
|
|
|
|
// the parent, this is taken care of when building
|
|
|
|
// the screen clipping
|
|
|
|
InvalidateScreenClipping(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResizeBy
|
|
|
|
void
|
|
|
|
ViewLayer::ResizeBy(int32 x, int32 y, BRegion* dirtyRegion)
|
|
|
|
{
|
|
|
|
if (x == 0 && y == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
fFrame.right += x;
|
|
|
|
fFrame.bottom += y;
|
|
|
|
|
|
|
|
if (fVisible && dirtyRegion) {
|
|
|
|
BRect oldBounds(Bounds());
|
|
|
|
oldBounds.right -= x;
|
|
|
|
oldBounds.bottom -= y;
|
|
|
|
|
2006-04-07 23:14:25 +04:00
|
|
|
BRegion* dirty = fWindow->GetRegion();
|
|
|
|
if (!dirty)
|
|
|
|
return;
|
|
|
|
|
|
|
|
dirty->Set(Bounds());
|
|
|
|
dirty->Include(oldBounds);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
|
|
|
if (!(fFlags & B_FULL_UPDATE_ON_RESIZE)) {
|
|
|
|
// the dirty region is just the difference of
|
|
|
|
// old and new bounds
|
2006-04-07 23:14:25 +04:00
|
|
|
dirty->Exclude(oldBounds & Bounds());
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
InvalidateScreenClipping(true);
|
|
|
|
|
2006-04-07 23:14:25 +04:00
|
|
|
if (dirty->CountRects() > 0) {
|
2005-12-08 15:41:19 +03:00
|
|
|
// exclude children, they are expected to
|
|
|
|
// include their own dirty regions in ParentResized()
|
|
|
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) {
|
|
|
|
if (child->IsVisible()) {
|
|
|
|
BRect previousChildVisible(child->Frame() & oldBounds & Bounds());
|
2006-04-07 23:14:25 +04:00
|
|
|
if (dirty->Frame().Intersects(previousChildVisible)) {
|
|
|
|
dirty->Exclude(previousChildVisible);
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-07 23:14:25 +04:00
|
|
|
ConvertToScreen(dirty);
|
|
|
|
dirtyRegion->Include(dirty);
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
2006-04-07 23:14:25 +04:00
|
|
|
fWindow->RecycleRegion(dirty);
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// layout the children
|
|
|
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling())
|
|
|
|
child->ParentResized(x, y, dirtyRegion);
|
|
|
|
|
|
|
|
// at this point, children are at their new locations,
|
|
|
|
// so we can rebuild the clipping
|
|
|
|
// TODO: when the implementation of Hide() and Show() is
|
|
|
|
// complete, see if this should be avoided
|
|
|
|
RebuildClipping(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ParentResized
|
|
|
|
void
|
|
|
|
ViewLayer::ParentResized(int32 x, int32 y, BRegion* dirtyRegion)
|
|
|
|
{
|
|
|
|
uint16 rm = fResizeMode & 0x0000FFFF;
|
|
|
|
BRect newFrame = fFrame;
|
|
|
|
|
|
|
|
// follow with left side
|
|
|
|
if ((rm & 0x0F00U) == _VIEW_RIGHT_ << 8)
|
|
|
|
newFrame.left += x;
|
|
|
|
else if ((rm & 0x0F00U) == _VIEW_CENTER_ << 8)
|
|
|
|
newFrame.left += x / 2;
|
|
|
|
|
|
|
|
// follow with right side
|
|
|
|
if ((rm & 0x000FU) == _VIEW_RIGHT_)
|
|
|
|
newFrame.right += x;
|
|
|
|
else if ((rm & 0x000FU) == _VIEW_CENTER_)
|
|
|
|
newFrame.right += x / 2;
|
|
|
|
|
|
|
|
// follow with top side
|
|
|
|
if ((rm & 0xF000U) == _VIEW_BOTTOM_ << 12)
|
|
|
|
newFrame.top += y;
|
|
|
|
else if ((rm & 0xF000U) == _VIEW_CENTER_ << 12)
|
|
|
|
newFrame.top += y / 2;
|
|
|
|
|
|
|
|
// follow with bottom side
|
|
|
|
if ((rm & 0x00F0U) == _VIEW_BOTTOM_ << 4)
|
|
|
|
newFrame.bottom += y;
|
|
|
|
else if ((rm & 0x00F0U) == _VIEW_CENTER_ << 4)
|
|
|
|
newFrame.bottom += y / 2;
|
|
|
|
|
|
|
|
if (newFrame != fFrame) {
|
|
|
|
// careful, MoveBy will change fFrame
|
|
|
|
int32 widthDiff = (int32)(newFrame.Width() - fFrame.Width());
|
|
|
|
int32 heightDiff = (int32)(newFrame.Height() - fFrame.Height());
|
|
|
|
|
|
|
|
MoveBy(newFrame.left - fFrame.left,
|
|
|
|
newFrame.top - fFrame.top, dirtyRegion);
|
|
|
|
|
|
|
|
ResizeBy(widthDiff, heightDiff, dirtyRegion);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ScrollBy
|
|
|
|
void
|
|
|
|
ViewLayer::ScrollBy(int32 x, int32 y, BRegion* dirtyRegion)
|
|
|
|
{
|
|
|
|
// blitting version, invalidates
|
|
|
|
// old contents
|
|
|
|
|
|
|
|
// remember old bounds for tracking dirty region
|
|
|
|
BRect oldBounds(Bounds());
|
|
|
|
// find the area of the view that can be scrolled,
|
|
|
|
// contents are shifted in the opposite direction from scrolling
|
|
|
|
BRect stillVisibleBounds(oldBounds);
|
|
|
|
stillVisibleBounds.OffsetBy(x, y);
|
|
|
|
|
|
|
|
// NOTE: using ConvertToVisibleInTopView()
|
|
|
|
// instead of ConvertToScreen(), this makes
|
|
|
|
// sure we don't try to move or invalidate an
|
|
|
|
// area hidden underneath the parent view
|
|
|
|
ConvertToVisibleInTopView(&oldBounds);
|
|
|
|
ConvertToVisibleInTopView(&stillVisibleBounds);
|
|
|
|
|
|
|
|
fScrollingOffset.x += x;
|
|
|
|
fScrollingOffset.y += y;
|
|
|
|
|
|
|
|
// do the blit, this will make sure
|
|
|
|
// that other more complex dirty regions
|
|
|
|
// are taken care of
|
2006-04-19 18:12:57 +04:00
|
|
|
BRegion* copyRegion = fWindow->GetRegion();
|
|
|
|
if (!copyRegion)
|
|
|
|
return;
|
|
|
|
copyRegion->Set(stillVisibleBounds);
|
|
|
|
fWindow->CopyContents(copyRegion, -x, -y);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
|
|
|
// find the dirty region as far as we are
|
|
|
|
// concerned
|
2006-04-19 18:12:57 +04:00
|
|
|
BRegion* dirty = copyRegion;
|
|
|
|
// reuse copyRegion and call it dirty
|
2006-04-07 23:14:25 +04:00
|
|
|
|
|
|
|
dirty->Set(oldBounds);
|
2005-12-08 15:41:19 +03:00
|
|
|
stillVisibleBounds.OffsetBy(-x, -y);
|
2006-04-07 23:14:25 +04:00
|
|
|
dirty->Exclude(stillVisibleBounds);
|
|
|
|
dirtyRegion->Include(dirty);
|
|
|
|
|
|
|
|
fWindow->RecycleRegion(dirty);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
|
|
|
// the screen clipping of this view and it's
|
|
|
|
// childs is no longer valid
|
|
|
|
InvalidateScreenClipping(true);
|
|
|
|
RebuildClipping(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ViewLayer::CopyBits(BRect src, BRect dst, BRegion& windowContentClipping)
|
|
|
|
{
|
|
|
|
if (!fVisible || !fWindow)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// TODO: confirm that in R5 this call is affected by origin and scale
|
|
|
|
|
|
|
|
// blitting version
|
|
|
|
|
|
|
|
int32 xOffset = (int32)(dst.left - src.left);
|
|
|
|
int32 yOffset = (int32)(dst.top - src.top);
|
|
|
|
|
|
|
|
// figure out which part can be blittet
|
|
|
|
BRect visibleSrc(src);
|
|
|
|
ConvertToVisibleInTopView(&visibleSrc);
|
|
|
|
|
|
|
|
BRect visibleSrcAtDest(src);
|
|
|
|
visibleSrcAtDest.OffsetBy(xOffset, yOffset);
|
|
|
|
ConvertToVisibleInTopView(&visibleSrcAtDest);
|
|
|
|
|
|
|
|
// clip src to visible at dest
|
|
|
|
visibleSrcAtDest.OffsetBy(-xOffset, -yOffset);
|
|
|
|
visibleSrc = visibleSrc & visibleSrcAtDest;
|
|
|
|
|
|
|
|
// do the blit, this will make sure
|
|
|
|
// that other more complex dirty regions
|
|
|
|
// are taken care of
|
2006-04-19 18:12:57 +04:00
|
|
|
BRegion* copyRegion = fWindow->GetRegion();
|
|
|
|
if (!copyRegion)
|
|
|
|
return;
|
|
|
|
|
|
|
|
copyRegion->Set(visibleSrc);
|
|
|
|
copyRegion->IntersectWith(&ScreenClipping(&windowContentClipping));
|
|
|
|
fWindow->CopyContents(copyRegion, xOffset, yOffset);
|
2005-12-08 15:41:19 +03:00
|
|
|
|
|
|
|
// find the dirty region as far as we are concerned
|
|
|
|
BRect dirtyDst(dst);
|
|
|
|
ConvertToVisibleInTopView(&dirtyDst);
|
|
|
|
|
2006-04-19 18:12:57 +04:00
|
|
|
BRegion* dirty = copyRegion;
|
|
|
|
// reuse copyRegion and call it "dirty"
|
2006-04-07 23:14:25 +04:00
|
|
|
|
|
|
|
dirty->Set(dirtyDst);
|
2005-12-08 15:41:19 +03:00
|
|
|
// exclude the part that we could copy
|
|
|
|
visibleSrc.OffsetBy(xOffset, yOffset);
|
2006-04-07 23:14:25 +04:00
|
|
|
dirty->Exclude(visibleSrc);
|
|
|
|
dirty->IntersectWith(&ScreenClipping(&windowContentClipping));
|
|
|
|
fWindow->MarkContentDirty(*dirty);
|
|
|
|
|
|
|
|
fWindow->RecycleRegion(dirty);
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark -
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ViewLayer::PushState()
|
|
|
|
{
|
|
|
|
fDrawState = fDrawState->PushState();
|
|
|
|
fDrawState->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ViewLayer::PopState()
|
|
|
|
{
|
|
|
|
if (fDrawState->PreviousState() == NULL) {
|
|
|
|
fprintf(stderr, "WARNING: User called BView(%s)::PopState(), "
|
|
|
|
"but there is NO state on stack!\n", Name());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rebuildClipping = fDrawState->ClippingRegion() != NULL;
|
|
|
|
|
|
|
|
fDrawState = fDrawState->PopState();
|
|
|
|
fDrawState->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE);
|
|
|
|
|
|
|
|
// rebuild clipping
|
|
|
|
// (the clipping from the popped state is not effective anymore)
|
|
|
|
if (rebuildClipping)
|
|
|
|
RebuildClipping(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ViewLayer::SetEventMask(uint32 eventMask, uint32 options)
|
|
|
|
{
|
|
|
|
fEventMask = eventMask;
|
|
|
|
fEventOptions = options;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-02 23:19:29 +03:00
|
|
|
void
|
|
|
|
ViewLayer::SetCursor(ServerCursor *cursor)
|
|
|
|
{
|
2006-02-26 21:15:31 +03:00
|
|
|
if (cursor != fCursor) {
|
|
|
|
if (fCursor)
|
|
|
|
fCursor->Release();
|
|
|
|
|
|
|
|
fCursor = cursor;
|
|
|
|
|
|
|
|
if (fCursor) {
|
|
|
|
fCursor->Acquire();
|
|
|
|
fCursor->SetPendingViewCursor(false);
|
|
|
|
}
|
|
|
|
}
|
2006-02-02 23:19:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-03 13:30:08 +03:00
|
|
|
void
|
|
|
|
ViewLayer::SetPicture(ServerPicture *picture)
|
|
|
|
{
|
|
|
|
fPicture = picture;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ServerPicture *
|
|
|
|
ViewLayer::Picture() const
|
|
|
|
{
|
|
|
|
return fPicture;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
void
|
|
|
|
ViewLayer::Draw(DrawingEngine* drawingEngine, BRegion* effectiveClipping,
|
|
|
|
BRegion* windowContentClipping, bool deep)
|
|
|
|
{
|
2006-02-13 16:43:30 +03:00
|
|
|
if (!fVisible) {
|
|
|
|
// child views cannot be visible either
|
2006-01-03 13:19:20 +03:00
|
|
|
return;
|
2006-02-13 16:43:30 +03:00
|
|
|
}
|
2006-01-03 13:19:20 +03:00
|
|
|
|
2005-12-29 22:30:48 +03:00
|
|
|
if (fViewBitmap != NULL || !fViewColor.IsTransparentMagic()) {
|
|
|
|
// we can only draw within our own area
|
2006-04-19 18:12:57 +04:00
|
|
|
BRegion* redraw = fWindow->GetRegion(ScreenClipping(windowContentClipping));
|
|
|
|
if (!redraw)
|
|
|
|
return;
|
2005-12-29 22:30:48 +03:00
|
|
|
// add the current clipping
|
2006-04-19 18:12:57 +04:00
|
|
|
redraw->IntersectWith(effectiveClipping);
|
2006-02-13 16:43:30 +03:00
|
|
|
|
2005-12-29 22:30:48 +03:00
|
|
|
if (fViewBitmap != NULL) {
|
|
|
|
// draw view bitmap
|
|
|
|
// TODO: support other options!
|
|
|
|
BRect rect = fBitmapDestination;
|
|
|
|
ConvertToScreenForDrawing(&rect);
|
2006-02-13 16:43:30 +03:00
|
|
|
|
2006-04-19 18:12:57 +04:00
|
|
|
align_rect_to_pixels(&rect);
|
|
|
|
|
|
|
|
if (fBitmapOptions & B_TILE_BITMAP_Y) {
|
|
|
|
// move rect up as much as needed
|
|
|
|
while (rect.top > redraw->Frame().top)
|
|
|
|
rect.OffsetBy(0.0, -(rect.Height() + 1));
|
|
|
|
}
|
|
|
|
if (fBitmapOptions & B_TILE_BITMAP_X) {
|
|
|
|
// move rect left as much as needed
|
|
|
|
while (rect.left > redraw->Frame().left)
|
|
|
|
rect.OffsetBy(-(rect.Width() + 1), 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX: locking removed because the WindowLayer keeps the engine locked
|
|
|
|
// because it keeps track of syncing right now
|
|
|
|
|
2005-12-29 22:30:48 +03:00
|
|
|
// lock the drawing engine for as long as we need the clipping
|
|
|
|
// to be valid
|
2006-04-19 18:12:57 +04:00
|
|
|
if (rect.IsValid()/* && drawingEngine->Lock()*/) {
|
|
|
|
drawingEngine->ConstrainClippingRegion(redraw);
|
2005-12-29 22:30:48 +03:00
|
|
|
|
|
|
|
DrawState defaultDrawState;
|
2006-04-19 18:12:57 +04:00
|
|
|
|
|
|
|
if (fBitmapOptions & B_TILE_BITMAP) {
|
|
|
|
// tile across entire view
|
|
|
|
float start = rect.left;
|
|
|
|
while (rect.top < redraw->Frame().bottom) {
|
|
|
|
while (rect.left < redraw->Frame().right) {
|
|
|
|
drawingEngine->DrawBitmap(fViewBitmap, fBitmapSource,
|
|
|
|
rect, &defaultDrawState);
|
|
|
|
rect.OffsetBy(rect.Width() + 1, 0.0);
|
|
|
|
}
|
|
|
|
rect.OffsetBy(start - rect.left, rect.Height() + 1);
|
|
|
|
}
|
|
|
|
// nothing left to be drawn
|
|
|
|
redraw->MakeEmpty();
|
|
|
|
|
|
|
|
} else if (fBitmapOptions & B_TILE_BITMAP_X) {
|
|
|
|
// tile in x direction
|
|
|
|
while (rect.left < redraw->Frame().right) {
|
|
|
|
drawingEngine->DrawBitmap(fViewBitmap, fBitmapSource,
|
|
|
|
rect, &defaultDrawState);
|
|
|
|
rect.OffsetBy(rect.Width() + 1, 0.0);
|
|
|
|
}
|
|
|
|
// remove horizontal stripe from clipping
|
|
|
|
rect.left = redraw->Frame().left;
|
|
|
|
rect.right = redraw->Frame().right;
|
|
|
|
redraw->Exclude(rect);
|
|
|
|
|
|
|
|
} else if (fBitmapOptions & B_TILE_BITMAP_Y) {
|
|
|
|
// tile in y direction
|
|
|
|
while (rect.top < redraw->Frame().bottom) {
|
|
|
|
drawingEngine->DrawBitmap(fViewBitmap, fBitmapSource,
|
|
|
|
rect, &defaultDrawState);
|
|
|
|
rect.OffsetBy(0.0, rect.Height() + 1);
|
|
|
|
}
|
|
|
|
// remove vertical stripe from clipping
|
|
|
|
rect.top = redraw->Frame().top;
|
|
|
|
rect.bottom = redraw->Frame().bottom;
|
|
|
|
redraw->Exclude(rect);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// no tiling at all
|
|
|
|
drawingEngine->DrawBitmap(fViewBitmap, fBitmapSource,
|
|
|
|
rect, &defaultDrawState);
|
|
|
|
redraw->Exclude(rect);
|
|
|
|
}
|
|
|
|
|
2005-12-29 22:30:48 +03:00
|
|
|
// NOTE: It is ok not to reset the clipping, that
|
|
|
|
// would only waste time
|
2006-04-19 18:12:57 +04:00
|
|
|
// drawingEngine->Unlock();
|
2005-12-29 22:30:48 +03:00
|
|
|
}
|
2006-02-13 16:43:30 +03:00
|
|
|
|
2005-12-29 22:30:48 +03:00
|
|
|
}
|
2006-02-13 16:43:30 +03:00
|
|
|
|
2005-12-29 22:30:48 +03:00
|
|
|
if (!fViewColor.IsTransparentMagic()) {
|
|
|
|
// fill visible region with view color,
|
|
|
|
// this version of FillRegion ignores any
|
|
|
|
// clipping, that's why "redraw" needs to
|
|
|
|
// be correct
|
2006-04-19 18:12:57 +04:00
|
|
|
drawingEngine->FillRegion(*redraw, fViewColor);
|
2005-12-29 22:30:48 +03:00
|
|
|
}
|
2006-04-19 18:12:57 +04:00
|
|
|
|
|
|
|
fWindow->RecycleRegion(redraw);
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
|
|
|
|
2005-12-21 01:31:42 +03:00
|
|
|
fBackgroundDirty = false;
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
// let children draw
|
|
|
|
if (deep) {
|
|
|
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) {
|
|
|
|
child->Draw(drawingEngine, effectiveClipping,
|
|
|
|
windowContentClipping, deep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-14 01:05:49 +03:00
|
|
|
void
|
|
|
|
ViewLayer::MouseDown(BMessage* message, BPoint where)
|
|
|
|
{
|
|
|
|
// empty hook methods
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ViewLayer::MouseUp(BMessage* message, BPoint where)
|
|
|
|
{
|
|
|
|
// empty hook methods
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ViewLayer::MouseMoved(BMessage* message, BPoint where)
|
|
|
|
{
|
|
|
|
// empty hook methods
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
// #pragma mark -
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ViewLayer::SetHidden(bool hidden)
|
|
|
|
{
|
|
|
|
if (fHidden != hidden) {
|
|
|
|
fHidden = hidden;
|
|
|
|
|
|
|
|
// recurse into children and update their visible flag
|
|
|
|
if (fParent) {
|
|
|
|
bool oldVisible = fVisible;
|
|
|
|
UpdateVisibleDeep(fParent->IsVisible());
|
|
|
|
if (oldVisible != fVisible) {
|
2006-02-17 00:58:22 +03:00
|
|
|
// Include or exclude us from the parent area, and update the
|
|
|
|
// children's clipping as well when the view will be visible
|
|
|
|
fParent->RebuildClipping(!hidden);
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
if (fWindow) {
|
|
|
|
// trigger a redraw
|
|
|
|
BRect clippedBounds = Bounds();
|
|
|
|
ConvertToVisibleInTopView(&clippedBounds);
|
2006-04-07 23:14:25 +04:00
|
|
|
BRegion* dirty = fWindow->GetRegion();
|
|
|
|
if (!dirty)
|
|
|
|
return;
|
|
|
|
dirty->Set(clippedBounds);
|
|
|
|
fWindow->MarkContentDirty(*dirty);
|
|
|
|
fWindow->RecycleRegion(dirty);
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
UpdateVisibleDeep(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsHidden
|
|
|
|
bool
|
|
|
|
ViewLayer::IsHidden() const
|
|
|
|
{
|
|
|
|
return fHidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
// UpdateVisibleDeep
|
|
|
|
void
|
|
|
|
ViewLayer::UpdateVisibleDeep(bool parentVisible)
|
|
|
|
{
|
|
|
|
fVisible = parentVisible && !fHidden;
|
|
|
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling())
|
|
|
|
child->UpdateVisibleDeep(fVisible);
|
|
|
|
}
|
|
|
|
|
2005-12-21 01:31:42 +03:00
|
|
|
// MarkBackgroundDirty
|
|
|
|
void
|
|
|
|
ViewLayer::MarkBackgroundDirty()
|
|
|
|
{
|
|
|
|
fBackgroundDirty = true;
|
|
|
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling())
|
|
|
|
child->MarkBackgroundDirty();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// AddTokensForLayersInRegion
|
|
|
|
void
|
|
|
|
ViewLayer::AddTokensForLayersInRegion(BMessage* message,
|
|
|
|
BRegion& region,
|
|
|
|
BRegion* windowContentClipping)
|
|
|
|
{
|
2006-02-06 22:31:02 +03:00
|
|
|
if (!fVisible)
|
|
|
|
return;
|
|
|
|
|
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
|
|
|
if (region.Intersects(ScreenClipping(windowContentClipping).Frame()))
|
|
|
|
message->AddInt32("_token", fToken);
|
|
|
|
|
|
|
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling())
|
|
|
|
child->AddTokensForLayersInRegion(message, region,
|
|
|
|
windowContentClipping);
|
|
|
|
}
|
|
|
|
|
2006-02-06 13:28:30 +03:00
|
|
|
// AddTokensForLayersInRegion
|
|
|
|
void
|
|
|
|
ViewLayer::AddTokensForLayersInRegion(BPrivate::PortLink& link,
|
|
|
|
BRegion& region,
|
|
|
|
BRegion* windowContentClipping)
|
|
|
|
{
|
2006-02-06 22:31:02 +03:00
|
|
|
if (!fVisible)
|
|
|
|
return;
|
|
|
|
|
2006-02-06 13:28:30 +03:00
|
|
|
if (region.Intersects(ScreenClipping(windowContentClipping).Frame()))
|
|
|
|
link.Attach<int32>(fToken);
|
|
|
|
|
|
|
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling())
|
|
|
|
child->AddTokensForLayersInRegion(link, region,
|
|
|
|
windowContentClipping);
|
|
|
|
}
|
|
|
|
|
2005-12-08 15:41:19 +03:00
|
|
|
// PrintToStream
|
|
|
|
void
|
|
|
|
ViewLayer::PrintToStream() const
|
|
|
|
{
|
|
|
|
printf("ViewLayer: %s\n", Name());
|
|
|
|
printf(" fToken: %ld\n", fToken);
|
|
|
|
printf(" fFrame: BRect(%.1f, %.1f, %.1f, %.1f)\n", fFrame.left, fFrame.top, fFrame.right, fFrame.bottom);
|
|
|
|
printf(" fScrollingOffset: BPoint(%.1f, %.1f)\n", fScrollingOffset.x, fScrollingOffset.y);
|
|
|
|
printf(" fHidden: %d\n", fHidden);
|
|
|
|
printf(" fVisible: %d\n", fVisible);
|
|
|
|
printf(" fWindow: %p\n", fWindow);
|
|
|
|
printf(" fParent: %p\n", fParent);
|
|
|
|
printf(" fLocalClipping:\n");
|
|
|
|
fLocalClipping.PrintToStream();
|
|
|
|
printf(" fScreenClipping:\n");
|
|
|
|
fScreenClipping.PrintToStream();
|
|
|
|
printf(" valid: %d\n", fScreenClippingValid);
|
|
|
|
printf(" state:\n");
|
|
|
|
printf(" user clipping: %p\n", fDrawState->ClippingRegion());
|
|
|
|
printf(" origin: BPoint(%.1f, %.1f)\n", fDrawState->Origin().x, fDrawState->Origin().y);
|
|
|
|
printf(" scale: %.2f\n", fDrawState->Scale());
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
// RebuildClipping
|
|
|
|
void
|
|
|
|
ViewLayer::RebuildClipping(bool deep)
|
|
|
|
{
|
|
|
|
// the clipping spans over the bounds area
|
|
|
|
fLocalClipping.Set(Bounds());
|
|
|
|
|
|
|
|
// exclude all childs from the clipping
|
|
|
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) {
|
|
|
|
if (child->IsVisible())
|
|
|
|
fLocalClipping.Exclude(child->Frame());
|
|
|
|
|
|
|
|
if (deep)
|
|
|
|
child->RebuildClipping(deep);
|
|
|
|
}
|
|
|
|
|
|
|
|
// add the user clipping in case there is one
|
|
|
|
if (const BRegion* userClipping = fDrawState->ClippingRegion()) {
|
|
|
|
// NOTE: in case the user sets a user defined clipping region,
|
|
|
|
// rebuilding the clipping is a bit more expensive because there
|
|
|
|
// is no separate "drawing region"... on the other
|
|
|
|
// hand, views for which this feature is actually used will
|
|
|
|
// probably not have any children, so it is not that expensive
|
|
|
|
// after all
|
2006-04-19 18:12:57 +04:00
|
|
|
BRegion* screenUserClipping = fWindow->GetRegion(*userClipping);
|
|
|
|
if (!screenUserClipping)
|
|
|
|
return;
|
|
|
|
fDrawState->Transform(screenUserClipping);
|
|
|
|
fLocalClipping.IntersectWith(screenUserClipping);
|
|
|
|
fWindow->RecycleRegion(screenUserClipping);
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fScreenClippingValid = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ScreenClipping
|
|
|
|
BRegion&
|
|
|
|
ViewLayer::ScreenClipping(BRegion* windowContentClipping, bool force) const
|
|
|
|
{
|
|
|
|
if (!fScreenClippingValid || force) {
|
|
|
|
fScreenClipping = fLocalClipping;
|
|
|
|
ConvertToScreen(&fScreenClipping);
|
|
|
|
|
|
|
|
// see if we parts of our bounds are hidden underneath
|
|
|
|
// the parent, the local clipping does not account for this
|
|
|
|
BRect clippedBounds = Bounds();
|
|
|
|
ConvertToVisibleInTopView(&clippedBounds);
|
|
|
|
if (clippedBounds.Width() < fScreenClipping.Frame().Width() ||
|
|
|
|
clippedBounds.Height() < fScreenClipping.Frame().Height()) {
|
2006-04-19 18:12:57 +04:00
|
|
|
BRegion* temp = fWindow->GetRegion();
|
|
|
|
if (temp) {
|
|
|
|
temp->Set(clippedBounds);
|
|
|
|
fScreenClipping.IntersectWith(temp);
|
|
|
|
fWindow->RecycleRegion(temp);
|
|
|
|
}
|
2005-12-08 15:41:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fScreenClipping.IntersectWith(windowContentClipping);
|
|
|
|
fScreenClippingValid = true;
|
|
|
|
}
|
|
|
|
//printf("###ViewLayer(%s)::ScreenClipping():\n", Name());
|
|
|
|
//fScreenClipping.PrintToStream();
|
|
|
|
return fScreenClipping;
|
|
|
|
}
|
|
|
|
|
|
|
|
// InvalidateScreenClipping
|
|
|
|
void
|
|
|
|
ViewLayer::InvalidateScreenClipping(bool deep)
|
|
|
|
{
|
|
|
|
fScreenClippingValid = false;
|
|
|
|
if (deep) {
|
|
|
|
// invalidate the childrens screen clipping as well
|
|
|
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) {
|
|
|
|
child->InvalidateScreenClipping(deep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// _MoveScreenClipping
|
|
|
|
void
|
|
|
|
ViewLayer::_MoveScreenClipping(int32 x, int32 y, bool deep)
|
|
|
|
{
|
|
|
|
if (fScreenClippingValid)
|
|
|
|
fScreenClipping.OffsetBy(x, y);
|
|
|
|
|
|
|
|
if (deep) {
|
|
|
|
// move the childrens screen clipping as well
|
|
|
|
for (ViewLayer* child = FirstChild(); child; child = child->NextSibling()) {
|
|
|
|
child->_MoveScreenClipping(x, y, deep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|