[gimp] app: add smarter soft boundaries for GimpSpinScale widgets
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add smarter soft boundaries for GimpSpinScale widgets
- Date: Wed, 6 Jul 2016 10:28:11 +0000 (UTC)
commit a96c27362146bc8bbb8b09907d8f71ac429a5187
Author: Michael Natterer <mitch gimp org>
Date: Wed Jul 6 12:19:40 2016 +0200
app: add smarter soft boundaries for GimpSpinScale widgets
Pass a GeglRectangle to all gimp_prop_gui_*() functions, and set
the soft limits to the rectangle's extents if the GParamSpec
metadata's "unit" is "pixel-coordinate" or "pixel-distance".
In GimpSymmetryEditor, pass the image extents, in GimpOperationTool
pass the drawable extents.
app/tools/gimpoperationtool.c | 14 ++++++
app/widgets/gimppropgui-constructors.c | 73 ++++++++++++++++----------------
app/widgets/gimppropgui-constructors.h | 5 ++
app/widgets/gimppropgui.c | 32 +++++++++++++-
app/widgets/gimppropgui.h | 3 +
app/widgets/gimpsymmetryeditor.c | 7 +++-
6 files changed, 96 insertions(+), 38 deletions(-)
---
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index 7f5b268..a48df9c 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -736,9 +736,23 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
if (filter_tool->config)
{
+ GeglRectangle *area = NULL;
+ GeglRectangle tmp = { 0, };
+
+ if (GIMP_TOOL (tool)->drawable)
+ {
+ GimpDrawable *drawable = GIMP_TOOL (tool)->drawable;
+
+ tmp.width = gimp_item_get_width (GIMP_ITEM (drawable));
+ tmp.height = gimp_item_get_height (GIMP_ITEM (drawable));
+
+ area = &tmp;
+ }
+
tool->options_gui =
gimp_prop_gui_new (G_OBJECT (filter_tool->config),
G_TYPE_FROM_INSTANCE (filter_tool->config), 0,
+ area,
GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool)),
(GimpCreatePickerFunc) gimp_filter_tool_add_color_picker,
tool);
diff --git a/app/widgets/gimppropgui-constructors.c b/app/widgets/gimppropgui-constructors.c
index ee6afe0..63915e8 100644
--- a/app/widgets/gimppropgui-constructors.c
+++ b/app/widgets/gimppropgui-constructors.c
@@ -59,6 +59,7 @@ GtkWidget *
_gimp_prop_gui_new_generic (GObject *config,
GParamSpec **param_specs,
guint n_param_specs,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker_func,
gpointer picker_creator)
@@ -100,11 +101,13 @@ _gimp_prop_gui_new_generic (GObject *config,
i++;
- widget_x = gimp_prop_widget_new_from_pspec (config, pspec, context,
+ widget_x = gimp_prop_widget_new_from_pspec (config, pspec,
+ area, context,
create_picker_func,
picker_creator,
&label_x);
- widget_y = gimp_prop_widget_new_from_pspec (config, next_pspec, context,
+ widget_y = gimp_prop_widget_new_from_pspec (config, next_pspec,
+ area, context,
create_picker_func,
picker_creator,
&label_y);
@@ -179,7 +182,8 @@ _gimp_prop_gui_new_generic (GObject *config,
const gchar *label;
gboolean expand = FALSE;
- widget = gimp_prop_widget_new_from_pspec (config, pspec, context,
+ widget = gimp_prop_widget_new_from_pspec (config, pspec,
+ area, context,
create_picker_func,
picker_creator,
&label);
@@ -393,6 +397,7 @@ GtkWidget *
_gimp_prop_gui_new_color_rotate (GObject *config,
GParamSpec **param_specs,
guint n_param_specs,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker_func,
gpointer picker_creator)
@@ -441,9 +446,8 @@ _gimp_prop_gui_new_color_rotate (GObject *config,
box = _gimp_prop_gui_new_generic (config,
param_specs + 6, 2,
- context,
- create_picker_func,
- picker_creator);
+ area, context,
+ create_picker_func, picker_creator);
gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, FALSE, 0);
gtk_widget_show (box);
@@ -460,6 +464,7 @@ GtkWidget *
_gimp_prop_gui_new_convolution_matrix (GObject *config,
GParamSpec **param_specs,
guint n_param_specs,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker_func,
gpointer picker_creator)
@@ -512,12 +517,12 @@ _gimp_prop_gui_new_convolution_matrix (GObject *config,
gtk_widget_show (hbox);
scale = gimp_prop_widget_new (config, "divisor",
- context, NULL, NULL, &label);
+ area, context, NULL, NULL, &label);
gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0);
gtk_widget_show (scale);
scale = gimp_prop_widget_new (config, "offset",
- context, NULL, NULL, &label);
+ area, context, NULL, NULL, &label);
gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0);
gtk_widget_show (scale);
@@ -528,18 +533,16 @@ _gimp_prop_gui_new_convolution_matrix (GObject *config,
vbox = _gimp_prop_gui_new_generic (config,
param_specs + 27, 4,
- context,
- create_picker_func,
- picker_creator);
+ area, context,
+ create_picker_func, picker_creator);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
vbox = _gimp_prop_gui_new_generic (config,
param_specs + 31,
n_param_specs - 31,
- context,
- create_picker_func,
- picker_creator);
+ area, context,
+ create_picker_func, picker_creator);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
@@ -550,6 +553,7 @@ GtkWidget *
_gimp_prop_gui_new_channel_mixer (GObject *config,
GParamSpec **param_specs,
guint n_param_specs,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker_func,
gpointer picker_creator)
@@ -578,17 +582,17 @@ _gimp_prop_gui_new_channel_mixer (GObject *config,
gtk_widget_show (vbox);
scale = gimp_prop_widget_new (config, "rr-gain",
- context, NULL, NULL, &label);
+ area, context, NULL, NULL, &label);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
scale = gimp_prop_widget_new (config, "rg-gain",
- context, NULL, NULL, &label);
+ area, context, NULL, NULL, &label);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
scale = gimp_prop_widget_new (config, "rb-gain",
- context, NULL, NULL, &label);
+ area, context, NULL, NULL, &label);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
@@ -602,17 +606,17 @@ _gimp_prop_gui_new_channel_mixer (GObject *config,
gtk_widget_show (vbox);
scale = gimp_prop_widget_new (config, "gr-gain",
- context, NULL, NULL, &label);
+ area, context, NULL, NULL, &label);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
scale = gimp_prop_widget_new (config, "gg-gain",
- context, NULL, NULL, &label);
+ area, context, NULL, NULL, &label);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
scale = gimp_prop_widget_new (config, "gb-gain",
- context, NULL, NULL, &label);
+ area, context, NULL, NULL, &label);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
@@ -626,23 +630,23 @@ _gimp_prop_gui_new_channel_mixer (GObject *config,
gtk_widget_show (vbox);
scale = gimp_prop_widget_new (config, "br-gain",
- context, NULL, NULL, &label);
+ area, context, NULL, NULL, &label);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
scale = gimp_prop_widget_new (config, "bg-gain",
- context, NULL, NULL, &label);
+ area, context, NULL, NULL, &label);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
scale = gimp_prop_widget_new (config, "bb-gain",
- context, NULL, NULL, &label);
+ area, context, NULL, NULL, &label);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
checkbox = gimp_prop_widget_new (config, "preserve-luminosity",
- context, NULL, NULL, &label);
+ area, context, NULL, NULL, &label);
gtk_box_pack_start (GTK_BOX (main_vbox), checkbox, FALSE, FALSE, 0);
gtk_widget_show (checkbox);
@@ -654,6 +658,7 @@ GtkWidget *
_gimp_prop_gui_new_diffraction_patterns (GObject *config,
GParamSpec **param_specs,
guint n_param_specs,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker_func,
gpointer picker_creator)
@@ -670,9 +675,8 @@ _gimp_prop_gui_new_diffraction_patterns (GObject *config,
vbox = _gimp_prop_gui_new_generic (config,
param_specs + 0, 3,
- context,
- create_picker_func,
- picker_creator);
+ area, context,
+ create_picker_func, picker_creator);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox,
gtk_label_new (_("Frequencies")));
@@ -680,9 +684,8 @@ _gimp_prop_gui_new_diffraction_patterns (GObject *config,
vbox = _gimp_prop_gui_new_generic (config,
param_specs + 3, 3,
- context,
- create_picker_func,
- picker_creator);
+ area, context,
+ create_picker_func, picker_creator);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox,
gtk_label_new (_("Contours")));
@@ -690,9 +693,8 @@ _gimp_prop_gui_new_diffraction_patterns (GObject *config,
vbox = _gimp_prop_gui_new_generic (config,
param_specs + 6, 3,
- context,
- create_picker_func,
- picker_creator);
+ area, context,
+ create_picker_func, picker_creator);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox,
gtk_label_new (_("Sharp Edges")));
@@ -700,9 +702,8 @@ _gimp_prop_gui_new_diffraction_patterns (GObject *config,
vbox = _gimp_prop_gui_new_generic (config,
param_specs + 9, 3,
- context,
- create_picker_func,
- picker_creator);
+ area, context,
+ create_picker_func, picker_creator);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox,
gtk_label_new (_("Other Options")));
diff --git a/app/widgets/gimppropgui-constructors.h b/app/widgets/gimppropgui-constructors.h
index eec7079..d96ac36 100644
--- a/app/widgets/gimppropgui-constructors.h
+++ b/app/widgets/gimppropgui-constructors.h
@@ -26,6 +26,7 @@
GtkWidget * _gimp_prop_gui_new_generic (GObject *config,
GParamSpec **param_specs,
guint n_param_specs,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker_func,
gpointer picker_creator);
@@ -34,6 +35,7 @@ GtkWidget * _gimp_prop_gui_new_color_rotate
(GObject *config,
GParamSpec **param_specs,
guint n_param_specs,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker_func,
gpointer picker_creator);
@@ -42,6 +44,7 @@ GtkWidget * _gimp_prop_gui_new_convolution_matrix
(GObject *config,
GParamSpec **param_specs,
guint n_param_specs,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker_func,
gpointer picker_creator);
@@ -50,6 +53,7 @@ GtkWidget * _gimp_prop_gui_new_channel_mixer
(GObject *config,
GParamSpec **param_specs,
guint n_param_specs,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker_func,
gpointer picker_creator);
@@ -58,6 +62,7 @@ GtkWidget * _gimp_prop_gui_new_diffraction_patterns
(GObject *config,
GParamSpec **param_specs,
guint n_param_specs,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker_func,
gpointer picker_creator);
diff --git a/app/widgets/gimppropgui.c b/app/widgets/gimppropgui.c
index 116b4ea..99a3e5f 100644
--- a/app/widgets/gimppropgui.c
+++ b/app/widgets/gimppropgui.c
@@ -67,6 +67,7 @@ static gboolean gimp_prop_string_to_boolean (GBinding *binding,
GtkWidget *
gimp_prop_widget_new (GObject *config,
const gchar *property_name,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker_func,
gpointer picker_creator,
@@ -79,7 +80,7 @@ gimp_prop_widget_new (GObject *config,
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (config),
property_name);
- return gimp_prop_widget_new_from_pspec (config, pspec, context,
+ return gimp_prop_widget_new_from_pspec (config, pspec, area, context,
create_picker_func, picker_creator,
label);
}
@@ -87,6 +88,7 @@ gimp_prop_widget_new (GObject *config,
GtkWidget *
gimp_prop_widget_new_from_pspec (GObject *config,
GParamSpec *pspec,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker_func,
gpointer picker_creator,
@@ -229,6 +231,31 @@ gimp_prop_widget_new_from_pspec (GObject *config,
widget = hbox;
}
+ else if (area)
+ {
+ if (HAS_KEY (pspec, "unit", "pixel-coordinate") ||
+ HAS_KEY (pspec, "unit", "pixel-distance"))
+ {
+ if (HAS_KEY (pspec, "axis", "x"))
+ {
+ g_printerr ("XXX setting widht %d on %s\n",
+ area->width, pspec->name);
+
+ gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (widget),
+ area->x,
+ area->x + area->width);
+ }
+ else if (HAS_KEY (pspec, "axis","y"))
+ {
+ g_printerr ("XXX setting height %d on %s\n",
+ area->height, pspec->name);
+
+ gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (widget),
+ area->y,
+ area->y + area->height);
+ }
+ }
+ }
}
else if (G_IS_PARAM_SPEC_STRING (pspec))
{
@@ -336,6 +363,7 @@ gimp_prop_widget_new_from_pspec (GObject *config,
typedef GtkWidget * (* GimpPropGuiNewFunc) (GObject *config,
GParamSpec **param_specs,
guint n_param_specs,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker_func,
gpointer picker_creator);
@@ -365,6 +393,7 @@ GtkWidget *
gimp_prop_gui_new (GObject *config,
GType owner_type,
GParamFlags flags,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker_func,
gpointer picker_creator)
@@ -415,6 +444,7 @@ gimp_prop_gui_new (GObject *config,
gui = gui_new_funcs[i].gui_new_func (config,
param_specs, n_param_specs,
+ area,
context,
create_picker_func,
picker_creator);
diff --git a/app/widgets/gimppropgui.h b/app/widgets/gimppropgui.h
index cac588d..7aebeac 100644
--- a/app/widgets/gimppropgui.h
+++ b/app/widgets/gimppropgui.h
@@ -31,12 +31,14 @@ typedef GtkWidget * (* GimpCreatePickerFunc) (gpointer creator,
GtkWidget * gimp_prop_widget_new (GObject *config,
const gchar *property_name,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker,
gpointer picker_creator,
const gchar **label);
GtkWidget * gimp_prop_widget_new_from_pspec (GObject *config,
GParamSpec *pspec,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker,
gpointer picker_creator,
@@ -44,6 +46,7 @@ GtkWidget * gimp_prop_widget_new_from_pspec (GObject *config,
GtkWidget * gimp_prop_gui_new (GObject *config,
GType owner_type,
GParamFlags flags,
+ GeglRectangle *area,
GimpContext *context,
GimpCreatePickerFunc create_picker,
gpointer picker_creator);
diff --git a/app/widgets/gimpsymmetryeditor.c b/app/widgets/gimpsymmetryeditor.c
index 829d29d..6c7f5c1 100644
--- a/app/widgets/gimpsymmetryeditor.c
+++ b/app/widgets/gimpsymmetryeditor.c
@@ -238,11 +238,16 @@ gimp_symmetry_editor_set_options (GimpSymmetryEditor *editor,
if (symmetry && G_TYPE_FROM_INSTANCE (symmetry) != GIMP_TYPE_SYMMETRY)
{
- GtkWidget *gui;
+ GimpImageEditor *image_editor = GIMP_IMAGE_EDITOR (editor);
+ GimpImage *image = image_editor->image;
+ GtkWidget *gui;
gui = gimp_prop_gui_new (G_OBJECT (symmetry),
GIMP_TYPE_SYMMETRY,
GIMP_SYMMETRY_PARAM_GUI,
+ GEGL_RECTANGLE (0, 0,
+ gimp_image_get_width (image),
+ gimp_image_get_height (image)),
GIMP_IMAGE_EDITOR (editor)->context,
NULL, NULL);
gtk_box_pack_start (GTK_BOX (editor->p->options_vbox), gui,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]