tweak-context.cpp revision ff3ee1f3aa5ce72ccec547b5be153caf2ebabed7
#define __SP_TWEAK_CONTEXT_C__
/*
* tweaking paths without node editing
*
* Authors:
* bulia byak
*
* Copyright (C) 2007 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#define noTWEAK_VERBOSE
#include "config.h"
#include <gdk/gdkkeysyms.h>
#include <numeric>
#include "display/canvas-bpath.h"
#include "display/bezier-utils.h"
#include "macros.h"
#include "document.h"
#include "selection.h"
#include "desktop.h"
#include "desktop-events.h"
#include "desktop-handles.h"
#include "desktop-affine.h"
#include "desktop-style.h"
#include "message-context.h"
#include "pixmaps/cursor-thin.xpm"
#include "pixmaps/cursor-thicken.xpm"
#include "pixmaps/cursor-push.xpm"
#include "pixmaps/cursor-roughen.xpm"
#include "libnr/n-art-bpath.h"
#include "libnr/nr-matrix-ops.h"
#include "libnr/nr-scale-translate-ops.h"
#include "context-fns.h"
#include "sp-item.h"
#include "inkscape.h"
#include "color.h"
#include "splivarot.h"
#include "sp-item-group.h"
#include "sp-shape.h"
#include "sp-path.h"
#include "path-chemistry.h"
#include "sp-text.h"
#include "sp-flowtext.h"
#include "display/canvas-bpath.h"
#include "display/canvas-arena.h"
#include "isnan.h"
#include "prefs-utils.h"
#include "tweak-context.h"
#define DDC_RED_RGBA 0xff0000ff
#define DYNA_MIN_WIDTH 1.0e-6
// FIXME: move it to some shared file to be reused by both calligraphy and dropper
#define C1 0.552
static NArtBpath const hatch_area_circle[] = {
{ NR_MOVETO, 0, 0, 0, 0, -1, 0 },
{ NR_END, 0, 0, 0, 0, 0, 0 }
};
static SPEventContextClass *parent_class;
{
if (!type) {
sizeof(SPTweakContextClass),
sizeof(SPTweakContext),
4,
NULL, /* value_table */
};
}
return type;
}
static void
{
}
static void
{
/* attributes */
tc->is_dilating = false;
tc->has_dilated = false;
}
static void
{
if (tc->dilate_area) {
}
if (tc->_message_context) {
delete tc->_message_context;
}
}
void
{
switch (mode) {
case TWEAK_MODE_PUSH:
break;
case TWEAK_MODE_MELT:
break;
case TWEAK_MODE_INFLATE:
break;
case TWEAK_MODE_ROUGHEN:
break;
}
}
static void
{
{
sp_curve_unref(c);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(tc->dilate_area), 0xff9900ff, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
}
tc->is_drawing = false;
}
static void
{
}
}
static void
{
else
}
double
{
// 10 times the pen width:
}
double
{
if (force > 3) {
}
}
bool
sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Point p, NR::Point vector, gint mode, double radius, double force, double fidelity)
{
bool did = false;
if (SP_IS_GROUP(item)) {
for (SPObject *child = sp_object_first_child(SP_OBJECT(item)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
if (SP_IS_ITEM(child)) {
if (sp_tweak_dilate_recursive (selection, SP_ITEM(child), p, vector, mode, radius, force, fidelity))
did = true;
}
}
if (!SP_IS_PATH(item)) {
if (!newrepr)
return false;
// remember the position of the item
// remember parent
// remember id
}
// skip those paths whose bboxes are entirely out of reach with our radius
if (bbox) {
return false;
}
}
return false;
}
res->SetBackData(false);
{
}
{
}
else
{
}
bool did_this = false;
join_straight, 4.0,
did_this = true;
} else if (mode == TWEAK_MODE_PUSH) {
join_straight, 4.0,
did_this = true;
} else if (mode == TWEAK_MODE_ROUGHEN) {
join_straight, 4.0,
did_this = true;
}
// the rest only makes sense if we actually changed the path
if (did_this) {
if (newrepr) { // converting to path, need to replace the repr
if (is_selected)
// It's going to resurrect, so we delete without notifying listeners.
// restore id
// add the new repr to the parent
// move to the saved position
if (is_selected)
}
if (newrepr)
else
} else {
// TODO: if there's 0 or 1 node left, delete this path altogether
}
if (newrepr) {
}
}
delete theShape;
delete theRes;
delete orig;
delete res;
if (did_this)
did = true;
}
return did;
}
bool
{
return false;
}
bool did = false;
return false;
}
did = true;
}
return did;
}
void
{
NR::Matrix const sm (NR::scale(radius, radius) * NR::translate(SP_EVENT_CONTEXT(tc)->desktop->point()));
}
void
{
// need to set explicitly, because the prefs may not have changed by the previous
}
void
{
// Juggling about so that prefs have the old value but tc->mode and the button show new mode:
// button has changed prefs, restore
// changing prefs changed tc->mode, restore back :)
}
{
case GDK_BUTTON_PRESS:
return TRUE;
}
tc->is_drawing = true;
tc->is_dilating = true;
tc->has_dilated = false;
}
break;
case GDK_MOTION_NOTIFY:
{
// draw the dilating cursor
}
if (num == 0) {
} else {
case TWEAK_MODE_PUSH:
_("<b>Pushing %d</b> selected object(s)"), num);
break;
case TWEAK_MODE_MELT:
_("<b>Melting %d</b> selected object(s)"), num);
break;
case TWEAK_MODE_INFLATE:
_("<b>Inflating %d</b> selected object(s)"), num);
break;
case TWEAK_MODE_ROUGHEN:
_("<b>Roughening %d</b> selected object(s)"), num);
break;
}
}
// dilating:
//tc->last_push = motion_doc;
tc->has_dilated = true;
// it's slow, so prevent clogging up with events
return TRUE;
}
}
break;
case GDK_BUTTON_RELEASE:
{
tc->is_drawing = false;
if (!tc->has_dilated) {
// if we did not rub, do a light tap
}
tc->is_dilating = false;
tc->has_dilated = false;
(tc->mode==TWEAK_MODE_INFLATE ? _("Inflate tweak") : (tc->mode==TWEAK_MODE_MELT ? _("Melt tweak") : (tc->mode==TWEAK_MODE_PUSH ? _("Push tweak") : _("Roughen tweak")))));
}
break;
}
case GDK_KEY_PRESS:
case GDK_p:
case GDK_P:
case GDK_1:
if (MOD__SHIFT_ONLY) {
}
break;
case GDK_m:
case GDK_M:
case GDK_2:
if (MOD__SHIFT_ONLY) {
}
break;
case GDK_b:
case GDK_B:
case GDK_3:
if (MOD__SHIFT_ONLY) {
}
break;
case GDK_r:
case GDK_R:
case GDK_4:
if (MOD__SHIFT_ONLY) {
}
break;
case GDK_Up:
case GDK_KP_Up:
if (!MOD__CTRL_ONLY) {
}
break;
case GDK_Down:
case GDK_KP_Down:
if (!MOD__CTRL_ONLY) {
}
break;
case GDK_Right:
case GDK_KP_Right:
if (!MOD__CTRL_ONLY) {
desktop->setToolboxAdjustmentValue ("altx-tweak", tc->width * 100); // the same spinbutton is for alt+x
}
break;
case GDK_Left:
case GDK_KP_Left:
if (!MOD__CTRL_ONLY) {
}
break;
case GDK_Home:
case GDK_KP_Home:
break;
case GDK_End:
case GDK_KP_End:
break;
case GDK_x:
case GDK_X:
if (MOD__ALT_ONLY) {
}
break;
case GDK_Control_L:
case GDK_Control_R:
if (MOD__SHIFT) {
} else {
}
break;
case GDK_Shift_L:
case GDK_Shift_R:
if (MOD__CTRL) {
}
break;
default:
break;
}
break;
case GDK_KEY_RELEASE:
case GDK_Control_L:
case GDK_Control_R:
break;
case GDK_Shift_L:
case GDK_Shift_R:
if (MOD__CTRL) {
}
break;
break;
default:
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 :