mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-25 17:23:56 +02:00
launchbar: using native toolbar items for buttons
- tested on linux ubuntu 14.04 gtk 3.10, mac os x 10.10.3 and windows 7 - looks good. On linux it has extra spacing but this is consistent with other toolbar items. Change-Id: Iafeb1510ce83163f77a09f61c28a4f67d14ab0a1
This commit is contained in:
parent
3a6a685bdb
commit
9986e4d6f6
1 changed files with 14 additions and 10 deletions
|
@ -14,6 +14,7 @@ import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
|
|
||||||
import org.eclipse.debug.core.ILaunchMode;
|
import org.eclipse.debug.core.ILaunchMode;
|
||||||
|
|
||||||
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
||||||
import org.eclipse.launchbar.core.internal.LaunchBarManager;
|
import org.eclipse.launchbar.core.internal.LaunchBarManager;
|
||||||
import org.eclipse.launchbar.core.internal.LaunchBarManager.Listener;
|
import org.eclipse.launchbar.core.internal.LaunchBarManager.Listener;
|
||||||
|
@ -29,6 +30,8 @@ import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.ToolBar;
|
||||||
|
import org.eclipse.swt.widgets.ToolItem;
|
||||||
|
|
||||||
public class LaunchBarControl implements Listener {
|
public class LaunchBarControl implements Listener {
|
||||||
public static final String ID = "org.eclipse.launchbar"; //$NON-NLS-1$
|
public static final String ID = "org.eclipse.launchbar"; //$NON-NLS-1$
|
||||||
|
@ -48,9 +51,9 @@ public class LaunchBarControl implements Listener {
|
||||||
|
|
||||||
Composite container = new Composite(parent, SWT.NONE);
|
Composite container = new Composite(parent, SWT.NONE);
|
||||||
container.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
container.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
||||||
GridLayout layout = new GridLayout(7, false);
|
GridLayout layout = new GridLayout(5, false);
|
||||||
layout.marginHeight = 8;
|
layout.marginHeight = 2;
|
||||||
layout.marginWidth = 8;
|
layout.marginWidth = 2;
|
||||||
container.setLayout(layout);
|
container.setLayout(layout);
|
||||||
container.addDisposeListener(new DisposeListener() {
|
container.addDisposeListener(new DisposeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,9 +62,10 @@ public class LaunchBarControl implements Listener {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
createButton(container, Activator.IMG_BUTTON_BUILD, Messages.LaunchBarControl_Build, Activator.CMD_BUILD);
|
ToolBar toolBar = new ToolBar(container, SWT.FLAT);
|
||||||
createButton(container, Activator.IMG_BUTTON_LAUNCH, Messages.LaunchBarControl_Launch, Activator.CMD_LAUNCH);
|
createButton(toolBar, Activator.IMG_BUTTON_BUILD, Messages.LaunchBarControl_Build, Activator.CMD_BUILD);
|
||||||
createButton(container, Activator.IMG_BUTTON_STOP, Messages.LaunchBarControl_Stop, Activator.CMD_STOP);
|
createButton(toolBar, Activator.IMG_BUTTON_LAUNCH, Messages.LaunchBarControl_Launch, Activator.CMD_LAUNCH);
|
||||||
|
createButton(toolBar, Activator.IMG_BUTTON_STOP, Messages.LaunchBarControl_Stop, Activator.CMD_STOP);
|
||||||
|
|
||||||
modeSelector = new ModeSelector(container, SWT.NONE);
|
modeSelector = new ModeSelector(container, SWT.NONE);
|
||||||
modeSelector.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
modeSelector.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
||||||
|
@ -97,11 +101,11 @@ public class LaunchBarControl implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createButton(Composite parent, String imageName, String toolTipText, final String command) {
|
private void createButton(Composite parent, String imageName, String toolTipText, final String command) {
|
||||||
CButton button = new CButton(parent, SWT.NONE);
|
ToolItem button = new ToolItem((ToolBar) parent, SWT.FLAT);
|
||||||
button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
|
//button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
|
||||||
Image srcImage = Activator.getDefault().getImage(imageName);
|
Image srcImage = Activator.getDefault().getImage(imageName);
|
||||||
Image image = new Image(parent.getDisplay(), srcImage, SWT.IMAGE_COPY);
|
//Image image = new Image(parent.getDisplay(), srcImage, SWT.IMAGE_COPY);
|
||||||
button.setHotImage(image);
|
button.setImage(srcImage);
|
||||||
button.setToolTipText(toolTipText);
|
button.setToolTipText(toolTipText);
|
||||||
button.addSelectionListener(new SelectionAdapter() {
|
button.addSelectionListener(new SelectionAdapter() {
|
||||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue