HaikuDepot: Improved screen shot window

* Black background
 * Auto-resize to fit new screen shot, re-center on screen
This commit is contained in:
Stephan Aßmus 2015-01-03 22:05:24 +01:00
parent 7f10f053c5
commit 2afa3f3b8b
2 changed files with 23 additions and 3 deletions

View File

@ -34,13 +34,19 @@ ScreenshotWindow::ScreenshotWindow(BWindow* parent, BRect frame)
fScreenshotView->SetExplicitMaxSize(
BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
BGroupView* groupView = new BGroupView(B_VERTICAL);
groupView->SetViewColor(0, 0, 0);
fScreenshotView->SetLowColor(0, 0, 0);
// Build layout
BLayoutBuilder::Group<>(this, B_VERTICAL)
.Add(fScreenshotView)
.SetInsets(B_USE_WINDOW_INSETS)
.AddGroup(groupView)
.Add(fScreenshotView)
.SetInsets(B_USE_WINDOW_INSETS)
.End()
;
CenterIn(parent->Frame());
CenterOnScreen();
}
@ -197,8 +203,20 @@ ScreenshotWindow::_DownloadThread()
printf("got screenshot");
fScreenshot = BitmapRef(new(std::nothrow)SharedBitmap(buffer), true);
fScreenshotView->SetBitmap(fScreenshot->Bitmap(SharedBitmap::SIZE_ANY));
_ResizeToFitAndCenter();
Unlock();
} else {
printf(" failed to download screenshot\n");
}
}
void
ScreenshotWindow::_ResizeToFitAndCenter()
{
float minWidth;
float minHeight;
GetSizeLimits(&minWidth, NULL, &minHeight, NULL);
ResizeTo(minWidth, minHeight);
CenterOnScreen();
}

View File

@ -38,6 +38,8 @@ private:
static int32 _DownloadThreadEntry(void* data);
void _DownloadThread();
void _ResizeToFitAndCenter();
private:
BMessenger fOnCloseTarget;
BMessage fOnCloseMessage;