1 /** \file
2 * Pen event context implementation.
3 */
5 /*
6 * Authors:
7 * Lauris Kaplinski <lauris@kaplinski.com>
8 * bulia byak <buliabyak@users.sf.net>
9 *
10 * Copyright (C) 2000 Lauris Kaplinski
11 * Copyright (C) 2000-2001 Ximian, Inc.
12 * Copyright (C) 2002 Lauris Kaplinski
13 * Copyright (C) 2004 Monash University
14 *
15 * Released under GNU GPL, read the file 'COPYING' for more information
16 */
18 #include <gdk/gdkkeysyms.h>
19 #include <cstring>
20 #include <string>
22 #include "pen-context.h"
23 #include "sp-namedview.h"
24 #include "sp-metrics.h"
25 #include "desktop.h"
26 #include "desktop-handles.h"
27 #include "selection.h"
28 #include "selection-chemistry.h"
29 #include "draw-anchor.h"
30 #include "message-stack.h"
31 #include "message-context.h"
32 #include "prefs-utils.h"
33 #include "sp-path.h"
34 #include "display/curve.h"
35 #include "pixmaps/cursor-pen.xpm"
36 #include "display/canvas-bpath.h"
37 #include "display/sp-ctrlline.h"
38 #include "display/sodipodi-ctrl.h"
39 #include <glibmm/i18n.h>
40 #include "libnr/n-art-bpath.h"
41 #include "libnr/nr-point-ops.h"
42 #include "helper/units.h"
43 #include "macros.h"
44 #include "context-fns.h"
46 static void sp_pen_context_class_init(SPPenContextClass *klass);
47 static void sp_pen_context_init(SPPenContext *pc);
48 static void sp_pen_context_dispose(GObject *object);
50 static void sp_pen_context_setup(SPEventContext *ec);
51 static void sp_pen_context_finish(SPEventContext *ec);
52 static void sp_pen_context_set(SPEventContext *ec, gchar const *key, gchar const *val);
53 static gint sp_pen_context_root_handler(SPEventContext *ec, GdkEvent *event);
54 static gint sp_pen_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
56 static void spdc_pen_set_initial_point(SPPenContext *pc, NR::Point const p);
57 static void spdc_pen_set_subsequent_point(SPPenContext *pc, NR::Point const p, bool statusbar);
58 static void spdc_pen_set_ctrl(SPPenContext *pc, NR::Point const p, guint state);
59 static void spdc_pen_finish_segment(SPPenContext *pc, NR::Point p, guint state);
61 static void spdc_pen_finish(SPPenContext *pc, gboolean closed);
63 static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const &bevent);
64 static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent);
65 static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent);
66 static gint pen_handle_2button_press(SPPenContext *const pc, GdkEventButton const &bevent);
67 static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event);
68 static void spdc_reset_colors(SPPenContext *pc);
70 static void pen_disable_events(SPPenContext *const pc);
71 static void pen_enable_events(SPPenContext *const pc);
73 static NR::Point pen_drag_origin_w(0, 0);
74 static bool pen_within_tolerance = false;
76 static SPDrawContextClass *pen_parent_class;
78 /**
79 * Register SPPenContext with Gdk and return its type.
80 */
81 GType
82 sp_pen_context_get_type(void)
83 {
84 static GType type = 0;
85 if (!type) {
86 GTypeInfo info = {
87 sizeof(SPPenContextClass),
88 NULL, NULL,
89 (GClassInitFunc) sp_pen_context_class_init,
90 NULL, NULL,
91 sizeof(SPPenContext),
92 4,
93 (GInstanceInitFunc) sp_pen_context_init,
94 NULL, /* value_table */
95 };
96 type = g_type_register_static(SP_TYPE_DRAW_CONTEXT, "SPPenContext", &info, (GTypeFlags)0);
97 }
98 return type;
99 }
101 /**
102 * Initialize the SPPenContext vtable.
103 */
104 static void
105 sp_pen_context_class_init(SPPenContextClass *klass)
106 {
107 GObjectClass *object_class;
108 SPEventContextClass *event_context_class;
110 object_class = (GObjectClass *) klass;
111 event_context_class = (SPEventContextClass *) klass;
113 pen_parent_class = (SPDrawContextClass*)g_type_class_peek_parent(klass);
115 object_class->dispose = sp_pen_context_dispose;
117 event_context_class->setup = sp_pen_context_setup;
118 event_context_class->finish = sp_pen_context_finish;
119 event_context_class->set = sp_pen_context_set;
120 event_context_class->root_handler = sp_pen_context_root_handler;
121 event_context_class->item_handler = sp_pen_context_item_handler;
122 }
124 /**
125 * Callback to initialize SPPenContext object.
126 */
127 static void
128 sp_pen_context_init(SPPenContext *pc)
129 {
131 SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
133 event_context->cursor_shape = cursor_pen_xpm;
134 event_context->hot_x = 4;
135 event_context->hot_y = 4;
137 pc->npoints = 0;
138 pc->mode = SP_PEN_CONTEXT_MODE_CLICK;
139 pc->state = SP_PEN_CONTEXT_POINT;
141 pc->c0 = NULL;
142 pc->c1 = NULL;
143 pc->cl0 = NULL;
144 pc->cl1 = NULL;
146 pc->events_disabled = 0;
148 pc->polylines_only = false;
149 pc->waiting_LPE = NULL;
150 }
152 /**
153 * Callback to destroy the SPPenContext object's members and itself.
154 */
155 static void
156 sp_pen_context_dispose(GObject *object)
157 {
158 SPPenContext *pc;
160 pc = SP_PEN_CONTEXT(object);
162 if (pc->c0) {
163 gtk_object_destroy(GTK_OBJECT(pc->c0));
164 pc->c0 = NULL;
165 }
166 if (pc->c1) {
167 gtk_object_destroy(GTK_OBJECT(pc->c1));
168 pc->c1 = NULL;
169 }
170 if (pc->cl0) {
171 gtk_object_destroy(GTK_OBJECT(pc->cl0));
172 pc->cl0 = NULL;
173 }
174 if (pc->cl1) {
175 gtk_object_destroy(GTK_OBJECT(pc->cl1));
176 pc->cl1 = NULL;
177 }
179 G_OBJECT_CLASS(pen_parent_class)->dispose(object);
181 pc->polylines_only = false;
182 pc->waiting_LPE = NULL;
183 if (pc->expecting_clicks_for_LPE > 0) {
184 // we received too few clicks to sanely set the parameter path so we remove the LPE from the item
185 sp_lpe_item_remove_current_path_effect(pc->waiting_item, false);
186 }
187 }
189 /**
190 * Callback to initialize SPPenContext object.
191 */
192 static void
193 sp_pen_context_setup(SPEventContext *ec)
194 {
195 SPPenContext *pc;
197 pc = SP_PEN_CONTEXT(ec);
199 if (((SPEventContextClass *) pen_parent_class)->setup) {
200 ((SPEventContextClass *) pen_parent_class)->setup(ec);
201 }
203 /* Pen indicators */
204 pc->c0 = sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRL, "shape", SP_CTRL_SHAPE_CIRCLE,
205 "size", 4.0, "filled", 0, "fill_color", 0xff00007f, "stroked", 1, "stroke_color", 0x0000ff7f, NULL);
206 pc->c1 = sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRL, "shape", SP_CTRL_SHAPE_CIRCLE,
207 "size", 4.0, "filled", 0, "fill_color", 0xff00007f, "stroked", 1, "stroke_color", 0x0000ff7f, NULL);
208 pc->cl0 = sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRLLINE, NULL);
209 sp_ctrlline_set_rgba32(SP_CTRLLINE(pc->cl0), 0x0000007f);
210 pc->cl1 = sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRLLINE, NULL);
211 sp_ctrlline_set_rgba32(SP_CTRLLINE(pc->cl1), 0x0000007f);
213 sp_canvas_item_hide(pc->c0);
214 sp_canvas_item_hide(pc->c1);
215 sp_canvas_item_hide(pc->cl0);
216 sp_canvas_item_hide(pc->cl1);
218 sp_event_context_read(ec, "mode");
220 pc->anchor_statusbar = false;
222 if (prefs_get_int_attribute("tools.freehand.pen", "selcue", 0) != 0) {
223 ec->enableSelectionCue();
224 }
225 }
227 static void
228 pen_cancel (SPPenContext *const pc)
229 {
230 pc->state = SP_PEN_CONTEXT_STOP;
231 spdc_reset_colors(pc);
232 sp_canvas_item_hide(pc->c0);
233 sp_canvas_item_hide(pc->c1);
234 sp_canvas_item_hide(pc->cl0);
235 sp_canvas_item_hide(pc->cl1);
236 pc->_message_context->clear();
237 pc->_message_context->flash(Inkscape::NORMAL_MESSAGE, _("Drawing cancelled"));
239 sp_canvas_end_forced_full_redraws(pc->desktop->canvas);
240 }
242 /**
243 * Finalization callback.
244 */
245 static void
246 sp_pen_context_finish(SPEventContext *ec)
247 {
248 SPPenContext *pc = SP_PEN_CONTEXT(ec);
250 if (pc->npoints != 0) {
251 pen_cancel (pc);
252 }
254 if (((SPEventContextClass *) pen_parent_class)->finish) {
255 ((SPEventContextClass *) pen_parent_class)->finish(ec);
256 }
257 }
259 /**
260 * Callback that sets key to value in pen context.
261 */
262 static void
263 sp_pen_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
264 {
265 SPPenContext *pc = SP_PEN_CONTEXT(ec);
267 if (!strcmp(key, "mode")) {
268 if ( val && !strcmp(val, "drag") ) {
269 pc->mode = SP_PEN_CONTEXT_MODE_DRAG;
270 } else {
271 pc->mode = SP_PEN_CONTEXT_MODE_CLICK;
272 }
273 }
274 }
276 /**
277 * Snaps new node relative to the previous node.
278 */
279 static void
280 spdc_endpoint_snap(SPPenContext const *const pc, NR::Point &p, guint const state)
281 {
282 if (pc->npoints > 0) {
283 spdc_endpoint_snap_rotation(pc, p, pc->p[0], state);
284 }
286 spdc_endpoint_snap_free(pc, p, state);
287 }
289 /**
290 * Snaps new node's handle relative to the new node.
291 */
292 static void
293 spdc_endpoint_snap_handle(SPPenContext const *const pc, NR::Point &p, guint const state)
294 {
295 g_return_if_fail(( pc->npoints == 2 ||
296 pc->npoints == 5 ));
298 spdc_endpoint_snap_rotation(pc, p, pc->p[pc->npoints - 2], state);
299 spdc_endpoint_snap_free(pc, p, state);
300 }
302 static gint
303 sp_pen_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event)
304 {
305 SPPenContext *const pc = SP_PEN_CONTEXT(ec);
307 gint ret = FALSE;
309 switch (event->type) {
310 case GDK_BUTTON_PRESS:
311 ret = pen_handle_button_press(pc, event->button);
312 break;
313 default:
314 break;
315 }
317 if (!ret) {
318 if (((SPEventContextClass *) pen_parent_class)->item_handler)
319 ret = ((SPEventContextClass *) pen_parent_class)->item_handler(ec, item, event);
320 }
322 return ret;
323 }
325 /**
326 * Callback to handle all pen events.
327 */
328 static gint
329 sp_pen_context_root_handler(SPEventContext *ec, GdkEvent *event)
330 {
331 SPPenContext *const pc = SP_PEN_CONTEXT(ec);
333 gint ret = FALSE;
335 switch (event->type) {
336 case GDK_BUTTON_PRESS:
337 ret = pen_handle_button_press(pc, event->button);
338 break;
340 case GDK_MOTION_NOTIFY:
341 ret = pen_handle_motion_notify(pc, event->motion);
342 break;
344 case GDK_BUTTON_RELEASE:
345 ret = pen_handle_button_release(pc, event->button);
346 break;
348 case GDK_2BUTTON_PRESS:
349 ret = pen_handle_2button_press(pc, event->button);
350 break;
352 case GDK_KEY_PRESS:
353 ret = pen_handle_key_press(pc, event);
354 break;
356 default:
357 break;
358 }
360 if (!ret) {
361 gint (*const parent_root_handler)(SPEventContext *, GdkEvent *)
362 = ((SPEventContextClass *) pen_parent_class)->root_handler;
363 if (parent_root_handler) {
364 ret = parent_root_handler(ec, event);
365 }
366 }
368 return ret;
369 }
371 /**
372 * Handle mouse button press event.
373 */
374 static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const &bevent)
375 {
376 if (pc->events_disabled) {
377 // skip event processing if events are disabled
378 return FALSE;
379 }
381 SPDrawContext * const dc = SP_DRAW_CONTEXT(pc);
382 SPDesktop * const desktop = SP_EVENT_CONTEXT_DESKTOP(dc);
383 NR::Point const event_w(bevent.x, bevent.y);
384 NR::Point const event_dt(desktop->w2d(event_w));
385 SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
387 gint ret = FALSE;
388 if (bevent.button == 1 && !event_context->space_panning
389 // when the last click for a waiting LPE occurs we want to finish the path
390 && pc->expecting_clicks_for_LPE != 1) {
392 if (Inkscape::have_viable_layer(desktop, dc->_message_context) == false) {
393 return TRUE;
394 }
396 pen_drag_origin_w = event_w;
397 pen_within_tolerance = true;
399 /* Test whether we hit any anchor. */
400 SPDrawAnchor * const anchor = spdc_test_inside(pc, event_w);
402 switch (pc->mode) {
403 case SP_PEN_CONTEXT_MODE_CLICK:
404 /* In click mode we add point on release */
405 switch (pc->state) {
406 case SP_PEN_CONTEXT_POINT:
407 case SP_PEN_CONTEXT_CONTROL:
408 case SP_PEN_CONTEXT_CLOSE:
409 break;
410 case SP_PEN_CONTEXT_STOP:
411 /* This is allowed, if we just cancelled curve */
412 pc->state = SP_PEN_CONTEXT_POINT;
413 break;
414 default:
415 break;
416 }
417 break;
418 case SP_PEN_CONTEXT_MODE_DRAG:
419 switch (pc->state) {
420 case SP_PEN_CONTEXT_STOP:
421 /* This is allowed, if we just cancelled curve */
422 case SP_PEN_CONTEXT_POINT:
423 if (pc->npoints == 0) {
425 if (bevent.state & GDK_CONTROL_MASK) {
426 freehand_create_single_dot(event_context, event_dt, "tools.freehand.pen", bevent.state);
427 ret = TRUE;
428 break;
429 }
431 // TODO: Perhaps it would be nicer to rearrange the following case
432 // distinction so that the case of a waiting LPE is treated separately
434 /* Set start anchor */
435 pc->sa = anchor;
436 NR::Point p;
437 if (anchor && !sp_pen_context_has_waiting_LPE(pc)) {
438 /* Adjust point to anchor if needed; if we have a waiting LPE, we need
439 a fresh path to be created so don't continue an existing one */
440 p = anchor->dp;
441 desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Continuing selected path"));
442 } else {
443 // This is the first click of a new curve; deselect item so that
444 // this curve is not combined with it (unless it is drawn from its
445 // anchor, which is handled by the sibling branch above)
446 Inkscape::Selection * const selection = sp_desktop_selection(desktop);
447 if (!(bevent.state & GDK_SHIFT_MASK) || sp_pen_context_has_waiting_LPE(pc)) {
448 /* if we have a waiting LPE, we need a fresh path to be created
449 so don't append to an existing one */
450 selection->clear();
451 desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating new path"));
452 } else if (selection->singleItem() && SP_IS_PATH(selection->singleItem())) {
453 desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Appending to selected path"));
454 }
456 /* Create green anchor */
457 p = event_dt;
458 spdc_endpoint_snap(pc, p, bevent.state);
459 pc->green_anchor = sp_draw_anchor_new(pc, pc->green_curve, TRUE, p);
460 }
461 spdc_pen_set_initial_point(pc, p);
462 } else {
464 /* Set end anchor */
465 pc->ea = anchor;
466 NR::Point p;
467 if (anchor) {
469 p = anchor->dp;
470 // we hit an anchor, will finish the curve (either with or without closing)
471 // in release handler
472 pc->state = SP_PEN_CONTEXT_CLOSE;
474 if (pc->green_anchor && pc->green_anchor->active) {
475 // we clicked on the current curve start, so close it even if
476 // we drag a handle away from it
477 dc->green_closed = TRUE;
478 }
479 ret = TRUE;
480 break;
482 } else {
484 p = event_dt;
485 spdc_endpoint_snap(pc, p, bevent.state); /* Snap node only if not hitting anchor. */
486 spdc_pen_set_subsequent_point(pc, p, true);
487 if (pc->polylines_only) {
488 spdc_pen_finish_segment(pc, p, bevent.state);
489 }
490 }
492 }
493 pc->state = pc->polylines_only ? SP_PEN_CONTEXT_POINT : SP_PEN_CONTEXT_CONTROL;
494 ret = TRUE;
495 break;
496 case SP_PEN_CONTEXT_CONTROL:
497 g_warning("Button down in CONTROL state");
498 break;
499 case SP_PEN_CONTEXT_CLOSE:
500 g_warning("Button down in CLOSE state");
501 break;
502 default:
503 break;
504 }
505 break;
506 default:
507 break;
508 }
509 } else if (bevent.button == 3 || pc->expecting_clicks_for_LPE == 1) { // when the last click for a waiting LPE occurs we want to finish the path
510 if (pc->npoints != 0) {
512 spdc_pen_finish_segment(pc, event_dt, bevent.state);
513 if (pc->green_closed) {
514 // finishing at the start anchor, close curve
515 spdc_pen_finish(pc, TRUE);
516 } else {
517 // finishing at some other anchor, finish curve but not close
518 spdc_pen_finish(pc, FALSE);
519 }
521 ret = TRUE;
522 }
523 }
525 if (pc->expecting_clicks_for_LPE) {
526 --pc->expecting_clicks_for_LPE;
527 }
529 return ret;
530 }
532 /**
533 * Handle motion_notify event.
534 */
535 static gint
536 pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent)
537 {
538 gint ret = FALSE;
540 SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
542 if (event_context->space_panning || mevent.state & GDK_BUTTON2_MASK || mevent.state & GDK_BUTTON3_MASK) {
543 // allow scrolling
544 return FALSE;
545 }
547 if (pc->events_disabled) {
548 // skip motion events if pen events are disabled
549 return FALSE;
550 }
552 NR::Point const event_w(mevent.x,
553 mevent.y);
554 if (pen_within_tolerance) {
555 gint const tolerance = prefs_get_int_attribute_limited("options.dragtolerance",
556 "value", 0, 0, 100);
557 if ( NR::LInfty( event_w - pen_drag_origin_w ) < tolerance ) {
558 return FALSE; // Do not drag if we're within tolerance from origin.
559 }
560 }
561 // Once the user has moved farther than tolerance from the original location
562 // (indicating they intend to move the object, not click), then always process the
563 // motion notify coordinates as given (no snapping back to origin)
564 pen_within_tolerance = false;
566 SPDesktop *const dt = pc->desktop;
567 if ( ( mevent.state & GDK_BUTTON1_MASK ) && !pc->grab ) {
568 /* Grab mouse, so release will not pass unnoticed */
569 pc->grab = SP_CANVAS_ITEM(dt->acetate);
570 sp_canvas_item_grab(pc->grab, ( GDK_KEY_PRESS_MASK | GDK_BUTTON_PRESS_MASK |
571 GDK_BUTTON_RELEASE_MASK |
572 GDK_POINTER_MOTION_MASK ),
573 NULL, mevent.time);
574 }
576 /* Find desktop coordinates */
577 NR::Point p = dt->w2d(event_w);
579 /* Test, whether we hit any anchor */
580 SPDrawAnchor *anchor = spdc_test_inside(pc, event_w);
582 switch (pc->mode) {
583 case SP_PEN_CONTEXT_MODE_CLICK:
584 switch (pc->state) {
585 case SP_PEN_CONTEXT_POINT:
586 if ( pc->npoints != 0 ) {
587 /* Only set point, if we are already appending */
588 spdc_endpoint_snap(pc, p, mevent.state);
589 spdc_pen_set_subsequent_point(pc, p, true);
590 ret = TRUE;
591 }
592 break;
593 case SP_PEN_CONTEXT_CONTROL:
594 case SP_PEN_CONTEXT_CLOSE:
595 /* Placing controls is last operation in CLOSE state */
596 spdc_endpoint_snap(pc, p, mevent.state);
597 spdc_pen_set_ctrl(pc, p, mevent.state);
598 ret = TRUE;
599 break;
600 case SP_PEN_CONTEXT_STOP:
601 /* This is perfectly valid */
602 break;
603 default:
604 break;
605 }
606 break;
607 case SP_PEN_CONTEXT_MODE_DRAG:
608 switch (pc->state) {
609 case SP_PEN_CONTEXT_POINT:
610 if ( pc->npoints > 0 ) {
611 /* Only set point, if we are already appending */
613 if (!anchor) { /* Snap node only if not hitting anchor */
614 spdc_endpoint_snap(pc, p, mevent.state);
615 }
617 spdc_pen_set_subsequent_point(pc, p, !anchor);
619 if (anchor && !pc->anchor_statusbar) {
620 pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> or <b>click and drag</b> to close and finish the path."));
621 pc->anchor_statusbar = true;
622 } else if (!anchor && pc->anchor_statusbar) {
623 pc->_message_context->clear();
624 pc->anchor_statusbar = false;
625 }
627 ret = TRUE;
628 } else {
629 if (anchor && !pc->anchor_statusbar) {
630 pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> or <b>click and drag</b> to continue the path from this point."));
631 pc->anchor_statusbar = true;
632 } else if (!anchor && pc->anchor_statusbar) {
633 pc->_message_context->clear();
634 pc->anchor_statusbar = false;
635 }
636 }
637 break;
638 case SP_PEN_CONTEXT_CONTROL:
639 case SP_PEN_CONTEXT_CLOSE:
640 /* Placing controls is last operation in CLOSE state */
642 // snap the handle
643 spdc_endpoint_snap_handle(pc, p, mevent.state);
645 if (!pc->polylines_only) {
646 spdc_pen_set_ctrl(pc, p, mevent.state);
647 } else {
648 spdc_pen_set_ctrl(pc, pc->p[1], mevent.state);
649 }
650 gobble_motion_events(GDK_BUTTON1_MASK);
651 ret = TRUE;
652 break;
653 case SP_PEN_CONTEXT_STOP:
654 /* This is perfectly valid */
655 break;
656 default:
657 break;
658 }
659 break;
660 default:
661 break;
662 }
663 return ret;
664 }
666 /**
667 * Handle mouse button release event.
668 */
669 static gint
670 pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent)
671 {
672 if (pc->events_disabled) {
673 // skip event processing if events are disabled
674 return FALSE;
675 }
677 gint ret = FALSE;
678 SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
679 if ( revent.button == 1 && !event_context->space_panning) {
681 SPDrawContext *dc = SP_DRAW_CONTEXT (pc);
683 NR::Point const event_w(revent.x,
684 revent.y);
685 /* Find desktop coordinates */
686 NR::Point p = pc->desktop->w2d(event_w);
688 /* Test whether we hit any anchor. */
689 SPDrawAnchor *anchor = spdc_test_inside(pc, event_w);
691 switch (pc->mode) {
692 case SP_PEN_CONTEXT_MODE_CLICK:
693 switch (pc->state) {
694 case SP_PEN_CONTEXT_POINT:
695 if ( pc->npoints == 0 ) {
696 /* Start new thread only with button release */
697 if (anchor) {
698 p = anchor->dp;
699 }
700 pc->sa = anchor;
701 spdc_pen_set_initial_point(pc, p);
702 } else {
703 /* Set end anchor here */
704 pc->ea = anchor;
705 if (anchor) {
706 p = anchor->dp;
707 }
708 }
709 pc->state = SP_PEN_CONTEXT_CONTROL;
710 ret = TRUE;
711 break;
712 case SP_PEN_CONTEXT_CONTROL:
713 /* End current segment */
714 spdc_endpoint_snap(pc, p, revent.state);
715 spdc_pen_finish_segment(pc, p, revent.state);
716 pc->state = SP_PEN_CONTEXT_POINT;
717 ret = TRUE;
718 break;
719 case SP_PEN_CONTEXT_CLOSE:
720 /* End current segment */
721 if (!anchor) { /* Snap node only if not hitting anchor */
722 spdc_endpoint_snap(pc, p, revent.state);
723 }
724 spdc_pen_finish_segment(pc, p, revent.state);
725 spdc_pen_finish(pc, TRUE);
726 pc->state = SP_PEN_CONTEXT_POINT;
727 ret = TRUE;
728 break;
729 case SP_PEN_CONTEXT_STOP:
730 /* This is allowed, if we just cancelled curve */
731 pc->state = SP_PEN_CONTEXT_POINT;
732 ret = TRUE;
733 break;
734 default:
735 break;
736 }
737 break;
738 case SP_PEN_CONTEXT_MODE_DRAG:
739 switch (pc->state) {
740 case SP_PEN_CONTEXT_POINT:
741 case SP_PEN_CONTEXT_CONTROL:
742 if (!pc->polylines_only) {
743 spdc_endpoint_snap(pc, p, revent.state);
744 spdc_pen_finish_segment(pc, p, revent.state);
745 }
746 break;
747 case SP_PEN_CONTEXT_CLOSE:
748 spdc_endpoint_snap(pc, p, revent.state);
749 spdc_pen_finish_segment(pc, p, revent.state);
750 if (pc->green_closed) {
751 // finishing at the start anchor, close curve
752 spdc_pen_finish(pc, TRUE);
753 } else {
754 // finishing at some other anchor, finish curve but not close
755 spdc_pen_finish(pc, FALSE);
756 }
757 break;
758 case SP_PEN_CONTEXT_STOP:
759 /* This is allowed, if we just cancelled curve */
760 break;
761 default:
762 break;
763 }
764 pc->state = SP_PEN_CONTEXT_POINT;
765 ret = TRUE;
766 break;
767 default:
768 break;
769 }
771 if (pc->grab) {
772 /* Release grab now */
773 sp_canvas_item_ungrab(pc->grab, revent.time);
774 pc->grab = NULL;
775 }
777 ret = TRUE;
779 dc->green_closed = FALSE;
780 }
782 // TODO: can we be sure that the path was created correctly?
783 // TODO: should we offer an option to collect the clicks in a list?
784 if (pc->expecting_clicks_for_LPE == 0 && sp_pen_context_has_waiting_LPE(pc)) {
785 pc->polylines_only = false;
787 SPEventContext *ec = SP_EVENT_CONTEXT(pc);
788 Inkscape::Selection *selection = sp_desktop_selection (ec->desktop);
790 if (pc->waiting_LPE) {
791 // we have an already created LPE waiting for a path
792 pc->waiting_LPE->acceptParamPath(SP_PATH(selection->singleItem()));
793 selection->add(SP_OBJECT(pc->waiting_item));
794 pc->waiting_LPE = NULL;
795 pc->polylines_only = false;
796 } else {
797 // the case that we need to create a new LPE and apply it to the just-drawn path is
798 // handled in spdc_check_for_and_apply_waiting_LPE() in draw-context.cpp
799 }
800 }
802 return ret;
803 }
805 static gint
806 pen_handle_2button_press(SPPenContext *const pc, GdkEventButton const &bevent)
807 {
808 gint ret = FALSE;
809 if (pc->npoints != 0 && bevent.button != 2) {
810 spdc_pen_finish(pc, FALSE);
811 ret = TRUE;
812 }
813 return ret;
814 }
816 void
817 pen_redraw_all (SPPenContext *const pc)
818 {
819 // green
820 if (pc->green_bpaths) {
821 // remove old piecewise green canvasitems
822 while (pc->green_bpaths) {
823 gtk_object_destroy(GTK_OBJECT(pc->green_bpaths->data));
824 pc->green_bpaths = g_slist_remove(pc->green_bpaths, pc->green_bpaths->data);
825 }
826 // one canvas bpath for all of green_curve
827 SPCanvasItem *cshape = sp_canvas_bpath_new(sp_desktop_sketch(pc->desktop), pc->green_curve);
828 sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), pc->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
829 sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cshape), 0, SP_WIND_RULE_NONZERO);
831 pc->green_bpaths = g_slist_prepend(pc->green_bpaths, cshape);
832 }
834 if (pc->green_anchor)
835 SP_CTRL(pc->green_anchor->ctrl)->moveto(pc->green_anchor->dp);
837 pc->red_curve->reset();
838 pc->red_curve->moveto(pc->p[0]);
839 pc->red_curve->curveto(pc->p[1], pc->p[2], pc->p[3]);
840 sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve);
842 // handles
843 if (pc->p[0] != pc->p[1]) {
844 SP_CTRL(pc->c1)->moveto(pc->p[1]);
845 sp_ctrlline_set_coords(SP_CTRLLINE(pc->cl1), pc->p[0], pc->p[1]);
846 sp_canvas_item_show (pc->c1);
847 sp_canvas_item_show (pc->cl1);
848 } else {
849 sp_canvas_item_hide (pc->c1);
850 sp_canvas_item_hide (pc->cl1);
851 }
853 NArtBpath const * bpath = pc->green_curve->last_bpath();
854 if (bpath) {
855 if (bpath->code == NR_CURVETO && NR::Point(bpath->x2, bpath->y2) != pc->p[0]) {
856 SP_CTRL(pc->c0)->moveto(NR::Point(bpath->x2, bpath->y2));
857 sp_ctrlline_set_coords(SP_CTRLLINE(pc->cl0), NR::Point(bpath->x2, bpath->y2), pc->p[0]);
858 sp_canvas_item_show (pc->c0);
859 sp_canvas_item_show (pc->cl0);
860 } else {
861 sp_canvas_item_hide (pc->c0);
862 sp_canvas_item_hide (pc->cl0);
863 }
864 }
865 }
867 void
868 pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y)
869 {
870 if (pc->npoints != 5)
871 return;
873 // green
874 NArtBpath const * bpath = pc->green_curve->last_bpath();
875 if (bpath) {
876 pc->green_curve->last_point_additive_move( Geom::Point(x,y) );
877 } else {
878 // start anchor too
879 if (pc->green_anchor) {
880 pc->green_anchor->dp += NR::Point(x, y);
881 }
882 }
884 // red
885 pc->p[0] += NR::Point(x, y);
886 pc->p[1] += NR::Point(x, y);
887 pen_redraw_all(pc);
888 }
890 void
891 pen_lastpoint_move_screen (SPPenContext *const pc, gdouble x, gdouble y)
892 {
893 pen_lastpoint_move (pc, x / pc->desktop->current_zoom(), y / pc->desktop->current_zoom());
894 }
896 void
897 pen_lastpoint_tocurve (SPPenContext *const pc)
898 {
899 if (pc->npoints != 5)
900 return;
902 // red
903 NArtBpath const * bpath = pc->green_curve->last_bpath();
904 if (bpath && bpath->code == NR_CURVETO) {
905 pc->p[1] = pc->p[0] + (NR::Point(bpath->x3, bpath->y3) - NR::Point(bpath->x2, bpath->y2));
906 } else {
907 pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]);
908 }
910 pen_redraw_all(pc);
911 }
913 void
914 pen_lastpoint_toline (SPPenContext *const pc)
915 {
916 if (pc->npoints != 5)
917 return;
919 pc->p[1] = pc->p[0];
921 pen_redraw_all(pc);
922 }
925 static gint
926 pen_handle_key_press(SPPenContext *const pc, GdkEvent *event)
927 {
928 gint ret = FALSE;
929 gdouble const nudge = prefs_get_double_attribute_limited("options.nudgedistance", "value", 2, 0, 1000); // in px
931 switch (get_group0_keyval (&event->key)) {
933 case GDK_Left: // move last point left
934 case GDK_KP_Left:
935 case GDK_KP_4:
936 if (!MOD__CTRL) { // not ctrl
937 if (MOD__ALT) { // alt
938 if (MOD__SHIFT) pen_lastpoint_move_screen(pc, -10, 0); // shift
939 else pen_lastpoint_move_screen(pc, -1, 0); // no shift
940 }
941 else { // no alt
942 if (MOD__SHIFT) pen_lastpoint_move(pc, -10*nudge, 0); // shift
943 else pen_lastpoint_move(pc, -nudge, 0); // no shift
944 }
945 ret = TRUE;
946 }
947 break;
948 case GDK_Up: // move last point up
949 case GDK_KP_Up:
950 case GDK_KP_8:
951 if (!MOD__CTRL) { // not ctrl
952 if (MOD__ALT) { // alt
953 if (MOD__SHIFT) pen_lastpoint_move_screen(pc, 0, 10); // shift
954 else pen_lastpoint_move_screen(pc, 0, 1); // no shift
955 }
956 else { // no alt
957 if (MOD__SHIFT) pen_lastpoint_move(pc, 0, 10*nudge); // shift
958 else pen_lastpoint_move(pc, 0, nudge); // no shift
959 }
960 ret = TRUE;
961 }
962 break;
963 case GDK_Right: // move last point right
964 case GDK_KP_Right:
965 case GDK_KP_6:
966 if (!MOD__CTRL) { // not ctrl
967 if (MOD__ALT) { // alt
968 if (MOD__SHIFT) pen_lastpoint_move_screen(pc, 10, 0); // shift
969 else pen_lastpoint_move_screen(pc, 1, 0); // no shift
970 }
971 else { // no alt
972 if (MOD__SHIFT) pen_lastpoint_move(pc, 10*nudge, 0); // shift
973 else pen_lastpoint_move(pc, nudge, 0); // no shift
974 }
975 ret = TRUE;
976 }
977 break;
978 case GDK_Down: // move last point down
979 case GDK_KP_Down:
980 case GDK_KP_2:
981 if (!MOD__CTRL) { // not ctrl
982 if (MOD__ALT) { // alt
983 if (MOD__SHIFT) pen_lastpoint_move_screen(pc, 0, -10); // shift
984 else pen_lastpoint_move_screen(pc, 0, -1); // no shift
985 }
986 else { // no alt
987 if (MOD__SHIFT) pen_lastpoint_move(pc, 0, -10*nudge); // shift
988 else pen_lastpoint_move(pc, 0, -nudge); // no shift
989 }
990 ret = TRUE;
991 }
992 break;
994 case GDK_U:
995 case GDK_u:
996 if (MOD__SHIFT_ONLY) {
997 pen_lastpoint_tocurve(pc);
998 ret = TRUE;
999 }
1000 break;
1001 case GDK_L:
1002 case GDK_l:
1003 if (MOD__SHIFT_ONLY) {
1004 pen_lastpoint_toline(pc);
1005 ret = TRUE;
1006 }
1007 break;
1009 case GDK_Return:
1010 case GDK_KP_Enter:
1011 if (pc->npoints != 0) {
1012 spdc_pen_finish(pc, FALSE);
1013 ret = TRUE;
1014 }
1015 break;
1016 case GDK_Escape:
1017 if (pc->npoints != 0) {
1018 // if drawing, cancel, otherwise pass it up for deselecting
1019 pen_cancel (pc);
1020 ret = TRUE;
1021 }
1022 break;
1023 case GDK_z:
1024 case GDK_Z:
1025 if (MOD__CTRL_ONLY && pc->npoints != 0) {
1026 // if drawing, cancel, otherwise pass it up for undo
1027 pen_cancel (pc);
1028 ret = TRUE;
1029 }
1030 break;
1031 case GDK_g:
1032 case GDK_G:
1033 if (MOD__SHIFT_ONLY) {
1034 sp_selection_to_guides();
1035 ret = true;
1036 }
1037 break;
1038 case GDK_BackSpace:
1039 case GDK_Delete:
1040 case GDK_KP_Delete:
1041 if (pc->green_curve->is_empty()) {
1042 if (!pc->red_curve->is_empty()) {
1043 pen_cancel (pc);
1044 ret = TRUE;
1045 } else {
1046 // do nothing; this event should be handled upstream
1047 }
1048 } else {
1049 /* Reset red curve */
1050 pc->red_curve->reset();
1051 /* Destroy topmost green bpath */
1052 if (pc->green_bpaths) {
1053 if (pc->green_bpaths->data)
1054 gtk_object_destroy(GTK_OBJECT(pc->green_bpaths->data));
1055 pc->green_bpaths = g_slist_remove(pc->green_bpaths, pc->green_bpaths->data);
1056 }
1057 /* Get last segment */
1058 NArtBpath const *const p = SP_CURVE_BPATH(pc->green_curve);
1059 gint const e = SP_CURVE_LENGTH(pc->green_curve);
1060 if ( e < 2 ) {
1061 g_warning("Green curve length is %d", e);
1062 break;
1063 }
1064 pc->p[0] = p[e - 2].c(3);
1065 if (p[e - 1].code == NR_CURVETO) {
1066 pc->p[1] = p[e - 1].c(1);
1067 } else {
1068 pc->p[1] = pc->p[0];
1069 }
1070 NR::Point const pt(( pc->npoints < 4
1071 ? p[e - 1].c(3)
1072 : pc->p[3] ));
1073 pc->npoints = 2;
1074 pc->green_curve->backspace();
1075 sp_canvas_item_hide(pc->c0);
1076 sp_canvas_item_hide(pc->c1);
1077 sp_canvas_item_hide(pc->cl0);
1078 sp_canvas_item_hide(pc->cl1);
1079 pc->state = SP_PEN_CONTEXT_POINT;
1080 spdc_pen_set_subsequent_point(pc, pt, true);
1081 ret = TRUE;
1082 }
1083 break;
1084 default:
1085 break;
1086 }
1087 return ret;
1088 }
1090 static void
1091 spdc_reset_colors(SPPenContext *pc)
1092 {
1093 /* Red */
1094 pc->red_curve->reset();
1095 sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), NULL);
1096 /* Blue */
1097 pc->blue_curve->reset();
1098 sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->blue_bpath), NULL);
1099 /* Green */
1100 while (pc->green_bpaths) {
1101 gtk_object_destroy(GTK_OBJECT(pc->green_bpaths->data));
1102 pc->green_bpaths = g_slist_remove(pc->green_bpaths, pc->green_bpaths->data);
1103 }
1104 pc->green_curve->reset();
1105 if (pc->green_anchor) {
1106 pc->green_anchor = sp_draw_anchor_destroy(pc->green_anchor);
1107 }
1108 pc->sa = NULL;
1109 pc->ea = NULL;
1110 pc->npoints = 0;
1111 pc->red_curve_is_valid = false;
1112 }
1115 static void
1116 spdc_pen_set_initial_point(SPPenContext *const pc, NR::Point const p)
1117 {
1118 g_assert( pc->npoints == 0 );
1120 pc->p[0] = p;
1121 pc->p[1] = p;
1122 pc->npoints = 2;
1123 sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), NULL);
1125 sp_canvas_force_full_redraw_after_interruptions(pc->desktop->canvas, 5);
1126 }
1128 /**
1129 * Show the status message for the current line/curve segment.
1130 * This type of message always shows angle/distance as the last
1131 * two parameters ("angle %3.2f°, distance %s").
1132 */
1133 static void
1134 spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, NR::Point const p, int pc_point_to_compare, gchar const *message)
1135 {
1136 g_assert(pc != NULL);
1137 g_assert((pc_point_to_compare == 0) || (pc_point_to_compare == 3)); // exclude control handles
1138 g_assert(message != NULL);
1140 SPDesktop *desktop = SP_EVENT_CONTEXT(pc)->desktop;
1141 NR::Point rel = p - pc->p[pc_point_to_compare];
1142 GString *dist = SP_PX_TO_METRIC_STRING(NR::L2(rel), desktop->namedview->getDefaultMetric());
1143 double angle = atan2(rel[NR::Y], rel[NR::X]) * 180 / M_PI;
1144 if (prefs_get_int_attribute("options.compassangledisplay", "value", 0) != 0)
1145 angle = angle_to_compass (angle);
1147 pc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, message, angle, dist->str);
1148 g_string_free(dist, FALSE);
1149 }
1151 static void
1152 spdc_pen_set_subsequent_point(SPPenContext *const pc, NR::Point const p, bool statusbar)
1153 {
1154 g_assert( pc->npoints != 0 );
1155 /* todo: Check callers to see whether 2 <= npoints is guaranteed. */
1157 pc->p[2] = p;
1158 pc->p[3] = p;
1159 pc->p[4] = p;
1160 pc->npoints = 5;
1161 pc->red_curve->reset();
1162 pc->red_curve->moveto(pc->p[0]);
1163 bool is_curve;
1164 if (pc->p[1] != pc->p[0])
1165 {
1166 pc->red_curve->curveto(pc->p[1], p, p);
1167 is_curve = true;
1168 } else {
1169 pc->red_curve->lineto(p);
1170 is_curve = false;
1171 }
1173 sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve);
1175 if (statusbar) {
1176 gchar *message = is_curve ?
1177 _("<b>Curve segment</b>: angle %3.2f°, distance %s; with <b>Ctrl</b> to snap angle, <b>Enter</b> to finish the path" ):
1178 _("<b>Line segment</b>: angle %3.2f°, distance %s; with <b>Ctrl</b> to snap angle, <b>Enter</b> to finish the path");
1179 spdc_pen_set_angle_distance_status_message(pc, p, 0, message);
1180 }
1181 }
1183 static void
1184 spdc_pen_set_ctrl(SPPenContext *const pc, NR::Point const p, guint const state)
1185 {
1186 sp_canvas_item_show(pc->c1);
1187 sp_canvas_item_show(pc->cl1);
1189 if ( pc->npoints == 2 ) {
1190 pc->p[1] = p;
1191 sp_canvas_item_hide(pc->c0);
1192 sp_canvas_item_hide(pc->cl0);
1193 SP_CTRL(pc->c1)->moveto(pc->p[1]);
1194 sp_ctrlline_set_coords(SP_CTRLLINE(pc->cl1), pc->p[0], pc->p[1]);
1196 spdc_pen_set_angle_distance_status_message(pc, p, 0, _("<b>Curve handle</b>: angle %3.2f°, length %s; with <b>Ctrl</b> to snap angle"));
1197 } else if ( pc->npoints == 5 ) {
1198 pc->p[4] = p;
1199 sp_canvas_item_show(pc->c0);
1200 sp_canvas_item_show(pc->cl0);
1201 bool is_symm = false;
1202 if ( ( ( pc->mode == SP_PEN_CONTEXT_MODE_CLICK ) && ( state & GDK_CONTROL_MASK ) ) ||
1203 ( ( pc->mode == SP_PEN_CONTEXT_MODE_DRAG ) && !( state & GDK_SHIFT_MASK ) ) ) {
1204 NR::Point delta = p - pc->p[3];
1205 pc->p[2] = pc->p[3] - delta;
1206 is_symm = true;
1207 pc->red_curve->reset();
1208 pc->red_curve->moveto(pc->p[0]);
1209 pc->red_curve->curveto(pc->p[1], pc->p[2], pc->p[3]);
1210 sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve);
1211 }
1212 SP_CTRL(pc->c0)->moveto(pc->p[2]);
1213 sp_ctrlline_set_coords(SP_CTRLLINE(pc->cl0), pc->p[3], pc->p[2]);
1214 SP_CTRL(pc->c1)->moveto(pc->p[4]);
1215 sp_ctrlline_set_coords(SP_CTRLLINE(pc->cl1), pc->p[3], pc->p[4]);
1217 gchar *message = is_symm ?
1218 _("<b>Curve handle, symmetric</b>: angle %3.2f°, length %s; with <b>Ctrl</b> to snap angle, with <b>Shift</b> to move this handle only") :
1219 _("<b>Curve handle</b>: angle %3.2f°, length %s; with <b>Ctrl</b> to snap angle, with <b>Shift</b> to move this handle only");
1220 spdc_pen_set_angle_distance_status_message(pc, p, 3, message);
1221 } else {
1222 g_warning("Something bad happened - npoints is %d", pc->npoints);
1223 }
1224 }
1226 static void
1227 spdc_pen_finish_segment(SPPenContext *const pc, NR::Point const /*p*/, guint const /*state*/)
1228 {
1229 if (!pc->red_curve->is_empty()) {
1230 pc->green_curve->append_continuous(pc->red_curve, 0.0625);
1231 SPCurve *curve = pc->red_curve->copy();
1232 /// \todo fixme:
1233 SPCanvasItem *cshape = sp_canvas_bpath_new(sp_desktop_sketch(pc->desktop), curve);
1234 curve->unref();
1235 sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), pc->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
1237 pc->green_bpaths = g_slist_prepend(pc->green_bpaths, cshape);
1239 pc->p[0] = pc->p[3];
1240 pc->p[1] = pc->p[4];
1241 pc->npoints = 2;
1243 pc->red_curve->reset();
1244 }
1245 }
1247 static void
1248 spdc_pen_finish(SPPenContext *const pc, gboolean const closed)
1249 {
1250 if (pc->expecting_clicks_for_LPE > 1) {
1251 // don't let the path be finished before we have collected the required number of mouse clicks
1252 return;
1253 }
1255 pen_disable_events(pc);
1257 SPDesktop *const desktop = pc->desktop;
1258 pc->_message_context->clear();
1259 desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Drawing finished"));
1261 pc->red_curve->reset();
1262 spdc_concat_colors_and_flush(pc, closed);
1263 pc->sa = NULL;
1264 pc->ea = NULL;
1266 pc->npoints = 0;
1267 pc->state = SP_PEN_CONTEXT_POINT;
1269 sp_canvas_item_hide(pc->c0);
1270 sp_canvas_item_hide(pc->c1);
1271 sp_canvas_item_hide(pc->cl0);
1272 sp_canvas_item_hide(pc->cl1);
1274 if (pc->green_anchor) {
1275 pc->green_anchor = sp_draw_anchor_destroy(pc->green_anchor);
1276 }
1279 sp_canvas_end_forced_full_redraws(pc->desktop->canvas);
1281 pen_enable_events(pc);
1282 }
1284 static void
1285 pen_disable_events(SPPenContext *const pc) {
1286 pc->events_disabled++;
1287 }
1289 static void
1290 pen_enable_events(SPPenContext *const pc) {
1291 g_return_if_fail(pc->events_disabled != 0);
1293 pc->events_disabled--;
1294 }
1296 /*
1297 Local Variables:
1298 mode:c++
1299 c-file-style:"stroustrup"
1300 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
1301 indent-tabs-mode:nil
1302 fill-column:99
1303 End:
1304 */
1305 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :