Tracker: Style fixes to IconCache and Utilities
This commit is contained in:
parent
ee196640fb
commit
ae7d51b28a
File diff suppressed because it is too large
Load Diff
@ -127,10 +127,11 @@ public:
|
||||
IconCacheEntry();
|
||||
~IconCacheEntry();
|
||||
|
||||
void SetAliasFor(const SharedIconCache*, const SharedCacheEntry*);
|
||||
static IconCacheEntry* ResolveIfAlias(const SharedIconCache*,
|
||||
IconCacheEntry*);
|
||||
IconCacheEntry* ResolveIfAlias(const SharedIconCache*);
|
||||
void SetAliasFor(const SharedIconCache* sharedCache,
|
||||
const SharedCacheEntry* entry);
|
||||
static IconCacheEntry* ResolveIfAlias(const SharedIconCache* sharedCache,
|
||||
IconCacheEntry* entry);
|
||||
IconCacheEntry* ResolveIfAlias(const SharedIconCache* sharedCache);
|
||||
|
||||
void SetIcon(BBitmap* bitmap, IconDrawMode mode, icon_size size,
|
||||
bool create = false);
|
||||
@ -159,15 +160,14 @@ 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);
|
||||
|
||||
// list of most common icons
|
||||
BBitmap* fLargeIcon;
|
||||
BBitmap* fHilightedLargeIcon;
|
||||
BBitmap* fMiniIcon;
|
||||
BBitmap* fHilitedLargeIcon;
|
||||
BBitmap* fHilitedMiniIcon;
|
||||
BBitmap* fHilightedMiniIcon;
|
||||
int32 fAliasForIndex;
|
||||
|
||||
// list of other icon kinds would be added here
|
||||
@ -254,7 +254,7 @@ public:
|
||||
// because adding to the hash table makes any pending pointer invalid
|
||||
void IconChanged(SharedCacheEntry*);
|
||||
|
||||
void SetAliasFor(IconCacheEntry* alias,
|
||||
void SetAliasFor(IconCacheEntry* entry,
|
||||
const SharedCacheEntry* original) const;
|
||||
IconCacheEntry* ResolveIfAlias(IconCacheEntry* entry) const;
|
||||
int32 EntryIndex(const SharedCacheEntry* entry) const;
|
||||
@ -333,7 +333,6 @@ public:
|
||||
void Deleting(const BView*);
|
||||
void IconChanged(const Model*);
|
||||
|
||||
|
||||
void RemoveAliasesTo(int32 index);
|
||||
|
||||
private:
|
||||
@ -455,20 +454,20 @@ private:
|
||||
NodeIconCache fNodeCache;
|
||||
SharedIconCache fSharedCache;
|
||||
|
||||
void InitHiliteTable();
|
||||
void InitHighlightTable();
|
||||
|
||||
int32 fHiliteTable[kColorTransformTableSize];
|
||||
bool fInitHiliteTable;
|
||||
// on if we still need to initialize the hilite table
|
||||
int32 fHighlightTable[kColorTransformTableSize];
|
||||
bool fInitHighlightTable;
|
||||
// whether or not we need to initialize the highlight table
|
||||
};
|
||||
|
||||
|
||||
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
|
||||
// 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,
|
||||
color_space colorSpace = kDefaultIconDepth,
|
||||
color_space colorSpace = kDefaultIconDepth,
|
||||
bool preallocate = false);
|
||||
~LazyBitmapAllocator();
|
||||
|
||||
|
@ -32,7 +32,8 @@ names are registered trademarks or trademarks of their respective holders.
|
||||
All rights reserved.
|
||||
*/
|
||||
|
||||
// menu items with small icons.
|
||||
//! Menu items with small icons.
|
||||
|
||||
|
||||
#include "IconCache.h"
|
||||
#include "IconMenuItem.h"
|
||||
@ -216,8 +217,8 @@ ModelMenuItem::Invoke(BMessage* message)
|
||||
// #pragma mark - SpecialModelMenuItem
|
||||
|
||||
|
||||
/*!
|
||||
A ModelMenuItem subclass that draws its label in italics.
|
||||
/*! A ModelMenuItem subclass that draws its label in italics.
|
||||
|
||||
It's used for example in the "Copy To" menu to indicate some special
|
||||
folders like the parent folder.
|
||||
*/
|
||||
@ -245,8 +246,8 @@ SpecialModelMenuItem::DrawContent()
|
||||
// #pragma mark - IconMenuItem
|
||||
|
||||
|
||||
/*!
|
||||
A menu item that draws an icon alongside the label.
|
||||
/*! A menu item that draws an icon alongside the label.
|
||||
|
||||
It's currently used in the mount and new file template menus.
|
||||
*/
|
||||
IconMenuItem::IconMenuItem(const char* label, BMessage* message, BBitmap* icon)
|
||||
@ -268,12 +269,9 @@ IconMenuItem::IconMenuItem(const char* label, BMessage* message,
|
||||
fDeviceIcon(NULL),
|
||||
fHeightDelta(0)
|
||||
{
|
||||
if (nodeInfo) {
|
||||
#ifdef __HAIKU__
|
||||
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_RGBA32);
|
||||
#else
|
||||
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_CMAP8);
|
||||
#endif
|
||||
if (nodeInfo != NULL) {
|
||||
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1),
|
||||
kDefaultIconDepth);
|
||||
|
||||
if (nodeInfo->GetTrackerIcon(fDeviceIcon, B_MINI_ICON)) {
|
||||
delete fDeviceIcon;
|
||||
@ -295,11 +293,8 @@ IconMenuItem::IconMenuItem(const char* label, BMessage* message,
|
||||
fHeightDelta(0)
|
||||
{
|
||||
BMimeType mime(iconType);
|
||||
#ifdef __HAIKU__
|
||||
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_RGBA32);
|
||||
#else
|
||||
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_CMAP8);
|
||||
#endif
|
||||
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1),
|
||||
kDefaultIconDepth);
|
||||
|
||||
if (mime.GetIcon(fDeviceIcon, which) != B_OK) {
|
||||
BMimeType super;
|
||||
@ -324,11 +319,8 @@ IconMenuItem::IconMenuItem(BMenu* submenu, BMessage* message,
|
||||
fHeightDelta(0)
|
||||
{
|
||||
BMimeType mime(iconType);
|
||||
#ifdef __HAIKU__
|
||||
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_RGBA32);
|
||||
#else
|
||||
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1), B_CMAP8);
|
||||
#endif
|
||||
fDeviceIcon = new BBitmap(BRect(0, 0, which - 1, which - 1),
|
||||
kDefaultIconDepth);
|
||||
|
||||
if (mime.GetIcon(fDeviceIcon, which) != B_OK) {
|
||||
BMimeType super;
|
||||
|
@ -33,21 +33,21 @@ All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
#include "Attributes.h"
|
||||
#include "MimeTypes.h"
|
||||
#include "Model.h"
|
||||
#include "PoseView.h"
|
||||
#include "Utilities.h"
|
||||
#include "ContainerWindow.h"
|
||||
|
||||
#include <IconUtils.h>
|
||||
|
||||
#include <Bitmap.h>
|
||||
#include <Catalog.h>
|
||||
#include <Debug.h>
|
||||
#include <Directory.h>
|
||||
#include <ctype.h>
|
||||
#include <fs_attr.h>
|
||||
#include <fs_info.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <BitmapStream.h>
|
||||
#include <Catalog.h>
|
||||
#include <Debug.h>
|
||||
#include <Font.h>
|
||||
#include <IconUtils.h>
|
||||
#include <MenuItem.h>
|
||||
#include <OS.h>
|
||||
#include <PopUpMenu.h>
|
||||
@ -58,11 +58,11 @@ All rights reserved.
|
||||
#include <VolumeRoster.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
#include "Attributes.h"
|
||||
#include "ContainerWindow.h"
|
||||
#include "MimeTypes.h"
|
||||
#include "Model.h"
|
||||
#include "PoseView.h"
|
||||
|
||||
|
||||
#ifndef _IMPEXP_BE
|
||||
@ -138,8 +138,9 @@ ValidateStream(BMallocIO* stream, uint32 key, int32 version)
|
||||
int32 testVersion;
|
||||
|
||||
if (stream->Read(&testKey, sizeof(uint32)) <= 0
|
||||
|| stream->Read(&testVersion, sizeof(int32)) <=0)
|
||||
|| stream->Read(&testVersion, sizeof(int32)) <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return testKey == key && testVersion == version;
|
||||
}
|
||||
@ -354,6 +355,7 @@ ExtendedPoseInfo::SetLocationForFrame(BPoint newLocation, BRect frame)
|
||||
fLocations[fNumFrames].fLocation = newLocation;
|
||||
fLocations[fNumFrames].fWorkspaces = 0xffffffff;
|
||||
fNumFrames++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -904,7 +906,7 @@ TitledSeparatorItem::Draw()
|
||||
|
||||
parent->EndLineArray();
|
||||
|
||||
font_height finfo;
|
||||
font_height finfo;
|
||||
parent->GetFontHeight(&finfo);
|
||||
|
||||
parent->SetLowColor(parent->ViewColor());
|
||||
@ -1401,12 +1403,12 @@ GetAppSignatureFromAttr(BFile* file, char* result)
|
||||
return (status_t)readResult;
|
||||
|
||||
return B_OK;
|
||||
#endif // B_APP_FILE_INFO_IS_FAST
|
||||
#endif // B_APP_FILE_INFO_IS_FAST
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GetAppIconFromAttr(BFile* file, BBitmap* result, icon_size size)
|
||||
GetAppIconFromAttr(BFile* file, BBitmap* icon, icon_size which)
|
||||
{
|
||||
// This call is a performance improvement that
|
||||
// avoids using the BAppFileInfo API when retrieving the
|
||||
@ -1415,7 +1417,7 @@ GetAppIconFromAttr(BFile* file, BBitmap* result, icon_size size)
|
||||
|
||||
//#ifdef B_APP_FILE_INFO_IS_FAST
|
||||
BAppFileInfo appFileInfo(file);
|
||||
return appFileInfo.GetIcon(result, size);
|
||||
return appFileInfo.GetIcon(icon, which);
|
||||
//#else
|
||||
//
|
||||
// const char* attrName = kAttrIcon;
|
||||
@ -1423,25 +1425,25 @@ GetAppIconFromAttr(BFile* file, BBitmap* result, icon_size size)
|
||||
//
|
||||
// // try vector icon
|
||||
// attr_info ainfo;
|
||||
// status_t ret = file->GetAttrInfo(attrName, &ainfo);
|
||||
// status_t result = file->GetAttrInfo(attrName, &ainfo);
|
||||
//
|
||||
// if (ret == B_OK) {
|
||||
// if (result == B_OK) {
|
||||
// uint8 buffer[ainfo.size];
|
||||
// ssize_t readResult = file->ReadAttr(attrName, type, 0, buffer,
|
||||
// ainfo.size);
|
||||
// ainfo.size);
|
||||
// if (readResult == ainfo.size) {
|
||||
// if (BIconUtils::GetVectorIcon(buffer, ainfo.size, result) == B_OK)
|
||||
// if (BIconUtils::GetVectorIcon(buffer, ainfo.size, icon) == B_OK)
|
||||
// return B_OK;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // try again with R5 icons
|
||||
// attrName = size == B_LARGE_ICON ? kAttrLargeIcon : kAttrMiniIcon;
|
||||
// type = size == B_LARGE_ICON ? LARGE_ICON_TYPE : MINI_ICON_TYPE;
|
||||
// attrName = which == B_LARGE_ICON ? kAttrLargeIcon : kAttrMiniIcon;
|
||||
// type = which == B_LARGE_ICON ? LARGE_ICON_TYPE : MINI_ICON_TYPE;
|
||||
//
|
||||
// ret = file->GetAttrInfo(attrName, &ainfo);
|
||||
// if (ret < B_OK)
|
||||
// return ret;
|
||||
// result = file->GetAttrInfo(attrName, &ainfo);
|
||||
// if (result < B_OK)
|
||||
// return result;
|
||||
//
|
||||
// uint8 buffer[ainfo.size];
|
||||
//
|
||||
@ -1449,22 +1451,21 @@ GetAppIconFromAttr(BFile* file, BBitmap* result, icon_size size)
|
||||
// if (readResult <= 0)
|
||||
// return (status_t)readResult;
|
||||
//
|
||||
// if (result->ColorSpace() != B_CMAP8) {
|
||||
// ret = BIconUtils::ConvertFromCMAP8(buffer, size, size, size, result);
|
||||
// } else {
|
||||
// result->SetBits(buffer, result->BitsLength(), 0, B_CMAP8);
|
||||
// }
|
||||
// if (icon->ColorSpace() != B_CMAP8)
|
||||
// result = BIconUtils::ConvertFromCMAP8(buffer, which, which, which, icon);
|
||||
// else
|
||||
// icon->SetBits(buffer, icon->BitsLength(), 0, B_CMAP8);
|
||||
//
|
||||
// return ret;
|
||||
// return result;
|
||||
//#endif // B_APP_FILE_INFO_IS_FAST
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
GetFileIconFromAttr(BNode* file, BBitmap* result, icon_size size)
|
||||
GetFileIconFromAttr(BNode* node, BBitmap* icon, icon_size size)
|
||||
{
|
||||
BNodeInfo fileInfo(file);
|
||||
return fileInfo.GetIcon(result, size);
|
||||
BNodeInfo fileInfo(node);
|
||||
return fileInfo.GetIcon(icon, size);
|
||||
}
|
||||
|
||||
|
||||
@ -1483,7 +1484,7 @@ EachMenuItem(BMenu* menu, bool recursive, BMenuItem* (*func)(BMenuItem *))
|
||||
for (int32 index = 0; index < count; index++) {
|
||||
BMenuItem* item = menu->ItemAt(index);
|
||||
BMenuItem* result = (func)(item);
|
||||
if (result)
|
||||
if (result != NULL)
|
||||
return result;
|
||||
|
||||
if (recursive) {
|
||||
@ -1540,16 +1541,16 @@ PositionPassingMenuItem::PositionPassingMenuItem(BMenu* menu, BMessage* message)
|
||||
status_t
|
||||
PositionPassingMenuItem::Invoke(BMessage* message)
|
||||
{
|
||||
if (!Menu())
|
||||
if (Menu() == NULL)
|
||||
return B_ERROR;
|
||||
|
||||
if (!IsEnabled())
|
||||
return B_ERROR;
|
||||
|
||||
if (!message)
|
||||
if (message == NULL)
|
||||
message = Message();
|
||||
|
||||
if (!message)
|
||||
if (message == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
BMessage clone(*message);
|
||||
@ -1564,6 +1565,7 @@ PositionPassingMenuItem::Invoke(BMessage* message)
|
||||
for (;;) {
|
||||
if (!menu->Supermenu())
|
||||
break;
|
||||
|
||||
menu = menu->Supermenu();
|
||||
}
|
||||
|
||||
|
@ -39,12 +39,11 @@ All rights reserved.
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <ByteOrder.h>
|
||||
#include <Bitmap.h>
|
||||
#include <ByteOrder.h>
|
||||
#include <DataIO.h>
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <Font.h>
|
||||
#include <GraphicsDefs.h>
|
||||
#include <Looper.h>
|
||||
#include <MenuItem.h>
|
||||
@ -59,10 +58,9 @@ All rights reserved.
|
||||
|
||||
|
||||
class BMessage;
|
||||
class BVolume;
|
||||
class BBitmap;
|
||||
class BTextView;
|
||||
class BView;
|
||||
class BVolume;
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
@ -490,8 +488,8 @@ void _ThrowOnError(status_t, const char* debugStr, const char*, int32);
|
||||
|
||||
// stub calls that work around BAppFile info inefficiency
|
||||
status_t GetAppSignatureFromAttr(BFile*, char*);
|
||||
status_t GetAppIconFromAttr(BFile*, BBitmap*, icon_size);
|
||||
status_t GetFileIconFromAttr(BNode*, BBitmap*, icon_size);
|
||||
status_t GetAppIconFromAttr(BFile* file, BBitmap* icon, icon_size which);
|
||||
status_t GetFileIconFromAttr(BNode* node, BBitmap* icon, icon_size which);
|
||||
|
||||
// debugging
|
||||
void HexDump(const void* buffer, int32 length);
|
||||
|
Loading…
x
Reference in New Issue
Block a user