Correctly paint the background of the instant preview of a displayed equation.

For a displayed equation, the height is artificially increased by a displayMargin() in InsetMathHull::metrics if it is a displayed equation and there is a preview. 

This extra height is not covered by the preview image and what one can see is the background as drawn by the MathHull inset. The color of this background should be either Color_mathbg or Color_background depending on whether the preview is shown or not.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32560 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-12-17 14:09:37 +00:00
parent 378d32bc06
commit 6b96abd211
8 changed files with 17 additions and 8 deletions

View File

@ -86,7 +86,7 @@ void PainterInfo::draw(int x, int y, docstring const & str)
ColorCode PainterInfo::backgroundColor(Inset const * inset, bool sel) const
{
ColorCode const color_bg = inset->backgroundColor();
ColorCode const color_bg = inset->backgroundColor(*this);
if (selected && sel)
// This inset is in a selection

View File

@ -540,7 +540,7 @@ void Inset::dump() const
}
ColorCode Inset::backgroundColor() const
ColorCode Inset::backgroundColor(PainterInfo const & /*pi*/) const
{
return Color_none;
}

View File

@ -511,7 +511,7 @@ public:
///
int scroll() const { return 0; }
///
virtual ColorCode backgroundColor() const;
virtual ColorCode backgroundColor(PainterInfo const &) const;
///
virtual ColorCode labelColor() const;
//

View File

@ -104,10 +104,10 @@ docstring const InsetBranch::buttonLabel(BufferView const & bv) const
}
ColorCode InsetBranch::backgroundColor() const
ColorCode InsetBranch::backgroundColor(PainterInfo const & pi) const
{
if (params_.branch.empty())
return Inset::backgroundColor();
return Inset::backgroundColor(pi);
// FIXME UNICODE
ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch));
if (c == Color_none)

View File

@ -66,7 +66,7 @@ private:
///
docstring const buttonLabel(BufferView const & bv) const;
///
ColorCode backgroundColor() const;
ColorCode backgroundColor(PainterInfo const &) const;
///
bool showInsetDialog(BufferView *) const;
///

View File

@ -127,7 +127,8 @@ public:
///
bool setMouseHover(bool mouse_hover);
///
ColorCode backgroundColor() const { return getLayout().bgcolor(); }
ColorCode backgroundColor(PainterInfo const &) const
{ return getLayout().bgcolor(); }
///
ColorCode labelColor() const { return getLayout().labelfont().color(); }
///

View File

@ -370,6 +370,14 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
}
ColorCode InsetMathHull::backgroundColor(PainterInfo const & pi) const
{
if (previewState(pi.base.bv))
return Color_background;
return Color_mathbg;
}
void InsetMathHull::drawBackground(PainterInfo & pi, int x, int y) const
{
Dimension const dim = dimension(*pi.base.bv);

View File

@ -58,7 +58,7 @@ public:
///
void label(row_type row, docstring const & label);
///
ColorCode backgroundColor() const { return Color_mathbg; }
ColorCode backgroundColor(PainterInfo const &) const;
///
void numbered(row_type row, bool num);
///