]> git.lyx.org Git - features.git/commitdiff
coordinate cache IU
authorAndré Pönitz <poenitz@gmx.net>
Mon, 10 Nov 2003 15:38:20 +0000 (15:38 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Mon, 10 Nov 2003 15:38:20 +0000 (15:38 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8071 a592a061-630c-0410-9148-cb99ea01b6c8

12 files changed:
src/insets/ChangeLog
src/insets/inset.C
src/insets/inset.h
src/insets/insetcollapsable.C
src/insets/insetcommand.C
src/insets/insettabular.C
src/insets/insettext.C
src/insets/insettoc.C
src/insets/updatableinset.C
src/mathed/formula.C
src/mathed/formulabase.C
src/mathed/formulabase.h

index 6db96b2093212016594c35bde1a2876758e297b9..7c6dab1af8e276691bf2166721f5a0b543e49484 100644 (file)
@@ -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]:
index ea46d9fd8eeb7c20c60ae26e04507ad2f1424f8e..f5337089679ead6a6172d8d3c9aaa231239911ae 100644 (file)
@@ -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_)
 {}
 
index c4240756b60be050370940f82d0005dd88ba945a..0a477651bed50045e3f33c7ef43ecf0161b99dc3 100644 (file)
@@ -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;
        ///
index c129f3c96711a46f402471dbeb6e8c4a73329523..e7313e0ab12251483e0e46448e7382c01cc0f323 100644 (file)
@@ -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();
 }
 
 
index 207a56d2e771af9fa8b765ba6d9dbe642da6ad78..713fbd35555880a7fe2f11a22300f6c281b34853 100644 (file)
@@ -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);
 }
 
index d293e1d61108071f9ef53a4ce40d09301db950fb..e0fec53c006e2bc78c5a0f8b5ea288d3b74e4961 100644 (file)
@@ -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);
        }
index a871874b53ea8baa5eb6d435528fd7e3173cb04b..56a718e4e26fa3b358a9ba0f7530c1775ee177fe 100644 (file)
@@ -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());
 }
index c345421baad024de2889a59498dc645728d56ad2..4811e1d1d0f96d98386e948b8f282f7bfe05b4b9 100644 (file)
@@ -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);
index 0bc7e235d3ebdb38895b6a21f1a9e72ddd7bbcd1..8463104b8ddbbf2848ae1e547e73f7b03b374985 100644 (file)
@@ -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;
                }
index b6d94ee06583359a29c3fd4c5b11f284f5537669..5c3a71e4939dc190c4e0993a266ba53131f04ac6 100644 (file)
@@ -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;
-
 }
 
 
index 1ce996a4e54b177c14dcd9e56b8f60dce4963b57..7ba15987d9565ebc01ed7797790960723f68c5dc 100644 (file)
@@ -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);
index 3f93f4c452fd8084ecc988a76ec60d2298111db2..f79f69662d8faef4daf0566eb8b8752c1fb76146 100644 (file)
@@ -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.