quick fix for windows resizing/moving at fractional offsets, fix for bitmap drawing placement, small clean ups

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12961 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2005-06-05 22:02:25 +00:00
parent 683be71e08
commit 457820a6ef
3 changed files with 15 additions and 19 deletions
+3 -5
View File
@@ -149,7 +149,6 @@ void
Layer::AddChild(Layer* layer, ServerWindow* serverWin) Layer::AddChild(Layer* layer, ServerWindow* serverWin)
{ {
STRACE(("Layer(%s)::AddChild(%s) START\n", GetName(), layer->GetName())); STRACE(("Layer(%s)::AddChild(%s) START\n", GetName(), layer->GetName()));
//printf("Layer(%s)::AddChild(%s)\n", GetName(), layer->GetName());
if (layer->fParent != NULL) { if (layer->fParent != NULL) {
printf("ERROR: AddChild(): Layer already has a parent\n"); printf("ERROR: AddChild(): Layer already has a parent\n");
@@ -956,7 +955,7 @@ Layer::MoveBy(float x, float y)
return; return;
} }
BPortLink msg(-1, -1); BPortLink msg(-1, -1);
msg.StartMessage(AS_ROOTLAYER_LAYER_MOVE); msg.StartMessage(AS_ROOTLAYER_LAYER_MOVE);
msg.Attach<Layer*>(this); msg.Attach<Layer*>(this);
msg.Attach<float>(x); msg.Attach<float>(x);
@@ -972,13 +971,12 @@ Layer::ResizeBy(float x, float y)
{ {
STRACE(("Layer(%s)::ResizeBy() START\n", GetName())); STRACE(("Layer(%s)::ResizeBy() START\n", GetName()));
if(!fParent) if (!fParent) {
{
printf("ERROR: in Layer::ResizeBy()! - No parent!\n"); printf("ERROR: in Layer::ResizeBy()! - No parent!\n");
return; return;
} }
BPortLink msg(-1, -1); BPortLink msg(-1, -1);
msg.StartMessage(AS_ROOTLAYER_LAYER_RESIZE); msg.StartMessage(AS_ROOTLAYER_LAYER_RESIZE);
msg.Attach<Layer*>(this); msg.Attach<Layer*>(this);
msg.Attach<float>(x); msg.Attach<float>(x);
+6 -14
View File
@@ -1521,10 +1521,9 @@ ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
ServerBitmap* sbmp = fServerApp->FindBitmap(bitmapToken); ServerBitmap* sbmp = fServerApp->FindBitmap(bitmapToken);
if (sbmp) { if (sbmp) {
BRect src = sbmp->Bounds(); BRect src = sbmp->Bounds();
BRect dst = fCurrentLayer->fParent->ConvertFromParent(fCurrentLayer->fFull.Frame()); BRect dst = src.OffsetToCopy(point);
dst.OffsetBy(point); dst = fCurrentLayer->ConvertToTop(dst);
fCurrentLayer->GetDisplayDriver()->DrawBitmap(sbmp, src, dst, fCurrentLayer->fLayerData); fCurrentLayer->GetDisplayDriver()->DrawBitmap(sbmp, src, dst, fCurrentLayer->fLayerData);
} }
@@ -1543,10 +1542,9 @@ ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
ServerBitmap* sbmp = fServerApp->FindBitmap(bitmapToken); ServerBitmap* sbmp = fServerApp->FindBitmap(bitmapToken);
if (sbmp) { if (sbmp) {
BRect src = sbmp->Bounds(); BRect src = sbmp->Bounds();
BRect dst = fCurrentLayer->fParent->ConvertFromParent(fCurrentLayer->fFull.Frame()); BRect dst = src.OffsetToCopy(point);
dst.OffsetBy(point); dst = fCurrentLayer->ConvertToTop(dst);
fCurrentLayer->GetDisplayDriver()->DrawBitmap(sbmp, src, dst, fCurrentLayer->fLayerData); fCurrentLayer->GetDisplayDriver()->DrawBitmap(sbmp, src, dst, fCurrentLayer->fLayerData);
} }
@@ -1564,10 +1562,7 @@ ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
ServerBitmap* sbmp = fServerApp->FindBitmap(bitmapToken); ServerBitmap* sbmp = fServerApp->FindBitmap(bitmapToken);
if (sbmp) { if (sbmp) {
BRect dst = fCurrentLayer->fParent->ConvertFromParent(fCurrentLayer->fFull.Frame()); dstRect = fCurrentLayer->ConvertToTop(dstRect);
dstRect.OffsetBy(dst.left, dst.top);
// TODO: why is this not working:
// fCurrentLayer->ConvertToTop(dstRect);
fCurrentLayer->GetDisplayDriver()->DrawBitmap(sbmp, srcRect, dstRect, fCurrentLayer->fLayerData); fCurrentLayer->GetDisplayDriver()->DrawBitmap(sbmp, srcRect, dstRect, fCurrentLayer->fLayerData);
} }
@@ -1587,10 +1582,7 @@ ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
ServerBitmap* sbmp = fServerApp->FindBitmap(bitmapToken); ServerBitmap* sbmp = fServerApp->FindBitmap(bitmapToken);
if (sbmp) { if (sbmp) {
BRect dst = fCurrentLayer->fParent->ConvertFromParent(fCurrentLayer->fFull.Frame()); dstRect = fCurrentLayer->ConvertToTop(dstRect);
dstRect.OffsetBy(dst.left, dst.top);
// TODO: why is this not working:
// fCurrentLayer->ConvertToTop(dstRect);
fCurrentLayer->GetDisplayDriver()->DrawBitmap(sbmp, srcRect, dstRect, fCurrentLayer->fLayerData); fCurrentLayer->GetDisplayDriver()->DrawBitmap(sbmp, srcRect, dstRect, fCurrentLayer->fLayerData);
} }
+6
View File
@@ -340,6 +340,9 @@ WinBorder::Draw(const BRect &r)
void void
WinBorder::MoveBy(float x, float y) WinBorder::MoveBy(float x, float y)
{ {
x = (float)int32(x);
y = (float)int32(y);
if (x == 0.0 && y == 0.0) if (x == 0.0 && y == 0.0)
return; return;
@@ -392,6 +395,9 @@ WinBorder::ResizeBy(float x, float y)
{ {
STRACE(("WinBorder(%s)::ResizeBy()\n", GetName())); STRACE(("WinBorder(%s)::ResizeBy()\n", GetName()));
x = (float)int32(x);
y = (float)int32(y);
float wantWidth = fFrame.Width() + x; float wantWidth = fFrame.Width() + x;
float wantHeight = fFrame.Height() + y; float wantHeight = fFrame.Height() + y;