mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Mark insets with invalid buffer() in red in devel-mode.
We tend to have insets which buffer() member is invalid. To help debugging, this commit paints their background in red when devel-mode is on. To this end, a new method develMode() is added to the Painter class. With this commit, it is easy to see that macro template do not have a proper buffer set!
This commit is contained in:
parent
44816adce6
commit
067d6dc759
@ -158,19 +158,21 @@ ColorCode PainterInfo::backgroundColor(Inset const * inset, bool sel) const
|
||||
if (selected && sel)
|
||||
// This inset is in a selection
|
||||
return Color_selection;
|
||||
else {
|
||||
if (color_bg != Color_none)
|
||||
// This inset has its own color
|
||||
return color_bg;
|
||||
else {
|
||||
if (background_color == Color_none)
|
||||
// This inset has no own color and does not inherit a color
|
||||
return Color_background;
|
||||
else
|
||||
// This inset has no own color, but inherits a color
|
||||
return background_color;
|
||||
}
|
||||
}
|
||||
|
||||
if (pain.develMode() && !inset->isBufferValid())
|
||||
// This inset is in error
|
||||
return Color_error;
|
||||
|
||||
if (color_bg != Color_none)
|
||||
// This inset has its own color
|
||||
return color_bg;
|
||||
|
||||
if (background_color == Color_none)
|
||||
// This inset has no own color and does not inherit a color
|
||||
return Color_background;
|
||||
|
||||
// This inset has no own color, but inherits a color
|
||||
return background_color;
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace frontend {
|
||||
*/
|
||||
class NullPainter : public Painter {
|
||||
public:
|
||||
NullPainter() : Painter(1) {}
|
||||
NullPainter() : Painter(1, false) {}
|
||||
|
||||
~NullPainter() {}
|
||||
|
||||
|
@ -49,7 +49,8 @@ namespace frontend {
|
||||
*/
|
||||
class Painter {
|
||||
public:
|
||||
Painter(double pixel_ratio) : pixel_ratio_(pixel_ratio) {}
|
||||
Painter(double pixel_ratio, bool devel_mode)
|
||||
: pixel_ratio_(pixel_ratio), devel_mode_(devel_mode) {}
|
||||
|
||||
static const int thin_line;
|
||||
|
||||
@ -152,6 +153,8 @@ public:
|
||||
|
||||
double pixelRatio() const { return pixel_ratio_; }
|
||||
|
||||
double develMode() const { return devel_mode_; }
|
||||
|
||||
/// draw the underbar, strikeout, xout, uuline and uwave font attributes
|
||||
virtual void textDecoration(FontInfo const & f, int x, int y, int width) = 0;
|
||||
|
||||
@ -182,6 +185,8 @@ public:
|
||||
private:
|
||||
/// Ratio between physical pixels and device-independent pixels
|
||||
double pixel_ratio_;
|
||||
/// True when developer more is on at application-level.
|
||||
bool devel_mode_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
@ -39,8 +39,8 @@ namespace frontend {
|
||||
|
||||
const int Painter::thin_line = 1;
|
||||
|
||||
GuiPainter::GuiPainter(QPaintDevice * device, double pixel_ratio)
|
||||
: QPainter(device), Painter(pixel_ratio)
|
||||
GuiPainter::GuiPainter(QPaintDevice * device, double pixel_ratio, bool devel_mode)
|
||||
: QPainter(device), Painter(pixel_ratio, devel_mode)
|
||||
{
|
||||
// set cache correctly
|
||||
current_color_ = pen().color();
|
||||
|
@ -34,7 +34,7 @@ namespace frontend {
|
||||
*/
|
||||
class GuiPainter : public QPainter, public Painter {
|
||||
public:
|
||||
GuiPainter(QPaintDevice *, double pixel_ratio);
|
||||
GuiPainter(QPaintDevice *, double pixel_ratio, bool devel_mode);
|
||||
virtual ~GuiPainter();
|
||||
|
||||
/// This painter paints
|
||||
|
@ -1330,7 +1330,7 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev)
|
||||
|
||||
d->last_pixel_ratio_ = pixelRatio();
|
||||
|
||||
GuiPainter pain(d->screenDevice(), pixelRatio());
|
||||
GuiPainter pain(d->screenDevice(), pixelRatio(), d->lyx_view_->develMode());
|
||||
|
||||
d->buffer_view_->draw(pain, d->caret_visible_);
|
||||
|
||||
|
@ -326,6 +326,9 @@ void MathRow::draw(PainterInfo & pi, int x, int const y) const
|
||||
Dimension d2 = d;
|
||||
d2.wid -= e.before + e.after;
|
||||
coords.insets().add(e.inset, d2);
|
||||
if (pi.pain.develMode() && !e.inset->isBufferValid())
|
||||
pi.pain.fillRectangle(x + e.before, y - d2.ascent(),
|
||||
d2.width(), d2.height(), Color_error);
|
||||
e.inset->draw(pi, x + e.before, y);
|
||||
coords.insets().add(e.inset, x, y);
|
||||
coords.insets().add(e.inset, d);
|
||||
|
Loading…
Reference in New Issue
Block a user