Hello,

I just committed this in preparation of potential advanced mouse click selection. Jose, rest assured that this patch does not modify anything at all and that I will not commit any new feature before it's ready and approved. I just wanted to show the way ;-)

Thanks,
Abdel.

[EMAIL PROTECTED] wrote:
Author: younes
Date: Sat Jan 27 11:41:03 2007
New Revision: 16878

URL: http://www.lyx.org/trac/changeset/16878
Log:
Prepare for advanced mouse click selections.

* WorkArea::dispatch(): add modifiers argument.

* GuiWorkArea::mousePressEvent(): transmit the modifier to WorkArea::dispatch().
Modified:
    lyx-devel/trunk/src/frontends/WorkArea.C
    lyx-devel/trunk/src/frontends/WorkArea.h
    lyx-devel/trunk/src/frontends/qt4/GuiWorkArea.C

Modified: lyx-devel/trunk/src/frontends/WorkArea.C
URL: 
http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/WorkArea.C?rev=16878
==============================================================================
--- lyx-devel/trunk/src/frontends/WorkArea.C (original)
+++ lyx-devel/trunk/src/frontends/WorkArea.C Sat Jan 27 11:41:03 2007
@@ -182,7 +182,7 @@
 }
-void WorkArea::dispatch(FuncRequest const & cmd0)
+void WorkArea::dispatch(FuncRequest const & cmd0, key_modifier::state k)
 {
        // Handle drag&drop
        if (cmd0.action == LFUN_FILE_OPEN) {
@@ -192,10 +192,23 @@
theLyXFunc().setLyXView(&lyx_view_); - bool needRedraw = buffer_view_->workAreaDispatch(cmd0);
+       FuncRequest cmd;
+
+       if (cmd0.action == LFUN_MOUSE_PRESS) {
+               if (k == key_modifier::shift)
+                       cmd = FuncRequest(cmd0, "region-select");
+               else if (k == key_modifier::ctrl)
+                       cmd = FuncRequest(cmd0, "paragraph-select");
+               else
+                       cmd = cmd0;
+       }
+       else
+               cmd = cmd0;
+
+       bool needRedraw = buffer_view_->workAreaDispatch(cmd);
// Skip these when selecting
-       if (cmd0.action != LFUN_MOUSE_MOTION) {
+       if (cmd.action != LFUN_MOUSE_MOTION) {
                lyx_view_.updateLayoutChoice();
                lyx_view_.updateMenubar();
                lyx_view_.updateToolbars();
@@ -203,14 +216,14 @@
        // GUI tweaks except with mouse motion with no button pressed.
- if (!(cmd0.action == LFUN_MOUSE_MOTION - && cmd0.button() == mouse_button::none)) { + if (!(cmd.action == LFUN_MOUSE_MOTION + && cmd.button() == mouse_button::none)) {
                // Slight hack: this is only called currently when we
                // clicked somewhere, so we force through the display
                // of the new status here.
                lyx_view_.clearMessage();
- // Show the cursor immediately after any operation.
+               // Show the cursor       immediately after any operation.
                hideCursor();
                toggleCursor();
        }

Modified: lyx-devel/trunk/src/frontends/WorkArea.h
URL: 
http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/WorkArea.h?rev=16878
==============================================================================
--- lyx-devel/trunk/src/frontends/WorkArea.h (original)
+++ lyx-devel/trunk/src/frontends/WorkArea.h Sat Jan 27 11:41:03 2007
@@ -98,7 +98,8 @@
        /// cause the display of the given area of the work area
        virtual void expose(int x, int y, int w, int h) = 0;
        ///
-       void dispatch(FuncRequest const & cmd0);
+       void dispatch(FuncRequest const & cmd0,
+               key_modifier::state = key_modifier::none);
        ///
        void resizeBufferView();
        ///

Modified: lyx-devel/trunk/src/frontends/qt4/GuiWorkArea.C
URL: 
http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/GuiWorkArea.C?rev=16878
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiWorkArea.C (original)
+++ lyx-devel/trunk/src/frontends/qt4/GuiWorkArea.C Sat Jan 27 11:41:03 2007
@@ -290,8 +290,8 @@
        }
FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
-                             q_button_state(e->button()));
-       dispatch(cmd);
+               q_button_state(e->button()));
+       dispatch(cmd, q_key_state(e->modifiers()));
 }



Reply via email to