gimp r26532 - in trunk: . app/display
- From: martinn svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26532 - in trunk: . app/display
- Date: Wed, 13 Aug 2008 18:37:15 +0000 (UTC)
Author: martinn
Date: Wed Aug 13 18:37:15 2008
New Revision: 26532
URL: http://svn.gnome.org/viewvc/gimp?rev=26532&view=rev
Log:
2008-08-13 Martin Nordholts <martinn svn gnome org>
* app/display/gimpdisplayshell-scale.c
(gimp_display_shell_scale_get_zoom_focus): New function
responsible for deciding what viewport coordinate to focus on when
zooming in and out.
Modified:
trunk/ChangeLog
trunk/app/display/gimpdisplayshell-scale.c
Modified: trunk/app/display/gimpdisplayshell-scale.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scale.c (original)
+++ trunk/app/display/gimpdisplayshell-scale.c Wed Aug 13 18:37:15 2008
@@ -74,6 +74,9 @@
gdouble scale,
gdouble x,
gdouble y);
+static void gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shell,
+ gint *x,
+ gint *y);
static void update_zoom_values (GtkAdjustment *adj,
ScaleDialogData *dialog);
@@ -308,8 +311,7 @@
GimpZoomType zoom_type,
gdouble new_scale)
{
- GdkEvent *event;
- gint x, y;
+ gint x, y;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (shell->canvas != NULL);
@@ -318,44 +320,7 @@
SCALE_EQUALS (new_scale, gimp_zoom_model_get_factor (shell->zoom)))
return;
- x = shell->disp_width / 2;
- y = shell->disp_height / 2;
-
- /* Center on the mouse position instead of the display center if
- * one of the following conditions are fulfilled and pointer is
- * within the canvas:
- *
- * (1) there's no current event (the action was triggered by an
- * input controller)
- * (2) the event originates from the canvas (a scroll event)
- * (3) the event originates from the shell (a key press event)
- *
- * Basically the only situation where we don't want to center on
- * mouse position is if the action is being called from a menu.
- */
-
- event = gtk_get_current_event ();
-
- if (! event ||
- gtk_get_event_widget (event) == shell->canvas ||
- gtk_get_event_widget (event) == GTK_WIDGET (shell))
- {
- gint canvas_pointer_x;
- gint canvas_pointer_y;
-
- gtk_widget_get_pointer (shell->canvas,
- &canvas_pointer_x,
- &canvas_pointer_y);
-
- if (canvas_pointer_x >= 0 &&
- canvas_pointer_y >= 0 &&
- canvas_pointer_x < shell->disp_width &&
- canvas_pointer_y < shell->disp_height)
- {
- x = canvas_pointer_x;
- y = canvas_pointer_y;
- }
- }
+ gimp_display_shell_scale_get_zoom_focus (shell, &x, &y);
gimp_display_shell_scale_to (shell, zoom_type, new_scale, x, y);
}
@@ -882,6 +847,61 @@
shell->display->config->resize_windows_on_zoom);
}
+/**
+ * gimp_display_shell_scale_get_zoom_focus:
+ * @shell:
+ * @x:
+ * @y:
+ *
+ * Calculates the viewport coordinate to focus on when zooming.
+ **/
+static void
+gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shell,
+ gint *x,
+ gint *y)
+{
+ GdkEvent *event;
+
+ *x = shell->disp_width / 2;
+ *y = shell->disp_height / 2;
+
+ /* Center on the mouse position instead of the display center if
+ * one of the following conditions are fulfilled and pointer is
+ * within the canvas:
+ *
+ * (1) there's no current event (the action was triggered by an
+ * input controller)
+ * (2) the event originates from the canvas (a scroll event)
+ * (3) the event originates from the shell (a key press event)
+ *
+ * Basically the only situation where we don't want to center on
+ * mouse position is if the action is being called from a menu.
+ */
+
+ event = gtk_get_current_event ();
+
+ if (! event ||
+ gtk_get_event_widget (event) == shell->canvas ||
+ gtk_get_event_widget (event) == GTK_WIDGET (shell))
+ {
+ gint canvas_pointer_x;
+ gint canvas_pointer_y;
+
+ gtk_widget_get_pointer (shell->canvas,
+ &canvas_pointer_x,
+ &canvas_pointer_y);
+
+ if (canvas_pointer_x >= 0 &&
+ canvas_pointer_y >= 0 &&
+ canvas_pointer_x < shell->disp_width &&
+ canvas_pointer_y < shell->disp_height)
+ {
+ *x = canvas_pointer_x;
+ *y = canvas_pointer_y;
+ }
+ }
+}
+
static void
update_zoom_values (GtkAdjustment *adj,
ScaleDialogData *dialog)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]