/** * gimp_display_shell_untransform_viewport: * @shell: a #GimpDisplayShell * @x: returns image x coordinate of display upper left corner * @y: returns image y coordinate of display upper left corner * @width: returns width of display measured in image coordinates * @height: returns height of display measured in image coordinates * * This function calculates the part of the image, im image coordinates, * that corresponds to the display viewport. **/ void gimp_display_shell_untransform_viewport (const GimpDisplayShell *shell, gint *x, gint *y, gint *width, gint *height) { GimpImage *image; gint x1, y1, x2, y2; g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); gimp_display_shell_untransform_xy (shell, 0, 0, &x1, &y1, FALSE); gimp_display_shell_untransform_xy (shell, shell->disp_width, shell->disp_height, &x2, &y2, FALSE); image = gimp_display_get_image (shell->display); if (x1 < 0) x1 = 0; if (y1 < 0) y1 = 0; if (x2 > gimp_image_get_width (image)) x2 = gimp_image_get_width (image); if (y2 > gimp_image_get_height (image)) y2 = gimp_image_get_height (image); if (x) *x = x1; if (y) *y = y1; if (width) *width = x2 - x1; if (height) *height = y2 - y1; }
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); } } }
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); } } }