[gimp] app: add support for picking GEGL relative-coordinate values
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add support for picking GEGL relative-coordinate values
- Date: Fri, 23 May 2014 23:41:11 +0000 (UTC)
commit 3550132ac79d4b98468ee26619610502c4856222
Author: Michael Natterer <mitch gimp org>
Date: Sat May 24 01:38:15 2014 +0200
app: add support for picking GEGL relative-coordinate values
Also, don't link relative coordinates by default, and remove some crap
heuristics that predate property keys.
app/tools/gimpoperationtool.c | 70 ++++++++++++++++++-----------------------
app/widgets/gimpproptable.c | 6 ++-
2 files changed, 35 insertions(+), 41 deletions(-)
---
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index d531b90..040eaba 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -370,16 +370,14 @@ gimp_operation_tool_color_picked (GimpImageMapTool *im_tool,
if (pspecs[1])
{
- GimpDrawable *drawable = GIMP_TOOL (im_tool)->drawable;
- GObjectClass *object_class = G_OBJECT_GET_CLASS (tool->config);
- GParamSpec *pspec_x;
- GParamSpec *pspec_y;
- gint width = 1;
- gint height = 1;
-
- /* the operation's coordinate system is the selection bounds of
- * the drawable
- */
+ GimpImageMapOptions *options = GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (tool);
+ GimpDrawable *drawable = GIMP_TOOL (im_tool)->drawable;
+ GObjectClass *object_class = G_OBJECT_GET_CLASS (tool->config);
+ GParamSpec *pspec_x;
+ GParamSpec *pspec_y;
+ gint width = 1;
+ gint height = 1;
+
if (drawable)
{
gint off_x, off_y;
@@ -389,11 +387,21 @@ gimp_operation_tool_color_picked (GimpImageMapTool *im_tool,
x -= off_x;
y -= off_y;
- if (gimp_item_mask_intersect (GIMP_ITEM (drawable),
- &off_x, &off_y, &width, &height))
+ switch (options->region)
{
- x -= off_x;
- y -= off_y;
+ case GIMP_IMAGE_MAP_REGION_SELECTION:
+ if (gimp_item_mask_intersect (GIMP_ITEM (drawable),
+ &off_x, &off_y, &width, &height))
+ {
+ x -= off_x;
+ y -= off_y;
+ }
+ break;
+
+ case GIMP_IMAGE_MAP_REGION_DRAWABLE:
+ width = gimp_item_get_width (GIMP_ITEM (drawable));
+ height = gimp_item_get_height (GIMP_ITEM (drawable));
+ break;
}
}
@@ -409,6 +417,15 @@ gimp_operation_tool_color_picked (GimpImageMapTool *im_tool,
g_value_init (&value_x, G_PARAM_SPEC_VALUE_TYPE (pspec_x));
g_value_init (&value_y, G_PARAM_SPEC_VALUE_TYPE (pspec_y));
+#define HAS_KEY(p,k,v) gimp_gegl_param_spec_has_key (p, k, v)
+
+ if (HAS_KEY (pspec_x, "unit", "relative-coordinate") &&
+ HAS_KEY (pspec_y, "unit", "relative-coordinate"))
+ {
+ x /= (gdouble) width;
+ y /= (gdouble) height;
+ }
+
if (G_IS_PARAM_SPEC_INT (pspec_x))
{
g_value_set_int (&value_x, x);
@@ -424,31 +441,6 @@ gimp_operation_tool_color_picked (GimpImageMapTool *im_tool,
}
else if (G_IS_PARAM_SPEC_DOUBLE (pspec_x))
{
- GParamSpecDouble *dspec_x = G_PARAM_SPEC_DOUBLE (pspec_x);
- GParamSpecDouble *dspec_y = G_PARAM_SPEC_DOUBLE (pspec_y);
-
- /* handle what certain well known ops use as extent,
- * this is by no measure proper code...
- */
- if (dspec_x->minimum == 0.0 && dspec_x->maximum == 1.0 &&
- dspec_y->minimum == 0.0 && dspec_y->maximum == 1.0)
- {
- x /= width;
- y /= height;
- }
- else if (dspec_x->minimum == -1.0 && dspec_x->maximum == 2.0 &&
- dspec_y->minimum == -1.0 && dspec_y->maximum == 2.0)
- {
- x /= width;
- y /= height;
- }
- else if (dspec_x->minimum == -1.0 && dspec_x->maximum == 1.0 &&
- dspec_y->minimum == -1.0 && dspec_y->maximum == 1.0)
- {
- x = x * 2.0 / width - 1.0;
- y = y * 2.0 / height - 1.0;
- }
-
g_value_set_double (&value_x, x);
g_value_set_double (&value_y, y);
diff --git a/app/widgets/gimpproptable.c b/app/widgets/gimpproptable.c
index f524415..28d8a96 100644
--- a/app/widgets/gimpproptable.c
+++ b/app/widgets/gimpproptable.c
@@ -306,7 +306,8 @@ gimp_prop_table_new (GObject *config,
0, 0);
gtk_widget_show (chain);
- if (! HAS_KEY (pspec, "unit", "pixel-coordinate") &&
+ if (! HAS_KEY (pspec, "unit", "pixel-coordinate") &&
+ ! HAS_KEY (pspec, "unit", "relative-coordinate") &&
gtk_adjustment_get_value (last_x_adj) ==
gtk_adjustment_get_value (adj))
{
@@ -328,7 +329,8 @@ gimp_prop_table_new (GObject *config,
g_object_set_data (G_OBJECT (last_x_adj), "y-adjustment", adj);
if (create_picker_func &&
- HAS_KEY (pspec, "unit", "pixel-coordinate"))
+ (HAS_KEY (pspec, "unit", "pixel-coordinate") ||
+ HAS_KEY (pspec, "unit", "relative-coordinate")))
{
GtkWidget *button;
gchar *pspec_name;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]