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