BColumnListView: BRow height is proportional to font size.
* Add a BRow default constructor that use font size to compute height. * Min height size for Title and Row are decoupled. * The font ratio for Title and Row are decoupled. * For small font use min height (set to usual 16.0). * Better baseline formula. * Fixes #11944.
This commit is contained in:
@@ -121,7 +121,8 @@ public:
|
|||||||
// a parent of a row, using the AddRow() function in BColumnListView().
|
// a parent of a row, using the AddRow() function in BColumnListView().
|
||||||
class BRow {
|
class BRow {
|
||||||
public:
|
public:
|
||||||
BRow(float height = 16.0);
|
BRow();
|
||||||
|
BRow(float height);
|
||||||
virtual ~BRow();
|
virtual ~BRow();
|
||||||
virtual bool HasLatch() const;
|
virtual bool HasLatch() const;
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ All rights reserved.
|
|||||||
|
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@@ -126,7 +127,10 @@ static const unsigned char kUpSortArrow8x8Invert[] = {
|
|||||||
|
|
||||||
static const float kTintedLineTint = 1.04;
|
static const float kTintedLineTint = 1.04;
|
||||||
|
|
||||||
static const float kTitleHeight = 16.0;
|
static const float kMinTitleHeight = 16.0;
|
||||||
|
static const float kMinRowHeight = 16.0;
|
||||||
|
static const float kTitleSpacing = 1.4;
|
||||||
|
static const float kRowSpacing = 1.4;
|
||||||
static const float kLatchWidth = 15.0;
|
static const float kLatchWidth = 15.0;
|
||||||
|
|
||||||
|
|
||||||
@@ -443,6 +447,20 @@ BColumn::MouseUp(BColumnListView* /*parent*/, BRow* /*row*/, BField* /*field*/)
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
BRow::BRow()
|
||||||
|
:
|
||||||
|
fChildList(NULL),
|
||||||
|
fIsExpanded(false),
|
||||||
|
fHeight(std::max(kMinRowHeight,
|
||||||
|
ceilf(be_plain_font->Size() * kRowSpacing))),
|
||||||
|
fNextSelected(NULL),
|
||||||
|
fPrevSelected(NULL),
|
||||||
|
fParent(NULL),
|
||||||
|
fList(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BRow::BRow(float height)
|
BRow::BRow(float height)
|
||||||
:
|
:
|
||||||
fChildList(NULL),
|
fChildList(NULL),
|
||||||
@@ -1913,7 +1931,9 @@ BColumnListView::MinSize()
|
|||||||
{
|
{
|
||||||
BSize size;
|
BSize size;
|
||||||
size.width = 100;
|
size.width = 100;
|
||||||
size.height = kTitleHeight + 4 * B_H_SCROLL_BAR_HEIGHT;
|
size.height = std::max(kMinTitleHeight,
|
||||||
|
ceilf(be_plain_font->Size() * kTitleSpacing))
|
||||||
|
+ 4 * B_H_SCROLL_BAR_HEIGHT;
|
||||||
if (!fHorizontalScrollBar->IsHidden())
|
if (!fHorizontalScrollBar->IsHidden())
|
||||||
size.height += fHorizontalScrollBar->Frame().Height() + 1;
|
size.height += fHorizontalScrollBar->Frame().Height() + 1;
|
||||||
// TODO: Take border size into account
|
// TODO: Take border size into account
|
||||||
@@ -2071,7 +2091,8 @@ BColumnListView::_GetChildViewRects(const BRect& bounds, BRect& titleRect,
|
|||||||
BRect& outlineRect, BRect& vScrollBarRect, BRect& hScrollBarRect)
|
BRect& outlineRect, BRect& vScrollBarRect, BRect& hScrollBarRect)
|
||||||
{
|
{
|
||||||
titleRect = bounds;
|
titleRect = bounds;
|
||||||
titleRect.bottom = titleRect.top + kTitleHeight;
|
titleRect.bottom = titleRect.top + std::max(kMinTitleHeight,
|
||||||
|
ceilf(be_plain_font->Size() * kTitleSpacing));
|
||||||
#if !LOWER_SCROLLBAR
|
#if !LOWER_SCROLLBAR
|
||||||
titleRect.right -= B_V_SCROLL_BAR_WIDTH;
|
titleRect.right -= B_V_SCROLL_BAR_WIDTH;
|
||||||
#endif
|
#endif
|
||||||
@@ -2084,7 +2105,8 @@ BColumnListView::_GetChildViewRects(const BRect& bounds, BRect& titleRect,
|
|||||||
|
|
||||||
vScrollBarRect = bounds;
|
vScrollBarRect = bounds;
|
||||||
#if LOWER_SCROLLBAR
|
#if LOWER_SCROLLBAR
|
||||||
vScrollBarRect.top += kTitleHeight;
|
vScrollBarRect.top += std::max(kMinTitleHeight,
|
||||||
|
ceilf(be_plain_font->Size() * kTitleSpacing));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vScrollBarRect.left = vScrollBarRect.right - B_V_SCROLL_BAR_WIDTH;
|
vScrollBarRect.left = vScrollBarRect.right - B_V_SCROLL_BAR_WIDTH;
|
||||||
|
|||||||
@@ -75,9 +75,8 @@ BTitledColumn::DrawString(const char* string, BView* parent, BRect rect)
|
|||||||
|
|
||||||
parent->GetFont(&font);
|
parent->GetFont(&font);
|
||||||
font.GetHeight(&finfo);
|
font.GetHeight(&finfo);
|
||||||
y = rect.top + ((rect.Height()
|
y = rect.top + finfo.ascent
|
||||||
- (finfo.ascent + finfo.descent + finfo.leading)) / 2)
|
+ (rect.Height() - ceilf(finfo.ascent + finfo.descent)) / 2.0f;
|
||||||
+ (finfo.ascent + finfo.descent) - 2;
|
|
||||||
|
|
||||||
switch (Alignment()) {
|
switch (Alignment()) {
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user