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:
@@ -73,9 +73,9 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop)
|
||||
status_t error = node->ReadAttr(kBackgroundImageInfo, info.type, 0, buffer, (size_t)info.size);
|
||||
if (error == info.size)
|
||||
error = container.Unflatten(buffer);
|
||||
|
||||
|
||||
delete [] buffer;
|
||||
|
||||
|
||||
if (error != B_OK)
|
||||
return NULL;
|
||||
|
||||
@@ -86,26 +86,26 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop)
|
||||
Mode mode = kTiled;
|
||||
bool textWidgetLabelOutline = false;
|
||||
BPoint offset;
|
||||
|
||||
if (container.FindString(kBackgroundImageInfoPath, index, &path) != B_OK)
|
||||
BBitmap *bitmap = NULL;
|
||||
|
||||
if (container.FindString(kBackgroundImageInfoPath, index, &path) == B_OK) {
|
||||
bitmap = BTranslationUtils::GetBitmap(path);
|
||||
if (!bitmap) {
|
||||
PRINT(("failed to load background bitmap from path\n"));
|
||||
}
|
||||
} else
|
||||
break;
|
||||
|
||||
BBitmap *bitmap = BTranslationUtils::GetBitmap(path);
|
||||
if (!bitmap) {
|
||||
// PRINT(("failed to load background bitmap from path\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
container.FindInt32(kBackgroundImageInfoWorkspaces, index, (int32 *)&workspaces);
|
||||
container.FindInt32(kBackgroundImageInfoMode, index, (int32 *)&mode);
|
||||
container.FindBool(kBackgroundImageInfoTextOutline, index, &textWidgetLabelOutline);
|
||||
container.FindPoint(kBackgroundImageInfoOffset, index, &offset);
|
||||
|
||||
|
||||
BackgroundImage::BackgroundImageInfo *imageInfo = new
|
||||
BackgroundImage::BackgroundImageInfo(workspaces, bitmap, mode, offset,
|
||||
textWidgetLabelOutline);
|
||||
|
||||
if (!result)
|
||||
if (!result)
|
||||
result = new BackgroundImage(node, isDesktop);
|
||||
|
||||
result->Add(imageInfo);
|
||||
@@ -137,9 +137,10 @@ BackgroundImage::BackgroundImage(const BNode *node, bool desktop)
|
||||
fView(NULL),
|
||||
fShowingBitmap(NULL),
|
||||
fBitmapForWorkspaceList(1, true)
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -250,7 +257,7 @@ BackgroundImage::ImageInfoForWorkspace(int32 workspace) const
|
||||
if (info->fWorkspace == workspaceMask)
|
||||
return info;
|
||||
if (info->fWorkspace & workspaceMask)
|
||||
result = info;
|
||||
result = info;
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -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;
|
||||
|
||||
BPath bpath(path);
|
||||
int32 imageIndex = view->AddImage(bpath);
|
||||
if (imageIndex < 0)
|
||||
imageIndex = -imageIndex - 1;
|
||||
if (container.FindString(kBackgroundImageInfoPath, index, &path) == B_OK) {
|
||||
if (strcmp(path, "")) {
|
||||
BPath bpath(path);
|
||||
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);
|
||||
container.AddString(kBackgroundImageInfoPath,
|
||||
fBackgroundsView->GetImage(info->fImageIndex)->GetPath().Path());
|
||||
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);
|
||||
|
||||
@@ -168,7 +168,7 @@ BackgroundsView::BackgroundsView(BRect frame, const char *name, int32 resize,
|
||||
}
|
||||
|
||||
fPreView = new PreView(BRect((150 - preview_width) / 2, 25 + 90 - preview_height,
|
||||
150 - (150 - preview_width) / 2, 25 + 90),
|
||||
150 - (150 - preview_width) / 2, 25 + 90),
|
||||
"preView",
|
||||
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_SUBPIXEL_PRECISE);
|
||||
fPreview->AddChild(fPreView);
|
||||
@@ -544,34 +544,39 @@ BackgroundsView::UpdateWithCurrent(void)
|
||||
} else {
|
||||
fIconLabelOutline->SetValue(fCurrentInfo->fTextWidgetLabelOutline
|
||||
? B_CONTROL_ON : B_CONTROL_OFF);
|
||||
|
||||
BString xtext, ytext;
|
||||
int32 cmd = 0;
|
||||
switch (fCurrentInfo->fMode) {
|
||||
case BackgroundImage::kCentered:
|
||||
cmd = kMsgCenterPlacement;
|
||||
break;
|
||||
case BackgroundImage::kScaledToFit:
|
||||
cmd = kMsgScalePlacement;
|
||||
break;
|
||||
case BackgroundImage::kAtOffset:
|
||||
cmd = kMsgManualPlacement;
|
||||
xtext << (int)fCurrentInfo->fOffset.x;
|
||||
ytext << (int)fCurrentInfo->fOffset.y;
|
||||
break;
|
||||
case BackgroundImage::kTiled:
|
||||
cmd = kMsgTilePlacement;
|
||||
break;
|
||||
}
|
||||
|
||||
if (cmd != 0)
|
||||
fPlacementMenu->FindItem(cmd)->SetMarked(true);
|
||||
|
||||
fXPlacementText->SetText(xtext.String());
|
||||
fYPlacementText->SetText(ytext.String());
|
||||
|
||||
|
||||
fLastImageIndex = fCurrentInfo->fImageIndex;
|
||||
FindImageItem(fLastImageIndex)->SetMarked(true);
|
||||
|
||||
if (fLastImageIndex > -1) {
|
||||
|
||||
BString xtext, ytext;
|
||||
int32 cmd = 0;
|
||||
switch (fCurrentInfo->fMode) {
|
||||
case BackgroundImage::kCentered:
|
||||
cmd = kMsgCenterPlacement;
|
||||
break;
|
||||
case BackgroundImage::kScaledToFit:
|
||||
cmd = kMsgScalePlacement;
|
||||
break;
|
||||
case BackgroundImage::kAtOffset:
|
||||
cmd = kMsgManualPlacement;
|
||||
xtext << (int)fCurrentInfo->fOffset.x;
|
||||
ytext << (int)fCurrentInfo->fOffset.y;
|
||||
break;
|
||||
case BackgroundImage::kTiled:
|
||||
cmd = kMsgTilePlacement;
|
||||
break;
|
||||
}
|
||||
|
||||
if (cmd != 0)
|
||||
fPlacementMenu->FindItem(cmd)->SetMarked(true);
|
||||
|
||||
fXPlacementText->SetText(xtext.String());
|
||||
fYPlacementText->SetText(ytext.String());
|
||||
} 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,38 +626,30 @@ 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);
|
||||
}
|
||||
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;
|
||||
if (fCurrentInfo->fMode == BackgroundImage::kAtOffset)
|
||||
fCurrentInfo->fOffset = offset;
|
||||
fCurrentInfo->fTextWidgetLabelOutline =
|
||||
textWidgetLabelOutline;
|
||||
fCurrentInfo->fMode = mode;
|
||||
if (fCurrentInfo->fMode == BackgroundImage::kAtOffset)
|
||||
fCurrentInfo->fOffset = offset;
|
||||
|
||||
fCurrentInfo->fImageIndex = fLastImageIndex;
|
||||
} else {
|
||||
fCurrent->Remove(fCurrentInfo);
|
||||
fCurrentInfo = NULL;
|
||||
}
|
||||
fCurrentInfo->fImageIndex = fLastImageIndex;
|
||||
}
|
||||
} else {
|
||||
fCurrent->RemoveAll();
|
||||
if (fLastImageIndex > -1) {
|
||||
fCurrentInfo = new BackgroundImage::BackgroundImageInfo(
|
||||
B_ALL_WORKSPACES, fLastImageIndex, mode, offset,
|
||||
textWidgetLabelOutline, fCurrent->GetShowingImageSet(),
|
||||
fCurrentInfo->fCacheMode);
|
||||
fCurrent->Add(fCurrentInfo);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user