mirror of https://github.com/GNOME/gimp.git
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.
This commit is contained in:
parent
ecfa0abca3
commit
a96c273621
|
@ -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);
|
||||
|
|
|
@ -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")));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue