#include "InsetLayout.h"
#include "Lexer.h"
#include "MetricsInfo.h"
-#include "OutputParams.h"
#include "TextClass.h"
#include "TocBackend.h"
#include "support/debug.h"
#include "support/docstream.h"
+#include "support/FileName.h"
#include "support/gettext.h"
#include "support/lassert.h"
#include "support/lstrings.h"
-#include "support/RefChanger.h"
+#include "support/Changer.h"
#include "support/TempFile.h"
using namespace std;
InsetCollapsible::CollapseStatus InsetCollapsible::status(BufferView const & bv) const
{
- if (decoration() == InsetLayout::CONGLOMERATE)
+ if (decoration() == InsetDecoration::CONGLOMERATE)
return status_;
return view_[&bv].auto_open_ ? Open : status_;
}
InsetCollapsible::Geometry InsetCollapsible::geometry(BufferView const & bv) const
{
switch (decoration()) {
- case InsetLayout::CLASSIC:
+ case InsetDecoration::CLASSIC:
if (status(bv) == Open)
return view_[&bv].openinlined_ ? LeftButton : TopButton;
return ButtonOnly;
- case InsetLayout::MINIMALISTIC:
- return status(bv) == Open ? NoButton : ButtonOnly ;
+ case InsetDecoration::MINIMALISTIC: {
+ return status(bv) == Open ?
+ (tempfile_ ? LeftButton : NoButton)
+ : ButtonOnly;
+ }
- case InsetLayout::CONGLOMERATE:
+ case InsetDecoration::CONGLOMERATE:
return status(bv) == Open ? SubLabel : Corners ;
- case InsetLayout::DEFAULT:
+ case InsetDecoration::DEFAULT:
break; // this shouldn't happen
}
{
Dimension dim;
FontInfo labelfont(getLabelfont());
+ int const offset =
+ (geometry(bv) != LeftButton && geometry(bv) != TopButton)
+ ? Inset::textOffset(&bv) : 0;
labelfont.realize(sane_font);
theFontMetrics(labelfont).buttonText(
- buttonLabel(bv), Inset::textOffset(&bv), dim.wid, dim.asc, dim.des);
+ buttonLabel(bv), offset, dim.wid, dim.asc, dim.des);
return dim;
}
{
view_[mi.base.bv].auto_open_ = mi.base.bv->cursor().isInside(this);
- FontInfo tmpfont = mi.base.font;
- mi.base.font = getFont();
- mi.base.font.realize(tmpfont);
-
BufferView const & bv = *mi.base.bv;
switch (geometry(bv)) {
int d = 0;
theFontMetrics(font).rectText(buttonLabel(bv), w, a, d);
dim.des += a + d;
+ dim.wid = max(dim.wid, w);
break;
}
case TopButton:
}
break;
}
-
- mi.base.font = tmpfont;
}
}
+ColorCode InsetCollapsible::backgroundColor(PainterInfo const &) const
+{
+ return getLayout().bgcolor();
+}
+
+
+ColorCode InsetCollapsible::labelColor() const
+{
+ return getLayout().labelfont().color();
+}
+
+
void InsetCollapsible::draw(PainterInfo & pi, int x, int y) const
{
BufferView const & bv = *pi.base.bv;
// Do not draw the cue for INSERTED -- it is already in the button and
// that's enough.
Changer cdummy = (pi.change.type == Change::INSERTED)
- ? make_change(pi.change, Change())
- : Changer();
+ ? changeVar(pi.change, Change())
+ : noChange();
InsetText::draw(pi, textx, texty);
break;
}
// We will take care of the frame and the change tracking cue
// ourselves, below.
{
- Changer cdummy = make_change(pi.change, Change());
+ Changer cdummy = changeVar(pi.change, Change());
const_cast<InsetCollapsible *>(this)->setDrawFrame(false);
InsetText::draw(pi, textx, texty);
const_cast<InsetCollapsible *>(this)->setDrawFrame(true);
int w = 0;
int a = 0;
int d = 0;
- Color const col = pi.full_repaint ? Color_none : pi.background_color;
+ Color const col = pi.full_repaint ? Color_none : pi.backgroundColor();
theFontMetrics(font).rectText(buttonLabel(bv), w, a, d);
int const ww = max(textdim.wid, w);
pi.pain.rectText(x + (ww - w) / 2, y + desc + a,
return false;
switch (decoration()) {
- case InsetLayout::CLASSIC:
- case InsetLayout::MINIMALISTIC:
+ case InsetDecoration::CLASSIC:
+ case InsetDecoration::MINIMALISTIC:
return status_ == Open;
default:
return true;
return true;
case LFUN_INSET_EDIT:
- flag.setEnabled(getLayout().editExternally() && tempfile_ == 0);
+ flag.setEnabled(!buffer().hasReadonlyFlag() &&
+ getLayout().editExternally() && tempfile_ == nullptr);
return true;
case LFUN_INSET_END_EDIT:
- flag.setEnabled(getLayout().editExternally() && tempfile_ != 0);
+ flag.setEnabled(!buffer().hasReadonlyFlag() &&
+ getLayout().editExternally() && tempfile_ != nullptr);
return true;
default:
docstring const InsetCollapsible::buttonLabel(BufferView const & bv) const
{
+ // U+1F512 LOCK
+ docstring const locked = tempfile_ ? docstring(1, 0x1F512) : docstring();
// indicate changed content in label (#8645)
// ✎ U+270E LOWER RIGHT PENCIL
docstring const indicator = (isChanged() && geometry(bv) == ButtonOnly)
InsetLayout const & il = getLayout();
docstring const label = getLabel();
if (!il.contentaslabel() || geometry(bv) != ButtonOnly)
- return indicator + label;
- return indicator + getNewLabel(label);
+ return locked + indicator + label;
+ return locked + indicator + getNewLabel(label);
}
}
-InsetLayout::InsetDecoration InsetCollapsible::decoration() const
+InsetDecoration InsetCollapsible::decoration() const
{
- InsetLayout::InsetDecoration const dec = getLayout().decoration();
- return dec == InsetLayout::DEFAULT ? InsetLayout::CLASSIC : dec;
+ InsetDecoration const dec = getLayout().decoration();
+ return dec == InsetDecoration::DEFAULT ? InsetDecoration::CLASSIC : dec;
}
{
string context_menu = contextMenuName();
string const it_context_menu = InsetText::contextMenuName();
- if (decoration() == InsetLayout::CONGLOMERATE)
+ if (decoration() == InsetDecoration::CONGLOMERATE)
return context_menu + ";" + it_context_menu;
string const ic_context_menu = InsetCollapsible::contextMenuName();
string InsetCollapsible::contextMenuName() const
{
- if (decoration() == InsetLayout::CONGLOMERATE)
+ if (decoration() == InsetDecoration::CONGLOMERATE)
return "context-conglomerate";
else
return "context-collapsible";