[Libreoffice] [PATCH] Added line numbers to the basic ide

Noel Power nopower at suse.com
Fri Nov 11 08:40:08 PST 2011


On 11/11/11 16:09, Noel Power wrote:
> On 10/11/11 03:02, August Sodora wrote:
>> Hello,
>>
>> I've attached a patch that attempts to add line numbers to the basic
>> ide. I believe it is mostly correct, although I am seeing a couple of
>> rendering issues that I haven't been able to track down yet. First,
>> the scrollbar seems to jump around and flicker a lot more than it does
>> without this patch. Second, typing so that the window has to scroll
>> horizontally causes the vertical scrollbar to move to a nonsensical
>> position. If anybody has a moment to take a look at this I would
>> really appreciate it! This has been bugging me for a while.
>>
> There are a couple problems as you mention with this patch, however I 
> do think that this is *really* useful and certainly something that I 
> would have liked to see at times. However sometimes I think the line 
> numbers can just be annoying ;-) so I think definitely this should be 
> configurable :-)
>
> The erratic behaviour of the vertical scrollbar ( note it doesn't 
> respond to clicks ) is I believe due to the fact that you probably 
> don't take into account the reduced size of the editor window ( 
> because now there is the extra width from the window with the line 
> numbers ) and in fact the width of that line-number window is dynamic 
> ( e.g. can change as you are typing when the number of lines increases 
> ). What I suspect is happening is the editor window area extends over 
> where the scrollbar is painted and the 'flicker' and erratic 
> 'positioning' is as a result of the the editor window and scroll bar 
> painting over one another.
>
> given the current state would you consider moving this to a feature 
> branch where perhaps others might be able to check it out and 
> collaborate/help ? Although I am not very familiar with vcl and/or ui 
> stuff, I'd be happy to try and help.
>
> Noel
>
>
@@ -1643,11 +1653,14 @@ void ComplexEditorWindow::Resize()
      long nBrkWidth = 20;
      long nSBWidth = aEWVScrollBar.GetSizePixel().Width();

-    Size aBrkSz( Size( nBrkWidth, aSz.Height() ) );
+    Size aBrkSz(nBrkWidth, aSz.Height());
      aBrkWindow.SetPosSizePixel( Point( DWBORDER, DWBORDER ), aBrkSz );

-    Size aEWSz( Size( aSz.Width() - nBrkWidth - nSBWidth + 2, 
aSz.Height() ) );
-    aEdtWindow.SetPosSizePixel( Point( DWBORDER+aBrkSz.Width()-1, 
DWBORDER ), aEWSz );
+    Size aLnSz(aLineNumberWindow.GetWidth(), aSz.Height());
+    aLineNumberWindow.SetPosSizePixel(Point(DWBORDER+aBrkSz.Width() - 
1, DWBORDER), aLnSz);
+
+    Size aEWSz(aSz.Width() - nBrkWidth - nSBWidth + 2, aSz.Height());
+    aEdtWindow.SetPosSizePixel( Point( 
DWBORDER+aBrkSz.Width()+aLnSz.Width()-1, DWBORDER ), aEWSz );

      aEWVScrollBar.SetPosSizePixel( Point( 
aOutSz.Width()-DWBORDER-nSBWidth, DWBORDER ), Size( nSBWidth, 
aSz.Height() ) );
  }

I think in the hunk above

+    Size aEWSz(aSz.Width() - nBrkWidth - nSBWidth + 2, aSz.Height());

should be

+   Size aEWSz(aSz.Width() - nBrkWidth - aLineNumberWindow.GetWidth() - 
nSBWidth + 2, aSz.Height());

or at least scroll bar seems to work as expected with that :-)
thanks,

Noel




More information about the LibreOffice mailing list