]> git.lyx.org Git - features.git/commitdiff
make on-screen appearance of nested delimiters closer to what LaTeX does
authorAndré Pönitz <poenitz@gmx.net>
Wed, 15 Aug 2001 06:53:25 +0000 (06:53 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 15 Aug 2001 06:53:25 +0000 (06:53 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2514 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_decorationinset.C
src/mathed/math_decorationinset.h
src/mathed/math_deliminset.C

index 469a28883796b33706fec57853993b3d51fb3591..f6c733352547a20212544183228d051c6099aa19 100644 (file)
@@ -14,7 +14,6 @@ using std::ostream;
 MathDecorationInset::MathDecorationInset(latexkeys const * key)
        : MathNestInset(1), key_(key)
 {
-       upper_ = key_->id != LM_underline && key_->id != LM_underbrace;
 }
 
 
@@ -24,6 +23,21 @@ MathInset * MathDecorationInset::clone() const
 }
 
 
+bool MathDecorationInset::upper() const
+{
+       return key_->id != LM_underline && key_->id != LM_underbrace;
+}
+
+
+bool MathDecorationInset::protect() const
+{
+       return
+                       key_->name == "overbrace" ||
+                       key_->name == "underbrace" ||
+                       key_->name == "overleftarrow" ||
+                       key_->name == "overrightarrow";
+}
+
 
 void MathDecorationInset::metrics(MathStyles st) const
 {
@@ -35,7 +49,7 @@ void MathDecorationInset::metrics(MathStyles st) const
 
        dh_ = 5; //mathed_char_height(LM_TC_VAR, size(), 'I', ascent_, descent_);  
 
-       if (upper_) {
+       if (upper()) {
                dy_ = -ascent_ - dh_;
                ascent_ += dh_ + 1;
        } else {
@@ -63,11 +77,7 @@ void MathDecorationInset::draw(Painter & pain, int x, int y) const
 void MathDecorationInset::write(ostream & os, bool fragile) const
 {
        string name = key_->name;
-       if (fragile &&
-                       (name == "overbrace" ||
-                        name == "underbrace" ||
-                        name == "overleftarrow" ||
-                        name == "overrightarrow"))
+       if (fragile && protect())
                os << "\\protect";
        os << '\\' << name;
 
@@ -82,6 +92,7 @@ void MathDecorationInset::write(ostream & os, bool fragile) const
                os << '}';
 }
 
+
 void MathDecorationInset::writeNormal(ostream & os) const
 {
        os << "[" << key_->name << " ";
index 98cd9058c7c94df15c99eb06120aafb9b08d98a9..54024c14d8a20f7ba488804da587cdb1d5c248a2 100644 (file)
@@ -28,11 +28,15 @@ public:
        void metrics(MathStyles st) const;
        ///
        void writeNormal(std::ostream & os) const;
+
 private:
        ///
-       latexkeys const * key_;
+       bool upper() const;
        ///
-       bool upper_;
+       bool protect() const;
+
+       ///
+       latexkeys const * key_;
        /// height cache of deco
        mutable int dh_;
        /// vertical offset cache of deco
index f5cbc7b2f495c03a3b46f33d70b70e00d6dbb681..1f46ecf5b5bad39dc3cbe4cfac9c15079b6a95bf 100644 (file)
@@ -50,46 +50,46 @@ void MathDelimInset::write(std::ostream & os, bool fragile) const
 }
 
 
+int MathDelimInset::dw() const
+{
+       int w = height() / 5;
+       if (w > 15)
+               w = 15;
+       if (w < 4)
+               w = 4;
+       return w;
+}
+
+
+void MathDelimInset::metrics(MathStyles st) const
+{
+       xcell(0).metrics(st);
+       size_    = st;
+       ascent_  = std::max(xcell(0).ascent(), mathed_char_ascent(LM_TC_VAR, st,'I'));
+       descent_ = xcell(0).descent();
+       width_   = xcell(0).width() + 2 * dw() + 4;
+}
+
+
 void MathDelimInset::draw(Painter & pain, int x, int y) const
 { 
        xo(x);
        yo(y); 
 
        int w = dw();
-       xcell(0).draw(pain, x + w, y);
+       xcell(0).draw(pain, x + w + 2, y);
        
        if (latexName(left_) == ".") {
-               pain.line(x + 4, yo() - ascent_, x + 4, yo() + descent_,
+               pain.line(x + 2, yo() - ascent_, x + 2, yo() + descent_,
                          LColor::mathcursor, Painter::line_onoffdash);
        } else
-               mathed_draw_deco(pain, x, y - ascent_, w, height(), left_);
+               mathed_draw_deco(pain, x, y - ascent_ - 2, w, height() + 4, left_);
 
-       x += width() - w - 2;
+       x += width();
 
        if (latexName(right_) == ".") {
-               pain.line(x + 4, yo() - ascent_, x + 4, yo() + descent_,
+               pain.line(x + 2, yo() - ascent_, x + 2, yo() + descent_,
                          LColor::mathcursor, Painter::line_onoffdash);
        } else
-               mathed_draw_deco(pain, x, y - ascent_, w, height(), right_);
-}
-
-
-int MathDelimInset::dw() const
-{
-       int w = height()/5;
-       if (w > 15)
-               w = 15;
-       if (w < 6)
-               w = 6;
-       return w;
-}
-
-
-void MathDelimInset::metrics(MathStyles st) const
-{
-       xcell(0).metrics(st);
-       size_    = st;
-       ascent_  = xcell(0).ascent() + 2;
-       descent_ = xcell(0).descent() + 2;
-       width_   = xcell(0).width() + 2 * dw() + 4;
+               mathed_draw_deco(pain, x - dw(), y - ascent_ - 2, w, height() + 4, right_);
 }