knot.cpp revision cb636f65fa2a5cd40ff3d571719326351ae68ad8
/*
* SPKnot implementation
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Abhishek Sharma
*
* Copyright (C) 1999-2005 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gdk/gdkkeysyms.h>
#include "helper/sp-marshal.h"
#include "display/sodipodi-ctrl.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "knot.h"
#include "document.h"
#include "document-undo.h"
#include "preferences.h"
#include "message-stack.h"
#include "message-context.h"
#include "event-context.h"
using Inkscape::DocumentUndo;
#include "compat-key-syms.h"
#endif
static bool nograb = false;
static bool within_tolerance = false;
static bool transform_escaped = false; // true iff resize or rotate was cancelled by esc.
enum {
};
static GObjectClass *parent_class;
{
if (!type) {
sizeof(SPKnotClass),
NULL, /* base_init */
NULL, /* base_finalize */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (SPKnot),
16, /* n_preallocs */
};
}
return type;
}
/**
* SPKnot vtable initialization.
*/
{
G_TYPE_BOOLEAN, 1,
G_TYPE_NONE, 1,
G_TYPE_NONE, 1,
G_TYPE_NONE, 1,
G_TYPE_NONE, 1,
G_TYPE_NONE, 2,
G_TYPE_BOOLEAN, 2,
G_TYPE_DOUBLE, 2,
}
/**
* Callback for SPKnot initialization.
*/
{
knot->_event_handler_id = 0;
}
/**
* Called before SPKnot destruction.
*/
{
// This happens e.g. when deleting a node in node tool while dragging it
}
if (knot->_event_handler_id > 0)
{
knot->_event_handler_id = 0;
}
}
for (gint i = 0; i < SP_KNOT_VISIBLE_STATES; i++) {
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
}
}
}
if (parent_class->dispose) {
}
}
{
// save drag origin
xp = x;
yp = y;
within_tolerance = true;
if (!nograb) {
etime);
}
}
/**
* Called to handle events on knots.
*/
{
/* Run client universal event handler, if present */
if (consumed) {
return TRUE;
}
case GDK_2BUTTON_PRESS:
}
break;
case GDK_BUTTON_PRESS:
sp_knot_start_dragging(knot, p, (gint) event->button.x, (gint) event->button.y, event->button.time);
}
break;
case GDK_BUTTON_RELEASE:
// If we have any pending snap event, then invoke it now
}
if (transform_escaped) {
transform_escaped = false;
} else {
if (!nograb) {
}
if (moved) {
FALSE);
knot_signals[UNGRABBED], 0,
} else {
knot_signals[CLICKED], 0,
}
}
}
break;
case GDK_MOTION_NOTIFY:
if ( within_tolerance
break; // do not drag if we're within tolerance from origin
}
// Once the user has moved farther than tolerance from the original location
// (indicating they intend to move the object, not click), then always process the
// motion notify coordinates as given (no snapping back to origin)
within_tolerance = false;
else
if (!moved) {
knot_signals[GRABBED], 0,
TRUE);
}
sp_event_context_snap_delay_handler(knot->desktop->event_context, NULL, (gpointer) knot, (GdkEventMotion *)event, DelayedSnapEvent::KNOT_HANDLER);
}
break;
case GDK_ENTER_NOTIFY:
}
break;
case GDK_LEAVE_NOTIFY:
}
break;
case GDK_KEY_PRESS: // keybindings for knot
case GDK_KEY_Escape:
if (!nograb) {
}
if (moved) {
FALSE);
knot_signals[UNGRABBED], 0,
transform_escaped = true;
}
break;
default:
break;
}
break;
default:
break;
}
}
{
knot->desktop->set_coordinate_status(knot->pos); // display the coordinate of knot, not cursor - they may be different!
}
{
if (tip) {
}
"anchor", SP_ANCHOR_CENTER,
"size", 8.0,
"filled", TRUE,
"fill_color", 0xffffff00,
"stroked", TRUE,
"stroke_color", 0x01000000,
"mode", SP_KNOT_MODE_XOR,
NULL);
return knot;
}
{
}
{
}
{
knot_signals[REQUEST], 0,
&p,
&done);
/* If user did not complete, we simply move knot to new position */
if (!done) {
}
}
{
knot_signals[DISTANCE], 0,
&p,
&distance);
return distance;
}
{
}
knot_signals[MOVED], 0,
&p,
state);
}
{
}
}
{
}
{
if (set) {
} else {
}
switch (flag) {
case SP_KNOT_VISIBLE:
if (set) {
} else {
}
break;
case SP_KNOT_MOUSEOVER:
case SP_KNOT_DRAGGING:
break;
case SP_KNOT_GRABBED:
break;
default:
break;
}
}
{
return;
}
}
}
/**
*/
{
"fill_color",
NULL);
"stroke_color",
NULL);
"fill_color",
NULL);
"stroke_color",
NULL);
} else {
"fill_color",
NULL);
"stroke_color",
NULL);
}
}
/*
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 :