if (width > maxWidth) { item.showing = false; } else { width += item.width; item.showing = i == 0 || width <= maxWidth; if (!simple && priority[i] == selectedIndex) width += curveWidth - 2*curveIndent; }
width += item.width; item.showing = i == 0 ? true : item.width > 0 && width <= maxWidth; if (!simple && priority[i] == selectedIndex) width += curveWidth - 2*curveIndent;
boolean setItemLocation() {	boolean changed = false;	if (items.length == 0) return false;	Point size = getSize();	int y = onBottom ? Math.max(borderBottom, size.y - borderBottom - tabHeight) : borderTop;	if (single) {		int defaultX = getDisplay().getBounds().width + 10; // off screen		for (int i = 0; i < items.length; i++) {			CTabItem item = items[i];			if (i == selectedIndex) {				firstIndex = selectedIndex;				int oldX = item.x, oldY = item.y;				item.x = borderLeft;				item.y = y;				item.showing = true;				if (showClose || item.showClose) {					item.closeRect.x = borderLeft + CTabItem.LEFT_MARGIN;					item.closeRect.y = onBottom ? size.y - borderBottom - tabHeight + (tabHeight - BUTTON_SIZE)/2: borderTop + (tabHeight - BUTTON_SIZE)/2;				}				if (item.x != oldX || item.y != oldY) changed = true;			} else {				item.x = defaultX;				item.showing = false;			}		}	} else {		int rightItemEdge = getRightItemEdge();		int maxWidth = rightItemEdge - borderLeft;		int width = 0;		for (int i = 0; i < priority.length; i++) {			CTabItem item = items[priority[i]];			if (width > maxWidth) {				item.showing = false;			} else {				width += item.width;				item.showing = i == 0 || width <= maxWidth;				if (!simple && priority[i] == selectedIndex) width += curveWidth - 2*curveIndent;			}		}		int x = 0;		int defaultX = getDisplay().getBounds().width + 10; // off screen		firstIndex = items.length - 1;		for (int i = 0; i < items.length; i++) {			CTabItem item = items[i];			if (!item.showing) {				if (item.x != defaultX) changed = true;				item.x = defaultX;			} else {				firstIndex = Math.min(firstIndex, i);				if (item.x != x || item.y != y) changed = true;				item.x = x;				item.y = y;				if (i == selectedIndex) {					int edge = Math.min(item.x + item.width, rightItemEdge);					item.closeRect.x = edge - CTabItem.RIGHT_MARGIN - BUTTON_SIZE;				} else {					item.closeRect.x = item.x + item.width - CTabItem.RIGHT_MARGIN - BUTTON_SIZE;				}				item.closeRect.y = onBottom ? size.y - borderBottom - tabHeight + (tabHeight - BUTTON_SIZE)/2: borderTop + (tabHeight - BUTTON_SIZE)/2;				x = x + item.width;				if (!simple && i == selectedIndex) x += curveWidth - 2*curveIndent;			}		}	}	return changed;}