use of com.intellij.ui.tabs.impl.TabLabel in project intellij-community by JetBrains.
the class JBRunnerTabs method shouldAddToGlobal.
public boolean shouldAddToGlobal(Point point) {
final TabLabel label = getSelectedLabel();
if (label == null || point == null) {
return true;
}
final Rectangle bounds = label.getBounds();
return point.y <= bounds.y + bounds.height;
}
use of com.intellij.ui.tabs.impl.TabLabel in project intellij-community by JetBrains.
the class JBRunnerTabs method processDropOver.
@Override
public void processDropOver(TabInfo over, RelativePoint relativePoint) {
final Point point = relativePoint.getPoint(getComponent());
myShowDropLocation = shouldAddToGlobal(point);
super.processDropOver(over, relativePoint);
for (Map.Entry<TabInfo, TabLabel> entry : myInfo2Label.entrySet()) {
final TabLabel label = entry.getValue();
if (label.getBounds().contains(point) && myDropInfo != entry.getKey()) {
select(entry.getKey(), false);
break;
}
}
}
use of com.intellij.ui.tabs.impl.TabLabel in project intellij-community by JetBrains.
the class TableLayout method getDropIndexFor.
@Override
public int getDropIndexFor(Point point) {
if (myLastTableLayout == null)
return -1;
int result = -1;
Component c = myTabs.getComponentAt(point);
if (c instanceof JBTabsImpl) {
for (int i = 0; i < myLastTableLayout.myVisibleInfos.size() - 1; i++) {
TabLabel first = myTabs.myInfo2Label.get(myLastTableLayout.myVisibleInfos.get(i));
TabLabel second = myTabs.myInfo2Label.get(myLastTableLayout.myVisibleInfos.get(i + 1));
Rectangle firstBounds = first.getBounds();
Rectangle secondBounds = second.getBounds();
final boolean between = firstBounds.getMaxX() < point.x && secondBounds.getX() > point.x && firstBounds.y < point.y && secondBounds.getMaxY() > point.y;
if (between) {
c = first;
break;
}
}
}
if (c instanceof TabLabel) {
TabInfo info = ((TabLabel) c).getInfo();
int index = myLastTableLayout.myVisibleInfos.indexOf(info);
boolean isDropTarget = myTabs.isDropTarget(info);
if (!isDropTarget) {
for (int i = 0; i <= index; i++) {
if (myTabs.isDropTarget(myLastTableLayout.myVisibleInfos.get(i))) {
index -= 1;
break;
}
}
result = index;
} else if (index < myLastTableLayout.myVisibleInfos.size()) {
result = index;
}
}
return result;
}
use of com.intellij.ui.tabs.impl.TabLabel 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.impl.TabLabel in project intellij-community by JetBrains.
the class TableLayout method computeLayoutTable.
private TablePassInfo computeLayoutTable(List<TabInfo> visibleInfos) {
final TablePassInfo data = new TablePassInfo(myTabs, visibleInfos);
final Insets insets = myTabs.getLayoutInsets();
data.toFitRec = new Rectangle(insets.left, insets.top, myTabs.getWidth() - insets.left - insets.right, myTabs.getHeight() - insets.top - insets.bottom);
int eachRow = 0, eachX = data.toFitRec.x;
TableRow eachTableRow = new TableRow(data);
data.table.add(eachTableRow);
data.requiredRows = 1;
for (TabInfo eachInfo : data.myVisibleInfos) {
final TabLabel eachLabel = myTabs.myInfo2Label.get(eachInfo);
final Dimension size = eachLabel.getPreferredSize();
if (eachX + size.width >= data.toFitRec.getMaxX()) {
data.requiredRows++;
eachX = data.toFitRec.x;
}
myTabs.layout(eachLabel, eachX, 0, size.width, 1);
eachX += size.width + myTabs.getInterTabSpaceLength();
data.requiredWidth += size.width + myTabs.getInterTabSpaceLength();
}
int selectedRow = -1;
eachX = data.toFitRec.x;
data.rowToFitMaxX = (int) data.toFitRec.getMaxX();
if (data.requiredRows > 1) {
final int rowFit = insets.left + data.requiredWidth / data.requiredRows;
for (TabInfo eachInfo : data.myVisibleInfos) {
final TabLabel eachLabel = myTabs.myInfo2Label.get(eachInfo);
final Rectangle eachBounds = eachLabel.getBounds();
if (eachBounds.contains(rowFit, 0)) {
data.rowToFitMaxX = (int) eachLabel.getBounds().getMaxX();
break;
}
}
}
for (TabInfo eachInfo : data.myVisibleInfos) {
final TabLabel eachLabel = myTabs.myInfo2Label.get(eachInfo);
final Dimension size = eachLabel.getPreferredSize();
if (eachX + size.width <= data.rowToFitMaxX) {
eachTableRow.add(eachInfo);
if (myTabs.getSelectedInfo() == eachInfo) {
selectedRow = eachRow;
}
eachX += size.width + myTabs.getInterTabSpaceLength();
} else {
eachTableRow = new TableRow(data);
data.table.add(eachTableRow);
eachRow++;
eachX = insets.left + size.width;
eachTableRow.add(eachInfo);
if (myTabs.getSelectedInfo() == eachInfo) {
selectedRow = eachRow;
}
}
}
List<TableRow> toMove = new ArrayList<>();
for (int i = selectedRow + 1; i < data.table.size(); i++) {
toMove.add(data.table.get(i));
}
return data;
}
Aggregations