Skip to content

Commit 606ad8c

Browse files
Debugging: Draw background with offset
1 parent d173442 commit 606ad8c

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/TableOwnerDrawSupport.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ public void handleEvent(Event event) {
8585
measureItem(event);
8686
break;
8787
case SWT.EraseItem:
88-
// Remove foreground/background/selected to draw custom selection
89-
event.detail &= ~(SWT.FOREGROUND | SWT.BACKGROUND | SWT.SELECTED);
88+
ColumnViewerSelectionColorListener.drawSelection(event, event.display);
89+
event.detail&= ~SWT.FOREGROUND;
9090
break;
9191
case SWT.PaintItem:
9292
performPaint(event);
@@ -152,7 +152,7 @@ private void performPaint(Event event) {
152152

153153
if (isSelected) {
154154
// Draw custom selection using shared utility
155-
ColumnViewerSelectionColorListener.drawSelection(event, fSharedLayout.getDevice());
155+
// ColumnViewerSelectionColorListener.drawSelection(event, fSharedLayout.getDevice());
156156
} else if (!isSelected) {
157157
Color foreground= item.getForeground(index);
158158
gc.setForeground(foreground);

bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerSelectionColorListener.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,20 @@ public static void drawSelection(Event event, org.eclipse.swt.graphics.Device de
181181
width = scrollable.getClientArea().width;
182182
}
183183

184+
int x = 0;
185+
if (width > 50) {
186+
x = 50;
187+
}
188+
184189
// Fill selection rectangle
185-
gc.fillRectangle(0, event.y, width, event.height);
190+
// Use event.x and event.width to respect the bounds provided by SWT,
191+
// which on some platforms (like GTK/Linux) excludes the image area
192+
gc.fillRectangle(x, event.y, width, event.height);
186193

187194
// Remove SELECTED and BACKGROUND flags to prevent native drawing from overwriting our custom colors
188-
event.detail &= ~(SWT.SELECTED | SWT.BACKGROUND);
195+
// Note: On Linux/GTK, we must keep the SELECTED flag so that icons are still drawn
196+
// We only remove BACKGROUND to prevent the native background from overwriting our custom colors
197+
event.detail &= ~(SWT.SELECTED);
189198
}
190199

191200
/**
@@ -213,15 +222,15 @@ private void drawCustomSelection(Event event) {
213222
*/
214223
public static Color getSelectionColor(String key, org.eclipse.swt.graphics.Device device) {
215224
ColorRegistry registry = JFaceResources.getColorRegistry();
216-
225+
217226
// Check if workbench has registered themed colors
218227
if (registry.hasValueFor(key)) {
219228
return registry.get(key);
220229
}
221-
230+
222231
// Fallback to system colors when workbench is not available
223232
RGB systemColor;
224-
233+
225234
switch (key) {
226235
case COLOR_SELECTION_BG_FOCUS:
227236
// Use system highlight color (title bar background) for focused selection
@@ -244,7 +253,7 @@ public static Color getSelectionColor(String key, org.eclipse.swt.graphics.Devic
244253
systemColor = device.getSystemColor(SWT.COLOR_LIST_SELECTION).getRGB();
245254
break;
246255
}
247-
256+
248257
// Register the fallback color so we don't recompute it every time
249258
registry.put(key, systemColor);
250259
return registry.get(key);

0 commit comments

Comments
 (0)