Rulers don't align with document

Bug #167500 reported by Mlthomas
18
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
High
Diederik van Lierop

Bug Description

If the scroll bars are turned off (Ctrl-B), then the
ruler markers (little arrows that indicate present
position of the cursor) do not match the visual
position of the cursor.

This is true for version 0.43 on Windows and svn
version 11707 on Linux.

Revision history for this message
Rwst (rwst) wrote :

confirmed.

Revision history for this message
Mgsloan-users (mgsloan-users) wrote :

Confirmed indeed. Acrually, it looks like the cursors are
also wrong normally, just to a much lesser extent. To see
this, position the cursor far to the left. When you
actually hover over the ruler it is correct, however in the
canvas it's about a tick mark off for me.

I worked on tracking this bug down quite a bit. I've given
up though. Someone more used to the convolutions of
inkscape's GUI code and GTK shouldn't find it not too hard.

It seems that the problem is the widget itself doesnt yet
realize the new size it has available. Or at least the
widget does not report the correct size through whatever
method is available.

Perhaps rather than attempting to use gtk's ruler we could
make our own using whatever inkscape's drawing system is?
It seems pretty inaccurate now, and that's what the ruler is
for - accuracy. I suppose. I don't actually use it.

Revision history for this message
Mlthomas (mlthomas) wrote :

Same problem exists for 0.44pre0 on Linux.

Revision history for this message
John Cliff (johncliff) wrote :

Ruler markers do seem to still loose connection to mouse position if you toggle the scroll bars on and off. SVN head as of 8-12-07

Changed in inkscape:
status: New → Confirmed
Revision history for this message
Tom Davidson (tjd-mit) wrote :

Okay, I think this is actually 3 separate problems. I have made an animated gif (screenshots with and without scroll bars, attached) to help to see what's going on. In both screenshots, the cursor is positioned at 0,0 (as you can see from the status bar). Document units are mm, and the grid is on a 5mm x 5mm spacing (the problem exists using other units, too). I have drawn one line segment from 5,10 to 10,10 with snap-to-grid enabled.

The cursor position in x,y, the grid position on the screen, and the art position on the screen are all constant and seemingly correct. Great!

I think the problems are as follows:

 1- Even when the scrollbars are enabled, the rulers don't align with the grid, as Mgsloan notes above. Here the problem is also that the 'wrong length' ruler being used, and is being squeezed in. The error is only at the Top/Left end I.e the X-ruler actually goes from ~ -10.2 to 60mm, instead of from -10 to 60mm. (The Y-ruler has the same problem, with extra length at the top.) The right/bottom ends of the ruler seem to be correct, with the skew getting worse towards the top/left, as mgsloan also noted.

 2- When the scrollbars are disabled, the original rulers are simply stretched to the larger canvas from the top-left without updating the distances along the rulers. E.g. In both cases, the X ruler goes from -10 to 60 mm, even though when the scrollbars are turned off, they should go from -10 to about 62 mm. Same idea for the Y-ruler. So now the bottom/right edges are also incorrect.

 3- the cursor marker is in general being drawn correctly relative to the ruler (it hops over when the scrollbars are toggled, e.g.), but it is also off by 1 pixel. You can't see the cursor in the attached file, but I used a cross-hair cursor and was careful to line it up pixel-exactly with the grid lines at 0,0. As you can see, it is always being draw one pixel right, and one pixel high of 0,0.

Perhaps it makes sense to break #1&2 being out as a separate bug from #3.

Revision history for this message
Tom Davidson (tjd-mit) wrote :

Adding those screenshots as individual PNGs

Revision history for this message
Tom Davidson (tjd-mit) wrote :
Revision history for this message
Tom Davidson (tjd-mit) wrote :

Marking high because of high visibility (all you have to do is turn on grids on a new document).

Changed in inkscape:
importance: Medium → High
Revision history for this message
Diederik van Lierop (mail-diedenrezi) wrote :

After having a close look, it appears that the rulers are always 2 pixels too short at each end! See the screendump I've attached. When moving to the upper-left of the canvas, you can see the triangles getting truncated 2 pixels too early

I couldn't find out why they're too short, so I've just compensated for this in the calculation of the scale and position of the markers. This seems to be working nicely, but there are still some issues left:
- some grid lines are 1 pixel off w.r.t. to the ruler, probably due to rounding
- the width of scrollbars is not taken into account yet (as pointed out above), so for now it only works then the scrollbars are invisible

I will see how far I can get with the remaining issues, but have committed my changes so far anyway because I'm going on holiday within a few hours and don't want to keep you waiting for a whole week ;-). (See rev. #17133)

Please confirm that the rulers are exactly 2 pixels too short at each side for you too, and that this is not resolution dependent. Because if it is, then my fix won't work due to hard coding "#define UNUSED_PIXELS 2"

Changed in inkscape:
assignee: nobody → mail-diedenrezi
Revision history for this message
Diederik van Lierop (mail-diedenrezi) wrote :

OK, this should be the final fix: see rev. #17209. The rulers are now correctly updated when the scrollbars are toggled.

It was tough to crack this one, mainly because I'm not very familiar with the GTK. Therefore, please confirm that this also works for you guys and that I haven't introduced any new bugs.

There's still a rounding error which causes some ticks to be off by a single pixel; This is only minor issue and I will look into this someday, but will mark this bug as fixed anyway.

Changed in inkscape:
status: Confirmed → Fix Released
Revision history for this message
Tom Davidson (tjd-mit) wrote :

The rulers do now align correctly with the grid (except for the occasional rounding error that you point out), which is great!

However the triangular markers in the ruler are misaligned by 1 screen pixel. Before your fix, they were 1 pixel high and to the left. After your fix they are 1 pixel low and to the right.
You can verify this as follows:
1) Turn on the grid
2) Choose a tool with a cross-hair cursor
3) Align the cursor with a grid intersection point (verify by looking at the X/Y position reported in the status bar)
4) Notice that the black triangles in the rulers are off by 1 screen pixel (1 px too far right in the top ruler, 1 px too low in the left ruler)

A screenshot is attached...

Changed in inkscape:
status: Fix Released → In Progress
Revision history for this message
Diederik van Lierop (mail-diedenrezi) wrote :

Thanks for reporting this Tom! This should be fixed as of rev. #17218, but I cannot tell for sure because there's no mouse pointer visible in my screenshots.

Revision history for this message
Tom Davidson (tjd-mit) wrote :

Looks good to me in 17218! Great quick work on an old and highly visible bug!

PS: I had to draw the mouse pointer in mine by hand. Please forgive my duplicity... ;)

Changed in inkscape:
status: In Progress → Fix Released
Revision history for this message
Diederik van Lierop (mail-diedenrezi) wrote :

The rounding errors should be gone as of rev. #17256. Well, at least I cannot reproduce them on my machine ;-)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.