Allows "Icon Label Outline" to be disabled when no background bitmaps are chosen.

It complements r29190 and fixes ticket #2395.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30495 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Saint-Pierre
2009-04-29 23:43:23 +00:00
parent 35d0af4fa0
commit 838eca4665
3 changed files with 101 additions and 89 deletions
+19 -11
View File
@@ -86,15 +86,15 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop)
Mode mode = kTiled;
bool textWidgetLabelOutline = false;
BPoint offset;
BBitmap *bitmap = NULL;
if (container.FindString(kBackgroundImageInfoPath, index, &path) != B_OK)
break;
BBitmap *bitmap = BTranslationUtils::GetBitmap(path);
if (container.FindString(kBackgroundImageInfoPath, index, &path) == B_OK) {
bitmap = BTranslationUtils::GetBitmap(path);
if (!bitmap) {
// PRINT(("failed to load background bitmap from path\n"));
continue;
PRINT(("failed to load background bitmap from path\n"));
}
} else
break;
container.FindInt32(kBackgroundImageInfoWorkspaces, index, (int32 *)&workspaces);
container.FindInt32(kBackgroundImageInfoMode, index, (int32 *)&mode);
@@ -140,6 +140,7 @@ BackgroundImage::BackgroundImage(const BNode *node, bool desktop)
{
}
BackgroundImage::~BackgroundImage()
{
}
@@ -151,6 +152,7 @@ BackgroundImage::Add(BackgroundImageInfo *info)
fBitmapForWorkspaceList.AddItem(info);
}
void
BackgroundImage::Show(BView *view, int32 workspace)
{
@@ -168,6 +170,16 @@ BackgroundImage::Show(BView *view, int32 workspace)
void
BackgroundImage::Show(BackgroundImageInfo *info, BView *view)
{
BPoseView *poseView = dynamic_cast<BPoseView *>(view);
if (poseView)
poseView->SetWidgetTextOutline(info->fTextWidgetOutline);
if (info->fBitmap == NULL) {
view->ClearViewBitmap();
view->Invalidate();
fShowingBitmap = info;
return;
}
BRect viewBounds(view->Bounds());
BRect bitmapBounds(info->fBitmap->Bounds());
BRect destinationBitmapBounds(bitmapBounds);
@@ -205,15 +217,10 @@ BackgroundImage::Show(BackgroundImageInfo *info, BView *view)
break;
}
BPoseView *poseView = dynamic_cast<BPoseView *>(view);
if (poseView)
poseView->SetWidgetTextOutline(info->fTextWidgetOutline);
// switch to the bitmap and force a redraw
view->SetViewBitmap(info->fBitmap, bitmapBounds, destinationBitmapBounds,
followFlags, tile);
view->Invalidate();
fShowingBitmap = info;
}
@@ -268,6 +275,7 @@ BackgroundImage::WorkspaceActivated(BView *view, int32 workspace, bool state)
return;
BackgroundImageInfo *info = ImageInfoForWorkspace(workspace);
if (info != fShowingBitmap) {
if (info)
Show(info, view);
@@ -116,13 +116,18 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop,
BPoint offset;
uint32 imageSet = 0;
uint32 cacheMode = 0;
if (container.FindString(kBackgroundImageInfoPath, index, &path) != B_OK)
break;
int32 imageIndex = -1;
if (container.FindString(kBackgroundImageInfoPath, index, &path) == B_OK) {
if (strcmp(path, "")) {
BPath bpath(path);
int32 imageIndex = view->AddImage(bpath);
if (imageIndex < 0)
imageIndex = view->AddImage(bpath);
if (imageIndex < 0) {
imageIndex = -imageIndex - 1;
}
}
} else
break;
container.FindInt32(kBackgroundImageInfoWorkspaces, index,
(int32 *)&workspaces);
@@ -359,12 +364,12 @@ BackgroundImage::ImageInfoForWorkspace(int32 workspace) const
if (fIsDesktop) {
if (info->fWorkspace == workspaceMask)
return info;
if (info->fWorkspace & workspaceMask)
result = info;
} else
return info;
}
return result;
}
@@ -427,13 +432,15 @@ BackgroundImage::SetBackgroundImage(BNode *node)
for (int32 index = 0; index < count; index++) {
BackgroundImageInfo *info = fBitmapForWorkspaceList.ItemAt(index);
if (fBackgroundsView->GetImage(info->fImageIndex) == NULL)
continue;
container.AddBool(kBackgroundImageInfoTextOutline,
info->fTextWidgetLabelOutline);
if (fBackgroundsView->GetImage(info->fImageIndex) != NULL) {
container.AddString(kBackgroundImageInfoPath,
fBackgroundsView->GetImage(info->fImageIndex)->GetPath().Path());
} else
container.AddString(kBackgroundImageInfoPath, "");
container.AddInt32(kBackgroundImageInfoWorkspaces, info->fWorkspace);
container.AddPoint(kBackgroundImageInfoOffset, info->fOffset);
container.AddInt32(kBackgroundImageInfoMode, info->fMode);
+15 -18
View File
@@ -545,6 +545,11 @@ BackgroundsView::UpdateWithCurrent(void)
fIconLabelOutline->SetValue(fCurrentInfo->fTextWidgetLabelOutline
? B_CONTROL_ON : B_CONTROL_OFF);
fLastImageIndex = fCurrentInfo->fImageIndex;
FindImageItem(fLastImageIndex)->SetMarked(true);
if (fLastImageIndex > -1) {
BString xtext, ytext;
int32 cmd = 0;
switch (fCurrentInfo->fMode) {
@@ -569,9 +574,9 @@ BackgroundsView::UpdateWithCurrent(void)
fXPlacementText->SetText(xtext.String());
fYPlacementText->SetText(ytext.String());
fLastImageIndex = fCurrentInfo->fImageIndex;
FindImageItem(fLastImageIndex)->SetMarked(true);
} else {
fPlacementMenu->FindItem(kMsgManualPlacement)->SetMarked(true);
}
}
rgb_color color = {255, 255, 255, 255};
@@ -593,6 +598,7 @@ BackgroundsView::Save()
{
bool textWidgetLabelOutline =
fIconLabelOutline->Value() == B_CONTROL_ON;
BackgroundImage::Mode mode = FindPlacementMode();
BPoint offset(atoi(fXPlacementText->Text()), atoi(fYPlacementText->Text()));
@@ -620,15 +626,12 @@ BackgroundsView::Save()
&& fCurrentInfo->fWorkspace != workspaceMask) {
fCurrentInfo->fWorkspace = fCurrentInfo->fWorkspace
^ workspaceMask;
if (fLastImageIndex > -1) {
fCurrentInfo = new BackgroundImage::BackgroundImageInfo(
workspaceMask, fLastImageIndex, mode, offset,
textWidgetLabelOutline, fCurrentInfo->fImageSet,
fCurrentInfo->fCacheMode);
fCurrent->Add(fCurrentInfo);
}
} else if (fCurrentInfo->fWorkspace == workspaceMask) {
if (fLastImageIndex > -1) {
fCurrentInfo->fTextWidgetLabelOutline =
textWidgetLabelOutline;
fCurrentInfo->fMode = mode;
@@ -636,22 +639,17 @@ BackgroundsView::Save()
fCurrentInfo->fOffset = offset;
fCurrentInfo->fImageIndex = fLastImageIndex;
} else {
fCurrent->Remove(fCurrentInfo);
fCurrentInfo = NULL;
}
}
} else {
fCurrent->RemoveAll();
if (fLastImageIndex > -1) {
fCurrentInfo = new BackgroundImage::BackgroundImageInfo(
B_ALL_WORKSPACES, fLastImageIndex, mode, offset,
textWidgetLabelOutline, fCurrent->GetShowingImageSet(),
fCurrentInfo->fCacheMode);
fCurrent->Add(fCurrentInfo);
}
}
} else if (fLastImageIndex > -1) {
} else {
if (fWorkspaceMenu->FindItem(kMsgCurrentWorkspace)->IsMarked()) {
fCurrentInfo = new BackgroundImage::BackgroundImageInfo(
workspaceMask, fLastImageIndex, mode, offset,
@@ -868,10 +866,6 @@ BackgroundsView::UpdatePreview()
bool imageEnabled = !(fImageMenu->FindItem(kMsgNoImage)->IsMarked());
if (fPlacementMenu->IsEnabled() ^ imageEnabled)
fPlacementMenu->SetEnabled(imageEnabled);
if (fIconLabelOutline->IsEnabled() ^ imageEnabled)
fIconLabelOutline->SetEnabled(imageEnabled);
if (!imageEnabled)
fIconLabelOutline->SetValue(B_CONTROL_ON);
bool textEnabled = (fPlacementMenu->FindItem(kMsgManualPlacement)->IsMarked())
&& imageEnabled;
@@ -969,7 +963,8 @@ BackgroundsView::UpdateButtons()
&& ((fCurrentInfo->fWorkspace != B_ALL_WORKSPACES)
^ (fWorkspaceMenu->FindItem(kMsgCurrentWorkspace)->IsMarked()))) {
hasChanged = true;
} else if (fCurrentInfo->fMode == BackgroundImage::kAtOffset) {
} else if (fCurrentInfo->fImageIndex > -1 &&
fCurrentInfo->fMode == BackgroundImage::kAtOffset) {
BString oldString, newString;
oldString << (int)fCurrentInfo->fOffset.x;
if (oldString != BString(fXPlacementText->Text())) {
@@ -983,6 +978,8 @@ BackgroundsView::UpdateButtons()
}
} else if (fImageMenu->IndexOf(fImageMenu->FindMarked()) > 0) {
hasChanged = true;
} else if (fIconLabelOutline->Value() == B_CONTROL_OFF) {
hasChanged = true;
}
fApply->SetEnabled(hasChanged);