X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetcollapsable.C;h=ce43acc582135c7dfc603ace9d0a760c7e93a5fe;hb=9f3dd22dd39c419522914846b21dd2b45720ad0a;hp=c08039052689cd6867b344d7d2767c5923fa5a86;hpb=8075064372c5361f2dfd91860003f0cb317b4e39;p=lyx.git diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index c080390526..ce43acc582 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -217,6 +217,7 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, } top_x = int(x); + topx_set = true; top_baseline = baseline; int const bl = baseline - ascent(bv, f) + ascent_collapsed(); @@ -225,6 +226,8 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, inset.draw(bv, f, bl + descent_collapsed() + inset.ascent(bv, f), x, cleared); + if (x < (top_x + button_length + TEXT_TO_INSET_OFFSET)) + x = top_x + button_length + TEXT_TO_INSET_OFFSET; } @@ -235,6 +238,9 @@ void InsetCollapsable::edit(BufferView * bv, int xp, int yp, if (collapsed_) { collapsed_ = false; + // set this only here as it should be recollapsed only if + // it was already collapsed! + first_after_edit = true; if (!bv->lockInset(this)) return; bv->updateInset(this, true); @@ -272,6 +278,7 @@ void InsetCollapsable::edit(BufferView * bv, bool front) return; inset.edit(bv, front); } + first_after_edit = true; } @@ -365,16 +372,17 @@ void InsetCollapsable::insetKeyPress(XKeyEvent * xke) int InsetCollapsable::latex(Buffer const * buf, ostream & os, - bool fragile, bool free_spc) const + bool fragile, bool free_spc) const { return inset.latex(buf, os, fragile, free_spc); } int InsetCollapsable::getMaxWidth(BufferView * bv, - UpdatableInset const * inset) const + UpdatableInset const * in) const { - int const w = UpdatableInset::getMaxWidth(bv, inset); +#if 0 + int const w = UpdatableInset::getMaxWidth(bv, in); if (w < 0) { // What does a negative max width signify? (Lgb) @@ -383,14 +391,21 @@ int InsetCollapsable::getMaxWidth(BufferView * bv, } // should be at least 30 pixels !!! return max(30, w - width_collapsed()); +#else + return UpdatableInset::getMaxWidth(bv, in); +#endif } void InsetCollapsable::update(BufferView * bv, LyXFont const & font, bool reinit) { - if (in_update) + if (in_update) { + if (reinit && owner()) { + owner()->update(bv, font, true); + } return; + } in_update = true; inset.update(bv, font, reinit); if (reinit && owner()) { @@ -407,6 +422,7 @@ InsetCollapsable::localDispatch(BufferView * bv, kb_action action, UpdatableInset::RESULT result = inset.localDispatch(bv, action, arg); if (result == FINISHED) bv->unlockInset(this); + first_after_edit = false; return result; } @@ -584,17 +600,47 @@ void InsetCollapsable::open(BufferView * bv) } -void InsetCollapsable::close(BufferView * bv) +void InsetCollapsable::close(BufferView * bv) const { if (collapsed_) return; collapsed_ = true; - bv->updateInset(this, true); + bv->updateInset(const_cast(this), true); } -void InsetCollapsable::setLabel(string const & l) +void InsetCollapsable::setLabel(string const & l) const { label = l; } + + +bool InsetCollapsable::searchForward(BufferView * bv, string const & str, + bool const & cs, bool const & mw) +{ + bool found = inset.searchForward(bv, str, cs, mw); + if (first_after_edit && !found) + close(bv); + first_after_edit = false; + return found; +} +bool InsetCollapsable::searchBackward(BufferView * bv, string const & str, + bool const & cs, bool const & mw) +{ + bool found = inset.searchBackward(bv, str, cs, mw); + if (first_after_edit && !found) + close(bv); + first_after_edit = false; + return found; +} + + +string const InsetCollapsable::selectNextWord(BufferView * bv, float & value) const +{ + string str = inset.selectNextWord(bv, value); + if (first_after_edit && str.empty()) + close(bv); + first_after_edit = false; + return str; +}