app: Keep canvas position on all display shell widgets
Don't use gimp_image_window_keep_canvas_pos() only for docks, use it for all widgets in the display shell: the rulers, the menu bar, the statusbar and the scrollbars. It is not really necessary for the two latter ones because they are below and/or to the right of the canvas, but we include them for completeness. Plus, they might get moved around some day...
This commit is contained in:
@ -124,6 +124,7 @@ gimp_display_shell_set_show_menubar (GimpDisplayShell *shell,
|
|||||||
|
|
||||||
if (window && gimp_image_window_get_active_shell (window) == shell)
|
if (window && gimp_image_window_get_active_shell (window) == shell)
|
||||||
{
|
{
|
||||||
|
gimp_image_window_keep_canvas_pos (gimp_display_shell_get_window (shell));
|
||||||
gimp_image_window_set_show_menubar (window, show);
|
gimp_image_window_set_show_menubar (window, show);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,6 +151,7 @@ gimp_display_shell_set_show_statusbar (GimpDisplayShell *shell,
|
|||||||
|
|
||||||
g_object_set (options, "show-statusbar", show, NULL);
|
g_object_set (options, "show-statusbar", show, NULL);
|
||||||
|
|
||||||
|
gimp_image_window_keep_canvas_pos (gimp_display_shell_get_window (shell));
|
||||||
gimp_statusbar_set_visible (GIMP_STATUSBAR (shell->statusbar), show);
|
gimp_statusbar_set_visible (GIMP_STATUSBAR (shell->statusbar), show);
|
||||||
|
|
||||||
appearance_set_action_active (shell, "view-show-statusbar", show);
|
appearance_set_action_active (shell, "view-show-statusbar", show);
|
||||||
@ -175,6 +177,7 @@ gimp_display_shell_set_show_rulers (GimpDisplayShell *shell,
|
|||||||
|
|
||||||
g_object_set (options, "show-rulers", show, NULL);
|
g_object_set (options, "show-rulers", show, NULL);
|
||||||
|
|
||||||
|
gimp_image_window_keep_canvas_pos (gimp_display_shell_get_window (shell));
|
||||||
gtk_widget_set_visible (shell->origin, show);
|
gtk_widget_set_visible (shell->origin, show);
|
||||||
gtk_widget_set_visible (shell->hrule, show);
|
gtk_widget_set_visible (shell->hrule, show);
|
||||||
gtk_widget_set_visible (shell->vrule, show);
|
gtk_widget_set_visible (shell->vrule, show);
|
||||||
@ -202,6 +205,7 @@ gimp_display_shell_set_show_scrollbars (GimpDisplayShell *shell,
|
|||||||
|
|
||||||
g_object_set (options, "show-scrollbars", show, NULL);
|
g_object_set (options, "show-scrollbars", show, NULL);
|
||||||
|
|
||||||
|
gimp_image_window_keep_canvas_pos (gimp_display_shell_get_window (shell));
|
||||||
gtk_widget_set_visible (shell->nav_ebox, show);
|
gtk_widget_set_visible (shell->nav_ebox, show);
|
||||||
gtk_widget_set_visible (shell->hsb, show);
|
gtk_widget_set_visible (shell->hsb, show);
|
||||||
gtk_widget_set_visible (shell->vsb, show);
|
gtk_widget_set_visible (shell->vsb, show);
|
||||||
|
@ -140,7 +140,6 @@ static void gimp_image_window_show_tooltip (GimpUIManager *man
|
|||||||
static void gimp_image_window_hide_tooltip (GimpUIManager *manager,
|
static void gimp_image_window_hide_tooltip (GimpUIManager *manager,
|
||||||
GimpImageWindow *window);
|
GimpImageWindow *window);
|
||||||
|
|
||||||
static void gimp_image_window_keep_canvas_pos (GimpImageWindow *window);
|
|
||||||
static gboolean gimp_image_window_resume_shell (GimpDisplayShell *shell);
|
static gboolean gimp_image_window_resume_shell (GimpDisplayShell *shell);
|
||||||
static void gimp_image_window_shell_size_allocate (GimpDisplayShell *shell,
|
static void gimp_image_window_shell_size_allocate (GimpDisplayShell *shell,
|
||||||
GtkAllocation *allocation,
|
GtkAllocation *allocation,
|
||||||
@ -1035,6 +1034,55 @@ gimp_image_window_shrink_wrap (GimpImageWindow *window,
|
|||||||
gimp_display_shell_scroll_center_image (active_shell, TRUE, TRUE);
|
gimp_display_shell_scroll_center_image (active_shell, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_image_window_keep_canvas_pos:
|
||||||
|
* @window:
|
||||||
|
*
|
||||||
|
* Stores the coordinate of the current shell image origin in
|
||||||
|
* GtkWindow coordinates and on the first size-allocate sets the
|
||||||
|
* offsets in the shell so the image origin remains the same in
|
||||||
|
* GtkWindow coordinates.
|
||||||
|
*
|
||||||
|
* Exampe use case: The user hides docks attached to the side of image
|
||||||
|
* windows. You want the image to remain fixed on the screen though,
|
||||||
|
* so you use this function to keep the image fixed after the docks
|
||||||
|
* have been hidden.
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gimp_image_window_keep_canvas_pos (GimpImageWindow *window)
|
||||||
|
{
|
||||||
|
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
|
||||||
|
gint image_origin_shell_x = -1;
|
||||||
|
gint image_origin_shell_y = -1;
|
||||||
|
gint image_origin_window_x = -1;
|
||||||
|
gint image_origin_window_y = -1;
|
||||||
|
PosCorrectionData *data = NULL;
|
||||||
|
|
||||||
|
/* Freeze the active tool until the UI has stabilized. If it draws
|
||||||
|
* while we hide widgets there will be flicker
|
||||||
|
*/
|
||||||
|
gimp_display_shell_pause (shell);
|
||||||
|
g_idle_add ((GSourceFunc) gimp_image_window_resume_shell, shell);
|
||||||
|
|
||||||
|
gimp_display_shell_transform_xy (shell,
|
||||||
|
0.0, 0.0,
|
||||||
|
&image_origin_shell_x, &image_origin_shell_y,
|
||||||
|
FALSE /*use_offsets*/);
|
||||||
|
gtk_widget_translate_coordinates (GTK_WIDGET (shell->canvas),
|
||||||
|
GTK_WIDGET (window),
|
||||||
|
image_origin_shell_x, image_origin_shell_y,
|
||||||
|
&image_origin_window_x, &image_origin_window_y);
|
||||||
|
|
||||||
|
data = g_new0 (PosCorrectionData, 1);
|
||||||
|
data->window = window;
|
||||||
|
data->x = image_origin_window_x;
|
||||||
|
data->y = image_origin_window_y;
|
||||||
|
g_signal_connect_data (shell, "size-allocate",
|
||||||
|
G_CALLBACK (gimp_image_window_shell_size_allocate),
|
||||||
|
data, (GClosureNotify) g_free,
|
||||||
|
G_CONNECT_AFTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* private functions */
|
/* private functions */
|
||||||
|
|
||||||
@ -1089,55 +1137,6 @@ gimp_image_window_hide_tooltip (GimpUIManager *manager,
|
|||||||
gimp_statusbar_pop (statusbar, "menu-tooltip");
|
gimp_statusbar_pop (statusbar, "menu-tooltip");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_image_window_keep_canvas_pos:
|
|
||||||
* @window:
|
|
||||||
*
|
|
||||||
* Stores the coordinate of the current shell image origin in
|
|
||||||
* GtkWindow coordinates and on the first size-allocate sets the
|
|
||||||
* offsets in the shell so the image origin remains the same in
|
|
||||||
* GtkWindow coordinates.
|
|
||||||
*
|
|
||||||
* Exampe use case: The user hides docks attached to the side of image
|
|
||||||
* windows. You want the image to remain fixed on the screen though,
|
|
||||||
* so you use this function to keep the image fixed after the docks
|
|
||||||
* have been hidden.
|
|
||||||
**/
|
|
||||||
static void
|
|
||||||
gimp_image_window_keep_canvas_pos (GimpImageWindow *window)
|
|
||||||
{
|
|
||||||
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
|
|
||||||
gint image_origin_shell_x = -1;
|
|
||||||
gint image_origin_shell_y = -1;
|
|
||||||
gint image_origin_window_x = -1;
|
|
||||||
gint image_origin_window_y = -1;
|
|
||||||
PosCorrectionData *data = NULL;
|
|
||||||
|
|
||||||
/* Freeze the active tool until the UI has stabilized. If it draws
|
|
||||||
* while we hide widgets there will be flicker
|
|
||||||
*/
|
|
||||||
gimp_display_shell_pause (shell);
|
|
||||||
g_idle_add ((GSourceFunc) gimp_image_window_resume_shell, shell);
|
|
||||||
|
|
||||||
gimp_display_shell_transform_xy (shell,
|
|
||||||
0.0, 0.0,
|
|
||||||
&image_origin_shell_x, &image_origin_shell_y,
|
|
||||||
FALSE /*use_offsets*/);
|
|
||||||
gtk_widget_translate_coordinates (GTK_WIDGET (shell->canvas),
|
|
||||||
GTK_WIDGET (window),
|
|
||||||
image_origin_shell_x, image_origin_shell_y,
|
|
||||||
&image_origin_window_x, &image_origin_window_y);
|
|
||||||
|
|
||||||
data = g_new0 (PosCorrectionData, 1);
|
|
||||||
data->window = window;
|
|
||||||
data->x = image_origin_window_x;
|
|
||||||
data->y = image_origin_window_y;
|
|
||||||
g_signal_connect_data (shell, "size-allocate",
|
|
||||||
G_CALLBACK (gimp_image_window_shell_size_allocate),
|
|
||||||
data, (GClosureNotify) g_free,
|
|
||||||
G_CONNECT_AFTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gimp_image_window_resume_shell (GimpDisplayShell *shell)
|
gimp_image_window_resume_shell (GimpDisplayShell *shell)
|
||||||
{
|
{
|
||||||
|
@ -85,5 +85,6 @@ gboolean gimp_image_window_is_iconified (GimpImageWindow *windo
|
|||||||
void gimp_image_window_shrink_wrap (GimpImageWindow *window,
|
void gimp_image_window_shrink_wrap (GimpImageWindow *window,
|
||||||
gboolean grow_only);
|
gboolean grow_only);
|
||||||
|
|
||||||
|
void gimp_image_window_keep_canvas_pos (GimpImageWindow *window);
|
||||||
|
|
||||||
#endif /* __GIMP_IMAGE_WINDOW_H__ */
|
#endif /* __GIMP_IMAGE_WINDOW_H__ */
|
||||||
|
Reference in New Issue
Block a user