namespace lyx {
-InsetCollapsable::CollapseStatus InsetCollapsable::status() const
+InsetCollapsable::CollapseStatus InsetCollapsable::status(BufferView const & bv) const
{
if (decoration() == InsetLayout::CONGLOMERATE)
return status_;
- return autoOpen_ ? Open : status_;
+ return auto_open_[&bv] ? Open : status_;
}
-InsetCollapsable::Geometry InsetCollapsable::geometry() const
+InsetCollapsable::Geometry InsetCollapsable::geometry(BufferView const & bv) const
{
switch (decoration()) {
case InsetLayout::CLASSIC:
- if (status() == Open)
+ if (status(bv) == Open)
return openinlined_ ? LeftButton : TopButton;
return ButtonOnly;
case InsetLayout::MINIMALISTIC:
- return status() == Open ? NoButton : ButtonOnly ;
+ return status(bv) == Open ? NoButton : ButtonOnly ;
case InsetLayout::CONGLOMERATE:
- return status() == Open ? SubLabel : Corners ;
+ return status(bv) == Open ? SubLabel : Corners ;
case InsetLayout::DEFAULT:
break; // this shouldn't happen
InsetCollapsable::InsetCollapsable(Buffer const & buf)
: InsetText(buf), status_(Inset::Open),
- openinlined_(false), autoOpen_(false), mouse_hover_(false)
+ openinlined_(false), mouse_hover_(false)
{
DocumentClass const & dc = buf.params().documentClass();
setLayout(&dc);
labelstring_(rhs.labelstring_),
button_dim(rhs.button_dim),
openinlined_(rhs.openinlined_),
- autoOpen_(rhs.autoOpen_),
+ auto_open_(rhs.auto_open_),
// the sole purpose of this copy constructor
mouse_hover_(false)
{
docstring InsetCollapsable::toolTip(BufferView const & bv, int x, int y) const
{
Dimension dim = dimensionCollapsed();
- if (geometry() == NoButton)
+ if (geometry(bv) == NoButton)
return translateIfPossible(layout_->labelstring());
- if (x > xo(bv) + dim.wid || y > yo(bv) + dim.des || isOpen())
+ if (x > xo(bv) + dim.wid || y > yo(bv) + dim.des || isOpen(bv))
return docstring();
OutputParams rp(&buffer().params().encoding());
{
LASSERT(layout_, /**/);
- autoOpen_ = mi.base.bv->cursor().isInside(this);
+ auto_open_[mi.base.bv] = mi.base.bv->cursor().isInside(this);
FontInfo tmpfont = mi.base.font;
mi.base.font = layout_->font();
mi.base.font.realize(tmpfont);
- switch (geometry()) {
+ switch (geometry(*mi.base.bv)) {
case NoButton:
InsetText::metrics(mi, dim);
break;
case LeftButton:
case ButtonOnly:
dim = dimensionCollapsed();
- if (geometry() == TopButton || geometry() == LeftButton) {
+ if (geometry(*mi.base.bv) == TopButton
+ || geometry(*mi.base.bv) == LeftButton) {
Dimension textdim;
InsetText::metrics(mi, textdim);
openinlined_ = (textdim.wid + dim.wid) < mi.base.textwidth;
{
LASSERT(layout_, /**/);
- autoOpen_ = pi.base.bv->cursor().isInside(this);
+ auto_open_[pi.base.bv] = pi.base.bv->cursor().isInside(this);
FontInfo tmpfont = pi.base.font;
pi.base.font = layout_->font();
// Draw button first -- top, left or only
Dimension dimc = dimensionCollapsed();
- if (geometry() == TopButton ||
- geometry() == LeftButton ||
- geometry() == ButtonOnly) {
+ if (geometry(*pi.base.bv) == TopButton ||
+ geometry(*pi.base.bv) == LeftButton ||
+ geometry(*pi.base.bv) == ButtonOnly) {
button_dim.x1 = x + 0;
button_dim.x2 = x + dimc.width();
button_dim.y1 = y - dimc.asc;
Dimension const textdim = InsetText::dimension(*pi.base.bv);
int const baseline = y;
int textx, texty;
- switch (geometry()) {
+ switch (geometry(*pi.base.bv)) {
case LeftButton:
textx = x + dimc.width();
texty = baseline;
const_cast<InsetCollapsable *>(this)->setDrawFrame(true);
int desc = textdim.descent();
- if (geometry() == Corners)
+ if (geometry(*pi.base.bv) == Corners)
desc -= 3;
const int xx1 = x + TEXT_TO_INSET_OFFSET - 1;
y + desc - 4, layout_->labelfont().color());
// the label below the text. Can be toggled.
- if (geometry() == SubLabel) {
+ if (geometry(*pi.base.bv) == SubLabel) {
FontInfo font(layout_->labelfont());
font.realize(sane_font);
font.decSize();
void InsetCollapsable::cursorPos(BufferView const & bv,
CursorSlice const & sl, bool boundary, int & x, int & y) const
{
- if (geometry() == ButtonOnly)
+ if (geometry(bv) == ButtonOnly)
status_ = Open;
- LASSERT(geometry() != ButtonOnly, /**/);
+ LASSERT(geometry(bv) != ButtonOnly, /**/);
InsetText::cursorPos(bv, sl, boundary, x, y);
Dimension const textdim = InsetText::dimension(bv);
- switch (geometry()) {
+ switch (geometry(bv)) {
case LeftButton:
x += dimensionCollapsed().wid;
break;
}
-Inset::EDITABLE InsetCollapsable::editable() const
+Inset::EDITABLE InsetCollapsable::editable(BufferView const & bv) const
{
- return geometry() != ButtonOnly ? HIGHLY_EDITABLE : IS_EDITABLE;
+ return geometry(bv) != ButtonOnly ? HIGHLY_EDITABLE : IS_EDITABLE;
}
-bool InsetCollapsable::descendable() const
+bool InsetCollapsable::descendable(BufferView const & bv) const
{
- return geometry() != ButtonOnly;
+ return geometry(bv) != ButtonOnly;
}
Inset * InsetCollapsable::editXY(Cursor & cur, int x, int y)
{
//lyxerr << "InsetCollapsable: edit xy" << endl;
- if (geometry() == ButtonOnly
+ if (geometry(cur.bv()) == ButtonOnly
|| (button_dim.contains(x, y)
- && geometry() != NoButton))
+ && geometry(cur.bv()) != NoButton))
return this;
cur.push(*this);
return InsetText::editXY(cur, x, y);
cur.noUpdate();
break;
}
- } else if (geometry() != ButtonOnly)
+ } else if (geometry(cur.bv()) != ButtonOnly)
InsetText::doDispatch(cur, cmd);
else
cur.undispatched();
case LFUN_MOUSE_TRIPLE:
if (hitButton(cmd))
cur.noUpdate();
- else if (geometry() != ButtonOnly)
+ else if (geometry(cur.bv()) != ButtonOnly)
InsetText::doDispatch(cur, cmd);
else
cur.undispatched();
case LFUN_MOUSE_RELEASE:
if (!hitButton(cmd)) {
// The mouse click has to be within the inset!
- if (geometry() != ButtonOnly)
+ if (geometry(cur.bv()) != ButtonOnly)
InsetText::doDispatch(cur, cmd);
else
cur.undispatched();
// toggle the inset visual state.
cur.dispatched();
cur.updateFlags(Update::Force | Update::FitCursor);
- if (geometry() == ButtonOnly) {
+ if (geometry(cur.bv()) == ButtonOnly) {
setStatus(cur, Open);
edit(cur, true);
}
else if (cmd.argument() == "toggle" || cmd.argument().empty())
if (status_ == Open) {
setStatus(cur, Collapsed);
- if (geometry() == ButtonOnly)
+ if (geometry(cur.bv()) == ButtonOnly)
cur.top().forwardPos();
} else
setStatus(cur, Open);
if (decoration() == InsetLayout::CONGLOMERATE)
return from_ascii("context-conglomerate");
- if (geometry() == NoButton)
+ if (geometry(bv) == NoButton)
return from_ascii("context-collapsable");
Dimension dim = dimensionCollapsed();
///
docstring const getNewLabel(docstring const & l) const;
///
- EDITABLE editable() const;
+ EDITABLE editable(BufferView const & bv) const;
/// can we go further down on mouse click?
- bool descendable() const;
+ bool descendable(BufferView const & bv) const;
///
void setLabel(docstring const & l);
///
virtual void setButtonLabel() {}
///
- bool isOpen() const { return geometry() != ButtonOnly; }
+ bool isOpen(BufferView const & bv) const
+ { return geometry(bv) != ButtonOnly; }
///
- CollapseStatus status() const;
+ CollapseStatus status(BufferView const & bv) const;
/** Of the old CollapseStatus we only keep the values
* Open and Collapsed.
* We define a list of possible inset decoration
/// Returns the geometry based on CollapseStatus
/// (status_), autoOpen_ and openinlined_, and of
/// course decoration().
- Geometry geometry() const;
+ Geometry geometry(BufferView const & bv) const;
/// Allow spellchecking, except for insets with latex_language
bool allowSpellCheck() const { return !forceLTR(); }
///
mutable Box button_dim;
/// a substatus of the Open status, determined automatically in metrics
mutable bool openinlined_;
- /// the inset will automatically open when the cursor is inside
- mutable bool autoOpen_;
+ /// the inset will automatically open when the cursor is inside. This is
+ /// dependent on the bufferview, compare with MathMacro::editing_.
+ mutable std::map<BufferView const *, bool> auto_open_;
/// changes color when mouse enters/leaves this inset
bool mouse_hover_;
};