Skip to content

Commit 77879f3

Browse files
arunjose696HeikoKlare
authored andcommitted
Replacing custom logic in Help>Search results to disable icons, with Image constructor call
For the results displayed in Help>Search, Previously, icons for disabled search hits were created by custom pixel-level manipulation using ImageData. This approach, at high zoom levels (e.g., 225%), causes icons to appear slightly distorted, as scaling of ImageData is a destructive operation. This logic has now been replaced by a call to the Image constructor with the flag set to disabled.
1 parent dc7434e commit 77879f3

File tree

1 file changed

+3
-37
lines changed

1 file changed

+3
-37
lines changed

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineResultSection.java

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.eclipse.swt.SWT;
3535
import org.eclipse.swt.custom.BusyIndicator;
3636
import org.eclipse.swt.graphics.Image;
37-
import org.eclipse.swt.graphics.ImageData;
3837
import org.eclipse.swt.layout.GridData;
3938
import org.eclipse.swt.layout.GridLayout;
4039
import org.eclipse.swt.widgets.Composite;
@@ -158,9 +157,9 @@ private void createFormText(Composite parent, FormToolkit toolkit) {
158157
searchResults.setImage(ISharedImages.IMG_OBJS_ERROR_TSK, PlatformUI.getWorkbench().getSharedImages()
159158
.getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
160159
searchResults.setImage(desc.getId(), desc.getIconImage());
161-
Image grayedImage = getGrayedImage(desc.getIconImage());
162-
searchResults.setImage(KEY_PREFIX_GRAYED + desc.getId(), grayedImage);
163-
searchResults.addDisposeListener(e -> grayedImage.dispose());
160+
Image disabledImage = new Image(desc.getIconImage().getDevice(), desc.getIconImage(), SWT.IMAGE_GRAY);
161+
searchResults.setImage(KEY_PREFIX_GRAYED + desc.getId(), disabledImage);
162+
searchResults.addDisposeListener(e -> disabledImage.dispose());
164163
searchResults.addHyperlinkListener(new IHyperlinkListener() {
165164

166165
@Override
@@ -309,39 +308,6 @@ private ISearchEngineResult[] getResults() {
309308
return results;
310309
}
311310

312-
/**
313-
* Returns a copy of the given image but grayed and half transparent.
314-
* This gives the icon a grayed/disabled look.
315-
*
316-
* @param image the image to gray
317-
* @return the grayed image
318-
*/
319-
private Image getGrayedImage(Image image) {
320-
// first gray the image
321-
Image temp = new Image(image.getDevice(), image, SWT.IMAGE_GRAY);
322-
// then add alpha to blend it 50/50 with the background
323-
ImageData data = temp.getImageData();
324-
ImageData maskData = data.getTransparencyMask();
325-
if (maskData != null) {
326-
for (int y=0;y<maskData.height;++y) {
327-
for (int x=0;x<maskData.width;++x) {
328-
if (maskData.getPixel(x, y) == 0) {
329-
// masked; set to transparent
330-
data.setAlpha(x, y, 0);
331-
}
332-
else {
333-
// not masked; set to translucent
334-
data.setAlpha(x, y, 128);
335-
}
336-
}
337-
}
338-
data.maskData = null;
339-
}
340-
Image grayed = new Image(image.getDevice(), data);
341-
temp.dispose();
342-
return grayed;
343-
}
344-
345311
void updateResults(boolean reflow) {
346312
ISearchEngineResult[] results = getResults();
347313
updateSectionTitle(results.length);

0 commit comments

Comments
 (0)