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);
        }
    }
}
示例#2
0
static void
gimp_blend_tool_update_item_hilight (GimpBlendTool *blend_tool)
{
  GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (blend_tool);

  if (gimp_draw_tool_is_active (draw_tool))
    {
      GimpBlendToolPoint hilight_point;
      gboolean           start_visible,  end_visible;
      gint               start_diameter, end_diameter;

      /* Calculate handle visibility */
      if (blend_tool->grabbed_point)
        {
          start_visible = FALSE;
          end_visible = FALSE;
        }
      else
        {
          gdouble dist;

          dist = gimp_draw_tool_calc_distance_square (draw_tool,
                                                      draw_tool->display,
                                                      blend_tool->mouse_x,
                                                      blend_tool->mouse_y,
                                                      blend_tool->start_x,
                                                      blend_tool->start_y);

          start_diameter = calc_handle_diameter (dist);
          start_visible  = start_diameter > 2;

          dist = gimp_draw_tool_calc_distance_square (draw_tool,
                                                      draw_tool->display,
                                                      blend_tool->mouse_x,
                                                      blend_tool->mouse_y,
                                                      blend_tool->end_x,
                                                      blend_tool->end_y);

          end_diameter = calc_handle_diameter (dist);
          end_visible  = end_diameter > 2;
        }

      gimp_canvas_item_set_visible (blend_tool->start_handle_circle,
                                    start_visible);
      gimp_canvas_item_set_visible (blend_tool->end_handle_circle,
                                    end_visible);

      /* Update hilights */
      if (blend_tool->grabbed_point)
        hilight_point = blend_tool->grabbed_point;
      else
        hilight_point = gimp_blend_tool_get_point_under_cursor (blend_tool);

      if (start_visible)
        {
          gimp_canvas_item_begin_change (blend_tool->start_handle_circle);
          g_object_set (blend_tool->start_handle_circle,
                        "width",  start_diameter,
                        "height", start_diameter,
                        NULL);
          gimp_canvas_item_end_change (blend_tool->start_handle_circle);
        }

      if (end_visible)
        {
          gimp_canvas_item_begin_change (blend_tool->end_handle_circle);
          g_object_set (blend_tool->end_handle_circle,
                        "width",  end_diameter,
                        "height", end_diameter,
                        NULL);
          gimp_canvas_item_end_change (blend_tool->end_handle_circle);
        }

      gimp_canvas_item_set_highlight (blend_tool->start_handle_circle,
                                      hilight_point == POINT_START);
      gimp_canvas_item_set_highlight (blend_tool->start_handle_cross,
                                      hilight_point == POINT_START);

      gimp_canvas_item_set_highlight (blend_tool->end_handle_circle,
                                      hilight_point == POINT_END);
      gimp_canvas_item_set_highlight (blend_tool->end_handle_cross,
                                      hilight_point == POINT_END);
  }
}