From 79b0392885b904378cf22846a01e62152abe2f0c Mon Sep 17 00:00:00 2001
From: Janus <janus2@ymail.com>
Date: Sat, 21 Mar 2015 19:24:05 +0000
Subject: [PATCH] Fix #11918. [Media] ListViewItem scales well with big fonts
---
src/preferences/media/MediaListItem.cpp | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/preferences/media/MediaListItem.cpp b/src/preferences/media/MediaListItem.cpp
index e642384..8681e0c 100644
a
|
b
|
struct MediaListItem::Renderer {
|
84 | 84 | onto->FillRect(frame, B_SOLID_LOW); |
85 | 85 | } |
86 | 86 | |
87 | | frame.left += 4; |
88 | | frame.top += kITEM_MARGIN; |
89 | | BRect iconFrame(MediaIcons::IconRectAt(frame.LeftTop() + BPoint(1, 0))); |
| 87 | BPoint point(frame.left + 4.0f, |
| 88 | frame.top + (frame.Height() - MediaIcons::sBounds.Height()) / 2.0f); |
| 89 | |
| 90 | BRect iconFrame(MediaIcons::IconRectAt(point + BPoint(1, 0))); |
90 | 91 | |
91 | 92 | onto->SetDrawingMode(B_OP_OVER); |
92 | 93 | if (fPrimaryIcon && !fDoubleInsets) { |
93 | 94 | onto->DrawBitmap(fPrimaryIcon, iconFrame); |
94 | | frame.left = iconFrame.right + 1; |
| 95 | point.x = iconFrame.right + 1; |
95 | 96 | } else if (fSecondaryIcon) { |
96 | 97 | onto->DrawBitmap(fSecondaryIcon, iconFrame); |
97 | 98 | } |
| 99 | |
98 | 100 | iconFrame = MediaIcons::IconRectAt(iconFrame.RightTop() + BPoint(1, 0)); |
99 | 101 | |
100 | 102 | if (fDoubleInsets && fPrimaryIcon) { |
101 | 103 | onto->DrawBitmap(fPrimaryIcon, iconFrame); |
102 | | frame.left = iconFrame.right + 1; |
| 104 | point.x = iconFrame.right + 1; |
103 | 105 | } |
104 | 106 | |
105 | 107 | onto->SetDrawingMode(B_OP_COPY); |
… |
… |
struct MediaListItem::Renderer {
|
108 | 110 | BFont font = be_plain_font; |
109 | 111 | font_height fontInfo; |
110 | 112 | font.GetHeight(&fontInfo); |
111 | | float lineHeight = fontInfo.ascent + fontInfo.descent |
112 | | + fontInfo.leading; |
| 113 | |
113 | 114 | onto->SetFont(&font); |
114 | | onto->MovePenTo(frame.left + 8, frame.top |
115 | | + ((frame.Height() - (lineHeight)) / 2) |
116 | | + (fontInfo.ascent + fontInfo.descent) - 1); |
| 115 | onto->MovePenTo(point.x + 8, frame.top |
| 116 | + fontInfo.ascent + (frame.Height() |
| 117 | - ceilf(fontInfo.ascent + fontInfo.descent)) / 2.0f); |
117 | 118 | onto->DrawString(fTitle); |
118 | 119 | |
119 | 120 | onto->SetHighColor(highColor); |