Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabian Pfaff2017-04-06 16:13:15 -0400
committerMatthias Becker2018-02-13 04:05:13 -0500
commit0c046c2f7805a1239aa978cee2ab21b1577307ed (patch)
treef2bedae74701350bb1e7a21d0ceb815e01838c09 /org.eclipse.ui.workbench.texteditor
parent96e7c74fbe4889ee584a84c73a954c4756e5f268 (diff)
downloadeclipse.platform.text-0c046c2f7805a1239aa978cee2ab21b1577307ed.tar.gz
eclipse.platform.text-0c046c2f7805a1239aa978cee2ab21b1577307ed.tar.xz
eclipse.platform.text-0c046c2f7805a1239aa978cee2ab21b1577307ed.zip
bug 514043 - [Dark Theme] range indicator color should be
configurable via preferences Change-Id: I6586f77f3e200677afc251bfc84a42f6d6513887 Signed-off-by: Fabian Pfaff <fabian.pfaff@vogella.com>
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor')
-rw-r--r--org.eclipse.ui.workbench.texteditor/plugin.properties3
-rw-r--r--org.eclipse.ui.workbench.texteditor/plugin.xml9
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java71
3 files changed, 48 insertions, 35 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/plugin.properties b/org.eclipse.ui.workbench.texteditor/plugin.properties
index a87812f37..4f2184330 100644
--- a/org.eclipse.ui.workbench.texteditor/plugin.properties
+++ b/org.eclipse.ui.workbench.texteditor/plugin.properties
@@ -186,6 +186,9 @@ command.joinLines.name = Join Lines
command.openHyperlink.name= Open Hyperlink
command.openHyperlink.description= Opens the hyperlink at the caret location or opens a chooser if more than one hyperlink is available
+Color.rangeIndicator= Range indicator color
+Color.rangeIndicatorDesc= The color that is used for the ruler that marks the range of the current selected text block.
+
SpellingEngine= Spelling Engine
blockSelectionModeFont.label= Text Editor Block Selection Font
diff --git a/org.eclipse.ui.workbench.texteditor/plugin.xml b/org.eclipse.ui.workbench.texteditor/plugin.xml
index 558c966b3..d51f0cc2d 100644
--- a/org.eclipse.ui.workbench.texteditor/plugin.xml
+++ b/org.eclipse.ui.workbench.texteditor/plugin.xml
@@ -1302,6 +1302,15 @@
value="Monaco-regular-11">
</fontValue>
</fontDefinition>
+ <colorDefinition
+ categoryId="org.eclipse.ui.workbenchMisc"
+ id="org.eclipse.ui.editors.rangeIndicatorColor"
+ label="%Color.rangeIndicator"
+ value="COLOR_LIST_SELECTION">
+ <description>
+ %Color.rangeIndicatorDesc
+ </description>
+ </colorDefinition>
</extension>
<extension
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java
index 429f6df35..f6cda6685 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java
@@ -27,6 +27,8 @@ import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.jface.resource.JFaceResources;
+
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationPresentation;
@@ -41,10 +43,11 @@ import org.eclipse.jface.text.source.IAnnotationPresentation;
*/
public class DefaultRangeIndicator extends Annotation implements IAnnotationPresentation {
- /** The color palette data of this range indicator */
- private static PaletteData fgPaletteData;
+ private static final String RANGE_INDICATOR_COLOR= "org.eclipse.ui.editors.rangeIndicatorColor"; //$NON-NLS-1$
/** The image of this range indicator */
private Image fImage;
+ /** The color used to draw the range indicator during the last paint action. */
+ private Color fLastRangeIndicatorColor;
/**
* Creates a new range indicator.
@@ -54,7 +57,6 @@ public class DefaultRangeIndicator extends Annotation implements IAnnotationPres
@Override
public void paint(GC gc, Canvas canvas, Rectangle bounds) {
-
Point canvasSize= canvas.getSize();
int x= 0;
@@ -74,12 +76,15 @@ public class DefaultRangeIndicator extends Annotation implements IAnnotationPres
if (h <= 0)
return;
- Image image = getImage(canvas);
+ Color currentRangeIndicatorColor= JFaceResources.getColorRegistry().get(RANGE_INDICATOR_COLOR);
+ Image image= getImage(canvas, currentRangeIndicatorColor);
gc.drawImage(image, 0, 0, w, h, x, y, w, h);
- gc.setBackground(canvas.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
+ gc.setBackground(currentRangeIndicatorColor);
gc.fillRectangle(x, bounds.y, w, b);
gc.fillRectangle(x, bounds.y + bounds.height - b, w, b);
+
+ fLastRangeIndicatorColor= currentRangeIndicatorColor;
}
@Override
@@ -91,28 +96,30 @@ public class DefaultRangeIndicator extends Annotation implements IAnnotationPres
* Returns the image of this range indicator.
*
* @param control the control
+ * @param rangeIndicatorColor the color to be used to paint the range indicator
* @return an image
*/
- private Image getImage(Control control) {
+ private Image getImage(Control control, Color rangeIndicatorColor) {
if (fImage == null) {
- fImage= createImage(control.getDisplay(), control.getSize());
-
- control.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- if (fImage != null && !fImage.isDisposed()) {
- fImage.dispose();
- fImage= null;
- }
+ fImage= createImage(control.getDisplay(), control.getSize(), rangeIndicatorColor);
+
+ control.addDisposeListener(new DisposeListener() {
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ if (fImage != null && !fImage.isDisposed()) {
+ fImage.dispose();
+ fImage = null;
}
- });
+ }
+ });
} else {
Rectangle imageRectangle= fImage.getBounds();
Point controlSize= control.getSize();
- if (imageRectangle.width < controlSize.x || imageRectangle.height < controlSize.y) {
+ if (imageRectangle.width < controlSize.x || imageRectangle.height < controlSize.y
+ || !rangeIndicatorColor.equals(fLastRangeIndicatorColor)) {
fImage.dispose();
- fImage= createImage(control.getDisplay(), controlSize);
+ fImage= createImage(control.getDisplay(), controlSize, rangeIndicatorColor);
}
}
@@ -125,22 +132,24 @@ public class DefaultRangeIndicator extends Annotation implements IAnnotationPres
*
* @param display the display on which to create the image
* @param size the image size
+ * @param rangeIndicatorColor the color to be used to paint the range indicator
* @return a new image
- */
- private static Image createImage(Display display, Point size) {
+ */
+ private static Image createImage(Display display, Point size, Color rangeIndicatorColor) {
int width= size.x;
int height= size.y;
- if (fgPaletteData == null)
- fgPaletteData= createPalette(display);
- ImageData imageData= new ImageData(width, height, 1, fgPaletteData);
+ ImageData imageData= new ImageData(width, height, 1, createPalette(display, rangeIndicatorColor));
for (int y= 0; y < height; y++)
for (int x= 0; x < width; x++)
imageData.setPixel(x, y, (x + y) % 2);
+ imageData.transparentPixel= imageData.palette.getPixel(imageData.getRGBs()[1]);
+
+
return new Image(display, imageData);
}
@@ -148,19 +157,11 @@ public class DefaultRangeIndicator extends Annotation implements IAnnotationPres
* Creates and returns a new color palette data.
*
* @param display the display
+ * @param rangeIndicatorColor the color to be used to paint the range indicator
* @return the new color palette data
*/
- private static PaletteData createPalette(Display display) {
- Color c1;
- Color c2;
-
- c1= display.getSystemColor(SWT.COLOR_LIST_SELECTION);
- c2= display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
-
- RGB rgbs[]= new RGB[] {
- new RGB(c1.getRed(), c1.getGreen(), c1.getBlue()),
- new RGB(c2.getRed(), c2.getGreen(), c2.getBlue())};
-
- return new PaletteData(rgbs);
+ private static PaletteData createPalette(Display display, Color rangeIndicatorColor) {
+ return new PaletteData(new RGB[] { rangeIndicatorColor.getRGB(),
+ display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND).getRGB() });
}
}

Back to the top