mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-21 15:23:59 +02:00
launchbar: fixing colors to be compatible with skinning
it looked awful in dark skin, now it should be inheriting system colors properly Change-Id: If963a19651ac30b20c7a2cb100b285f33f799ca9
This commit is contained in:
parent
d5c63d386c
commit
9435e1f802
3 changed files with 42 additions and 39 deletions
|
@ -62,17 +62,12 @@ public abstract class CSelector extends Composite {
|
||||||
private static final int arrowMax = 2;
|
private static final int arrowMax = 2;
|
||||||
private Transition arrowTransition;
|
private Transition arrowTransition;
|
||||||
private Object selection;
|
private Object selection;
|
||||||
protected final Color backgroundColor;
|
|
||||||
protected final Color outlineColor;
|
|
||||||
protected final Color highlightColor;
|
|
||||||
protected final Color white;
|
|
||||||
private boolean mouseOver;
|
private boolean mouseOver;
|
||||||
private Label currentIcon;
|
private Label currentIcon;
|
||||||
private Label currentLabel;
|
private Label currentLabel;
|
||||||
private Shell popup;
|
private Shell popup;
|
||||||
private LaunchBarListViewer listViewer;
|
private LaunchBarListViewer listViewer;
|
||||||
private Job delayJob;
|
private Job delayJob;
|
||||||
|
|
||||||
private MouseListener mouseListener = new MouseAdapter() {
|
private MouseListener mouseListener = new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseUp(MouseEvent event) {
|
public void mouseUp(MouseEvent event) {
|
||||||
|
@ -91,7 +86,6 @@ public abstract class CSelector extends Composite {
|
||||||
}
|
}
|
||||||
return control == this;
|
return control == this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Listener focusOutListener = new Listener() {
|
private Listener focusOutListener = new Listener() {
|
||||||
private Job closingJob;
|
private Job closingJob;
|
||||||
|
|
||||||
|
@ -121,7 +115,6 @@ public abstract class CSelector extends Composite {
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
return Status.CANCEL_STATUS;
|
return Status.CANCEL_STATUS;
|
||||||
|
|
||||||
closePopup();
|
closePopup();
|
||||||
closingJob = null;
|
closingJob = null;
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
|
@ -141,23 +134,20 @@ public abstract class CSelector extends Composite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public CSelector(Composite parent, int style) {
|
public CSelector(Composite parent, int style) {
|
||||||
super(parent, style);
|
super(parent, style);
|
||||||
backgroundColor = getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
|
setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
|
||||||
outlineColor = getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
|
|
||||||
highlightColor = getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
|
|
||||||
white = getDisplay().getSystemColor(SWT.COLOR_WHITE);
|
|
||||||
GridLayout mainButtonLayout = new GridLayout();
|
GridLayout mainButtonLayout = new GridLayout();
|
||||||
setLayout(mainButtonLayout);
|
setLayout(mainButtonLayout);
|
||||||
addPaintListener(new PaintListener() {
|
addPaintListener(new PaintListener() {
|
||||||
@Override
|
@Override
|
||||||
public void paintControl(PaintEvent e) {
|
public void paintControl(PaintEvent e) {
|
||||||
GC gc = e.gc;
|
GC gc = e.gc;
|
||||||
gc.setBackground(backgroundColor);
|
gc.setBackground(getBackground());
|
||||||
gc.setForeground(outlineColor);
|
gc.setForeground(getOutlineColor());
|
||||||
Point size = getSize();
|
Point size = getSize();
|
||||||
final int arc = 3;
|
final int arc = 3;
|
||||||
gc.fillRoundRectangle(0, 0, size.x - 1, size.y - 1, arc, arc);
|
gc.fillRoundRectangle(0, 0, size.x - 1, size.y - 1, arc, arc);
|
||||||
|
@ -226,7 +216,7 @@ public abstract class CSelector extends Composite {
|
||||||
buttonLayout.marginHeight = buttonLayout.marginWidth = 0;
|
buttonLayout.marginHeight = buttonLayout.marginWidth = 0;
|
||||||
buttonComposite.setLayout(buttonLayout);
|
buttonComposite.setLayout(buttonLayout);
|
||||||
buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||||
buttonComposite.setBackground(backgroundColor);
|
buttonComposite.setBackground(getBackground());
|
||||||
buttonComposite.addMouseListener(mouseListener);
|
buttonComposite.addMouseListener(mouseListener);
|
||||||
buttonComposite.setToolTipText(toolTipText);
|
buttonComposite.setToolTipText(toolTipText);
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
|
@ -253,7 +243,8 @@ public abstract class CSelector extends Composite {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
arrow.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
|
arrow.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
|
||||||
arrow.setBackground(backgroundColor);
|
arrow.setBackground(getBackground());
|
||||||
|
arrow.setForeground(getForeground());
|
||||||
arrowTransition = new Transition(arrow, arrowMax, 80);
|
arrowTransition = new Transition(arrow, arrowMax, 80);
|
||||||
arrow.addPaintListener(new PaintListener() {
|
arrow.addPaintListener(new PaintListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -275,7 +266,7 @@ public abstract class CSelector extends Composite {
|
||||||
if (editable) {
|
if (editable) {
|
||||||
final EditButton editButton = new EditButton(buttonComposite, SWT.NONE);
|
final EditButton editButton = new EditButton(buttonComposite, SWT.NONE);
|
||||||
editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
|
editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
|
||||||
editButton.setBackground(backgroundColor);
|
editButton.setBackground(getBackground());
|
||||||
editButton.addSelectionListener(new SelectionAdapter() {
|
editButton.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
@ -314,7 +305,7 @@ public abstract class CSelector extends Composite {
|
||||||
}
|
}
|
||||||
popup = new Shell(getShell(), SWT.TOOL | SWT.ON_TOP | SWT.RESIZE);
|
popup = new Shell(getShell(), SWT.TOOL | SWT.ON_TOP | SWT.RESIZE);
|
||||||
popup.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 0).create());
|
popup.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 0).create());
|
||||||
|
popup.setBackground(getBackground());
|
||||||
listViewer = new LaunchBarListViewer(popup);
|
listViewer = new LaunchBarListViewer(popup);
|
||||||
initializeListViewer(listViewer);
|
initializeListViewer(listViewer);
|
||||||
listViewer.setFilterVisible(elements.length > 7);
|
listViewer.setFilterVisible(elements.length > 7);
|
||||||
|
@ -337,7 +328,6 @@ public abstract class CSelector extends Composite {
|
||||||
Rectangle buttonBounds = getBounds();
|
Rectangle buttonBounds = getBounds();
|
||||||
Point popupLocation = popup.getDisplay().map(this, null, 0, buttonBounds.height);
|
Point popupLocation = popup.getDisplay().map(this, null, 0, buttonBounds.height);
|
||||||
popup.setLocation(popupLocation.x, popupLocation.y + 5);
|
popup.setLocation(popupLocation.x, popupLocation.y + 5);
|
||||||
|
|
||||||
restoreShellSize();
|
restoreShellSize();
|
||||||
popup.setVisible(true);
|
popup.setVisible(true);
|
||||||
popup.setFocus();
|
popup.setFocus();
|
||||||
|
@ -352,7 +342,6 @@ public abstract class CSelector extends Composite {
|
||||||
getDisplay().removeFilter(SWT.MouseUp, focusOutListener);
|
getDisplay().removeFilter(SWT.MouseUp, focusOutListener);
|
||||||
saveShellSize();
|
saveShellSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,4 +530,11 @@ public abstract class CSelector extends Composite {
|
||||||
// nothing to do here
|
// nothing to do here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Color getOutlineColor() {
|
||||||
|
return getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getHighlightColor() {
|
||||||
|
return getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.swt.events.MouseTrackAdapter;
|
||||||
import org.eclipse.swt.events.MouseTrackListener;
|
import org.eclipse.swt.events.MouseTrackListener;
|
||||||
import org.eclipse.swt.events.PaintEvent;
|
import org.eclipse.swt.events.PaintEvent;
|
||||||
import org.eclipse.swt.events.PaintListener;
|
import org.eclipse.swt.events.PaintListener;
|
||||||
|
import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.graphics.Point;
|
import org.eclipse.swt.graphics.Point;
|
||||||
|
@ -173,13 +174,13 @@ public class ConfigSelector extends CSelector {
|
||||||
GridLayout buttonLayout = new GridLayout();
|
GridLayout buttonLayout = new GridLayout();
|
||||||
buttonLayout.marginWidth = buttonLayout.marginHeight = 7;
|
buttonLayout.marginWidth = buttonLayout.marginHeight = 7;
|
||||||
createButton.setLayout(buttonLayout);
|
createButton.setLayout(buttonLayout);
|
||||||
createButton.setBackground(backgroundColor);
|
createButton.setBackground(getBackground());
|
||||||
createButton.addPaintListener(new PaintListener() {
|
createButton.addPaintListener(new PaintListener() {
|
||||||
@Override
|
@Override
|
||||||
public void paintControl(PaintEvent e) {
|
public void paintControl(PaintEvent e) {
|
||||||
Point size = createButton.getSize();
|
Point size = createButton.getSize();
|
||||||
GC gc = e.gc;
|
GC gc = e.gc;
|
||||||
gc.setForeground(outlineColor);
|
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
|
||||||
gc.drawLine(0, 0, size.x, 0);
|
gc.drawLine(0, 0, size.x, 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -187,14 +188,16 @@ public class ConfigSelector extends CSelector {
|
||||||
final Label createLabel = new Label(createButton, SWT.None);
|
final Label createLabel = new Label(createButton, SWT.None);
|
||||||
createLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
createLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||||
createLabel.setText(Messages.ConfigSelector_2);
|
createLabel.setText(Messages.ConfigSelector_2);
|
||||||
createLabel.setBackground(backgroundColor);
|
createLabel.setBackground(getBackground());
|
||||||
|
|
||||||
MouseListener mouseListener = new MouseAdapter() {
|
MouseListener mouseListener = new MouseAdapter() {
|
||||||
|
@Override
|
||||||
public void mouseUp(org.eclipse.swt.events.MouseEvent e) {
|
public void mouseUp(org.eclipse.swt.events.MouseEvent e) {
|
||||||
final NewLaunchConfigWizard wizard = new NewLaunchConfigWizard();
|
final NewLaunchConfigWizard wizard = new NewLaunchConfigWizard();
|
||||||
WizardDialog dialog = new WizardDialog(getShell(), wizard);
|
WizardDialog dialog = new WizardDialog(getShell(), wizard);
|
||||||
if (dialog.open() == Window.OK) {
|
if (dialog.open() == Window.OK) {
|
||||||
new Job(Messages.ConfigSelector_3) {
|
new Job(Messages.ConfigSelector_3) {
|
||||||
|
@Override
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
try {
|
try {
|
||||||
wizard.getWorkingCopy().doSave();
|
wizard.getWorkingCopy().doSave();
|
||||||
|
@ -214,11 +217,13 @@ public class ConfigSelector extends CSelector {
|
||||||
MouseTrackListener mouseTrackListener = new MouseTrackAdapter() {
|
MouseTrackListener mouseTrackListener = new MouseTrackAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseEnter(MouseEvent e) {
|
public void mouseEnter(MouseEvent e) {
|
||||||
|
Color highlightColor = getHighlightColor();
|
||||||
createButton.setBackground(highlightColor);
|
createButton.setBackground(highlightColor);
|
||||||
createLabel.setBackground(highlightColor);
|
createLabel.setBackground(highlightColor);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void mouseExit(MouseEvent e) {
|
public void mouseExit(MouseEvent e) {
|
||||||
|
Color backgroundColor = getBackground();
|
||||||
createButton.setBackground(backgroundColor);
|
createButton.setBackground(backgroundColor);
|
||||||
createLabel.setBackground(backgroundColor);
|
createLabel.setBackground(backgroundColor);
|
||||||
}
|
}
|
||||||
|
@ -239,6 +244,7 @@ public class ConfigSelector extends CSelector {
|
||||||
super.setSelection(element);
|
super.setSelection(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void openPopup() {
|
public void openPopup() {
|
||||||
super.openPopup();
|
super.openPopup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,9 +172,6 @@ public class LaunchBarListViewer extends StructuredViewer {
|
||||||
private Label label;
|
private Label label;
|
||||||
protected EditButton editButton;
|
protected EditButton editButton;
|
||||||
private int index;
|
private int index;
|
||||||
private Color backgroundColor = getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
|
|
||||||
private Color outlineColor = getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
|
|
||||||
private Color highlightColor = getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
|
|
||||||
private ILabelProvider labelProvider;
|
private ILabelProvider labelProvider;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -187,12 +184,13 @@ public class LaunchBarListViewer extends StructuredViewer {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.labelProvider = labelProvider;
|
this.labelProvider = labelProvider;
|
||||||
setData(element);
|
setData(element);
|
||||||
|
setBackground(getParent().getBackground());
|
||||||
addPaintListener(new PaintListener() {
|
addPaintListener(new PaintListener() {
|
||||||
@Override
|
@Override
|
||||||
public void paintControl(PaintEvent e) {
|
public void paintControl(PaintEvent e) {
|
||||||
Point size = getSize();
|
Point size = getSize();
|
||||||
GC gc = e.gc;
|
GC gc = e.gc;
|
||||||
gc.setForeground(outlineColor);
|
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
|
||||||
gc.drawLine(0, size.y - 1, size.x, size.y - 1);
|
gc.drawLine(0, size.y - 1, size.x, size.y - 1);
|
||||||
if (label == null)
|
if (label == null)
|
||||||
lazyInit();
|
lazyInit();
|
||||||
|
@ -240,17 +238,17 @@ public class LaunchBarListViewer extends StructuredViewer {
|
||||||
addTraverseListener(listItemTraverseListener);
|
addTraverseListener(listItemTraverseListener);
|
||||||
addKeyListener(lisItemKeyListener);
|
addKeyListener(lisItemKeyListener);
|
||||||
|
|
||||||
setBackground(backgroundColor);
|
|
||||||
layout(true);
|
layout(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelected(boolean selected) {
|
public void setSelected(boolean selected) {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
setBackground(highlightColor);
|
setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
|
||||||
int idx = getIndex();
|
int idx = getIndex();
|
||||||
if (idx != selIndex) {
|
if (idx != selIndex) {
|
||||||
if (selIndex >= 0) {
|
if (selIndex >= 0) {
|
||||||
listItems[selIndex].setBackground(backgroundColor);
|
listItems[selIndex].setBackground(getParent().getBackground());
|
||||||
scrollBucket = Math.max(Math.min(scrollBucket + idx - selIndex, maxScrollBucket), 0);
|
scrollBucket = Math.max(Math.min(scrollBucket + idx - selIndex, maxScrollBucket), 0);
|
||||||
} else { // initially
|
} else { // initially
|
||||||
scrollBucket = Math.min(idx, maxScrollBucket);
|
scrollBucket = Math.min(idx, maxScrollBucket);
|
||||||
|
@ -258,7 +256,7 @@ public class LaunchBarListViewer extends StructuredViewer {
|
||||||
}
|
}
|
||||||
selIndex = idx;
|
selIndex = idx;
|
||||||
} else {
|
} else {
|
||||||
setBackground(backgroundColor);
|
setBackground(getParent().getBackground());
|
||||||
}
|
}
|
||||||
if (editButton != null) {
|
if (editButton != null) {
|
||||||
editButton.setSelected(selected);
|
editButton.setSelected(selected);
|
||||||
|
@ -340,10 +338,13 @@ public class LaunchBarListViewer extends StructuredViewer {
|
||||||
|
|
||||||
public LaunchBarListViewer(Composite parent) {
|
public LaunchBarListViewer(Composite parent) {
|
||||||
filterControl = new FilterControl(parent);
|
filterControl = new FilterControl(parent);
|
||||||
|
filterControl.setBackground(parent.getBackground());
|
||||||
listScrolled = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.NO_BACKGROUND);
|
listScrolled = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.NO_BACKGROUND);
|
||||||
listScrolled.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
listScrolled.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||||
listScrolled.setExpandHorizontal(true);
|
listScrolled.setExpandHorizontal(true);
|
||||||
|
listScrolled.setBackground(parent.getBackground());
|
||||||
listComposite = new Composite(listScrolled, SWT.NONE);
|
listComposite = new Composite(listScrolled, SWT.NONE);
|
||||||
|
listComposite.setBackground(parent.getBackground());
|
||||||
listScrolled.setContent(listComposite);
|
listScrolled.setContent(listComposite);
|
||||||
listComposite.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 0).create());
|
listComposite.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 0).create());
|
||||||
selIndex = -1;
|
selIndex = -1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue