void gimp_display_shell_rotate (GimpDisplayShell *shell, gdouble delta) { g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); gimp_display_shell_rotate_to (shell, shell->rotate_angle + delta); }
void gimp_display_shell_rotate_drag (GimpDisplayShell *shell, gdouble last_x, gdouble last_y, gdouble cur_x, gdouble cur_y, gboolean constrain) { gint image_width, image_height; gdouble px, py; gdouble x1, y1, x2, y2; gdouble angle1, angle2, angle; g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); gimp_display_shell_scale_get_image_size (shell, &image_width, &image_height); px = -shell->offset_x + image_width / 2; py = -shell->offset_y + image_height / 2; x1 = cur_x - px; x2 = last_x - px; y1 = py - cur_y; y2 = py - last_y; /* find the first angle */ angle1 = atan2 (y1, x1); /* find the angle */ angle2 = atan2 (y2, x2); angle = angle2 - angle1; if (angle > G_PI || angle < -G_PI) angle = angle2 - ((angle1 < 0) ? 2.0 * G_PI + angle1 : angle1 - 2.0 * G_PI); shell->rotate_drag_angle += (angle * 180.0 / G_PI); if (shell->rotate_drag_angle < 0.0) shell->rotate_drag_angle += 360; if (shell->rotate_drag_angle >= 360.0) shell->rotate_drag_angle -= 360; gimp_display_shell_rotate_to (shell, constrain ? (gint) shell->rotate_drag_angle / 15 * 15 : shell->rotate_drag_angle); }
static void rotate_adjustment_changed (GtkAdjustment *adj, RotateDialogData *dialog) { gdouble angle = gtk_adjustment_get_value (dialog->rotate_adj); g_signal_handlers_block_by_func (dialog->shell, display_shell_rotated, dialog); gimp_display_shell_rotate_to (dialog->shell, angle); g_signal_handlers_unblock_by_func (dialog->shell, display_shell_rotated, dialog); }
void view_rotate_absolute_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpDisplay *display; GimpDisplayShell *shell; gdouble angle = 0.0; return_if_no_display (display, data); shell = gimp_display_get_shell (display); angle = action_select_value ((GimpActionSelectType) value, 0.0, -180.0, 180.0, 0.0, 1.0, 15.0, 90.0, 0.0, TRUE); gimp_display_shell_rotate_to (shell, angle); }