mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
coordinate cache IU
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8071 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7915d583c2
commit
6b22f0e423
@ -3,6 +3,9 @@
|
||||
|
||||
* inset.h: remove Inset::id_
|
||||
|
||||
* inset.h: top_x -> xo_, top_baseline -> yo_ to unify with mathed/*.[Ch]
|
||||
* *.[Ch]: adjust
|
||||
|
||||
2003-11-10 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* inset.[Ch]:
|
||||
|
@ -26,14 +26,14 @@ using std::string;
|
||||
|
||||
InsetOld::InsetOld()
|
||||
: InsetBase(),
|
||||
top_x(0), top_baseline(0), scx(0), owner_(0),
|
||||
xo_(0), yo_(0), scx(0), owner_(0),
|
||||
background_color_(LColor::inherit)
|
||||
{}
|
||||
|
||||
|
||||
InsetOld::InsetOld(InsetOld const & in)
|
||||
: InsetBase(),
|
||||
top_x(0), top_baseline(0), scx(0), owner_(0),
|
||||
xo_(0), yo_(0), scx(0), owner_(0),
|
||||
name_(in.name_), background_color_(in.background_color_)
|
||||
{}
|
||||
|
||||
|
@ -213,9 +213,9 @@ public:
|
||||
///
|
||||
LColor_color backgroundColor() const;
|
||||
///
|
||||
int x() const { return top_x; }
|
||||
int x() const { return xo_; }
|
||||
///
|
||||
int y() const { return top_baseline; }
|
||||
int y() const { return yo_; }
|
||||
///
|
||||
virtual void deleteLyXText(BufferView *, bool = true) const {}
|
||||
/// returns the actuall scroll-value
|
||||
@ -288,9 +288,9 @@ public:
|
||||
virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
|
||||
protected:
|
||||
///
|
||||
mutable int top_x;
|
||||
mutable int xo_;
|
||||
///
|
||||
mutable int top_baseline;
|
||||
mutable int yo_;
|
||||
///
|
||||
mutable int scx;
|
||||
///
|
||||
|
@ -146,8 +146,8 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y, bool inlined) const
|
||||
button_dim.y1 = -aa;
|
||||
button_dim.y2 = -aa + dim_collapsed.height();
|
||||
|
||||
top_x = x;
|
||||
top_baseline = y;
|
||||
xo_ = x;
|
||||
yo_ = y;
|
||||
|
||||
if (!isOpen()) {
|
||||
draw_collapsed(pi, x, y);
|
||||
@ -327,7 +327,7 @@ InsetCollapsable::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
|
||||
|
||||
int InsetCollapsable::insetInInsetY() const
|
||||
{
|
||||
return inset.y() - top_baseline + inset.insetInInsetY();
|
||||
return inset.y() - yo_ + inset.insetInInsetY();
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,6 +48,8 @@ void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetCommand::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
xo_ = x;
|
||||
yo_ = y;
|
||||
button_.draw(pi, x, y);
|
||||
}
|
||||
|
||||
|
@ -255,8 +255,8 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
||||
if (!owner())
|
||||
x += scroll();
|
||||
|
||||
top_x = x;
|
||||
top_baseline = y;
|
||||
xo_ = x;
|
||||
yo_ = y;
|
||||
x += ADD_TO_TABULAR_WIDTH;
|
||||
|
||||
int cell = 0;
|
||||
@ -474,7 +474,7 @@ void InsetTabular::edit(BufferView * bv, int x, int y)
|
||||
setPos(bv, x, y);
|
||||
clearSelection();
|
||||
finishUndo();
|
||||
int xx = cursorx_ - top_x + tabular.getBeginningOfTextInCell(actcell);
|
||||
int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell);
|
||||
bv->cursor().push(this);
|
||||
if (x > xx)
|
||||
activateCellInset(bv, x - xx, y - cursory_);
|
||||
@ -623,7 +623,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
|
||||
clearSelection();
|
||||
int column = actcol;
|
||||
if (bv->top_y() + bv->painter().paperHeight()
|
||||
< top_baseline + tabular.getHeightOfTabular())
|
||||
< yo_ + tabular.getHeightOfTabular())
|
||||
{
|
||||
bv->scrollDocView(bv->top_y() + bv->painter().paperHeight());
|
||||
actcell = tabular.getCellBelow(first_visible_cell) + column;
|
||||
@ -638,9 +638,9 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
|
||||
if (hs)
|
||||
clearSelection();
|
||||
int column = actcol;
|
||||
if (top_baseline < 0) {
|
||||
if (yo_ < 0) {
|
||||
bv->scrollDocView(bv->top_y() - bv->painter().paperHeight());
|
||||
if (top_baseline > 0)
|
||||
if (yo_ > 0)
|
||||
actcell = column;
|
||||
else
|
||||
actcell = tabular.getCellBelow(first_visible_cell) + column;
|
||||
@ -968,7 +968,7 @@ void InsetTabular::calculate_dimensions_of_cells(MetricsInfo & mi) const
|
||||
|
||||
void InsetTabular::getCursorPos(BufferView *, int & x, int & y) const
|
||||
{
|
||||
x = TEXT_TO_INSET_OFFSET + cursorx_ - top_x;
|
||||
x = TEXT_TO_INSET_OFFSET + cursorx_ - xo_;
|
||||
y = TEXT_TO_INSET_OFFSET + cursory_;
|
||||
}
|
||||
|
||||
@ -1015,7 +1015,7 @@ void InsetTabular::setPos(BufferView * bv, int x, int y) const
|
||||
lx += tabular.getWidthOfColumn(actcell + 1)
|
||||
+ tabular.getAdditionalWidth(actcell);
|
||||
|
||||
cursorx_ = lx - tabular.getWidthOfColumn(actcell) + top_x + 2;
|
||||
cursorx_ = lx - tabular.getWidthOfColumn(actcell) + xo_ + 2;
|
||||
resetPos(bv);
|
||||
}
|
||||
|
||||
@ -1030,7 +1030,7 @@ int InsetTabular::getCellXPos(int cell) const
|
||||
for (; c < cell; ++c)
|
||||
lx += tabular.getWidthOfColumn(c);
|
||||
|
||||
return lx - tabular.getWidthOfColumn(cell) + top_x;
|
||||
return lx - tabular.getWidthOfColumn(cell) + xo_;
|
||||
}
|
||||
|
||||
|
||||
@ -1091,8 +1091,8 @@ void InsetTabular::resetPos(BufferView * bv) const
|
||||
} else if (cursorx_ - offset < 20) {
|
||||
scroll(bv, 20 - cursorx_ + offset);
|
||||
updateLocal(bv);
|
||||
} else if (scroll() && top_x > 20 &&
|
||||
top_x + tabular.getWidthOfTabular() > bv->workWidth() - 20) {
|
||||
} else if (scroll() && xo_ > 20 &&
|
||||
xo_ + tabular.getWidthOfTabular() > bv->workWidth() - 20) {
|
||||
scroll(bv, old_x - cursorx_);
|
||||
updateLocal(bv);
|
||||
}
|
||||
|
@ -241,8 +241,8 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
// update our idea of where we are. Clearly, we should
|
||||
// not have to know this information.
|
||||
top_x = x;
|
||||
top_baseline = y;
|
||||
xo_ = x;
|
||||
yo_ = y;
|
||||
|
||||
int const start_x = x;
|
||||
|
||||
@ -271,7 +271,7 @@ void InsetText::drawFrame(Painter & pain, int x) const
|
||||
{
|
||||
int const ttoD2 = TEXT_TO_INSET_OFFSET / 2;
|
||||
int const frame_x = x + ttoD2;
|
||||
int const frame_y = top_baseline - dim_.asc + ttoD2;
|
||||
int const frame_y = yo_ - dim_.asc + ttoD2;
|
||||
int const frame_w = dim_.wid - TEXT_TO_INSET_OFFSET;
|
||||
int const frame_h = dim_.asc + dim_.des - TEXT_TO_INSET_OFFSET;
|
||||
pain.rectangle(frame_x, frame_y, frame_w, frame_h, frameColor());
|
||||
@ -689,7 +689,7 @@ void InsetText::validate(LaTeXFeatures & features) const
|
||||
|
||||
void InsetText::getCursorPos(BufferView *, int & x, int & y) const
|
||||
{
|
||||
x = cx() - top_x;
|
||||
x = cx() - xo_;
|
||||
y = cy();
|
||||
}
|
||||
|
||||
@ -918,7 +918,7 @@ void InsetText::setFrameColor(LColor_color col)
|
||||
|
||||
int InsetText::cx() const
|
||||
{
|
||||
return text_.cursor.x() + top_x + TEXT_TO_INSET_OFFSET;
|
||||
return text_.cursor.x() + xo_ + TEXT_TO_INSET_OFFSET;
|
||||
}
|
||||
|
||||
|
||||
@ -1006,7 +1006,7 @@ void InsetText::clearInset(BufferView * bv, int start_x, int baseline) const
|
||||
}
|
||||
if (ty + h > pain.paperHeight())
|
||||
h = pain.paperHeight();
|
||||
if (top_x + w > pain.paperWidth())
|
||||
if (xo_ + w > pain.paperWidth())
|
||||
w = pain.paperWidth();
|
||||
pain.fillRectangle(start_x + 1, ty + 1, w - 3, h - 1, backgroundColor());
|
||||
}
|
||||
|
@ -80,10 +80,6 @@ InsetTOC::priv_dispatch(FuncRequest const & cmd,
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (button().box().contains(cmd.x, cmd.y))
|
||||
InsetCommandMailer("toc", *this).showDialog(cmd.view());
|
||||
return DispatchResult(true, true);
|
||||
|
||||
case LFUN_INSET_DIALOG_SHOW:
|
||||
InsetCommandMailer("toc", *this).showDialog(cmd.view());
|
||||
return DispatchResult(true, true);
|
||||
|
@ -47,37 +47,37 @@ void UpdatableInset::scroll(BufferView * bv, float s) const
|
||||
}
|
||||
|
||||
int const workW = bv->workWidth();
|
||||
int const tmp_top_x = top_x - scx;
|
||||
int const tmp_xo_ = xo_ - scx;
|
||||
|
||||
if (tmp_top_x > 0 && tmp_top_x + width() < workW)
|
||||
if (tmp_xo_ > 0 && tmp_xo_ + width() < workW)
|
||||
return;
|
||||
if (s > 0 && top_x > 0)
|
||||
if (s > 0 && xo_ > 0)
|
||||
return;
|
||||
|
||||
scx = int(s * workW / 2);
|
||||
|
||||
#warning metrics?
|
||||
if (tmp_top_x + scx + width() < workW / 2)
|
||||
scx = workW / 2 - tmp_top_x - width();
|
||||
if (tmp_xo_ + scx + width() < workW / 2)
|
||||
scx = workW / 2 - tmp_xo_ - width();
|
||||
}
|
||||
|
||||
|
||||
void UpdatableInset::scroll(BufferView * bv, int offset) const
|
||||
{
|
||||
if (offset > 0) {
|
||||
if (!scx && top_x >= 20)
|
||||
if (!scx && xo_ >= 20)
|
||||
return;
|
||||
if (top_x + offset > 20)
|
||||
if (xo_ + offset > 20)
|
||||
scx = 0;
|
||||
// scx = - top_x;
|
||||
// scx = - xo_;
|
||||
else
|
||||
scx += offset;
|
||||
} else {
|
||||
#warning metrics?
|
||||
if (!scx && top_x + width() < bv->workWidth() - 20)
|
||||
if (!scx && xo_ + width() < bv->workWidth() - 20)
|
||||
return;
|
||||
if (top_x - scx + offset + width() < bv->workWidth() - 20) {
|
||||
scx += bv->workWidth() - width() - top_x - 20;
|
||||
if (xo_ - scx + offset + width() < bv->workWidth() - 20) {
|
||||
scx += bv->workWidth() - width() - xo_ - 20;
|
||||
} else {
|
||||
scx += offset;
|
||||
}
|
||||
|
@ -195,6 +195,9 @@ bool editing_inset(InsetFormula const * inset)
|
||||
|
||||
void InsetFormula::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
xo_ = x;
|
||||
yo_ = y;
|
||||
|
||||
// The previews are drawn only when we're not editing the inset.
|
||||
bool const use_preview = !editing_inset(this)
|
||||
&& RenderPreview::activated()
|
||||
@ -224,13 +227,6 @@ void InsetFormula::draw(PainterInfo & pi, int x, int y) const
|
||||
|
||||
par_->draw(p, x, y);
|
||||
}
|
||||
|
||||
xo_ = x;
|
||||
yo_ = y;
|
||||
|
||||
top_x = x;
|
||||
top_baseline = y;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,7 +78,6 @@ bool openNewInset(BufferView * bv, UpdatableInset * inset)
|
||||
|
||||
|
||||
InsetFormulaBase::InsetFormulaBase()
|
||||
: xo_(0), yo_(0)
|
||||
{
|
||||
// This is needed as long the math parser is not re-entrant
|
||||
initMath();
|
||||
@ -173,12 +172,10 @@ void InsetFormulaBase::getCursor(BufferView &, int & x, int & y) const
|
||||
|
||||
void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const
|
||||
{
|
||||
// calling metrics here destroys the cached xo,yo positions e.g. in
|
||||
// MathParboxinset. And it would be too expensive anyway...
|
||||
//metrics(bv);
|
||||
if (!mathcursor) {
|
||||
lyxerr << "getCursorPos - should not happen";
|
||||
x = y = 0;
|
||||
x = 0;
|
||||
y = 0;
|
||||
return;
|
||||
}
|
||||
mathcursor->getPos(x, y);
|
||||
|
@ -116,11 +116,6 @@ protected:
|
||||
void handleFont(BufferView * bv, std::string const & arg, std::string const & font);
|
||||
///
|
||||
void handleFont2(BufferView * bv, std::string const & arg);
|
||||
|
||||
///
|
||||
mutable int xo_;
|
||||
///
|
||||
mutable int yo_;
|
||||
};
|
||||
|
||||
// We don't really mess want around with mathed stuff outside mathed.
|
||||
|
Loading…
Reference in New Issue
Block a user