X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetCollapsable.cpp;h=8f233f761bad432b58520ac01c6f7bbedb019f6c;hb=12c7e7dde3851ad894380fd42ba741dd3d0cbcc7;hp=74c53ef61bac6c8166621e5de7ded38822f5b0d0;hpb=9c8e7429fabd3b3c39a3374667ae624c3dbdcd01;p=lyx.git diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index 74c53ef61b..8f233f761b 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -26,6 +26,7 @@ #include "Lexer.h" #include "MetricsInfo.h" #include "OutputParams.h" +#include "TextClass.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" @@ -238,6 +239,7 @@ void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const bool InsetCollapsable::setMouseHover(BufferView const * bv, bool mouse_hover) + const { mouse_hover_[bv] = mouse_hover; return true; @@ -313,22 +315,22 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const const int xx2 = x + textdim.wid - TEXT_TO_INSET_OFFSET + 1; pi.pain.line(xx1, y + desc - 4, xx1, y + desc, - labelColor()); + Color_foreground); if (status_ == Open) pi.pain.line(xx1, y + desc, xx2, y + desc, - labelColor()); + Color_foreground); else { // Make status_ value visible: pi.pain.line(xx1, y + desc, xx1 + 4, y + desc, - labelColor()); + Color_foreground); pi.pain.line(xx2 - 4, y + desc, xx2, y + desc, - labelColor()); + Color_foreground); } pi.pain.line(x + textdim.wid - 3, y + desc, x + textdim.wid - 3, - y + desc - 4, labelColor()); + y + desc - 4, Color_foreground); // the label below the text. Can be toggled. if (geometry(bv) == SubLabel) { @@ -351,12 +353,10 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const if (cur.isInside(this)) { y -= textdim.asc; y += 3; - pi.pain.line(xx1, y + 4, xx1, y, labelColor()); - pi.pain.line(xx1 + 4, y, xx1, y, labelColor()); - pi.pain.line(xx2, y + 4, xx2, y, - labelColor()); - pi.pain.line(xx2 - 4, y, xx2, y, - labelColor()); + pi.pain.line(xx1, y + 4, xx1, y, Color_foreground); + pi.pain.line(xx1 + 4, y, xx1, y, Color_foreground); + pi.pain.line(xx2, y + 4, xx2, y, Color_foreground); + pi.pain.line(xx2 - 4, y, xx2, y, Color_foreground); } break; } @@ -412,6 +412,13 @@ bool InsetCollapsable::hitButton(FuncRequest const & cmd) const } +bool InsetCollapsable::clickable(int x, int y) const +{ + FuncRequest cmd(LFUN_NOACTION, x, y, mouse_button::none); + return hitButton(cmd); +} + + docstring const InsetCollapsable::getNewLabel(docstring const & l) const { docstring label; @@ -473,7 +480,7 @@ void InsetCollapsable::doDispatch(Cursor & cur, FuncRequest & cmd) case mouse_button::button4: case mouse_button::button5: // Nothing to do. - cur.noUpdate(); + cur.noScreenUpdate(); break; } } else if (geometry(cur.bv()) != ButtonOnly) @@ -486,7 +493,7 @@ void InsetCollapsable::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_MOUSE_DOUBLE: case LFUN_MOUSE_TRIPLE: if (hitButton(cmd)) - cur.noUpdate(); + cur.noScreenUpdate(); else if (geometry(cur.bv()) != ButtonOnly) InsetText::doDispatch(cur, cmd); else @@ -504,7 +511,7 @@ void InsetCollapsable::doDispatch(Cursor & cur, FuncRequest & cmd) } if (cmd.button() != mouse_button::button1) { // Nothing to do. - cur.noUpdate(); + cur.noScreenUpdate(); break; } // if we are selecting, we do not want to @@ -514,7 +521,7 @@ void InsetCollapsable::doDispatch(Cursor & cur, FuncRequest & cmd) // Left button is clicked, the user asks to // toggle the inset visual state. cur.dispatched(); - cur.updateFlags(Update::Force | Update::FitCursor); + cur.screenUpdateFlags(Update::Force | Update::FitCursor); if (geometry(cur.bv()) == ButtonOnly) { setStatus(cur, Open); edit(cur, true); @@ -591,10 +598,8 @@ void InsetCollapsable::setStatus(Cursor & cur, CollapseStatus status) { status_ = status; setButtonLabel(); - if (status_ == Collapsed) { + if (status_ == Collapsed) cur.leaveInset(*this); - mouse_hover_.clear(); - } }