Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageGcDrawer;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
Expand Down Expand Up @@ -333,10 +334,6 @@ private class PresentationLabelProvider extends LabelProvider implements IFontPr

private final HashMap<Color, Image> images = new HashMap<>();

private int imageSize = -1;

private int usableImageSize = -1;

private static final int REFRESH_INTERVAL_IN_MS = 300;

private final Runnable updateControlsAndRefreshTreeRunnable = () -> {
Expand Down Expand Up @@ -440,25 +437,20 @@ public Image getImage(Object element) {
c = display.getSystemColor(SWT.COLOR_WHITE);
foregroundColor = display.getSystemColor(DEFINITION_NOT_AVAIL_COLOR);
}
final Color gcBackgroundcolor = c;
final Color gcForegroundColor = foregroundColor;
Image image = images.get(c);
if (image == null) {
ensureImageSize();
image = new Image(display, imageSize, imageSize);

GC gc = new GC(image);
gc.setBackground(tree.getViewer().getControl().getBackground());
gc.setForeground(tree.getViewer().getControl().getBackground());
gc.drawRectangle(0, 0, imageSize - 1, imageSize - 1);

gc.setForeground(foregroundColor);
gc.setBackground(c);

int offset = (imageSize - usableImageSize) / 2;
gc.drawRectangle(offset, offset, usableImageSize - offset, usableImageSize - offset);
gc.fillRectangle(offset + 1, offset + 1, usableImageSize - offset - 1,
usableImageSize - offset - 1);
gc.dispose();

ImageGcDrawer imageGcDrawer = (gc, imageWidth, imageHeight) -> {
gc.setForeground(tree.getViewer().getControl().getBackground());
gc.drawRectangle(0, 0, imageWidth - 1, imageHeight - 1);

gc.setForeground(gcForegroundColor);
gc.setBackground(gcBackgroundcolor);
gc.fillRectangle(2, 2, 11, 11);
gc.drawRectangle(2, 2, 11, 11);
};
image = new Image(display, imageGcDrawer, 16, 16);
images.put(c, image);
}
return image;
Expand All @@ -470,13 +462,6 @@ public Image getImage(Object element) {
}
}

private void ensureImageSize() {
if (imageSize == -1) {
imageSize = tree.getViewer().getTree().getItemHeight();
usableImageSize = Math.max(1, imageSize - 4);
}
}

@Override
public String getText(Object element) {
if (element instanceof IHierarchalThemeElementDefinition themeElement) {
Expand Down
Loading