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)
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 */
......@@ -543,6 +543,17 @@ typedef enum /*< pdb-skip >*/
} 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
*/
......
......@@ -22,13 +22,6 @@
#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_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))
......
......@@ -31,6 +31,7 @@ enum
{
PROP_0,
PROP_PREVIEW,
PROP_REGION,
PROP_SETTINGS
};
......@@ -65,6 +66,15 @@ gimp_image_map_options_class_init (GimpImageMapOptionsClass *klass)
"preview", NULL,
TRUE,
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_param_spec_string ("settings",
NULL, NULL,
......@@ -105,10 +115,16 @@ gimp_image_map_options_set_property (GObject *object,
case PROP_PREVIEW:
options->preview = g_value_get_boolean (value);
break;
case PROP_REGION:
options->region = g_value_get_enum (value);
break;
case PROP_SETTINGS:
g_free (options->settings);
options->settings = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -128,9 +144,15 @@ gimp_image_map_options_get_property (GObject *object,
case PROP_PREVIEW:
g_value_set_boolean (value, options->preview);
break;
case PROP_REGION:
g_value_set_enum (value, options->region);
break;
case PROP_SETTINGS:
g_value_set_string (value, options->settings);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......
......@@ -34,10 +34,11 @@ typedef struct _GimpToolOptionsClass GimpImageMapOptionsClass;
struct _GimpImageMapOptions
{
GimpToolOptions parent_instance;
GimpToolOptions parent_instance;
gboolean preview;
gchar *settings;
gboolean preview;
GimpImageMapRegion region;
gchar *settings;
};
......
......@@ -341,6 +341,7 @@ gimp_image_map_tool_initialize (GimpTool *tool,
{
GimpImageMapToolClass *klass;
GtkWidget *vbox;
GtkWidget *combo;
GtkWidget *toggle;
klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);
......@@ -403,7 +404,7 @@ gimp_image_map_tool_initialize (GimpTool *tool,
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)");
gtk_box_pack_end (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
gtk_widget_show (toggle);
......@@ -416,10 +417,16 @@ gimp_image_map_tool_initialize (GimpTool *tool,
toggle = gimp_prop_check_button_new (G_OBJECT (tool_info->tool_options),
"preview",
_("_Preview"));
gtk_box_pack_end (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
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 */
gimp_image_map_tool_dialog (image_map_tool);
}
......@@ -527,6 +534,16 @@ gimp_image_map_tool_options_notify (GimpTool *tool,
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
......@@ -698,9 +715,8 @@ gimp_image_map_tool_reset (GimpImageMapTool *tool)
static void
gimp_image_map_tool_create_map (GimpImageMapTool *tool)
{
GimpToolInfo *tool_info;
g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (tool));
GimpImageMapOptions *options = GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (tool);
GimpToolInfo *tool_info = GIMP_TOOL (tool)->tool_info;
if (tool->image_map)
{
......@@ -710,13 +726,13 @@ gimp_image_map_tool_create_map (GimpImageMapTool *tool)
g_assert (tool->operation);
tool_info = GIMP_TOOL (tool)->tool_info;
tool->image_map = gimp_image_map_new (tool->drawable,
tool->undo_desc,
tool->operation,
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_CALLBACK (gimp_image_map_tool_flush),
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