Пример #1
0
static gboolean
idle_move_item (gpointer data)
{
  BstCanvasSource *self = data;
  GnomeCanvasItem *item = GNOME_CANVAS_ITEM (self);

  GDK_THREADS_ENTER ();
  if (self->source && item->canvas)
    {
      SfiReal x, y;
      bse_proxy_get (self->source,
                     "pos-x", &x,
                     "pos-y", &y,
                     NULL);
      x *= BST_CANVAS_SOURCE_PIXEL_SCALE;
      y *= -BST_CANVAS_SOURCE_PIXEL_SCALE;
      gnome_canvas_item_w2i (item, &x, &y);
      g_object_freeze_notify (G_OBJECT (self));
      gnome_canvas_item_move (item, x, y);
      /* canvas notification bug workaround */
      g_object_notify (self, "x");
      g_object_notify (self, "y");
      g_object_thaw_notify (G_OBJECT (self));
    }
  self->idle_reposition = FALSE;
  g_object_unref (self);
  GDK_THREADS_LEAVE ();
  return FALSE;
}
Пример #2
0
static gint
zenity_move_clothes_event (GnomeCanvasItem *item, 
                           GdkEvent *event,
                           gpointer data)
{
  static double x, y;
  double new_x, new_y;
  static int dragging;
  double item_x, item_y;

  /* set item_[xy] to the event x,y position in the parent's 
   * item-relative coordinates
   */
  
  item_x = event->button.x;
  item_y = event->button.y;
  gnome_canvas_item_w2i (item->parent, &item_x, &item_y);

  switch (event->type) {
    case GDK_BUTTON_PRESS:
      x = item_x;
      y = item_y;
      gnome_canvas_item_ungrab (item, event->button.time);
      gnome_canvas_item_raise_to_top (item);
      dragging = TRUE;
      break;

    case GDK_MOTION_NOTIFY:
      if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
        new_x = item_x;
        new_y = item_y;

        gnome_canvas_item_move (item, new_x - x, new_y - y);
        x = new_x;
        y = new_y;
      }
      break;

    case GDK_BUTTON_RELEASE:
      gnome_canvas_item_ungrab (item, event->button.time);
      dragging = FALSE;
      break;

    default:
      break;
  }

  return FALSE;
}
Пример #3
0
/**
 * This is called when the wire data was moved. Update the view accordingly.
 */
static void
wire_moved_callback (ItemData *data, SheetPos *pos, SheetItem *item)
{
	WireItem *wire_item;

	g_return_if_fail (data != NULL);
	g_return_if_fail (IS_ITEM_DATA (data));
	g_return_if_fail (item != NULL);
	g_return_if_fail (IS_WIRE_ITEM (item));

	if (pos == NULL)
		return;

	wire_item = WIRE_ITEM (item);

	/*
	 * Move the canvas item and invalidate the bbox cache.
	 */
	gnome_canvas_item_move (GNOME_CANVAS_ITEM (item), pos->x, pos->y);
	wire_item->priv->cache_valid = FALSE;
}
Пример #4
0
static gboolean
bst_canvas_source_event (GnomeCanvasItem *item,
			 GdkEvent        *event)
{
  BstCanvasSource *csource = BST_CANVAS_SOURCE (item);
  gboolean handled = FALSE;
  
  switch (event->type)
    {
    case GDK_BUTTON_PRESS:
      if (!csource->in_move && event->button.button == 2)
	{
	  GdkCursor *fleur = gdk_cursor_new (GDK_FLEUR);
	  if (gnome_canvas_item_grab (item,
                                      GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
                                      fleur,
                                      event->button.time) == 0)
            {
              gdouble x = event->button.x, y = event->button.y;
              gnome_canvas_item_w2i (item, &x, &y);
              csource->move_dx = x;
              csource->move_dy = y;
              csource->in_move = TRUE;
              bse_item_group_undo (csource->source, "Move");
            }
	  gdk_cursor_destroy (fleur);
	  handled = TRUE;
	}
      break;
    case GDK_MOTION_NOTIFY:
      if (csource->in_move)
	{
	  gdouble x = event->motion.x, y = event->motion.y;
	  
	  gnome_canvas_item_w2i (item, &x, &y);
	  gnome_canvas_item_move (item, x - csource->move_dx, y - csource->move_dy);
	  GNOME_CANVAS_NOTIFY (item);
	  handled = TRUE;
	}
      else
	{
	  guint channel;
	  const gchar *label = NULL, *prefix = NULL, *ident = NULL;

	  /* set i/o channel hints */
	  channel = bst_canvas_source_ichannel_at (csource, event->motion.x, event->motion.y);
	  if (channel != ~0)
	    {
	      label = bse_source_ichannel_label (csource->source, channel);
	      ident = bse_source_ichannel_ident (csource->source, channel);
	      prefix = _("Input");
	    }
	  else
	    {
	      channel = bst_canvas_source_ochannel_at (csource, event->motion.x, event->motion.y);
	      if (channel != ~0)
		{
		  label = bse_source_ochannel_label (csource->source, channel);
		  ident = bse_source_ochannel_ident (csource->source, channel);
		  prefix = _("Output");
		}
	    }
	  if (label)
	    gxk_status_printf (GXK_STATUS_IDLE_HINT, _("(Hint)"), "%s[%s]: %s", prefix, ident, label);
	  else
	    gxk_status_set (GXK_STATUS_IDLE_HINT, NULL, NULL);
	}
      break;
    case GDK_BUTTON_RELEASE:
      if (event->button.button == 2 && csource->in_move)
	{
          bse_item_ungroup_undo (csource->source);
	  csource->in_move = FALSE;
	  gnome_canvas_item_ungrab (item, event->button.time);
	  handled = TRUE;
	}
      break;
    default:
      break;
    }
  
  if (!handled && GNOME_CANVAS_ITEM_CLASS (bst_canvas_source_parent_class)->event)
    handled = GNOME_CANVAS_ITEM_CLASS (bst_canvas_source_parent_class)->event (item, event);
  
  return handled;
}
Пример #5
0
void continue_movesel(GdkEvent *event)
{
  double pt[2], dx, dy, upmargin;
  GList *list;
  struct Item *item;
  int tmppageno;
  struct Page *tmppage;
  
  get_pointer_coords(event, pt);
  if (ui.view_continuous == VIEW_MODE_CONTINUOUS) pt[1] += ui.selection->move_pagedelta;
  if (ui.view_continuous == VIEW_MODE_HORIZONTAL) pt[0] += ui.selection->move_pagedelta;
  if (ui.cur_item_type == ITEM_MOVESEL_VERT) pt[0] = 0;

  // check for page jumps
  if (ui.cur_item_type == ITEM_MOVESEL_VERT)
    upmargin = ui.selection->bbox.bottom - ui.selection->bbox.top;
  else upmargin = VIEW_CONTINUOUS_SKIP;
  tmppageno = ui.selection->move_pageno;
  tmppage = g_list_nth_data(journal.pages, tmppageno);
  if (ui.view_continuous == VIEW_MODE_CONTINUOUS) {
    while (pt[1] < - upmargin) {
      if (tmppageno == 0) break;
      tmppageno--;
      tmppage = g_list_nth_data(journal.pages, tmppageno);
      pt[1] += tmppage->height + VIEW_CONTINUOUS_SKIP;
      ui.selection->move_pagedelta += tmppage->height + VIEW_CONTINUOUS_SKIP;
    }
    while (pt[1] > tmppage->height+VIEW_CONTINUOUS_SKIP) {
      if (tmppageno == journal.npages-1) break;
      pt[1] -= tmppage->height + VIEW_CONTINUOUS_SKIP;
      ui.selection->move_pagedelta -= tmppage->height + VIEW_CONTINUOUS_SKIP;
      tmppageno++;
      tmppage = g_list_nth_data(journal.pages, tmppageno);
    }
  }
  if (ui.view_continuous == VIEW_MODE_HORIZONTAL) {
    while (pt[0] < -VIEW_CONTINUOUS_SKIP) {
      if (tmppageno == 0) break;
      tmppageno--;
      tmppage = g_list_nth_data(journal.pages, tmppageno);
      pt[0] += tmppage->width + VIEW_CONTINUOUS_SKIP;
      ui.selection->move_pagedelta += tmppage->width + VIEW_CONTINUOUS_SKIP;
    }
    while (pt[0] > tmppage->width+VIEW_CONTINUOUS_SKIP) {
      if (tmppageno == journal.npages-1) break;
      pt[0] -= tmppage->width + VIEW_CONTINUOUS_SKIP;
      ui.selection->move_pagedelta -= tmppage->width + VIEW_CONTINUOUS_SKIP;
      tmppageno++;
      tmppage = g_list_nth_data(journal.pages, tmppageno);
    }
  }
  
  if (tmppageno != ui.selection->move_pageno) {
    // move to a new page !
    ui.selection->move_pageno = tmppageno;
    if (tmppageno == ui.selection->orig_pageno)
      ui.selection->move_layer = ui.selection->layer;
    else
      ui.selection->move_layer = (struct Layer *)(g_list_last(
        ((struct Page *)g_list_nth_data(journal.pages, tmppageno))->layers)->data);
    gnome_canvas_item_reparent(ui.selection->canvas_item, ui.selection->move_layer->group);
    for (list = ui.selection->items; list!=NULL; list = list->next) {
      item = (struct Item *)list->data;
      if (item->canvas_item!=NULL)
        gnome_canvas_item_reparent(item->canvas_item, ui.selection->move_layer->group);
    }
    // avoid a refresh bug
    gnome_canvas_item_move(GNOME_CANVAS_ITEM(ui.selection->move_layer->group), 0., 0.);
    if (ui.cur_item_type == ITEM_MOVESEL_VERT)
      gnome_canvas_item_set(ui.selection->canvas_item,
        "x2", tmppage->width+100, 
        "y1", ui.selection->anchor_y+ui.selection->move_pagedelta, NULL);
            /* note: moving across pages for vert. space only works in vertical continuous mode */
  }
  
  // now, process things normally

  dx = pt[0] - ui.selection->last_x;
  dy = pt[1] - ui.selection->last_y;
  if (hypot(dx,dy) < 1) return; // don't move subpixel
  ui.selection->last_x = pt[0];
  ui.selection->last_y = pt[1];

  // move the canvas items
  if (ui.cur_item_type == ITEM_MOVESEL_VERT)
    gnome_canvas_item_set(ui.selection->canvas_item, "y2", pt[1], NULL);
  else 
    gnome_canvas_item_move(ui.selection->canvas_item, dx, dy);
  
  for (list = ui.selection->items; list != NULL; list = list->next) {
    item = (struct Item *)list->data;
    if (item->canvas_item != NULL)
      gnome_canvas_item_move(item->canvas_item, dx, dy);
  }
}
Пример #6
0
static gboolean
bst_canvas_link_event (GnomeCanvasItem *item,
		       GdkEvent        *event)
{
  BstCanvasLink *clink = BST_CANVAS_LINK (item);
  gboolean handled = FALSE;
  
  switch (event->type)
    {
    case GDK_BUTTON_PRESS:
      if (event->button.button == 2)
	{
	  GdkCursor *fleur;
	  
	  if (clink->ocsource)
	    {
	      clink->start_move_dx = event->button.x;
	      clink->start_move_dy = event->button.y;
	      gnome_canvas_item_w2i (GNOME_CANVAS_ITEM (clink->ocsource),
				     &clink->start_move_dx,
				     &clink->start_move_dy);
	    }
	  if (clink->icsource)
	    {
	      clink->end_move_dx = event->button.x;
	      clink->end_move_dy = event->button.y;
	      gnome_canvas_item_w2i (GNOME_CANVAS_ITEM (clink->icsource),
				     &clink->end_move_dx,
				     &clink->end_move_dy);
	    }
	  clink->in_move = TRUE;
	  
	  fleur = gdk_cursor_new (GDK_FLEUR);
	  gnome_canvas_item_grab (item,
				  GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
				  fleur,
				  event->button.time);
	  gdk_cursor_destroy (fleur);
	  handled = TRUE;
	}
      break;
    case GDK_MOTION_NOTIFY:
      if (clink->in_move && clink->ocsource)
	{
	  gdouble x = event->motion.x, y = event->motion.y;
	  
	  gnome_canvas_item_w2i (GNOME_CANVAS_ITEM (clink->ocsource), &x, &y);
	  gnome_canvas_item_move (GNOME_CANVAS_ITEM (clink->ocsource),
				  x - clink->start_move_dx,
				  y - clink->start_move_dy);
	  GNOME_CANVAS_NOTIFY (clink->ocsource);
	  handled = TRUE;
	}
      if (clink->in_move && clink->icsource)
	{
	  gdouble x = event->motion.x, y = event->motion.y;
	  
	  gnome_canvas_item_w2i (GNOME_CANVAS_ITEM (clink->icsource), &x, &y);
	  gnome_canvas_item_move (GNOME_CANVAS_ITEM (clink->icsource),
				  x - clink->end_move_dx,
				  y - clink->end_move_dy);
	  GNOME_CANVAS_NOTIFY (clink->icsource);
	  handled = TRUE;
	}
      break;
    case GDK_BUTTON_RELEASE:
      if (event->button.button == 2 && clink->in_move)
	{
	  clink->in_move = FALSE;
	  gnome_canvas_item_ungrab (item, event->button.time);
	  handled = TRUE;
	}
      break;
    default:
      break;
    }
  
  if (!handled && GNOME_CANVAS_ITEM_CLASS (bst_canvas_link_parent_class)->event)
    handled |= GNOME_CANVAS_ITEM_CLASS (bst_canvas_link_parent_class)->event (item, event);
  
  return handled;
}