mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
wide selection fixes on Win
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -316,7 +316,7 @@ public class CheckboxTreeBase extends Tree {
|
||||
myCheckbox.setVisible(true);
|
||||
myCheckbox.setSelected(state != NodeState.CLEAR);
|
||||
myCheckbox.setEnabled(node.isEnabled() && state != NodeState.PARTIAL);
|
||||
|
||||
myCheckbox.setOpaque(false);
|
||||
myCheckbox.setBackground(null);
|
||||
setBackground(null);
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
|
||||
public void setUI(final TreeUI ui) {
|
||||
TreeUI actualUI = ui;
|
||||
if (!isCustomUI()) {
|
||||
if (!(ui instanceof WideSelectionTreeUI) && (UIUtil.isUnderAquaBasedLookAndFeel() || SystemInfo.isWindows)) { //todo[kb] fix on ubunty
|
||||
if (!(ui instanceof WideSelectionTreeUI) && (UIUtil.isUnderAquaBasedLookAndFeel() || SystemInfo.isWindows) && isMacWideSelection()) { //todo[kb] fix on ubunty
|
||||
actualUI = new WideSelectionTreeUI(isMacWideSelection(), !isFileColorsEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.ScreenUtil;
|
||||
import com.intellij.ui.mac.MacPopupMenuUI;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -45,6 +46,7 @@ import sun.security.action.GetPropertyAction;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.EventListenerList;
|
||||
import javax.swing.plaf.ColorUIResource;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
import javax.swing.plaf.metal.DefaultMetalTheme;
|
||||
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||
@@ -255,7 +257,7 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
LOG.assertTrue(laf != null);
|
||||
return laf;
|
||||
}
|
||||
if ("Rubymine".equals(lowercaseProductName) || "Pycharm".equals(lowercaseProductName)) {
|
||||
if (PlatformUtils.isRubyMine() || PlatformUtils.isPyCharm()) {
|
||||
final String desktop = AccessController.doPrivileged(new GetPropertyAction("sun.desktop"));
|
||||
if ("gnome".equals(desktop)) {
|
||||
UIManager.LookAndFeelInfo laf=findLaf(systemLafClassName);
|
||||
@@ -432,8 +434,8 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
fixPopupWeight();
|
||||
|
||||
fixGtkPopupStyle();
|
||||
|
||||
final UIDefaults uiDefaults = UIManager.getLookAndFeelDefaults();
|
||||
fixTreeWideSelection(uiDefaults);
|
||||
if (UIUtil.isUnderAquaLookAndFeel()) {
|
||||
// update ui for popup menu to get round corners
|
||||
uiDefaults.put("PopupMenuUI", MacPopupMenuUI.class.getCanonicalName());
|
||||
@@ -466,6 +468,30 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
fixSeparatorColor(uiDefaults);
|
||||
}
|
||||
|
||||
private static void fixTreeWideSelection(UIDefaults uiDefaults) {
|
||||
if (UIUtil.isUnderAlloyIDEALookAndFeel()) {
|
||||
final Color bg = new ColorUIResource(56, 117, 215);
|
||||
uiDefaults.put("Tree.selectionBackground", bg);
|
||||
uiDefaults.put("MenuItem.selectionBackground", bg);
|
||||
uiDefaults.put("Menu.selectionBackground", bg);
|
||||
uiDefaults.put("List.selectionBackground", bg);
|
||||
uiDefaults.put("ComboBox.selectionBackground", bg);
|
||||
uiDefaults.put("Table.selectionBackground", bg);
|
||||
uiDefaults.put("TextArea.selectionBackground", bg);
|
||||
uiDefaults.put("EditorPane.selectionBackground", bg);
|
||||
uiDefaults.put("TextPane.selectionBackground", bg);
|
||||
uiDefaults.put("info", bg);
|
||||
uiDefaults.put("FormattedTextField.selectionBackground", bg);
|
||||
uiDefaults.put("textHighlight", bg);
|
||||
uiDefaults.put("PasswordField.selectionBackground", bg);
|
||||
uiDefaults.put("TextField.selectionBackground", bg);
|
||||
uiDefaults.put("RadioButtonMenuItem.selectionBackground", bg);
|
||||
uiDefaults.put("CheckBoxMenuItem.selectionBackground", bg);
|
||||
} if (UIUtil.isUnderMetalLookAndFeel()) {
|
||||
uiDefaults.put("Tree.hash", new ColorUIResource(117, 117, 117));
|
||||
}
|
||||
}
|
||||
|
||||
private static void fixSeparatorColor(UIDefaults uiDefaults) {
|
||||
if (UIUtil.isUnderAquaLookAndFeel()) {
|
||||
uiDefaults.put("Separator.background", UIUtil.AQUA_SEPARATOR_BACKGROUND_COLOR);
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.util.ui.tree;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.util.containers.ComparatorUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -54,6 +55,8 @@ public class WideSelectionTreeUI extends BasicTreeUI {
|
||||
private boolean myWideSelection;
|
||||
private boolean myAlwaysPaintRowBackground;
|
||||
private boolean myOldRepaintAllRowValue;
|
||||
private boolean invertLineColor;
|
||||
|
||||
|
||||
public WideSelectionTreeUI() {
|
||||
this(true, true);
|
||||
@@ -216,7 +219,11 @@ public class WideSelectionTreeUI extends BasicTreeUI {
|
||||
final boolean hasBeenExpanded,
|
||||
final boolean isLeaf) {
|
||||
if (!UIUtil.isUnderAquaBasedLookAndFeel()) {
|
||||
if (UIUtil.isUnderAlloyIDEALookAndFeel()) {
|
||||
invertLineColor = tree.getSelectionModel().isRowSelected(row) && tree.hasFocus();
|
||||
}
|
||||
super.paintHorizontalPartOfLeg(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
|
||||
invertLineColor = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,17 +235,42 @@ public class WideSelectionTreeUI extends BasicTreeUI {
|
||||
@Override
|
||||
protected void paintVerticalPartOfLeg(final Graphics g, final Rectangle clipBounds, final Insets insets, final TreePath path) {
|
||||
if (!UIUtil.isUnderAquaBasedLookAndFeel()) {
|
||||
invertLineColor = UIUtil.isUnderAlloyIDEALookAndFeel() && tree.hasFocus() && tree.getSelectionModel().isPathSelected(path);
|
||||
super.paintVerticalPartOfLeg(g, clipBounds, insets, path);
|
||||
invertLineColor = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintHorizontalLine(Graphics g, JComponent c, int y, int left, int right) {
|
||||
if (!UIUtil.isUnderAquaBasedLookAndFeel()) {
|
||||
super.paintHorizontalLine(g, c, y, left, right);
|
||||
protected void paintVerticalLine(Graphics g, JComponent c, int x, int top, int bottom) {
|
||||
if (tree.hasFocus()) {
|
||||
int y0 = top, y1 = top;
|
||||
while (y1 < bottom) {
|
||||
y0 = y1;
|
||||
final int row = tree.getRowForPath(tree.getClosestPathForLocation(x, y0 + 1));
|
||||
invertLineColor = tree.isRowSelected(row);
|
||||
g.setColor(getHashColor());
|
||||
final Rectangle bounds = tree.getRowBounds(row);
|
||||
y1 = bounds.y + bounds.height;
|
||||
super.paintVerticalLine(g, c, x, y0, Math.min(bottom, y1));
|
||||
}
|
||||
invertLineColor = false;
|
||||
} else {
|
||||
super.paintVerticalLine(g, c, x, top, bottom);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Color getHashColor() {
|
||||
if (invertLineColor && !ComparatorUtil.equalsNullable(UIUtil.getTreeSelectionForeground(), UIUtil.getTreeForeground())) {
|
||||
final Color c = UIUtil.getTreeSelectionForeground();
|
||||
if (c != null) {
|
||||
return c.darker();
|
||||
}
|
||||
}
|
||||
return super.getHashColor();
|
||||
}
|
||||
|
||||
public boolean isWideSelection() {
|
||||
return myWideSelection;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user