Martin Vermeer wrote:
On Sun, Sep 16, 2007 at 10:41:21AM +0200, Abdelrazak Younes wrote:
Martin Vermeer wrote:
On Sun, Sep 16, 2007 at 04:27:04AM +0200, Tommaso Cucinotta wrote:
Hi,
I couldn't really understand what information is
stored inside the BufferView.offset_ref_ variable.
At a first glance, it would seem that anchor_ref_
stores the "paragraph offset" that is displayed from
the WorkArea top line, and offset_ref_ stores the
"pixel offset". Namely, the top WorkArea line of
pixels would display the offset_ref_-th line of
the anchor_ref_-th paragraph.
Almost right. IIRC anchor_ref_ represents the top visible paragraph,
and offset_ref_ the offset, in pixels, of the cursor position (which may
be in a later paragraph).
Well, I guess this has changed in the 1.5 series (probably my doing) but
the offset_ref_ is independent from the cursor position and the
anchor_ref_ is not necessarily the top visible paragraph.
The anchor_ref_ is really the anchor paragraph of the BufferView from
which all other paragraphs are positioned.
...which is one of the visible paragraphs, not necessarily the top one
In general yes. But, in trunk, it could happen that it is temporarily
off-screen when doing page scrolling. Of course it is put again on top
of the screen on next updateMetrics().
The offset_ref_ is basically the offset position of the anchor paragraph
from the top screen (and that is 0). In effect, offset_ref_ is just the
opposite of the paragraph position on screen and I am really tempted to
rename that.
"Normalization" means making the cursor paragraph the top one on-screen.
See BufferView.cpp:288 "...making the cursor paragraph the anchor one."
(I think).
?? I don't see this comment in BufferView, neither in trunk nor in branch.
This code doesn't actually say anything about the screen
position of the anchor.
Possibly some comment is missing. I took me a really long time to
understand this stuff...
Even if I keep these two values in sync with the scrollbar,
it seems there are other variables that decide what pars
the workarea starts displaying from the top.
Yes.
Moreover, what var decides how the gray text background
is cut at the end of the doc ?
Yes, that is tricky. It's years ago that I looked at this :-(
I suspect it is in GuiWorkArea::setScrollbarParams():
// do what cursor movement does (some grey)
h += height() / 4;
Look at the end of BufferView::draw() to understand how the grey area
size is calculated.
Are you sure? I don't see any calculation, just decision logic.
Well, there is no real calculation, BufferView::draw() will just draw a
gray rectangle starting at the bottom of the last paragraph.
Abdel.