A more radical approach to inset background painting

Now by default all insets paint their own background when needed. This
means that 63cf3297 and part of 9940acc5 can be reverted.

To avoid extra painting, background drawing is disabled for
InsetCommand and InsetCollapsable. These insets draw background as
part of their normal drawing activity.

This will avoid drawing artifacts with InsetNewpage, InsetVSpace and
probably some others.
This commit is contained in:
Jean-Marc Lasgouttes 2016-08-17 11:21:38 +02:00
parent 6f82f51cbe
commit e194c9ce27
10 changed files with 15 additions and 38 deletions

View File

@ -520,6 +520,16 @@ void Inset::metricsMarkers2(Dimension & dim, int framesize) const
}
void Inset::drawBackground(PainterInfo & pi, int x, int y) const
{
if (pi.full_repaint && backgroundColor(pi) == Color_none)
return;
Dimension const dim = dimension(*pi.base.bv);
pi.pain.fillRectangle(x, y - dim.asc, dim.wid, dim.asc + dim.des,
pi.backgroundColor(this));
}
void Inset::drawMarkers(PainterInfo & pi, int x, int y) const
{
ColorCode pen_color = mouseHovered(pi.base.bv) || editing(pi.base.bv)?

View File

@ -190,7 +190,7 @@ public:
virtual void drawSelection(PainterInfo &, int, int) const {}
/// draw inset background if the inset has an own background and a
/// selection is drawn by drawSelection.
virtual void drawBackground(PainterInfo &, int, int) const {}
virtual void drawBackground(PainterInfo &, int, int) const;
///
virtual bool editing(BufferView const * bv) const;
///

View File

@ -54,6 +54,8 @@ public:
void metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///
virtual void drawBackground(PainterInfo &, int, int) const {}
/// return x,y of given position relative to the inset's baseline
void cursorPos(BufferView const & bv, CursorSlice const & sl,

View File

@ -78,6 +78,8 @@ public:
///
void draw(PainterInfo & pi, int x, int y) const;
///
virtual void drawBackground(PainterInfo &, int, int) const {}
///
void latex(otexstream &, OutputParams const &) const;
///
int plaintext(odocstringstream & ods, OutputParams const & op,

View File

@ -211,16 +211,6 @@ void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const
}
void InsetQuotes::drawBackground(PainterInfo & pi, int x, int y) const
{
if (pi.full_repaint)
return;
Dimension const dim = dimension(*pi.base.bv);
pi.pain.fillRectangle(x, y - dim.asc, dim.wid, dim.asc + dim.des,
pi.backgroundColor(this));
}
void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
{
FontInfo font = pi.base.font;

View File

@ -70,8 +70,6 @@ public:
///
void metrics(MetricsInfo &, Dimension &) const;
///
void drawBackground(PainterInfo & pi, int x, int y) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///
void write(std::ostream &) const;

View File

@ -134,16 +134,6 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
}
void InsetSpecialChar::drawBackground(PainterInfo & pi, int x, int y) const
{
if (pi.full_repaint)
return;
Dimension const dim = dimension(*pi.base.bv);
pi.pain.fillRectangle(x, y - dim.asc, dim.wid, dim.asc + dim.des,
pi.backgroundColor(this));
}
namespace {
// helper function: draw text and update x.

View File

@ -61,8 +61,6 @@ public:
///
void metrics(MetricsInfo &, Dimension &) const;
///
void drawBackground(PainterInfo & pi, int x, int y) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///
void write(std::ostream &) const;

View File

@ -583,17 +583,6 @@ void MathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const
}
void MathMacroTemplate::drawBackground(PainterInfo & pi, int x, int y) const
{
if (pi.full_repaint)
return;
Dimension const dim = dimension(*pi.base.bv);
pi.pain.fillRectangle(x, y - dim.asc, dim.wid, dim.asc + dim.des,
pi.backgroundColor(this));
}
void MathMacroTemplate::draw(PainterInfo & pi, int x, int y) const
{
// FIXME: Calling Changer on the same object repeatedly is inefficient.

View File

@ -92,8 +92,6 @@ public:
///
void draw(PainterInfo & pi, int x, int y) const;
///
void drawBackground(PainterInfo & pi, int x, int y) const;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
/// identifies macro templates
MathMacroTemplate * asMacroTemplate() { return this; }