node-context.cpp revision 7e417fb969db6e58d87411bfb9d607b69ec040c9
#define __SP_NODE_CONTEXT_C__
/*
* Node editing context
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
*
* This code is in public domain, except stamping code,
* which is Copyright (C) Masatake Yamato 2002
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <gdk/gdkkeysyms.h>
#include "macros.h"
#include "display/sp-canvas-util.h"
#include "object-edit.h"
#include "sp-path.h"
#include "path-chemistry.h"
#include "rubberband.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "selection.h"
#include "pixmaps/cursor-node.xpm"
#include "message-context.h"
#include "node-context.h"
#include "pixmaps/cursor-node-d.xpm"
#include "prefs-utils.h"
#include "xml/node-event-vector.h"
#include "style.h"
#include "splivarot.h"
NULL, /* child_added */
NULL, /* child_removed */
NULL, /* content_changed */
NULL /* order_changed */
};
static SPEventContextClass *parent_class;
{
if (!type) {
sizeof(SPNodeContextClass),
sizeof(SPNodeContext),
4,
NULL, /* value_table */
};
}
return type;
}
static void
{
}
static void
{
}
static void
{
ec->enableGrDrag(false);
}
}
if (repr) {
}
}
if (ec->shape_knot_holder) {
}
if (nc->_node_message_context) {
delete nc->_node_message_context;
}
}
static void
{
nc->sel_changed_connection = sp_desktop_selection(ec->desktop)->connectChanged(sigc::bind(sigc::ptr_fun(&sp_node_context_selection_changed), (gpointer)nc));
nc->rb_escaped = false;
nc->cursor_drag = false;
nc->added_node = false;
if (item) {
nc->nodepath = sp_nodepath_new(ec->desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0));
//point pack to parent in case nodepath is deleted
}
// setting listener
if (ec->shape_knot_holder)
else
if (repr) {
}
}
}
ec->enableSelectionCue();
}
ec->enableGrDrag();
}
}
/**
\brief Callback that processes the "changed" signal on the selection;
destroys old and creates new nodepath and reassigns listeners to the new selected item's repr
*/
void
{
}
if (ec->shape_knot_holder) {
}
if (old_repr) { // remove old listener
}
if (item) {
nc->nodepath = sp_nodepath_new(desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0));
}
// setting new listener
if (ec->shape_knot_holder)
else
if (repr) {
}
}
}
}
/**
\brief Regenerates nodepath when the item's repr was change outside of node edit
(e.g. by undo, or xml editor, or edited in another view). The item is assumed to be the same
(otherwise sp_node_context_selection_changed() would have been called), so repr and listeners
are not changed.
*/
void
{
}
if (ec->shape_knot_holder) {
}
if (item) {
nc->nodepath = sp_nodepath_new(desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0));
}
}
}
/**
\brief Callback that is fired whenever an attribute of the selected item (which we have in the nodepath) changes
*/
static void
{
if (np) {
if (!strcmp(name, "d") || !strcmp(name, "sodipodi:nodetypes")) { // With paths, we only need to act if one of the path-affecting attributes has changed.
if (np->local_change > 0)
np->local_change--;
}
} else if (kh) {
}
}
}
void
{
_("<b>Ctrl</b>: toggle node type, snap handle angle, move hor/vert; <b>Ctrl+Alt</b>: move along handles"),
_("<b>Shift</b>: toggle node selection, disable snapping, rotate both handles"),
_("<b>Alt</b>: lock handle length; <b>Ctrl+Alt</b>: move along handles"));
}
bool
{
//Translate click point into proper coord system
NR::Maybe<Path::cut_position> position = get_nearest_position_on_Path(nc->nodepath->livarot_path, nc->curvepoint_doc);
NR::Point nearest = get_point_on_Path(nc->nodepath->livarot_path, position.assume().piece, position.assume().t);
double stroke_tolerance =
desktop->current_zoom() *
: 0.0)
}
return close;
}
static gint
{
case GDK_2BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
// find out clicked item, disregarding groups, honoring Alt
// find out if we're over the selected item, disregarding groups
bool over_stroke = false;
over_stroke = sp_node_context_is_over_stroke (nc, item_over, NR::Point(event->button.x, event->button.y), false);
}
case GDK_BUTTON_RELEASE:
//add a node
} else {
nc->added_node = false;
break;
}
//select the segment
} else {
}
}
break;
case GDK_2BUTTON_PRESS:
//add a node
nc->added_node = true;
break;
default:
break;
}
} else {
}
}
break;
}
break;
case GDK_BUTTON_PRESS:
// save drag origin
event_context->within_tolerance = true;
// find out if we're over the selected item, disregarding groups
// save drag origin
bool over_stroke = sp_node_context_is_over_stroke (nc, item_over, NR::Point(event->button.x, event->button.y), true);
//only dragging curves
if (over_stroke) {
} else {
break;
}
} else {
break;
}
}
break;
}
break;
default:
break;
}
if (!ret) {
}
return ret;
}
static gint
{
double const nudge = prefs_get_double_attribute_limited("options.nudgedistance", "value", 2, 0, 1000); // in px
event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100); // read every time, to make prefs changes really live
double const offset = prefs_get_double_attribute_limited("options.defaultscale", "value", 2, 0, 1000);
case GDK_BUTTON_PRESS:
// save drag origin
event_context->within_tolerance = true;
}
break;
case GDK_MOTION_NOTIFY:
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)
event_context->within_tolerance = false;
} else {
}
} else {
break;
}
bool over_stroke = false;
over_stroke = sp_node_context_is_over_stroke (nc, item_over, NR::Point(event->motion.x, event->motion.y), false);
}
nc->cursor_drag = false;
nc->cursor_drag = true;
}
}
break;
case GDK_BUTTON_RELEASE:
}
} else {
else
}
}
nc->rb_escaped = false;
break;
}
break;
case GDK_KEY_PRESS:
case GDK_Insert:
case GDK_KP_Insert:
// with any modifiers
break;
case GDK_Delete:
case GDK_KP_Delete:
case GDK_BackSpace:
if (MOD__CTRL_ONLY) {
} else {
}
}
break;
case GDK_C:
case GDK_c:
if (MOD__SHIFT_ONLY) {
}
break;
case GDK_S:
case GDK_s:
if (MOD__SHIFT_ONLY) {
}
break;
case GDK_Y:
case GDK_y:
if (MOD__SHIFT_ONLY) {
}
break;
case GDK_B:
case GDK_b:
if (MOD__SHIFT_ONLY) {
}
break;
case GDK_J:
case GDK_j:
if (MOD__SHIFT_ONLY) {
}
break;
case GDK_D:
case GDK_d:
if (MOD__SHIFT_ONLY) {
}
break;
case GDK_L:
case GDK_l:
if (MOD__SHIFT_ONLY) {
}
break;
case GDK_U:
case GDK_u:
if (MOD__SHIFT_ONLY) {
}
break;
case GDK_R:
case GDK_r:
if (MOD__SHIFT_ONLY) {
// FIXME: add top panel button
}
break;
case GDK_Left: // move selection left
case GDK_KP_Left:
case GDK_KP_4:
if (!MOD__CTRL) { // not ctrl
if (MOD__ALT) { // alt
}
else { // no alt
}
}
break;
case GDK_Up: // move selection up
case GDK_KP_Up:
case GDK_KP_8:
if (!MOD__CTRL) { // not ctrl
if (MOD__ALT) { // alt
}
else { // no alt
}
}
break;
case GDK_Right: // move selection right
case GDK_KP_Right:
case GDK_KP_6:
if (!MOD__CTRL) { // not ctrl
if (MOD__ALT) { // alt
}
else { // no alt
}
}
break;
case GDK_Down: // move selection down
case GDK_KP_Down:
case GDK_KP_2:
if (!MOD__CTRL) { // not ctrl
if (MOD__ALT) { // alt
}
else { // no alt
}
}
break;
case GDK_Tab: // Tab - cycle selection forward
}
break;
case GDK_ISO_Left_Tab: // Shift Tab - cycle selection backward
}
break;
case GDK_Escape:
{
nc->rb_escaped = true;
} else {
} else {
}
}
break;
}
case GDK_bracketleft:
else {
}
} else if ( snaps != 0 ) {
}
break;
case GDK_bracketright:
else {
}
} else if ( snaps != 0 ) {
}
break;
case GDK_less:
case GDK_comma:
if (MOD__CTRL) {
} else if (MOD__ALT) {
else {
}
} else {
}
break;
case GDK_greater:
case GDK_period:
if (MOD__CTRL) {
} else if (MOD__ALT) {
else {
}
} else {
}
break;
case GDK_Alt_L:
break;
case GDK_Alt_R:
break;
case GDK_Control_L:
break;
case GDK_Control_R:
break;
case GDK_Shift_L:
case GDK_Shift_R:
case GDK_Meta_L:
case GDK_Meta_R:
break;
default:
break;
}
break;
case GDK_KEY_RELEASE:
case GDK_Alt_L:
break;
case GDK_Alt_R:
break;
case GDK_Control_L:
break;
case GDK_Control_R:
break;
case GDK_Shift_L:
case GDK_Shift_R:
case GDK_Meta_L:
case GDK_Meta_R:
break;
}
break;
default:
break;
}
if (!ret) {
}
return ret;
}
/*
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 :