Code

Commit LivePathEffect branch to trunk!
[inkscape.git] / src / node-context.cpp
1 #define __SP_NODE_CONTEXT_C__
3 /*
4  * Node editing context
5  *
6  * Authors:
7  *   Lauris Kaplinski <lauris@kaplinski.com>
8  *   bulia byak <buliabyak@users.sf.net>
9  *
10  * This code is in public domain
11  */
13 #ifdef HAVE_CONFIG_H
14 # include "config.h"
15 #endif
16 #include <gdk/gdkkeysyms.h>
17 #include "macros.h"
18 #include <glibmm/i18n.h>
19 #include "display/sp-canvas-util.h"
20 #include "object-edit.h"
21 #include "sp-path.h"
22 #include "path-chemistry.h"
23 #include "rubberband.h"
24 #include "desktop.h"
25 #include "desktop-handles.h"
26 #include "selection.h"
27 #include "pixmaps/cursor-node.xpm"
28 #include "message-context.h"
29 #include "node-context.h"
30 #include "pixmaps/cursor-node-d.xpm"
31 #include "prefs-utils.h"
32 #include "xml/node-event-vector.h"
33 #include "style.h"
34 #include "splivarot.h"
35 #include "shape-editor.h"
37 static void sp_node_context_class_init(SPNodeContextClass *klass);
38 static void sp_node_context_init(SPNodeContext *node_context);
39 static void sp_node_context_dispose(GObject *object);
41 static void sp_node_context_setup(SPEventContext *ec);
42 static gint sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event);
43 static gint sp_node_context_item_handler(SPEventContext *event_context,
44                                          SPItem *item, GdkEvent *event);
46 static SPEventContextClass *parent_class;
48 GType
49 sp_node_context_get_type()
50 {
51     static GType type = 0;
52     if (!type) {
53         GTypeInfo info = {
54             sizeof(SPNodeContextClass),
55             NULL, NULL,
56             (GClassInitFunc) sp_node_context_class_init,
57             NULL, NULL,
58             sizeof(SPNodeContext),
59             4,
60             (GInstanceInitFunc) sp_node_context_init,
61             NULL,    /* value_table */
62         };
63         type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPNodeContext", &info, (GTypeFlags)0);
64     }
65     return type;
66 }
68 static void
69 sp_node_context_class_init(SPNodeContextClass *klass)
70 {
71     GObjectClass *object_class = (GObjectClass *) klass;
72     SPEventContextClass *event_context_class = (SPEventContextClass *) klass;
74     parent_class = (SPEventContextClass*)g_type_class_peek_parent(klass);
76     object_class->dispose = sp_node_context_dispose;
78     event_context_class->setup = sp_node_context_setup;
79     event_context_class->root_handler = sp_node_context_root_handler;
80     event_context_class->item_handler = sp_node_context_item_handler;
81 }
83 static void
84 sp_node_context_init(SPNodeContext *node_context)
85 {
86     SPEventContext *event_context = SP_EVENT_CONTEXT(node_context);
88     event_context->cursor_shape = cursor_node_xpm;
89     event_context->hot_x = 1;
90     event_context->hot_y = 1;
92     node_context->leftalt = FALSE;
93     node_context->rightalt = FALSE;
94     node_context->leftctrl = FALSE;
95     node_context->rightctrl = FALSE;
96     
97     new (&node_context->sel_changed_connection) sigc::connection();
98 }
100 static void
101 sp_node_context_dispose(GObject *object)
103     SPNodeContext *nc = SP_NODE_CONTEXT(object);
104     SPEventContext *ec = SP_EVENT_CONTEXT(object);
106     ec->enableGrDrag(false);
108     nc->sel_changed_connection.disconnect();
109     nc->sel_changed_connection.~connection();
111     delete nc->shape_editor;
113     if (nc->_node_message_context) {
114         delete nc->_node_message_context;
115     }
117     G_OBJECT_CLASS(parent_class)->dispose(object);
120 static void
121 sp_node_context_setup(SPEventContext *ec)
123     SPNodeContext *nc = SP_NODE_CONTEXT(ec);
125     if (((SPEventContextClass *) parent_class)->setup)
126         ((SPEventContextClass *) parent_class)->setup(ec);
128     nc->sel_changed_connection.disconnect();
129     nc->sel_changed_connection = sp_desktop_selection(ec->desktop)->connectChanged(sigc::bind(sigc::ptr_fun(&sp_node_context_selection_changed), (gpointer)nc));
131     Inkscape::Selection *selection = sp_desktop_selection(ec->desktop);
132     SPItem *item = selection->singleItem();
134     nc->shape_editor = new ShapeEditor(ec->desktop);
136     nc->rb_escaped = false;
138     nc->cursor_drag = false;
140     nc->added_node = false;
142     nc->current_state = SP_NODE_CONTEXT_INACTIVE;
144     if (item) {
145         nc->shape_editor->set_item(item);
146     }
148     if (prefs_get_int_attribute("tools.nodes", "selcue", 0) != 0) {
149         ec->enableSelectionCue();
150     }
152     if (prefs_get_int_attribute("tools.nodes", "gradientdrag", 0) != 0) {
153         ec->enableGrDrag();
154     }
156     nc->_node_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
158     nc->shape_editor->update_statusbar();
161 /**
162 \brief  Callback that processes the "changed" signal on the selection;
163 destroys old and creates new nodepath and reassigns listeners to the new selected item's repr
164 */
165 void
166 sp_node_context_selection_changed(Inkscape::Selection *selection, gpointer data)
168     SPNodeContext *nc = SP_NODE_CONTEXT(data);
170     // TODO: update ShapeEditorsCollective instead
171     nc->shape_editor->unset_item();
172     SPItem *item = selection->singleItem(); 
173     nc->shape_editor->set_item(item);
175     nc->shape_editor->update_statusbar();
178 void
179 sp_node_context_show_modifier_tip(SPEventContext *event_context, GdkEvent *event)
181     sp_event_show_modifier_tip
182         (event_context->defaultMessageContext(), event,
183          _("<b>Ctrl</b>: toggle node type, snap handle angle, move hor/vert; <b>Ctrl+Alt</b>: move along handles"),
184          _("<b>Shift</b>: toggle node selection, disable snapping, rotate both handles"),
185          _("<b>Alt</b>: lock handle length; <b>Ctrl+Alt</b>: move along handles"));
189 static gint
190 sp_node_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event)
192     gint ret = FALSE;
194     if (((SPEventContextClass *) parent_class)->item_handler)
195         ret = ((SPEventContextClass *) parent_class)->item_handler(event_context, item, event);
197     return ret;
200 static gint
201 sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
203     SPDesktop *desktop = event_context->desktop;
204     Inkscape::Selection *selection = sp_desktop_selection (desktop);
206     SPNodeContext *nc = SP_NODE_CONTEXT(event_context);
207     double const nudge = prefs_get_double_attribute_limited("options.nudgedistance", "value", 2, 0, 1000); // in px
208     event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100); // read every time, to make prefs changes really live
209     int const snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12);
210     double const offset = prefs_get_double_attribute_limited("options.defaultscale", "value", 2, 0, 1000);
212     gint ret = FALSE;
213     switch (event->type) {
214         case GDK_BUTTON_PRESS:
215             if (event->button.button == 1 && !event_context->space_panning) {
216                 // save drag origin
217                 event_context->xp = (gint) event->button.x;
218                 event_context->yp = (gint) event->button.y;
219                 event_context->within_tolerance = true;
220                 nc->shape_editor->cancel_hit();
222                 if (!(event->button.state & GDK_SHIFT_MASK)) {
223                     if (!nc->drag) {
224                         if (nc->shape_editor->has_nodepath() && selection->single() /* && item_over */) {
225                             // save drag origin
226                             bool over_stroke = nc->shape_editor->is_over_stroke(NR::Point(event->button.x, event->button.y), true);
227                             //only dragging curves
228                             if (over_stroke) {
229                                 ret = TRUE;
230                                 break;
231                             }
232                         }
233                     }
234                 }
235                 NR::Point const button_w(event->button.x,
236                                          event->button.y);
237                 NR::Point const button_dt(desktop->w2d(button_w));
238                 Inkscape::Rubberband::get()->start(desktop, button_dt);
239                 nc->current_state = SP_NODE_CONTEXT_INACTIVE;
240                 desktop->updateNow();
241                 ret = TRUE;
242             }
243             break;
244         case GDK_MOTION_NOTIFY:
245             if (event->motion.state & GDK_BUTTON1_MASK && !event_context->space_panning) {
247                 if ( event_context->within_tolerance
248                      && ( abs( (gint) event->motion.x - event_context->xp ) < event_context->tolerance )
249                      && ( abs( (gint) event->motion.y - event_context->yp ) < event_context->tolerance ) ) {
250                     break; // do not drag if we're within tolerance from origin
251                 }
253                 // The path went away while dragging; throw away any further motion
254                 // events until the mouse pointer is released.
255                 
256                 if (nc->shape_editor->hits_curve() && !nc->shape_editor->has_nodepath()) {
257                   break;
258                 }
260                 // Once the user has moved farther than tolerance from the original location
261                 // (indicating they intend to move the object, not click), then always process the
262                 // motion notify coordinates as given (no snapping back to origin)
263                 event_context->within_tolerance = false;
265                 // Once we determine what the user is doing (dragging either a node or the
266                 // selection rubberband), make sure we continue to perform that operation
267                 // until the mouse pointer is lifted.
268                 if (nc->current_state == SP_NODE_CONTEXT_INACTIVE) {
269                     if (nc->shape_editor->hits_curve() && nc->shape_editor->has_nodepath()) {
270                         nc->current_state = SP_NODE_CONTEXT_NODE_DRAGGING;
271                     } else {
272                         nc->current_state = SP_NODE_CONTEXT_RUBBERBAND_DRAGGING;
273                     }
274                 }
276                 switch (nc->current_state) {
277                     case SP_NODE_CONTEXT_NODE_DRAGGING:
278                         {
279                             nc->shape_editor->curve_drag (event->motion.x, event->motion.y);
281                             gobble_motion_events(GDK_BUTTON1_MASK);
282                             break;
283                         }
284                     case SP_NODE_CONTEXT_RUBBERBAND_DRAGGING:
285                         if (Inkscape::Rubberband::get()->is_started()) {
286                             NR::Point const motion_w(event->motion.x,
287                                                 event->motion.y);
288                             NR::Point const motion_dt(desktop->w2d(motion_w));
289                             Inkscape::Rubberband::get()->move(motion_dt);
290                         }
291                         break;
292                 }
294                 nc->drag = TRUE;
295                 ret = TRUE;
296             } else {
297                 if (!nc->shape_editor->has_nodepath() || selection->singleItem() == NULL) {
298                     break;
299                 }
301                 bool over_stroke = false;
302                 over_stroke = nc->shape_editor->is_over_stroke(NR::Point(event->motion.x, event->motion.y), false);
304                 if (nc->cursor_drag && !over_stroke) {
305                     event_context->cursor_shape = cursor_node_xpm;
306                     event_context->hot_x = 1;
307                     event_context->hot_y = 1;
308                     sp_event_context_update_cursor(event_context);
309                     nc->cursor_drag = false;
310                 } else if (!nc->cursor_drag && over_stroke) {
311                     event_context->cursor_shape = cursor_node_d_xpm;
312                     event_context->hot_x = 1;
313                     event_context->hot_y = 1;
314                     sp_event_context_update_cursor(event_context);
315                     nc->cursor_drag = true;
316                 }
317             }
318             break;
320         case GDK_2BUTTON_PRESS:
321         case GDK_BUTTON_RELEASE:
322             if ( (event->button.button == 1) && (!nc->drag) && !event_context->space_panning) {
323                 // find out clicked item, disregarding groups, honoring Alt
324                 SPItem *item_clicked = sp_event_context_find_item (desktop,
325                         NR::Point(event->button.x, event->button.y),
326                         (event->button.state & GDK_MOD1_MASK) && !(event->button.state & GDK_CONTROL_MASK), TRUE);
328                 event_context->xp = event_context->yp = 0;
330                 bool over_stroke = false;
331                 if (nc->shape_editor->has_nodepath()) {
332                     over_stroke = nc->shape_editor->is_over_stroke(NR::Point(event->button.x, event->button.y), false);
333                 }
335                 if (item_clicked || over_stroke) {
336                     if (over_stroke || nc->added_node) {
337                         switch (event->type) {
338                             case GDK_BUTTON_RELEASE:
339                                 if (event->button.state & GDK_CONTROL_MASK && event->button.state & GDK_MOD1_MASK) {
340                                     //add a node
341                                     nc->shape_editor->add_node_near_point();
342                                 } else {
343                                     if (nc->added_node) { // we just received double click, ignore release
344                                         nc->added_node = false;
345                                         break;
346                                     }
347                                     //select the segment
348                                     if (event->button.state & GDK_SHIFT_MASK) {
349                                         nc->shape_editor->select_segment_near_point(true);
350                                     } else {
351                                         nc->shape_editor->select_segment_near_point(false);
352                                     }
353                                     desktop->updateNow();
354                                 }
355                                 break;
356                             case GDK_2BUTTON_PRESS:
357                                 //add a node
358                                 nc->shape_editor->add_node_near_point();
359                                 nc->added_node = true;
360                                 break;
361                             default:
362                                 break;
363                         }
364                     } else if (event->button.state & GDK_SHIFT_MASK) {
365                         selection->toggle(item_clicked);
366                         desktop->updateNow();
367                     } else {
368                         selection->set(item_clicked);
369                         desktop->updateNow();
370                     }
371                     ret = TRUE;
372                     break;
373                 }
374             } 
375             if (event->type == GDK_BUTTON_RELEASE) {
376                 event_context->xp = event_context->yp = 0;
377                 if (event->button.button == 1) {
378                     NR::Maybe<NR::Rect> b = Inkscape::Rubberband::get()->getRectangle();
380                     if (nc->shape_editor->hits_curve() && !event_context->within_tolerance) { //drag curve
381                         nc->shape_editor->finish_drag();
382                     } else if (b && !event_context->within_tolerance) { // drag to select
383                         nc->shape_editor->select_rect(*b, event->button.state & GDK_SHIFT_MASK);
384                     } else {
385                         if (!(nc->rb_escaped)) { // unless something was cancelled
386                             if (nc->shape_editor->has_selection())
387                                 nc->shape_editor->deselect();
388                             else
389                                 sp_desktop_selection(desktop)->clear();
390                         }
391                     }
392                     ret = TRUE;
393                     Inkscape::Rubberband::get()->stop();
394                     desktop->updateNow();
395                     nc->rb_escaped = false;
396                     nc->drag = FALSE;
397                     nc->shape_editor->cancel_hit();
398                     nc->current_state = SP_NODE_CONTEXT_INACTIVE;
399                 }
400             }
401             break;
402         case GDK_KEY_PRESS:
403             switch (get_group0_keyval(&event->key)) {
404                 case GDK_Insert:
405                 case GDK_KP_Insert:
406                     // with any modifiers
407                     nc->shape_editor->add_node();
408                     ret = TRUE;
409                     break;
410                 case GDK_Delete:
411                 case GDK_KP_Delete:
412                 case GDK_BackSpace:
413                     if (MOD__CTRL_ONLY) {
414                         nc->shape_editor->delete_nodes();
415                     } else {
416                         nc->shape_editor->delete_nodes_preserving_shape();
417                     }
418                     ret = TRUE;
419                     break;
420                 case GDK_C:
421                 case GDK_c:
422                     if (MOD__SHIFT_ONLY) {
423                         nc->shape_editor->set_node_type(Inkscape::NodePath::NODE_CUSP);
424                         ret = TRUE;
425                     }
426                     break;
427                 case GDK_S:
428                 case GDK_s:
429                     if (MOD__SHIFT_ONLY) {
430                         nc->shape_editor->set_node_type(Inkscape::NodePath::NODE_SMOOTH);
431                         ret = TRUE;
432                     }
433                     break;
434                 case GDK_Y:
435                 case GDK_y:
436                     if (MOD__SHIFT_ONLY) {
437                         nc->shape_editor->set_node_type(Inkscape::NodePath::NODE_SYMM);
438                         ret = TRUE;
439                     }
440                     break;
441                 case GDK_B:
442                 case GDK_b:
443                     if (MOD__SHIFT_ONLY) {
444                         nc->shape_editor->break_at_nodes();
445                         ret = TRUE;
446                     }
447                     break;
448                 case GDK_J:
449                 case GDK_j:
450                     if (MOD__SHIFT_ONLY) {
451                         nc->shape_editor->join_nodes();
452                         ret = TRUE;
453                     }
454                     break;
455                 case GDK_D:
456                 case GDK_d:
457                     if (MOD__SHIFT_ONLY) {
458                         nc->shape_editor->duplicate_nodes();
459                         ret = TRUE;
460                     }
461                     break;
462                 case GDK_L:
463                 case GDK_l:
464                     if (MOD__SHIFT_ONLY) {
465                         nc->shape_editor->set_type_of_segments(NR_LINETO);
466                         ret = TRUE;
467                     }
468                     break;
469                 case GDK_U:
470                 case GDK_u:
471                     if (MOD__SHIFT_ONLY) {
472                         nc->shape_editor->set_type_of_segments(NR_CURVETO);
473                         ret = TRUE;
474                     }
475                     break;
476                 case GDK_R:
477                 case GDK_r:
478                     if (MOD__SHIFT_ONLY) {
479                         // FIXME: add top panel button
480                         sp_selected_path_reverse();
481                         ret = TRUE;
482                     }
483                     break;
484                 case GDK_Left: // move selection left
485                 case GDK_KP_Left:
486                 case GDK_KP_4:
487                     if (!MOD__CTRL) { // not ctrl
488                         if (MOD__ALT) { // alt
489                             if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(-10, 0); // shift
490                             else nc->shape_editor->move_nodes_screen(-1, 0); // no shift
491                         }
492                         else { // no alt
493                             if (MOD__SHIFT) nc->shape_editor->move_nodes(-10*nudge, 0); // shift
494                             else nc->shape_editor->move_nodes(-nudge, 0); // no shift
495                         }
496                         ret = TRUE;
497                     }
498                     break;
499                 case GDK_Up: // move selection up
500                 case GDK_KP_Up:
501                 case GDK_KP_8:
502                     if (!MOD__CTRL) { // not ctrl
503                         if (MOD__ALT) { // alt
504                             if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(0, 10); // shift
505                             else nc->shape_editor->move_nodes_screen(0, 1); // no shift
506                         }
507                         else { // no alt
508                             if (MOD__SHIFT) nc->shape_editor->move_nodes(0, 10*nudge); // shift
509                             else nc->shape_editor->move_nodes(0, nudge); // no shift
510                         }
511                         ret = TRUE;
512                     }
513                     break;
514                 case GDK_Right: // move selection right
515                 case GDK_KP_Right:
516                 case GDK_KP_6:
517                     if (!MOD__CTRL) { // not ctrl
518                         if (MOD__ALT) { // alt
519                             if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(10, 0); // shift
520                             else nc->shape_editor->move_nodes_screen(1, 0); // no shift
521                         }
522                         else { // no alt
523                             if (MOD__SHIFT) nc->shape_editor->move_nodes(10*nudge, 0); // shift
524                             else nc->shape_editor->move_nodes(nudge, 0); // no shift
525                         }
526                         ret = TRUE;
527                     }
528                     break;
529                 case GDK_Down: // move selection down
530                 case GDK_KP_Down:
531                 case GDK_KP_2:
532                     if (!MOD__CTRL) { // not ctrl
533                         if (MOD__ALT) { // alt
534                             if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(0, -10); // shift
535                             else nc->shape_editor->move_nodes_screen(0, -1); // no shift
536                         }
537                         else { // no alt
538                             if (MOD__SHIFT) nc->shape_editor->move_nodes(0, -10*nudge); // shift
539                             else nc->shape_editor->move_nodes(0, -nudge); // no shift
540                         }
541                         ret = TRUE;
542                     }
543                     break;
544                 case GDK_Escape:
545                 {
546                     NR::Maybe<NR::Rect> const b = Inkscape::Rubberband::get()->getRectangle();
547                     if (b) {
548                         Inkscape::Rubberband::get()->stop();
549                         nc->current_state = SP_NODE_CONTEXT_INACTIVE;
550                         nc->rb_escaped = true;
551                     } else {
552                         if (nc->shape_editor->has_selection()) {
553                             nc->shape_editor->deselect();
554                         } else {
555                             sp_desktop_selection(desktop)->clear();
556                         }
557                     }
558                     ret = TRUE;
559                     break;
560                 }
562                 case GDK_bracketleft:
563                     if ( MOD__CTRL && !MOD__ALT && ( snaps != 0 ) ) {
564                         if (nc->leftctrl)
565                             nc->shape_editor->rotate_nodes (M_PI/snaps, -1, false);
566                         if (nc->rightctrl)
567                             nc->shape_editor->rotate_nodes (M_PI/snaps, 1, false);
568                     } else if ( MOD__ALT && !MOD__CTRL ) {
569                         if (nc->leftalt && nc->rightalt)
570                             nc->shape_editor->rotate_nodes (1, 0, true);
571                         else {
572                             if (nc->leftalt)
573                                 nc->shape_editor->rotate_nodes (1, -1, true);
574                             if (nc->rightalt)
575                                 nc->shape_editor->rotate_nodes (1, 1, true);
576                         }
577                     } else if ( snaps != 0 ) {
578                         nc->shape_editor->rotate_nodes (M_PI/snaps, 0, false);
579                     }
580                     ret = TRUE;
581                     break;
582                 case GDK_bracketright:
583                     if ( MOD__CTRL && !MOD__ALT && ( snaps != 0 ) ) {
584                         if (nc->leftctrl)
585                             nc->shape_editor->rotate_nodes (-M_PI/snaps, -1, false);
586                         if (nc->rightctrl)
587                             nc->shape_editor->rotate_nodes (-M_PI/snaps, 1, false);
588                     } else if ( MOD__ALT && !MOD__CTRL ) {
589                         if (nc->leftalt && nc->rightalt)
590                             nc->shape_editor->rotate_nodes (-1, 0, true);
591                         else {
592                             if (nc->leftalt)
593                                 nc->shape_editor->rotate_nodes (-1, -1, true);
594                             if (nc->rightalt)
595                                 nc->shape_editor->rotate_nodes (-1, 1, true);
596                         }
597                     } else if ( snaps != 0 ) {
598                         nc->shape_editor->rotate_nodes (-M_PI/snaps, 0, false);
599                     }
600                     ret = TRUE;
601                     break;
602                 case GDK_less:
603                 case GDK_comma:
604                     if (MOD__CTRL) {
605                         if (nc->leftctrl)
606                             nc->shape_editor->scale_nodes(-offset, -1);
607                         if (nc->rightctrl)
608                             nc->shape_editor->scale_nodes(-offset, 1);
609                     } else if (MOD__ALT) {
610                         if (nc->leftalt && nc->rightalt)
611                             nc->shape_editor->scale_nodes_screen (-1, 0);
612                         else {
613                             if (nc->leftalt)
614                                 nc->shape_editor->scale_nodes_screen (-1, -1);
615                             if (nc->rightalt)
616                                 nc->shape_editor->scale_nodes_screen (-1, 1);
617                         }
618                     } else {
619                         nc->shape_editor->scale_nodes (-offset, 0);
620                     }
621                     ret = TRUE;
622                     break;
623                 case GDK_greater:
624                 case GDK_period:
625                     if (MOD__CTRL) {
626                         if (nc->leftctrl)
627                             nc->shape_editor->scale_nodes (offset, -1);
628                         if (nc->rightctrl)
629                             nc->shape_editor->scale_nodes (offset, 1);
630                     } else if (MOD__ALT) {
631                         if (nc->leftalt && nc->rightalt)
632                             nc->shape_editor->scale_nodes_screen (1, 0);
633                         else {
634                             if (nc->leftalt)
635                                 nc->shape_editor->scale_nodes_screen (1, -1);
636                             if (nc->rightalt)
637                                 nc->shape_editor->scale_nodes_screen (1, 1);
638                         }
639                     } else {
640                         nc->shape_editor->scale_nodes (offset, 0);
641                     }
642                     ret = TRUE;
643                     break;
645                 case GDK_Alt_L:
646                     nc->leftalt = TRUE;
647                     sp_node_context_show_modifier_tip(event_context, event);
648                     break;
649                 case GDK_Alt_R:
650                     nc->rightalt = TRUE;
651                     sp_node_context_show_modifier_tip(event_context, event);
652                     break;
653                 case GDK_Control_L:
654                     nc->leftctrl = TRUE;
655                     sp_node_context_show_modifier_tip(event_context, event);
656                     break;
657                 case GDK_Control_R:
658                     nc->rightctrl = TRUE;
659                     sp_node_context_show_modifier_tip(event_context, event);
660                     break;
661                 case GDK_Shift_L:
662                 case GDK_Shift_R:
663                 case GDK_Meta_L:
664                 case GDK_Meta_R:
665                     sp_node_context_show_modifier_tip(event_context, event);
666                     break;
667                 default:
668                     ret = node_key(event);
669                     break;
670             }
671             break;
672         case GDK_KEY_RELEASE:
673             switch (get_group0_keyval(&event->key)) {
674                 case GDK_Alt_L:
675                     nc->leftalt = FALSE;
676                     event_context->defaultMessageContext()->clear();
677                     break;
678                 case GDK_Alt_R:
679                     nc->rightalt = FALSE;
680                     event_context->defaultMessageContext()->clear();
681                     break;
682                 case GDK_Control_L:
683                     nc->leftctrl = FALSE;
684                     event_context->defaultMessageContext()->clear();
685                     break;
686                 case GDK_Control_R:
687                     nc->rightctrl = FALSE;
688                     event_context->defaultMessageContext()->clear();
689                     break;
690                 case GDK_Shift_L:
691                 case GDK_Shift_R:
692                 case GDK_Meta_L:
693                 case GDK_Meta_R:
694                     event_context->defaultMessageContext()->clear();
695                     break;
696             }
697             break;
698         default:
699             break;
700     }
702     if (!ret) {
703         if (((SPEventContextClass *) parent_class)->root_handler)
704             ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event);
705     }
707     return ret;
711 /*
712   Local Variables:
713   mode:c++
714   c-file-style:"stroustrup"
715   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
716   indent-tabs-mode:nil
717   fill-column:99
718   End:
719 */
720 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :