implemented hooks for resizing and moving operations. BViews now resize corectly in Playground app. Ignore the Convert*() stuff.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13399 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1117,115 +1117,169 @@ Layer::Scale() const
|
|||||||
BPoint
|
BPoint
|
||||||
Layer::ConvertToParent(BPoint pt)
|
Layer::ConvertToParent(BPoint pt)
|
||||||
{
|
{
|
||||||
|
#ifndef NEW_CLIPPING
|
||||||
pt -= BoundsOrigin();
|
pt -= BoundsOrigin();
|
||||||
pt += fFrame.LeftTop();
|
pt += fFrame.LeftTop();
|
||||||
return pt;
|
return pt;
|
||||||
|
#else
|
||||||
|
ConvertToParent2(&pt);
|
||||||
|
return pt;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Converts the passed rectangle to parent coordinates
|
//! Converts the passed rectangle to parent coordinates
|
||||||
BRect
|
BRect
|
||||||
Layer::ConvertToParent(BRect rect)
|
Layer::ConvertToParent(BRect rect)
|
||||||
{
|
{
|
||||||
|
#ifndef NEW_CLIPPING
|
||||||
// rect.OffsetBy(fFrame.LeftTop());
|
// rect.OffsetBy(fFrame.LeftTop());
|
||||||
// return rect;
|
// return rect;
|
||||||
rect.OffsetBy(-BoundsOrigin().x, -BoundsOrigin().y);
|
rect.OffsetBy(-BoundsOrigin().x, -BoundsOrigin().y);
|
||||||
rect.OffsetBy(fFrame.LeftTop());
|
rect.OffsetBy(fFrame.LeftTop());
|
||||||
return rect;
|
return rect;
|
||||||
|
#else
|
||||||
|
ConvertToParent2(&rect);
|
||||||
|
return rect;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Converts the passed region to parent coordinates
|
//! Converts the passed region to parent coordinates
|
||||||
BRegion
|
BRegion
|
||||||
Layer::ConvertToParent(BRegion* reg)
|
Layer::ConvertToParent(BRegion* reg)
|
||||||
{
|
{
|
||||||
|
#ifndef NEW_CLIPPING
|
||||||
// TODO: wouldn't it be more efficient to use the copy
|
// TODO: wouldn't it be more efficient to use the copy
|
||||||
// constructor for BRegion and then call OffsetBy()?
|
// constructor for BRegion and then call OffsetBy()?
|
||||||
BRegion newreg;
|
BRegion newreg;
|
||||||
for (int32 i = 0; i < reg->CountRects(); i++)
|
for (int32 i = 0; i < reg->CountRects(); i++)
|
||||||
newreg.Include(ConvertToParent(reg->RectAt(i)));
|
newreg.Include(ConvertToParent(reg->RectAt(i)));
|
||||||
return newreg;
|
return newreg;
|
||||||
|
#else
|
||||||
|
BRegion newReg(*reg);
|
||||||
|
ConvertToParent2(&newReg);
|
||||||
|
return newReg;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Converts the passed point from parent coordinates
|
//! Converts the passed point from parent coordinates
|
||||||
BPoint
|
BPoint
|
||||||
Layer::ConvertFromParent(BPoint pt)
|
Layer::ConvertFromParent(BPoint pt)
|
||||||
{
|
{
|
||||||
|
#ifndef NEW_CLIPPING
|
||||||
// return pt - fFrame.LeftTop();
|
// return pt - fFrame.LeftTop();
|
||||||
pt -= fFrame.LeftTop();
|
pt -= fFrame.LeftTop();
|
||||||
pt += BoundsOrigin();
|
pt += BoundsOrigin();
|
||||||
return pt;
|
return pt;
|
||||||
|
#else
|
||||||
|
ConvertFromParent2(&pt);
|
||||||
|
return pt;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Converts the passed rectangle from parent coordinates
|
//! Converts the passed rectangle from parent coordinates
|
||||||
BRect
|
BRect
|
||||||
Layer::ConvertFromParent(BRect rect)
|
Layer::ConvertFromParent(BRect rect)
|
||||||
{
|
{
|
||||||
|
#ifndef NEW_CLIPPING
|
||||||
// rect.OffsetBy(-fFrame.left, -fFrame.top);
|
// rect.OffsetBy(-fFrame.left, -fFrame.top);
|
||||||
// return rect;
|
// return rect;
|
||||||
rect.OffsetBy(-fFrame.left, -fFrame.top);
|
rect.OffsetBy(-fFrame.left, -fFrame.top);
|
||||||
rect.OffsetBy(BoundsOrigin());
|
rect.OffsetBy(BoundsOrigin());
|
||||||
return rect;
|
return rect;
|
||||||
|
#else
|
||||||
|
ConvertFromParent2(&rect);
|
||||||
|
return rect;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Converts the passed region from parent coordinates
|
//! Converts the passed region from parent coordinates
|
||||||
BRegion
|
BRegion
|
||||||
Layer::ConvertFromParent(BRegion *reg)
|
Layer::ConvertFromParent(BRegion *reg)
|
||||||
{
|
{
|
||||||
|
#ifndef NEW_CLIPPING
|
||||||
BRegion newreg;
|
BRegion newreg;
|
||||||
for(int32 i=0; i<reg->CountRects();i++)
|
for(int32 i=0; i<reg->CountRects();i++)
|
||||||
newreg.Include(ConvertFromParent(reg->RectAt(i)));
|
newreg.Include(ConvertFromParent(reg->RectAt(i)));
|
||||||
return newreg;
|
return newreg;
|
||||||
|
#else
|
||||||
|
BRegion newReg(*reg);
|
||||||
|
ConvertFromParent2(&newReg);
|
||||||
|
return newReg;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConvertToTop
|
// ConvertToTop
|
||||||
BPoint
|
BPoint
|
||||||
Layer::ConvertToTop(BPoint pt)
|
Layer::ConvertToTop(BPoint pt)
|
||||||
{
|
{
|
||||||
|
#ifndef NEW_CLIPPING
|
||||||
if (fParent) {
|
if (fParent) {
|
||||||
// return (fParent->ConvertToTop(pt + fFrame.LeftTop()));
|
// return (fParent->ConvertToTop(pt + fFrame.LeftTop()));
|
||||||
pt = ConvertToParent(pt);
|
pt = ConvertToParent(pt);
|
||||||
return fParent->ConvertToTop(pt);
|
return fParent->ConvertToTop(pt);
|
||||||
} else
|
} else
|
||||||
return pt;
|
return pt;
|
||||||
|
#else
|
||||||
|
ConvertToScreen2(&pt);
|
||||||
|
return pt;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Converts the passed rectangle to screen coordinates
|
//! Converts the passed rectangle to screen coordinates
|
||||||
BRect
|
BRect
|
||||||
Layer::ConvertToTop(BRect rect)
|
Layer::ConvertToTop(BRect rect)
|
||||||
{
|
{
|
||||||
|
#ifndef NEW_CLIPPING
|
||||||
if (fParent) {
|
if (fParent) {
|
||||||
// return fParent->ConvertToTop(rect.OffsetByCopy(fFrame.LeftTop()));
|
// return fParent->ConvertToTop(rect.OffsetByCopy(fFrame.LeftTop()));
|
||||||
rect = ConvertToParent(rect);
|
rect = ConvertToParent(rect);
|
||||||
return fParent->ConvertToTop(rect);
|
return fParent->ConvertToTop(rect);
|
||||||
} else
|
} else
|
||||||
return rect;
|
return rect;
|
||||||
|
#else
|
||||||
|
ConvertToScreen2(&rect);
|
||||||
|
return rect;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Converts the passed region to screen coordinates
|
//! Converts the passed region to screen coordinates
|
||||||
BRegion
|
BRegion
|
||||||
Layer::ConvertToTop(BRegion *reg)
|
Layer::ConvertToTop(BRegion *reg)
|
||||||
{
|
{
|
||||||
|
#ifndef NEW_CLIPPING
|
||||||
BRegion newreg;
|
BRegion newreg;
|
||||||
for (int32 i = 0; i < reg->CountRects();i++)
|
for (int32 i = 0; i < reg->CountRects();i++)
|
||||||
newreg.Include(ConvertToTop(reg->RectAt(i)));
|
newreg.Include(ConvertToTop(reg->RectAt(i)));
|
||||||
return newreg;
|
return newreg;
|
||||||
|
#else
|
||||||
|
BRegion newReg(*reg);
|
||||||
|
ConvertToScreen2(&newReg);
|
||||||
|
return newReg;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConvertFromTop
|
// ConvertFromTop
|
||||||
BPoint
|
BPoint
|
||||||
Layer::ConvertFromTop(BPoint pt)
|
Layer::ConvertFromTop(BPoint pt)
|
||||||
{
|
{
|
||||||
|
#ifndef NEW_CLIPPING
|
||||||
if (fParent) {
|
if (fParent) {
|
||||||
// return fParent->ConvertFromTop(pt-fFrame.LeftTop());
|
// return fParent->ConvertFromTop(pt-fFrame.LeftTop());
|
||||||
pt = ConvertFromParent(pt);
|
pt = ConvertFromParent(pt);
|
||||||
return fParent->ConvertFromTop(pt);
|
return fParent->ConvertFromTop(pt);
|
||||||
} else
|
} else
|
||||||
return pt;
|
return pt;
|
||||||
|
#else
|
||||||
|
ConvertFromScreen2(&pt);
|
||||||
|
return pt;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Converts the passed rectangle from screen coordinates
|
//! Converts the passed rectangle from screen coordinates
|
||||||
BRect
|
BRect
|
||||||
Layer::ConvertFromTop(BRect rect)
|
Layer::ConvertFromTop(BRect rect)
|
||||||
{
|
{
|
||||||
|
#ifndef NEW_CLIPPING
|
||||||
if (fParent) {
|
if (fParent) {
|
||||||
// return fParent->ConvertFromTop(rect.OffsetByCopy(-fFrame.LeftTop().x,
|
// return fParent->ConvertFromTop(rect.OffsetByCopy(-fFrame.LeftTop().x,
|
||||||
// -fFrame.LeftTop().y));
|
// -fFrame.LeftTop().y));
|
||||||
@@ -1233,24 +1287,35 @@ Layer::ConvertFromTop(BRect rect)
|
|||||||
return fParent->ConvertFromTop(rect);
|
return fParent->ConvertFromTop(rect);
|
||||||
} else
|
} else
|
||||||
return rect;
|
return rect;
|
||||||
|
#else
|
||||||
|
ConvertFromScreen2(&rect);
|
||||||
|
return rect;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Converts the passed region from screen coordinates
|
//! Converts the passed region from screen coordinates
|
||||||
BRegion
|
BRegion
|
||||||
Layer::ConvertFromTop(BRegion *reg)
|
Layer::ConvertFromTop(BRegion *reg)
|
||||||
{
|
{
|
||||||
|
#ifndef NEW_CLIPPING
|
||||||
BRegion newreg;
|
BRegion newreg;
|
||||||
|
|
||||||
for (int32 i = 0; i < reg->CountRects(); i++)
|
for (int32 i = 0; i < reg->CountRects(); i++)
|
||||||
newreg.Include(ConvertFromTop(reg->RectAt(i)));
|
newreg.Include(ConvertFromTop(reg->RectAt(i)));
|
||||||
|
|
||||||
return newreg;
|
return newreg;
|
||||||
|
#else
|
||||||
|
BRegion newReg(*reg);
|
||||||
|
ConvertFromScreen2(&newReg);
|
||||||
|
return newReg;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Recursively deletes all children of the calling layer
|
//! Recursively deletes all children of the calling layer
|
||||||
void
|
void
|
||||||
Layer::PruneTree(void)
|
Layer::PruneTree(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
Layer* lay;
|
Layer* lay;
|
||||||
Layer* nextlay;
|
Layer* nextlay;
|
||||||
|
|
||||||
@@ -1756,6 +1821,37 @@ Layer::do_CopyBits(BRect& src, BRect& dst, int32 xOffset, int32 yOffset) {
|
|||||||
|
|
||||||
#ifdef NEW_CLIPPING
|
#ifdef NEW_CLIPPING
|
||||||
|
|
||||||
|
void
|
||||||
|
Layer::MovedByHook(float dx, float dy)
|
||||||
|
{
|
||||||
|
if (Window() && Flags() & B_FRAME_EVENTS && !IsTopLayer()) {
|
||||||
|
BMessage msg(B_VIEW_MOVED);
|
||||||
|
msg.AddInt64("when", system_time());
|
||||||
|
msg.AddPoint("where", Frame().LeftTop());
|
||||||
|
Window()->SendMessageToClient(&msg, fViewToken, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Layer::ResizedByHook(float dx, float dy, bool automatic)
|
||||||
|
{
|
||||||
|
if (Window() && Flags() & B_FRAME_EVENTS && !IsTopLayer()) {
|
||||||
|
BMessage msg(B_VIEW_RESIZED);
|
||||||
|
msg.AddInt64("when", system_time());
|
||||||
|
msg.AddFloat("width", Frame().Width());
|
||||||
|
msg.AddFloat("height", Frame().Height());
|
||||||
|
msg.AddPoint("where", Frame().LeftTop());
|
||||||
|
Window()->SendMessageToClient(&msg, fViewToken, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Layer::ScrolledByHook(float dx, float dy)
|
||||||
|
{
|
||||||
|
// empty.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Layer::GetWantedRegion(BRegion& reg) const
|
Layer::GetWantedRegion(BRegion& reg) const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user