Fix the check for the max tab offset when there is only one tab.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42528 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -452,9 +452,12 @@ DefaultDecorator::_DoLayout()
|
|||||||
void
|
void
|
||||||
DefaultDecorator::_DoTabLayout()
|
DefaultDecorator::_DoTabLayout()
|
||||||
{
|
{
|
||||||
float tabPosition = 0;
|
float tabOffset = 0;
|
||||||
if (fTabList.CountItems() == 1)
|
if (fTabList.CountItems() == 1) {
|
||||||
tabPosition = _TabAt(0)->tabOffset;
|
float tabSize;
|
||||||
|
tabOffset = _SingleTabOffsetAndSize(tabSize);
|
||||||
|
}
|
||||||
|
|
||||||
float sumTabWidth = 0;
|
float sumTabWidth = 0;
|
||||||
// calculate our tab rect
|
// calculate our tab rect
|
||||||
for (int32 i = 0; i < fTabList.CountItems(); i++) {
|
for (int32 i = 0; i < fTabList.CountItems(); i++) {
|
||||||
@@ -524,15 +527,15 @@ DefaultDecorator::_DoTabLayout()
|
|||||||
|
|
||||||
// make sure fTabOffset is within limits and apply it to
|
// make sure fTabOffset is within limits and apply it to
|
||||||
// the tabRect
|
// the tabRect
|
||||||
if (tab->tabLocation != 0.0
|
tab->tabOffset = (uint32)tabOffset;
|
||||||
|
if (tab->tabLocation != 0.0 && fTabList.CountItems() == 1
|
||||||
&& tab->tabOffset > (fRightBorder.right - fLeftBorder.left
|
&& tab->tabOffset > (fRightBorder.right - fLeftBorder.left
|
||||||
- tabRect.Width())) {
|
- tabRect.Width())) {
|
||||||
tab->tabOffset = uint32(fRightBorder.right - fLeftBorder.left
|
tab->tabOffset = uint32(fRightBorder.right - fLeftBorder.left
|
||||||
- tabRect.Width());
|
- tabRect.Width());
|
||||||
}
|
}
|
||||||
tab->tabOffset = (uint32)tabPosition;
|
|
||||||
tabRect.OffsetBy(tab->tabOffset, 0);
|
tabRect.OffsetBy(tab->tabOffset, 0);
|
||||||
tabPosition += tabRect.Width();
|
tabOffset += tabRect.Width();
|
||||||
|
|
||||||
sumTabWidth += tabRect.Width();
|
sumTabWidth += tabRect.Width();
|
||||||
}
|
}
|
||||||
@@ -1253,17 +1256,8 @@ DefaultDecorator::_ResizeBy(BPoint offset, BRegion* dirty)
|
|||||||
BRect oldTabRect(tabRect);
|
BRect oldTabRect(tabRect);
|
||||||
|
|
||||||
float tabSize;
|
float tabSize;
|
||||||
float maxLocation;
|
float tabOffset = _SingleTabOffsetAndSize(tabSize);
|
||||||
if (fLook != kLeftTitledWindowLook) {
|
|
||||||
tabSize = fRightBorder.right - fLeftBorder.left;
|
|
||||||
} else {
|
|
||||||
tabSize = fBottomBorder.bottom - fTopBorder.top;
|
|
||||||
}
|
|
||||||
maxLocation = tabSize - tab->maxTabSize;
|
|
||||||
if (maxLocation < 0)
|
|
||||||
maxLocation = 0;
|
|
||||||
|
|
||||||
float tabOffset = floorf(tab->tabLocation * maxLocation);
|
|
||||||
float delta = tabOffset - tab->tabOffset;
|
float delta = tabOffset - tab->tabOffset;
|
||||||
tab->tabOffset = (uint32)tabOffset;
|
tab->tabOffset = (uint32)tabOffset;
|
||||||
if (fLook != kLeftTitledWindowLook)
|
if (fLook != kLeftTitledWindowLook)
|
||||||
@@ -1888,6 +1882,24 @@ DefaultDecorator::_DefaultTextOffset() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float
|
||||||
|
DefaultDecorator::_SingleTabOffsetAndSize(float& tabSize)
|
||||||
|
{
|
||||||
|
float maxLocation;
|
||||||
|
if (fLook != kLeftTitledWindowLook) {
|
||||||
|
tabSize = fRightBorder.right - fLeftBorder.left;
|
||||||
|
} else {
|
||||||
|
tabSize = fBottomBorder.bottom - fTopBorder.top;
|
||||||
|
}
|
||||||
|
DefaultDecorator::Tab* tab = _TabAt(0);
|
||||||
|
maxLocation = tabSize - tab->maxTabSize;
|
||||||
|
if (maxLocation < 0)
|
||||||
|
maxLocation = 0;
|
||||||
|
|
||||||
|
return floorf(tab->tabLocation * maxLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DefaultDecorator::_CalculateTabsRegion()
|
DefaultDecorator::_CalculateTabsRegion()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ private:
|
|||||||
Decorator::Tab* tab = NULL);
|
Decorator::Tab* tab = NULL);
|
||||||
|
|
||||||
inline float _DefaultTextOffset() const;
|
inline float _DefaultTextOffset() const;
|
||||||
|
inline float _SingleTabOffsetAndSize(float& tabSize);
|
||||||
|
|
||||||
void _CalculateTabsRegion();
|
void _CalculateTabsRegion();
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user