Let command inset honor inheritFont() on screen

The RenderButton object now has a inherit_font_ property. It is set
depending on the value of Inset::inheritFont().

This is a better fix than 55533804, which caused bugs #10682 and #10677.

Fixes bug #10258
This commit is contained in:
Jean-Marc Lasgouttes 2017-05-24 11:28:08 +02:00
parent 3f34ebbaf9
commit b58dcff836
6 changed files with 14 additions and 10 deletions

View File

@ -96,7 +96,8 @@ InsetCommand::~InsetCommand()
void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
{
button_.update(screenLabel(), editable() || clickable(*mi.base.bv, 0, 0));
button_.update(screenLabel(), editable() || clickable(*mi.base.bv, 0, 0),
inheritFont());
button_.metrics(mi, dim);
}

View File

@ -623,7 +623,7 @@ void InsetExternal::setParams(InsetExternalParams const & p)
renderer_.reset(new RenderButton);
button_ptr = renderer_->asButton();
}
button_ptr->update(screenLabel(params_, buffer()), true);
button_ptr->update(screenLabel(params_, buffer()), true, false);
return;
}

View File

@ -1022,7 +1022,7 @@ void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
} else {
if (!set_label_) {
set_label_ = true;
button_.update(screenLabel(), true);
button_.update(screenLabel(), true, false);
}
button_.metrics(mi, dim);
}
@ -1207,7 +1207,7 @@ void InsetInclude::updateCommand()
void InsetInclude::updateBuffer(ParIterator const & it, UpdateType utype)
{
button_.update(screenLabel(), true);
button_.update(screenLabel(), true, false);
Buffer const * const childbuffer = getChildBuffer();
if (childbuffer) {

View File

@ -32,16 +32,18 @@ RenderBase * RenderButton::clone(Inset const *) const
}
void RenderButton::update(docstring const & text, bool editable)
void RenderButton::update(docstring const & text, bool editable,
bool inherit_font)
{
text_ = text;
editable_ = editable;
inherit_font_ = inherit_font;
}
void RenderButton::metrics(MetricsInfo &, Dimension & dim) const
void RenderButton::metrics(MetricsInfo & mi, Dimension & dim) const
{
FontInfo font = sane_font;
FontInfo font = inherit_font_ ? mi.base.font : sane_font;
font.decSize();
frontend::FontMetrics const & fm =
theFontMetrics(font);
@ -58,7 +60,7 @@ void RenderButton::metrics(MetricsInfo &, Dimension & dim) const
void RenderButton::draw(PainterInfo & pi, int x, int y) const
{
// Draw it as a box with the LaTeX text
FontInfo font = sane_font;
FontInfo font = inherit_font_ ? pi.base.font : sane_font;
font.setColor(Color_command);
font.decSize();

View File

@ -33,7 +33,7 @@ public:
virtual void draw(PainterInfo & pi, int x, int y) const;
/// Provide the text for the button
void update(docstring const &, bool editable);
void update(docstring const &, bool editable, bool inherit_font);
/// The "sensitive area" box, i.e., the button area
Box box() const { return button_box_; }
@ -47,6 +47,7 @@ private:
/// The stored data.
docstring text_;
bool editable_;
bool inherit_font_;
Box button_box_;
};

View File

@ -40,7 +40,7 @@ void CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const
{
if (!set_label_) {
set_label_ = true;
button_.update(screenLabel(), true);
button_.update(screenLabel(), true, false);
}
button_.metrics(mi, dim);
}