Tracker: made title view height depend on font size.

* It now uses a font that's 3/4 the size of the plain font; ie. there
  shouldn't be any change with the default font size.
* Also cleaned up some weird layout code on the way.
This commit is contained in:
Axel Dörfler
2015-09-09 21:05:10 +02:00
parent 46dd7d5077
commit d8b517b50f
5 changed files with 37 additions and 23 deletions
+4 -10
View File
@@ -953,18 +953,12 @@ BContainerWindow::Init(const BMessage* message)
void
BContainerWindow::InitLayout()
{
BLayoutItem* item
= fBorderedView->GroupLayout()->AddView(0, fPoseView->TitleView());
BSize minSize = item->MinSize();
BSize maxSize = item->MaxSize();
item->SetExplicitMinSize(BSize(minSize.Width(), kTitleViewHeight));
item->SetExplicitMaxSize(BSize(maxSize.Width(), kTitleViewHeight));
fBorderedView->GroupLayout()->AddView(0, fPoseView->TitleView());
item = fCountContainer->GroupLayout()->AddView(fPoseView->CountView());
minSize = item->MinSize();
maxSize = item->MaxSize();
BLayoutItem* item = fCountContainer->GroupLayout()->AddView(
fPoseView->CountView());
item->SetExplicitMinSize(BSize(kCountViewWidth, B_H_SCROLL_BAR_HEIGHT));
item->SetExplicitMaxSize(BSize(kCountViewWidth, maxSize.Height()));
item->SetExplicitMaxSize(BSize(kCountViewWidth, B_SIZE_UNSET));
// Eliminate the extra borders
fMenuContainer->GroupLayout()->SetInsets(0, 0, -1, 0);
+1 -6
View File
@@ -899,12 +899,7 @@ TFilePanel::RestoreState()
}
// Finish UI creation now that the PoseView is initialized
BLayoutItem* item
= fBorderedView->GroupLayout()->AddView(0, fPoseView->TitleView());
BSize minSize = item->MinSize();
BSize maxSize = item->MaxSize();
item->SetExplicitMinSize(BSize(minSize.Width(), kTitleViewHeight));
item->SetExplicitMaxSize(BSize(maxSize.Width(), kTitleViewHeight));
fBorderedView->GroupLayout()->AddView(0, fPoseView->TitleView());
BRect rect(fBorderedView->Frame());
rect.right = rect.left + kCountViewWidth;
+1 -1
View File
@@ -9911,7 +9911,7 @@ BPoseView::CheckAutoScroll(BPoint mouseLoc, bool shouldScroll)
border.bottom = border.top;
border.top -= kBorderHeight;
if (ViewMode() == kListMode)
border.top -= kTitleViewHeight;
border.top -= TitleView()->Bounds().Height();
bool selectionScrolling = fSelectionRectInfo.isDragging;
+26 -5
View File
@@ -124,9 +124,13 @@ BTitleView::BTitleView(BPoseView* view)
#endif
BFont font(be_plain_font);
font.SetSize(9);
font.SetSize(floorf(be_plain_font->Size() * 0.75f));
SetFont(&font);
font_height height;
GetFontHeight(&height);
fPreferredHeight = ceilf(height.ascent + height.descent) + 2;
Reset();
}
@@ -190,6 +194,20 @@ BTitleView::RemoveTitle(BColumn* column)
}
BSize
BTitleView::MinSize()
{
return BSize(16, fPreferredHeight);
}
BSize
BTitleView::MaxSize()
{
return BSize(B_SIZE_UNLIMITED, fPreferredHeight);
}
void
BTitleView::Draw(BRect rect)
{
@@ -215,8 +233,8 @@ BTitleView::Draw(BRect /*updateRect*/, bool useOffscreen, bool updateOnly,
view->SetOrigin(-bounds.left, 0);
view->SetLowColor(LowColor());
view->SetHighColor(HighColor());
BFont font(be_plain_font);
font.SetSize(9);
BFont font;
GetFont(&font);
view->SetFont(&font);
} else
view = this;
@@ -452,7 +470,7 @@ BRect
BColumnTitle::Bounds() const
{
BRect bounds(fColumn->Offset() - kTitleColumnLeftExtraMargin, 0, 0,
kTitleViewHeight);
fParent->Bounds().Height());
bounds.right = bounds.left + fColumn->Width() + kTitleColumnExtraMargin;
return bounds;
@@ -463,7 +481,10 @@ void
BColumnTitle::Draw(BView* view, bool pressed)
{
BRect bounds(Bounds());
BPoint loc(0, bounds.bottom - 4);
font_height height;
view->GetFontHeight(&height);
BPoint loc(0, bounds.top + ceilf(height.ascent) + 2);
if (pressed) {
bounds.bottom--;
+5 -1
View File
@@ -50,7 +50,6 @@ class BColumnTitle;
class ColumnTrackState;
class OffscreenBitmap;
const int32 kTitleViewHeight = 16;
const int32 kEdgeSize = 6;
const int32 kTitleColumnLeftExtraMargin = 11;
const int32 kTitleColumnRightExtraMargin = 5;
@@ -70,6 +69,9 @@ public:
virtual void MouseUp(BPoint where);
virtual void Draw(BRect updateRect);
virtual BSize MinSize();
virtual BSize MaxSize();
void Draw(BRect, bool useOffscreen = false,
bool updateOnly = true,
const BColumnTitle* pressedColumn = 0,
@@ -90,9 +92,11 @@ private:
BColumnTitle* InColumnResizeArea(BPoint) const;
BColumnTitle* FindColumnTitle(const BColumn*) const;
private:
BPoseView* fPoseView;
BObjectList<BColumnTitle> fTitleList;
BCursor fHorizontalResizeCursor;
float fPreferredHeight;
BColumnTitle* fPreviouslyClickedColumnTitle;
bigtime_t fPreviousLeftClickTime;