_DistributeTabSize cleanup
* use ceilf() over ceil() and floorf() over floor() * rename prevTab to previousTab * check that tab pointer is valid in each loop * use tabCount variable in each loop to check the end condition
This commit is contained in:
@@ -430,22 +430,25 @@ TabDecorator::_DistributeTabSize(float delta)
|
|||||||
secMaxTabSize = tabWidth;
|
secMaxTabSize = tabWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
float minus = ceil(std::min(maxTabSize - secMaxTabSize, delta));
|
float minus = ceilf(std::min(maxTabSize - secMaxTabSize, delta));
|
||||||
delta -= minus;
|
delta -= minus;
|
||||||
minus /= nTabsWithMaxSize;
|
minus /= nTabsWithMaxSize;
|
||||||
|
|
||||||
Decorator::Tab* prevTab = NULL;
|
Decorator::Tab* previousTab = NULL;
|
||||||
for (int32 i = 0; i < fTabList.CountItems(); i++) {
|
for (int32 i = 0; i < tabCount; i++) {
|
||||||
Decorator::Tab* tab = fTabList.ItemAt(i);
|
Decorator::Tab* tab = fTabList.ItemAt(i);
|
||||||
|
if (tab == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (int_equal(maxTabSize, tab->tabRect.Width()))
|
if (int_equal(maxTabSize, tab->tabRect.Width()))
|
||||||
tab->tabRect.right -= minus;
|
tab->tabRect.right -= minus;
|
||||||
|
|
||||||
if (prevTab) {
|
if (previousTab != NULL) {
|
||||||
tab->tabRect.OffsetBy(prevTab->tabRect.right - tab->tabRect.left,
|
float offsetX = previousTab->tabRect.right - tab->tabRect.left;
|
||||||
0);
|
tab->tabRect.OffsetBy(offsetX, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
prevTab = tab;
|
previousTab = tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
@@ -454,10 +457,13 @@ TabDecorator::_DistributeTabSize(float delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// done
|
// done
|
||||||
prevTab->tabRect.right = floor(fFrame.right + fBorderWidth);
|
previousTab->tabRect.right = floorf(fFrame.right + fBorderWidth);
|
||||||
|
|
||||||
|
for (int32 i = 0; i < tabCount; i++) {
|
||||||
|
Decorator::Tab* tab = fTabList.ItemAt(i);
|
||||||
|
if (tab == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
for (int32 i = 0; i < fTabList.CountItems(); i++) {
|
|
||||||
Decorator::Tab* tab = _TabAt(i);
|
|
||||||
tab->tabOffset = uint32(tab->tabRect.left - fLeftBorder.left);
|
tab->tabOffset = uint32(tab->tabRect.left - fLeftBorder.left);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user