mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix vertical gaps for big fonts in push dialog tree renderer.
This commit is contained in:
@@ -71,7 +71,6 @@ public class RepositoryNode extends CheckedTreeNode implements EditableTreeNode,
|
||||
public void render(@NotNull ColoredTreeCellRenderer renderer) {
|
||||
int repoFixedWidth = 120;
|
||||
int borderHOffset = myRepositoryPanel.getHBorderOffset(renderer);
|
||||
int borderVOffset = myRepositoryPanel.getVBorderOffset(renderer);
|
||||
if (myLoading.get()) {
|
||||
renderer.setIcon(myLoadingIcon);
|
||||
renderer.setIconOnTheRight(false);
|
||||
@@ -81,27 +80,31 @@ public class RepositoryNode extends CheckedTreeNode implements EditableTreeNode,
|
||||
renderer.append("");
|
||||
renderer.appendFixedTextFragmentWidth(checkBoxWidth + renderer.getIconTextGap() + borderHOffset);
|
||||
}
|
||||
if (myCheckBoxVGap > 0) {
|
||||
int shiftV = myCheckBoxVGap - borderVOffset;
|
||||
renderer.setBorder(new EmptyBorder(shiftV / 2, 0, shiftV / 2, 0));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (myCheckBoxHGap <= 0) {
|
||||
renderer.append("");
|
||||
renderer.appendFixedTextFragmentWidth(myRepositoryPanel.calculateRendererShiftH(renderer));
|
||||
}
|
||||
if (myCheckBoxVGap <= 0) {
|
||||
int shiftV = -myCheckBoxVGap + borderVOffset;
|
||||
renderer.setBorder(new EmptyBorder(shiftV / 2, 0, shiftV / 2, 0));
|
||||
}
|
||||
}
|
||||
renderer.append(getRepoName(renderer, repoFixedWidth), isChecked() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES);
|
||||
renderer.append(getRepoName(renderer, repoFixedWidth),
|
||||
isChecked() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES);
|
||||
renderer.appendFixedTextFragmentWidth(repoFixedWidth);
|
||||
renderer.append(myRepositoryPanel.getSourceName(), isChecked() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES);
|
||||
renderer.append(myRepositoryPanel.getArrow(), isChecked() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES);
|
||||
renderer.append(myRepositoryPanel.getSourceName(),
|
||||
isChecked() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES);
|
||||
renderer
|
||||
.append(myRepositoryPanel.getArrow(), isChecked() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES);
|
||||
PushTargetPanel pushTargetPanel = myRepositoryPanel.getTargetPanel();
|
||||
pushTargetPanel.render(renderer);
|
||||
|
||||
int maxSize = Math.max(myRepositoryPanel.getCheckBoxHeight(), myLoadingIcon.getIconHeight());
|
||||
int rendererHeight = renderer.getPreferredSize().height;
|
||||
if (maxSize > rendererHeight) {
|
||||
if (myCheckBoxVGap > 0 && isLoading() || myCheckBoxVGap < 0 && !isLoading()) {
|
||||
int vShift = maxSize - rendererHeight;
|
||||
renderer.setBorder(new EmptyBorder((vShift + 1) / 2, 0, (vShift) / 2, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -52,6 +52,7 @@ public class RepositoryWithBranchPanel<T extends PushTarget> extends NonOpaquePa
|
||||
private final int myCheckBoxLoadingIconGapV;
|
||||
private final LoadingIcon myLoadingIcon;
|
||||
private final int myCheckBoxWidth;
|
||||
private final int myCheckBoxHeight;
|
||||
|
||||
|
||||
public RepositoryWithBranchPanel(@NotNull final Project project, @NotNull String repoName,
|
||||
@@ -102,6 +103,7 @@ public class RepositoryWithBranchPanel<T extends PushTarget> extends NonOpaquePa
|
||||
emptyBorderCheckBox.setBorder(null);
|
||||
Dimension size = emptyBorderCheckBox.getPreferredSize();
|
||||
myCheckBoxWidth = size.width;
|
||||
myCheckBoxHeight = size.height;
|
||||
myLoadingIcon = LoadingIcon.create(myCheckBoxWidth, size.height);
|
||||
myCheckBoxLoadingIconGapH = myCheckBoxWidth - myLoadingIcon.getIconWidth();
|
||||
myCheckBoxLoadingIconGapV = size.height - myLoadingIcon.getIconHeight();
|
||||
@@ -223,6 +225,10 @@ public class RepositoryWithBranchPanel<T extends PushTarget> extends NonOpaquePa
|
||||
Border border = coloredRenderer.getMyBorder();
|
||||
return border != null ? border.getBorderInsets(coloredRenderer).top : 0;
|
||||
}
|
||||
|
||||
public int getCheckBoxHeight() {
|
||||
return myCheckBoxHeight;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user