Re: What is offset_ref_ ?

2007-09-16 Thread Martin Vermeer
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).

Normalization means making the cursor paragraph the top one on-screen.
 
 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;

 
 Thanx,
 
T.

- Martin



Re: What is offset_ref_ ?

2007-09-16 Thread Andre Poenitz
On Sun, Sep 16, 2007 at 09:00:50AM +0300, 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).
 
 Normalization means making the cursor paragraph the top one on-screen.

Is this in the comments somewhere? If not, could you put it there?

Andre'


Re: What is offset_ref_ ?

2007-09-16 Thread Abdelrazak Younes

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.


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.


Well, in the current implementation, center() will center the cursor 
position on screen, not necessarily the paragraph.


 

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.


Abdel.



Re: What is offset_ref_ ?

2007-09-16 Thread Martin Vermeer
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

 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). This code doesn't actually say anything about the screen
position of the anchor.

 Well, in the current implementation, center() will center the cursor 
 position on screen, not necessarily the paragraph.

OK.
 
  
 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.
 
 Abdel.
 


Re: What is offset_ref_ ?

2007-09-16 Thread Abdelrazak Younes

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.



Re: What is offset_ref_ ?

2007-09-16 Thread Martin Vermeer
On Sun, Sep 16, 2007 at 11:35:09AM +0200, Abdelrazak Younes wrote:
 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.

No, this is _my_ comment here ;-) corrcting my earlier comment.
 
 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...
 
+1
 
 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.

Yes, but the question was (as I understood it to mean): where is it
decided how big this rectangle will be, i.e., how far will the scrolling
go on when we run out of paragraphs ;-) 

- Martin



Re: What is offset_ref_ ?

2007-09-16 Thread Tommaso Cucinotta

And, what about ParagraphMetrics.position_, ascent
and discent ?

Ok, they're y coords, they represent the paragraph vertical
dimension and position, but I couldn't really figure out what
are they relative to, and why I always see in the code
*) position()-ascent()
*) position()+descent()

Thanx again, bye,

   T.



Re: What is offset_ref_ ?

2007-09-16 Thread Andre Poenitz
On Sun, Sep 16, 2007 at 02:42:11PM +0200, Tommaso Cucinotta wrote:
 And, what about ParagraphMetrics.position_, ascent
 and discent ?
 
 Ok, they're y coords, they represent the paragraph vertical
 dimension and position, but I couldn't really figure out what
 are they relative to, and why I always see in the code
 *) position()-ascent()
 *) position()+descent()
 
 Thanx again, bye,

Because we always measure from some base line, so the top of something
would be y + asc, and the bottom y - des.

Andre'


Re: What is offset_ref_ ?

2007-09-16 Thread Martin Vermeer
On Sun, Sep 16, 2007 at 02:53:56PM +0200, Andre Poenitz wrote:
 On Sun, Sep 16, 2007 at 02:42:11PM +0200, Tommaso Cucinotta wrote:
  And, what about ParagraphMetrics.position_, ascent
  and discent ?
  
  Ok, they're y coords, they represent the paragraph vertical
  dimension and position, but I couldn't really figure out what
  are they relative to, and why I always see in the code
  *) position()-ascent()
  *) position()+descent()
  
  Thanx again, bye,
 
 Because we always measure from some base line, so the top of something
 would be y + asc, and the bottom y - des.

The baseline is like in LaTeX, the line the letter shapes rests on, so
for the letter p it would be the lower edge of the arc, like _p_.

- Martin



Re: What is offset_ref_ ?

2007-09-16 Thread Abdelrazak Younes

Tommaso Cucinotta wrote:

And, what about ParagraphMetrics.position_, ascent
and discent ?

Ok, they're y coords, they represent the paragraph vertical
dimension and position, but I couldn't really figure out what
are they relative to,


All inset and paragraph coords are absolute WRT the screen. (0,0) is the 
top left corner.



and why I always see in the code
*) position()-ascent()
*) position()+descent()


* Position of a paragraph is the baseline of its first row.
* position()-ascent() is the where the paragraph drawing effectively start.
* position()+descent() is the where the paragraph drawing effectively end.

position()-ascent()  
position()   
 
 
 
 
position()+descent() 

Hope this helps. Feel free to synthesize all these information and write 
some documentation ;-)


Abdel.



Re: What is offset_ref_ ?

2007-09-16 Thread Abdelrazak Younes

Martin Vermeer wrote:

On Sun, Sep 16, 2007 at 11:35:09AM +0200, Abdelrazak Younes wrote:



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.


Yes, but the question was (as I understood it to mean): where is it
decided how big this rectangle will be, i.e., how far will the scrolling
go on when we run out of paragraphs ;-) 


Ah... then yes you're right, it a combination of 
GuiWorkArea::setScrollbarParams() and BufferView::scrollDocView().


Abdel.



Re: What is offset_ref_ ?

2007-09-16 Thread Pavel Sanda
 Hope this helps. Feel free to synthesize all these information and write 
 some documentation ;-)

btw i'm trying to catch such threads and put them into
http://wiki.lyx.org/Devel/Diagrams .  

pavel


Re: What is offset_ref_ ?

2007-09-16 Thread Abdelrazak Younes

Pavel Sanda wrote:
Hope this helps. Feel free to synthesize all these information and write 
some documentation ;-)


btw i'm trying to catch such threads and put them into
http://wiki.lyx.org/Devel/Diagrams .  


Very good initiative. Proper doxygen documentation should also go in the 
header... We are such a lazy bunch...


Abdel.



Re: What is offset_ref_ ?

2007-09-16 Thread Tommaso Cucinotta

Pavel Sanda ha scritto:

btw i'm trying to catch such threads and put them into
http://wiki.lyx.org/Devel/Diagrams .  
  

Great. Also, the (reference point of the) return
value of buffer_view::coordOffset() and buffer_view::getPos(),
and the role of BufferView.wh_ would complete the
picture.

Guess coordPos() is the DocIterator coordinate relative
to the paragraph topleft corner (equal to baseline of
cursor pos relative to baseline of topleft paragraph char).
getPos() gives the on-screen coordinates of the DocIterator
*baseline* (hope so).

   T.



Re: What is offset_ref_ ?

2007-09-16 Thread Martin Vermeer
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).

"Normalization" means making the cursor paragraph the top one on-screen.
 
> 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;

 
> Thanx,
> 
>T.

- Martin



Re: What is offset_ref_ ?

2007-09-16 Thread Andre Poenitz
On Sun, Sep 16, 2007 at 09:00:50AM +0300, 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).
> 
> "Normalization" means making the cursor paragraph the top one on-screen.

Is this in the comments somewhere? If not, could you put it there?

Andre'


Re: What is offset_ref_ ?

2007-09-16 Thread Abdelrazak Younes

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.


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.


Well, in the current implementation, center() will center the cursor 
position on screen, not necessarily the paragraph.


 

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.


Abdel.



Re: What is offset_ref_ ?

2007-09-16 Thread Martin Vermeer
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

> 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). This code doesn't actually say anything about the screen
position of the anchor.

> Well, in the current implementation, center() will center the cursor 
> position on screen, not necessarily the paragraph.

OK.
 
> > 
> >>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.
 
> Abdel.
> 


Re: What is offset_ref_ ?

2007-09-16 Thread Abdelrazak Younes

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.



Re: What is offset_ref_ ?

2007-09-16 Thread Martin Vermeer
On Sun, Sep 16, 2007 at 11:35:09AM +0200, Abdelrazak Younes wrote:
> 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.

No, this is _my_ comment here ;-) corrcting my earlier comment.
 
> >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...
 
+1
 
> 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.

Yes, but the question was (as I understood it to mean): where is it
decided how big this rectangle will be, i.e., how far will the scrolling
go on when we run out of paragraphs ;-) 

- Martin



Re: What is offset_ref_ ?

2007-09-16 Thread Tommaso Cucinotta

And, what about ParagraphMetrics.position_, ascent
and discent ?

Ok, they're y coords, they represent the paragraph vertical
dimension and position, but I couldn't really figure out what
are they relative to, and why I always see in the code
*) position()-ascent()
*) position()+descent()

Thanx again, bye,

   T.



Re: What is offset_ref_ ?

2007-09-16 Thread Andre Poenitz
On Sun, Sep 16, 2007 at 02:42:11PM +0200, Tommaso Cucinotta wrote:
> And, what about ParagraphMetrics.position_, ascent
> and discent ?
> 
> Ok, they're y coords, they represent the paragraph vertical
> dimension and position, but I couldn't really figure out what
> are they relative to, and why I always see in the code
> *) position()-ascent()
> *) position()+descent()
> 
> Thanx again, bye,

Because we always measure from some base line, so the top of something
would be y + asc, and the bottom y - des.

Andre'


Re: What is offset_ref_ ?

2007-09-16 Thread Martin Vermeer
On Sun, Sep 16, 2007 at 02:53:56PM +0200, Andre Poenitz wrote:
> On Sun, Sep 16, 2007 at 02:42:11PM +0200, Tommaso Cucinotta wrote:
> > And, what about ParagraphMetrics.position_, ascent
> > and discent ?
> > 
> > Ok, they're y coords, they represent the paragraph vertical
> > dimension and position, but I couldn't really figure out what
> > are they relative to, and why I always see in the code
> > *) position()-ascent()
> > *) position()+descent()
> > 
> > Thanx again, bye,
> 
> Because we always measure from some base line, so the top of something
> would be y + asc, and the bottom y - des.

The baseline is like in LaTeX, the line the letter shapes rests on, so
for the letter p it would be the lower edge of the arc, like _p_.

- Martin



Re: What is offset_ref_ ?

2007-09-16 Thread Abdelrazak Younes

Tommaso Cucinotta wrote:

And, what about ParagraphMetrics.position_, ascent
and discent ?

Ok, they're y coords, they represent the paragraph vertical
dimension and position, but I couldn't really figure out what
are they relative to,


All inset and paragraph coords are absolute WRT the screen. (0,0) is the 
top left corner.



and why I always see in the code
*) position()-ascent()
*) position()+descent()


* Position of a paragraph is the baseline of its first row.
* position()-ascent() is the where the paragraph drawing effectively start.
* position()+descent() is the where the paragraph drawing effectively end.

position()-ascent()  
position()   
 
 
 
 
position()+descent() 

Hope this helps. Feel free to synthesize all these information and write 
some documentation ;-)


Abdel.



Re: What is offset_ref_ ?

2007-09-16 Thread Abdelrazak Younes

Martin Vermeer wrote:

On Sun, Sep 16, 2007 at 11:35:09AM +0200, Abdelrazak Younes wrote:



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.


Yes, but the question was (as I understood it to mean): where is it
decided how big this rectangle will be, i.e., how far will the scrolling
go on when we run out of paragraphs ;-) 


Ah... then yes you're right, it a combination of 
GuiWorkArea::setScrollbarParams() and BufferView::scrollDocView().


Abdel.



Re: What is offset_ref_ ?

2007-09-16 Thread Pavel Sanda
> Hope this helps. Feel free to synthesize all these information and write 
> some documentation ;-)

btw i'm trying to catch such threads and put them into
http://wiki.lyx.org/Devel/Diagrams .  

pavel


Re: What is offset_ref_ ?

2007-09-16 Thread Abdelrazak Younes

Pavel Sanda wrote:
Hope this helps. Feel free to synthesize all these information and write 
some documentation ;-)


btw i'm trying to catch such threads and put them into
http://wiki.lyx.org/Devel/Diagrams .  


Very good initiative. Proper doxygen documentation should also go in the 
header... We are such a lazy bunch...


Abdel.



Re: What is offset_ref_ ?

2007-09-16 Thread Tommaso Cucinotta

Pavel Sanda ha scritto:

btw i'm trying to catch such threads and put them into
http://wiki.lyx.org/Devel/Diagrams .  
  

Great. Also, the (reference point of the) return
value of buffer_view::coordOffset() and buffer_view::getPos(),
and the role of BufferView.wh_ would complete the
picture.

Guess coordPos() is the DocIterator coordinate relative
to the paragraph topleft corner (equal to baseline of
cursor pos relative to baseline of topleft paragraph char).
getPos() gives the on-screen coordinates of the DocIterator
*baseline* (hope so).

   T.