Use 18x18 as standard icon size, as it seems more common. Position the icon

slightly more pleasing.

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@261 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi
2012-07-03 15:30:48 +02:00
committed by Alexandre Deckner
parent 6063974734
commit 85fc02b33d
+10 -6
View File
@@ -795,14 +795,18 @@ WebTabView::~WebTabView()
} }
static const int kIconSize = 18;
static const int kIconInset = 3;
BSize BSize
WebTabView::MaxSize() WebTabView::MaxSize()
{ {
// Account for icon. // Account for icon.
BSize size(TabView::MaxSize()); BSize size(TabView::MaxSize());
size.height = max_c(size.height, 16 + 8); size.height = max_c(size.height, kIconSize + kIconInset * 2);
if (fIcon) if (fIcon)
size.width += 16 + 8; size.width += kIconSize + kIconInset * 2;
// Account for close button. // Account for close button.
size.width += size.height; size.width += size.height;
return size; return size;
@@ -817,16 +821,16 @@ WebTabView::DrawContents(BView* owner, BRect frame, const BRect& updateRect,
_DrawCloseButton(owner, frame, updateRect, isFirst, isLast, isFront); _DrawCloseButton(owner, frame, updateRect, isFirst, isLast, isFront);
if (fIcon) { if (fIcon) {
BRect iconBounds(0, 0, 15, 15); BRect iconBounds(0, 0, kIconSize - 1, kIconSize - 1);
// clip to icon bounds, if they are smaller // clip to icon bounds, if they are smaller
if (iconBounds.Contains(fIcon->Bounds())) if (iconBounds.Contains(fIcon->Bounds()))
iconBounds = fIcon->Bounds(); iconBounds = fIcon->Bounds();
BPoint iconPos(frame.left + 4, BPoint iconPos(frame.left + kIconInset - 1,
frame.top + (frame.Height() - iconBounds.Height()) / 2); frame.top + floorf((frame.Height() - iconBounds.Height()) / 2));
iconBounds.OffsetTo(iconPos); iconBounds.OffsetTo(iconPos);
owner->SetDrawingMode(B_OP_OVER); owner->SetDrawingMode(B_OP_OVER);
owner->DrawBitmap(fIcon, fIcon->Bounds(), iconBounds); owner->DrawBitmap(fIcon, fIcon->Bounds(), iconBounds);
frame.left = frame.left + 16 + 8; frame.left = frame.left + kIconSize + kIconInset * 2;
} }
TabView::DrawContents(owner, frame, updateRect, isFirst, isLast, isFront); TabView::DrawContents(owner, frame, updateRect, isFirst, isLast, isFront);