From 655f15bdd2b7b76b0e15b0b3c6c1ada8f355f437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sundstr=C3=B6m?= Date: Sun, 16 Aug 2009 14:10:20 +0000 Subject: [PATCH] * Clean up * Inserted window-covering view in layout hierarchy. (I removed SetLayout(). Is everything as it should be now?) * Moved creation and resizing of bitmap around and added some temporary printfs trying to figure out the drawing glitch to the right of the barberpole. The view has its view color set to B_TRANSPARENT_COLOR, but that should not affect the area to the right, outside of it. This might be unrelated, but for some reason the activity view fails to keep its barberpole bitmap bounds in sync with the view bounds. The bitmap gets created to match view bounds in AllAttached(), gets recreated by FrameResized() and yet in Draw() it does not always match the view's bounds. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32438 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../tracker/zipomatic/ZipOMaticActivity.cpp | 83 ++++++++++++------- .../tracker/zipomatic/ZipOMaticActivity.h | 1 + .../tracker/zipomatic/ZipOMaticWindow.cpp | 25 ++---- .../tracker/zipomatic/ZipOMaticWindow.h | 1 - 4 files changed, 61 insertions(+), 49 deletions(-) diff --git a/src/add-ons/tracker/zipomatic/ZipOMaticActivity.cpp b/src/add-ons/tracker/zipomatic/ZipOMaticActivity.cpp index 5f8ec2b5ee..3c4bf08754 100644 --- a/src/add-ons/tracker/zipomatic/ZipOMaticActivity.cpp +++ b/src/add-ons/tracker/zipomatic/ZipOMaticActivity.cpp @@ -5,6 +5,9 @@ #include "ZipOMaticActivity.h" +#include + + Activity::Activity(BRect frame, const char* name, uint32 resizingMode, uint32 flags) : @@ -12,8 +15,6 @@ Activity::Activity(BRect frame, const char* name, uint32 resizingMode, fIsRunning(false), fBitmap(NULL) { - SetViewColor(B_TRANSPARENT_COLOR); - fPattern.data[0] = 0x0f; fPattern.data[1] = 0x1e; fPattern.data[2] = 0x3c; @@ -22,8 +23,6 @@ Activity::Activity(BRect frame, const char* name, uint32 resizingMode, fPattern.data[5] = 0xe1; fPattern.data[6] = 0xc3; fPattern.data[7] = 0x87; - - _CreateBitmap(); }; @@ -33,6 +32,14 @@ Activity::~Activity() } +void +Activity::AllAttached() +{ + SetViewColor(B_TRANSPARENT_COLOR); + _CreateBitmap(); +} + + void Activity::Start() { @@ -74,8 +81,8 @@ Activity::Pulse() { uchar tmp = fPattern.data[7]; - for (int j = 7; j > 0; --j) - fPattern.data[j] = fPattern.data[j-1]; + for (int j = 7; j > 0; --j) + fPattern.data[j] = fPattern.data[j-1]; fPattern.data[0] = tmp; @@ -86,6 +93,18 @@ Activity::Pulse() void Activity::Draw(BRect rect) { + BRect viewRect = Bounds(); + BRect bitmapRect = fBitmap->Bounds(); + + if (bitmapRect != viewRect) { + printf("Activity::Draw(): bitmapRect != viewRect\n"); + bitmapRect.PrintToStream(); + viewRect.PrintToStream(); + + delete fBitmap; + _CreateBitmap(); + } + _DrawOnBitmap(IsRunning()); SetDrawingMode(B_OP_COPY); DrawBitmap(fBitmap); @@ -97,15 +116,15 @@ Activity::_DrawOnBitmap(bool running) { if (fBitmap->Lock()) { - BRect rect = fBitmap->Bounds(); + BRect rect = fBitmap->Bounds(); fBitmapView->SetDrawingMode(B_OP_COPY); - rgb_color color; - color.red = 0; - color.green = 0; - color.blue = 0; - color.alpha = 255; + rgb_color color; + color.red = 0; + color.green = 0; + color.blue = 0; + color.alpha = 255; if (running) color.blue = 200; @@ -119,13 +138,13 @@ Activity::_DrawOnBitmap(bool running) // draw frame // left - color.red = 150; - color.green = 150; - color.blue = 150; + color.red = 150; + color.green = 150; + color.blue = 150; fBitmapView->SetHighColor(color); fBitmapView->SetDrawingMode(B_OP_OVER); - BPoint point_a = fBitmap->Bounds().LeftTop(); - BPoint point_b = fBitmap->Bounds().LeftBottom(); + BPoint point_a = fBitmap->Bounds().LeftTop(); + BPoint point_b = fBitmap->Bounds().LeftBottom(); point_b.y -= 1; fBitmapView->StrokeLine(point_a, point_b); point_a.x += 1; @@ -134,8 +153,8 @@ Activity::_DrawOnBitmap(bool running) fBitmapView->StrokeLine(point_a, point_b); // top - point_a = fBitmap->Bounds().LeftTop(); - point_b = fBitmap->Bounds().RightTop(); + point_a = fBitmap->Bounds().LeftTop(); + point_b = fBitmap->Bounds().RightTop(); point_b.x -= 1; fBitmapView->StrokeLine(point_a, point_b); point_a.y += 1; @@ -144,12 +163,12 @@ Activity::_DrawOnBitmap(bool running) fBitmapView->StrokeLine(point_a, point_b); // right - color.red = 255; - color.green = 255; - color.blue = 255; + color.red = 255; + color.green = 255; + color.blue = 255; fBitmapView->SetHighColor(color); - point_a = fBitmap->Bounds().RightTop(); - point_b = fBitmap->Bounds().RightBottom(); + point_a = fBitmap->Bounds().RightTop(); + point_b = fBitmap->Bounds().RightBottom(); fBitmapView->StrokeLine(point_a, point_b); point_a.y += 1; point_a.x -= 1; @@ -157,8 +176,8 @@ Activity::_DrawOnBitmap(bool running) fBitmapView->StrokeLine(point_a, point_b); // bottom - point_a = fBitmap->Bounds().LeftBottom(); - point_b = fBitmap->Bounds().RightBottom(); + point_a = fBitmap->Bounds().LeftBottom(); + point_b = fBitmap->Bounds().RightBottom(); fBitmapView->StrokeLine(point_a, point_b); point_a.x += 1; point_a.y -= 1; @@ -166,9 +185,9 @@ Activity::_DrawOnBitmap(bool running) fBitmapView->StrokeLine(point_a, point_b); // some blending - color.red = 150; - color.green = 150; - color.blue = 150; + color.red = 150; + color.green = 150; + color.blue = 150; fBitmapView->SetHighColor(color); fBitmapView->SetDrawingMode(B_OP_SUBTRACT); fBitmapView->StrokeRect(rect); @@ -198,9 +217,9 @@ Activity::_DrawOnBitmap(bool running) void Activity::_LightenBitmapHighColor(rgb_color* color) { - color->red -= 30; - color->green -= 30; - color->blue -= 30; + color->red -= 30; + color->green -= 30; + color->blue -= 30; fBitmapView->SetHighColor(*color); } diff --git a/src/add-ons/tracker/zipomatic/ZipOMaticActivity.h b/src/add-ons/tracker/zipomatic/ZipOMaticActivity.h index 7fd4ac9bf4..a988e918ff 100644 --- a/src/add-ons/tracker/zipomatic/ZipOMaticActivity.h +++ b/src/add-ons/tracker/zipomatic/ZipOMaticActivity.h @@ -20,6 +20,7 @@ public: void Pause(); void Stop(); bool IsRunning(); + virtual void AllAttached(); virtual void Pulse(); virtual void Draw(BRect draw); virtual void FrameResized(float width, float height); diff --git a/src/add-ons/tracker/zipomatic/ZipOMaticWindow.cpp b/src/add-ons/tracker/zipomatic/ZipOMaticWindow.cpp index 816f9dec64..d7fca5d652 100644 --- a/src/add-ons/tracker/zipomatic/ZipOMaticWindow.cpp +++ b/src/add-ons/tracker/zipomatic/ZipOMaticWindow.cpp @@ -61,14 +61,15 @@ ZippoWindow::ZippoWindow(BRect frame, BMessage* refs) BSeparatorView* separator = new BSeparatorView(B_HORIZONTAL); - SetLayout(new BGroupLayout(B_VERTICAL)); - BLayoutBuilder::Group<>(this, B_VERTICAL, 10) - .Add(fActivityView) - .Add(fArchiveNameView) - .Add(fZipOutputView) - .Add(separator) - .Add(fStopButton) - .SetInsets(14, 14, 14, 14) + BLayoutBuilder::Group<>(this) + .AddGroup(B_VERTICAL, 10) + .Add(fActivityView) + .Add(fArchiveNameView) + .Add(fZipOutputView) + .Add(separator) + .Add(fStopButton) + .SetInsets(14, 14, 14, 14) + .End() .End(); if (refs != NULL) { @@ -266,11 +267,3 @@ ZippoWindow::_CloseWindowOrKeepOpen() PostMessage(B_QUIT_REQUESTED); } - -void -ZippoWindow::Zoom(BPoint origin, float width, float height) -{ - // TODO: Think about removing this method when - // zipomatic's new layout code works right. -} - diff --git a/src/add-ons/tracker/zipomatic/ZipOMaticWindow.h b/src/add-ons/tracker/zipomatic/ZipOMaticWindow.h index 7507e15425..0917e731e3 100644 --- a/src/add-ons/tracker/zipomatic/ZipOMaticWindow.h +++ b/src/add-ons/tracker/zipomatic/ZipOMaticWindow.h @@ -18,7 +18,6 @@ public: virtual void MessageReceived(BMessage* message); virtual bool QuitRequested(); - virtual void Zoom(BPoint origin, float width, float height); bool IsZipping(); void StopZipping();