On Sun, Dec 02, 2001 at 11:07:13AM +0000, Jose Abilio Oliveira Matos wrote:

> > Please apply, unless someone with a clue has an objection.
> 
>   I don't have a clue but I have an objection: "Where is it (the
> patch)?"

well, what a pedantic quibble !

>   Does this seems like a valid objection to you? ;-)

attached this time ...

john
-- 
"Faced with the prospect of rereading this book, I would rather have 
 my brains ripped out by a plastic fork."
        - Charles Cooper on "Business at the Speed of Thought" 
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.425
diff -u -r1.425 ChangeLog
--- src/ChangeLog       2001/11/30 16:10:24     1.425
+++ src/ChangeLog       2001/12/01 13:14:50
@@ -1,3 +1,7 @@
+2001-11-30  John Levon  <[EMAIL PROTECTED]>
+
+       * BufferView_pimpl.C: allow to click on RHS of full row insets
+ 
 2001-11-30  Juergen Vigna  <[EMAIL PROTECTED]>
 
        * tabular.C (LyXTabular): add a same_id to set the same id's in the
 
Index: src/BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.178
diff -u -r1.178 BufferView_pimpl.C
--- src/BufferView_pimpl.C      2001/11/29 17:12:16     1.178
+++ src/BufferView_pimpl.C      2001/12/01 13:14:53
@@ -858,59 +874,45 @@
        LyXCursor cursor;
        text->setCursorFromCoordinates(bv_, cursor, x, y_tmp);
        text->setCursor(bv_, cursor, cursor.par(),cursor.pos(),true);
-
 
+       lyx::pos_type pos;
+ 
        if (cursor.pos() < cursor.par()->size()
            && cursor.par()->isInset(cursor.pos())
            && isEditableInset(cursor.par()->getInset(cursor.pos()))) {
-
-               // Check whether the inset really was hit
-               Inset * tmpinset = cursor.par()->getInset(cursor.pos());
-               LyXFont font = text->getFont(buffer_,
-                                                 cursor.par(), cursor.pos());
-               int const width = tmpinset->width(bv_, font);
-               int const inset_x = font.isVisibleRightToLeft()
-                       ? cursor.x() - width : cursor.x();
-               int const start_x = inset_x + tmpinset->scroll();
-               int const end_x = inset_x + width;
-
-               if (x > start_x && x < end_x
-                   && y_tmp > cursor.y() - tmpinset->ascent(bv_, font)
-                   && y_tmp < cursor.y() + tmpinset->descent(bv_, font)) {
-                       text->setCursor(bv_, cursor.par(),cursor.pos(), true);
-                       x = x - start_x;
-                       // The origin of an inset is on the baseline
-                       y = y_tmp - (text->cursor.y()); 
-                       return tmpinset;
-               }
+               pos = cursor.pos();
+       } else if ((cursor.pos() - 1 >= 0)
+               && cursor.par()->isInset(cursor.pos() - 1)
+               && isEditableInset(cursor.par()->getInset(cursor.pos() - 1))) {
+               pos = cursor.pos() - 1;
+               // if the inset takes a full row, then the cursor.y()
+               // at the end of the inset will be wrong. So step the cursor
+               // back one
+               text->setCursor(bv_, cursor, cursor.par(), cursor.pos() - 1, true);
+       } else {
+               return 0;
        }
 
-       if ((cursor.pos() - 1 >= 0) &&
-           cursor.par()->isInset(cursor.pos() - 1) &&
-           isEditableInset(cursor.par()->getInset(cursor.pos() - 1))) {
-               Inset * tmpinset = cursor.par()->getInset(cursor.pos()-1);
-               LyXFont font = text->getFont(buffer_, cursor.par(),
-                                                 cursor.pos() - 1);
-               int const width = tmpinset->width(bv_, font);
-               int const inset_x = font.isVisibleRightToLeft()
-                       ? cursor.x() : cursor.x() - width;
-               int const start_x = inset_x + tmpinset->scroll();
-               int const end_x = inset_x + width;
-
-               if (x > start_x && x < end_x
-                   && y_tmp > cursor.y() - tmpinset->ascent(bv_, font)
-                   && y_tmp < cursor.y() + tmpinset->descent(bv_, font)) {
-#if 0
-                       if (move_cursor && (tmpinset != bv_->theLockingInset()))
-#endif
-                               text->setCursor(bv_, cursor.par(),
-                                               cursor.pos() - 1, true);
-                       x = x - start_x;
-                       // The origin of an inset is on the baseline
-                       y = y_tmp - (text->cursor.y()); 
-                       return tmpinset;
-               }
+       // Check whether the inset really was hit
+       Inset * inset = cursor.par()->getInset(pos);
+       LyXFont const & font = text->getFont(buffer_, cursor.par(), pos);
+       int const width = inset->width(bv_, font);
+       int const inset_x = font.isVisibleRightToLeft()
+               ? cursor.x() - width : cursor.x();
+       int const start_x = inset_x + inset->scroll();
+       int const end_x = inset_x + width;
+       int const start_y = cursor.y() - inset->ascent(bv_, font);
+       int const end_y = cursor.y() + inset->descent(bv_, font);
+ 
+       if (x > start_x && x < end_x
+               && y_tmp > start_y && y < end_y) {
+               text->setCursor(bv_, cursor.par(), pos, true);
+               x = x - start_x;
+               // The origin of an inset is on the baseline
+               y = y_tmp - (text->cursor.y()); 
+               return inset;
        }
+
        return 0;
 }
 

Reply via email to