From bca3f1efbfbbeba03fb4e11df34f1c1c8770e2b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 3 Nov 2006 15:13:31 +0000 Subject: [PATCH] Added support for the vector icons to FileTypes and DiskProbe. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19194 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/diskprobe/AttributeEditors.cpp | 44 ++++++++++++++++--- src/apps/diskprobe/Jamfile | 1 + src/apps/diskprobe/ProbeView.cpp | 4 +- src/preferences/filetypes/FileTypesWindow.cpp | 2 +- src/preferences/filetypes/IconView.cpp | 4 +- .../filetypes/MimeTypeListView.cpp | 2 +- 6 files changed, 46 insertions(+), 11 deletions(-) diff --git a/src/apps/diskprobe/AttributeEditors.cpp b/src/apps/diskprobe/AttributeEditors.cpp index 988d51a9cd..2dd8183ad7 100644 --- a/src/apps/diskprobe/AttributeEditors.cpp +++ b/src/apps/diskprobe/AttributeEditors.cpp @@ -7,6 +7,10 @@ #include "AttributeEditors.h" #include "DataEditor.h" +#ifdef HAIKU_TARGET_PLATFORM_HAIKU +# include +#endif + #include #include #include @@ -764,7 +768,8 @@ ImageView::ImageView(BRect rect, DataEditor &editor) fEditor(editor), fBitmap(NULL) { - if (editor.Type() == 'MICN' || editor.Type() == 'ICON') + if (editor.Type() == 'MICN' || editor.Type() == 'ICON' + || (!strcmp(editor.Attribute(), "BEOS:ICON") && editor.Type() == B_RAW_TYPE)) SetName("Icon View"); fDescriptionView = new BStringView(Bounds(), "", "Could not read image", B_FOLLOW_NONE); @@ -817,8 +822,11 @@ ImageView::MessageReceived(BMessage *message) void ImageView::Draw(BRect updateRect) { - if (fBitmap != NULL) + if (fBitmap != NULL) { + SetDrawingMode(B_OP_ALPHA); DrawBitmap(fBitmap, BPoint((Bounds().Width() - fBitmap->Bounds().Width()) / 2, 0)); + SetDrawingMode(B_OP_COPY); + } } @@ -848,6 +856,10 @@ ImageView::UpdateImage() fEditor.SetViewSize(viewSize); return; } + if (fBitmap != NULL && !strcmp(fEditor.Attribute(), "BEOS:ICON") + && fEditor.Type() == B_RAW_TYPE) { + return; + } delete fBitmap; fBitmap = NULL; @@ -863,6 +875,20 @@ ImageView::UpdateImage() if (fBitmap->InitCheck() == B_OK) fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8); break; +#ifdef HAIKU_TARGET_PLATFORM_HAIKU + case B_RAW_TYPE: + if (strcmp(fEditor.Attribute(), "BEOS:ICON")) + break; + + fBitmap = new BBitmap(BRect(0, 0, 127, 127), B_RGB32); + if (fBitmap->InitCheck() != B_OK || fEditor.FileSize() > 64 * 1024 + || BIconUtils::GetVectorIcon((const uint8 *)data, + (size_t)fEditor.FileSize(), fBitmap) != B_OK) { + delete fBitmap; + fBitmap = NULL; + } + break; +#endif case 'PNG ': { BMemoryIO stream(data, fEditor.FileSize()); @@ -883,19 +909,23 @@ ImageView::UpdateImage() // Update the bitmap description. If no image can be displayed, // we will show our "unsupported" message - if (fBitmap->InitCheck() != B_OK) { + if (fBitmap != NULL && fBitmap->InitCheck() != B_OK) { delete fBitmap; fBitmap = NULL; } if (fBitmap != NULL) { char buffer[256]; - const char *type; + const char *type = "Unknown Type"; switch (fEditor.Type()) { case 'MICN': case 'ICON': type = "Icon"; break; + case B_RAW_TYPE: + if (!strcmp(fEditor.Attribute(), "BEOS:ICON")) + type = "Icon"; + break; case 'PNG ': type = "PNG Format"; break; @@ -903,7 +933,6 @@ ImageView::UpdateImage() type = "Flattened Bitmap"; break; default: - type = "Unknown Type"; break; } const char *colorSpace; @@ -1017,6 +1046,11 @@ GetTypeEditorFor(BRect rect, DataEditor &editor) return new ImageView(rect, editor); } +#ifdef HAIKU_TARGET_PLATFORM_HAIKU + if (!strcmp(editor.Attribute(), "BEOS:ICON") && editor.Type() == B_RAW_TYPE) + return new ImageView(rect, editor); +#endif + return NULL; } diff --git a/src/apps/diskprobe/Jamfile b/src/apps/diskprobe/Jamfile index 488280aa98..38dd6c7f7b 100644 --- a/src/apps/diskprobe/Jamfile +++ b/src/apps/diskprobe/Jamfile @@ -2,6 +2,7 @@ SubDir HAIKU_TOP src apps diskprobe ; SetSubDirSupportedPlatformsBeOSCompatible ; +UseLibraryHeaders icon ; UsePrivateHeaders shared ; Application DiskProbe : diff --git a/src/apps/diskprobe/ProbeView.cpp b/src/apps/diskprobe/ProbeView.cpp index 4b3ec312af..b1f381c56d 100644 --- a/src/apps/diskprobe/ProbeView.cpp +++ b/src/apps/diskprobe/ProbeView.cpp @@ -236,7 +236,7 @@ IconView::Draw(BRect updateRect) if (fBitmap == NULL) return; - SetDrawingMode(B_OP_OVER); + SetDrawingMode(B_OP_ALPHA); DrawBitmap(fBitmap, updateRect, updateRect); SetDrawingMode(B_OP_COPY); } @@ -246,7 +246,7 @@ void IconView::UpdateIcon() { if (fBitmap == NULL) - fBitmap = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8); + fBitmap = new BBitmap(BRect(0, 0, 31, 31), B_RGB32); if (fBitmap != NULL) { status_t status = B_ERROR; diff --git a/src/preferences/filetypes/FileTypesWindow.cpp b/src/preferences/filetypes/FileTypesWindow.cpp index 30dc78839d..602408a948 100644 --- a/src/preferences/filetypes/FileTypesWindow.cpp +++ b/src/preferences/filetypes/FileTypesWindow.cpp @@ -115,7 +115,7 @@ TypeIconView::SetTo(BMimeType* type) if (type != NULL) { if (fIcon == NULL) { fIcon = new BBitmap(BRect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1), - B_CMAP8); + B_RGB32); } icon_for_type(*type, *fIcon, B_LARGE_ICON, &fIconSource); diff --git a/src/preferences/filetypes/IconView.cpp b/src/preferences/filetypes/IconView.cpp index 1293367600..d0bba10251 100644 --- a/src/preferences/filetypes/IconView.cpp +++ b/src/preferences/filetypes/IconView.cpp @@ -96,8 +96,8 @@ IconView::SetTo(entry_ref* ref) if (node.InitCheck() != B_OK || info.InitCheck() != B_OK) return; - - BBitmap* icon = new BBitmap(BRect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1), B_CMAP8); + + BBitmap* icon = new BBitmap(BRect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1), B_RGB32); if (info.GetIcon(icon, B_LARGE_ICON) != B_OK) { delete icon; return; diff --git a/src/preferences/filetypes/MimeTypeListView.cpp b/src/preferences/filetypes/MimeTypeListView.cpp index 99f986c55c..88f1441698 100644 --- a/src/preferences/filetypes/MimeTypeListView.cpp +++ b/src/preferences/filetypes/MimeTypeListView.cpp @@ -137,7 +137,7 @@ MimeTypeItem::DrawItem(BView* owner, BRect frame, bool complete) owner->FillRect(rect, B_SOLID_LOW); } - BBitmap bitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_CMAP8); + BBitmap bitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_RGB32); BMimeType mimeType(fType.String()); status_t status = icon_for_type(mimeType, bitmap, B_MINI_ICON); if (status < B_OK) {