mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
change toolwindows hidden tabs popup icon (#IDEA-190646, #IDEA-186615)
(cherry picked from commit cfb5cab)
https://upsource.jetbrains.com/IDEA/review/IDEA-CR-32397
This commit is contained in:
@@ -19,16 +19,17 @@ import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.util.ui.GraphicsUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author pegov
|
||||
*/
|
||||
public abstract class MoreTabsIcon {
|
||||
private final Icon icon = AllIcons.General.MoreTabs;
|
||||
private int myCounter;
|
||||
|
||||
public void paintIcon(final Component c, Graphics graphics) {
|
||||
@@ -44,26 +45,34 @@ public abstract class MoreTabsIcon {
|
||||
int width = graphics.getFontMetrics().stringWidth(String.valueOf(myCounter));
|
||||
iconX -= width / 2 + 1;
|
||||
|
||||
AllIcons.General.MoreTabs.paintIcon(c, graphics, iconX, iconY);
|
||||
icon.paintIcon(c, graphics, iconX, iconY);
|
||||
Graphics g = graphics.create();
|
||||
try {
|
||||
UISettings.setupAntialiasing(g);
|
||||
UIUtil.drawStringWithHighlighting(g, String.valueOf(myCounter),
|
||||
iconX + AllIcons.General.MoreTabs.getIconWidth() + 2,
|
||||
iconY + AllIcons.General.MoreTabs.getIconHeight() - 5,
|
||||
iconX + getIconWidth() + 2,
|
||||
iconY + getIconHeight() - 5,
|
||||
JBColor.BLACK,
|
||||
ColorUtil.withPreAlpha(JBColor.WHITE, .9));
|
||||
} finally {
|
||||
g.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getIconWidth() {
|
||||
return icon.getIconWidth();
|
||||
}
|
||||
|
||||
public int getIconHeight() {
|
||||
return icon.getIconHeight();
|
||||
}
|
||||
|
||||
protected int getIconX(final Rectangle iconRec) {
|
||||
return iconRec.x + iconRec.width / 2 - (AllIcons.General.MoreTabs.getIconWidth()) / 2;
|
||||
return iconRec.x + iconRec.width / 2 - (getIconWidth()) / 2;
|
||||
}
|
||||
|
||||
protected int getIconY(final Rectangle iconRec) {
|
||||
return iconRec.y + iconRec.height / 2 - AllIcons.General.MoreTabs.getIconHeight() / 2;
|
||||
return iconRec.y + iconRec.height / 2 - getIconHeight() / 2;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+8
-19
@@ -13,9 +13,11 @@ import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import com.intellij.ui.content.ContentManagerEvent;
|
||||
import com.intellij.ui.content.TabbedContent;
|
||||
import com.intellij.ui.tabs.impl.singleRow.MoreTabsIcon;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.BaseButtonBehavior;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
@@ -30,18 +32,11 @@ class TabContentLayout extends ContentLayout {
|
||||
ArrayList<ContentTabLabel> myTabs = new ArrayList<>();
|
||||
final Map<Content, ContentTabLabel> myContent2Tabs = new HashMap<>();
|
||||
|
||||
private final MoreIcon myMoreIcon = new MoreIcon() {
|
||||
private final MoreTabsIcon myMoreIcon = new MoreTabsIcon() {
|
||||
@Nullable
|
||||
protected Rectangle getIconRec() {
|
||||
return myLastLayout.moreRect;
|
||||
}
|
||||
|
||||
protected boolean isActive() {
|
||||
return myUi.myWindow.isActive();
|
||||
}
|
||||
|
||||
protected int getIconY(final Rectangle iconRec) {
|
||||
return iconRec.height / TAB_ARC - getIconHeight() / TAB_ARC;
|
||||
}
|
||||
};
|
||||
|
||||
TabContentLayout(ToolWindowContentUi ui) {
|
||||
@@ -181,21 +176,15 @@ class TabContentLayout extends ContentLayout {
|
||||
|
||||
if (data.toDrop.size() > 0) {
|
||||
data.moreRect = new Rectangle(data.eachX + MORE_ICON_BORDER, 0, myMoreIcon.getIconWidth(), bounds.height);
|
||||
final int selectedIndex = manager.getIndexOfContent(manager.getSelectedContent());
|
||||
if (selectedIndex == 0) {
|
||||
myMoreIcon.setPaintedIcons(false, true);
|
||||
}
|
||||
else if (selectedIndex == manager.getContentCount() - 1) {
|
||||
myMoreIcon.setPaintedIcons(true, false);
|
||||
}
|
||||
else {
|
||||
myMoreIcon.setPaintedIcons(true, true);
|
||||
}
|
||||
myMoreIcon.updateCounter(data.toDrop.size());
|
||||
}
|
||||
else {
|
||||
data.moreRect = null;
|
||||
}
|
||||
|
||||
final Rectangle moreRect = data.moreRect == null ? null : new Rectangle(data.eachX, 0, myMoreIcon.getIconWidth()+MORE_ICON_BORDER, bounds.height);
|
||||
|
||||
myUi.isResizableArea = p -> moreRect == null || !moreRect.contains(p);
|
||||
myLastLayout = data;
|
||||
}
|
||||
|
||||
|
||||
+9
-2
@@ -43,6 +43,7 @@ import com.intellij.util.ContentUtilEx;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.EmptyIterator;
|
||||
import com.intellij.util.containers.JBIterable;
|
||||
import com.intellij.util.containers.Predicate;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -81,6 +82,8 @@ public class ToolWindowContentUi extends JPanel implements ContentUI, PropertyCh
|
||||
|
||||
private ToolWindowContentUiType myType = ToolWindowContentUiType.TABBED;
|
||||
|
||||
public Predicate<Point> isResizableArea = p -> true;
|
||||
|
||||
public ToolWindowContentUi(ToolWindowImpl window) {
|
||||
myWindow = window;
|
||||
myContent.setOpaque(false);
|
||||
@@ -130,6 +133,10 @@ public class ToolWindowContentUi extends JPanel implements ContentUI, PropertyCh
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isResizeable(@NotNull Point point) {
|
||||
return isResizableArea.apply(point);
|
||||
}
|
||||
|
||||
public void setType(@NotNull ToolWindowContentUiType type) {
|
||||
if (myType != type) {
|
||||
|
||||
@@ -380,7 +387,7 @@ public class ToolWindowContentUi extends JPanel implements ContentUI, PropertyCh
|
||||
myLastPoint.set(info != null ? info.getLocation() : e.getLocationOnScreen());
|
||||
if (allowResize && ui.isResizeable()) {
|
||||
myPressPoint.set(myLastPoint.get());
|
||||
arm(c.getComponentAt(e.getPoint()) == c ? c : null);
|
||||
arm(c.getComponentAt(e.getPoint()) == c && ui.isResizeable(e.getPoint()) ? c : null);
|
||||
}
|
||||
ui.myWindow.fireActivated();
|
||||
}
|
||||
@@ -399,7 +406,7 @@ public class ToolWindowContentUi extends JPanel implements ContentUI, PropertyCh
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
c.setCursor(allowResize && ui.isResizeable() && getActualSplitter() != null && c.getComponentAt(e.getPoint()) == c
|
||||
c.setCursor(allowResize && ui.isResizeable() && getActualSplitter() != null && c.getComponentAt(e.getPoint()) == c && ui.isResizeable(e.getPoint())
|
||||
? Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR)
|
||||
: Cursor.getDefaultCursor());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user