pencil-context.cpp revision 32d45022bee1aac3efef2614be44ea1faf944227
/** \file
* Pencil event context implementation.
*/
/*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
*
* Copyright (C) 2000 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
* Copyright (C) 2002 Lauris Kaplinski
* Copyright (C) 2004 Monash University
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <gdk/gdkkeysyms.h>
#include "pencil-context.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "selection.h"
#include "selection-chemistry.h"
#include "draw-anchor.h"
#include "message-stack.h"
#include "message-context.h"
#include "modifier-fns.h"
#include "sp-path.h"
#include "prefs-utils.h"
#include "snap.h"
#include "pixmaps/cursor-pencil.xpm"
#include "display/bezier-utils.h"
#include "display/canvas-bpath.h"
#include "libnr/in-svg-plane.h"
#include "libnr/n-art-bpath.h"
#include "context-fns.h"
#include "sp-namedview.h"
#include "document.h"
#include "desktop-style.h"
#include "macros.h"
static gint pencil_handle_key_press(SPPencilContext *const pc, guint const keyval, guint const state);
static SPDrawContextClass *pencil_parent_class;
/**
* Register SPPencilContext class with Gdk and return its type number.
*/
{
if (!type) {
sizeof(SPPencilContextClass),
sizeof(SPPencilContext),
4,
NULL, /* value_table */
};
}
return type;
}
/**
* Initialize SPPencilContext vtable.
*/
static void
{
}
/**
* Callback to initialize SPPencilContext object.
*/
static void
{
}
/**
* Callback to setup SPPencilContext object.
*/
static void
{
ec->enableSelectionCue();
}
}
pc->is_drawing = false;
pc->anchor_statusbar = false;
}
static void
{
}
/** Snaps new node relative to the previous node. */
static void
{
}
/**
* Callback for handling all pencil context events.
*/
{
case GDK_BUTTON_PRESS:
break;
case GDK_MOTION_NOTIFY:
break;
case GDK_BUTTON_RELEASE:
break;
case GDK_KEY_PRESS:
break;
default:
break;
}
if (!ret) {
if (parent_root_handler) {
}
}
return ret;
}
static gint
{
return TRUE;
}
/* Find desktop coordinates */
/* Test whether we hit any anchor. */
/* Current segment will be finished with release */
break;
default:
/* Set first point of sequence */
freehand_create_single_dot(event_context, p, "tools.freehand.pencil", bevent.state & GDK_SHIFT_MASK);
ret = true;
break;
}
if (anchor) {
} else {
// This is the first click of a new curve; deselect item so that
// this curve is not combined with it (unless it is drawn from its
// anchor, which is handled by the sibling branch above)
}
}
spdc_set_startpoint(pc, p);
break;
}
pc->is_drawing = true;
}
return ret;
}
static gint
{
// mouse was accidentally moved during Ctrl+click;
// ignore the motion and create a single point
return TRUE;
}
if (event_context->space_panning || mevent.state & GDK_BUTTON2_MASK || mevent.state & GDK_BUTTON3_MASK) {
// allow scrolling
return FALSE;
}
/* Grab mouse, so release will not pass unnoticed */
}
/* Find desktop coordinates */
/* Test whether we hit any anchor. */
/* Set red endpoint */
if (anchor) {
} else {
}
spdc_set_endpoint(pc, p);
break;
default:
/* We may be idle or already freehand */
/* Create green anchor */
}
/** \todo
* fixme: I am not sure whether we want to snap to anchors
* in middle of freehand (Lauris)
*/
if (anchor) {
}
}
pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Release</b> here to close and finish the path."));
pc->anchor_statusbar = true;
pc->anchor_statusbar = false;
} else if (!anchor) {
}
} else {
pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to continue the path from this point."));
pc->anchor_statusbar = true;
pc->anchor_statusbar = false;
}
}
break;
}
return ret;
}
static gint
{
pc->is_drawing = false;
/* Find desktop coordinates */
/* Test whether we hit any anchor. */
revent.y));
case SP_PENCIL_CONTEXT_IDLE:
/* Releasing button in idle mode means single click */
// Ctrl+click creates a single point so only set context in ADDLINE mode when Ctrl isn't pressed
}
break;
/* Finish segment now */
if (anchor) {
} else {
}
spdc_set_endpoint(pc, p);
break;
/* Finish segment now */
/// \todo fixme: Clean up what follows (Lauris)
if (anchor) {
}
/* Write curves to object */
if (pc->green_anchor) {
}
break;
default:
break;
}
/* Release grab now */
}
}
return ret;
}
static void
{
/* Release grab now */
}
pc->is_drawing = false;
while (pc->green_bpaths) {
}
if (pc->green_anchor) {
}
}
static gint
{
switch (keyval) {
case GDK_Up:
case GDK_Down:
case GDK_KP_Up:
case GDK_KP_Down:
// Prevent the zoom field from activation.
if (!mod_ctrl_only(state)) {
}
break;
case GDK_Escape:
// if drawing, cancel, otherwise pass it up for deselecting
if (pc->is_drawing) {
pencil_cancel (pc);
}
}
break;
case GDK_z:
case GDK_Z:
// if drawing, cancel, otherwise pass it up for undo
if (pc->is_drawing) {
pencil_cancel (pc);
}
}
break;
case GDK_g:
case GDK_G:
if (mod_shift_only(state)) {
ret = true;
}
break;
default:
break;
}
return ret;
}
/**
* Reset points and set new starting point.
*/
static void
{
pc->red_curve_is_valid = false;
if (in_svg_plane(p)) {
}
}
/**
* Change moving endpoint position.
* <ul>
* <li>Ctrl constrains to moving to H/V direction, snapping in given direction.
* <li>Otherwise we snap freely to whatever attractors are available.
* </ul>
*
* Number of points is (re)set to 2 always, 2nd point is modified.
* We change RED curve.
*/
static void
{
return;
/* May occur if first point wasn't in SVG plane (e.g. weird w2d transform, perhaps from bad
* zoom setting).
*/
}
if ( ( p == pc->p[0] )
|| !in_svg_plane(p) )
{
} else {
pc->p[1] = p;
pc->red_curve_is_valid = true;
}
}
/**
* Finalize addline.
*
* \todo
* fixme: I'd like remove red reset from concat colors (lauris).
* Still not sure, how it will make most sense.
*/
static void
{
{
} else {
/* Write curves to object. */
}
}
static void
{
&& in_svg_plane(p) )
{
}
}
static inline double
square(double const x)
{
return x * x;
}
static void
{
* prefs_get_double_attribute_limited("tools.freehand.pencil",
"tolerance", 10.0, 1.0, 100.0) );
if ( n_segs > 0
{
/* Fit and draw and reset state */
pc->red_curve_is_valid = true;
} else {
/* Fit and draw and copy last point */
/* Set up direction of next curve. */
{
/* Relevance: validity of last_seg.c(2). */
}
/// \todo fixme:
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), pc->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
pc->red_curve_is_valid = false;
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :