Remove trailing underscore on members x and y of Point class.

These members are not private.
This commit is contained in:
Jean-Marc Lasgouttes 2024-06-20 14:28:45 +02:00
parent b78d2a4eda
commit c7c16fe9fa
12 changed files with 97 additions and 98 deletions

View File

@ -511,7 +511,7 @@ bool BufferView::needsFitCursor() const
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;
@ -844,7 +844,7 @@ void BufferView::setCursorFromScrollbar()
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;
@ -885,9 +885,9 @@ Change const BufferView::getCurrentChange() const
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;
}
@ -1060,7 +1060,7 @@ bool BufferView::scrollToCursor(DocIterator const & dit, ScrollType how)
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 =
@ -1100,7 +1100,7 @@ bool BufferView::scrollToCursor(DocIterator const & dit, ScrollType how)
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;
@ -2064,7 +2064,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
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);
@ -2082,7 +2082,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
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);
@ -2127,10 +2127,10 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
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);
@ -2145,10 +2145,10 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
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);
@ -2609,8 +2609,8 @@ Inset const * BufferView::clickableMathInset(InsetMathNest const * inset,
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(
@ -2643,8 +2643,8 @@ void BufferView::updateHoveredInset() const
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;
@ -2706,8 +2706,8 @@ void BufferView::mouseEventDispatch(FuncRequest const & cmd0)
// 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;
@ -3419,7 +3419,7 @@ Point BufferView::getPos(DocIterator const & dit) const
// offset from outer paragraph
Point p = coordOffset(dit);
p.y_ += tm.parMetrics(bot.pit()).position();
p.y += tm.parMetrics(bot.pit()).position();
return p;
}
@ -3453,9 +3453,9 @@ void BufferView::caretPosAndDim(Point & p, Dimension & dim) const
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;
}
@ -3479,10 +3479,10 @@ void BufferView::buildCaretGeometry(bool complet)
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)
@ -3490,8 +3490,8 @@ void BufferView::buildCaretGeometry(bool complet)
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},
@ -3502,12 +3502,12 @@ void BufferView::buildCaretGeometry(bool complet)
// 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},
@ -3525,10 +3525,10 @@ void BufferView::buildCaretGeometry(bool complet)
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);
}
}
@ -3548,7 +3548,7 @@ bool BufferView::caretInView() const
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;
}
@ -3616,7 +3616,7 @@ void BufferView::checkCursorScrollOffset()
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_;
@ -3779,8 +3779,8 @@ void BufferView::draw(frontend::Painter & pain, bool paint_caret)
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();
}

View File

@ -48,7 +48,7 @@ void CoordCache::dump() const
// (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);
}
}

View File

@ -31,10 +31,10 @@ struct Geometry {
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
@ -42,15 +42,15 @@ struct Geometry {
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;
@ -101,13 +101,13 @@ public:
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
@ -122,7 +122,7 @@ public:
if (it == data_.end())
return false;
return it->second.pos.x_ != -10000;
return it->second.pos.x != -10000;
}
bool hasDim(T const * thing) const

View File

@ -93,8 +93,8 @@ DocIterator bruteFind(Cursor const & c, int x, int y)
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'
@ -968,8 +968,8 @@ bool Cursor::popForward()
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;
}
@ -1331,7 +1331,7 @@ void Cursor::posVisToRowExtremity(bool left)
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);
@ -2236,7 +2236,7 @@ bool Cursor::upDownInText(bool up)
// 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
@ -2565,7 +2565,7 @@ void Cursor::moveToClosestEdge(int const x, bool const edit)
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();
}
}

View File

@ -26,12 +26,12 @@ void Dimension::operator+=(Dimension const & dim)
}
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

View File

@ -80,8 +80,8 @@ public:
Point() = default;
Point(int x, int y);
int x_ = 0;
int y_ = 0;
int x = 0;
int y = 0;
};
} // namespace lyx

View File

@ -334,7 +334,7 @@ void TextMetrics::updatePosCache(pit_type pit) const
{
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());
}
@ -1435,7 +1435,7 @@ pos_type TextMetrics::getPosNearX(Row const & row, int & x,
/// 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.
@ -2041,8 +2041,8 @@ void TextMetrics::draw(PainterInfo & pi, int x, int y) const
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_) {
@ -2267,13 +2267,13 @@ void TextMetrics::completionPosAndDim(Cursor const & cur, int & x, int & y,
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;
}

View File

@ -223,8 +223,8 @@ void GuiWorkArea::init()
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() );
}
@ -555,10 +555,10 @@ void GuiWorkArea::Private::drawCaret(QPainter & painter, int horiz_offset) const
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);
}
@ -1197,8 +1197,8 @@ void GuiWorkArea::Private::paintPreeditText(GuiPainter & pain)
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
@ -1323,14 +1323,14 @@ void GuiWorkArea::Private::paintPreeditText(GuiPainter & pain)
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

View File

@ -6389,10 +6389,10 @@ int InsetTabular::dist(BufferView & bv, idx_type const cell, int x, int y) const
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);

View File

@ -1476,10 +1476,9 @@ void InsetMathMacro::completionPosAndDim(Cursor const & cur, int & x, int & y,
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;
}

View File

@ -165,10 +165,10 @@ void InsetMathNest::cursorPos(BufferView const & bv,
}
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");
@ -2464,8 +2464,8 @@ void InsetMathNest::completionPosAndDim(Cursor const & cur, int & x, int & y,
// and position
Point xy = cur.bv().coordCache().insets().xy(inset);
x = xy.x_;
y = xy.y_;
x = xy.x;
y = xy.y;
}

View File

@ -981,7 +981,7 @@ int MathData::xm(BufferView const & bv) const
{
Geometry const & g = bv.coordCache().getArrays().geometry(this);
return g.pos.x_ + g.dim.wid / 2;
return g.pos.x + g.dim.wid / 2;
}
@ -989,7 +989,7 @@ int MathData::ym(BufferView const & bv) const
{
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;
}