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.
This commit is contained in:
@ -1519,9 +1519,17 @@ gimp_display_shell_fill (GimpDisplayShell *shell,
|
|||||||
gimp_display_shell_set_unit (shell, unit);
|
gimp_display_shell_set_unit (shell, unit);
|
||||||
gimp_display_shell_set_initial_scale (shell, scale, NULL, NULL);
|
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_display_shell_sync_config (shell, shell->display->config);
|
||||||
|
|
||||||
|
gimp_image_window_suspend_keep_pos (window);
|
||||||
gimp_display_shell_appearance_update (shell);
|
gimp_display_shell_appearance_update (shell);
|
||||||
|
gimp_image_window_resume_keep_pos (window);
|
||||||
|
|
||||||
gimp_image_window_update_tabs (window);
|
gimp_image_window_update_tabs (window);
|
||||||
#if 0
|
#if 0
|
||||||
gimp_help_set_help_data (shell->canvas, NULL, NULL);
|
gimp_help_set_help_data (shell->canvas, NULL, NULL);
|
||||||
|
@ -118,6 +118,8 @@ struct _GimpImageWindowPrivate
|
|||||||
|
|
||||||
GdkScreen *initial_screen;
|
GdkScreen *initial_screen;
|
||||||
gint initial_monitor;
|
gint initial_monitor;
|
||||||
|
|
||||||
|
gint suspend_keep_pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -1599,12 +1601,22 @@ gimp_image_window_get_default_dockbook (GimpImageWindow *window)
|
|||||||
void
|
void
|
||||||
gimp_image_window_keep_canvas_pos (GimpImageWindow *window)
|
gimp_image_window_keep_canvas_pos (GimpImageWindow *window)
|
||||||
{
|
{
|
||||||
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
|
GimpImageWindowPrivate *private;
|
||||||
|
GimpDisplayShell *shell;
|
||||||
gint canvas_x;
|
gint canvas_x;
|
||||||
gint canvas_y;
|
gint canvas_y;
|
||||||
gint window_x;
|
gint window_x;
|
||||||
gint window_y;
|
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);
|
gimp_display_shell_transform_xy (shell, 0.0, 0.0, &canvas_x, &canvas_y);
|
||||||
|
|
||||||
if (gtk_widget_translate_coordinates (GTK_WIDGET (shell->canvas),
|
if (gtk_widget_translate_coordinates (GTK_WIDGET (shell->canvas),
|
||||||
@ -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:
|
* gimp_image_window_update_tabs:
|
||||||
@ -1803,9 +1840,11 @@ gimp_image_window_shell_size_allocate (GimpDisplayShell *shell,
|
|||||||
data->canvas_x, data->canvas_y,
|
data->canvas_x, data->canvas_y,
|
||||||
&new_window_x, &new_window_y))
|
&new_window_x, &new_window_y))
|
||||||
{
|
{
|
||||||
gimp_display_shell_scroll (shell,
|
gint off_x = new_window_x - data->window_x;
|
||||||
new_window_x - data->window_x,
|
gint off_y = new_window_y - data->window_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,
|
g_signal_handlers_disconnect_by_func (shell,
|
||||||
|
@ -93,6 +93,8 @@ void gimp_image_window_shrink_wrap (GimpImageWindow *win
|
|||||||
GtkWidget * gimp_image_window_get_default_dockbook (GimpImageWindow *window);
|
GtkWidget * gimp_image_window_get_default_dockbook (GimpImageWindow *window);
|
||||||
|
|
||||||
void gimp_image_window_keep_canvas_pos (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);
|
void gimp_image_window_update_tabs (GimpImageWindow *window);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user