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