Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 186622 Details for
Bug 163769
[rulers] overview ruler annotation arming not correct
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Fix Annotation drawing 2
patch2.txt (text/plain), 7.48 KB, created by
Markus Keller
on 2011-01-12 08:28:20 EST
(
hide
)
Description:
Fix Annotation drawing 2
Filename:
MIME Type:
Creator:
Markus Keller
Created:
2011-01-12 08:28:20 EST
Size:
7.48 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jface.text >Index: src/org/eclipse/jface/text/source/OverviewRuler.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java,v >retrieving revision 1.77 >diff -u -r1.77 OverviewRuler.java >--- src/org/eclipse/jface/text/source/OverviewRuler.java 10 Jan 2011 19:14:14 -0000 1.77 >+++ src/org/eclipse/jface/text/source/OverviewRuler.java 12 Jan 2011 13:26:39 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -39,6 +39,7 @@ > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.ScrollBar; > > import org.eclipse.jface.util.Util; > >@@ -307,6 +308,8 @@ > } > } > >+ private static final boolean DEBUG= false; >+ > /** > * <code>true</code> if we're on a Mac, where "new GC(canvas)" is expensive. > * @see <a href="https://bugs.eclipse.org/298936">bug 298936</a> >@@ -637,6 +640,11 @@ > > Rectangle r= new Rectangle(0, 0, 0, 0); > int yy, hh= ANNOTATION_HEIGHT; >+ >+ /** height of the vertical thumb, or -1 if values have not been calculated yet */ >+ int thumbHeight= -1; >+ int visibleLines= 1; >+ int invisibleLines= 0; > > IDocument document= fTextViewer.getDocument(); > StyledText textWidget= fTextViewer.getTextWidget(); >@@ -650,9 +658,10 @@ > int maxLines= textWidget.getLineCount(); > Point size= fCanvas.getSize(); > int writable= JFaceTextUtil.computeLineHeight(textWidget, 0, maxLines, maxLines); >+ boolean noScrollThumb= false; > if (size.y > writable) >- size.y= Math.max(writable - fHeader.getSize().y, 0); >- >+ noScrollThumb= true; >+ > for (Iterator iterator= fAnnotationsSortedByLayer.iterator(); iterator.hasNext();) { > Object annotationType= iterator.next(); > >@@ -706,7 +715,41 @@ > > int startOffset= visible != null ? annotationOffset - visible.getOffset() : widgetRegion.getOffset(); > int startLine= textWidget.getLineAtOffset(startOffset); >- yy= Math.min((startLine * size.y) / maxLines, size.y - hh); >+ >+ if (thumbHeight == -1) { >+ ScrollBar verticalBar= textWidget.getVerticalBar(); >+ thumbHeight= verticalBar != null ? verticalBar.getThumbBounds().height : 0; >+ >+ // XXX: To avoid jumping when lines become visible/invisible, visibleLines should ideally be computed as double, not int >+ int topIndex= textWidget.getLineIndex(0); >+ int partialBottomIndex= JFaceTextUtil.getPartialBottomIndex(textWidget); >+ visibleLines= partialBottomIndex - topIndex + 1; >+ invisibleLines= maxLines - visibleLines; >+ if (DEBUG) >+ System.out.println("vis: " + visibleLines + ", invis: " + invisibleLines); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ // Hint: (thumbHeight / 2) / (visibleLines / 2) == thumbHeight / visibleLines; >+ // Hint2: To avoid rounding errors with integer arithmetic, we have to do the division by 2 only at the very end. >+ >+ if (noScrollThumb || invisibleLines <= 0) { // relative positions don't make sense: use >+ int offset= fCanvas.getLocation().y; >+ yy = Math.max(0, (2 * startLine + 1) * writable / (maxLines * 2) - offset); >+ >+ } else if (startLine + 1 < visibleLines / 2) { // before middle of first page: map to area from 0 to thumbHeight/2 >+ yy= startLine * thumbHeight / visibleLines; >+ >+ } else if (maxLines - visibleLines / 2 <= startLine) { // after middle of last page: map to area from size.y-1 - thumbHeight/2 to size.y-1 >+ yy= (2 * (size.y-1) - thumbHeight + 2 * (startLine - (maxLines - visibleLines / 2) + 1) * thumbHeight / visibleLines) / 2; >+ >+ } else { >+ yy= (thumbHeight + 2 * (startLine + 1 - visibleLines / 2) * (size.y - thumbHeight) / invisibleLines) / 2; >+ } >+ >+ // center should be at the calculated position: >+ yy-= hh / 2; >+ // cap at start/end: >+ yy= Math.max(0, Math.min(yy, size.y-1 - hh)); > > if (!areColorsComputed) { > fill= getFillColor(annotationType, style[t] == FilterIterator.TEMPORARY); >@@ -735,6 +778,21 @@ > } > } > } >+ >+ if (DEBUG) { >+ // draw debugging guides (boundaries): >+ gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_DARK_MAGENTA)); >+ yy= thumbHeight / 2; >+ gc.drawLine(0, yy, size.x/2, yy); >+ yy= size.y - thumbHeight / 2; >+ gc.drawLine(0, yy, size.x/2, yy); >+ >+ gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_BLUE)); >+ yy= 0; >+ gc.drawLine(0, yy, size.x/2, yy); >+ yy= size.y - 1; >+ gc.drawLine(0, yy, size.x/2, yy); >+ } > } > > /* >Index: src/org/eclipse/jface/text/source/SourceViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java,v >retrieving revision 1.94 >diff -u -r1.94 SourceViewer.java >--- src/org/eclipse/jface/text/source/SourceViewer.java 9 Aug 2010 16:35:25 -0000 1.94 >+++ src/org/eclipse/jface/text/source/SourceViewer.java 12 Jan 2011 13:26:39 -0000 >@@ -157,6 +157,32 @@ > int bottomOffset= clArea.y + clArea.height - scrollbarHeight; > int[] arrowHeights= getVerticalScrollArrowHeights(textWidget, bottomOffset); > >+ /* >+ * Goal: Center of thumb should align with center of line mark in overview ruler. >+ */ >+ >+// //TODO: should move this into the painter in OverviewRuler >+// >+// ScrollBar verticalBar= textWidget.getVerticalBar(); >+// double thumbTrackHeight= verticalBar.getThumbTrackBounds().height; >+// double thumbHeight= verticalBar.getThumbBounds().height; >+// double textLineCount= Math.max(1, textWidget.getLineCount()); >+// int topIndex= textWidget.getTopIndex(); >+// Rectangle clientArea= textWidget.getClientArea(); >+// int bottomIndex= textWidget.getLineIndex(clientArea.y + clientArea.height); >+// double visibleLineCount= bottomIndex - topIndex + 1; >+// // (thumbHeight-additionalThumbHeight)/thumbTrackHeight == visibleLineCount/textLineCount: >+// double additionalThumbHeight= Math.max(0, thumbHeight - visibleLineCount/textLineCount*thumbTrackHeight); >+// >+// //TODO: >+//// System.out.println(additionalThumbHeight); >+//// fOverviewRuler.getControl().setBackground(fOverviewRuler.getControl().getDisplay().getSystemColor(SWT.COLOR_GREEN)); >+// >+// int overviewRulerX= clArea.x + clArea.width - overviewRulerWidth - 1; >+// int overviewRulerY= (int)(clArea.y + arrowHeights[0] + additionalThumbHeight/2d); >+// int overviewRulerHeight= (int)(clArea.height - arrowHeights[0] - arrowHeights[1] - additionalThumbHeight - scrollbarHeight); >+// fOverviewRuler.getControl().setBounds(overviewRulerX, overviewRulerY, overviewRulerWidth, overviewRulerHeight); >+ > int overviewRulerX= clArea.x + clArea.width - overviewRulerWidth - 1; > fOverviewRuler.getControl().setBounds(overviewRulerX, clArea.y + arrowHeights[0], overviewRulerWidth, clArea.height - arrowHeights[0] - arrowHeights[1] - scrollbarHeight); > >@@ -205,7 +231,6 @@ > } finally { > textWidget.setSize(originalSize); // also resets scroll bar values > } >- return arrowHeights; > } > return arrowHeights; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 163769
:
72050
|
143870
|
144937
|
146934
|
150218
|
150219
|
150488
|
186620
|
186622
|
186755