These members are not private.
int const asc = fm.maxAscent();
int const des = fm.maxDescent();
Point const p = getPos(d->cursor_);
- if (p.y_ - asc >= 0 && p.y_ + des < height_)
+ if (p.y - asc >= 0 && p.y + des < height_)
return false;
}
return true;
newy = last;
break;
case CUR_INSIDE:
- int const y = getPos(oldcur).y_;
+ int const y = getPos(oldcur).y;
newy = min(last, max(y, first));
if (y == newy)
return;
CursorStatus BufferView::cursorStatus(DocIterator const & dit) const
{
Point const p = getPos(dit);
- if (p.y_ < 0)
+ if (p.y < 0)
return CUR_ABOVE;
- if (p.y_ > workHeight())
+ if (p.y > workHeight())
return CUR_BELOW;
return CUR_INSIDE;
}
LBUFERR(!pm.rows().empty());
// FIXME: smooth scrolling doesn't work in mathed.
CursorSlice const & cs = dit.innerTextSlice();
- int const ypos = pm.position() + coordOffset(dit).y_;
+ int const ypos = pm.position() + coordOffset(dit).y;
ParagraphMetrics const & inner_pm =
textMetrics(cs.text()).parMetrics(cs.pit());
Dimension const & row_dim =
d->inlineCompletionPos_ = DocIterator();
tm.redoParagraph(bot_pit);
- int const offset = coordOffset(dit).y_;
+ int const offset = coordOffset(dit).y;
pit_type const old_pit = d->anchor_pit_;
d->anchor_pit_ = bot_pit;
Point p = getPos(cur);
// This code has been commented out to enable to scroll down a
// document, even if there are large insets in it (see bug #5465).
- /*if (p.y_ < 0 || p.y_ > height_) {
+ /*if (p.y < 0 || p.y > height_) {
// The cursor is off-screen so recenter before proceeding.
showCursor();
p = getPos(cur);
if (scrolled)
processUpdateFlags(Update::Force);
- d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_,
+ d->text_metrics_[&buffer_.text()].editXY(cur, p.x, p.y,
true, act == LFUN_SCREEN_UP);
//FIXME: what to do with cur.x_target()?
bool update = in_texted && cur.bv().checkDepm(cur, old);
cur.finishUndo();
break;
}
- int y = getPos(cur).y_;
+ int y = getPos(cur).y;
int const ymin = y - height_ + defaultRowHeight();
while (y > ymin && cur.up())
- y = getPos(cur).y_;
+ y = getPos(cur).y;
cur.finishUndo();
dr.screenUpdate(Update::SinglePar | Update::FitCursor);
cur.finishUndo();
break;
}
- int y = getPos(cur).y_;
+ int y = getPos(cur).y;
int const ymax = y + height_ - defaultRowHeight();
while (y < ymax && cur.down())
- y = getPos(cur).y_;
+ y = getPos(cur).y;
cur.finishUndo();
dr.screenUpdate(Update::SinglePar | Update::FitCursor);
void BufferView::updateHoveredInset() const
{
// Get inset under mouse, if there is one.
- int const x = d->mouse_position_cache_.x_;
- int const y = d->mouse_position_cache_.y_;
+ int const x = d->mouse_position_cache_.x;
+ int const y = d->mouse_position_cache_.y;
Inset const * covering_inset = getCoveringInset(buffer_.text(), x, y);
if (covering_inset && covering_inset->asInsetMath()) {
Inset const * inner_inset = clickableMathInset(
if (need_redraw) {
LYXERR(Debug::PAINTING, "Mouse hover detected at: ("
- << d->mouse_position_cache_.x_ << ", "
- << d->mouse_position_cache_.y_ << ")");
+ << d->mouse_position_cache_.x << ", "
+ << d->mouse_position_cache_.y << ")");
d->update_strategy_ = DecorationUpdate;
// make sure we stay within the screen...
cmd.set_y(min(max(cmd.y(), -1), height_));
- d->mouse_position_cache_.x_ = cmd.x();
- d->mouse_position_cache_.y_ = cmd.y();
+ d->mouse_position_cache_.x = cmd.x();
+ d->mouse_position_cache_.y = cmd.y();
d->mouse_selecting_ =
cmd.action() == LFUN_MOUSE_MOTION && cmd.button() == mouse_button::button1;
// offset from outer paragraph
Point p = coordOffset(dit);
- p.y_ += tm.parMetrics(bot.pit()).position();
+ p.y += tm.parMetrics(bot.pit()).position();
return p;
}
p = getPos(cur);
// center fat carets horizontally
- p.x_ -= dim.wid / 2;
+ p.x -= dim.wid / 2;
// p is top-left
- p.y_ -= dim.asc;
+ p.y -= dim.asc;
}
bool const slant = fm.italic() && cur.inTexted() && !cur.selection();
double const slope = slant ? fm.italicSlope() : 0;
cg.shapes.push_back(
- {{iround(p.x_ + dim.asc * slope), p.y_},
- {iround(p.x_ - dim.des * slope), p.y_ + dim.height()},
- {iround(p.x_ + dir * dim.wid - dim.des * slope), p.y_ + dim.height()},
- {iround(p.x_ + dir * dim.wid + dim.asc * slope), p.y_}}
+ {{iround(p.x + dim.asc * slope), p.y},
+ {iround(p.x - dim.des * slope), p.y + dim.height()},
+ {iround(p.x + dir * dim.wid - dim.des * slope), p.y + dim.height()},
+ {iround(p.x + dir * dim.wid + dim.asc * slope), p.y}}
);
// The language indicator _| (if needed)
if (!((realfont.language() == doclang && isrtl == doclang->rightToLeft())
|| realfont.language() == latex_language)) {
int const lx = dim.height() / 3;
- int const xx = iround(p.x_ - dim.des * slope);
- int const yy = p.y_ + dim.height();
+ int const xx = iround(p.x - dim.des * slope);
+ int const yy = p.y + dim.height();
cg.shapes.push_back(
{{xx, yy - dim.wid},
{xx + dir * (dim.wid + lx - 1), yy - dim.wid},
// The completion triangle |> (if needed)
if (complet) {
- int const m = p.y_ + dim.height() / 2;
+ int const m = p.y + dim.height() / 2;
int const d = dim.height() / 8;
// offset for slanted carret
int const sx = iround((dim.asc - (dim.height() / 2 - d)) * slope);
// starting position x
- int const xx = p.x_ + dir * dim.wid + sx;
+ int const xx = p.x + dir * dim.wid + sx;
cg.shapes.push_back(
{{xx, m - d},
{xx + dir * d, m},
cg.bottom = -1000000;
for (auto const & shape : cg.shapes)
for (Point const & p : shape) {
- cg.left = min(cg.left, p.x_);
- cg.right = max(cg.right, p.x_);
- cg.top = min(cg.top, p.y_);
- cg.bottom = max(cg.bottom, p.y_);
+ cg.left = min(cg.left, p.x);
+ cg.right = max(cg.right, p.x);
+ cg.top = min(cg.top, p.y);
+ cg.bottom = max(cg.bottom, p.y);
}
}
caretPosAndDim(p, dim);
// does the cursor touch the screen ?
- if (p.y_ + dim.height() < 0 || p.y_ >= workHeight())
+ if (p.y + dim.height() < 0 || p.y >= workHeight())
return false;
return true;
}
setCurrentRowSlice(rowSlice);
// Current x position of the cursor in pixels
- int cur_x = getPos(d->cursor_).x_;
+ int cur_x = getPos(d->cursor_).x;
// Horizontal scroll offset of the cursor row in pixels
int offset = d->horiz_scroll_offset_;
if (!cur.inTexted())
break;
TextMetrics const & tm = textMetrics(cur.text());
- if (d->caret_geometry_.left >= tm.origin().x_
- && d->caret_geometry_.right <= tm.origin().x_ + tm.dim().width())
+ if (d->caret_geometry_.left >= tm.origin().x
+ && d->caret_geometry_.right <= tm.origin().x + tm.dim().width())
break;
cur.pop();
}
// (therefore it has type 'void *') (see bug #7376).
void const * inset = ccd.first;
Point const p = ccd.second.pos;
- LYXERR(Debug::PAINTING, "Inset " << inset << " has point " << p.x_ << "," << p.y_);
+ LYXERR(Debug::PAINTING, "Inset " << inset << " has point " << p.x << "," << p.y);
}
}
bool covers(int x, int y) const
{
- return x >= pos.x_
- && x <= pos.x_ + dim.wid
- && y >= pos.y_ - dim.asc
- && y <= pos.y_ + dim.des;
+ return x >= pos.x
+ && x <= pos.x + dim.wid
+ && y >= pos.y - dim.asc
+ && y <= pos.y + dim.des;
}
int squareDistance(int x, int y) const
int xx = 0;
int yy = 0;
- if (x < pos.x_)
- xx = pos.x_ - x;
- else if (x > pos.x_ + dim.wid)
- xx = x - pos.x_ - dim.wid;
+ if (x < pos.x)
+ xx = pos.x - x;
+ else if (x > pos.x + dim.wid)
+ xx = x - pos.x - dim.wid;
- if (y < pos.y_ - dim.asc)
- yy = pos.y_ - dim.asc - y;
- else if (y > pos.y_ + dim.des)
- yy = y - pos.y_ - dim.des;
+ if (y < pos.y - dim.asc)
+ yy = pos.y - dim.asc - y;
+ else if (y > pos.y + dim.des)
+ yy = y - pos.y - dim.des;
// Optimisation: We avoid to compute the sqrt on purpose.
return xx*xx + yy*yy;
int x(T const * thing) const
{
check(thing, "x");
- return data_.find(thing)->second.pos.x_;
+ return data_.find(thing)->second.pos.x;
}
int y(T const * thing) const
{
check(thing, "y");
- return data_.find(thing)->second.pos.y_;
+ return data_.find(thing)->second.pos.y;
}
Point xy(T const * thing) const
if (it == data_.end())
return false;
- return it->second.pos.x_ != -10000;
+ return it->second.pos.x != -10000;
}
bool hasDim(T const * thing) const
Point const o = insetCache.xy(inset);
inset->cursorPos(c.bv(), it.top(), c.boundary(), xo, yo);
// Convert to absolute
- xo += o.x_;
- yo += o.y_;
+ xo += o.x;
+ yo += o.y;
double d = (x - xo) * (x - xo) + (y - yo) * (y - yo);
// '<=' in order to take the last possible position
// this is important for clicking behind \sum in e.g. '\sum_i a'
void Cursor::getPos(int & x, int & y) const
{
Point p = bv().getPos(*this);
- x = p.x_;
- y = p.y_;
+ x = p.x;
+ y = p.y;
}
TextMetrics const & tm = bv_->textMetrics(text());
// Looking for extremities is like clicking on the left or the
// right of the row.
- int x = tm.origin().x_ + (left ? 0 : textRow().width());
+ int x = tm.origin().x + (left ? 0 : textRow().width());
bool b = false;
pos() = tm.getPosNearX(textRow(), x, b);
boundary(b);
// with and without selection are handled differently
if (!selection()) {
- int yo1 = bv().getPos(*this).y_;
+ int yo1 = bv().getPos(*this).y;
Cursor old = *this;
// To next/previous row
// FIXME: the y position is often guessed wrongly across styles and
return;
int const wid = insetCache.dim(inset).wid;
Point p = insetCache.xy(inset);
- if (x > p.x_ + (wid + 1) / 2)
+ if (x > p.x + (wid + 1) / 2)
posForward();
}
}
}
-Point::Point(int x, int y) : x_(x), y_(y)
+Point::Point(int px, int py) : x(px), y(py)
{
- LASSERT(x > -1000000, x_ = -1000000);
- LASSERT(x < 1000000, x_ = 1000000);
- LASSERT(y > -1000000, y_ = -1000000);
- LASSERT(y < 1000000, y_ = 1000000);
+ LASSERT(px > -1000000, x = -1000000);
+ LASSERT(px < 1000000, x = 1000000);
+ LASSERT(py > -1000000, y = -1000000);
+ LASSERT(py < 1000000, y = 1000000);
}
} // namespace lyx
Point() = default;
Point(int x, int y);
- int x_ = 0;
- int y_ = 0;
+ int x = 0;
+ int y = 0;
};
} // namespace lyx
{
frontend::NullPainter np;
PainterInfo pi(bv_, np);
- drawParagraph(pi, pit, origin_.x_, par_metrics_[pit].position());
+ drawParagraph(pi, pit, origin_.x, par_metrics_[pit].position());
}
/// For the main Text, it is possible that this pit is not
/// yet in the CoordCache when moving cursor up.
/// x Paragraph coordinate is always 0 for main text anyway.
- int const xo = origin_.x_;
+ int const xo = origin_.x;
x -= xo;
// Adapt to cursor row scroll offset if applicable.
if (par_metrics_.empty())
return;
- origin_.x_ = x;
- origin_.y_ = y;
+ origin_.x = x;
+ origin_.y = y;
y -= par_metrics_.begin()->second.ascent();
for (auto & pm_pair : par_metrics_) {
from.boundary(false);
Point lxy = cur.bv().getPos(from);
Point rxy = cur.bv().getPos(to);
- dim.wid = abs(rxy.x_ - lxy.x_);
+ dim.wid = abs(rxy.x - lxy.x);
// calculate position of word
- y = lxy.y_;
- x = min(rxy.x_, lxy.x_);
+ y = lxy.y;
+ x = min(rxy.x, lxy.x);
- //lyxerr << "wid=" << dim.width() << " x=" << x << " y=" << y << " lxy.x_=" << lxy.x_ << " rxy.x_=" << rxy.x_ << " word=" << word << std::endl;
+ //lyxerr << "wid=" << dim.width() << " x=" << x << " y=" << y << " lxy.x=" << lxy.x << " rxy.x=" << rxy.x << " word=" << word << std::endl;
//lyxerr << " wordstart=" << wordStart << " bvcur=" << bvcur << " cur=" << cur << std::endl;
}
Point point;
Dimension dim;
d->buffer_view_->caretPosAndDim(point, dim);
- int cur_x = point.x_ - dim.width();
- int cur_y = point.y_ + dim.height();
+ int cur_x = point.x - dim.width();
+ int cur_y = point.y + dim.height();
d->im_cursor_rect_ = QRectF(cur_x, (cur_y - dim.height()) , 1, dim.height() );
}
QPainterPath path;
for (Point const & p : shape) {
if (first) {
- path.moveTo(p.x_ - horiz_offset, p.y_);
+ path.moveTo(p.x - horiz_offset, p.y);
first = false;
} else
- path.lineTo(p.x_ - horiz_offset, p.y_);
+ path.lineTo(p.x - horiz_offset, p.y);
}
painter.fillPath(path, color);
}
Point point;
Dimension dim;
buffer_view_->caretPosAndDim(point, dim);
- int cur_x = point.x_ - dim.width();
- int cur_y = point.y_ + dim.height();
+ int cur_x = point.x - dim.width();
+ int cur_y = point.y + dim.height();
if (preedit_string_.empty()) {
// Chinese input methods may exit here just obtaining im_cursor_rect
dim.height() + preedit_lower_margin);
if (mod_anc.rem >= 0)
im_anchor_rect_ = QRectF(mod_anc.rem,
- point.y_ + (dim.height() + 1) * (mod_anc.quot - 1), 1,
+ point.y + (dim.height() + 1) * (mod_anc.quot - 1), 1,
dim.height() + preedit_lower_margin );
else
im_anchor_rect_ = QRectF(text_width + mod_anc.rem,
- point.y_ + (dim.height() + 1) * (mod_anc.quot - 2), 1,
+ point.y + (dim.height() + 1) * (mod_anc.quot - 2), 1,
dim.height() + preedit_lower_margin );
} else {
- im_cursor_rect_ = QRectF(point.x_, point.y_, 1, dim.height() + preedit_lower_margin);
+ im_cursor_rect_ = QRectF(point.x, point.y, 1, dim.height() + preedit_lower_margin);
im_anchor_rect_ = im_cursor_rect_;
}
// Urge platform input method to make inputMethodQuery to check the values
int yy = 0;
Inset const & inset = *tabular.cellInset(cell);
Point o = bv.coordCache().getInsets().xy(&inset);
- int const xbeg = o.x_ - tabular.textHOffset(cell);
+ int const xbeg = o.x - tabular.textHOffset(cell);
int const xend = xbeg + tabular.cellWidth(cell);
row_type const row = tabular.cellRow(cell);
- int const ybeg = o.y_ - tabular.rowAscent(row)
+ int const ybeg = o.y - tabular.rowAscent(row)
- tabular.interRowSpace(row) - tabular.textVOffset(cell);
int const yend = ybeg + tabular.cellHeight(cell);
dim.asc += 3;
// and position
- Point xy
- = cur.bv().coordCache().insets().xy(this);
- x = xy.x_;
- y = xy.y_;
+ Point xy = cur.bv().coordCache().insets().xy(this);
+ x = xy.x;
+ y = xy.y;
}
}
Point const pt2 = coord_cache.getInsets().xy(this);
//lyxerr << "retrieving position cache for MathData "
- // << pt.x_ << ' ' << pt.y_ << endl;
- x = pt.x_ - pt2.x_ + ar.pos2x(&bv, sl.pos());
- y = pt.y_ - pt2.y_;
-// lyxerr << "pt.y_ : " << pt.y_ << " pt2_.y_ : " << pt2.y_
+ // << pt.x << ' ' << pt.y << endl;
+ x = pt.x - pt2.x + ar.pos2x(&bv, sl.pos());
+ y = pt.y - pt2.y;
+// lyxerr << "pt.y : " << pt.y << " pt2_.y : " << pt2.y
// << " asc: " << ascent() << " des: " << descent()
// << " ar.asc: " << ar.ascent() << " ar.des: " << ar.descent() << endl;
// move cursor visually into empty cells ("blue rectangles");
// and position
Point xy = cur.bv().coordCache().insets().xy(inset);
- x = xy.x_;
- y = xy.y_;
+ x = xy.x;
+ y = xy.y;
}
{
Geometry const & g = bv.coordCache().getArrays().geometry(this);
- return g.pos.x_ + g.dim.wid / 2;
+ return g.pos.x + g.dim.wid / 2;
}
{
Geometry const & g = bv.coordCache().getArrays().geometry(this);
- return g.pos.y_ + (g.dim.des - g.dim.asc) / 2;
+ return g.pos.y + (g.dim.des - g.dim.asc) / 2;
}