app: in filter tools, allow toggling on-canvas controller visibility

In GimpFilterTool, when the filter uses an on-canvas controller,
provide a toggle in the tool's filter-options dialog allowing to
toggle the controller's visibility.  This allows getting the
controller out of the way when unneeded.
This commit is contained in:
Ell 2019-01-13 08:02:32 -05:00
parent f1a7abaef9
commit 33c22ae2a3
4 changed files with 50 additions and 4 deletions

View File

@ -36,6 +36,7 @@ enum
PROP_PREVIEW_SPLIT,
PROP_PREVIEW_ALIGNMENT,
PROP_PREVIEW_POSITION,
PROP_CONTROLLER,
PROP_REGION,
PROP_COLOR_MANAGED,
PROP_GAMMA_HACK
@ -96,6 +97,13 @@ gimp_filter_options_class_init (GimpFilterOptionsClass *klass)
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_CONTROLLER,
"controller",
_("On-canvas con_trols"),
_("Show on-canvas filter controls"),
TRUE,
GIMP_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_REGION,
g_param_spec_enum ("region",
NULL, NULL,
@ -152,6 +160,10 @@ gimp_filter_options_set_property (GObject *object,
options->preview_position = g_value_get_double (value);
break;
case PROP_CONTROLLER:
options->controller = g_value_get_boolean (value);
break;
case PROP_REGION:
options->region = g_value_get_enum (value);
break;
@ -196,6 +208,10 @@ gimp_filter_options_get_property (GObject *object,
g_value_set_double (value, options->preview_position);
break;
case PROP_CONTROLLER:
g_value_set_boolean (value, options->controller);
break;
case PROP_REGION:
g_value_set_enum (value, options->region);
break;

View File

@ -40,6 +40,7 @@ struct _GimpFilterOptions
gboolean preview_split;
GimpAlignmentType preview_alignment;
gdouble preview_position;
gboolean controller;
GimpFilterRegion region;
gboolean color_managed;
gboolean gamma_hack;

View File

@ -245,8 +245,9 @@ gimp_filter_tool_finalize (GObject *object)
g_clear_object (&filter_tool->settings);
g_clear_pointer (&filter_tool->description, g_free);
g_clear_object (&filter_tool->gui);
filter_tool->settings_box = NULL;
filter_tool->region_combo = NULL;
filter_tool->settings_box = NULL;
filter_tool->controller_toggle = NULL;
filter_tool->region_combo = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -374,6 +375,15 @@ gimp_filter_tool_initialize (GimpTool *tool,
toggle, "sensitive",
G_BINDING_SYNC_CREATE);
/* The show-controller toggle */
filter_tool->controller_toggle =
gimp_prop_check_button_new (G_OBJECT (tool_info->tool_options),
"controller", NULL);
gtk_box_pack_end (GTK_BOX (vbox), filter_tool->controller_toggle,
FALSE, FALSE, 0);
if (filter_tool->widget)
gtk_widget_show (filter_tool->controller_toggle);
/* The Color Options expander */
expander = gtk_expander_new (_("Advanced Color Options"));
gtk_expander_set_resize_toplevel (GTK_EXPANDER (expander), TRUE);
@ -788,6 +798,12 @@ gimp_filter_tool_options_notify (GimpTool *tool,
if (filter_options->preview_split)
gimp_filter_tool_move_guide (filter_tool);
}
else if (! strcmp (pspec->name, "controller") &&
filter_tool->widget)
{
gimp_tool_widget_set_visible (filter_tool->widget,
filter_options->controller);
}
else if (! strcmp (pspec->name, "region") &&
filter_tool->filter)
{
@ -978,8 +994,9 @@ gimp_filter_tool_halt (GimpFilterTool *filter_tool)
GTK_CONTAINER (gimp_filter_tool_dialog_get_vbox (filter_tool)));
g_clear_object (&filter_tool->gui);
filter_tool->settings_box = NULL;
filter_tool->region_combo = NULL;
filter_tool->settings_box = NULL;
filter_tool->controller_toggle = NULL;
filter_tool->region_combo = NULL;
}
if (filter_tool->filter)
@ -1750,12 +1767,23 @@ gimp_filter_tool_set_widget (GimpFilterTool *filter_tool,
if (filter_tool->widget)
{
GimpFilterOptions *options = GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool);
g_object_ref (filter_tool->widget);
gimp_tool_widget_set_visible (filter_tool->widget,
options->controller);
if (GIMP_TOOL (filter_tool)->display)
gimp_draw_tool_start (GIMP_DRAW_TOOL (filter_tool),
GIMP_TOOL (filter_tool)->display);
}
if (filter_tool->controller_toggle)
{
gtk_widget_set_visible (filter_tool->controller_toggle,
filter_tool->widget != NULL);
}
}
gboolean

View File

@ -58,6 +58,7 @@ struct _GimpFilterTool
gboolean overlay;
GimpToolGui *gui;
GtkWidget *settings_box;
GtkWidget *controller_toggle;
GtkWidget *region_combo;
GtkWidget *active_picker;