mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-196056 Plugins: fix "Plugins" button base line
This commit is contained in:
@@ -120,8 +120,9 @@ public class Breadcrumbs extends JBPanelWithEmptyText {
|
||||
repaint();
|
||||
}
|
||||
|
||||
public int getBaseline() {
|
||||
return views.isEmpty() ? 0 : views.get(0).getBaseline();
|
||||
@Override
|
||||
public int getBaseline(int width, int height) {
|
||||
return views.isEmpty() ? -1 : views.get(0).getBaseline();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+9
-1
@@ -35,6 +35,7 @@ import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.ui.components.JBTextField;
|
||||
import com.intellij.ui.components.labels.LinkLabel;
|
||||
import com.intellij.ui.components.labels.LinkListener;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.io.HttpRequests;
|
||||
@@ -287,7 +288,14 @@ public class PluginManagerConfigurableNew
|
||||
myCardPanel.select(Pair.create(descriptor, label != null && currentTab == UPDATES_TAB), true);
|
||||
myPluginsModel.detailPanel.backTabIndex = currentTab;
|
||||
|
||||
myTopController.setLeftComponent(backButton);
|
||||
NonOpaquePanel buttonPanel = new NonOpaquePanel(backButton) {
|
||||
@Override
|
||||
public int getBaseline(int width, int height) {
|
||||
return backButton.getBaseline(width, height);
|
||||
}
|
||||
};
|
||||
buttonPanel.setBorder(JBUI.Borders.empty(0, 3));
|
||||
myTopController.setLeftComponent(buttonPanel);
|
||||
myTabHeaderComponent.clearSelection();
|
||||
};
|
||||
|
||||
|
||||
@@ -219,13 +219,9 @@ public class TabHeaderComponent extends JComponent {
|
||||
super.paintComponent(g);
|
||||
calculateSize();
|
||||
|
||||
FontMetrics fm = getFontMetrics(getFont());
|
||||
int x = getStartX();
|
||||
int height = getHeight();
|
||||
int tabTitleY = fm.getAscent() + (height - fm.getHeight()) / 2;
|
||||
if (myBreadcrumbs != null) {
|
||||
tabTitleY = myBaselineY + myBreadcrumbs.getBaseline();
|
||||
}
|
||||
int tabTitleY = getBaseline(-1, -1);
|
||||
|
||||
for (int i = 0, size = myTabs.size(); i < size; i++) {
|
||||
if (mySelectionTab == i || myHoverTab == i) {
|
||||
@@ -241,6 +237,16 @@ public class TabHeaderComponent extends JComponent {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBaseline(int width, int height) {
|
||||
FontMetrics fm = getFontMetrics(getFont());
|
||||
int tabTitleY = fm.getAscent() + (getHeight() - fm.getHeight()) / 2;
|
||||
if (myBreadcrumbs != null) {
|
||||
tabTitleY = myBaselineY + Math.max(myBreadcrumbs.getBaseline(-1, -1), 0);
|
||||
}
|
||||
return tabTitleY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBounds(int x, int y, int width, int height) {
|
||||
myBaselineY = y;
|
||||
|
||||
@@ -79,4 +79,13 @@ final class Banner extends SimpleBanner {
|
||||
super.setLeftComponent(component);
|
||||
myBreadcrumbs.setVisible(component == null);
|
||||
}
|
||||
|
||||
@Override
|
||||
void updateProgressBorder() {
|
||||
}
|
||||
|
||||
@Override
|
||||
Component getBaselineTemplate() {
|
||||
return myBreadcrumbs;
|
||||
}
|
||||
}
|
||||
|
||||
+58
-1
@@ -4,6 +4,7 @@ package com.intellij.openapi.options.newEditor;
|
||||
import com.intellij.ui.AnimatedIcon;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -15,17 +16,63 @@ class SimpleBanner extends JPanel {
|
||||
private final AnimatedIcon.Default myAnimatedIcon = new AnimatedIcon.Default();
|
||||
private boolean myShowProgress;
|
||||
|
||||
protected final JPanel myLeftPanel = new NonOpaquePanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
|
||||
protected final JPanel myLeftPanel;
|
||||
protected final JLabel myProgress = new JLabel(EmptyIcon.ICON_16);
|
||||
protected Component myLeftComponent;
|
||||
protected Component myCenterComponent;
|
||||
|
||||
SimpleBanner() {
|
||||
super(new BorderLayout(10, 0));
|
||||
myLeftPanel = new NonOpaquePanel(new FlowLayout(FlowLayout.CENTER, 0, 0) {
|
||||
@Override
|
||||
public Dimension preferredLayoutSize(Container target) {
|
||||
return getPreferredLeftPanelSize(super.preferredLayoutSize(target));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void layoutContainer(Container target) {
|
||||
super.layoutContainer(target);
|
||||
baselineLayout();
|
||||
}
|
||||
});
|
||||
myLeftPanel.add(myProgress);
|
||||
add(BorderLayout.WEST, myLeftPanel);
|
||||
}
|
||||
|
||||
Dimension getPreferredLeftPanelSize(Dimension size) {
|
||||
return size;
|
||||
}
|
||||
|
||||
private void baselineLayout() {
|
||||
Component template = getBaselineTemplate();
|
||||
if (template == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int baseline = template.getBaseline(template.getWidth(), template.getHeight());
|
||||
if (baseline == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
int components = myLeftPanel.getComponentCount();
|
||||
for (int i = 0; i < components; i++) {
|
||||
Component component = myLeftPanel.getComponent(i);
|
||||
if (component == template) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int y;
|
||||
if (component == myProgress) {
|
||||
y = (int)(JBUI.scale(1.5f) + (template.getHeight() - component.getHeight()) / 2f);
|
||||
}
|
||||
else {
|
||||
y = baseline - component.getBaseline(component.getWidth(), component.getHeight());
|
||||
}
|
||||
|
||||
component.setLocation(component.getX(), y);
|
||||
}
|
||||
}
|
||||
|
||||
void setLeftComponent(Component component) {
|
||||
if (myLeftComponent != null) {
|
||||
myLeftPanel.remove(myLeftComponent);
|
||||
@@ -35,6 +82,7 @@ class SimpleBanner extends JPanel {
|
||||
myLeftComponent = component;
|
||||
myLeftPanel.add(component, 0);
|
||||
}
|
||||
updateProgressBorder();
|
||||
}
|
||||
|
||||
void setCenterComponent(Component component) {
|
||||
@@ -52,9 +100,18 @@ class SimpleBanner extends JPanel {
|
||||
void showProgress(boolean start) {
|
||||
myShowProgress = start;
|
||||
myProgress.setIcon(start ? myAnimatedIcon : EmptyIcon.ICON_16);
|
||||
updateProgressBorder();
|
||||
}
|
||||
|
||||
void updateProgressBorder() {
|
||||
myProgress.setBorder(myLeftPanel.getComponentCount() == 1 ? JBUI.Borders.emptyLeft(10) : null);
|
||||
}
|
||||
|
||||
boolean canShow() {
|
||||
return myLeftComponent != null || myCenterComponent != null || myShowProgress;
|
||||
}
|
||||
|
||||
Component getBaselineTemplate() {
|
||||
return myCenterComponent;
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -3,6 +3,7 @@ package com.intellij.openapi.options.newEditor;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.HashMap;
|
||||
@@ -12,7 +13,12 @@ import java.util.Map;
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class SingleSettingEditor extends ConfigurableEditor {
|
||||
private final SimpleBanner myBanner = new SimpleBanner();
|
||||
private final SimpleBanner myBanner = new SimpleBanner() {
|
||||
@Override
|
||||
Dimension getPreferredLeftPanelSize(Dimension size) {
|
||||
return new Dimension(size.width, JBUI.scale(35));
|
||||
}
|
||||
};
|
||||
private final Map<Configurable, ConfigurableController> myControllers = new HashMap<>();
|
||||
private ConfigurableController myLastController;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user