Lines Matching refs:item

69      * Adds an item to a canvas group.
71 void add(SPCanvasItem *item);
74 * Removes an item from a canvas group.
76 void remove(SPCanvasItem *item);
97 static void update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags);
102 static double point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item);
107 static void render(SPCanvasItem *item, SPCanvasBuf *buf);
109 static void viewboxChanged(SPCanvasItem *item, Geom::IntRect const &new_area);
114 SPCanvasItem item;
158 * Callback that removes item from all referers and destroys it.
171 void sp_canvas_item_construct(SPCanvasItem *item, SPCanvasGroup *parent, gchar const *first_arg_name, va_list args);
174 * Helper that returns true iff item is descendant of parent.
176 bool is_descendant(SPCanvasItem const *item, SPCanvasItem const *parent);
213 sp_canvas_item_init(SPCanvasItem *item)
215 item->xform = Geom::Affine(Geom::identity());
216 item->ctrlResize = 0;
217 item->ctrlType = Inkscape::CTRL_TYPE_UNKNOWN;
218 item->ctrlFlags = Inkscape::CTRL_FLAG_NORMAL;
223 item->visible = TRUE;
224 item->in_destruction = false;
225 item->pickable = true;
236 SPCanvasItem *item = SP_CANVAS_ITEM(g_object_new(type, NULL));
239 sp_canvas_item_construct(item, parent, first_arg_name, args);
242 return item;
247 void sp_canvas_item_construct(SPCanvasItem *item, SPCanvasGroup *parent, gchar const *first_arg_name, va_list args)
250 g_return_if_fail(SP_IS_CANVAS_ITEM(item));
252 item->parent = SP_CANVAS_ITEM(parent);
253 item->canvas = item->parent->canvas;
255 g_object_set_valist(G_OBJECT(item), first_arg_name, args);
257 SP_CANVAS_GROUP(item->parent)->add(item);
259 sp_canvas_item_request_update(item);
265 * Helper function that requests redraw only if item's visible flag is set.
267 static void redraw_if_visible(SPCanvasItem *item)
269 if (item->visible) {
270 int x0 = (int)(item->x1);
271 int x1 = (int)(item->x2);
272 int y0 = (int)(item->y1);
273 int y1 = (int)(item->y2);
276 item->canvas->requestRedraw((int)(item->x1 - 1), (int)(item->y1 -1), (int)(item->x2 + 1), (int)(item->y2 + 1));
281 void sp_canvas_item_destroy(SPCanvasItem *item)
283 g_return_if_fail(SP_IS_CANVAS_ITEM(item));
285 if (!item->in_destruction)
286 g_object_run_dispose(G_OBJECT(item));
292 SPCanvasItem *item = SP_CANVAS_ITEM (object);
297 if (!item->in_destruction)
299 item->in_destruction=true;
304 if (SP_IS_CTRLRECT(item)) {
306 SP_CTRLRECT(object)->update(item->xform, 0);
308 redraw_if_visible (item);
310 item->visible = FALSE;
312 if (item == item->canvas->_current_item) {
313 item->canvas->_current_item = NULL;
314 item->canvas->_need_repick = TRUE;
317 if (item == item->canvas->_new_current_item) {
318 item->canvas->_new_current_item = NULL;
319 item->canvas->_need_repick = TRUE;
322 if (item == item->canvas->_grabbed_item) {
323 item->canvas->_grabbed_item = NULL;
334 if (item == item->canvas->_focused_item) {
335 item->canvas->_focused_item = NULL;
338 if (item->parent) {
339 SP_CANVAS_GROUP(item->parent)->remove(item);
343 item->in_destruction = false;
371 * Helper function to update item and its children.
375 static void sp_canvas_item_invoke_update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
377 // Apply the child item's transform
378 Geom::Affine child_affine = item->xform * affine;
383 if (item->need_update) {
387 if (item->need_affine) {
392 if (SP_CANVAS_ITEM_GET_CLASS (item)->update) {
393 SP_CANVAS_ITEM_GET_CLASS (item)->update(item, child_affine, child_flags);
397 item->need_update = FALSE;
398 item->need_affine = FALSE;
402 * Helper function to invoke the point method of the item.
404 * The argument x, y should be in the parent's item-relative coordinate
405 * system. This routine applies the inverse of the item's transform,
408 static double sp_canvas_item_invoke_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item)
410 if (SP_CANVAS_ITEM_GET_CLASS(item)->point) {
411 return SP_CANVAS_ITEM_GET_CLASS (item)->point (item, p, actual_item);
418 * Makes the item's affine transformation matrix be equal to the specified
421 * @item: A canvas item.
424 void sp_canvas_item_affine_absolute(SPCanvasItem *item, Geom::Affine const &affine)
426 item->xform = affine;
428 if (!item->need_affine) {
429 item->need_affine = TRUE;
430 if (item->parent != NULL) {
431 sp_canvas_item_request_update (item->parent);
433 item->canvas->requestUpdate();
437 item->canvas->_need_repick = TRUE;
441 * Raises the item in its parent's stack by the specified number of positions.
443 * @param item A canvas item.
444 * @param positions Number of steps to raise the item.
447 * stack, then the item is put at the top.
449 void sp_canvas_item_raise(SPCanvasItem *item, int positions)
451 g_return_if_fail (item != NULL);
452 g_return_if_fail (SP_IS_CANVAS_ITEM (item));
455 if (!item->parent || positions == 0) {
459 SPCanvasGroup *parent = SP_CANVAS_GROUP (item->parent);
460 std::list<SPCanvasItem *>::iterator l = std::find(parent->items.begin(),parent->items.end(), item);
466 parent->items.remove(item);
467 parent->items.insert(l, item);
469 redraw_if_visible (item);
470 item->canvas->_need_repick = TRUE;
473 void sp_canvas_item_raise_to_top(SPCanvasItem *item)
475 g_return_if_fail (item != NULL);
476 g_return_if_fail (SP_IS_CANVAS_ITEM (item));
477 if (!item->parent)
479 SPCanvasGroup *parent = SP_CANVAS_GROUP (item->parent);
480 parent->items.remove(item);
481 parent->items.push_back(item);
482 redraw_if_visible (item);
483 item->canvas->_need_repick = TRUE;
489 * Lowers the item in its parent's stack by the specified number of positions.
491 * @param item A canvas item.
492 * @param positions Number of steps to lower the item.
495 * stack, then the item is put at the bottom.
497 void sp_canvas_item_lower(SPCanvasItem *item, int positions)
499 g_return_if_fail (item != NULL);
500 g_return_if_fail (SP_IS_CANVAS_ITEM (item));
503 SPCanvasGroup *parent = SP_CANVAS_GROUP(item->parent);
505 if (!parent || positions == 0 || item == parent->items.front() ) {
509 std::list<SPCanvasItem *>::iterator l = std::find(parent->items.begin(), parent->items.end(), item);
515 parent->items.remove(item);
516 parent->items.insert(l, item);
518 redraw_if_visible (item);
519 item->canvas->_need_repick = TRUE;
522 void sp_canvas_item_lower_to_bottom(SPCanvasItem *item)
524 g_return_if_fail (item != NULL);
525 g_return_if_fail (SP_IS_CANVAS_ITEM (item));
526 if (!item->parent)
528 SPCanvasGroup *parent = SP_CANVAS_GROUP (item->parent);
529 parent->items.remove(item);
530 parent->items.push_front(item);
531 redraw_if_visible (item);
532 item->canvas->_need_repick = TRUE;
535 bool sp_canvas_item_is_visible(SPCanvasItem *item)
537 return item->visible;
541 * Sets visible flag on item and requests a redraw.
543 void sp_canvas_item_show(SPCanvasItem *item)
545 g_return_if_fail (item != NULL);
546 g_return_if_fail (SP_IS_CANVAS_ITEM (item));
548 if (item->visible) {
552 item->visible = TRUE;
554 int x0 = (int)(item->x1);
555 int x1 = (int)(item->x2);
556 int y0 = (int)(item->y1);
557 int y1 = (int)(item->y2);
560 item->canvas->requestRedraw((int)(item->x1), (int)(item->y1), (int)(item->x2 + 1), (int)(item->y2 + 1));
561 item->canvas->_need_repick = TRUE;
566 * Clears visible flag on item and requests a redraw.
568 void sp_canvas_item_hide(SPCanvasItem *item)
570 g_return_if_fail (item != NULL);
571 g_return_if_fail (SP_IS_CANVAS_ITEM (item));
573 if (!item->visible) {
577 item->visible = FALSE;
579 int x0 = (int)(item->x1);
580 int x1 = (int)(item->x2);
581 int y0 = (int)(item->y1);
582 int y1 = (int)(item->y2);
585 item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)(item->x2 + 1), (int)(item->y2 + 1));
586 item->canvas->_need_repick = TRUE;
591 * Grab item under cursor.
593 * \pre !canvas->grabbed_item && item->flags & SP_CANVAS_ITEM_VISIBLE
595 int sp_canvas_item_grab(SPCanvasItem *item, guint event_mask, GdkCursor *cursor, guint32 etime)
597 g_return_val_if_fail (item != NULL, -1);
598 g_return_val_if_fail (SP_IS_CANVAS_ITEM (item), -1);
599 g_return_val_if_fail (gtk_widget_get_mapped (GTK_WIDGET (item->canvas)), -1);
601 if (item->canvas->_grabbed_item) {
605 // This test disallows grabbing events by an invisible item, which may be useful
610 //if (!(item->flags & SP_CANVAS_ITEM_VISIBLE))
624 getWindow(item->canvas),
631 gdk_pointer_grab( getWindow(item->canvas), FALSE,
636 item->canvas->_grabbed_item = item;
637 item->canvas->_grabbed_event_mask = event_mask;
638 item->canvas->_current_item = item; // So that events go to the grabbed item
644 * Ungrabs the item, which must have been grabbed in the canvas, and ungrabs the
647 * @param item A canvas item that holds a grab.
650 void sp_canvas_item_ungrab(SPCanvasItem *item, guint32 etime)
652 g_return_if_fail (item != NULL);
653 g_return_if_fail (SP_IS_CANVAS_ITEM (item));
655 if (item->canvas->_grabbed_item != item) {
659 item->canvas->_grabbed_item = NULL;
671 * Returns the product of all transformation matrices from the root item down
672 * to the item.
674 Geom::Affine sp_canvas_item_i2w_affine(SPCanvasItem const *item)
676 g_assert (SP_IS_CANVAS_ITEM (item)); // should we get this?
680 while (item) {
681 affine *= item->xform;
682 item = item->parent;
689 bool is_descendant(SPCanvasItem const *item, SPCanvasItem const *parent)
691 while (item) {
692 if (item == parent) {
695 item = item->parent;
704 * Requests that the canvas queue an update for the specified item.
706 * To be used only by item implementations.
708 void sp_canvas_item_request_update(SPCanvasItem *item)
710 if (item->need_update) {
714 item->need_update = TRUE;
716 if (item->parent != NULL) {
718 sp_canvas_item_request_update (item->parent);
721 item->canvas->requestUpdate();
726 * Returns position of item in group.
728 gint sp_canvas_item_order (SPCanvasItem * item)
730 SPCanvasGroup * p = SP_CANVAS_GROUP(item->parent);
733 if ((*it) == item) {
779 void SPCanvasGroup::update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags)
781 SPCanvasGroup const *group = SP_CANVAS_GROUP(item);
796 item->x1 = bounds->min()[Geom::X];
797 item->y1 = bounds->min()[Geom::Y];
798 item->x2 = bounds->max()[Geom::X];
799 item->y2 = bounds->max()[Geom::Y];
802 item->x1 = item->x2 = item->y1 = item->y2 = 0;
806 double SPCanvasGroup::point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item)
808 SPCanvasGroup const *group = SP_CANVAS_GROUP(item);
811 int x1 = (int)(x - item->canvas->_close_enough);
812 int y1 = (int)(y - item->canvas->_close_enough);
813 int x2 = (int)(x + item->canvas->_close_enough);
814 int y2 = (int)(y + item->canvas->_close_enough);
824 SPCanvasItem *point_item = NULL; // cater for incomplete item implementations
837 // of the item to be focused, and have that one selected. Of course this will only work if the
840 if (pickable && point_item && ((int) (dist + 0.5) <= item->canvas->_close_enough)) {
850 void SPCanvasGroup::render(SPCanvasItem *item, SPCanvasBuf *buf)
852 SPCanvasGroup const *group = SP_CANVAS_GROUP(item);
869 void SPCanvasGroup::viewboxChanged(SPCanvasItem *item, Geom::IntRect const &new_area)
871 SPCanvasGroup *group = SP_CANVAS_GROUP(item);
883 void SPCanvasGroup::add(SPCanvasItem *item)
885 g_object_ref(item);
886 g_object_ref_sink(item);
888 items.push_back(item);
890 sp_canvas_item_request_update(item);
893 void SPCanvasGroup::remove(SPCanvasItem *item)
896 g_return_if_fail(item != NULL);
897 items.remove(item);
900 item->parent = NULL;
901 g_object_unref(item);
948 // Create the root item as a special case
1268 SPCanvasItem* item = NULL;
1270 item = _grabbed_item;
1272 item = _current_item;
1279 item = _focused_item;
1288 while (item && !finished) {
1289 g_object_ref (item);
1290 g_signal_emit (G_OBJECT (item), item_signals[ITEM_EVENT], 0, ev, &finished);
1291 SPCanvasItem *parent = item->parent;
1292 g_object_unref (item);
1293 item = parent;
1312 // current item, but not enter on any other item. This is more or
1322 // leave events in case the current item changes. It is also used to
1323 // re-pick the current item if the current one gets deleted. Also,
1360 // LeaveNotify means that there is no current item, so we don't look for one
1377 // find the closest item
1388 return retval; // current item did not change
1440 // dispatch normally regardless of the event's window if an item
1471 // Pick the current item as if the button were not pressed, and
1929 // Pick new current item