On Tue, 11 Sep 2007 08:15:11 +0300 Martin Vermeer <[EMAIL PROTECTED]> wrote:
> On Mon, Sep 10, 2007 at 10:42:32PM +0200, Andre Poenitz wrote: > > On Mon, Sep 10, 2007 at 10:44:01PM +0300, Martin Vermeer wrote: > > > OK for trunk? Here's a better one. - Martin
Index: src/mathed/InsetMathFrac.h =================================================================== --- src/mathed/InsetMathFrac.h (revision 20193) +++ src/mathed/InsetMathFrac.h (working copy) @@ -27,7 +27,8 @@ FRAC, OVER, ATOP, - NICEFRAC + NICEFRAC, + UNITFRAC }; /// Index: src/mathed/MathFactory.cpp =================================================================== --- src/mathed/MathFactory.cpp (revision 20193) +++ src/mathed/MathFactory.cpp (working copy) @@ -370,6 +370,8 @@ return MathAtom(new InsetMathFrac(InsetMathFrac::OVER)); if (s == "nicefrac") return MathAtom(new InsetMathFrac(InsetMathFrac::NICEFRAC)); + if (s == "unitfrac") + return MathAtom(new InsetMathFrac(InsetMathFrac::UNITFRAC)); //if (s == "infer") // return MathAtom(new MathInferInset); if (s == "atop") Index: src/mathed/InsetMathFrac.cpp =================================================================== --- src/mathed/InsetMathFrac.cpp (revision 20193) +++ src/mathed/InsetMathFrac.cpp (working copy) @@ -48,9 +48,11 @@ bool InsetMathFrac::metrics(MetricsInfo & mi, Dimension & dim) const { FracChanger dummy(mi.base); + if (kind_ == UNITFRAC) + ShapeChanger dummy2(mi.base.font, Font::UP_SHAPE); cell(0).metrics(mi); cell(1).metrics(mi); - if (kind_ == NICEFRAC) { + if (kind_ == NICEFRAC || kind_ == UNITFRAC) { dim.wid = cell(0).width() + cell(1).width() + 5; dim.asc = cell(0).height() + 5; dim.des = cell(1).height() - 5; @@ -72,7 +74,9 @@ setPosCache(pi, x, y); int m = x + dim_.wid / 2; FracChanger dummy(pi.base); - if (kind_ == NICEFRAC) { + if (kind_ == UNITFRAC) + ShapeChanger dummy2(pi.base.font, Font::UP_SHAPE); + if (kind_ == NICEFRAC || kind_ == UNITFRAC) { cell(0).draw(pi, x + 2, y - cell(0).descent() - 5); cell(1).draw(pi, x + cell(0).width() + 5, @@ -111,7 +115,7 @@ cell(0).drawT(pain, m - cell(0).width() / 2, y - cell(0).descent() - 1); cell(1).drawT(pain, m - cell(1).width() / 2, y + cell(1).ascent()); // ASCII art: ignore niceties - if (kind_ == FRAC || kind_ == OVER || kind_ == NICEFRAC) + if (kind_ == FRAC || kind_ == OVER || kind_ == NICEFRAC || kind_ == UNITFRAC) pain.horizontalLine(x, y, dim_.width()); } @@ -128,6 +132,7 @@ break; case FRAC: case NICEFRAC: + case UNITFRAC: InsetMathNest::write(os); break; } @@ -143,6 +148,8 @@ return from_ascii("over"); case NICEFRAC: return from_ascii("nicefrac"); + case UNITFRAC: + return from_ascii("unitfrac"); case ATOP: return from_ascii("atop"); } @@ -183,8 +190,8 @@ void InsetMathFrac::validate(LaTeXFeatures & features) const { - if (kind_ == NICEFRAC) - features.require("nicefrac"); + if (kind == NICEFRAC || kind_ == UNITFRAC) + features.require("units"); InsetMathNest::validate(features); } Index: src/LaTeXFeatures.cpp =================================================================== --- src/LaTeXFeatures.cpp (revision 20193) +++ src/LaTeXFeatures.cpp (working copy) @@ -405,7 +405,7 @@ "dvipost", "fancybox", "calc", - "nicefrac", + "units", "tipa", "framed", "pdfcolmk", Index: lib/ui/stdtoolbars.inc =================================================================== --- lib/ui/stdtoolbars.inc (revision 20175) +++ lib/ui/stdtoolbars.inc (working copy) @@ -273,7 +273,8 @@ Toolbar "frac-square" "Fractions" Item "Standard \\frac" "math-insert \frac" Item "No hor. line \\atop" "math-insert \atop" - Item "Nice \\nicefrac" "math-insert \nicefrac" + Item "Nice (3/4) \\nicefrac" "math-insert \nicefrac" + Item "Units (km/h) \\unitfrac" "math-insert \unitfrac" Item "Text frac (amsmath) \\tfrac" "math-insert \tfrac" Item "Display frac (amsmath) \\dfrac" "math-insert \dfrac" Item "Binomial \\choose" "math-insert \choose"