From 6902fe4c069926bc4eba5da32caf68678a7f6c49 Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Wed, 15 Oct 2014 20:13:37 +0400 Subject: [PATCH] Fix vertical gaps for big fonts in push dialog tree renderer. --- .../intellij/dvcs/push/ui/RepositoryNode.java | 27 ++++++++++--------- .../push/ui/RepositoryWithBranchPanel.java | 6 +++++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java index 169d09a19c73..12236ed4aefe 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java @@ -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 diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java index 833ae6aa6b4c..e54f867f72a8 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java @@ -52,6 +52,7 @@ public class RepositoryWithBranchPanel 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 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 extends NonOpaquePa Border border = coloredRenderer.getMyBorder(); return border != null ? border.getBorderInsets(coloredRenderer).top : 0; } + + public int getCheckBoxHeight() { + return myCheckBoxHeight; + } }