[haiku-commits] haiku: hrev48599 - src/apps/haikudepot/ui

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 3 Jan 2015 22:08:39 +0100 (CET)

hrev48599 adds 1 changeset to branch 'master'
old head: 7f10f053c52084d5bf5977b17452fcc758ffed6f
new head: 2afa3f3b8b288d0f2a87c9ce09be443c013c87bc
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=2afa3f3+%5E7f10f05

----------------------------------------------------------------------------

2afa3f3: HaikuDepot: Improved screen shot window
  
   * Black background
   * Auto-resize to fit new screen shot, re-center on screen

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev48599
Commit:      2afa3f3b8b288d0f2a87c9ce09be443c013c87bc
URL:         http://cgit.haiku-os.org/haiku/commit/?id=2afa3f3
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sat Jan  3 21:05:24 2015 UTC

----------------------------------------------------------------------------

2 files changed, 23 insertions(+), 3 deletions(-)
src/apps/haikudepot/ui/ScreenshotWindow.cpp | 24 +++++++++++++++++++++---
src/apps/haikudepot/ui/ScreenshotWindow.h   |  2 ++

----------------------------------------------------------------------------

diff --git a/src/apps/haikudepot/ui/ScreenshotWindow.cpp 
b/src/apps/haikudepot/ui/ScreenshotWindow.cpp
index e6b1c9b..da01928 100644
--- a/src/apps/haikudepot/ui/ScreenshotWindow.cpp
+++ b/src/apps/haikudepot/ui/ScreenshotWindow.cpp
@@ -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();
+}
diff --git a/src/apps/haikudepot/ui/ScreenshotWindow.h 
b/src/apps/haikudepot/ui/ScreenshotWindow.h
index 5af9c0e..8d61b61 100644
--- a/src/apps/haikudepot/ui/ScreenshotWindow.h
+++ b/src/apps/haikudepot/ui/ScreenshotWindow.h
@@ -38,6 +38,8 @@ private:
        static  int32                           _DownloadThreadEntry(void* 
data);
                        void                            _DownloadThread();
 
+                       void                            _ResizeToFitAndCenter();
+
 private:
                        BMessenger                      fOnCloseTarget;
                        BMessage                        fOnCloseMessage;


Other related posts:

  • » [haiku-commits] haiku: hrev48599 - src/apps/haikudepot/ui - superstippi