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:
@@ -86,16 +86,16 @@ 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) {
|
||||||
|
bitmap = BTranslationUtils::GetBitmap(path);
|
||||||
|
if (!bitmap) {
|
||||||
|
PRINT(("failed to load background bitmap from path\n"));
|
||||||
|
}
|
||||||
|
} else
|
||||||
break;
|
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(kBackgroundImageInfoWorkspaces, index, (int32 *)&workspaces);
|
||||||
container.FindInt32(kBackgroundImageInfoMode, index, (int32 *)&mode);
|
container.FindInt32(kBackgroundImageInfoMode, index, (int32 *)&mode);
|
||||||
container.FindBool(kBackgroundImageInfoTextOutline, index, &textWidgetLabelOutline);
|
container.FindBool(kBackgroundImageInfoTextOutline, index, &textWidgetLabelOutline);
|
||||||
@@ -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;
|
|
||||||
|
|
||||||
BPath bpath(path);
|
if (container.FindString(kBackgroundImageInfoPath, index, &path) == B_OK) {
|
||||||
int32 imageIndex = view->AddImage(bpath);
|
if (strcmp(path, "")) {
|
||||||
if (imageIndex < 0)
|
BPath bpath(path);
|
||||||
imageIndex = -imageIndex - 1;
|
imageIndex = view->AddImage(bpath);
|
||||||
|
if (imageIndex < 0) {
|
||||||
|
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);
|
||||||
container.AddString(kBackgroundImageInfoPath,
|
if (fBackgroundsView->GetImage(info->fImageIndex) != NULL) {
|
||||||
fBackgroundsView->GetImage(info->fImageIndex)->GetPath().Path());
|
container.AddString(kBackgroundImageInfoPath,
|
||||||
|
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);
|
||||||
|
|||||||
@@ -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,
|
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",
|
"preView",
|
||||||
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_SUBPIXEL_PRECISE);
|
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_SUBPIXEL_PRECISE);
|
||||||
fPreview->AddChild(fPreView);
|
fPreview->AddChild(fPreView);
|
||||||
@@ -545,33 +545,38 @@ BackgroundsView::UpdateWithCurrent(void)
|
|||||||
fIconLabelOutline->SetValue(fCurrentInfo->fTextWidgetLabelOutline
|
fIconLabelOutline->SetValue(fCurrentInfo->fTextWidgetLabelOutline
|
||||||
? B_CONTROL_ON : B_CONTROL_OFF);
|
? 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;
|
fLastImageIndex = fCurrentInfo->fImageIndex;
|
||||||
FindImageItem(fLastImageIndex)->SetMarked(true);
|
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};
|
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,38 +626,30 @@ 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;
|
if (fCurrentInfo->fMode == BackgroundImage::kAtOffset)
|
||||||
if (fCurrentInfo->fMode == BackgroundImage::kAtOffset)
|
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 if (fLastImageIndex > -1) {
|
} else {
|
||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user