Vincent van Ravesteijn wrote:
Abdelrazak Younes wrote: > > We also need to fix the selection painting within Inset. In your > example, the inset should have a blue background, regardless off end of > paragraph. That's also to be fixed for mathed. I mean, if you're looking > for something else to fix ;-) > > Abdel. > Tu veux tester ? Wanna give it a try ? Vincent
It can even (much) simpler and better... it now also works for nested insets.
(sorry for the spam) Vincent
Index: src/insets/InsetCollapsable.cpp =================================================================== --- src/insets/InsetCollapsable.cpp (revision 26450) +++ src/insets/InsetCollapsable.cpp (working copy) @@ -265,7 +265,10 @@ autoOpen_ = pi.base.bv->cursor().isInside(this); ColorCode const old_color = pi.background_color; - pi.background_color = backgroundColor(); + if (pi.selected_) + pi.background_color = Color_selection; + else + pi.background_color = backgroundColor(); FontInfo tmpfont = pi.base.font; pi.base.font = layout_->font(); Index: src/insets/InsetText.cpp =================================================================== --- src/insets/InsetText.cpp (revision 26450) +++ src/insets/InsetText.cpp (working copy) @@ -198,8 +198,12 @@ int const yframe = y - TEXT_TO_INSET_OFFSET - tm.ascent(); int const h = tm.height() + 2 * TEXT_TO_INSET_OFFSET; int const xframe = x + TEXT_TO_INSET_OFFSET / 2; - if (pi.full_repaint) - pi.pain.fillRectangle(xframe, yframe, w, h, backgroundColor()); + if (pi.full_repaint) { + if (pi.selected_) + pi.pain.fillRectangle(xframe, yframe, w, h, Color_selection); + else + pi.pain.fillRectangle(xframe, yframe, w, h, backgroundColor()); + } if (drawFrame_) pi.pain.rectangle(xframe, yframe, w, h, frameColor()); } Index: src/rowpainter.cpp =================================================================== --- src/rowpainter.cpp (revision 26450) +++ src/rowpainter.cpp (working copy) @@ -665,7 +665,13 @@ if (x_ > pi_.base.bv->workWidth()) continue; x_ = pi_.base.bv->coordCache().getInsets().x(inset); + + bool pi_selected = pi_.selected_; + Cursor & cur = pi_.base.bv->cursor(); + if (cur.text() == &text_ && cur.anchor().text() == &text_) + pi_.selected_ = row_.sel_beg <= pos && row_.sel_end > pos; paintInset(inset, pos); + pi_.selected_ = pi_selected; } } @@ -794,7 +800,13 @@ } else if (inset) { // If outer row has changed, nested insets are repaint completely. pi_.base.bv->coordCache().insets().add(inset, int(x_), yo_); + + bool pi_selected = pi_.selected_; + Cursor & cur = pi_.base.bv->cursor(); + if (cur.text() == &text_ && cur.anchor().text() == &text_) + pi_.selected_ = row_.sel_beg <= pos && row_.sel_end > pos; paintInset(inset, pos); + pi_.selected_ = pi_selected; ++vpos; } else { Index: src/MetricsInfo.h =================================================================== --- src/MetricsInfo.h (revision 26450) +++ src/MetricsInfo.h (working copy) @@ -105,6 +105,8 @@ /// Whether the parent is deleted (change tracking) bool erased_; /// + bool selected_; + /// bool full_repaint; /// ColorCode background_color;