From 23b0de5eb26424b6bbb0703b68a1168ca6691a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 26 Mar 2009 14:10:02 +0000 Subject: [PATCH] Cleanups, mostly to make diffing it against the original file from Tracker more easy. It's not so nice that this code is replicated, there could be refactoring to get a base-class which is used by both Tracker and Backgrounds and the Tracker version extends it for the caching, while the Background preflet extends it in other ways. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29730 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/backgrounds/BackgroundImage.h | 149 +++++++++--------- 1 file changed, 74 insertions(+), 75 deletions(-) diff --git a/src/preferences/backgrounds/BackgroundImage.h b/src/preferences/backgrounds/BackgroundImage.h index 57978e7fcf..8a7b119acc 100644 --- a/src/preferences/backgrounds/BackgroundImage.h +++ b/src/preferences/backgrounds/BackgroundImage.h @@ -66,108 +66,107 @@ const uint32 kRestoreBackgroundImage = 'Tbgr'; const uint32 kChangeBackgroundImage = 'Cbgr'; class BackgroundImage { - // This class knows everything about which bitmap to use for a given - // view and how. - // Unlike other windows, the Desktop window can have different backgrounds - // for each workspace + // This class knows everything about which bitmap to use for a given + // view and how. + // Unlike other windows, the Desktop window can have different backgrounds + // for each workspace +public: + + enum Mode { + kAtOffset, + kCentered, // only works on Desktop + kScaledToFit, // only works on Desktop + kTiled + }; + + class BackgroundImageInfo { + // element of the per-workspace list public: + BackgroundImageInfo(uint32 workspace, int32 imageIndex, Mode mode, + BPoint offset, bool textWidgetLabelOutline, uint32 imageSet, + uint32 cacheMode); + ~BackgroundImageInfo(); - enum Mode { - kAtOffset, - kCentered, // only works on Desktop - kScaledToFit, // only works on Desktop - kTiled - }; + void LoadBitmap(); + void UnloadBitmap(uint32 globalCacheMode); - class BackgroundImageInfo { - // element of the per-workspace list - public: - BackgroundImageInfo(uint32 workspace, int32 imageIndex, Mode mode, - BPoint offset, bool textWidgetLabelOutline, uint32 imageSet, - uint32 cacheMode); - ~BackgroundImageInfo(); + uint32 fWorkspace; + int32 fImageIndex; + Mode fMode; + BPoint fOffset; + bool fTextWidgetLabelOutline; + uint32 fImageSet; + uint32 fCacheMode; // image cache strategy (0 cache , 1 no cache) + }; - void LoadBitmap(); - void UnloadBitmap(uint32 globalCacheMode); - - uint32 fWorkspace; - int32 fImageIndex; - Mode fMode; - BPoint fOffset; - bool fTextWidgetLabelOutline; - uint32 fImageSet; - uint32 fCacheMode; // image cache strategy (0 cache , 1 no cache) - }; - - static BackgroundImage *GetBackgroundImage(const BNode *node, - bool isDesktop, BackgroundsView* view); + static BackgroundImage *GetBackgroundImage(const BNode *node, + bool isDesktop, BackgroundsView* view); // create a BackgroundImage object by reading it from a node - virtual ~BackgroundImage(); + virtual ~BackgroundImage(); - void Show(BView *view, int32 workspace); + void Show(BView *view, int32 workspace); // display the right background for a given workspace - void Remove(); + void Remove(); // remove the background from it's current view - void WorkspaceActivated(BView *view, int32 workspace, bool state); + void WorkspaceActivated(BView *view, int32 workspace, bool state); // respond to a workspace change - void ScreenChanged(BRect rect, color_space space); + void ScreenChanged(BRect rect, color_space space); // respond to a screen size change - /*static BackgroundImage *Refresh(BackgroundImage *oldBackgroundImage, - const BNode *fromNode, bool desktop, BPoseView *poseView); - // respond to a background image setting change - void ChangeImageSet(BPoseView *poseView); - // change to the next imageSet if any, no refresh*/ - BackgroundImageInfo *ImageInfoForWorkspace(int32) const; + /*static BackgroundImage *Refresh(BackgroundImage *oldBackgroundImage, + const BNode *fromNode, bool desktop, BPoseView *poseView); + // respond to a background image setting change + void ChangeImageSet(BPoseView *poseView); + // change to the next imageSet if any, no refresh*/ + BackgroundImageInfo *ImageInfoForWorkspace(int32) const; - // return fIsDesktop - bool IsDesktop() { return fIsDesktop;} + bool IsDesktop() { return fIsDesktop;} - status_t SetBackgroundImage(BNode *node); + status_t SetBackgroundImage(BNode *node); - void Show(BackgroundImageInfo *, BView *view); + void Show(BackgroundImageInfo *, BView *view); - uint32 GetShowingImageSet() { return fShowingImageSet; } + uint32 GetShowingImageSet() { return fShowingImageSet; } - void Add(BackgroundImageInfo *); - void Remove(BackgroundImageInfo *); - void RemoveAll(); + void Add(BackgroundImageInfo *); + void Remove(BackgroundImageInfo *); + void RemoveAll(); - private: - BackgroundImage(const BNode *node, bool isDesktop, BackgroundsView* view); +private: + BackgroundImage(const BNode *node, bool isDesktop, BackgroundsView* view); // no public constructor, GetBackgroundImage factory function is // used instead - bool fIsDesktop; - BNode fDefinedByNode; - BView *fView; - BackgroundsView* fBackgroundsView; - BackgroundImageInfo *fShowingBitmap; + bool fIsDesktop; + BNode fDefinedByNode; + BView *fView; + BackgroundsView* fBackgroundsView; + BackgroundImageInfo *fShowingBitmap; - BObjectList fBitmapForWorkspaceList; + BObjectList fBitmapForWorkspaceList; - uint32 fImageSetPeriod; // period between imagesets, 0 if none - uint32 fShowingImageSet; // current imageset - uint32 fImageSetCount; // imageset count - uint32 fCacheMode;// image cache strategy (0 all, 1 none, 2 own strategy) - bool fRandomChange; // random or sequential change + uint32 fImageSetPeriod; // period between imagesets, 0 if none + uint32 fShowingImageSet; // current imageset + uint32 fImageSetCount; // imageset count + uint32 fCacheMode;// image cache strategy (0 all, 1 none, 2 own strategy) + bool fRandomChange; // random or sequential change }; class Image { - // element for each image - public: - Image(BPath path); - ~Image(); + // element for each image +public: + Image(BPath path); + ~Image(); - void UnloadBitmap(); - const char* GetName() {return name.String();} - BBitmap* GetBitmap(); - BPath GetPath() {return fPath;} - private: - BBitmap *fBitmap; - BPath fPath; - BString name; + void UnloadBitmap(); + const char* GetName() {return name.String();} + BBitmap* GetBitmap(); + BPath GetPath() {return fPath;} +private: + BBitmap *fBitmap; + BPath fPath; + BString name; }; #endif