mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-27 19:40:10 +00:00
Fix bug where the cursor was largely off-screen on document opening (bug 3427).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@20191 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
12c9598e9e
commit
a0c7b98414
@ -126,7 +126,7 @@ BufferView::BufferView()
|
||||
: width_(0), height_(0), buffer_(0), wh_(0),
|
||||
cursor_(*this),
|
||||
multiparsel_cache_(false), anchor_ref_(0), offset_ref_(0),
|
||||
intl_(new Intl), last_inset_(0)
|
||||
need_centering_(false), intl_(new Intl), last_inset_(0)
|
||||
{
|
||||
xsel_cache_.set = false;
|
||||
intl_->initKeyMapper(lyxrc.use_kbmap);
|
||||
@ -593,16 +593,31 @@ int BufferView::workWidth() const
|
||||
}
|
||||
|
||||
|
||||
void BufferView::center()
|
||||
void BufferView::updateOffsetRef()
|
||||
{
|
||||
// No need to update offset_ref_ in this case.
|
||||
if (!need_centering_)
|
||||
return;
|
||||
|
||||
// We are not properly started yet, delay until resizing is
|
||||
// done.
|
||||
if (height_ == 0)
|
||||
return;
|
||||
|
||||
CursorSlice & bot = cursor_.bottom();
|
||||
TextMetrics & tm = text_metrics_[bot.text()];
|
||||
pit_type const pit = bot.pit();
|
||||
tm.redoParagraph(pit);
|
||||
ParagraphMetrics const & pm = tm.parMetrics(pit);
|
||||
anchor_ref_ = pit;
|
||||
offset_ref_ = bv_funcs::coordOffset(*this, cursor_, cursor_.boundary()).y_
|
||||
+ pm.ascent() - height_ / 2;
|
||||
ParagraphMetrics const & pm = tm.parMetrics(bot.pit());
|
||||
Point p = bv_funcs::coordOffset(*this, cursor_, cursor_.boundary());
|
||||
offset_ref_ = p.y_ + pm.ascent() - height_ / 2;
|
||||
|
||||
need_centering_ = false;
|
||||
}
|
||||
|
||||
|
||||
void BufferView::center()
|
||||
{
|
||||
anchor_ref_ = cursor_.bottom().pit();
|
||||
need_centering_ = true;
|
||||
}
|
||||
|
||||
|
||||
@ -1481,6 +1496,8 @@ void BufferView::updateMetrics(bool singlepar)
|
||||
if (!singlepar)
|
||||
tm.redoParagraph(pit);
|
||||
|
||||
updateOffsetRef();
|
||||
|
||||
int y0 = tm.parMetrics(pit).ascent() - offset_ref_;
|
||||
|
||||
// Redo paragraphs above anchor if necessary.
|
||||
|
@ -290,6 +290,10 @@ private:
|
||||
pit_type anchor_ref_;
|
||||
///
|
||||
int offset_ref_;
|
||||
///
|
||||
void updateOffsetRef();
|
||||
///
|
||||
bool need_centering_;
|
||||
|
||||
/// keyboard mapping object.
|
||||
boost::scoped_ptr<Intl> const intl_;
|
||||
|
@ -129,6 +129,9 @@ What's new
|
||||
|
||||
- Fix bug where the "longest label" widget in the paragraph dialog was disabled
|
||||
after its content was deleted (bug 4127).
|
||||
|
||||
- Fix bug where the cursor was largely off-screen on document opening
|
||||
(bug 3427).
|
||||
|
||||
|
||||
* DOCUMENTATION
|
||||
|
Loading…
x
Reference in New Issue
Block a user