Tracker: Refactor IconCache size handling and usages.

* Instead of taking an icon_size, which we were having to cast
   random integers to anyway, just take a BSize and convert internally
   as needed. This simplifies a lot of usages of IconCache methods.

 * Compute what B_MINI_ICON size will be at startup. This way,
   we do not wind up caching "mini" icons in the fLarge*Icon variables
   under HiDPI.

   This does have a downside that if anything actually
   does try to fetch "true mini" (16x16) icons when the real
   ComposeIconSize(B_MINI_ICON) is larger than that, it will wind up
   (confusingly) in fLarge*Icon, but that should not cause problems
   and after this commit should not happen at all, anyway.

 * Make mini-icon-mode use ComposeSize instead of the hardcoded 16x16,
   and adjust metrics computations around it.

 * Fetch larger icons in MountMenu logic. Also use BString::SetToFormat.

 * Remove an unused, deprecated method from BPoseView.

 * Rename variables in thumbnail generation code to match new behavior.
This commit is contained in:
Augustin Cavalier
2022-08-26 17:24:44 -04:00
parent 9f4bb0f544
commit 0c973c9467
14 changed files with 166 additions and 164 deletions
+3 -4
View File
@@ -414,7 +414,7 @@ DraggableContainerIcon::MouseDown(BPoint where)
window->CurrentMessage()->FindInt32("buttons", (int32*)&buttons);
if (IconCache::sIconCache->IconHitTest(where, window->TargetModel(),
kNormalIcon, (icon_size)(fIconSize.IntegerWidth() + 1))) {
kNormalIcon, fIconSize)) {
// The click hit the icon, initiate a drag
fDragButton = buttons
& (B_PRIMARY_MOUSE_BUTTON | B_SECONDARY_MOUSE_BUTTON);
@@ -487,7 +487,7 @@ DraggableContainerIcon::MouseMoved(BPoint where, uint32, const BMessage*)
// Draw the icon
float hIconOffset = (rect.Width() - Bounds().Width()) / 2;
IconCache::sIconCache->Draw(model, view, BPoint(hIconOffset, 0),
kNormalIcon, (icon_size)(fIconSize.IntegerWidth() + 1), true);
kNormalIcon, fIconSize, true);
// See if we need to truncate the string
BString nameString = model->Name();
@@ -549,8 +549,7 @@ DraggableContainerIcon::Draw(BRect updateRect)
float iconOffsetX = (Bounds().Width() - fIconSize.Width()) / 2;
float iconOffsetY = (Bounds().Height() - fIconSize.Height()) / 2;
IconCache::sIconCache->Draw(window->TargetModel(), this,
BPoint(iconOffsetX, iconOffsetY), kNormalIcon, (icon_size)(fIconSize.IntegerWidth() + 1),
true);
BPoint(iconOffsetX, iconOffsetY), kNormalIcon, fIconSize, true);
}
+77 -60
View File
@@ -63,6 +63,7 @@ All rights reserved.
// generic icon
#include <ControlLook.h>
#include <Debug.h>
#include <Screen.h>
#include <Volume.h>
@@ -102,6 +103,17 @@ All rights reserved.
#undef NODE_CACHE_ASYNC_DRAWS
BSize IconCache::sMiniIconSize;
static inline icon_size
icon_size_for(BSize size)
{
ASSERT(size.Width() == size.Height());
return (icon_size)(size.IntegerWidth() + 1);
}
IconCacheEntry::IconCacheEntry()
:
fLargeIcon(NULL),
@@ -159,7 +171,7 @@ IconCacheEntry::ResolveIfAlias(const SharedIconCache* sharedCache,
bool
IconCacheEntry::CanConstructBitmap(IconDrawMode mode, icon_size) const
IconCacheEntry::CanConstructBitmap(IconDrawMode mode, BSize) const
{
if (mode == kSelected) {
// for now only
@@ -171,19 +183,19 @@ IconCacheEntry::CanConstructBitmap(IconDrawMode mode, icon_size) const
bool
IconCacheEntry::HaveIconBitmap(IconDrawMode mode, icon_size size) const
IconCacheEntry::HaveIconBitmap(IconDrawMode mode, BSize size) const
{
ASSERT(mode == kSelected || mode == kNormalIcon);
// for now only
if (mode == kNormalIcon) {
return size == B_MINI_ICON ? fMiniIcon != NULL
return size == IconCache::sMiniIconSize ? fMiniIcon != NULL
: fLargeIcon != NULL
&& fLargeIcon->Bounds().IntegerWidth() + 1 == size;
&& fLargeIcon->Bounds().Size() == size;
} else if (mode == kSelected) {
return size == B_MINI_ICON ? fHighlightedMiniIcon != NULL
return size == IconCache::sMiniIconSize ? fHighlightedMiniIcon != NULL
: fHighlightedLargeIcon != NULL
&& fHighlightedLargeIcon->Bounds().IntegerWidth() + 1 == size;
&& fHighlightedLargeIcon->Bounds().Size() == size;
}
return false;
@@ -191,18 +203,18 @@ IconCacheEntry::HaveIconBitmap(IconDrawMode mode, icon_size size) const
BBitmap*
IconCacheEntry::IconForMode(IconDrawMode mode, icon_size size) const
IconCacheEntry::IconForMode(IconDrawMode mode, BSize size) const
{
ASSERT(mode == kSelected || mode == kNormalIcon);
// for now only
if (mode == kNormalIcon) {
if (size == B_MINI_ICON)
if (size == IconCache::sMiniIconSize)
return fMiniIcon;
else
return fLargeIcon;
} else if (mode == kSelected) {
if (size == B_MINI_ICON)
if (size == IconCache::sMiniIconSize)
return fHighlightedMiniIcon;
else
return fHighlightedLargeIcon;
@@ -214,7 +226,7 @@ IconCacheEntry::IconForMode(IconDrawMode mode, icon_size size) const
bool
IconCacheEntry::IconHitTest(BPoint where, IconDrawMode mode,
icon_size size) const
BSize size) const
{
ASSERT(where.x < size && where.y < size);
BBitmap* bitmap = IconForMode(mode, size);
@@ -236,7 +248,7 @@ IconCacheEntry::IconHitTest(BPoint where, IconDrawMode mode,
+ floorf(where.x) * 4 + 3)) > 20;
case B_CMAP8:
return *(bits + (int32)(floorf(where.y) * size + where.x))
return *(bits + (int32)(floorf(where.y) * icon_size_for(size) + where.x))
!= B_TRANSPARENT_8_BIT;
default:
@@ -248,7 +260,7 @@ IconCacheEntry::IconHitTest(BPoint where, IconDrawMode mode,
BBitmap*
IconCacheEntry::ConstructBitmap(BBitmap* constructFrom,
IconDrawMode requestedMode, IconDrawMode constructFromMode,
icon_size size, LazyBitmapAllocator* lazyBitmap)
BSize size, LazyBitmapAllocator* lazyBitmap)
{
ASSERT(requestedMode == kSelected && constructFromMode == kNormalIcon);
// for now
@@ -263,10 +275,10 @@ IconCacheEntry::ConstructBitmap(BBitmap* constructFrom,
BBitmap*
IconCacheEntry::ConstructBitmap(IconDrawMode requestedMode, icon_size size,
IconCacheEntry::ConstructBitmap(IconDrawMode requestedMode, BSize size,
LazyBitmapAllocator* lazyBitmap)
{
BBitmap* source = (size == B_MINI_ICON) ? fMiniIcon : fLargeIcon;
BBitmap* source = (size == IconCache::sMiniIconSize) ? fMiniIcon : fLargeIcon;
ASSERT(source != NULL);
return ConstructBitmap(source, requestedMode, kNormalIcon, size,
@@ -276,7 +288,7 @@ IconCacheEntry::ConstructBitmap(IconDrawMode requestedMode, icon_size size,
bool
IconCacheEntry::AlternateModeForIconConstructing(IconDrawMode requestedMode,
IconDrawMode &alternate, icon_size)
IconDrawMode &alternate, BSize)
{
if ((requestedMode & kSelected) != 0) {
// for now
@@ -289,17 +301,16 @@ IconCacheEntry::AlternateModeForIconConstructing(IconDrawMode requestedMode,
void
IconCacheEntry::SetIcon(BBitmap* bitmap, IconDrawMode mode, icon_size size,
bool /*create*/)
IconCacheEntry::SetIcon(BBitmap* bitmap, IconDrawMode mode, BSize size)
{
BBitmap** icon = NULL;
if (mode == kNormalIcon) {
if (size == B_MINI_ICON)
if (size == IconCache::sMiniIconSize)
icon = &fMiniIcon;
else
icon = &fLargeIcon;
} else if (mode == kSelectedIcon) {
if (size == B_MINI_ICON)
if (size == IconCache::sMiniIconSize)
icon = &fHighlightedMiniIcon;
else
icon = &fHighlightedLargeIcon;
@@ -318,6 +329,8 @@ IconCache::IconCache()
fInitHighlightTable(true)
{
InitHighlightTable();
sMiniIconSize = be_control_look->ComposeIconSize(B_MINI_ICON);
}
@@ -332,7 +345,7 @@ IconCache::IconCache()
IconCacheEntry*
IconCache::GetIconForPreferredApp(const char* fileTypeSignature,
const char* preferredApp, IconDrawMode mode, icon_size size,
const char* preferredApp, IconDrawMode mode, BSize size,
LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry)
{
ASSERT(fSharedCache.IsLocked());
@@ -362,7 +375,7 @@ IconCache::GetIconForPreferredApp(const char* fileTypeSignature,
BString signature(fileTypeSignature);
signature.ToLower();
if (preferredAppType.GetIconForType(signature.String(),
lazyBitmap->Get(), size) != B_OK) {
lazyBitmap->Get(), icon_size_for(size)) != B_OK) {
return NULL;
}
@@ -389,7 +402,7 @@ IconCache::GetIconForPreferredApp(const char* fileTypeSignature,
IconCacheEntry*
IconCache::GetIconFromMetaMime(const char* fileType, IconDrawMode mode,
icon_size size, LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry)
BSize size, LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry)
{
ASSERT(fSharedCache.IsLocked());
@@ -409,7 +422,7 @@ IconCache::GetIconFromMetaMime(const char* fileType, IconDrawMode mode,
BMimeType mime(fileType);
// try getting the icon directly from the metamime
if (mime.GetIcon(lazyBitmap->Get(), size) != B_OK) {
if (mime.GetIcon(lazyBitmap->Get(), icon_size_for(size)) != B_OK) {
// try getting it from the preferred app of this type
char preferredAppSig[B_MIME_TYPE_LENGTH];
if (mime.GetPreferredApp(preferredAppSig) != B_OK)
@@ -472,7 +485,7 @@ IconCache::GetIconFromMetaMime(const char* fileType, IconDrawMode mode,
IconCacheEntry*
IconCache::GetIconFromFileTypes(ModelNodeLazyOpener* modelOpener,
IconSource &source, IconDrawMode mode, icon_size size,
IconSource &source, IconDrawMode mode, BSize size,
LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry)
{
ASSERT(fSharedCache.IsLocked());
@@ -564,7 +577,7 @@ IconCache::GetVolumeIcon(AutoLock<SimpleIconCache>*nodeCacheLocker,
AutoLock<SimpleIconCache>* sharedCacheLocker,
AutoLock<SimpleIconCache>** resultingOpenCache,
Model* model, IconSource &source,
IconDrawMode mode, icon_size size, LazyBitmapAllocator* lazyBitmap)
IconDrawMode mode, BSize size, LazyBitmapAllocator* lazyBitmap)
{
*resultingOpenCache = nodeCacheLocker;
nodeCacheLocker->Lock();
@@ -597,7 +610,8 @@ IconCache::GetVolumeIcon(AutoLock<SimpleIconCache>*nodeCacheLocker,
if (volume.IsShared()) {
// check if it's a network share and give it a special icon
BBitmap* bitmap = lazyBitmap->Get();
GetTrackerResources()->GetIconResource(R_ShareIcon, size, bitmap);
GetTrackerResources()->GetIconResource(R_ShareIcon,
icon_size_for(size), bitmap);
if (entry == NULL) {
PRINT_ADD_ITEM(
("File %s; Line %d # adding entry for model %s\n",
@@ -605,7 +619,7 @@ IconCache::GetVolumeIcon(AutoLock<SimpleIconCache>*nodeCacheLocker,
entry = fNodeCache.AddItem(model->NodeRef());
}
entry->SetIcon(lazyBitmap->Adopt(), kNormalIcon, size);
} else if (volume.GetIcon(lazyBitmap->Get(), size) == B_OK) {
} else if (volume.GetIcon(lazyBitmap->Get(), icon_size_for(size)) == B_OK) {
// ask the device for an icon
BBitmap* bitmap = lazyBitmap->Adopt();
ASSERT(bitmap != NULL);
@@ -642,7 +656,7 @@ IconCache::GetRootIcon(AutoLock<SimpleIconCache>*,
AutoLock<SimpleIconCache>* sharedCacheLocker,
AutoLock<SimpleIconCache>** resultingOpenCache,
Model*, IconSource &source, IconDrawMode mode,
icon_size size, LazyBitmapAllocator* lazyBitmap)
BSize size, LazyBitmapAllocator* lazyBitmap)
{
*resultingOpenCache = sharedCacheLocker;
(*resultingOpenCache)->Lock();
@@ -657,7 +671,7 @@ IconCacheEntry*
IconCache::GetWellKnownIcon(AutoLock<SimpleIconCache>*,
AutoLock<SimpleIconCache>* sharedCacheLocker,
AutoLock<SimpleIconCache>** resultingOpenCache,
Model* model, IconSource &source, IconDrawMode mode, icon_size size,
Model* model, IconSource &source, IconDrawMode mode, BSize size,
LazyBitmapAllocator* lazyBitmap)
{
const WellKnowEntryList::WellKnownEntry* wellKnownEntry
@@ -749,7 +763,8 @@ IconCache::GetWellKnownIcon(AutoLock<SimpleIconCache>*,
entry = fSharedCache.AddItem(type.String());
BBitmap* bitmap = lazyBitmap->Get();
GetTrackerResources()->GetIconResource(resourceId, size, bitmap);
GetTrackerResources()->GetIconResource(resourceId,
icon_size_for(size), bitmap);
entry->SetIcon(lazyBitmap->Adopt(), kNormalIcon, size);
}
@@ -770,7 +785,7 @@ IconCache::GetNodeIcon(ModelNodeLazyOpener* modelOpener,
AutoLock<SimpleIconCache>* nodeCacheLocker,
AutoLock<SimpleIconCache>** resultingOpenCache,
Model* model, IconSource& source,
IconDrawMode mode, icon_size size,
IconDrawMode mode, BSize size,
LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry, bool permanent)
{
*resultingOpenCache = nodeCacheLocker;
@@ -791,11 +806,13 @@ IconCache::GetNodeIcon(ModelNodeLazyOpener* modelOpener,
status_t result = B_ERROR;
if (model->IsExecutable()
&& (file = dynamic_cast<BFile*>(model->Node())) != NULL) {
result = GetAppIconFromAttr(file, lazyBitmap->Get(), size);
result = GetAppIconFromAttr(file, lazyBitmap->Get(), icon_size_for(size));
} else {
result = GetThumbnailFromAttr(model, lazyBitmap->Get(), size);
if (result != B_OK && result != B_BUSY)
result = GetFileIconFromAttr(model->Node(), lazyBitmap->Get(), size);
if (result != B_OK && result != B_BUSY) {
result = GetFileIconFromAttr(model->Node(), lazyBitmap->Get(),
icon_size_for(size));
}
}
if (result == B_OK) {
@@ -832,7 +849,7 @@ IconCacheEntry*
IconCache::GetGenericIcon(AutoLock<SimpleIconCache>* sharedCacheLocker,
AutoLock<SimpleIconCache>** resultingOpenCache,
Model* model, IconSource &source,
IconDrawMode mode, icon_size size,
IconDrawMode mode, BSize size,
LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry)
{
*resultingOpenCache = sharedCacheLocker;
@@ -863,7 +880,7 @@ IconCache::GetGenericIcon(AutoLock<SimpleIconCache>* sharedCacheLocker,
IconCacheEntry*
IconCache::GetFallbackIcon(AutoLock<SimpleIconCache>* sharedCacheLocker,
AutoLock<SimpleIconCache>** resultingOpenCache,
Model* model, IconDrawMode mode, icon_size size,
Model* model, IconDrawMode mode, BSize size,
LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry)
{
*resultingOpenCache = sharedCacheLocker;
@@ -873,7 +890,8 @@ IconCache::GetFallbackIcon(AutoLock<SimpleIconCache>* sharedCacheLocker,
model->PreferredAppSignature());
BBitmap* bitmap = lazyBitmap->Get();
GetTrackerResources()->GetIconResource(R_FileIcon, size, bitmap);
GetTrackerResources()->GetIconResource(R_FileIcon,
icon_size_for(size), bitmap);
entry->SetIcon(lazyBitmap->Adopt(), kNormalIcon, size);
if (mode != kNormalIcon) {
@@ -891,7 +909,7 @@ IconCacheEntry*
IconCache::Preload(AutoLock<SimpleIconCache>* nodeCacheLocker,
AutoLock<SimpleIconCache>* sharedCacheLocker,
AutoLock<SimpleIconCache>** resultingCache,
Model* model, IconDrawMode mode, icon_size size,
Model* model, IconDrawMode mode, BSize size,
bool permanent)
{
IconCacheEntry* entry = NULL;
@@ -1078,7 +1096,7 @@ IconCache::Preload(AutoLock<SimpleIconCache>* nodeCacheLocker,
void
IconCache::Draw(Model* model, BView* view, BPoint where, IconDrawMode mode,
icon_size size, bool async)
BSize size, bool async)
{
// the following does not actually lock the caches, we are using the
// lockLater mode; we will decide which of the two to lock down depending
@@ -1108,7 +1126,7 @@ IconCache::Draw(Model* model, BView* view, BPoint where, IconDrawMode mode,
void
IconCache::SyncDraw(Model* model, BView* view, BPoint where,
IconDrawMode mode, icon_size size,
IconDrawMode mode, BSize size,
void (*blitFunc)(BView*, BPoint, BBitmap*, void*),
void* passThruState)
{
@@ -1130,7 +1148,7 @@ IconCache::SyncDraw(Model* model, BView* view, BPoint where,
void
IconCache::Preload(Model* model, IconDrawMode mode, icon_size size,
IconCache::Preload(Model* model, IconDrawMode mode, BSize size,
bool permanent)
{
AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false);
@@ -1142,7 +1160,7 @@ IconCache::Preload(Model* model, IconDrawMode mode, icon_size size,
status_t
IconCache::Preload(const char* fileType, IconDrawMode mode, icon_size size)
IconCache::Preload(const char* fileType, IconDrawMode mode, BSize size)
{
AutoLock<SimpleIconCache> sharedCacheLocker(&fSharedCache);
LazyBitmapAllocator lazyBitmap(size);
@@ -1160,7 +1178,7 @@ IconCache::Preload(const char* fileType, IconDrawMode mode, icon_size size)
return B_OK;
// try getting the icon directly from the metamime
result = mime.GetIcon(lazyBitmap.Get(), size);
result = mime.GetIcon(lazyBitmap.Get(), icon_size_for(size));
if (result != B_OK)
return result;
@@ -1240,7 +1258,7 @@ IconCache::IconChanged(const char* mimeType, const char* appSignature)
BBitmap*
IconCache::MakeSelectedIcon(const BBitmap* normal, icon_size size,
IconCache::MakeSelectedIcon(const BBitmap* normal, BSize size,
LazyBitmapAllocator* lazyBitmap)
{
return MakeTransformedIcon(normal, size, fHighlightTable, lazyBitmap);
@@ -1291,7 +1309,7 @@ IconCache::InitHighlightTable()
BBitmap*
IconCache::MakeTransformedIcon(const BBitmap* source, icon_size /*size*/,
IconCache::MakeTransformedIcon(const BBitmap* source, BSize /*size*/,
int32 colorTransformTable[], LazyBitmapAllocator* lazyBitmap)
{
if (fInitHighlightTable)
@@ -1305,8 +1323,7 @@ IconCache::MakeTransformedIcon(const BBitmap* source, icon_size /*size*/,
// && result->Bounds() == source->Bounds());
if (result->ColorSpace() != source->ColorSpace()
|| result->Bounds() != source->Bounds()) {
printf("IconCache::MakeTransformedIcon() - "
"bitmap format mismatch!\n");
printf("IconCache::MakeTransformedIcon() - bitmap format mismatch!\n");
return NULL;
}
@@ -1355,7 +1372,7 @@ IconCache::MakeTransformedIcon(const BBitmap* source, icon_size /*size*/,
bool
IconCache::IconHitTest(BPoint where, const Model* model, IconDrawMode mode,
icon_size size)
BSize size)
{
AutoLock<SimpleIconCache> nodeCacheLocker(&fNodeCache, false);
AutoLock<SimpleIconCache> sharedCacheLocker(&fSharedCache, false);
@@ -1417,7 +1434,7 @@ SharedIconCache::SharedIconCache()
void
SharedIconCache::Draw(IconCacheEntry* entry, BView* view, BPoint where,
IconDrawMode mode, icon_size size, bool async)
IconDrawMode mode, BSize size, bool async)
{
((SharedCacheEntry*)entry)->Draw(view, where, mode, size, async);
}
@@ -1425,7 +1442,7 @@ SharedIconCache::Draw(IconCacheEntry* entry, BView* view, BPoint where,
void
SharedIconCache::Draw(IconCacheEntry* entry, BView* view, BPoint where,
IconDrawMode mode, icon_size size, void (*blitFunc)(BView*, BPoint,
IconDrawMode mode, BSize size, void (*blitFunc)(BView*, BPoint,
BBitmap*, void*), void* passThruState)
{
((SharedCacheEntry*)entry)->Draw(view, where, mode, size,
@@ -1512,7 +1529,7 @@ SharedCacheEntry::SharedCacheEntry(const char* fileType,
void
SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode,
icon_size size, bool async)
BSize size, bool async)
{
BBitmap* bitmap = IconForMode(mode, size);
ASSERT(bitmap != NULL);
@@ -1538,7 +1555,7 @@ SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode,
void
SharedCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode,
icon_size size, void (*blitFunc)(BView*, BPoint, BBitmap*, void*),
BSize size, void (*blitFunc)(BView*, BPoint, BBitmap*, void*),
void* passThruState)
{
BBitmap* bitmap = IconForMode(mode, size);
@@ -1598,7 +1615,7 @@ NodeCacheEntry::NodeCacheEntry(const node_ref* node, bool permanent)
void
NodeCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode,
icon_size size, bool async)
BSize size, bool async)
{
BBitmap* bitmap = IconForMode(mode, size);
if (bitmap == NULL)
@@ -1627,7 +1644,7 @@ NodeCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode,
void
NodeCacheEntry::Draw(BView* view, BPoint where, IconDrawMode mode,
icon_size size, void (*blitFunc)(BView*, BPoint, BBitmap*, void*),
BSize size, void (*blitFunc)(BView*, BPoint, BBitmap*, void*),
void* passThruState)
{
BBitmap* bitmap = IconForMode(mode, size);
@@ -1687,7 +1704,7 @@ NodeIconCache::NodeIconCache()
void
NodeIconCache::Draw(IconCacheEntry* entry, BView* view, BPoint where,
IconDrawMode mode, icon_size size, bool async)
IconDrawMode mode, BSize size, bool async)
{
((NodeCacheEntry*)entry)->Draw(view, where, mode, size, async);
}
@@ -1695,7 +1712,7 @@ NodeIconCache::Draw(IconCacheEntry* entry, BView* view, BPoint where,
void
NodeIconCache::Draw(IconCacheEntry* entry, BView* view, BPoint where,
IconDrawMode mode, icon_size size,
IconDrawMode mode, BSize size,
void (*blitFunc)(BView*, BPoint, BBitmap*, void*), void* passThruState)
{
((NodeCacheEntry*)entry)->Draw(view, where, mode, size,
@@ -1786,7 +1803,7 @@ SimpleIconCache::SimpleIconCache(const char* name)
void
SimpleIconCache::Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode,
icon_size, bool)
BSize, bool)
{
TRESPASS();
// pure virtual, do nothing
@@ -1795,7 +1812,7 @@ SimpleIconCache::Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode,
void
SimpleIconCache::Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode,
icon_size, void(*)(BView*, BPoint, BBitmap*, void*), void*)
BSize, void(*)(BView*, BPoint, BBitmap*, void*), void*)
{
TRESPASS();
// pure virtual, do nothing
@@ -1826,7 +1843,7 @@ SimpleIconCache::IsLocked() const
// #pragma mark - LazyBitmapAllocator
LazyBitmapAllocator::LazyBitmapAllocator(icon_size size,
LazyBitmapAllocator::LazyBitmapAllocator(BSize size,
color_space colorSpace, bool preallocate)
:
fBitmap(NULL),
@@ -1848,7 +1865,7 @@ BBitmap*
LazyBitmapAllocator::Get()
{
if (fBitmap == NULL)
fBitmap = new BBitmap(BRect(0, 0, fSize - 1, fSize - 1), fColorSpace);
fBitmap = new BBitmap(BRect(BPoint(0, 0), fSize), fColorSpace);
return fBitmap;
}
+40 -39
View File
@@ -161,21 +161,20 @@ public:
IconCacheEntry* entry);
IconCacheEntry* ResolveIfAlias(const SharedIconCache* sharedCache);
void SetIcon(BBitmap* bitmap, IconDrawMode mode, icon_size size,
bool create = false);
void SetIcon(BBitmap* bitmap, IconDrawMode mode, BSize size);
bool HaveIconBitmap(IconDrawMode mode, icon_size size) const;
bool CanConstructBitmap(IconDrawMode mode, icon_size size) const;
bool HaveIconBitmap(IconDrawMode mode, BSize size) const;
bool CanConstructBitmap(IconDrawMode mode, BSize size) const;
static bool AlternateModeForIconConstructing(IconDrawMode requestedMode,
IconDrawMode &alternate, icon_size size);
IconDrawMode &alternate, BSize size);
BBitmap* ConstructBitmap(BBitmap* constructFrom,
IconDrawMode requestedMode, IconDrawMode constructFromMode,
icon_size size, LazyBitmapAllocator*);
BBitmap* ConstructBitmap(IconDrawMode requestedMode, icon_size size,
BSize size, LazyBitmapAllocator*);
BBitmap* ConstructBitmap(IconDrawMode requestedMode, BSize size,
LazyBitmapAllocator*);
// same as above, always uses normal icon as source
bool IconHitTest(BPoint, IconDrawMode, icon_size) const;
bool IconHitTest(BPoint, IconDrawMode, BSize) const;
// given a point, returns true if a non-transparent pixel was hit
void RetireIcons(BObjectList<BBitmap>* retiredBitmapList);
@@ -188,8 +187,8 @@ public:
// while we are drawing them, shouldn't be a practical problem
protected:
BBitmap* IconForMode(IconDrawMode mode, icon_size size) const;
void SetIconForMode(BBitmap* bitmap, IconDrawMode mode, icon_size size);
BBitmap* IconForMode(IconDrawMode mode, BSize size) const;
void SetIconForMode(BBitmap* bitmap, IconDrawMode mode, BSize size);
// list of most common icons
BBitmap* fLargeIcon;
@@ -212,9 +211,9 @@ public:
virtual ~SimpleIconCache() {}
virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode mode,
icon_size size, bool async = false) = 0;
BSize size, bool async = false) = 0;
virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode,
icon_size, void (*)(BView*, BPoint, BBitmap*, void*),
BSize, void (*)(BView*, BPoint, BBitmap*, void*),
void* = NULL) = 0;
bool Lock();
@@ -231,10 +230,10 @@ public:
SharedCacheEntry();
SharedCacheEntry(const char* fileType, const char* appSignature = 0);
void Draw(BView*, BPoint, IconDrawMode mode, icon_size size,
void Draw(BView*, BPoint, IconDrawMode mode, BSize size,
bool async = false);
void Draw(BView*, BPoint, IconDrawMode, icon_size,
void Draw(BView*, BPoint, IconDrawMode, BSize,
void (*)(BView*, BPoint, BBitmap*, void*), void* = NULL);
const char* FileType() const;
@@ -270,9 +269,9 @@ public:
SharedIconCache();
virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode mode,
icon_size size, bool async = false);
BSize size, bool async = false);
virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode,
icon_size, void (*)(BView*, BPoint, BBitmap*, void*), void* = NULL);
BSize, void (*)(BView*, BPoint, BBitmap*, void*), void* = NULL);
SharedCacheEntry* FindItem(const char* fileType,
const char* appSignature = 0) const;
@@ -301,10 +300,10 @@ class NodeCacheEntry : public IconCacheEntry {
public:
NodeCacheEntry(bool permanent = false);
NodeCacheEntry(const node_ref*, bool permanent = false);
void Draw(BView*, BPoint, IconDrawMode mode, icon_size size,
void Draw(BView*, BPoint, IconDrawMode mode, BSize size,
bool async = false);
void Draw(BView*, BPoint, IconDrawMode, icon_size,
void Draw(BView*, BPoint, IconDrawMode, BSize,
void (*)(BView*, BPoint, BBitmap*, void*), void* = NULL);
const node_ref* Node() const;
@@ -337,10 +336,10 @@ public:
NodeIconCache();
virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode,
icon_size, bool async = false);
BSize, bool async = false);
virtual void Draw(IconCacheEntry*, BView*, BPoint, IconDrawMode,
icon_size, void (*)(BView*, BPoint, BBitmap*, void*), void* = 0);
BSize, void (*)(BView*, BPoint, BBitmap*, void*), void* = 0);
NodeCacheEntry* FindItem(const node_ref*) const;
NodeCacheEntry* AddItem(const node_ref*, bool permanent = false);
@@ -368,12 +367,12 @@ public:
IconCache();
void Draw(Model*, BView*, BPoint where, IconDrawMode mode,
icon_size size, bool async = false);
BSize size, bool async = false);
// draw an icon for a model, load the icon from the appropriate
// location if not cached already
void SyncDraw(Model*, BView*, BPoint, IconDrawMode,
icon_size, void (*)(BView*, BPoint, BBitmap*, void*),
BSize, void (*)(BView*, BPoint, BBitmap*, void*),
void* passThruState = 0);
// draw an icon for a model, load the icon from the appropriate
// location if not cached already; only works for sync draws,
@@ -382,9 +381,9 @@ public:
// preload calls used to ensure successive cache hit for the respective
// icon, used for common tracker types, etc; Not calling these should only
// cause a slowdown
void Preload(Model*, IconDrawMode mode, icon_size size,
void Preload(Model*, IconDrawMode mode, BSize size,
bool permanent = false);
status_t Preload(const char* mimeType, IconDrawMode mode, icon_size size);
status_t Preload(const char* mimeType, IconDrawMode mode, BSize size);
void Deleting(const Model*);
// hook to manage unloading icons for nodes that are going away
@@ -406,70 +405,72 @@ public:
// called when metamime database changed to figure out which models
// to redraw
bool IconHitTest(BPoint, const Model*, IconDrawMode, icon_size);
bool IconHitTest(BPoint, const Model*, IconDrawMode, BSize);
// utility calls for building specialized icons
BBitmap* MakeSelectedIcon(const BBitmap* normal, icon_size,
BBitmap* MakeSelectedIcon(const BBitmap* normal, BSize,
LazyBitmapAllocator*);
static bool NeedsDeletionNotification(IconSource);
static IconCache* sIconCache;
static BSize sMiniIconSize;
private:
// shared calls
IconCacheEntry* Preload(AutoLock<SimpleIconCache>* nodeCache,
AutoLock<SimpleIconCache>* sharedCache,
AutoLock<SimpleIconCache>** resultingLockedCache,
Model*, IconDrawMode mode, icon_size size, bool permanent);
Model*, IconDrawMode mode, BSize size, bool permanent);
// preload uses lazy locking, returning the cache we decided
// to use to get the icon
// <resultingLockedCache> may be null if we don't care
// shared mime-based icon retrieval calls
IconCacheEntry* GetIconForPreferredApp(const char* mimeTypeSignature,
const char* preferredApp, IconDrawMode mode, icon_size size,
const char* preferredApp, IconDrawMode mode, BSize size,
LazyBitmapAllocator*, IconCacheEntry*);
IconCacheEntry* GetIconFromFileTypes(ModelNodeLazyOpener*,
IconSource &source, IconDrawMode mode, icon_size size,
IconSource &source, IconDrawMode mode, BSize size,
LazyBitmapAllocator*, IconCacheEntry*);
IconCacheEntry* GetIconFromMetaMime(const char* fileType,
IconDrawMode mode, icon_size size, LazyBitmapAllocator*,
IconDrawMode mode, BSize size, LazyBitmapAllocator*,
IconCacheEntry*);
IconCacheEntry* GetVolumeIcon(AutoLock<SimpleIconCache>* nodeCache,
AutoLock<SimpleIconCache>* sharedCache,
AutoLock<SimpleIconCache>** resultingLockedCache,
Model*, IconSource&, IconDrawMode mode,
icon_size size, LazyBitmapAllocator*);
BSize size, LazyBitmapAllocator*);
IconCacheEntry* GetRootIcon(AutoLock<SimpleIconCache>* nodeCache,
AutoLock<SimpleIconCache>* sharedCache,
AutoLock<SimpleIconCache>** resultingLockedCache,
Model*, IconSource&, IconDrawMode mode,
icon_size size, LazyBitmapAllocator*);
BSize size, LazyBitmapAllocator*);
IconCacheEntry* GetWellKnownIcon(AutoLock<SimpleIconCache> *nodeCache,
AutoLock<SimpleIconCache>* sharedCache,
AutoLock<SimpleIconCache>** resultingLockedCache,
Model*, IconSource&, IconDrawMode mode,
icon_size size, LazyBitmapAllocator*);
BSize size, LazyBitmapAllocator*);
IconCacheEntry* GetNodeIcon(ModelNodeLazyOpener *,
AutoLock<SimpleIconCache>* nodeCache,
AutoLock<SimpleIconCache>** resultingLockedCache,
Model*, IconSource&, IconDrawMode mode,
icon_size size, LazyBitmapAllocator*, IconCacheEntry*,
BSize size, LazyBitmapAllocator*, IconCacheEntry*,
bool permanent);
IconCacheEntry* GetGenericIcon(AutoLock<SimpleIconCache>* sharedCache,
AutoLock<SimpleIconCache>** resultingLockedCache,
Model*, IconSource&, IconDrawMode mode,
icon_size size, LazyBitmapAllocator*, IconCacheEntry*);
BSize size, LazyBitmapAllocator*, IconCacheEntry*);
IconCacheEntry* GetFallbackIcon(
AutoLock<SimpleIconCache>* sharedCacheLocker,
AutoLock<SimpleIconCache>** resultingOpenCache,
Model* model, IconDrawMode mode, icon_size size,
Model* model, IconDrawMode mode, BSize size,
LazyBitmapAllocator* lazyBitmap, IconCacheEntry* entry);
BBitmap* MakeTransformedIcon(const BBitmap*, icon_size,
BBitmap* MakeTransformedIcon(const BBitmap*, BSize,
int32 colorTransformTable [], LazyBitmapAllocator*);
private:
NodeIconCache fNodeCache;
SharedIconCache fSharedCache;
@@ -487,7 +488,7 @@ class LazyBitmapAllocator {
// Utility class used when we aren't sure that we will keep a bitmap,
// need a bitmap or be able to construct it properly
public:
LazyBitmapAllocator(icon_size size,
LazyBitmapAllocator(BSize size,
color_space colorSpace = kDefaultIconDepth,
bool preallocate = false);
~LazyBitmapAllocator();
@@ -497,7 +498,7 @@ public:
private:
BBitmap* fBitmap;
icon_size fSize;
BSize fSize;
color_space fColorSpace;
};
+2 -2
View File
@@ -165,12 +165,12 @@ ModelMenuItem::DrawIcon()
// draw small icon, synchronously
if (IsEnabled()) {
IconCache::sIconCache->Draw(fModel.ResolveIfLink(), Menu(), where,
kNormalIcon, (icon_size)ListIconSize());
kNormalIcon, BSize(ListIconSize() - 1, ListIconSize() - 1));
} else {
// dimmed, for now use a special blitter; icon cache should
// know how to blit one eventually
IconCache::sIconCache->SyncDraw(fModel.ResolveIfLink(), Menu(), where,
kNormalIcon, (icon_size)ListIconSize(), DimmedIconBlitter);
kNormalIcon, BSize(ListIconSize() - 1, ListIconSize() - 1), DimmedIconBlitter);
}
Menu()->PopState();
+4 -6
View File
@@ -38,6 +38,7 @@ All rights reserved.
#include "MountMenu.h"
#include <Catalog.h>
#include <ControlLook.h>
#include <Debug.h>
#include <Locale.h>
#include <MenuItem.h>
@@ -119,16 +120,13 @@ AddMenuItemVisitor::Visit(BPartition* partition, int32 level)
unit = 'M';
}
char* buffer = name.LockBuffer(256);
snprintf(buffer, 256, "(%.1f %cB %s)",
name.SetToFormat("(%.1f %cB %s)",
1.0 * partition->Size() / divisor, unit, type);
name.UnlockBuffer();
}
}
// get icon
BBitmap* icon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1),
BBitmap* icon = new BBitmap(BRect(BPoint(0, 0), be_control_look->ComposeIconSize(B_MINI_ICON)),
B_RGBA32);
if (partition->GetIcon(icon, B_MINI_ICON) != B_OK) {
delete icon;
@@ -206,7 +204,7 @@ MountMenu::AddDynamicItem(add_state)
continue;
}
// Use the shared icon instead of the device icon
if (get_device_icon(info.device_name, icon->Bits(), B_MINI_ICON)
if (get_device_icon(info.device_name, icon, B_MINI_ICON)
!= B_OK) {
GetTrackerResources()->GetIconResource(R_ShareIcon,
B_MINI_ICON, icon);
+2 -2
View File
@@ -191,8 +191,8 @@ NodePreloader::PreloadOne(const char* dirPath)
if (model->InitCheck() == B_OK && model->IconFrom() == kUnknownSource) {
TTracker::WatchNode(model->NodeRef(),
B_WATCH_STAT | B_WATCH_ATTR, this);
IconCache::sIconCache->Preload(model, kNormalIcon, B_MINI_ICON,
true);
IconCache::sIconCache->Preload(model, kNormalIcon,
IconCache::sMiniIconSize, true);
fModelList.AddItem(model);
model->CloseNode();
} else
+9 -18
View File
@@ -741,7 +741,7 @@ BPose::MoveTo(BPoint point, BPoseView* poseView, bool invalidate)
float scale = 1.0;
if (poseView->ViewMode() == kIconMode) {
scale = poseView->IconSize() / 32.0;
scale = (float)poseView->IconSizeInt() / 32.0;
}
fLocation.x = point.x / scale;
fLocation.y = point.y / scale;
@@ -799,17 +799,8 @@ BPose::WidgetFor(BColumn* column, BPoseView* poseView,
}
// the following method is deprecated
bool
BPose::TestLargeIconPixel(BPoint point) const
{
return IconCache::sIconCache->IconHitTest(point, ResolvedModel(),
kNormalIcon, B_LARGE_ICON);
}
void
BPose::DrawIcon(BPoint where, BView* view, icon_size which, bool direct,
BPose::DrawIcon(BPoint where, BView* view, BSize size, bool direct,
bool drawUnselected)
{
if (fClipboardMode == kMoveSelectionTo) {
@@ -821,22 +812,22 @@ BPose::DrawIcon(BPoint where, BView* view, icon_size which, bool direct,
view->SetDrawingMode(B_OP_OVER);
IconCache::sIconCache->Draw(ResolvedModel(), view, where,
fIsSelected && !drawUnselected ? kSelectedIcon : kNormalIcon, which,
fIsSelected && !drawUnselected ? kSelectedIcon : kNormalIcon, size,
true);
if (fPercent != -1)
DrawBar(where, view, which);
DrawBar(where, view, size);
}
void
BPose::DrawBar(BPoint where, BView* view, icon_size which)
BPose::DrawBar(BPoint where, BView* view, BSize iconSize)
{
view->PushState();
int32 size = which - 1;
int32 size = iconSize.IntegerWidth();
int32 yOffset;
int32 barWidth = (int32)(7.0f / 32.0f * (float)which);
int32 barWidth = (int32)(7.0f / 32.0f * (float)(size + 1));
if (barWidth < 4) {
barWidth = 4;
yOffset = 0;
@@ -899,7 +890,7 @@ BPose::Location(const BPoseView* poseView) const
{
float scale = 1.0;
if (poseView->ViewMode() == kIconMode)
scale = poseView->IconSize() / 32.0;
scale = (float)poseView->IconSizeInt() / 32.0;
return BPoint(fLocation.x * scale, fLocation.y * scale);
}
@@ -910,7 +901,7 @@ BPose::SetLocation(BPoint point, const BPoseView* poseView)
{
float scale = 1.0;
if (poseView->ViewMode() == kIconMode)
scale = poseView->IconSize() / 32.0;
scale = (float)poseView->IconSizeInt() / 32.0;
fLocation = BPoint(floorf(point.x / scale), floorf(point.y / scale));
if (isinff(fLocation.x) || isinff(fLocation.y))
+3 -3
View File
@@ -75,9 +75,9 @@ public:
// special purpose draw call for deselecting over a textured
// background
void DrawBar(BPoint where, BView* view, icon_size which);
void DrawBar(BPoint where, BView* view, BSize iconSize);
void DrawIcon(BPoint where, BView* view, icon_size which, bool direct,
void DrawIcon(BPoint where, BView* view, BSize size, bool direct,
bool drawUnselected = false);
void DrawToggleSwitch(BRect, BPoseView*);
void MouseUp(BPoint poseLoc, BPoseView*, BPoint where, int32 index);
@@ -136,7 +136,7 @@ private:
static bool _PeriodicUpdateCallback(BPose* pose, void* cookie);
void EditPreviousNextWidgetCommon(BPoseView* poseView, bool next);
void CreateWidgets(BPoseView*);
bool TestLargeIconPixel(BPoint) const;
BRect _IconRect(const BPoseView* poseView,
BPoint location) const;
+3 -5
View File
@@ -1019,17 +1019,15 @@ BPoseView::SetIconPoseHeight()
break;
case kMiniIconMode:
fViewState->SetIconSize(B_MINI_ICON);
fViewState->SetIconSize(IconCache::sMiniIconSize.IntegerWidth() + 1);
fIconPoseHeight = std::max((float)IconSizeInt(), sFontHeight + 1);
break;
case kListMode:
default:
{
fViewState->SetIconSize(ListIconSize());
fIconPoseHeight = fListElemHeight;
break;
}
}
}
@@ -1039,8 +1037,8 @@ BPoseView::GetLayoutInfo(uint32 mode, BPoint* grid, BPoint* offset) const
{
switch (mode) {
case kMiniIconMode:
grid->Set(96, 20);
offset->Set(10, 5);
grid->Set(IconSizeInt() * 6, ceilf(IconSizeInt() * 1.25f));
offset->Set(ceilf(IconSizeInt() * 0.6f), ceilf(IconSizeInt() * 0.3f));
break;
case kIconMode:
+3 -3
View File
@@ -205,7 +205,7 @@ public:
void SetIconPoseHeight();
float IconPoseHeight() const;
uint32 IconSizeInt() const;
icon_size IconSize() const;
BSize IconSize() const;
BRect Extent() const;
void GetLayoutInfo(uint32 viewMode, BPoint* grid,
@@ -889,10 +889,10 @@ BPoseView::IconSizeInt() const
}
inline icon_size
inline BSize
BPoseView::IconSize() const
{
return (icon_size)fViewState->IconSize();
return BSize(fViewState->IconSize() - 1, fViewState->IconSize() - 1);
}
+2 -4
View File
@@ -190,13 +190,11 @@ BTextWidget::CalcRectCommon(BPoint poseLoc, const BColumn* column,
// icon mode
result.left = poseLoc.x
+ roundf((view->IconSizeInt() - viewWidth) / 2);
result.bottom = poseLoc.y + view->IconPoseHeight();
} else {
// mini icon mode
result.left = poseLoc.x + B_MINI_ICON + kMiniIconSeparator;
result.bottom = poseLoc.y
+ roundf((B_MINI_ICON + view->FontHeight()) / 2);
result.left = poseLoc.x + view->IconSizeInt() + kMiniIconSeparator;
}
result.bottom = poseLoc.y + view->IconPoseHeight();
result.right = result.left + viewWidth;
}
+12 -12
View File
@@ -113,19 +113,19 @@ ScaleBitmap(BBitmap* source, BBitmap& dest, BRect bounds, color_space colorSpace
static status_t
ScaleBitmap(BBitmap* source, BBitmap& dest, icon_size size, color_space colorSpace)
ScaleBitmap(BBitmap* source, BBitmap& dest, BSize size, color_space colorSpace)
{
return ScaleBitmap(source, dest, BRect(0, 0, size - 1, size - 1), colorSpace);
return ScaleBitmap(source, dest, BRect(BPoint(0, 0), size), colorSpace);
}
class GenerateThumbnailJob : public BSupportKit::BJob {
public:
GenerateThumbnailJob(Model* model, const BFile& file,
icon_size size, color_space colorSpace)
BSize requestedSize, color_space colorSpace)
: BJob("GenerateThumbnail"),
fMimeType(model->MimeType()),
fSize(size),
fRequestedSize(requestedSize),
fColorSpace(colorSpace)
{
fFile = new(std::nothrow) BFile(file);
@@ -154,7 +154,7 @@ public:
public:
const BString fMimeType;
const node_ref fNodeRef;
const icon_size fSize;
const BSize fRequestedSize;
const color_space fColorSpace;
private:
@@ -180,7 +180,7 @@ GenerateThumbnailJob::Execute()
// now, scale and directly insert into the icon cache
BBitmap tmp(NULL, false);
ScaleBitmap(image, tmp, fSize, fColorSpace);
ScaleBitmap(image, tmp, fRequestedSize, fColorSpace);
BBitmap* cacheThumb = new BBitmap(tmp.Bounds(), 0, tmp.ColorSpace());
cacheThumb->ImportBits(&tmp);
@@ -195,7 +195,7 @@ GenerateThumbnailJob::Execute()
return B_NO_MEMORY;
}
entry->SetIcon(cacheThumb, kNormalIcon, fSize);
entry->SetIcon(cacheThumb, kNormalIcon, fRequestedSize);
cacheLocker.Unlock();
// write values to attributes
@@ -266,7 +266,7 @@ thumbnail_worker(void* castToJobQueue)
static status_t
GenerateThumbnail(Model* model, color_space colorSpace, icon_size which)
GenerateThumbnail(Model* model, color_space colorSpace, BSize size)
{
// First check we do not have a job queued already.
BAutolock jobsLock(sActiveJobsLock);
@@ -287,7 +287,7 @@ GenerateThumbnail(Model* model, color_space colorSpace, icon_size which)
return status;
GenerateThumbnailJob* job = new(std::nothrow) GenerateThumbnailJob(model,
*file, which, colorSpace);
*file, size, colorSpace);
ObjectDeleter<GenerateThumbnailJob> jobDeleter(job);
if (job == NULL)
return B_NO_MEMORY;
@@ -328,7 +328,7 @@ GenerateThumbnail(Model* model, color_space colorSpace, icon_size which)
status_t
GetThumbnailFromAttr(Model* model, BBitmap* icon, icon_size which)
GetThumbnailFromAttr(Model* model, BBitmap* icon, BSize size)
{
if (model == NULL || icon == NULL)
return B_BAD_VALUE;
@@ -362,7 +362,7 @@ GetThumbnailFromAttr(Model* model, BBitmap* icon, icon_size which)
BBitmap thumb(BTranslationUtils::GetBitmap(&webpData));
// convert thumb to icon size
if (which == B_XXL_ICON) {
if ((size.IntegerWidth() + 1) == B_XXL_ICON) {
// import icon data from attribute without resizing
result = icon->ImportBits(&thumb);
} else {
@@ -391,7 +391,7 @@ GetThumbnailFromAttr(Model* model, BBitmap* icon, icon_size which)
}
if (ShouldGenerateThumbnail(model->MimeType()))
return GenerateThumbnail(model, icon->ColorSpace(), which);
return GenerateThumbnail(model, icon->ColorSpace(), size);
return B_NOT_SUPPORTED;
}
+1 -1
View File
@@ -20,7 +20,7 @@ namespace BPrivate {
class Model;
status_t GetThumbnailFromAttr(Model* model, BBitmap* icon, icon_size which);
status_t GetThumbnailFromAttr(Model* model, BBitmap* icon, BSize size);
bool ShouldGenerateThumbnail(const char* type);
+5 -5
View File
@@ -296,7 +296,7 @@ HeaderView::Draw(BRect)
// Draw the icon, straddling the border
SetDrawingMode(B_OP_OVER);
IconCache::sIconCache->Draw(fIconModel, this, fIconRect.LeftTop(),
kNormalIcon, B_LARGE_ICON, true);
kNormalIcon, fIconRect.Size(), true);
SetDrawingMode(B_OP_COPY);
// Font information
@@ -387,7 +387,7 @@ HeaderView::MouseDown(BPoint where)
offsetPoint.x = where.x - fIconRect.left;
offsetPoint.y = where.y - fIconRect.top;
if (IconCache::sIconCache->IconHitTest(offsetPoint, fIconModel,
kNormalIcon, B_LARGE_ICON)) {
kNormalIcon, fIconRect.Size())) {
// Can't drag the trash anywhere..
fTrackingState = fModel->IsTrash()
? open_only_track : icon_track;
@@ -405,7 +405,7 @@ HeaderView::MouseDown(BPoint where)
offsetPoint.y = fClickPoint.y - fIconRect.top;
fDoubleClick
= IconCache::sIconCache->IconHitTest(offsetPoint,
fIconModel, kNormalIcon, B_LARGE_ICON);
fIconModel, kNormalIcon, fIconRect.Size());
}
}
}
@@ -430,7 +430,7 @@ HeaderView::MouseMoved(BPoint where, uint32, const BMessage* dragMessage)
SetDrawingMode(B_OP_OVER);
if (overTarget != fIsDropTarget) {
IconCache::sIconCache->Draw(fIconModel, this, fIconRect.LeftTop(),
overTarget ? kSelectedIcon : kNormalIcon, B_LARGE_ICON, true);
overTarget ? kSelectedIcon : kNormalIcon, fIconRect.Size(), true);
fIsDropTarget = overTarget;
}
}
@@ -473,7 +473,7 @@ HeaderView::MouseMoved(BPoint where, uint32, const BMessage* dragMessage)
// Draw the icon
float hIconOffset = (rect.Width() - fIconRect.Width()) / 2;
IconCache::sIconCache->Draw(fIconModel, view,
BPoint(hIconOffset, 0), kNormalIcon, B_LARGE_ICON, true);
BPoint(hIconOffset, 0), kNormalIcon, fIconRect.Size(), true);
// See if we need to truncate the string
BString nameString(fModel->Name());