VPDragger::VPDragger(VPDrag *parent, Geom::Point p, VanishingPoint &vp) { this->parent = parent; this->point = p; this->point_original = p; this->dragging_started = false; if (vp.is_finite()) { // create the knot this->knot = sp_knot_new (inkscape_active_desktop(), NULL); this->knot->setMode(SP_KNOT_MODE_XOR); this->knot->setFill(VP_KNOT_COLOR_NORMAL, VP_KNOT_COLOR_NORMAL, VP_KNOT_COLOR_NORMAL); this->knot->setStroke(0x000000ff, 0x000000ff, 0x000000ff); sp_knot_update_ctrl(this->knot); // move knot to the given point sp_knot_set_position (this->knot, this->point, SP_KNOT_STATE_NORMAL); sp_knot_show (this->knot); // connect knot's signals g_signal_connect (G_OBJECT (this->knot), "moved", G_CALLBACK (vp_knot_moved_handler), this); g_signal_connect (G_OBJECT (this->knot), "grabbed", G_CALLBACK (vp_knot_grabbed_handler), this); g_signal_connect (G_OBJECT (this->knot), "ungrabbed", G_CALLBACK (vp_knot_ungrabbed_handler), this); // add the initial VP (which may be NULL!) this->addVP (vp); } }
void KnotHolderEntity::create(SPDesktop *desktop, SPItem *item, KnotHolder *parent, Inkscape::ControlType type, const gchar *tip, SPKnotShapeType shape, SPKnotModeType mode, guint32 color) { knot = sp_knot_new(desktop, tip); this->parent_holder = parent; this->item = item; // TODO: remove the item either from here or from knotholder.cpp this->desktop = desktop; my_counter = KnotHolderEntity::counter++; g_object_set(G_OBJECT(knot->item), "shape", shape, NULL); g_object_set(G_OBJECT(knot->item), "mode", mode, NULL); // TODO base more appearance from this type instead of passing in arbitrary values. knot->item->ctrlType = type; knot->fill [SP_KNOT_STATE_NORMAL] = color; g_object_set (G_OBJECT(knot->item), "fill_color", color, NULL); update_knot(); sp_knot_show(knot); _moved_connection = knot->_moved_signal.connect(sigc::mem_fun(*parent_holder, &KnotHolder::knot_moved_handler)); _click_connection = knot->_click_signal.connect(sigc::mem_fun(*parent_holder, &KnotHolder::knot_clicked_handler)); _ungrabbed_connection = knot->_ungrabbed_signal.connect(sigc::mem_fun(*parent_holder, &KnotHolder::knot_ungrabbed_handler)); }
static void sp_sel_trans_update_handles (SPSelTrans * seltrans) { NRPointF p; g_return_if_fail (seltrans != NULL); if ((!seltrans->show_handles) || (seltrans->empty)) { sp_remove_handles (seltrans->shandle, 8); sp_remove_handles (seltrans->rhandle, 8); sp_remove_handles (&seltrans->chandle, 1); return; } if (seltrans->state == SP_SELTRANS_STATE_SCALE) { sp_remove_handles (seltrans->rhandle, 8); sp_remove_handles (&seltrans->chandle, 1); sp_show_handles (seltrans, seltrans->shandle, handles_scale, 8); } else { sp_remove_handles (seltrans->shandle, 8); sp_remove_handles (&seltrans->chandle, 1); sp_show_handles (seltrans, seltrans->rhandle, handles_rotate, 8); } // center handle if (seltrans->chandle == NULL) { seltrans->chandle = sp_knot_new (seltrans->desktop); g_object_set (G_OBJECT (seltrans->chandle), "anchor", handle_center.anchor, "shape", SP_CTRL_SHAPE_BITMAP, "size", 13, "mode", SP_CTRL_MODE_COLOR, "fill", 0x00000000, "fill_mouseover", 0x0000007f, "stroke", 0x000000ff, "stroke_mouseover", 0x000000ff, //"fill", 0xff40ffa0, //"fill_mouseover", 0x40ffffa0, //"stroke", 0xFFb0b0ff, //"stroke_mouseover", 0xffffffFF, "pixbuf", handles[handle_center.control], #if 0 "cursor_mouseover", CursorSelectMouseover, "cursor_dragging", CursorSelectDragging, #endif NULL); g_signal_connect (G_OBJECT (seltrans->chandle), "request", G_CALLBACK (sp_sel_trans_handle_request), (gpointer) &handle_center); g_signal_connect (G_OBJECT (seltrans->chandle), "moved", G_CALLBACK (sp_sel_trans_handle_new_event), (gpointer) &handle_center); g_signal_connect (G_OBJECT (seltrans->chandle), "grabbed", G_CALLBACK (sp_sel_trans_handle_grab), (gpointer) &handle_center); g_signal_connect (G_OBJECT (seltrans->chandle), "ungrabbed", G_CALLBACK (sp_sel_trans_handle_ungrab), (gpointer) &handle_center); } sp_knot_show (seltrans->chandle); p.x = seltrans->center.x; p.y = seltrans->center.y; sp_knot_set_position (seltrans->chandle, &p, 0); }
void sp_knot_holder_add_full (SPKnotHolder *knot_holder, SPKnotHolderSetFunc knot_set, SPKnotHolderGetFunc knot_get, SPKnotShapeType shape, SPKnotModeType mode) { SPKnotHolderEntity *e; SPItem *item; NRPointF sp, dp; NRMatrixF i2d; g_return_if_fail (knot_holder != NULL); g_return_if_fail (knot_set != NULL); g_return_if_fail (knot_get != NULL); item = SP_ITEM (knot_holder->item); #if 0 #define KH_EPSILON 1e-6 /* Precondition for knot_set and knot_get */ { NRPointF p1, p2; knot_get (item, &p1); knot_set (item, &p1, 0); knot_get (item, &p2); g_assert (fabs(p1.x - p2.x) < KH_EPSILON && fabs(p1.y - p2.y) < KH_EPSILON); } #endif /* create new SPKnotHolderEntry */ e = g_new (SPKnotHolderEntity, 1); e->knot = sp_knot_new (knot_holder->desktop); e->knot_set = knot_set; e->knot_get = knot_get; g_object_set (G_OBJECT (e->knot->item), "shape", shape, NULL); g_object_set (G_OBJECT (e->knot->item), "mode", mode, NULL); knot_holder->entity = g_slist_append (knot_holder->entity, e); /* move to current point */ e->knot_get (item, &sp); sp_item_i2d_affine(item, &i2d); dp.x = NR_MATRIX_DF_TRANSFORM_X (&i2d, sp.x, sp.y); dp.y = NR_MATRIX_DF_TRANSFORM_Y (&i2d, sp.x, sp.y); sp_knot_set_position (e->knot, &dp, SP_KNOT_STATE_NORMAL); e->handler_id = g_signal_connect (G_OBJECT (e->knot), "moved", G_CALLBACK (knot_moved_handler), knot_holder); g_signal_connect (G_OBJECT (e->knot), "ungrabbed", G_CALLBACK (knot_ungrabbed_handler), knot_holder); #ifdef KNOT_HOLDER_DEBUG g_signal_connect (ob, "destroy", sp_knot_holder_debug, "SPKnotHolder::knot"); #endif sp_knot_show (e->knot); }
static void sp_show_handles (SPSelTrans * seltrans, SPKnot * knot[], const SPSelTransHandle handle[], gint num) { NRPointF p; gint i; for (i = 0; i < num; i++) { if (knot[i] == NULL) { knot[i] = sp_knot_new (seltrans->desktop); g_object_set (G_OBJECT (knot[i]), "anchor", handle[i].anchor, "shape", SP_CTRL_SHAPE_BITMAP, "size", 13, "mode", SP_KNOT_MODE_COLOR, "fill", 0x4040ffa0, "fill_mouseover", 0xff4040f0, "stroke", 0x000000a0, "stroke_mouseover", 0x000000FF, //"fill", 0xffff0080, //"fill_mouseover", 0x00ffff80, //"stroke", 0xFFFFFFff, //"stroke_mouseover", 0xb0b0b0FF, "pixbuf", handles[handle[i].control], #if 0 "cursor_mouseover", CursorSelectMouseover, "cursor_dragging", CursorSelectDragging, #endif NULL); g_signal_connect (G_OBJECT (knot[i]), "request", G_CALLBACK (sp_sel_trans_handle_request), (gpointer) &handle[i]); g_signal_connect (G_OBJECT (knot[i]), "moved", G_CALLBACK (sp_sel_trans_handle_new_event), (gpointer) &handle[i]); g_signal_connect (G_OBJECT (knot[i]), "grabbed", G_CALLBACK (sp_sel_trans_handle_grab), (gpointer) &handle[i]); g_signal_connect (G_OBJECT (knot[i]), "ungrabbed", G_CALLBACK (sp_sel_trans_handle_ungrab), (gpointer) &handle[i]); g_signal_connect (G_OBJECT (knot[i]), "event", G_CALLBACK (sp_seltrans_handle_event), (gpointer) &handle[i]); } sp_knot_show (knot[i]); p.x = seltrans->box.x0 + handle[i].x * fabs (seltrans->box.x1 - seltrans->box.x0); p.y = seltrans->box.y0 + handle[i].y * fabs (seltrans->box.y1 - seltrans->box.y0); //gtk_signal_handler_block_by_func (GTK_OBJECT (knot[i]), // GTK_SIGNAL_FUNC (sp_sel_trans_handle_new_event), &handle[i]); sp_knot_set_position (knot[i], &p, 0); //gtk_signal_handler_unblock_by_func (GTK_OBJECT (knot[i]), // GTK_SIGNAL_FUNC (sp_sel_trans_handle_new_event), &handle[i]); } }