Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tts: scroll the page when the next selected sentence is too close to the bottom #355

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions crengine/src/lvdocview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6390,12 +6390,17 @@ int LVDocView::onSelectionCommand( int cmd, int param )
int y0 = GetPos();
int h = m_pageRects[0].height() - m_pageMargins.top
- m_pageMargins.bottom - getPageHeaderHeight();

//if selection is in the bottom 150px of the screen, scroll the page
int bottomMarginBuffer = 150;
h = h - bottomMarginBuffer;

//int y1 = y0 + h;
if (makeSelStartVisible) {
// make start of selection visible
if (isScrollMode()) {
if (startPoint.y < y0 + m_font_size * 2 || startPoint.y > y0 + h * 3/4)
SetPos(startPoint.y - m_font_size * 2);
if (startPoint.y < y0 + m_font_size * 2 || startPoint.y > y0 + h * 3/4 || endPoint.y > y0 + h)
SetPos(startPoint.y - m_font_size * 1);
} else {
if (startPoint.y < y0 || startPoint.y >= y0 + h)
SetPos(startPoint.y);
Expand All @@ -6405,7 +6410,7 @@ int LVDocView::onSelectionCommand( int cmd, int param )
// make end of selection visible
if (isScrollMode()) {
if (endPoint.y > y0 + h * 3/4 - m_font_size * 2)
SetPos(endPoint.y - h * 3/4 + m_font_size * 2, false);
SetPos(endPoint.y - h * 3/4 + m_font_size * 1, false);
} else {
if (endPoint.y < y0 || endPoint.y >= y0 + h)
SetPos(endPoint.y, false);
Expand Down