提交 f4f571df 编写于 作者: J jurgen

Grid background fix

上级 a53f8798
......@@ -423,6 +423,7 @@ public abstract class LightGrid extends Canvas {
setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND));
setLineColor(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
backgroundColor = getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
if ((style & SWT.MULTI) != 0) {
selectionType = SWT.MULTI;
......@@ -448,9 +449,6 @@ public abstract class LightGrid extends Canvas {
itemHeight = sizingGC.getFontMetrics().getHeight() + 3;
//RGB white = getDisplay().getSystemColor(SWT.COLOR_WHITE).getRGB();
RGB cellSel = blend(
getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION).getRGB(),
new RGB(255, 255, 255),
......@@ -545,9 +543,6 @@ public abstract class LightGrid extends Canvas {
@Override
public Color getBackground()
{
checkWidget();
if (backgroundColor == null)
return getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
return backgroundColor;
}
......@@ -557,7 +552,6 @@ public abstract class LightGrid extends Canvas {
@Override
public void setBackground(Color color)
{
checkWidget();
backgroundColor = color;
redraw();
}
......@@ -4391,12 +4385,12 @@ public abstract class LightGrid extends Canvas {
} while (true);
}
private int blend(int v1, int v2, int ratio)
private static int blend(int v1, int v2, int ratio)
{
return (ratio * v1 + (100 - ratio) * v2) / 100;
}
private RGB blend(RGB c1, RGB c2, int ratio)
public static RGB blend(RGB c1, RGB c2, int ratio)
{
int r = blend(c1.red, c2.red, ratio);
int g = blend(c1.green, c2.green, ratio);
......
......@@ -20,6 +20,7 @@ package org.jkiss.dbeaver.ui.controls.lightgrid.renderers;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.*;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.ui.TextUtils;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.lightgrid.LightGrid;
......@@ -73,7 +74,17 @@ public class DefaultCellRenderer extends GridCellRenderer {
}
if (drawAsSelected) {
gc.setBackground(colorSelected);
Color cellBackground = grid.getCellBackground(column, row);
if (cellBackground.equals(grid.getBackground())) {
gc.setBackground(colorSelected);
} else {
RGB cellSel = LightGrid.blend(
cellBackground.getRGB(),
colorSelected.getRGB(),
50);
gc.setBackground(DBeaverUI.getSharedTextColors().getColor(cellSel));
}
gc.setForeground(colorSelectedText);
} else {
if (grid.isEnabled()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册