Search in sources :

Example 16 with TabInfo

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);
}
Also used : TabInfo(com.intellij.ui.tabs.TabInfo)

Example 17 with TabInfo

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;
    }
}
Also used : TabInfo(com.intellij.ui.tabs.TabInfo)

Example 18 with TabInfo

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;
}
Also used : TabLabel(com.intellij.ui.tabs.impl.TabLabel) TabInfo(com.intellij.ui.tabs.TabInfo) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with TabInfo

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;
}
Also used : TabInfo(com.intellij.ui.tabs.TabInfo)

Example 20 with TabInfo

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);
    }
}
Also used : TabInfo(com.intellij.ui.tabs.TabInfo)

Aggregations

TabInfo (com.intellij.ui.tabs.TabInfo)41 TabLabel (com.intellij.ui.tabs.impl.TabLabel)6 RelativePoint (com.intellij.ui.awt.RelativePoint)4 JBTabsImpl (com.intellij.ui.tabs.impl.JBTabsImpl)4 Content (com.intellij.ui.content.Content)3 JBTabs (com.intellij.ui.tabs.JBTabs)3 TabsListener (com.intellij.ui.tabs.TabsListener)3 NonOpaquePanel (com.intellij.ui.components.panels.NonOpaquePanel)2 ContentManager (com.intellij.ui.content.ContentManager)2 PyDebugProcess (com.jetbrains.python.debugger.PyDebugProcess)2 ArrayList (java.util.ArrayList)2 EmptyBorder (javax.swing.border.EmptyBorder)2 Nullable (org.jetbrains.annotations.Nullable)2 BuckSettingsProvider (com.facebook.buck.intellij.ideabuck.config.BuckSettingsProvider)1 RunnerLayoutUi (com.intellij.execution.ui.RunnerLayoutUi)1 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 Editor (com.intellij.openapi.editor.Editor)1 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)1