mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
ScrollbarParameters: clean-up and document
Position is always 0.
This commit is contained in:
parent
0e3c8ba627
commit
325c476bcb
@ -370,13 +370,13 @@ int BufferView::leftMargin() const
|
||||
|
||||
bool BufferView::isTopScreen() const
|
||||
{
|
||||
return d->scrollbarParameters_.position == d->scrollbarParameters_.min;
|
||||
return 0 == d->scrollbarParameters_.min;
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::isBottomScreen() const
|
||||
{
|
||||
return d->scrollbarParameters_.position == d->scrollbarParameters_.max;
|
||||
return 0 == d->scrollbarParameters_.max;
|
||||
}
|
||||
|
||||
|
||||
@ -559,7 +559,6 @@ void BufferView::updateScrollbar()
|
||||
for (size_t i = last.first + 1; i != parsize; ++i)
|
||||
d->scrollbarParameters_.max += d->par_height_[i];
|
||||
|
||||
d->scrollbarParameters_.position = 0;
|
||||
// The reference is the top position so we remove one page.
|
||||
if (lyxrc.scroll_below_document)
|
||||
d->scrollbarParameters_.max -= minVisiblePart();
|
||||
@ -600,17 +599,19 @@ string BufferView::contextMenu(int x, int y) const
|
||||
}
|
||||
|
||||
|
||||
void BufferView::scrollDocView(int value, bool update)
|
||||
|
||||
void BufferView::scrollDocView(int const value, bool update)
|
||||
{
|
||||
int const offset = value - d->scrollbarParameters_.position;
|
||||
// The scrollbar values are relative to the top of the screen, therefore the
|
||||
// offset is equal to the target value.
|
||||
|
||||
// No scrolling at all? No need to redraw anything
|
||||
if (offset == 0)
|
||||
if (value == 0)
|
||||
return;
|
||||
|
||||
// If the offset is less than 2 screen height, prefer to scroll instead.
|
||||
if (abs(offset) <= 2 * height_) {
|
||||
d->anchor_ypos_ -= offset;
|
||||
if (abs(value) <= 2 * height_) {
|
||||
d->anchor_ypos_ -= value;
|
||||
buffer_.changed(true);
|
||||
updateHoveredInset();
|
||||
return;
|
||||
|
@ -57,15 +57,15 @@ enum CursorStatus {
|
||||
/// Scrollbar Parameters.
|
||||
struct ScrollbarParameters
|
||||
{
|
||||
// These parameters are normalized against the screen geometry and pixel
|
||||
// coordinates. Position 0 corresponds to the top the the screen.
|
||||
ScrollbarParameters()
|
||||
: min(0), max(0), position(0), single_step(1), page_step(1)
|
||||
: min(0), max(0), single_step(1), page_step(1)
|
||||
{}
|
||||
/// Minimum scrollbar position in pixels.
|
||||
int min;
|
||||
/// Maximum scrollbar position in pixels.
|
||||
int max;
|
||||
/// Current position in the document in pixels.
|
||||
int position;
|
||||
/// Line-scroll amount in pixels.
|
||||
int single_step;
|
||||
/// Page-scroll amount in pixels.
|
||||
|
@ -682,7 +682,7 @@ void GuiWorkArea::Private::updateScrollbar()
|
||||
p->verticalScrollBar()->setRange(scroll_.min, scroll_.max);
|
||||
p->verticalScrollBar()->setPageStep(scroll_.page_step);
|
||||
p->verticalScrollBar()->setSingleStep(scroll_.single_step);
|
||||
p->verticalScrollBar()->setSliderPosition(scroll_.position);
|
||||
p->verticalScrollBar()->setSliderPosition(0);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user