Commit 235a20b6 authored by Ell's avatar Ell

app: add option to keep canvas padding in "show all" mode

Add an option to keep the normal canvas padding in "show all" mode,
instead of extending the checkerboard pattern indefinitely.  This
is useful when wanting to show the image content beyond the canvas,
while still keeping the focus on the canvas; further commits will
extend this mode to behave in more view-related cases as if "show
all" wasn't enabled.

Add a new 'View -> Padding Color -> Keep Padding in "Show All"
Mode" toggle, which controls this behavior, with a corresponding
default-value option in the preferences, under "Image Windows ->
Appearance".
parent f7798bcd
......@@ -627,6 +627,17 @@ static const GimpEnumActionEntry view_padding_color_actions[] =
GIMP_HELP_VIEW_PADDING_COLOR }
};
static const GimpToggleActionEntry view_padding_color_toggle_actions[] =
{
{ "view-padding-color-in-show-all", NULL,
NC_("view-padding-color", "Keep Padding in \"Show _All\" Mode"), NULL,
NC_("view-padding-color",
"Keep canvas padding when \"View -> Show All\" is enabled"),
view_padding_color_in_show_all_cmd_callback,
FALSE,
GIMP_HELP_VIEW_PADDING_COLOR }
};
static const GimpEnumActionEntry view_scroll_horizontal_actions[] =
{
{ "view-scroll-horizontal", NULL,
......@@ -762,6 +773,10 @@ view_actions_setup (GimpActionGroup *group)
G_N_ELEMENTS (view_padding_color_actions),
view_padding_color_cmd_callback);
gimp_action_group_add_toggle_actions (group, "view-padding-color",
view_padding_color_toggle_actions,
G_N_ELEMENTS (view_padding_color_toggle_actions));
gimp_action_group_add_enum_actions (group, "view-action",
view_scroll_horizontal_actions,
G_N_ELEMENTS (view_scroll_horizontal_actions),
......@@ -1044,6 +1059,9 @@ view_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("view-padding-color-custom", image);
SET_SENSITIVE ("view-padding-color-prefs", image);
SET_SENSITIVE ("view-padding-color-in-show-all", image);
SET_ACTIVE ("view-padding-color-in-show-all", display && options->padding_in_show_all);
SET_SENSITIVE ("view-show-menubar", image);
SET_ACTIVE ("view-show-menubar", display && options->show_menubar);
SET_SENSITIVE ("view-show-rulers", image);
......
......@@ -1162,11 +1162,30 @@ view_padding_color_cmd_callback (GimpAction *action,
gimp_display_shell_set_padding (shell,
default_options->padding_mode,
&default_options->padding_color);
gimp_display_shell_set_padding_in_show_all (shell,
default_options->padding_in_show_all);
}
break;
}
}
void
view_padding_color_in_show_all_cmd_callback (GimpAction *action,
GVariant *value,
gpointer data)
{
GimpDisplayShell *shell;
gboolean active;
return_if_no_shell (shell, data);
active = g_variant_get_boolean (value);
if (active != gimp_display_shell_get_padding_in_show_all (shell))
{
gimp_display_shell_set_padding_in_show_all (shell, active);
}
}
void
view_shrink_wrap_cmd_callback (GimpAction *action,
GVariant *value,
......
......@@ -166,6 +166,9 @@ void view_snap_to_vectors_cmd_callback (GimpAction *action,
void view_padding_color_cmd_callback (GimpAction *action,
GVariant *value,
gpointer data);
void view_padding_color_in_show_all_cmd_callback (GimpAction *action,
GVariant *value,
gpointer data);
void view_shrink_wrap_cmd_callback (GimpAction *action,
GVariant *value,
......
......@@ -56,7 +56,8 @@ enum
PROP_SNAP_TO_CANVAS,
PROP_SNAP_TO_PATH,
PROP_PADDING_MODE,
PROP_PADDING_COLOR
PROP_PADDING_COLOR,
PROP_PADDING_IN_SHOW_ALL
};
......@@ -219,6 +220,13 @@ gimp_display_options_class_init (GimpDisplayOptionsClass *klass)
CANVAS_PADDING_COLOR_BLURB,
FALSE, &white,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_PADDING_IN_SHOW_ALL,
"padding-in-show-all",
"Keep padding in \"Show All\" mode",
CANVAS_PADDING_IN_SHOW_ALL_BLURB,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
}
static void
......@@ -344,6 +352,13 @@ gimp_display_options_fullscreen_class_init (GimpDisplayOptionsFullscreenClass *k
CANVAS_PADDING_COLOR_BLURB,
FALSE, &black,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_PADDING_IN_SHOW_ALL,
"padding-in-show-all",
"Keep padding in \"Show All\" mode",
CANVAS_PADDING_IN_SHOW_ALL_BLURB,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
}
static void
......@@ -503,6 +518,9 @@ gimp_display_options_set_property (GObject *object,
case PROP_PADDING_COLOR:
options->padding_color = *(GimpRGB *) g_value_get_boxed (value);
break;
case PROP_PADDING_IN_SHOW_ALL:
options->padding_in_show_all = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -568,6 +586,9 @@ gimp_display_options_get_property (GObject *object,
case PROP_PADDING_COLOR:
g_value_set_boxed (value, &options->padding_color);
break;
case PROP_PADDING_IN_SHOW_ALL:
g_value_set_boolean (value, options->padding_in_show_all);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......
......@@ -61,6 +61,7 @@ struct _GimpDisplayOptions
GimpCanvasPaddingMode padding_mode;
GimpRGB padding_color;
gboolean padding_mode_set;
gboolean padding_in_show_all;
};
struct _GimpDisplayOptionsClass
......
......@@ -33,6 +33,10 @@ _("Sets the dynamics search path.")
_("Sets the canvas padding color used if the padding mode is set to " \
"custom color.")
#define CANVAS_PADDING_IN_SHOW_ALL_BLURB \
_("Specifies whether to keep the canvas padding when \"View -> Show All\" " \
"is enabled.")
#define CANVAS_PADDING_MODE_BLURB \
_("Specifies how the area around the image should be drawn.")
......
......@@ -1010,6 +1010,10 @@ prefs_display_options_frame_add (Gimp *gimp,
g_signal_connect (button, "color-changed",
G_CALLBACK (prefs_canvas_padding_color_changed),
combo);
prefs_check_button_add (object, "padding-in-show-all",
_("_Keep canvas padding in \"Show All\" mode"),
GTK_BOX (vbox));
}
static void
......
......@@ -36,6 +36,7 @@
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-actions.h"
#include "gimpdisplayshell-appearance.h"
#include "gimpdisplayshell-expose.h"
#include "gimpdisplayshell-selection.h"
#include "gimpimagewindow.h"
#include "gimpstatusbar.h"
......@@ -67,30 +68,32 @@ gimp_display_shell_appearance_update (GimpDisplayShell *shell)
fullscreen);
}
gimp_display_shell_set_show_menubar (shell,
options->show_menubar);
gimp_display_shell_set_show_statusbar (shell,
options->show_statusbar);
gimp_display_shell_set_show_rulers (shell,
options->show_rulers);
gimp_display_shell_set_show_scrollbars (shell,
options->show_scrollbars);
gimp_display_shell_set_show_selection (shell,
options->show_selection);
gimp_display_shell_set_show_layer (shell,
options->show_layer_boundary);
gimp_display_shell_set_show_canvas (shell,
options->show_canvas_boundary);
gimp_display_shell_set_show_guides (shell,
options->show_guides);
gimp_display_shell_set_show_grid (shell,
options->show_grid);
gimp_display_shell_set_show_sample_points (shell,
options->show_sample_points);
gimp_display_shell_set_padding (shell,
options->padding_mode,
&options->padding_color);
gimp_display_shell_set_show_menubar (shell,
options->show_menubar);
gimp_display_shell_set_show_statusbar (shell,
options->show_statusbar);
gimp_display_shell_set_show_rulers (shell,
options->show_rulers);
gimp_display_shell_set_show_scrollbars (shell,
options->show_scrollbars);
gimp_display_shell_set_show_selection (shell,
options->show_selection);
gimp_display_shell_set_show_layer (shell,
options->show_layer_boundary);
gimp_display_shell_set_show_canvas (shell,
options->show_canvas_boundary);
gimp_display_shell_set_show_guides (shell,
options->show_guides);
gimp_display_shell_set_show_grid (shell,
options->show_grid);
gimp_display_shell_set_show_sample_points (shell,
options->show_sample_points);
gimp_display_shell_set_padding (shell,
options->padding_mode,
&options->padding_color);
gimp_display_shell_set_padding_in_show_all (shell,
options->padding_in_show_all);
}
void
......@@ -523,6 +526,37 @@ gimp_display_shell_get_padding (GimpDisplayShell *shell,
*padding_color = options->padding_color;
}
void
gimp_display_shell_set_padding_in_show_all (GimpDisplayShell *shell,
gboolean keep)
{
GimpDisplayOptions *options;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
options = appearance_get_options (shell);
if (options->padding_in_show_all != keep)
{
g_object_set (options, "padding-in-show-all", keep, NULL);
if (shell->display)
gimp_display_shell_expose_full (shell);
gimp_display_shell_set_action_active (shell,
"view-padding-color-in-show-all",
keep);
}
}
gboolean
gimp_display_shell_get_padding_in_show_all (GimpDisplayShell *shell)
{
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
return appearance_get_options (shell)->padding_in_show_all;
}
/* private functions */
......
......@@ -19,71 +19,74 @@
#define __GIMP_DISPLAY_SHELL_APPEARANCE_H__
void gimp_display_shell_appearance_update (GimpDisplayShell *shell);
void gimp_display_shell_set_show_menubar (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_menubar (GimpDisplayShell *shell);
void gimp_display_shell_set_show_statusbar (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_statusbar (GimpDisplayShell *shell);
void gimp_display_shell_set_show_rulers (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_rulers (GimpDisplayShell *shell);
void gimp_display_shell_set_show_scrollbars (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_scrollbars (GimpDisplayShell *shell);
void gimp_display_shell_set_show_selection (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_selection (GimpDisplayShell *shell);
void gimp_display_shell_set_show_layer (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_layer (GimpDisplayShell *shell);
void gimp_display_shell_set_show_canvas (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_canvas (GimpDisplayShell *shell);
void gimp_display_shell_update_show_canvas (GimpDisplayShell *shell);
void gimp_display_shell_set_show_grid (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_grid (GimpDisplayShell *shell);
void gimp_display_shell_set_show_guides (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_guides (GimpDisplayShell *shell);
void gimp_display_shell_set_snap_to_grid (GimpDisplayShell *shell,
gboolean snap);
gboolean gimp_display_shell_get_snap_to_grid (GimpDisplayShell *shell);
void gimp_display_shell_set_show_sample_points (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_sample_points (GimpDisplayShell *shell);
void gimp_display_shell_set_snap_to_guides (GimpDisplayShell *shell,
gboolean snap);
gboolean gimp_display_shell_get_snap_to_guides (GimpDisplayShell *shell);
void gimp_display_shell_set_snap_to_canvas (GimpDisplayShell *shell,
gboolean snap);
gboolean gimp_display_shell_get_snap_to_canvas (GimpDisplayShell *shell);
void gimp_display_shell_set_snap_to_vectors (GimpDisplayShell *shell,
gboolean snap);
gboolean gimp_display_shell_get_snap_to_vectors (GimpDisplayShell *shell);
void gimp_display_shell_set_padding (GimpDisplayShell *shell,
GimpCanvasPaddingMode mode,
const GimpRGB *color);
void gimp_display_shell_get_padding (GimpDisplayShell *shell,
GimpCanvasPaddingMode *mode,
GimpRGB *color);
void gimp_display_shell_appearance_update (GimpDisplayShell *shell);
void gimp_display_shell_set_show_menubar (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_menubar (GimpDisplayShell *shell);
void gimp_display_shell_set_show_statusbar (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_statusbar (GimpDisplayShell *shell);
void gimp_display_shell_set_show_rulers (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_rulers (GimpDisplayShell *shell);
void gimp_display_shell_set_show_scrollbars (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_scrollbars (GimpDisplayShell *shell);
void gimp_display_shell_set_show_selection (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_selection (GimpDisplayShell *shell);
void gimp_display_shell_set_show_layer (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_layer (GimpDisplayShell *shell);
void gimp_display_shell_set_show_canvas (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_canvas (GimpDisplayShell *shell);
void gimp_display_shell_update_show_canvas (GimpDisplayShell *shell);
void gimp_display_shell_set_show_grid (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_grid (GimpDisplayShell *shell);
void gimp_display_shell_set_show_guides (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_guides (GimpDisplayShell *shell);
void gimp_display_shell_set_snap_to_grid (GimpDisplayShell *shell,
gboolean snap);
gboolean gimp_display_shell_get_snap_to_grid (GimpDisplayShell *shell);
void gimp_display_shell_set_show_sample_points (GimpDisplayShell *shell,
gboolean show);
gboolean gimp_display_shell_get_show_sample_points (GimpDisplayShell *shell);
void gimp_display_shell_set_snap_to_guides (GimpDisplayShell *shell,
gboolean snap);
gboolean gimp_display_shell_get_snap_to_guides (GimpDisplayShell *shell);
void gimp_display_shell_set_snap_to_canvas (GimpDisplayShell *shell,
gboolean snap);
gboolean gimp_display_shell_get_snap_to_canvas (GimpDisplayShell *shell);
void gimp_display_shell_set_snap_to_vectors (GimpDisplayShell *shell,
gboolean snap);
gboolean gimp_display_shell_get_snap_to_vectors (GimpDisplayShell *shell);
void gimp_display_shell_set_padding (GimpDisplayShell *shell,
GimpCanvasPaddingMode mode,
const GimpRGB *color);
void gimp_display_shell_get_padding (GimpDisplayShell *shell,
GimpCanvasPaddingMode *mode,
GimpRGB *color);
void gimp_display_shell_set_padding_in_show_all (GimpDisplayShell *shell,
gboolean keep);
gboolean gimp_display_shell_get_padding_in_show_all (GimpDisplayShell *shell);
#endif /* __GIMP_DISPLAY_SHELL_APPEARANCE_H__ */
......@@ -485,6 +485,7 @@ gimp_display_shell_canvas_draw_image (GimpDisplayShell *shell,
cairo_rectangle_list_t *clip_rectangles;
GeglRectangle image_rect;
GeglRectangle rotated_image_rect;
GeglRectangle canvas_rect;
cairo_matrix_t matrix;
gdouble x1, y1;
gdouble x2, y2;
......@@ -496,6 +497,13 @@ gimp_display_shell_canvas_draw_image (GimpDisplayShell *shell,
&image_rect.width,
&image_rect.height);
gimp_display_shell_scale_get_image_unrotated_bounds (
shell,
&canvas_rect.x,
&canvas_rect.y,
&canvas_rect.width,
&canvas_rect.height);
/* first, draw the background
*/
......@@ -516,7 +524,19 @@ gimp_display_shell_canvas_draw_image (GimpDisplayShell *shell,
if (shell->show_all)
{
cairo_save (cr);
if (gimp_display_shell_get_padding_in_show_all (shell))
{
cairo_rectangle (cr,
canvas_rect.x,
canvas_rect.y,
canvas_rect.width,
canvas_rect.height);
cairo_clip (cr);
}
gimp_display_shell_draw_checkerboard (shell, cr);
cairo_restore (cr);
}
......
......@@ -351,6 +351,8 @@
<menuitem action="view-padding-color-dark-check" />
<menuitem action="view-padding-color-custom" />
<separator />
<menuitem action="view-padding-color-in-show-all" />
<separator />
<menuitem action="view-padding-color-prefs" />
</menu>
<menuitem action="view-show-menubar" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment