Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2016-10-18 16:11:47 -0400
committerDani Megert2017-05-15 09:29:00 -0400
commit31a9bc3cb873b5f8396a73ddf5b8b7eeed1e7c5a (patch)
treeef25142bc290a0338f971e9ef55934ef960e5ace
parentf644806f15ee3e28a293a875b2673014d4ff26bd (diff)
downloadeclipse.platform.text-31a9bc3cb873b5f8396a73ddf5b8b7eeed1e7c5a.tar.gz
eclipse.platform.text-31a9bc3cb873b5f8396a73ddf5b8b7eeed1e7c5a.tar.xz
eclipse.platform.text-31a9bc3cb873b5f8396a73ddf5b8b7eeed1e7c5a.zip
Bug 506167 - Print margin position is not updated when using
pinch-to-zoom gesture Change-Id: Ie8d7cefab791f143c2773582389be6b12a4be7cb Signed-off-by: Till Brychcy <register.eclipse@brychcy.de>
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java
index 1d667d8d4..2da2866ae 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java
@@ -16,6 +16,7 @@ import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
@@ -45,7 +46,8 @@ public class MarginPainter implements IPainter, PaintListener {
/** The line width of the line to be painted, default value <code>1</code> */
private int fLineWidth= 0; // NOTE: 0 means width is 1 but with optimized performance
/** The cached x-offset of the <code>fMarginWidth</code> for the current font */
- private int fCachedWidgetX= -1;
+ private int fCachedWidgetX= -1;
+ private Font fFontForCachedWidgetX;
/** The active state of this painter */
private boolean fIsActive= false;
@@ -112,6 +114,7 @@ public class MarginPainter implements IPainter, PaintListener {
*/
private void computeWidgetX() {
GC gc= new GC(fTextWidget);
+ fFontForCachedWidgetX= fTextWidget.getFont();
int pixels= gc.getFontMetrics().getAverageCharWidth();
gc.dispose();
@@ -149,6 +152,9 @@ public class MarginPainter implements IPainter, PaintListener {
@Override
public void paintControl(PaintEvent e) {
if (fTextWidget != null) {
+ if (fFontForCachedWidgetX != fTextWidget.getFont()) {
+ computeWidgetX();
+ }
int x= fCachedWidgetX - fTextWidget.getHorizontalPixel();
if (x >= 0) {
Rectangle area= fTextWidget.getClientArea();

Back to the top