use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.
the class ScrollableSingleRowLayout method scroll.
@Override
public void scroll(int units) {
myScrollOffset += units;
if (myLastSingRowLayout == null)
return;
int offset = -myScrollOffset;
for (TabInfo info : myLastSingRowLayout.myVisibleInfos) {
final int length = getRequiredLength(info);
if (info == myTabs.getSelectedInfo()) {
int maxLength = myLastSingRowLayout.toFitLength - getStrategy().getMoreRectAxisSize();
if (offset < 0 && length < maxLength) {
myScrollOffset += offset;
} else if (offset + length > maxLength) {
myScrollOffset += offset + length - maxLength;
}
break;
}
offset += length;
}
clampScrollOffsetToBounds(myLastSingRowLayout);
}
use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.
the class ScrollableSingleRowLayout method doScrollSelectionInView.
private void doScrollSelectionInView(SingleRowPassInfo passInfo) {
int offset = -myScrollOffset;
for (TabInfo info : passInfo.myVisibleInfos) {
final int length = getRequiredLength(info);
if (info == myTabs.getSelectedInfo()) {
if (offset < 0) {
scroll(offset);
} else {
final int maxLength = passInfo.toFitLength - getStrategy().getMoreRectAxisSize();
if (offset + length > maxLength) {
scroll(offset + length - maxLength);
}
}
break;
}
offset += length;
}
}
use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.
the class ScrollableSingleRowLayout method findLastVisibleLabel.
@Nullable
@Override
protected TabLabel findLastVisibleLabel(SingleRowPassInfo data) {
int i = data.toLayout.size() - 1;
while (i > 0) {
final TabInfo info = data.toLayout.get(i);
final TabLabel label = myTabs.myInfo2Label.get(info);
if (!label.getBounds().isEmpty()) {
return label;
}
i--;
}
return null;
}
use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.
the class SingleRowLayout method layoutSingleRow.
public LayoutPassInfo layoutSingleRow(List<TabInfo> visibleInfos) {
SingleRowPassInfo data = new SingleRowPassInfo(this, visibleInfos);
final boolean layoutLabels = checkLayoutLabels(data);
if (!layoutLabels) {
data = myLastSingRowLayout;
}
final TabInfo selected = myTabs.getSelectedInfo();
prepareLayoutPassInfo(data, selected);
myTabs.resetLayout(layoutLabels || myTabs.isHideTabs());
if (layoutLabels && !myTabs.isHideTabs()) {
data.position = getStrategy().getStartPosition(data) - getScrollOffset();
recomputeToLayout(data);
layoutLabelsAndGhosts(data);
layoutMoreButton(data);
}
if (selected != null) {
data.comp = new WeakReference<>(selected.getComponent());
getStrategy().layoutComp(data);
}
updateMoreIconVisibility(data);
data.tabRectangle = new Rectangle();
if (data.toLayout.size() > 0) {
final TabLabel firstLabel = myTabs.myInfo2Label.get(data.toLayout.get(0));
final TabLabel lastLabel = findLastVisibleLabel(data);
if (firstLabel != null && lastLabel != null) {
data.tabRectangle.x = firstLabel.getBounds().x;
data.tabRectangle.y = firstLabel.getBounds().y;
data.tabRectangle.width = (int) lastLabel.getBounds().getMaxX() - data.tabRectangle.x;
data.tabRectangle.height = (int) lastLabel.getBounds().getMaxY() - data.tabRectangle.y;
}
}
myLastSingRowLayout = data;
return data;
}
use of com.intellij.ui.tabs.TabInfo in project intellij-community by JetBrains.
the class SingleRowLayout method layoutLabelsAndGhosts.
protected void layoutLabelsAndGhosts(final SingleRowPassInfo data) {
if (data.firstGhostVisible || myTabs.isGhostsAlwaysVisible()) {
data.firstGhost = getStrategy().getLayoutRect(data, data.position, myTabs.getGhostTabLength());
myTabs.layout(myLeftGhost, data.firstGhost);
data.position += getStrategy().getLengthIncrement(data.firstGhost.getSize()) + myTabs.getInterTabSpaceLength();
}
int deltaToFit = 0;
if (data.firstGhostVisible || data.lastGhostVisible) {
if (data.requiredLength < data.toFitLength && getStrategy().canBeStretched()) {
deltaToFit = (int) Math.floor((data.toFitLength - data.requiredLength) / (double) data.toLayout.size());
}
}
int totalLength = 0;
int positionStart = data.position;
boolean layoutStopped = false;
for (TabInfo eachInfo : data.toLayout) {
final TabLabel label = myTabs.myInfo2Label.get(eachInfo);
if (layoutStopped) {
label.setActionPanelVisible(false);
final Rectangle rec = getStrategy().getLayoutRect(data, 0, 0);
myTabs.layout(label, rec);
continue;
}
label.setActionPanelVisible(true);
final Dimension eachSize = label.getPreferredSize();
boolean isLast = data.toLayout.indexOf(eachInfo) == data.toLayout.size() - 1;
int length;
if (!isLast || deltaToFit == 0) {
length = getStrategy().getLengthIncrement(eachSize) + deltaToFit;
} else {
length = data.toFitLength - totalLength;
}
boolean continueLayout = applyTabLayout(data, label, length, deltaToFit);
data.position = getStrategy().getMaxPosition(label.getBounds());
data.position += myTabs.getInterTabSpaceLength();
totalLength = getStrategy().getMaxPosition(label.getBounds()) - positionStart + myTabs.getInterTabSpaceLength();
if (!continueLayout) {
layoutStopped = true;
}
}
for (TabInfo eachInfo : data.toDrop) {
JBTabsImpl.resetLayout(myTabs.myInfo2Label.get(eachInfo));
}
if (data.lastGhostVisible || myTabs.isGhostsAlwaysVisible()) {
data.lastGhost = getStrategy().getLayoutRect(data, data.position, myTabs.getGhostTabLength());
myTabs.layout(myRightGhost, data.lastGhost);
}
}
Aggregations