Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 163769

Summary: [rulers] overview ruler annotation arming not correct
Product: [Eclipse Project] Platform Reporter: Aaron Digulla <digulla>
Component: TextAssignee: Markus Keller <markus.kell.r>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: bogofilter+eclipse.org, daniel_megert, gabriele.garuglieri, markus.kell.r, noelgrandin, raksha.vasisht
Version: 3.2.1   
Target Milestone: 3.7 M5   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Screenshot
none
Picture with wrong arming
none
Patch v01
none
Patch v02
none
Patch v03
none
mylyn/context/zip
none
Patch v04
none
Fix annotation drawing
none
Fix Annotation drawing 2
none
Drawing and arming none

Description Aaron Digulla CLA 2006-11-08 03:47:42 EST
Took me a moment to determine what's going on here ... :-)

In the vertical overview to the right of Java editors, you can see TODOs, warnings, etc. Depending on the number of lines of the source, these become increasingly hard to hit with the mouse.

It seems that the vertical size of the clickable/active area depends on the number of lines the editor can fit on the screen divided by the total number of lines but there is no visual indication of that.

The net effect is that for very short files, the active area is much higher than the little box indicates and for very long files, the active area becomes smaller and smaller until you have to hit one pixel.

Also, the color of these indicators cannot be changed (or at least I couldn't find the setting in the prefs). On some setups, the yellow is almost impossible to distiguish from the light gray background.

As a fix, I'd like the following:

- The active area should never become smaller than the visible indicator. I don't mind when it's bigger but it should never become smaller than 4 pixels.

Alternatively, you could make the whole thing active (like a "click to move the scroll bar instantly") and if the user "accidentially" hits a marker, home into the respective line.

- For a next version, a popup or slideout might be nice when you have a cluster of TODOs/warnings. For example, right now, you show a popup message with details to the error. When several markers are below the mouse, show all messages (along with line numbers) and align the popup with the bar so that the user can move into it to select a specific line (like Ctrl-Space when you have several options).

- The colors of TODOs, warnings and whatever can be in the overview bar should be configurable. Maybe it already is; in this case, it's too hard to find. Searching for "TODO", "warning" and "overview" in the prefs should turn them up.
Comment 1 Dani Megert CLA 2006-11-08 04:14:35 EST
There seems to be a bug in computing the activation area which should be the size of the annotation. Same bug can be seen using 3.1. Not an issue for me because I always hit the middle of the annotation with my high-precision laser mouse ;-)

The color can be configured under General > Editors > Text Editors > Annotations. It can also be found by entering "color" or "annotation" into the preference text search field.

>When several markers are below the mouse, show all
>messages
We already show all of them i.e. "Multiple markers at this line".

The idea with having a popup that allows to go directly to a marker if there's more than one is similar to what we offer in the vertical ruler when roll-over is enabled. I suggest to decouple this from here and write a feature request.
Comment 2 Aaron Digulla CLA 2006-11-08 09:12:42 EST
>The color can be configured under General > Editors > Text Editors >
>Annotations.

Ah. Well, I can't see much of an effect when I change the color for warnings.

I guess the color which I can select is modified somehow before it is used. You can see this for yourself when you set the color to black. Only the rectangle at the top of the overview bar is now black; the icons in the vertical ruler are unaffected, the squiggles are grey, as are the warning boxes.

I suggest that you take the selected color literally for the squiggles and the inside of the marks on the right. The outline of the marks should then be computed to be a darker hue of the inner color.

>>When several markers are below the mouse, show all
>>messages
>We already show all of them i.e. "Multiple markers at this line".

I meant the annotations. There is no message when they get pushed into each other. For example, when you have annotations on several consecutive lines and a long source, it's impossible to aim at one of them.

I'll add a feature request for this.
Comment 3 Dani Megert CLA 2006-11-08 09:46:32 EST
The color problem is covered by bug 90194.
Comment 4 Markus Keller CLA 2007-06-21 11:16:58 EDT
The popup for overlapping annotations is bug 163813.
Comment 5 Markus Keller CLA 2007-06-21 11:22:22 EDT
Created attachment 72050 [details]
Screenshot

(In reply to comment #1)
> [..] Not an issue for me
> because I always hit the middle of the annotation with my high-precision laser
> mouse ;-)

That statement indeed needs a ;-), since this screenshot shows that the middle of the annotation can already be outside of the responsive area (document with 2500 lines, annotation on line 150 => only 2 topmost pixels are responsive).
Comment 6 Dani Megert CLA 2007-06-25 05:59:30 EDT
See also bug 60943.
Comment 7 Dani Megert CLA 2007-06-25 06:00:48 EDT
*** Bug 40700 has been marked as a duplicate of this bug. ***
Comment 8 Dani Megert CLA 2008-04-24 06:56:12 EDT
*** Bug 34168 has been marked as a duplicate of this bug. ***
Comment 9 Aaron Digulla CLA 2008-04-24 16:12:02 EDT
This bug is now 1.5 years old. For me, this ought to be simple to fix but it wasn't fixed in 3.3. Is there a reason why you push it beyond 3.4 again?
Comment 10 Dani Megert CLA 2008-04-25 02:16:35 EDT
>Is there a reason why you push it beyond 3.4 again?
No, we've moved it for no reason. Feel free to provide that simple fix and we will reconsider.
Comment 11 Aaron Digulla CLA 2008-04-25 16:17:00 EDT
In which plugin and class do you handle the mouse click on the vertical ruler?
Comment 12 Dani Megert CLA 2008-04-26 08:11:49 EDT
>In which plugin and class do you handle the mouse click on the vertical ruler?
I assume a typo: this bug is about the Overview ruler.

org.eclipse.jface.text.source.OverviewRuler (in org.eclipse.jface.text).

Can't wait to see the patch ;-)
Comment 13 Dani Megert CLA 2009-08-10 04:36:26 EDT
Another use case of this:

1. paste:
public class foo {
	//  a comment
}
2. add bookmark on word "comment"
3. mouse hand is activated to early when coming from below (see attached picture)


Besides a bug in the logic this might be an int arithmetic issue.
Comment 14 Dani Megert CLA 2009-08-10 04:37:33 EDT
Created attachment 143870 [details]
Picture with wrong arming
Comment 15 Prakash Rangaraj CLA 2009-08-19 06:56:48 EDT
Created attachment 144937 [details]
Patch v01

Attaching Patch v01.
Comment 16 Dani Megert CLA 2009-08-28 04:16:09 EDT
The patch goes into the right direction by removing the rounding errors. I would always switch to double and probably use Math.round(...) instead of casting to int which always floors the value. However, the patch adds code that reduces the hit area and that's not good because that method is not only used when hitting/hovering over the annotations but it is also used to show you the line number and go to a line when clicking in the ruler.

Another test case is to use a big font (e.g. 48pt).

The hit area should be the whole overview ruler area that corresponds to the line(s) that includes the y coordinate. Also, I'm not convinced that we need the +/-1 code (pixel init code) that's currently there.
Comment 17 Prakash Rangaraj CLA 2009-09-11 04:59:32 EDT
Created attachment 146934 [details]
Patch v02

(In reply to comment #16)
> The patch goes into the right direction by removing the rounding errors. I
> would always switch to double and probably use Math.round(...) instead of
> casting to int which always floors the value
     How will rounding improve the hit in our case?

> However, the patch adds code that
> reduces the hit area and that's not good because that method is not only used
> when hitting/hovering over the annotations but it is also used to show you the
> line number and go to a line when clicking in the ruler.

    Fixed in the patch v02

> Another test case is to use a big font (e.g. 48pt).
    Tested. Works


> The hit area should be the whole overview ruler area that corresponds to the
> line(s) that includes the y coordinate. Also, I'm not convinced that we need
> the +/-1 code (pixel init code) that's currently there.
    This is required when the ruler length is very small than the actual number of lines (like in comment #5).
Comment 18 Dani Megert CLA 2009-09-14 07:15:58 EDT
>How will rounding improve the hit in our case?
If 0.8 is rounded to 1.0 instead of floored to 0.0 then it is closer to the original value, isn't it?
Comment 19 Prakash Rangaraj CLA 2009-09-15 03:05:14 EDT
(In reply to comment #18)
> >How will rounding improve the hit in our case?
> If 0.8 is rounded to 1.0 instead of floored to 0.0 then it is closer to the
> original value, isn't it?

    Yes, but that doesn't improve the hit when it is done for pixel0. And similarly when rounding is done for pixel1 and the value tends to be 0.4. If we want to improve the hit applying a similar logic then probably we need to floor the value of pixel0 and ceil the value of pixel1. I did try that, but the difference is hardly noticeable.
Comment 20 Prakash Rangaraj CLA 2009-09-15 10:48:41 EDT
Updating target
Comment 21 Dani Megert CLA 2009-09-22 10:51:14 EDT
Sorry for the delayed feedback, I was really busy.

>Yes, but that doesn't improve the hit when it is done for pixel0.
Right, I didn't try it - rounding just sounded better when reading the code.

The hit area (change of mouse pointer to hand) detection now looks good but the hover is wrong in the case where the mouse is not over the rectangle: it shows the bookmark text instead the line number. Maybe I was not fully clear about this in comment 16 where I missed the line hover when using your first patch.

We should
- show the annotation hover when over the annotation and show the line number 
  hover otherwise
- go to the annotation when the mouse is clicked on the annotation and go to the
  line otherwise
Comment 22 Dani Megert CLA 2009-10-13 08:37:03 EDT
ping ;-)

Note that the OverviewRuler code changed in HEAD.
Comment 23 Dani Megert CLA 2009-10-20 04:06:24 EDT
Prakash, can I expect a new patch this week for M3?
Comment 24 Prakash Rangaraj CLA 2009-10-20 04:34:14 EDT
(In reply to comment #23)
> Prakash, can I expect a new patch this week for M3?

    Yes. I'll be working on this bug on Thursday
Comment 25 Prakash Rangaraj CLA 2009-10-22 06:16:04 EDT
Created attachment 150218 [details]
Patch v03

Attaching Patch v03
Comment 26 Prakash Rangaraj CLA 2009-10-22 06:16:17 EDT
Created attachment 150219 [details]
mylyn/context/zip
Comment 27 Dani Megert CLA 2009-10-23 11:25:00 EDT
Prakash, the latest patch does not touch the Overview ruler and hence cannot fix this bug. In addition the patch causes API tooling errors in my workspace because you've set the bundle version to 3.6.100 instead of 3.6.0. I suggest you enable API tooling ;-)

The new API doesn't make sense to me.
Comment 28 Prakash Rangaraj CLA 2009-10-26 04:11:23 EDT
Created attachment 150488 [details]
Patch v04

(In reply to comment #27)
> Prakash, the latest patch does not touch the Overview ruler and hence cannot
> fix this bug. 

     Sorry. Patch v03 is in addition to Patch v02 (which fixes the location of the hand cursor) - not a replacement. Patch v04 combines both and fixes the manifest version also.

> In addition the patch causes API tooling errors in my workspace
> because you've set the bundle version to 3.6.100 instead of 3.6.0. I suggest
> you enable API tooling ;-)

     I have enabled it. When it showed an error, I changed it in the Overview page of editor manually without realizing there is Quick Fix. (it correctly fixes the version)
 
> The new API doesn't make sense to me.

     OverviewRulerHoverManager computes the tool tip for a given location. It first converts the cursor location to line number and consults the IAnnotationHover for that line number. IAnnotationHover returns the tooltip, based on whether annotation is available in the line or not. I thought the new API is the right way to find the tooltip on a line, ignoring the annotations in the line. If you have better alternatives, please suggest me.
Comment 29 Dani Megert CLA 2009-10-26 11:58:38 EDT
I have tested Patch v04 but the problem described in comment 13 is still present as shown in attachment 143870 [details] :-(.

The computation is all done in the DefaultAnnotationHover, so I really can't see any benefit in the new API.
Comment 30 Dani Megert CLA 2009-10-26 12:34:15 EDT
>I have tested Patch v04 but the problem described in comment 13 is still
>present as shown in attachment 143870 [details] [diff] :-(.
This is not 100% correct: the arming is now OK, but the hover and the navigation is still wrong (as mentioned in comment 21).
Comment 31 Dani Megert CLA 2009-11-18 09:35:55 EST
Prakash, I'm reassigning this to Markus because he's currently reworking the Overview ruler with regards to the scroll bar's thumb size.
Comment 32 Markus Keller CLA 2011-01-12 08:22:42 EST
Created attachment 186620 [details]
Fix annotation drawing

Does not yet fix the hover manager and mouse clicks/arming.
Comment 33 Markus Keller CLA 2011-01-12 08:28:20 EST
Created attachment 186622 [details]
Fix Annotation drawing 2

Eclipse patch creation wizard is broken...
Comment 34 Markus Keller CLA 2011-01-13 12:11:55 EST
Created attachment 186755 [details]
Drawing and arming
Comment 35 Markus Keller CLA 2011-01-13 12:18:16 EST
*** Bug 295091 has been marked as a duplicate of this bug. ***
Comment 36 Markus Keller CLA 2011-01-13 16:32:48 EST
Fixed in HEAD of OverviewRuler for source viewers.

Compare viewers will be tackled with bug 294454.
Comment 37 Dani Megert CLA 2011-01-14 04:36:59 EST
I have tested fix but the problem described in comment 13 is still
present as shown in attachment 143870 [details] :-(.

Sample snippet:
------ %< ------
public class foo {
   //   a comment
}
------ %< ------
Comment 38 Markus Keller CLA 2011-01-14 11:51:10 EST
(In reply to comment #37)
This only happened in cases where a line was mapped to an area taller than 5px in the overview ruler. In that situation, some pixels before and after the drawn rectangle belong to the same line, so I thought it would be nice to expand the hit area for free.

But after testing it a bit more, I now agree that the arming (using the hand cursor) should be aligned with the area of the rectangle. In HEAD, I still use the whole mapped area as click target for the annotation, but I've fixed the cursor.

Committed to OverviewRuler with a few other fixes.
Comment 39 Raksha Vasisht CLA 2011-01-25 04:50:41 EST
Verified for 3.7 M5 with I20110124-1800.

Filed bug 335282 : overview ruler annotation arming not correct with vertical scroll bars