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) {
|
if (fDrawText) {
|
||||||
BPoint drawPoint(ContentLocation());
|
BPoint drawPoint(ContentLocation());
|
||||||
drawPoint.x += 20 + (fExtraPad ? 6 : 0);
|
drawPoint.x += ListIconSize() + (fExtraPad ? 10 : 4);
|
||||||
if (fHeightDelta > 0)
|
if (fHeightDelta > 0)
|
||||||
drawPoint.y += ceil(fHeightDelta / 2);
|
drawPoint.y += ceil(fHeightDelta / 2);
|
||||||
Menu()->MovePenTo(drawPoint);
|
Menu()->MovePenTo(drawPoint);
|
||||||
@ -164,12 +164,12 @@ ModelMenuItem::DrawIcon()
|
|||||||
// draw small icon, synchronously
|
// draw small icon, synchronously
|
||||||
if (IsEnabled()) {
|
if (IsEnabled()) {
|
||||||
IconCache::sIconCache->Draw(fModel.ResolveIfLink(), Menu(), where,
|
IconCache::sIconCache->Draw(fModel.ResolveIfLink(), Menu(), where,
|
||||||
kNormalIcon, B_MINI_ICON);
|
kNormalIcon, (icon_size)ListIconSize());
|
||||||
} else {
|
} else {
|
||||||
// dimmed, for now use a special blitter; icon cache should
|
// dimmed, for now use a special blitter; icon cache should
|
||||||
// know how to blit one eventually
|
// know how to blit one eventually
|
||||||
IconCache::sIconCache->SyncDraw(fModel.ResolveIfLink(), Menu(), where,
|
IconCache::sIconCache->SyncDraw(fModel.ResolveIfLink(), Menu(), where,
|
||||||
kNormalIcon, B_MINI_ICON, DimmedIconBlitter);
|
kNormalIcon, (icon_size)ListIconSize(), DimmedIconBlitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu()->PopState();
|
Menu()->PopState();
|
||||||
@ -180,10 +180,11 @@ void
|
|||||||
ModelMenuItem::GetContentSize(float* width, float* height)
|
ModelMenuItem::GetContentSize(float* width, float* height)
|
||||||
{
|
{
|
||||||
_inherited::GetContentSize(width, height);
|
_inherited::GetContentSize(width, height);
|
||||||
fHeightDelta = 16 - *height;
|
float iconSize = ListIconSize();
|
||||||
if (*height < 16)
|
fHeightDelta = iconSize - *height;
|
||||||
*height = 16;
|
if (*height < iconSize)
|
||||||
*width = *width + 20 + (fExtraPad ? 18 : 0);
|
*height = iconSize;
|
||||||
|
*width = *width + 4 + iconSize + (fExtraPad ? 18 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -235,7 +235,6 @@ BPoseView::BPoseView(Model* model, uint32 viewMode)
|
|||||||
fCountView(NULL),
|
fCountView(NULL),
|
||||||
fListElemHeight(0.0f),
|
fListElemHeight(0.0f),
|
||||||
fIconPoseHeight(0.0f),
|
fIconPoseHeight(0.0f),
|
||||||
fListIconSize(0.0f),
|
|
||||||
fDropTarget(NULL),
|
fDropTarget(NULL),
|
||||||
fAlreadySelectedDropTarget(NULL),
|
fAlreadySelectedDropTarget(NULL),
|
||||||
fSelectionHandler(be_app),
|
fSelectionHandler(be_app),
|
||||||
@ -278,9 +277,7 @@ BPoseView::BPoseView(Model* model, uint32 viewMode)
|
|||||||
fDeskbarFrame(0, 0, -1, -1),
|
fDeskbarFrame(0, 0, -1, -1),
|
||||||
fTextWidgetToCheck(NULL)
|
fTextWidgetToCheck(NULL)
|
||||||
{
|
{
|
||||||
fListIconSize = std::max((float)B_MINI_ICON,
|
fListElemHeight = std::fmax(ListIconSize(),
|
||||||
B_MINI_ICON * be_plain_font->Size() / 12);
|
|
||||||
fListElemHeight = std::max(fListIconSize,
|
|
||||||
ceilf(sFontHeight) < 20 ? 20 : ceilf(sFontHeight * 1.1f));
|
ceilf(sFontHeight) < 20 ? 20 : ceilf(sFontHeight * 1.1f));
|
||||||
|
|
||||||
fViewState->SetViewMode(viewMode);
|
fViewState->SetViewMode(viewMode);
|
||||||
@ -1032,7 +1029,7 @@ BPoseView::SetIconPoseHeight()
|
|||||||
case kListMode:
|
case kListMode:
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
fViewState->SetIconSize(fListIconSize);
|
fViewState->SetIconSize(ListIconSize());
|
||||||
fIconPoseHeight = fListElemHeight;
|
fIconPoseHeight = fListElemHeight;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -724,7 +724,6 @@ protected:
|
|||||||
BCountView* fCountView;
|
BCountView* fCountView;
|
||||||
float fListElemHeight;
|
float fListElemHeight;
|
||||||
float fIconPoseHeight;
|
float fIconPoseHeight;
|
||||||
float fListIconSize;
|
|
||||||
BPose* fDropTarget;
|
BPose* fDropTarget;
|
||||||
BPose* fAlreadySelectedDropTarget;
|
BPose* fAlreadySelectedDropTarget;
|
||||||
BLooper* fSelectionHandler;
|
BLooper* fSelectionHandler;
|
||||||
@ -1065,7 +1064,7 @@ BPoseView::CountColumns() const
|
|||||||
inline float
|
inline float
|
||||||
BPoseView::StartOffset() const
|
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
|
static BRect
|
||||||
LineBounds(BPoint where, float length, bool vertical)
|
LineBounds(BPoint where, float length, bool vertical)
|
||||||
{
|
{
|
||||||
|
@ -417,6 +417,8 @@ const BMenuItem* EachMenuItem(const BMenu* menu, bool recursive,
|
|||||||
int64 StringToScalar(const char* text);
|
int64 StringToScalar(const char* text);
|
||||||
// string to num, understands kB, MB, etc.
|
// string to num, understands kB, MB, etc.
|
||||||
|
|
||||||
|
int32 ListIconSize();
|
||||||
|
|
||||||
// misc calls
|
// misc calls
|
||||||
void EmbedUniqueVolumeInfo(BMessage* message, const BVolume* volume);
|
void EmbedUniqueVolumeInfo(BMessage* message, const BVolume* volume);
|
||||||
status_t MatchArchivedVolume(BVolume* volume, const BMessage* message,
|
status_t MatchArchivedVolume(BVolume* volume, const BMessage* message,
|
||||||
|
Loading…
Reference in New Issue
Block a user