]> git.lyx.org Git - lyx.git/commitdiff
Re-introduce display() for insets, fixing various bugs
authorMartin Vermeer <martin.vermeer@hut.fi>
Mon, 20 Oct 2003 18:56:48 +0000 (18:56 +0000)
committerMartin Vermeer <martin.vermeer@hut.fi>
Mon, 20 Oct 2003 18:56:48 +0000 (18:56 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7940 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/insets/ChangeLog
src/insets/inset.h
src/insets/insetfloat.h
src/insets/insetfootlike.h
src/mathed/ChangeLog
src/mathed/formula.C
src/mathed/formula.h
src/text.C

index c941076080c89cfa3d7856954f5c00d54492780f..054943975597c6fa95785a98cba4ae7acaa1e2c1 100644 (file)
@@ -1,3 +1,9 @@
+2003-10-20  Martin Vermeer  <martin.vermeer@hut.fi>
+
+       * text.C: re-introduce display() for insets, fixing the
+       various bugs (stretch of line above, math inset 
+       positioning, ...)
+
 2003-10-20  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * text.C (rightMargin): remove spurious semicolon
index 801084977654365c49b013536b263e135488607a..eb25292ab985cc011e178d42c08afe50339e5da4 100644 (file)
@@ -1,3 +1,11 @@
+2003-10-20  Martin Vermeer  <martin.vermeer@hut.fi>
+
+       * inset.h:
+       * insetfloat.h:
+       * insetfootlike.h: re-introduce display() for insets, 
+       fixing the various bugs (stretch of line above, math inset
+       positioning, ...)
+
 2003-10-17  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * insetbase.C (dispatch): new func
index 7fd12af7bf54039730e8142b86c48fe13a1bebfd..cb0a3850a861d44df4b6857baa62902a69ee3093 100644 (file)
@@ -274,6 +274,8 @@ public:
        // is this equivalent to a space (which is BTW different from
        // a line separator)?
        virtual bool isSpace() const { return false; }
+       // should we have a non-filled line before this inset?
+       virtual bool display() const { return false; }
        // should we break lines after this inset?
        virtual bool isLineSeparator() const { return false; }
        // if this inset has paragraphs should they be output all as default
index 5416845ac27d83000f1aa3c9334471d6ea473a3f..2ffa79218e9ba33f6ad07477ab3320f3c615b75d 100644 (file)
@@ -45,6 +45,8 @@ public:
        ///
        ~InsetFloat();
        ///
+       virtual bool display() const { return true; }
+       ///
        void write(Buffer const & buf, std::ostream & os) const;
        ///
        void read(Buffer const & buf, LyXLex & lex);
index c6489f53d399b392d87e7c1b3578451f2cefde47..12615d57a080ecddf6ad23a31f24a85b98288c13 100644 (file)
@@ -28,6 +28,8 @@ public:
        ///
        void write(Buffer const & buf, std::ostream & os) const;
        ///
+       bool display() const { return true; }
+       ///
        bool insetAllowed(InsetOld::Code) const;
        /** returns true if, when outputing LaTeX, font changes should
            be closed before generating this inset. This is needed for
index 514983b19fdef4a5d3b19696ee3df14f3e4fa162..7c349a3c562d05018b06e4170187f3a7495d3a14 100644 (file)
@@ -1,3 +1,9 @@
+2003-10-20  Martin Vermeer  <martin.vermeer@hut.fi>
+
+       * formula.[Ch]: re-introduce display() for insets, fixing the
+       various bugs (stretch of line above, math inset
+       positioning, ...)
+
 2003-10-17  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * ref_inset.C (priv_dispatch): take the code from localDispatch
index e6c7cf1939b6943953da6831336744079b8e0ef4..f5abd3aef2616ced0439792f8f1f1499f410e222 100644 (file)
@@ -219,7 +219,7 @@ void InsetFormula::draw(PainterInfo & pi, int x, int y) const
                        //p.pain.rectangle(x, y - a, w, h, LColor::mathframe);
                }
 
-               par_->draw(p, x + offset_, y);
+               par_->draw(p, x, y);
        }
 
        xo_ = x;
@@ -276,13 +276,6 @@ void InsetFormula::metrics(MetricsInfo & m, Dimension & dim) const
                dim.des += 1;
        }
 
-       if (display()) {
-               offset_ = (m.base.textwidth - dim.wid) / 2;
-               dim.wid = m.base.textwidth;
-       } else {
-               offset_ = 0;
-       }
-
        dim_ = dim;
 }
 
index 6a26dce01e3f92a2dc284ccac7ae912ec8124510..2f8642f521174ef2cde3b77a9221a4e2cd9dbc88 100644 (file)
@@ -83,8 +83,6 @@ private:
 
        /// contents
        MathAtom par_;
-       /// x offset for drawing displayed formula
-       mutable int offset_;
 
        /// The pointer never changes although *preview_'s contents may.
        boost::scoped_ptr<RenderPreview> const preview_;
index 0620599b0ed544689f5bf425261f6a9424c9b4ef..a3c33d9f8b6ba5d2a15b962d96104931738b44b3 100644 (file)
@@ -691,6 +691,21 @@ pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit,
                        point = i;
                        break;
                }
+               InsetOld * in;
+               // Break before...      
+               if (i + 1 < last) {
+                       in = pit->getInset(i + 1);
+                       if (in && in->display()) {
+                               point = i;
+                               break;
+                       }
+                       // ...and after.
+                       in = pit->getInset(i);
+                       if (in && in->display()) {
+                               point = i;
+                               break;
+                       }
+               }
 
                char const c = pit->getChar(i);
                if (i > endPosOfFontSpan) {
@@ -716,7 +731,7 @@ pos_type LyXText::rowBreakPoint(ParagraphList::iterator pit,
                x += thiswidth;
                chunkwidth += thiswidth;
 
-               InsetOld * in = pit->isInset(i) ? pit->getInset(i) : 0;
+               in = pit->getInset(i);
 
                // break before a character that will fall off
                // the right of the row
@@ -1445,14 +1460,32 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
                        align = LYX_ALIGN_LEFT;
                }
 
+               // Display-style insets should always be on a centred row
+               // (Simplify this to inset = pit->getInset(rit->pos()) once
+               // the "bit silly" bug is fixed, MV)
+               inset = pit->isInset(rit->pos()) ? pit->getInset(rit->pos()) : 0;
+               if (inset && inset->display()) {
+                       align = LYX_ALIGN_CENTER;
+               }
+               
                switch (align) {
            case LYX_ALIGN_BLOCK:
                {
                        int const ns = numberOfSeparators(*pit, *rit);
                        RowList::iterator next_row = boost::next(rit);
+                       bool disp_inset = false;
+                       if (next_row != pit->rows.end()) {
+                               InsetOld * in = pit->getInset(next_row->pos());
+                               if (in)
+                                       disp_inset = in->display();
+                       }
+                       // If we have separators, this is not the last row of a
+                       // par, does not end in newline, and is not row above a
+                       // display inset... then stretch it
                        if (ns
                                && next_row != pit->rows.end()
                                && !pit->isNewline(next_row->pos() - 1)
+                               && !disp_inset
                                ) {
                                        fill_separator = w / ns;
                        } else if (is_rtl) {