Skip to content

Commit

Permalink
[GEF] Workaround line width not always correct on Windows hi-dpi
Browse files Browse the repository at this point in the history
- If a figure is drawn with line width 1 and then some other part with line width 2 it might still render with line width 1
- This was manifesting in connection line widths and Plateau icon
  • Loading branch information
Phillipus committed Aug 20, 2023
1 parent 6191447 commit a2d17a3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions org.eclipse.draw2d/src/org/eclipse/draw2d/SWTGraphics.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* <P>
* WARNING: This class is not intended to be subclassed.
*/
@SuppressWarnings({"rawtypes", "unchecked"})
@SuppressWarnings({"rawtypes", "unchecked", "restriction"})
public class SWTGraphics extends Graphics {

private double scale = 1.0;
Expand Down Expand Up @@ -317,7 +317,13 @@ protected final void checkPaint() {

LineAttributes lineAttributes = currentState.lineAttributes;
if (!appliedState.lineAttributes.equals(lineAttributes)) {
if (getAdvanced()) {
/*
* Workaround Windows Hi-DPI where setting line width to 1 and then setting it to 2 doesn't always take effect.
* And other drawing artefacts to do with line width.
* So don't use LineAttributes.
*/
// if (getAdvanced()) {
if (getAdvanced() && !("win32".equals(SWT.getPlatform()) && org.eclipse.swt.internal.DPIUtil.getDeviceZoom() > 100)) { //$NON-NLS-1$
gc.setLineAttributes(lineAttributes);
} else {
gc.setLineWidth((int) lineAttributes.width);
Expand Down Expand Up @@ -1286,7 +1292,6 @@ public void setLineAttributes(LineAttributes lineAttributes) {
setLineAttributes(lineAttributes, true);
}

@SuppressWarnings("restriction")
public void setLineAttributes(LineAttributes lineAttributes, boolean adjustForWindowsHiDPI) {
copyLineAttributes(currentState.lineAttributes, lineAttributes);

Expand Down Expand Up @@ -1333,7 +1338,6 @@ public void setLineDash(float[] value) {
setLineDash(value, true);
}

@SuppressWarnings("restriction")
public void setLineDash(float[] value, boolean adjustForWindowsHiDPI) {
if (value != null) {
// validate dash values
Expand Down

0 comments on commit a2d17a3

Please sign in to comment.