]> git.lyx.org Git - features.git/commit
Keyboard based horizontal scrolling for wide insets
authorHashini Senaratne <hashz1990@gmail.com>
Sat, 26 Jul 2014 11:17:28 +0000 (13:17 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 7 Jan 2015 21:55:11 +0000 (22:55 +0100)
commit5a361b35cf0c2a2f1ca9535b0748045063f20555
tree920c13d3d99192467b906bbf12caf5f09e6d16fc
parent8fb1aa51f8d14747bd21d9e113a8dd301a2f07dc
Keyboard based horizontal scrolling for wide insets

[This commit is the output of the "horizontal scrolling" GSoC 2013
 project, by Hashini Senaratne. The code has been cleaned up, some
 variables have been renamed and moved from the Cursor class to
 BufferView::Private. This is the base from which I (jmarc) will polish
 the feature for landing on master.

 Below is the original commit log of Hashini, updated to reflect the
 changes that have been done.]

This feature also applicable for other insets; graphics and labels.

This implementation is capable of scrolling a single row when reaching
its content which is beyond the screen limits, using left and right
arrow keys.

The attribute 'horiz_scroll_offset_' introduced in the
BufferView::Private class plays a main role in horizontal scrolling of
the wide rows that grow beyond the screen limits. This attribute
represents by how much pixels the current row that the text cursor
lies in should be get scrolled.

The main logic that is responsible for drawing the scrolled rows is
within the BufferView class, BufferView::checkCursorScrollOffset.

 * The main logic is called via BufferView::draw.

 * What this does is set the horiz_scroll_offset_ attribute in in order to
 show the position that the text cursor lies in.

 * To make sure that BufferView::draw gets involved when Update flag is
 FitCursor, necessary changes are made in BufferView::processUpdateFlags.

Basically what the logic that used to set the horiz_scroll_offset_
does is,

 * The row which the text cursor lies in is identified by a
 CursorSlice that points to the beginning of the row. This is the
 'rowSlice' variable used in BufferView::checkCursorScrollOffset. Acessors
 are added to obtain this variable. Here row objects were not used to
 identify the current row, because it appears that row objects can
 disappear when doing a decoration update for example. This means that
 comparing row pointers is not a good idea, because they can change
 without notice.

 * Stop calculations of horiz_scroll_offset_ variable, if metrics have not been
 computed yet. Otherwise the calls to TextMetrics::parMetrics, calls
 redoParagraph and may change the row heigths. Therefore vertical scrolling
 feature may get disturbed. This is avoided.

 * Using BufferView::::setCurrentRowSlice resets horiz_scroll_offset_
 when changing cursor row. This is done in order to prevent unwanted
 scrolling that happens when changing the selected row using up and
 down arrow keys.

 * Recompute inset positions before checking scoll offset of the row, by
 painting the row insets with drawing disabled. This is done because the
 position of insets is computed within the drawing procedure.

 * Current x position of the text cursor is compared with the
 horiz_scroll_offset_ value and the other variables like row.width(),
 bv.workWidth(). Compute the new horiz_scroll_offset_ value in order
 to show where the text cursor lies in. The basics conditions that we
 check before recomputing it are, if the text cursor lies rightward to
 the current right screen boundary, if the text cursor lies leftward
 to the current left screen boundary, if the text cursor lies within
 screen boundaries but the length of the row is less than the left
 boundary of the screen (this happens when we delete some content of
 the row using delete key or backspace key).

 * Change update strategy when scrooll offset has changed. This allows to
 redraw the row when no drawing was scheduled. By doing so, it was
 possible to redraw a wide row when moving to the leftmost position of the
 wide row, from the leftmost position of the row below, using the left
 arrow key.

In TextMetrics::drawParagraph it is checked whether the current row is
what is drawing now. If it is so, the value used to the x value of the row
for drawing is adapted according to BufferView::horizScrollOffset.

The method used to pass boundary() was fixed to get row when cursor was in
a nested inset. This matter is considered in Cursor::textRow and it is
modified accordingly.

GuiWorkArea::Private::showCursor() is modified to show the cursor position
in a scrolled row.
src/BufferView.cpp
src/BufferView.h
src/CursorSlice.h
src/TextMetrics.cpp
src/frontends/qt4/GuiWorkArea.cpp