Tracker: NavMenu icons scale with font size
* Moved icon size computation into separate utility function.
This commit is contained in:
parent
fa584266d5
commit
a55e9f5235
@ -126,7 +126,7 @@ ModelMenuItem::DrawContent()
|
||||
{
|
||||
if (fDrawText) {
|
||||
BPoint drawPoint(ContentLocation());
|
||||
drawPoint.x += 20 + (fExtraPad ? 6 : 0);
|
||||
drawPoint.x += ListIconSize() + (fExtraPad ? 10 : 4);
|
||||
if (fHeightDelta > 0)
|
||||
drawPoint.y += ceil(fHeightDelta / 2);
|
||||
Menu()->MovePenTo(drawPoint);
|
||||
@ -164,12 +164,12 @@ ModelMenuItem::DrawIcon()
|
||||
// draw small icon, synchronously
|
||||
if (IsEnabled()) {
|
||||
IconCache::sIconCache->Draw(fModel.ResolveIfLink(), Menu(), where,
|
||||
kNormalIcon, B_MINI_ICON);
|
||||
kNormalIcon, (icon_size)ListIconSize());
|
||||
} 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, B_MINI_ICON, DimmedIconBlitter);
|
||||
kNormalIcon, (icon_size)ListIconSize(), DimmedIconBlitter);
|
||||
}
|
||||
|
||||
Menu()->PopState();
|
||||
@ -180,10 +180,11 @@ void
|
||||
ModelMenuItem::GetContentSize(float* width, float* height)
|
||||
{
|
||||
_inherited::GetContentSize(width, height);
|
||||
fHeightDelta = 16 - *height;
|
||||
if (*height < 16)
|
||||
*height = 16;
|
||||
*width = *width + 20 + (fExtraPad ? 18 : 0);
|
||||
float iconSize = ListIconSize();
|
||||
fHeightDelta = iconSize - *height;
|
||||
if (*height < iconSize)
|
||||
*height = iconSize;
|
||||
*width = *width + 4 + iconSize + (fExtraPad ? 18 : 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -235,7 +235,6 @@ BPoseView::BPoseView(Model* model, uint32 viewMode)
|
||||
fCountView(NULL),
|
||||
fListElemHeight(0.0f),
|
||||
fIconPoseHeight(0.0f),
|
||||
fListIconSize(0.0f),
|
||||
fDropTarget(NULL),
|
||||
fAlreadySelectedDropTarget(NULL),
|
||||
fSelectionHandler(be_app),
|
||||
@ -278,9 +277,7 @@ BPoseView::BPoseView(Model* model, uint32 viewMode)
|
||||
fDeskbarFrame(0, 0, -1, -1),
|
||||
fTextWidgetToCheck(NULL)
|
||||
{
|
||||
fListIconSize = std::max((float)B_MINI_ICON,
|
||||
B_MINI_ICON * be_plain_font->Size() / 12);
|
||||
fListElemHeight = std::max(fListIconSize,
|
||||
fListElemHeight = std::fmax(ListIconSize(),
|
||||
ceilf(sFontHeight) < 20 ? 20 : ceilf(sFontHeight * 1.1f));
|
||||
|
||||
fViewState->SetViewMode(viewMode);
|
||||
@ -1032,7 +1029,7 @@ BPoseView::SetIconPoseHeight()
|
||||
case kListMode:
|
||||
default:
|
||||
{
|
||||
fViewState->SetIconSize(fListIconSize);
|
||||
fViewState->SetIconSize(ListIconSize());
|
||||
fIconPoseHeight = fListElemHeight;
|
||||
break;
|
||||
}
|
||||
|
@ -724,7 +724,6 @@ protected:
|
||||
BCountView* fCountView;
|
||||
float fListElemHeight;
|
||||
float fIconPoseHeight;
|
||||
float fListIconSize;
|
||||
BPose* fDropTarget;
|
||||
BPose* fAlreadySelectedDropTarget;
|
||||
BLooper* fSelectionHandler;
|
||||
@ -1065,7 +1064,7 @@ BPoseView::CountColumns() const
|
||||
inline float
|
||||
BPoseView::StartOffset() const
|
||||
{
|
||||
return kListOffset + fListIconSize + kMiniIconSeparator + 1;
|
||||
return kListOffset + ListIconSize() + kMiniIconSeparator + 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1257,6 +1257,15 @@ StringToScalar(const char* text)
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
ListIconSize()
|
||||
{
|
||||
static int32 sIconSize = std::max((int32)B_MINI_ICON,
|
||||
(int32)ceilf(B_MINI_ICON * be_plain_font->Size() / 12));
|
||||
return sIconSize;
|
||||
}
|
||||
|
||||
|
||||
static BRect
|
||||
LineBounds(BPoint where, float length, bool vertical)
|
||||
{
|
||||
|
@ -417,6 +417,8 @@ const BMenuItem* EachMenuItem(const BMenu* menu, bool recursive,
|
||||
int64 StringToScalar(const char* text);
|
||||
// string to num, understands kB, MB, etc.
|
||||
|
||||
int32 ListIconSize();
|
||||
|
||||
// misc calls
|
||||
void EmbedUniqueVolumeInfo(BMessage* message, const BVolume* volume);
|
||||
status_t MatchArchivedVolume(BVolume* volume, const BMessage* message,
|
||||
|
Loading…
Reference in New Issue
Block a user