Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 180415 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/themes/LightColorSelectionFactory.java (-35 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.ui.internal.themes;
13
14
import org.eclipse.swt.graphics.RGB;
15
16
/**
17
 * LightColorSelectionFactory is a factory that returns the lighter of two
18
 * {@link RGB} instances.
19
 * 
20
 * @since 3.3
21
 * 
22
 */
23
24
public class LightColorSelectionFactory extends ColorSelectionFactory {
25
26
	/* (non-Javadoc)
27
	 * @see org.eclipse.ui.internal.themes.ColorSelectionFactory#compare(org.eclipse.swt.graphics.RGB, org.eclipse.swt.graphics.RGB)
28
	 */
29
	RGB compare(RGB rgb1, RGB rgb2) {
30
		if (difference(rgb1, rgb2) > 0)
31
			return rgb1;
32
		return rgb2;
33
	}
34
35
}
(-)Eclipse UI/org/eclipse/ui/internal/themes/DarkColorSelectionFactory.java (-38 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.ui.internal.themes;
13
14
import org.eclipse.swt.graphics.RGB;
15
16
/**
17
 * DarkColorSelectionFactory is a factory that returns the darker of two
18
 * {@link RGB} instances.
19
 * 
20
 * @since 3.3
21
 * 
22
 */
23
24
public class DarkColorSelectionFactory extends ColorSelectionFactory {
25
26
	/*
27
	 * (non-Javadoc)
28
	 * 
29
	 * @see org.eclipse.ui.internal.themes.ColorSelectionFactory#compare(org.eclipse.swt.graphics.RGB,
30
	 *      org.eclipse.swt.graphics.RGB)
31
	 */
32
	RGB compare(RGB rgb1, RGB rgb2) {
33
		if (difference(rgb1, rgb2) > 0)
34
			return rgb2;
35
		return rgb1;
36
	}
37
38
}
(-)Eclipse (+131 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.ui.internal.themes;
13
14
import java.util.Hashtable;
15
16
import org.eclipse.core.runtime.IConfigurationElement;
17
import org.eclipse.core.runtime.IExecutableExtension;
18
import org.eclipse.swt.graphics.RGB;
19
import org.eclipse.ui.themes.ColorUtil;
20
import org.eclipse.ui.themes.IColorFactory;
21
22
/**
23
 * ColorSelectionFactory is the abstract superclass of factories that compare
24
 * two colors.
25
 * 
26
 * @since 3.3
27
 * 
28
 */
29
public class KelvinColorFactory implements IColorFactory,
30
		IExecutableExtension {
31
32
	protected static final RGB white = new RGB(255, 255, 255);
33
	
34
	String base;
35
	String definitionId; 
36
37
	/**
38
	 * This executable extension requires parameters to be explicitly declared
39
	 * via the second method described in the <code>IExecutableExtension</code>
40
	 * documentation. The following parameters are parsed:
41
	 * <code>base</code>, describes the base color to produce all other colours from.
42
	 * This value may either be an RGB triple or an SWT constant.
43
	 * <code>definitionId</code>, describes the id of color we are looking for, one of
44
	 * "org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"
45
	 * "org.eclipse.ui.workbench.ACTIVE_TAB_BG_END"
46
	 * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement,
47
	 *      java.lang.String, java.lang.Object)
48
	 */
49
	public void setInitializationData(IConfigurationElement config,
50
			String propertyName, Object data) {
51
52
		if (data instanceof Hashtable) {
53
			Hashtable table = (Hashtable) data;
54
			base = (String) table.get("base"); //$NON-NLS-1$
55
			definitionId = (String) table.get("definitionId"); //$NON-NLS-1$
56
		}
57
	}
58
59
	/* 
60
	 * Return the number of RGB values in test that are
61
	 * equal to or between lower and upper.
62
	 */
63
	protected int valuesInRange(RGB test, int lower, int upper) {
64
		int hits = 0;
65
		if(test.red >= lower && test.red <= upper) hits++;
66
		if(test.blue >= lower && test.blue <= upper) hits++;
67
		if(test.green >= lower && test.green <= upper) hits++;
68
69
		return hits;
70
	}
71
	
72
	/*
73
	 * Return the RGB value for the bottom tab color
74
	 * based on a blend of white and sample color
75
	 */
76
	private RGB getLightenedColor(RGB sample) {
77
		//Group 1
78
		if(valuesInRange(sample, 180, 255) >= 2)
79
			return sample;
80
		
81
		//Group 2
82
		if(valuesInRange(sample, 100, 179) >= 2)
83
			return ColorUtil.blend(white, sample, 30);
84
		
85
		//Group 3
86
		if(valuesInRange(sample, 0, 99) >= 2)
87
			return ColorUtil.blend(white, sample, 60);
88
		
89
		//Group 4
90
		return ColorUtil.blend(white, sample, 30);
91
	}
92
	
93
	/*
94
	 * Return the Start (top of tab) color as an RGB
95
	 */
96
	private RGB createStartColor() {
97
		if (base == null) 
98
			return new RGB(0, 0, 0);
99
		RGB base = createEndColor();
100
		return ColorUtil.blend(white, base, 75);
101
	}
102
103
	/*
104
	 * Return the End (top of tab) color as an RGB
105
	 */
106
	public RGB createEndColor() {
107
		if (base == null) 
108
			return new RGB(0, 0, 0);
109
		return getLightenedColor(
110
				ColorUtil.getColorValue(base));
111
	}	
112
113
	/*
114
	 * (non-Javadoc)
115
	 * 
116
	 * @see org.eclipse.ui.themes.IColorFactory#createColor()
117
	 */
118
	public RGB createColor() {
119
		//should have base, otherwise error in the xml
120
		if (base == null) 
121
			return white;
122
		
123
		if (definitionId.equals("org.eclipse.ui.workbench.ACTIVE_TAB_BG_START")) //$NON-NLS-1$
124
			return createStartColor();
125
		if (definitionId.equals("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END")) //$NON-NLS-1$
126
			return createEndColor();
127
		
128
		//should be one of start or end, otherwise error in the xml
129
		return white;
130
	}
131
}
(-)plugin.xml (-15 / +11 lines)
Lines 1189-1195 Link Here
1189
      <colorDefinition
1189
      <colorDefinition
1190
            label="%Color.activeTabText"
1190
            label="%Color.activeTabText"
1191
            categoryId="org.eclipse.ui.presentation.default"
1191
            categoryId="org.eclipse.ui.presentation.default"
1192
            value="COLOR_TITLE_FOREGROUND"
1192
            value="COLOR_WIDGET_FOREGROUND"
1193
            id="org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR">
1193
            id="org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR">
1194
         <description>
1194
         <description>
1195
            %Color.activeTabTextDesc
1195
            %Color.activeTabTextDesc
Lines 1212-1226 Link Here
1212
               value="COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT">
1212
               value="COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT">
1213
         </colorValue>
1213
         </colorValue>
1214
         <colorFactory
1214
         <colorFactory
1215
               class="org.eclipse.ui.internal.themes.DarkColorSelectionFactory"
1215
               class="org.eclipse.ui.internal.themes.KelvinColorFactory"
1216
               plugin="org.eclipse.ui">
1216
               plugin="org.eclipse.ui">
1217
          <parameter
1217
          <parameter
1218
                  name="color1"
1218
                  name="base" value="COLOR_TITLE_BACKGROUND">
1219
                  value="COLOR_TITLE_BACKGROUND_GRADIENT">
1220
          </parameter>
1219
          </parameter>
1221
          <parameter
1220
          <parameter
1222
                  name="color2"
1221
                  name="definitionId" value="org.eclipse.ui.workbench.ACTIVE_TAB_BG_END">
1223
                  value="COLOR_TITLE_BACKGROUND">
1224
          </parameter>
1222
          </parameter>
1225
         </colorFactory>
1223
         </colorFactory>
1226
      </colorDefinition>
1224
      </colorDefinition>
Lines 1236-1251 Link Here
1236
               value="COLOR_TITLE_INACTIVE_BACKGROUND">
1234
               value="COLOR_TITLE_INACTIVE_BACKGROUND">
1237
         </colorValue>
1235
         </colorValue>
1238
         <colorFactory
1236
         <colorFactory
1239
               class="org.eclipse.ui.internal.themes.LightColorSelectionFactory"
1237
               class="org.eclipse.ui.internal.themes.KelvinColorFactory"
1240
               plugin="org.eclipse.ui">
1238
               plugin="org.eclipse.ui">
1241
            <parameter
1239
          <parameter
1242
                  name="color1"
1240
                  name="base" value="COLOR_TITLE_BACKGROUND">
1243
                  value="COLOR_TITLE_BACKGROUND_GRADIENT">
1241
          </parameter>
1244
            </parameter>
1242
          <parameter
1245
            <parameter
1243
                  name="definitionId" value="org.eclipse.ui.workbench.ACTIVE_TAB_BG_START">
1246
                  name="color2"
1244
          </parameter>
1247
                  value="COLOR_TITLE_BACKGROUND">
1248
            </parameter>
1249
         </colorFactory>
1245
         </colorFactory>
1250
      </colorDefinition>
1246
      </colorDefinition>
1251
<!-- Active (Nofocus) Tab Colors -->
1247
<!-- Active (Nofocus) Tab Colors -->

Return to bug 180415