diff options
author | Fabio Zadrozny | 2016-04-03 18:37:39 +0000 |
---|---|---|
committer | Dani Megert | 2016-04-25 12:11:09 +0000 |
commit | 1cd3bf94801aa5a2c23b161d86866cebd9de529b (patch) | |
tree | aa2c193a531665913070cb54ae76193178c184e0 | |
parent | f17b47543969005692dfd543520798bacd8754f5 (diff) | |
download | eclipse.platform.text-1cd3bf94801aa5a2c23b161d86866cebd9de529b.tar.gz eclipse.platform.text-1cd3bf94801aa5a2c23b161d86866cebd9de529b.tar.xz eclipse.platform.text-1cd3bf94801aa5a2c23b161d86866cebd9de529b.zip |
Bug 490951 - Overview ruler inverted when using themed scroll.Y20160428-1430Y20160428-1000I20160502-2000I20160501-2000I20160430-2000I20160429-2300I20160429-2000I20160428-0800I20160427-2000I20160427-1200I20160427-0800I20160427-0400I20160426-2330I20160426-2000I20160426-1615I20160426-1430I20160426-1245I20160426-1105I20160426-1045I20160426-1000I20160426-0800I20160426-0130I20160426-0030I20160425-2230I20160425-2000I20160425-1300
Makes the HeaderPainter invisible if there are no scroll bars.
Fixes the computation of positions in the overview ruler.
Change-Id: I5900ac1bf9e03069a23c971c1bf82f46ed3650f0
Signed-off-by: Fabio Zadrozny <fabiofz@gmail.com>
-rw-r--r-- | org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java | 18 | ||||
-rw-r--r-- | org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java | 28 |
2 files changed, 35 insertions, 11 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java index fca2c058d9f..1064840d8f2 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java @@ -347,7 +347,23 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler { writable= JFaceTextUtil.computeLineHeight(textWidget, 0, maxLines, maxLines); ScrollBar verticalBar= textWidget.getVerticalBar(); - thumbHeight= verticalBar != null ? Math.max(Math.min(bounds.height, verticalBar.getThumbBounds().height), 0) : 0; + if (verticalBar != null && !verticalBar.getVisible()) { + // Note: when the vertical bar is invisible, the thumbHeight is not reliable, + // so, we'll compute what would be the thumbHeight in case it was visible. + int max= verticalBar.getMaximum(); + double clientAreaHeight= textWidget.getClientArea().height; + if (max > clientAreaHeight) { + double percentage= clientAreaHeight / max; + thumbHeight= (int) (bounds.height * percentage); + } else { + thumbHeight= bounds.height; + } + if (thumbHeight < 0) { + thumbHeight= 0; + } + } else { + thumbHeight= verticalBar != null ? Math.max(Math.min(bounds.height, verticalBar.getThumbBounds().height), 0) : 0; + } int partialTopIndex= JFaceTextUtil.getPartialTopIndex(textWidget); int topLineHeight= textWidget.getLineHeight(textWidget.getOffsetAtLine(partialTopIndex)); diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java index 99eb3f5766b..cab98611df1 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java @@ -136,12 +136,12 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi width -= overviewRulerWidth + fGap; } + ScrollBar horizontalBar= textWidget.getHorizontalBar(); + final boolean hScrollVisible= horizontalBar != null && horizontalBar.getVisible(); if (fVerticalRuler != null && fIsVerticalRulerVisible) { int verticalRulerWidth= fVerticalRuler.getWidth(); final Control verticalRulerControl= fVerticalRuler.getControl(); int oldWidth= verticalRulerControl.getBounds().width; - ScrollBar horizontalBar= textWidget.getHorizontalBar(); - boolean hScrollVisible= horizontalBar != null && horizontalBar.isVisible(); int rulerHeight= clArea.height - topTrim; if (hScrollVisible) rulerHeight-= scrollbarHeight; @@ -163,16 +163,24 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi int[] arrowHeights= getVerticalScrollArrowHeights(textWidget, bottomOffset); int overviewRulerX= clArea.x + clArea.width - overviewRulerWidth - 1; - fOverviewRuler.getControl().setBounds(overviewRulerX, clArea.y + arrowHeights[0], overviewRulerWidth, clArea.height - arrowHeights[0] - arrowHeights[1] - scrollbarHeight); - + boolean noSpaceForHeader= (arrowHeights[0] <= 0 && arrowHeights[1] <= 0 && !hScrollVisible); Control headerControl= fOverviewRuler.getHeaderControl(); - boolean noArrows= arrowHeights[0] < 6 && arrowHeights[1] < 6; // need at least 6px to render the header control - if (noArrows || arrowHeights[0] < arrowHeights[1] && arrowHeights[0] < scrollbarHeight && arrowHeights[1] > scrollbarHeight) { - // // not enough space for header at top => move to bottom - int headerHeight= noArrows ? scrollbarHeight : arrowHeights[1]; - headerControl.setBounds(overviewRulerX, clArea.y + clArea.height - arrowHeights[1] - scrollbarHeight, overviewRulerWidth, headerHeight); + Control rulerControl= fOverviewRuler.getControl(); + if (noSpaceForHeader) { + // If we don't have space to draw because we don't have arrows and the horizontal scroll is invisible, + // use the whole space for the ruler and leave the headerControl without any space (will actually be invisible). + rulerControl.setBounds(overviewRulerX, clArea.y, overviewRulerWidth, clArea.height); + headerControl.setBounds(0, 0, 0, 0); } else { - headerControl.setBounds(overviewRulerX, clArea.y, overviewRulerWidth, arrowHeights[0]); + boolean smallArrows= arrowHeights[0] < 6 && arrowHeights[1] < 6; // need at least 6px to render the header control + rulerControl.setBounds(overviewRulerX, clArea.y + arrowHeights[0], overviewRulerWidth, clArea.height - arrowHeights[0] - arrowHeights[1] - scrollbarHeight); + if (smallArrows || arrowHeights[0] < arrowHeights[1] && arrowHeights[0] < scrollbarHeight && arrowHeights[1] > scrollbarHeight) { + // not enough space for header at top => move to bottom + int headerHeight= smallArrows ? scrollbarHeight : arrowHeights[1]; + headerControl.setBounds(overviewRulerX, clArea.y + clArea.height - arrowHeights[1] - scrollbarHeight, overviewRulerWidth, headerHeight); + } else { + headerControl.setBounds(overviewRulerX, clArea.y, overviewRulerWidth, arrowHeights[0]); + } } headerControl.redraw(); } |