[gimp] app: make new images jump around much less
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: make new images jump around much less
- Date: Mon, 11 Jan 2016 00:54:40 +0000 (UTC)
commit cbf231113467a94e9d35bfcb0b9d1008f5aa71f2
Author: Michael Natterer <mitch gimp org>
Date: Mon Jan 11 01:50:29 2016 +0100
app: make new images jump around much less
Implement a mechanism to suspend/resume GimpImageWindow's "keep canvas
pos" logic which is used to keep the image in place across widget
changed such as show/hide rulers.
gimp_display_shell_fill(): call suspend()/resume() around
gimp_display_shell_appearance_update(), and center the image after
calculating the initial scale factor, so the image jumping at least
starts at the approximately right position.
app/display/gimpdisplayshell.c | 8 ++++++
app/display/gimpimagewindow.c | 55 ++++++++++++++++++++++++++++++++++------
app/display/gimpimagewindow.h | 2 +
3 files changed, 57 insertions(+), 8 deletions(-)
---
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 31df80a..21e0e50 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -1519,9 +1519,17 @@ gimp_display_shell_fill (GimpDisplayShell *shell,
gimp_display_shell_set_unit (shell, unit);
gimp_display_shell_set_initial_scale (shell, scale, NULL, NULL);
+ /* center the image so subsequent stuff only moves it a little in
+ * the center
+ */
+ gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
+
gimp_display_shell_sync_config (shell, shell->display->config);
+ gimp_image_window_suspend_keep_pos (window);
gimp_display_shell_appearance_update (shell);
+ gimp_image_window_resume_keep_pos (window);
+
gimp_image_window_update_tabs (window);
#if 0
gimp_help_set_help_data (shell->canvas, NULL, NULL);
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index bae461c..b629d78 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -118,6 +118,8 @@ struct _GimpImageWindowPrivate
GdkScreen *initial_screen;
gint initial_monitor;
+
+ gint suspend_keep_pos;
};
typedef struct
@@ -1599,11 +1601,21 @@ gimp_image_window_get_default_dockbook (GimpImageWindow *window)
void
gimp_image_window_keep_canvas_pos (GimpImageWindow *window)
{
- GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
- gint canvas_x;
- gint canvas_y;
- gint window_x;
- gint window_y;
+ GimpImageWindowPrivate *private;
+ GimpDisplayShell *shell;
+ gint canvas_x;
+ gint canvas_y;
+ gint window_x;
+ gint window_y;
+
+ g_return_if_fail (GIMP_IS_IMAGE_WINDOW (window));
+
+ private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
+
+ if (private->suspend_keep_pos > 0)
+ return;
+
+ shell = gimp_image_window_get_active_shell (window);
gimp_display_shell_transform_xy (shell, 0.0, 0.0, &canvas_x, &canvas_y);
@@ -1626,6 +1638,31 @@ gimp_image_window_keep_canvas_pos (GimpImageWindow *window)
}
}
+void
+gimp_image_window_suspend_keep_pos (GimpImageWindow *window)
+{
+ GimpImageWindowPrivate *private;
+
+ g_return_if_fail (GIMP_IS_IMAGE_WINDOW (window));
+
+ private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
+
+ private->suspend_keep_pos++;
+}
+
+void
+gimp_image_window_resume_keep_pos (GimpImageWindow *window)
+{
+ GimpImageWindowPrivate *private;
+
+ g_return_if_fail (GIMP_IS_IMAGE_WINDOW (window));
+
+ private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
+
+ g_return_if_fail (private->suspend_keep_pos > 0);
+
+ private->suspend_keep_pos--;
+}
/**
* gimp_image_window_update_tabs:
@@ -1803,9 +1840,11 @@ gimp_image_window_shell_size_allocate (GimpDisplayShell *shell,
data->canvas_x, data->canvas_y,
&new_window_x, &new_window_y))
{
- gimp_display_shell_scroll (shell,
- new_window_x - data->window_x,
- new_window_y - data->window_y);
+ gint off_x = new_window_x - data->window_x;
+ gint off_y = new_window_y - data->window_y;
+
+ if (off_x || off_y)
+ gimp_display_shell_scroll (shell, off_x, off_y);
}
g_signal_handlers_disconnect_by_func (shell,
diff --git a/app/display/gimpimagewindow.h b/app/display/gimpimagewindow.h
index ca326f9..6c6b16e 100644
--- a/app/display/gimpimagewindow.h
+++ b/app/display/gimpimagewindow.h
@@ -93,6 +93,8 @@ void gimp_image_window_shrink_wrap (GimpImageWindow *win
GtkWidget * gimp_image_window_get_default_dockbook (GimpImageWindow *window);
void gimp_image_window_keep_canvas_pos (GimpImageWindow *window);
+void gimp_image_window_suspend_keep_pos (GimpImageWindow *window);
+void gimp_image_window_resume_keep_pos (GimpImageWindow *window);
void gimp_image_window_update_tabs (GimpImageWindow *window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]