From 0a09d9271fe0c2ab1829ece2acfebe4a607448ba Mon Sep 17 00:00:00 2001 From: Elliot Wolk Date: Sun, 13 Mar 2022 11:39:14 -0400 Subject: [PATCH 1/3] selection: in scroll mode, move pos to 1 line from top/bottom instead of 2 lines --- crengine/src/lvdocview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crengine/src/lvdocview.cpp b/crengine/src/lvdocview.cpp index 849fe079d..99fc3256e 100644 --- a/crengine/src/lvdocview.cpp +++ b/crengine/src/lvdocview.cpp @@ -6395,7 +6395,7 @@ int LVDocView::onSelectionCommand( int cmd, int param ) // 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); + SetPos(startPoint.y - m_font_size * 1); } else { if (startPoint.y < y0 || startPoint.y >= y0 + h) SetPos(startPoint.y); @@ -6405,7 +6405,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); From 0d8fc700241eae019d51f83b6799c2df3f010c72 Mon Sep 17 00:00:00 2001 From: Elliot Wolk Date: Sun, 13 Mar 2022 11:40:22 -0400 Subject: [PATCH 2/3] selection: force pos move in scroll mode if end of selection is out of range --- crengine/src/lvdocview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crengine/src/lvdocview.cpp b/crengine/src/lvdocview.cpp index 99fc3256e..f696c06f2 100644 --- a/crengine/src/lvdocview.cpp +++ b/crengine/src/lvdocview.cpp @@ -6394,7 +6394,7 @@ int LVDocView::onSelectionCommand( int cmd, int param ) if (makeSelStartVisible) { // make start of selection visible if (isScrollMode()) { - if (startPoint.y < y0 + m_font_size * 2 || startPoint.y > y0 + h * 3/4) + 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) From 581fe6a7a0410acace7db954b23750bc9490f280 Mon Sep 17 00:00:00 2001 From: Elliot Wolk Date: Sun, 13 Mar 2022 11:43:58 -0400 Subject: [PATCH 3/3] selection: scroll page if selection is in the bottom 150px of the screen --- crengine/src/lvdocview.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crengine/src/lvdocview.cpp b/crengine/src/lvdocview.cpp index f696c06f2..616a84731 100644 --- a/crengine/src/lvdocview.cpp +++ b/crengine/src/lvdocview.cpp @@ -6390,6 +6390,11 @@ 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