Commit 6c5515c6 authored by Michael Natterer's avatar Michael Natterer 😴

app: allow to specify the workarea of GEGL ops in the GEGL tool GUI

Add a combo that switches between "selection" and "entire layer".
Need to find a way to hide that thing when the setting makes no
difference. Also the combo is generally pretty much experimantal.
parent 41fc19e7
...@@ -1179,6 +1179,35 @@ gimp_dynamics_output_type_get_type (void) ...@@ -1179,6 +1179,35 @@ gimp_dynamics_output_type_get_type (void)
return type; return type;
} }
GType
gimp_image_map_region_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_IMAGE_MAP_REGION_SELECTION, "GIMP_IMAGE_MAP_REGION_SELECTION", "selection" },
{ GIMP_IMAGE_MAP_REGION_DRAWABLE, "GIMP_IMAGE_MAP_REGION_DRAWABLE", "drawable" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_IMAGE_MAP_REGION_SELECTION, NC_("image-map-region", "Use the selection as input"), NULL },
{ GIMP_IMAGE_MAP_REGION_DRAWABLE, NC_("image-map-region", "Use the entire layer as input"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("GimpImageMapRegion", values);
gimp_type_set_translation_context (type, "image-map-region");
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
/* Generated data ends here */ /* Generated data ends here */
...@@ -543,6 +543,17 @@ typedef enum /*< pdb-skip >*/ ...@@ -543,6 +543,17 @@ typedef enum /*< pdb-skip >*/
} GimpDynamicsOutputType; } GimpDynamicsOutputType;
#define GIMP_TYPE_IMAGE_MAP_REGION (gimp_image_map_region_get_type ())
GType gimp_image_map_region_get_type (void) G_GNUC_CONST;
typedef enum /*< pdb-skip >*/
{
GIMP_IMAGE_MAP_REGION_SELECTION, /*< desc="Use the selection as input" >*/
GIMP_IMAGE_MAP_REGION_DRAWABLE /*< desc="Use the entire layer as input" >*/
} GimpImageMapRegion;
/* /*
* non-registered enums; register them if needed * non-registered enums; register them if needed
*/ */
......
...@@ -22,13 +22,6 @@ ...@@ -22,13 +22,6 @@
#include "gimpobject.h" #include "gimpobject.h"
typedef enum
{
GIMP_IMAGE_MAP_REGION_SELECTION,
GIMP_IMAGE_MAP_REGION_DRAWABLE
} GimpImageMapRegion;
#define GIMP_TYPE_IMAGE_MAP (gimp_image_map_get_type ()) #define GIMP_TYPE_IMAGE_MAP (gimp_image_map_get_type ())
#define GIMP_IMAGE_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_IMAGE_MAP, GimpImageMap)) #define GIMP_IMAGE_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_IMAGE_MAP, GimpImageMap))
#define GIMP_IMAGE_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_IMAGE_MAP, GimpImageMapClass)) #define GIMP_IMAGE_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_IMAGE_MAP, GimpImageMapClass))
......
...@@ -31,6 +31,7 @@ enum ...@@ -31,6 +31,7 @@ enum
{ {
PROP_0, PROP_0,
PROP_PREVIEW, PROP_PREVIEW,
PROP_REGION,
PROP_SETTINGS PROP_SETTINGS
}; };
...@@ -65,6 +66,15 @@ gimp_image_map_options_class_init (GimpImageMapOptionsClass *klass) ...@@ -65,6 +66,15 @@ gimp_image_map_options_class_init (GimpImageMapOptionsClass *klass)
"preview", NULL, "preview", NULL,
TRUE, TRUE,
GIMP_PARAM_STATIC_STRINGS); GIMP_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_REGION,
g_param_spec_enum ("region",
NULL, NULL,
GIMP_TYPE_IMAGE_MAP_REGION,
GIMP_IMAGE_MAP_REGION_SELECTION,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_SETTINGS, g_object_class_install_property (object_class, PROP_SETTINGS,
g_param_spec_string ("settings", g_param_spec_string ("settings",
NULL, NULL, NULL, NULL,
...@@ -105,10 +115,16 @@ gimp_image_map_options_set_property (GObject *object, ...@@ -105,10 +115,16 @@ gimp_image_map_options_set_property (GObject *object,
case PROP_PREVIEW: case PROP_PREVIEW:
options->preview = g_value_get_boolean (value); options->preview = g_value_get_boolean (value);
break; break;
case PROP_REGION:
options->region = g_value_get_enum (value);
break;
case PROP_SETTINGS: case PROP_SETTINGS:
g_free (options->settings); g_free (options->settings);
options->settings = g_value_dup_string (value); options->settings = g_value_dup_string (value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break; break;
...@@ -128,9 +144,15 @@ gimp_image_map_options_get_property (GObject *object, ...@@ -128,9 +144,15 @@ gimp_image_map_options_get_property (GObject *object,
case PROP_PREVIEW: case PROP_PREVIEW:
g_value_set_boolean (value, options->preview); g_value_set_boolean (value, options->preview);
break; break;
case PROP_REGION:
g_value_set_enum (value, options->region);
break;
case PROP_SETTINGS: case PROP_SETTINGS:
g_value_set_string (value, options->settings); g_value_set_string (value, options->settings);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break; break;
......
...@@ -37,6 +37,7 @@ struct _GimpImageMapOptions ...@@ -37,6 +37,7 @@ struct _GimpImageMapOptions
GimpToolOptions parent_instance; GimpToolOptions parent_instance;
gboolean preview; gboolean preview;
GimpImageMapRegion region;
gchar *settings; gchar *settings;
}; };
......
...@@ -341,6 +341,7 @@ gimp_image_map_tool_initialize (GimpTool *tool, ...@@ -341,6 +341,7 @@ gimp_image_map_tool_initialize (GimpTool *tool,
{ {
GimpImageMapToolClass *klass; GimpImageMapToolClass *klass;
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *combo;
GtkWidget *toggle; GtkWidget *toggle;
klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool); klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);
...@@ -403,7 +404,7 @@ gimp_image_map_tool_initialize (GimpTool *tool, ...@@ -403,7 +404,7 @@ gimp_image_map_tool_initialize (GimpTool *tool,
gtk_widget_show (settings_ui); gtk_widget_show (settings_ui);
} }
/* The hack toggle */ /* The gamma hack toggle */
toggle = gtk_check_button_new_with_label ("Gamma hack (temp hack, please ignore)"); toggle = gtk_check_button_new_with_label ("Gamma hack (temp hack, please ignore)");
gtk_box_pack_end (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
gtk_widget_show (toggle); gtk_widget_show (toggle);
...@@ -416,10 +417,16 @@ gimp_image_map_tool_initialize (GimpTool *tool, ...@@ -416,10 +417,16 @@ gimp_image_map_tool_initialize (GimpTool *tool,
toggle = gimp_prop_check_button_new (G_OBJECT (tool_info->tool_options), toggle = gimp_prop_check_button_new (G_OBJECT (tool_info->tool_options),
"preview", "preview",
_("_Preview")); _("_Preview"));
gtk_box_pack_end (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
gtk_widget_show (toggle); gtk_widget_show (toggle);
/* The area combo */
combo = gimp_prop_enum_combo_box_new (G_OBJECT (tool_info->tool_options),
"region",
0, 0);
gtk_box_pack_end (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
gtk_widget_show (combo);
/* Fill in subclass widgets */ /* Fill in subclass widgets */
gimp_image_map_tool_dialog (image_map_tool); gimp_image_map_tool_dialog (image_map_tool);
} }
...@@ -527,6 +534,16 @@ gimp_image_map_tool_options_notify (GimpTool *tool, ...@@ -527,6 +534,16 @@ gimp_image_map_tool_options_notify (GimpTool *tool,
gimp_tool_control_pop_preserve (tool->control); gimp_tool_control_pop_preserve (tool->control);
} }
} }
else if (! strcmp (pspec->name, "region") &&
image_map_tool->image_map)
{
gimp_tool_control_push_preserve (tool->control, TRUE);
gimp_image_map_tool_create_map (image_map_tool);
gimp_image_map_tool_preview (image_map_tool);
gimp_tool_control_pop_preserve (tool->control);
}
} }
static gboolean static gboolean
...@@ -698,9 +715,8 @@ gimp_image_map_tool_reset (GimpImageMapTool *tool) ...@@ -698,9 +715,8 @@ gimp_image_map_tool_reset (GimpImageMapTool *tool)
static void static void
gimp_image_map_tool_create_map (GimpImageMapTool *tool) gimp_image_map_tool_create_map (GimpImageMapTool *tool)
{ {
GimpToolInfo *tool_info; GimpImageMapOptions *options = GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (tool);
GimpToolInfo *tool_info = GIMP_TOOL (tool)->tool_info;
g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (tool));
if (tool->image_map) if (tool->image_map)
{ {
...@@ -710,13 +726,13 @@ gimp_image_map_tool_create_map (GimpImageMapTool *tool) ...@@ -710,13 +726,13 @@ gimp_image_map_tool_create_map (GimpImageMapTool *tool)
g_assert (tool->operation); g_assert (tool->operation);
tool_info = GIMP_TOOL (tool)->tool_info;
tool->image_map = gimp_image_map_new (tool->drawable, tool->image_map = gimp_image_map_new (tool->drawable,
tool->undo_desc, tool->undo_desc,
tool->operation, tool->operation,
gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info))); gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info)));
gimp_image_map_set_region (tool->image_map, options->region);
g_signal_connect (tool->image_map, "flush", g_signal_connect (tool->image_map, "flush",
G_CALLBACK (gimp_image_map_tool_flush), G_CALLBACK (gimp_image_map_tool_flush),
tool); tool);
......
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