void
gimp_display_shell_update_software_cursor (GimpDisplayShell    *shell,
                                           GimpCursorPrecision  precision,
                                           gint                 display_x,
                                           gint                 display_y,
                                           gdouble              image_x,
                                           gdouble              image_y)
{
  GimpStatusbar   *statusbar;
  GimpSessionInfo *session_info;
  GimpImage       *image;

  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));

  image = gimp_display_get_image (shell->display);

  if (shell->draw_cursor &&
      shell->proximity   &&
      display_x >= 0     &&
      display_y >= 0)
    {
      gimp_canvas_item_begin_change (shell->cursor);

      gimp_canvas_cursor_set (shell->cursor,
                              display_x,
                              display_y);
      gimp_canvas_item_set_visible (shell->cursor, TRUE);

      gimp_canvas_item_end_change (shell->cursor);
    }
  else
    {
      gimp_canvas_item_set_visible (shell->cursor, FALSE);
    }

  /*  use the passed image_coords for the statusbar because they are
   *  possibly snapped...
   */
  statusbar = gimp_display_shell_get_statusbar (shell);

  gimp_statusbar_update_cursor (statusbar, precision, image_x, image_y);

  session_info = gimp_dialog_factory_find_session_info (gimp_dialog_factory_get_singleton (),
                                                        "gimp-cursor-view");
  if (session_info && gimp_session_info_get_widget (session_info))
    {
      GtkWidget *cursor_view;

      cursor_view = gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (session_info)));

      if (cursor_view)
        {
          gint t_x = -1;
          gint t_y = -1;

          /*  ...but use the unsnapped display_coords for the info window  */
          if (display_x >= 0 && display_y >= 0)
            gimp_display_shell_untransform_xy (shell, display_x, display_y,
                                               &t_x, &t_y, FALSE);

          gimp_cursor_view_update_cursor (GIMP_CURSOR_VIEW (cursor_view),
                                          image, shell->unit,
                                          t_x, t_y);
        }
    }
}
Exemplo n.º 2
0
void
gimp_display_shell_update_cursor (GimpDisplayShell *shell,
                                  gint              display_x,
                                  gint              display_y,
                                  gint              image_x,
                                  gint              image_y)
{
    GimpDialogFactory *factory;
    GimpSessionInfo   *session_info;
    GimpImage         *image;
    gboolean           new_cursor;

    g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));

    image = shell->display->image;

    new_cursor = (shell->draw_cursor &&
                  shell->proximity   &&
                  display_x >= 0     &&
                  display_y >= 0);

    /* Erase old cursor, if necessary */

    if (shell->have_cursor && (! new_cursor                 ||
                               display_x != shell->cursor_x ||
                               display_y != shell->cursor_y))
    {
        gimp_display_shell_expose_area (shell,
                                        shell->cursor_x - 7,
                                        shell->cursor_y - 7,
                                        15, 15);
        if (! new_cursor)
            shell->have_cursor = FALSE;
    }

    shell->have_cursor = new_cursor;
    shell->cursor_x    = display_x;
    shell->cursor_y    = display_y;

    /*  use the passed image_coords for the statusbar because they are
     *  possibly snapped...
     */
    gimp_statusbar_update_cursor (GIMP_STATUSBAR (shell->statusbar),
                                  image_x, image_y);

    factory = gimp_dialog_factory_from_name ("dock");
    session_info = gimp_dialog_factory_find_session_info (factory,
                   "gimp-cursor-view");
    if (session_info && session_info->widget)
    {
        GtkWidget *cursor_view;

        cursor_view = gtk_bin_get_child (GTK_BIN (session_info->widget));

        if (cursor_view)
        {
            gint t_x = -1;
            gint t_y = -1;

            /*  ...but use the unsnapped display_coords for the info window  */
            if (display_x >= 0 && display_y >= 0)
                gimp_display_shell_untransform_xy (shell, display_x, display_y,
                                                   &t_x, &t_y, FALSE, FALSE);

            gimp_cursor_view_update_cursor (GIMP_CURSOR_VIEW (cursor_view),
                                            shell->display->image, shell->unit,
                                            t_x, t_y);
        }
    }
}