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
This commit is contained in:
Stephan Aßmus
2009-03-26 14:10:02 +00:00
parent af20d1a13e
commit 23b0de5eb2
+74 -75
View File
@@ -66,108 +66,107 @@ const uint32 kRestoreBackgroundImage = 'Tbgr';
const uint32 kChangeBackgroundImage = 'Cbgr'; const uint32 kChangeBackgroundImage = 'Cbgr';
class BackgroundImage { class BackgroundImage {
// This class knows everything about which bitmap to use for a given // This class knows everything about which bitmap to use for a given
// view and how. // view and how.
// Unlike other windows, the Desktop window can have different backgrounds // Unlike other windows, the Desktop window can have different backgrounds
// for each workspace // 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: public:
BackgroundImageInfo(uint32 workspace, int32 imageIndex, Mode mode,
BPoint offset, bool textWidgetLabelOutline, uint32 imageSet,
uint32 cacheMode);
~BackgroundImageInfo();
enum Mode { void LoadBitmap();
kAtOffset, void UnloadBitmap(uint32 globalCacheMode);
kCentered, // only works on Desktop
kScaledToFit, // only works on Desktop
kTiled
};
class BackgroundImageInfo { uint32 fWorkspace;
// element of the per-workspace list int32 fImageIndex;
public: Mode fMode;
BackgroundImageInfo(uint32 workspace, int32 imageIndex, Mode mode, BPoint fOffset;
BPoint offset, bool textWidgetLabelOutline, uint32 imageSet, bool fTextWidgetLabelOutline;
uint32 cacheMode); uint32 fImageSet;
~BackgroundImageInfo(); uint32 fCacheMode; // image cache strategy (0 cache , 1 no cache)
};
void LoadBitmap(); static BackgroundImage *GetBackgroundImage(const BNode *node,
void UnloadBitmap(uint32 globalCacheMode); bool isDesktop, BackgroundsView* view);
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);
// create a BackgroundImage object by reading it from a node // 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 // display the right background for a given workspace
void Remove(); void Remove();
// remove the background from it's current view // 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 // 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 // respond to a screen size change
/*static BackgroundImage *Refresh(BackgroundImage *oldBackgroundImage, /*static BackgroundImage *Refresh(BackgroundImage *oldBackgroundImage,
const BNode *fromNode, bool desktop, BPoseView *poseView); const BNode *fromNode, bool desktop, BPoseView *poseView);
// respond to a background image setting change // respond to a background image setting change
void ChangeImageSet(BPoseView *poseView); void ChangeImageSet(BPoseView *poseView);
// change to the next imageSet if any, no refresh*/ // change to the next imageSet if any, no refresh*/
BackgroundImageInfo *ImageInfoForWorkspace(int32) const; 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 Add(BackgroundImageInfo *);
void Remove(BackgroundImageInfo *); void Remove(BackgroundImageInfo *);
void RemoveAll(); void RemoveAll();
private: private:
BackgroundImage(const BNode *node, bool isDesktop, BackgroundsView* view); BackgroundImage(const BNode *node, bool isDesktop, BackgroundsView* view);
// no public constructor, GetBackgroundImage factory function is // no public constructor, GetBackgroundImage factory function is
// used instead // used instead
bool fIsDesktop; bool fIsDesktop;
BNode fDefinedByNode; BNode fDefinedByNode;
BView *fView; BView *fView;
BackgroundsView* fBackgroundsView; BackgroundsView* fBackgroundsView;
BackgroundImageInfo *fShowingBitmap; BackgroundImageInfo *fShowingBitmap;
BObjectList<BackgroundImageInfo> fBitmapForWorkspaceList; BObjectList<BackgroundImageInfo> fBitmapForWorkspaceList;
uint32 fImageSetPeriod; // period between imagesets, 0 if none uint32 fImageSetPeriod; // period between imagesets, 0 if none
uint32 fShowingImageSet; // current imageset uint32 fShowingImageSet; // current imageset
uint32 fImageSetCount; // imageset count uint32 fImageSetCount; // imageset count
uint32 fCacheMode;// image cache strategy (0 all, 1 none, 2 own strategy) uint32 fCacheMode;// image cache strategy (0 all, 1 none, 2 own strategy)
bool fRandomChange; // random or sequential change bool fRandomChange; // random or sequential change
}; };
class Image { class Image {
// element for each image // element for each image
public: public:
Image(BPath path); Image(BPath path);
~Image(); ~Image();
void UnloadBitmap(); void UnloadBitmap();
const char* GetName() {return name.String();} const char* GetName() {return name.String();}
BBitmap* GetBitmap(); BBitmap* GetBitmap();
BPath GetPath() {return fPath;} BPath GetPath() {return fPath;}
private: private:
BBitmap *fBitmap; BBitmap *fBitmap;
BPath fPath; BPath fPath;
BString name; BString name;
}; };
#endif #endif