mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-23 08:13:50 +02:00
Improve dark theme on Windows
Switch to CTabFolder/CTabItem for newui. This changeset is a breaking change but on a review of existing adopters/extenders of CDT no one is actually accessing these fields. Change-Id: Ic1ef0f242c1d2932726f3a6d4c9df9558312764a Signed-off-by: Torbjörn Svensson <torbjorn.svensson@st.com> Also-by: Jonah Graham <jonah@kichwacoders.com>
This commit is contained in:
parent
93fbce4f2c
commit
3af7d50c4a
1 changed files with 20 additions and 29 deletions
|
@ -74,6 +74,8 @@ import org.eclipse.jface.resource.ResourceLocator;
|
||||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.custom.CTabFolder;
|
||||||
|
import org.eclipse.swt.custom.CTabItem;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
@ -92,8 +94,6 @@ import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Listener;
|
import org.eclipse.swt.widgets.Listener;
|
||||||
import org.eclipse.swt.widgets.MessageBox;
|
import org.eclipse.swt.widgets.MessageBox;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.swt.widgets.TabFolder;
|
|
||||||
import org.eclipse.swt.widgets.TabItem;
|
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
import org.eclipse.ui.IWorkbenchPartReference;
|
import org.eclipse.ui.IWorkbenchPartReference;
|
||||||
|
@ -199,16 +199,8 @@ public abstract class AbstractPage extends PropertyPage implements IPreferencePa
|
||||||
protected boolean isFile = false;
|
protected boolean isFile = false;
|
||||||
|
|
||||||
// tabs
|
// tabs
|
||||||
/**
|
private CTabFolder folder;
|
||||||
* @deprecated This field was never meant to be API. This field will be made private.
|
private List<InternalTab> itabs = new ArrayList<>();
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
protected TabFolder folder;
|
|
||||||
/**
|
|
||||||
* @deprecated This field was never meant to be API. This field will be made private.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
protected ArrayList<InternalTab> itabs = new ArrayList<>();
|
|
||||||
/**
|
/**
|
||||||
* @deprecated This field was never meant to be API. This field will be made private.
|
* @deprecated This field was never meant to be API. This field will be made private.
|
||||||
*/
|
*/
|
||||||
|
@ -217,11 +209,7 @@ public abstract class AbstractPage extends PropertyPage implements IPreferencePa
|
||||||
|
|
||||||
private static boolean isNewOpening = true;
|
private static boolean isNewOpening = true;
|
||||||
|
|
||||||
/**
|
private class InternalTab {
|
||||||
* @deprecated This class was never meant to be API. This class will be made private.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
protected class InternalTab {
|
|
||||||
Composite comp;
|
Composite comp;
|
||||||
String text;
|
String text;
|
||||||
String tip;
|
String tip;
|
||||||
|
@ -236,9 +224,12 @@ public abstract class AbstractPage extends PropertyPage implements IPreferencePa
|
||||||
tip = _tip;
|
tip = _tip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TabItem createOn(TabFolder f) {
|
/**
|
||||||
|
* @since 7.3
|
||||||
|
*/
|
||||||
|
public CTabItem createOn(CTabFolder f) {
|
||||||
if (tab.canBeVisible()) {
|
if (tab.canBeVisible()) {
|
||||||
TabItem ti = new TabItem(f, SWT.NONE);
|
CTabItem ti = new CTabItem(f, SWT.NONE);
|
||||||
ti.setText(text);
|
ti.setText(text);
|
||||||
if (tip != null)
|
if (tip != null)
|
||||||
ti.setToolTipText(tip);
|
ti.setToolTipText(tip);
|
||||||
|
@ -398,7 +389,7 @@ public abstract class AbstractPage extends PropertyPage implements IPreferencePa
|
||||||
itabs.clear();
|
itabs.clear();
|
||||||
if (!isSingle()) {
|
if (!isSingle()) {
|
||||||
parentComposite.setLayout(new FillLayout());
|
parentComposite.setLayout(new FillLayout());
|
||||||
folder = new TabFolder(parentComposite, SWT.NONE);
|
folder = new CTabFolder(parentComposite, SWT.NONE);
|
||||||
// folder.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
|
// folder.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
|
||||||
}
|
}
|
||||||
loadExtensionsSynchronized(parentComposite);
|
loadExtensionsSynchronized(parentComposite);
|
||||||
|
@ -409,7 +400,7 @@ public abstract class AbstractPage extends PropertyPage implements IPreferencePa
|
||||||
folder.addSelectionListener(new SelectionAdapter() {
|
folder.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
|
public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
|
||||||
if (folder.getSelection().length > 0) {
|
if (folder.getSelection() != null) {
|
||||||
updateSelectedTab();
|
updateSelectedTab();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -418,9 +409,9 @@ public abstract class AbstractPage extends PropertyPage implements IPreferencePa
|
||||||
int selectedTab = 0;
|
int selectedTab = 0;
|
||||||
Class<? extends ICPropertyTab> recentTab = recentTabs.get(getClass());
|
Class<? extends ICPropertyTab> recentTab = recentTabs.get(getClass());
|
||||||
if (recentTab != null) {
|
if (recentTab != null) {
|
||||||
TabItem[] tabs = folder.getItems();
|
CTabItem[] tabs = folder.getItems();
|
||||||
for (int i = 0; i < tabs.length; i++) {
|
for (int i = 0; i < tabs.length; i++) {
|
||||||
TabItem control = tabs[i];
|
CTabItem control = tabs[i];
|
||||||
if (recentTab.isInstance(control.getData())) {
|
if (recentTab.isInstance(control.getData())) {
|
||||||
selectedTab = i;
|
selectedTab = i;
|
||||||
break;
|
break;
|
||||||
|
@ -434,7 +425,7 @@ public abstract class AbstractPage extends PropertyPage implements IPreferencePa
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSelectedTab() {
|
private void updateSelectedTab() {
|
||||||
ICPropertyTab newTab = (ICPropertyTab) folder.getSelection()[0].getData();
|
ICPropertyTab newTab = (ICPropertyTab) folder.getSelection().getData();
|
||||||
if (newTab != null && currentTab != newTab) {
|
if (newTab != null && currentTab != newTab) {
|
||||||
recentTabs.put(getClass(), newTab.getClass());
|
recentTabs.put(getClass(), newTab.getClass());
|
||||||
if (currentTab != null)
|
if (currentTab != null)
|
||||||
|
@ -1287,13 +1278,13 @@ public abstract class AbstractPage extends PropertyPage implements IPreferencePa
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean willAdd = false;
|
boolean willAdd = false;
|
||||||
TabItem[] ts = folder.getItems();
|
CTabItem[] ts = folder.getItems();
|
||||||
int x = folder.getSelectionIndex();
|
int x = folder.getSelectionIndex();
|
||||||
String currHeader = (x == -1) ? null : ts[x].getText();
|
String currHeader = (x == -1) ? null : ts[x].getText();
|
||||||
for (int i = 0; i < itabs.size(); i++) {
|
for (int i = 0; i < itabs.size(); i++) {
|
||||||
InternalTab itab = itabs.get(i);
|
InternalTab itab = itabs.get(i);
|
||||||
TabItem ti = null;
|
CTabItem ti = null;
|
||||||
for (TabItem element2 : ts) {
|
for (CTabItem element2 : ts) {
|
||||||
if (element2.isDisposed())
|
if (element2.isDisposed())
|
||||||
continue;
|
continue;
|
||||||
if (element2.getData() == itab.tab) {
|
if (element2.getData() == itab.tab) {
|
||||||
|
@ -1317,11 +1308,11 @@ public abstract class AbstractPage extends PropertyPage implements IPreferencePa
|
||||||
for (int j = 0; j < ts.length; j++)
|
for (int j = 0; j < ts.length; j++)
|
||||||
if (ts[j] != null && !ts[j].isDisposed())
|
if (ts[j] != null && !ts[j].isDisposed())
|
||||||
ts[j].dispose();
|
ts[j].dispose();
|
||||||
TabItem ti = null;
|
CTabItem ti = null;
|
||||||
for (int i = 0; i < itabs.size(); i++) {
|
for (int i = 0; i < itabs.size(); i++) {
|
||||||
InternalTab itab = itabs.get(i);
|
InternalTab itab = itabs.get(i);
|
||||||
if (itab.tab.canBeVisible()) {
|
if (itab.tab.canBeVisible()) {
|
||||||
TabItem currTI = itab.createOn(folder);
|
CTabItem currTI = itab.createOn(folder);
|
||||||
if (currHeader != null && currHeader.equals(itab.text))
|
if (currHeader != null && currHeader.equals(itab.text))
|
||||||
ti = currTI;
|
ti = currTI;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue