mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 11:52:25 +00:00
This commit should hopefully fix all scrolling issues. As an added bonus, mouse scrolling should be faster due to a deleted call to BufferView::update() that was not usefull (the important call to updateMetrics() is done in WorkArea()).
Log: * BufferView/pimpl: - scrollDocView(): call to BufferView::update() deleted. - scrollDocView(): second part is now in setCursorFromScrollbar() - setCursorFromScrollbar(): new method. * WorkArea: - setBufferView(): show the cursor immediately - redraw(): call to updateScrollbar() - updateScrollbar(): new method - scrollBufferView(): fix it and show the cursor immediately. * qt4/GuiWorkArea - setScrollbarParams(): now disable the Qt scrollbar tracking. - paintEvent(): scrollbar related code deleted * qt3/QWorkArea - setScrollbarParams(): now disable the Qt scrollbar tracking. * qt3/QContentPane - paintEvent(): scrollbar related code deleted git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14704 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c98992f774
commit
dd429b7f26
@ -150,6 +150,12 @@ void BufferView::scrollDocView(int value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BufferView::setCursorFromScrollbar()
|
||||||
|
{
|
||||||
|
pimpl_->setCursorFromScrollbar();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool BufferView::available() const
|
bool BufferView::available() const
|
||||||
{
|
{
|
||||||
return pimpl_->available();
|
return pimpl_->available();
|
||||||
|
@ -160,6 +160,8 @@ public:
|
|||||||
void scroll(int lines);
|
void scroll(int lines);
|
||||||
/// Scroll the view by a number of pixels
|
/// Scroll the view by a number of pixels
|
||||||
void scrollDocView(int pixels);
|
void scrollDocView(int pixels);
|
||||||
|
/// Set the cursor position based on the scrollbar one.
|
||||||
|
void setCursorFromScrollbar();
|
||||||
|
|
||||||
/// return the pixel width of the document view
|
/// return the pixel width of the document view
|
||||||
int workWidth() const;
|
int workWidth() const;
|
||||||
|
@ -435,10 +435,12 @@ void BufferView::Pimpl::scrollDocView(int value)
|
|||||||
t.redoParagraph(anchor_ref_);
|
t.redoParagraph(anchor_ref_);
|
||||||
int const h = t.getPar(anchor_ref_).height();
|
int const h = t.getPar(anchor_ref_).height();
|
||||||
offset_ref_ = int((bar * t.paragraphs().size() - anchor_ref_) * h);
|
offset_ref_ = int((bar * t.paragraphs().size() - anchor_ref_) * h);
|
||||||
update();
|
}
|
||||||
|
|
||||||
if (!lyxrc.cursor_follows_scrollbar)
|
|
||||||
return;
|
void BufferView::Pimpl::setCursorFromScrollbar()
|
||||||
|
{
|
||||||
|
LyXText & t = *bv_->text();
|
||||||
|
|
||||||
int const height = 2 * defaultRowHeight();
|
int const height = 2 * defaultRowHeight();
|
||||||
int const first = height;
|
int const first = height;
|
||||||
|
@ -66,6 +66,8 @@ public:
|
|||||||
ScrollbarParameters const & scrollbarParameters() const;
|
ScrollbarParameters const & scrollbarParameters() const;
|
||||||
///
|
///
|
||||||
void scrollDocView(int value);
|
void scrollDocView(int value);
|
||||||
|
///
|
||||||
|
void setCursorFromScrollbar();
|
||||||
/// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
|
/// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
|
||||||
void scroll(int lines);
|
void scroll(int lines);
|
||||||
///
|
///
|
||||||
|
@ -159,7 +159,9 @@ WorkArea::WorkArea(LyXView & lyx_view)
|
|||||||
|
|
||||||
void WorkArea::setBufferView(BufferView * buffer_view)
|
void WorkArea::setBufferView(BufferView * buffer_view)
|
||||||
{
|
{
|
||||||
|
hideCursor();
|
||||||
buffer_view_ = buffer_view;
|
buffer_view_ = buffer_view;
|
||||||
|
toggleCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -193,6 +195,9 @@ void WorkArea::redraw()
|
|||||||
}
|
}
|
||||||
|
|
||||||
buffer_view_->updateMetrics(false);
|
buffer_view_->updateMetrics(false);
|
||||||
|
|
||||||
|
updateScrollbar();
|
||||||
|
|
||||||
ViewMetricsInfo const & vi = buffer_view_->viewMetricsInfo();
|
ViewMetricsInfo const & vi = buffer_view_->viewMetricsInfo();
|
||||||
greyed_out_ = false;
|
greyed_out_ = false;
|
||||||
getPainter().start();
|
getPainter().start();
|
||||||
@ -266,11 +271,25 @@ void WorkArea::resizeBufferView()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WorkArea::updateScrollbar()
|
||||||
|
{
|
||||||
|
buffer_view_->updateScrollbar();
|
||||||
|
ScrollbarParameters const & scroll_ = buffer_view_->scrollbarParameters();
|
||||||
|
setScrollbarParams(scroll_.height, scroll_.position,
|
||||||
|
scroll_.lineScrollHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void WorkArea::scrollBufferView(int position)
|
void WorkArea::scrollBufferView(int position)
|
||||||
{
|
{
|
||||||
buffer_view_->scrollDocView(position);
|
buffer_view_->scrollDocView(position);
|
||||||
lyx_view_.updateLayoutChoice();
|
|
||||||
redraw();
|
redraw();
|
||||||
|
hideCursor();
|
||||||
|
if (lyxrc.cursor_follows_scrollbar) {
|
||||||
|
buffer_view_->setCursorFromScrollbar();
|
||||||
|
lyx_view_.updateLayoutChoice();
|
||||||
|
}
|
||||||
|
toggleCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,6 +139,8 @@ protected:
|
|||||||
LyXView & lyx_view_;
|
LyXView & lyx_view_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
///
|
||||||
|
void updateScrollbar();
|
||||||
///
|
///
|
||||||
void checkAndGreyOut();
|
void checkAndGreyOut();
|
||||||
|
|
||||||
|
@ -357,14 +357,6 @@ void QContentPane::paintEvent(QPaintEvent * e)
|
|||||||
QPainter q(this);
|
QPainter q(this);
|
||||||
q.drawPixmap(QPoint(r.x(), r.y()),
|
q.drawPixmap(QPoint(r.x(), r.y()),
|
||||||
*pixmap_.get(), r);
|
*pixmap_.get(), r);
|
||||||
|
|
||||||
buffer_view_->updateScrollbar();
|
|
||||||
ScrollbarParameters const & scroll_ = buffer_view_->scrollbarParameters();
|
|
||||||
|
|
||||||
wa_->scrollbar_->setTracking(false);
|
|
||||||
wa_->setScrollbarParams(scroll_.height, scroll_.position,
|
|
||||||
scroll_.lineScrollHeight);
|
|
||||||
wa_->scrollbar_->setTracking(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ QWorkArea::~QWorkArea()
|
|||||||
|
|
||||||
void QWorkArea::setScrollbarParams(int h, int pos, int line_h)
|
void QWorkArea::setScrollbarParams(int h, int pos, int line_h)
|
||||||
{
|
{
|
||||||
|
scrollbar_->setTracking(false);
|
||||||
// do what cursor movement does (some grey)
|
// do what cursor movement does (some grey)
|
||||||
h += height() / 4;
|
h += height() / 4;
|
||||||
|
|
||||||
@ -99,6 +100,8 @@ void QWorkArea::setScrollbarParams(int h, int pos, int line_h)
|
|||||||
content_->trackScrollbar(true);
|
content_->trackScrollbar(true);
|
||||||
scrollbar_->setLineStep(line_h);
|
scrollbar_->setLineStep(line_h);
|
||||||
scrollbar_->setPageStep(height());
|
scrollbar_->setPageStep(height());
|
||||||
|
|
||||||
|
scrollbar_->setTracking(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -184,6 +184,8 @@ GuiWorkArea::~GuiWorkArea()
|
|||||||
|
|
||||||
void GuiWorkArea::setScrollbarParams(int h, int scroll_pos, int scroll_line_step)
|
void GuiWorkArea::setScrollbarParams(int h, int scroll_pos, int scroll_line_step)
|
||||||
{
|
{
|
||||||
|
verticalScrollBar()->setTracking(false);
|
||||||
|
|
||||||
// do what cursor movement does (some grey)
|
// do what cursor movement does (some grey)
|
||||||
h += height() / 4;
|
h += height() / 4;
|
||||||
int scroll_max_ = std::max(0, h - height());
|
int scroll_max_ = std::max(0, h - height());
|
||||||
@ -191,6 +193,8 @@ void GuiWorkArea::setScrollbarParams(int h, int scroll_pos, int scroll_line_step
|
|||||||
verticalScrollBar()->setRange(0, scroll_max_);
|
verticalScrollBar()->setRange(0, scroll_max_);
|
||||||
verticalScrollBar()->setSliderPosition(scroll_pos);
|
verticalScrollBar()->setSliderPosition(scroll_pos);
|
||||||
verticalScrollBar()->setSingleStep(scroll_line_step);
|
verticalScrollBar()->setSingleStep(scroll_line_step);
|
||||||
|
|
||||||
|
verticalScrollBar()->setTracking(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -478,15 +482,6 @@ void GuiWorkArea::paintEvent(QPaintEvent * e)
|
|||||||
|
|
||||||
if (show_hcursor_)
|
if (show_hcursor_)
|
||||||
q.drawPixmap(cursor_x_, cursor_y_ + cursor_h_ - 1, hcursor_);
|
q.drawPixmap(cursor_x_, cursor_y_ + cursor_h_ - 1, hcursor_);
|
||||||
|
|
||||||
buffer_view_->updateScrollbar();
|
|
||||||
|
|
||||||
ScrollbarParameters const & scroll_ = buffer_view_->scrollbarParameters();
|
|
||||||
|
|
||||||
verticalScrollBar()->setTracking(false);
|
|
||||||
setScrollbarParams(scroll_.height, scroll_.position,
|
|
||||||
scroll_.lineScrollHeight);
|
|
||||||
verticalScrollBar()->setTracking(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user