Tracker: style fixes to BackgroundImage

This commit is contained in:
John Scipione
2014-06-20 20:10:30 -04:00
parent ce3ae98bd0
commit 95c61b83a0
2 changed files with 49 additions and 34 deletions
+42 -29
View File
@@ -60,7 +60,10 @@ const char* kBackgroundImageInfoMode = B_BACKGROUND_MODE;
const char* kBackgroundImageInfoWorkspaces = B_BACKGROUND_WORKSPACES; const char* kBackgroundImageInfoWorkspaces = B_BACKGROUND_WORKSPACES;
const char* kBackgroundImageInfoPath = B_BACKGROUND_IMAGE; const char* kBackgroundImageInfoPath = B_BACKGROUND_IMAGE;
} // namespace BPrivate } // namespace BPrivate
// #pragma mark - BackgroundImage
BackgroundImage* BackgroundImage*
@@ -83,7 +86,7 @@ BackgroundImage::GetBackgroundImage(const BNode* node, bool isDesktop)
if (error != B_OK) if (error != B_OK)
return NULL; return NULL;
BackgroundImage* result = NULL; BackgroundImage* backgroundImage = NULL;
for (int32 index = 0; ; index++) { for (int32 index = 0; ; index++) {
const char* path; const char* path;
uint32 workspaces = B_ALL_WORKSPACES; uint32 workspaces = B_ALL_WORKSPACES;
@@ -117,22 +120,24 @@ BackgroundImage::GetBackgroundImage(const BNode* node, bool isDesktop)
BackgroundImage::BackgroundImageInfo(workspaces, bitmap, mode, BackgroundImage::BackgroundImageInfo(workspaces, bitmap, mode,
offset, textWidgetLabelOutline); offset, textWidgetLabelOutline);
if (!result) if (backgroundImage == NULL)
result = new BackgroundImage(node, isDesktop); backgroundImage = new BackgroundImage(node, isDesktop);
result->Add(imageInfo); backgroundImage->Add(imageInfo);
} }
return result;
return backgroundImage;
} }
BackgroundImage::BackgroundImageInfo::BackgroundImageInfo(uint32 workspaces, BackgroundImage::BackgroundImageInfo::BackgroundImageInfo(uint32 workspaces,
BBitmap* bitmap, Mode mode, BPoint offset, bool textWidgetOutline) BBitmap* bitmap, Mode mode, BPoint offset, bool textWidgetOutline)
: fWorkspace(workspaces), :
fBitmap(bitmap), fWorkspace(workspaces),
fMode(mode), fBitmap(bitmap),
fOffset(offset), fMode(mode),
fTextWidgetOutline(textWidgetOutline) fOffset(offset),
fTextWidgetOutline(textWidgetOutline)
{ {
} }
@@ -144,11 +149,12 @@ BackgroundImage::BackgroundImageInfo::~BackgroundImageInfo()
BackgroundImage::BackgroundImage(const BNode* node, bool desktop) BackgroundImage::BackgroundImage(const BNode* node, bool desktop)
: fIsDesktop(desktop), :
fDefinedByNode(*node), fIsDesktop(desktop),
fView(NULL), fDefinedByNode(*node),
fShowingBitmap(NULL), fView(NULL),
fBitmapForWorkspaceList(1, true) fShowingBitmap(NULL),
fBitmapForWorkspaceList(1, true)
{ {
} }
@@ -232,6 +238,7 @@ BackgroundImage::Show(BackgroundImageInfo* info, BView* view)
case kAtOffset: case kAtOffset:
destinationBitmapBounds.OffsetTo(info->fOffset); destinationBitmapBounds.OffsetTo(info->fOffset);
break; break;
case kTiled: case kTiled:
if (fIsDesktop) { if (fIsDesktop) {
destinationBitmapBounds.OffsetBy( destinationBitmapBounds.OffsetBy(
@@ -276,15 +283,16 @@ BackgroundImage::BRectVerticalOverlap(BRect hostRect, BRect resizedRect)
void void
BackgroundImage::Remove() BackgroundImage::Remove()
{ {
if (fShowingBitmap) { if (fShowingBitmap != NULL) {
fView->ClearViewBitmap(); fView->ClearViewBitmap();
fView->Invalidate(); fView->Invalidate();
BPoseView* poseView = dynamic_cast<BPoseView*>(fView); BPoseView* poseView = dynamic_cast<BPoseView*>(fView);
// make sure text widgets draw the default way, erasing // make sure text widgets draw the default way, erasing
// their background // their background
if (poseView) if (poseView != NULL)
poseView->SetWidgetTextOutline(true); poseView->SetWidgetTextOutline(true);
} }
fShowingBitmap = NULL; fShowingBitmap = NULL;
} }
@@ -307,6 +315,7 @@ BackgroundImage::ImageInfoForWorkspace(int32 workspace) const
BackgroundImageInfo* info = fBitmapForWorkspaceList.ItemAt(index); BackgroundImageInfo* info = fBitmapForWorkspaceList.ItemAt(index);
if (info->fWorkspace == workspaceMask) if (info->fWorkspace == workspaceMask)
return info; return info;
if (info->fWorkspace & workspaceMask) if (info->fWorkspace & workspaceMask)
result = info; result = info;
} }
@@ -318,25 +327,29 @@ BackgroundImage::ImageInfoForWorkspace(int32 workspace) const
void void
BackgroundImage::WorkspaceActivated(BView* view, int32 workspace, bool state) BackgroundImage::WorkspaceActivated(BView* view, int32 workspace, bool state)
{ {
if (!fIsDesktop) if (!fIsDesktop) {
// we only care for desktop bitmaps // we only care for desktop bitmaps
return; return;
}
if (!state) if (!state) {
// we only care comming into a new workspace, not leaving one // we only care comming into a new workspace, not leaving one
return; return;
}
BackgroundImageInfo* info = ImageInfoForWorkspace(workspace); BackgroundImageInfo* info = ImageInfoForWorkspace(workspace);
if (info != fShowingBitmap) { if (info != fShowingBitmap) {
if (info) if (info != NULL)
Show(info, view); Show(info, view);
else { else {
if (BPoseView* poseView = dynamic_cast<BPoseView*>(view)) BPoseView* poseView = dynamic_cast<BPoseView*>(view);
if (poseView != NULL)
poseView->SetWidgetTextOutline(true); poseView->SetWidgetTextOutline(true);
view->ClearViewBitmap(); view->ClearViewBitmap();
view->Invalidate(); view->Invalidate();
} }
fShowingBitmap = info; fShowingBitmap = info;
} }
} }
@@ -345,7 +358,7 @@ BackgroundImage::WorkspaceActivated(BView* view, int32 workspace, bool state)
void void
BackgroundImage::ScreenChanged(BRect, color_space) BackgroundImage::ScreenChanged(BRect, color_space)
{ {
if (!fIsDesktop || !fShowingBitmap) if (!fIsDesktop || fShowingBitmap == NULL)
return; return;
if (fShowingBitmap->fMode == kCentered) { if (fShowingBitmap->fMode == kCentered) {
@@ -367,14 +380,14 @@ BackgroundImage*
BackgroundImage::Refresh(BackgroundImage* oldBackgroundImage, BackgroundImage::Refresh(BackgroundImage* oldBackgroundImage,
const BNode* fromNode, bool desktop, BPoseView* poseView) const BNode* fromNode, bool desktop, BPoseView* poseView)
{ {
if (oldBackgroundImage) { if (oldBackgroundImage != NULL) {
oldBackgroundImage->Remove(); oldBackgroundImage->Remove();
delete oldBackgroundImage; delete oldBackgroundImage;
} }
BackgroundImage* result = GetBackgroundImage(fromNode, desktop); BackgroundImage* backgroundImage = GetBackgroundImage(fromNode, desktop);
if (result && poseView->ViewMode() != kListMode) if (backgroundImage != NULL && poseView->ViewMode() != kListMode)
result->Show(poseView, current_workspace()); backgroundImage->Show(poseView, current_workspace());
return result; return backgroundImage;
} }
+7 -5
View File
@@ -31,15 +31,16 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders. names are registered trademarks or trademarks of their respective holders.
All rights reserved. All rights reserved.
*/ */
#ifndef __BACKGROUND_IMAGE__
#define __BACKGROUND_IMAGE__
// Classes used for setting up and managing background images // Classes used for setting up and managing background images
#ifndef _BACKGROUND_IMAGE_H
#define _BACKGROUND_IMAGE_H
#include <ObjectList.h>
#include <String.h> #include <String.h>
#include "ObjectList.h"
class BNode; class BNode;
@@ -132,4 +133,5 @@ private:
using namespace BPrivate; using namespace BPrivate;
#endif
#endif // _BACKGROUND_IMAGE_H