1 /* 2 * Copyright 2014, Stephan Aßmus <superstippi@gmx.de>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef SCREENSHOT_WINDOW_H 6 #define SCREENSHOT_WINDOW_H 7 8 #include <Locker.h> 9 #include <Messenger.h> 10 #include <ToolBar.h> 11 #include <Window.h> 12 13 #include "PackageInfo.h" 14 15 16 class BarberPole; 17 class BitmapView; 18 class BStringView; 19 20 21 enum { 22 MSG_NEXT_SCREENSHOT = 'nscr', 23 MSG_PREVIOUS_SCREENSHOT = 'pscr', 24 MSG_DOWNLOAD_START = 'dlst', 25 MSG_DOWNLOAD_STOP = 'dlsp', 26 }; 27 28 29 class ScreenshotWindow : public BWindow { 30 public: 31 ScreenshotWindow(BWindow* parent, BRect frame); 32 virtual ~ScreenshotWindow(); 33 34 virtual bool QuitRequested(); 35 36 virtual void MessageReceived(BMessage* message); 37 38 void SetOnCloseMessage( 39 const BMessenger& messenger, 40 const BMessage& message); 41 42 void SetPackage(const PackageInfoRef& package); 43 44 static void CleanupIcons(); 45 46 private: 47 void _DownloadScreenshot(); 48 49 void _SetWorkerThread(thread_id thread); 50 51 static int32 _DownloadThreadEntry(void* data); 52 void _DownloadThread(); 53 54 void _ResizeToFitAndCenter(); 55 void _UpdateToolBar(); 56 57 private: 58 enum { 59 kProgressIndicatorDelay = 200000 // us 60 }; 61 62 private: 63 BMessenger fOnCloseTarget; 64 BMessage fOnCloseMessage; 65 66 BToolBar* fToolBar; 67 BarberPole* fBarberPole; 68 bool fBarberPoleShown; 69 BStringView* fIndexView; 70 71 BitmapRef fScreenshot; 72 BitmapView* fScreenshotView; 73 74 int32 fCurrentScreenshotIndex; // atomic 75 76 PackageInfoRef fPackage; 77 bool fDownloadPending; 78 79 BLocker fLock; 80 thread_id fWorkerThread; 81 }; 82 83 84 #endif // SCREENSHOT_WINDOW_H 85