app/core/core-enums.h app/core/gimpgradient.[ch] app/pdb/Makefile.am

2004-05-31  Michael Natterer  <mitch@gimp.org>

	* app/core/core-enums.h
	* app/core/gimpgradient.[ch]
	* app/pdb/Makefile.am
	* app/widgets/gimpgradienteditor.c
	* tools/pdbgen/Makefile.am
	* tools/pdbgen/groups.pl
	* tools/pdbgen/pdb/gradient_edit.pdb: applied a patch from Shlomi
	Fish that adds lots of gradient edit functions to
	gimpgradient.[ch] and makes them available through the PDB.
	Fixes bug #129675 and bug #129678.

	Did some cleanups / enhancments to the patch:

	* app/core/gimpgradient.[ch]: changed the naming scheme of the new
	functions and changed old functions to match the new scheme.
	Introduce a "freeze_count" and public freeze()/thaw() API which
	enables subsequent gradient changes without "dirty" being emitted
	all the time.  Added GimpGradient parameters to all functions
	which modify the gradient.

	* app/widgets/gimpgradienteditor.c: use the new freeze/thaw
	stuff to keep the gradient from updating when not in
	"Instant Update" mode.

	* app/actions/gradient-editor-commands.c: removed all gradient
	editing code and call the new core functions.

	* libgimp/Makefile.am
	* tools/pdbgen/pdb/gradient_edit.pdb: changed the namespace of all
	added functions. Generate libgimp wrappers for them..

	* app/pdb/gradient_edit_cmds.c
	* app/pdb/internal_procs.c
	* libgimp/gimp_pdb.h
	* libgimp/gimpenums.h
	* libgimp/gimpgradientedit_pdb.[ch]
	* plug-ins/pygimp/gimpenums.py
	* plug-ins/script-fu/script-fu-constants.c
	* tools/pdbgen/enums.pl: (re)generated.
This commit is contained in:
Michael Natterer
2004-05-30 22:04:16 +00:00
committed by Michael Natterer
parent 2626b09043
commit 421024cc5c
21 changed files with 6729 additions and 782 deletions

View File

@ -1,3 +1,45 @@
2004-05-31 Michael Natterer <mitch@gimp.org>
* app/core/core-enums.h
* app/core/gimpgradient.[ch]
* app/pdb/Makefile.am
* app/widgets/gimpgradienteditor.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/groups.pl
* tools/pdbgen/pdb/gradient_edit.pdb: applied a patch from Shlomi
Fish that adds lots of gradient edit functions to
gimpgradient.[ch] and makes them available through the PDB.
Fixes bug #129675 and bug #129678.
Did some cleanups / enhancments to the patch:
* app/core/gimpgradient.[ch]: changed the naming scheme of the new
functions and changed old functions to match the new scheme.
Introduce a "freeze_count" and public freeze()/thaw() API which
enables subsequent gradient changes without "dirty" being emitted
all the time. Added GimpGradient parameters to all functions
which modify the gradient.
* app/widgets/gimpgradienteditor.c: use the new freeze/thaw
stuff to keep the gradient from updating when not in
"Instant Update" mode.
* app/actions/gradient-editor-commands.c: removed all gradient
editing code and call the new core functions.
* libgimp/Makefile.am
* tools/pdbgen/pdb/gradient_edit.pdb: changed the namespace of all
added functions. Generate libgimp wrappers for them..
* app/pdb/gradient_edit_cmds.c
* app/pdb/internal_procs.c
* libgimp/gimp_pdb.h
* libgimp/gimpenums.h
* libgimp/gimpgradientedit_pdb.[ch]
* plug-ins/pygimp/gimpenums.py
* plug-ins/script-fu/script-fu-constants.c
* tools/pdbgen/enums.pl: (re)generated.
2004-05-29 Sven Neumann <sven@gimp.org>
* plug-ins/common/autocrop.c: applied patch from Philip Lafleur

View File

@ -71,11 +71,9 @@ void
gradient_editor_left_color_cmd_callback (GtkAction *action,
gpointer data)
{
GimpGradientEditor *editor;
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
editor = GIMP_GRADIENT_EDITOR (data);
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
editor->left_saved_dirty = GIMP_DATA (gradient)->dirty;
@ -103,13 +101,14 @@ gradient_editor_load_left_cmd_callback (GtkAction *action,
{
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
GimpContext *user_context;
GimpContext *context;
GimpGradientSegment *seg;
GimpRGB color;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
context =
gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
switch (value)
{
@ -119,51 +118,32 @@ gradient_editor_load_left_cmd_callback (GtkAction *action,
else
seg = gimp_gradient_segment_get_last (editor->control_sel_l);
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
&seg->right_color,
&editor->control_sel_r->right_color,
TRUE, TRUE);
color = seg->right_color;
break;
case 1: /* Fetch from right endpoint */
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_r->right_color,
&editor->control_sel_r->right_color,
TRUE, TRUE);
color = editor->control_sel_r->right_color;
break;
case 2: /* Fetch from FG color */
gimp_context_get_foreground (user_context, &color);
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
&color,
&editor->control_sel_r->right_color,
TRUE, TRUE);
gimp_context_get_foreground (context, &color);
break;
case 3: /* Fetch from BG color */
gimp_context_get_background (user_context, &color);
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
&color,
&editor->control_sel_r->right_color,
TRUE, TRUE);
gimp_context_get_background (context, &color);
break;
default: /* Load a color */
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
&editor->saved_colors[value - 4],
&editor->control_sel_r->right_color,
TRUE, TRUE);
color = editor->saved_colors[value - 4];
break;
}
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_segment_range_blend (gradient,
editor->control_sel_l,
editor->control_sel_r,
&color,
&editor->control_sel_r->right_color,
TRUE, TRUE);
}
void
@ -172,8 +152,12 @@ gradient_editor_save_left_cmd_callback (GtkAction *action,
gpointer data)
{
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
editor->saved_colors[value] = editor->control_sel_l->left_color;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
gimp_gradient_segment_get_left_color (gradient, editor->control_sel_l,
&editor->saved_colors[value]);
}
void
@ -210,13 +194,14 @@ gradient_editor_load_right_cmd_callback (GtkAction *action,
{
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
GimpContext *user_context;
GimpContext *context;
GimpGradientSegment *seg;
GimpRGB color;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
context =
gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
switch (value)
{
@ -226,51 +211,32 @@ gradient_editor_load_right_cmd_callback (GtkAction *action,
else
seg = gimp_gradient_segment_get_first (editor->control_sel_r);
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_r->left_color,
&seg->left_color,
TRUE, TRUE);
color = seg->left_color;
break;
case 1: /* Fetch from left endpoint */
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_l->left_color,
&editor->control_sel_l->left_color,
TRUE, TRUE);
color = editor->control_sel_l->left_color;
break;
case 2: /* Fetch from FG color */
gimp_context_get_foreground (user_context, &color);
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_l->left_color,
&color,
TRUE, TRUE);
gimp_context_get_foreground (context, &color);
break;
case 3: /* Fetch from BG color */
gimp_context_get_background (user_context, &color);
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_l->left_color,
&color,
TRUE, TRUE);
gimp_context_get_background (context, &color);
break;
default: /* Load a color */
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_l->left_color,
&editor->saved_colors[value - 4],
TRUE, TRUE);
color = editor->saved_colors[value - 4];
break;
}
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_segment_range_blend (gradient,
editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_l->left_color,
&color,
TRUE, TRUE);
}
void
@ -279,8 +245,12 @@ gradient_editor_save_right_cmd_callback (GtkAction *action,
gpointer data)
{
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
editor->saved_colors[value] = editor->control_sel_l->left_color;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
gimp_gradient_segment_get_right_color (gradient, editor->control_sel_r,
&editor->saved_colors[value]);
}
void
@ -291,25 +261,16 @@ gradient_editor_blending_func_cmd_callback (GtkAction *action,
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
GimpGradientSegmentType type;
GimpGradientSegment *seg, *aseg;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
type = (GimpGradientSegmentType)
gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
seg = editor->control_sel_l;
do
{
seg->type = type;
aseg = seg;
seg = seg->next;
}
while (aseg != editor->control_sel_r);
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_segment_range_set_blending_function (gradient,
editor->control_sel_l,
editor->control_sel_r,
type);
}
void
@ -320,25 +281,16 @@ gradient_editor_coloring_type_cmd_callback (GtkAction *action,
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
GimpGradientSegmentColor color;
GimpGradientSegment *seg, *aseg;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
color = (GimpGradientSegmentColor)
gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
seg = editor->control_sel_l;
do
{
seg->color = color;
aseg = seg;
seg = seg->next;
}
while (aseg != editor->control_sel_r);
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_segment_range_set_coloring_type (gradient,
editor->control_sel_l,
editor->control_sel_r,
color);
}
void
@ -347,122 +299,14 @@ gradient_editor_flip_cmd_callback (GtkAction *action,
{
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
GimpGradientSegment *oseg, *oaseg;
GimpGradientSegment *seg, *prev, *tmp;
GimpGradientSegment *lseg, *rseg;
gdouble left, right;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
left = editor->control_sel_l->left;
right = editor->control_sel_r->right;
/* Build flipped segments */
prev = NULL;
oseg = editor->control_sel_r;
tmp = NULL;
do
{
seg = gimp_gradient_segment_new ();
if (prev == NULL)
{
seg->left = left;
tmp = seg; /* Remember first segment */
}
else
seg->left = left + right - oseg->right;
seg->middle = left + right - oseg->middle;
seg->right = left + right - oseg->left;
seg->left_color = oseg->right_color;
seg->right_color = oseg->left_color;
switch (oseg->type)
{
case GIMP_GRAD_SPHERE_INCREASING:
seg->type = GIMP_GRAD_SPHERE_DECREASING;
break;
case GIMP_GRAD_SPHERE_DECREASING:
seg->type = GIMP_GRAD_SPHERE_INCREASING;
break;
default:
seg->type = oseg->type;
}
switch (oseg->color)
{
case GIMP_GRAD_HSV_CCW:
seg->color = GIMP_GRAD_HSV_CW;
break;
case GIMP_GRAD_HSV_CW:
seg->color = GIMP_GRAD_HSV_CCW;
break;
default:
seg->color = oseg->color;
}
seg->prev = prev;
seg->next = NULL;
if (prev)
prev->next = seg;
prev = seg;
oaseg = oseg;
oseg = oseg->prev; /* Move backwards! */
}
while (oaseg != editor->control_sel_l);
seg->right = right; /* Squish accumulative error */
/* Free old segments */
lseg = editor->control_sel_l->prev;
rseg = editor->control_sel_r->next;
oseg = editor->control_sel_l;
do
{
oaseg = oseg->next;
gimp_gradient_segment_free (oseg);
oseg = oaseg;
}
while (oaseg != rseg);
/* Link in new segments */
if (lseg)
lseg->next = tmp;
else
gradient->segments = tmp;
tmp->prev = lseg;
seg->next = rseg;
if (rseg)
rseg->prev = seg;
/* Reset selection */
editor->control_sel_l = tmp;
editor->control_sel_r = seg;
/* Done */
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor);
gimp_gradient_segment_range_flip (gradient,
editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_l,
&editor->control_sel_r);
}
void
@ -544,25 +388,16 @@ void
gradient_editor_split_midpoint_cmd_callback (GtkAction *action,
gpointer data)
{
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
GimpGradientSegment *seg, *lseg, *rseg;
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
seg = editor->control_sel_l;
do
{
gimp_gradient_segment_split_midpoint (gradient, seg, &lseg, &rseg);
seg = rseg->next;
}
while (lseg != editor->control_sel_r);
editor->control_sel_r = rseg;
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor);
gimp_gradient_segment_range_split_midpoint (gradient,
editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_l,
&editor->control_sel_r);
}
void
@ -646,165 +481,44 @@ void
gradient_editor_delete_cmd_callback (GtkAction *action,
gpointer data)
{
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
GimpGradientSegment *lseg, *rseg, *seg, *aseg, *next;
gdouble join;
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
/* Remember segments to the left and to the right of the selection */
lseg = editor->control_sel_l->prev;
rseg = editor->control_sel_r->next;
/* Cannot delete all the segments in the gradient */
if ((lseg == NULL) && (rseg == NULL))
return;
/* Calculate join point */
join = (editor->control_sel_l->left +
editor->control_sel_r->right) / 2.0;
if (lseg == NULL)
join = 0.0;
else if (rseg == NULL)
join = 1.0;
/* Move segments */
if (lseg != NULL)
gimp_gradient_segments_compress_range (lseg, lseg, lseg->left, join);
if (rseg != NULL)
gimp_gradient_segments_compress_range (rseg, rseg, join, rseg->right);
/* Link */
if (lseg)
lseg->next = rseg;
if (rseg)
rseg->prev = lseg;
/* Delete old segments */
seg = editor->control_sel_l;
do
{
next = seg->next;
aseg = seg;
gimp_gradient_segment_free (seg);
seg = next;
}
while (aseg != editor->control_sel_r);
/* Change selection */
if (rseg)
{
editor->control_sel_l = rseg;
editor->control_sel_r = rseg;
}
else
{
editor->control_sel_l = lseg;
editor->control_sel_r = lseg;
}
if (lseg == NULL)
gradient->segments = rseg;
/* Done */
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor);
gimp_gradient_segment_range_delete (gradient,
editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_l,
&editor->control_sel_r);
}
void
gradient_editor_recenter_cmd_callback (GtkAction *action,
gpointer data)
{
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
GimpGradientSegment *seg, *aseg;
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
seg = editor->control_sel_l;
do
{
seg->middle = (seg->left + seg->right) / 2.0;
aseg = seg;
seg = seg->next;
}
while (aseg != editor->control_sel_r);
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor);
gimp_gradient_segment_range_recenter_handles (gradient,
editor->control_sel_l,
editor->control_sel_r);
}
void
gradient_editor_redistribute_cmd_callback (GtkAction *action,
gpointer data)
{
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
GimpGradientSegment *seg, *aseg;
gdouble left, right, seg_len;
gint num_segs;
gint i;
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
/* Count number of segments in selection */
num_segs = 0;
seg = editor->control_sel_l;
do
{
num_segs++;
aseg = seg;
seg = seg->next;
}
while (aseg != editor->control_sel_r);
/* Calculate new segment length */
left = editor->control_sel_l->left;
right = editor->control_sel_r->right;
seg_len = (right - left) / num_segs;
/* Redistribute */
seg = editor->control_sel_l;
for (i = 0; i < num_segs; i++)
{
seg->left = left + i * seg_len;
seg->right = left + (i + 1) * seg_len;
seg->middle = (seg->left + seg->right) / 2.0;
seg = seg->next;
}
/* Fix endpoints to squish accumulative error */
editor->control_sel_l->left = left;
editor->control_sel_r->right = right;
/* Done */
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor);
gimp_gradient_segment_range_redistribute_handles (gradient,
editor->control_sel_l,
editor->control_sel_r);
}
void
@ -812,14 +526,16 @@ gradient_editor_blend_color_cmd_callback (GtkAction *action,
gpointer data)
{
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_l->left_color,
&editor->control_sel_r->right_color,
TRUE, FALSE);
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
gimp_data_dirty (GIMP_DATA_EDITOR (editor)->data);
gimp_gradient_segment_range_blend (gradient,
editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_l->left_color,
&editor->control_sel_r->right_color,
TRUE, FALSE);
}
void
@ -827,14 +543,16 @@ gradient_editor_blend_opacity_cmd_callback (GtkAction *action,
gpointer data)
{
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_l->left_color,
&editor->control_sel_r->right_color,
FALSE, TRUE);
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
gimp_data_dirty (GIMP_DATA_EDITOR (editor)->data);
gimp_gradient_segment_range_blend (gradient,
editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_l->left_color,
&editor->control_sel_r->right_color,
FALSE, TRUE);
}
@ -846,32 +564,30 @@ gradient_editor_left_color_changed (ColorNotebook *cnb,
ColorNotebookState state,
gpointer data)
{
GimpGradientEditor *editor;
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
editor = (GimpGradientEditor *) data;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
switch (state)
{
case COLOR_NOTEBOOK_UPDATE:
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
(GimpRGB *) color,
&editor->control_sel_r->right_color,
TRUE, TRUE);
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_segment_range_blend (gradient,
editor->control_sel_l,
editor->control_sel_r,
color,
&editor->control_sel_r->right_color,
TRUE, TRUE);
break;
case COLOR_NOTEBOOK_OK:
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
(GimpRGB *) color,
&editor->control_sel_r->right_color,
TRUE, TRUE);
gimp_gradient_segment_range_blend (gradient,
editor->control_sel_l,
editor->control_sel_r,
color,
&editor->control_sel_r->right_color,
TRUE, TRUE);
gimp_gradient_segments_free (editor->left_saved_segments);
gimp_data_dirty (GIMP_DATA (gradient));
color_notebook_free (cnb);
editor->color_notebook = NULL;
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
@ -894,32 +610,30 @@ gradient_editor_right_color_changed (ColorNotebook *cnb,
ColorNotebookState state,
gpointer data)
{
GimpGradientEditor *editor;
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
GimpGradient *gradient;
editor = (GimpGradientEditor *) data;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
switch (state)
{
case COLOR_NOTEBOOK_UPDATE:
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_r->left_color,
(GimpRGB *) color,
TRUE, TRUE);
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_segment_range_blend (gradient,
editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_r->left_color,
color,
TRUE, TRUE);
break;
case COLOR_NOTEBOOK_OK:
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_r->left_color,
(GimpRGB *) color,
TRUE, TRUE);
gimp_gradient_segment_range_blend (gradient,
editor->control_sel_l,
editor->control_sel_r,
&editor->control_sel_r->left_color,
color,
TRUE, TRUE);
gimp_gradient_segments_free (editor->right_saved_segments);
gimp_data_dirty (GIMP_DATA (gradient));
color_notebook_free (cnb);
editor->color_notebook = NULL;
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
@ -1022,34 +736,16 @@ gradient_editor_split_uniform_response (GtkWidget *widget,
if (response_id == GTK_RESPONSE_OK)
{
GimpGradient *gradient;
GimpGradientSegment *seg, *aseg, *lseg, *rseg, *lsel;
GimpGradient *gradient;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
seg = editor->control_sel_l;
lsel = NULL;
do
{
aseg = seg;
gimp_gradient_segment_split_uniform (gradient, seg,
editor->split_parts,
&lseg, &rseg);
if (seg == editor->control_sel_l)
lsel = lseg;
seg = rseg->next;
}
while (aseg != editor->control_sel_r);
editor->control_sel_l = lsel;
editor->control_sel_r = rseg;
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor);
gimp_gradient_segment_range_split_uniform (gradient,
editor->control_sel_l,
editor->control_sel_r,
editor->split_parts,
&editor->control_sel_l,
&editor->control_sel_r);
}
}
@ -1063,114 +759,15 @@ gradient_editor_replicate_response (GtkWidget *widget,
if (response_id == GTK_RESPONSE_OK)
{
GimpGradient *gradient;
gdouble sel_left, sel_right, sel_len;
gdouble new_left;
gdouble factor;
GimpGradientSegment *prev, *seg, *tmp;
GimpGradientSegment *oseg, *oaseg;
GimpGradientSegment *lseg, *rseg;
gint i;
GimpGradient *gradient;
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
/* Remember original parameters */
sel_left = editor->control_sel_l->left;
sel_right = editor->control_sel_r->right;
sel_len = sel_right - sel_left;
factor = 1.0 / editor->replicate_times;
/* Build replicated segments */
prev = NULL;
seg = NULL;
tmp = NULL;
for (i = 0; i < editor->replicate_times; i++)
{
/* Build one cycle */
new_left = sel_left + i * factor * sel_len;
oseg = editor->control_sel_l;
do
{
seg = gimp_gradient_segment_new ();
if (prev == NULL)
{
seg->left = sel_left;
tmp = seg; /* Remember first segment */
}
else
{
seg->left = new_left + factor * (oseg->left - sel_left);
}
seg->middle = new_left + factor * (oseg->middle - sel_left);
seg->right = new_left + factor * (oseg->right - sel_left);
seg->left_color = oseg->left_color;
seg->right_color = oseg->right_color;
seg->type = oseg->type;
seg->color = oseg->color;
seg->prev = prev;
seg->next = NULL;
if (prev)
prev->next = seg;
prev = seg;
oaseg = oseg;
oseg = oseg->next;
}
while (oaseg != editor->control_sel_r);
}
seg->right = sel_right; /* Squish accumulative error */
/* Free old segments */
lseg = editor->control_sel_l->prev;
rseg = editor->control_sel_r->next;
oseg = editor->control_sel_l;
do
{
oaseg = oseg->next;
gimp_gradient_segment_free (oseg);
oseg = oaseg;
}
while (oaseg != rseg);
/* Link in new segments */
if (lseg)
lseg->next = tmp;
else
gradient->segments = tmp;
tmp->prev = lseg;
seg->next = rseg;
if (rseg)
rseg->prev = seg;
/* Reset selection */
editor->control_sel_l = tmp;
editor->control_sel_r = seg;
/* Done */
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor);
gimp_gradient_segment_range_replicate (gradient,
editor->control_sel_l,
editor->control_sel_r,
editor->replicate_times,
&editor->control_sel_l,
&editor->control_sel_r);
}
}

View File

@ -578,7 +578,7 @@ typedef enum /*< skip >*/
GIMP_CUSTOM_PALETTE
} GimpConvertPaletteType;
typedef enum /*< pdb-skip, skip >*/
typedef enum /*< skip >*/
{
GIMP_GRAD_LINEAR = 0,
GIMP_GRAD_CURVED,
@ -587,7 +587,7 @@ typedef enum /*< pdb-skip, skip >*/
GIMP_GRAD_SPHERE_DECREASING
} GimpGradientSegmentType;
typedef enum /*< pdb-skip, skip >*/
typedef enum /*< skip >*/
{
GIMP_GRAD_RGB, /* normal RGB */
GIMP_GRAD_HSV_CCW, /* counterclockwise hue */

File diff suppressed because it is too large Load Diff

View File

@ -59,6 +59,7 @@ struct _GimpGradient
/*< private >*/
GimpGradientSegment *last_visited;
gint freeze_count;
};
struct _GimpGradientClass
@ -87,35 +88,155 @@ void gimp_gradient_get_color_at (GimpGradient *gradient,
GimpGradientSegment * gimp_gradient_get_segment_at (GimpGradient *grad,
gdouble pos);
void gimp_gradient_freeze (GimpGradient *gradient);
void gimp_gradient_thaw (GimpGradient *gradient);
/* gradient segment functions */
GimpGradientSegment * gimp_gradient_segment_new (void);
GimpGradientSegment * gimp_gradient_segment_get_last (GimpGradientSegment *seg);
GimpGradientSegment * gimp_gradient_segment_get_first (GimpGradientSegment *seg);
GimpGradientSegment * gimp_gradient_segment_get_nth (GimpGradientSegment *seg,
gint index);
void gimp_gradient_segment_free (GimpGradientSegment *seg);
void gimp_gradient_segments_free (GimpGradientSegment *seg);
void gimp_gradient_segment_free (GimpGradientSegment *seg);
void gimp_gradient_segments_free (GimpGradientSegment *seg);
void gimp_gradient_segment_split_midpoint (GimpGradient *gradient,
void gimp_gradient_segment_split_midpoint (GimpGradient *gradient,
GimpGradientSegment *lseg,
GimpGradientSegment **newl,
GimpGradientSegment **newr);
void gimp_gradient_segment_split_uniform (GimpGradient *gradient,
void gimp_gradient_segment_split_uniform (GimpGradient *gradient,
GimpGradientSegment *lseg,
gint parts,
GimpGradientSegment **newl,
GimpGradientSegment **newr);
void gimp_gradient_segments_compress_range (GimpGradientSegment *range_l,
/* Colors Setting/Getting Routines */
void gimp_gradient_segment_get_left_color (GimpGradient *gradient,
GimpGradientSegment *seg,
GimpRGB *color);
void gimp_gradient_segment_set_left_color (GimpGradient *gradient,
GimpGradientSegment *seg,
const GimpRGB *color);
void gimp_gradient_segment_get_right_color (GimpGradient *gradient,
GimpGradientSegment *seg,
GimpRGB *color);
void gimp_gradient_segment_set_right_color (GimpGradient *gradient,
GimpGradientSegment *seg,
const GimpRGB *color);
/* Position Setting/Getting Routines */
/* (Setters return the position after it was set) */
gdouble gimp_gradient_segment_get_left_pos (GimpGradient *gradient,
GimpGradientSegment *seg);
gdouble gimp_gradient_segment_set_left_pos (GimpGradient *gradient,
GimpGradientSegment *seg,
gdouble pos);
gdouble gimp_gradient_segment_get_right_pos (GimpGradient *gradient,
GimpGradientSegment *seg);
gdouble gimp_gradient_segment_set_right_pos (GimpGradient *gradient,
GimpGradientSegment *seg,
gdouble pos);
gdouble gimp_gradient_segment_get_middle_pos (GimpGradient *gradient,
GimpGradientSegment *seg);
gdouble gimp_gradient_segment_set_middle_pos (GimpGradient *gradient,
GimpGradientSegment *seg,
gdouble pos);
/* Getting/Setting the Blending Function/Coloring Type */
GimpGradientSegmentType
gimp_gradient_segment_get_blending_function (GimpGradient *gradient,
GimpGradientSegment *seg);
GimpGradientSegmentColor
gimp_gradient_segment_get_coloring_type (GimpGradient *gradient,
GimpGradientSegment *seg);
/*
* If the second segment is NULL, these functions will process
* until the end of the string.
* */
void gimp_gradient_segment_range_compress (GimpGradient *gradient,
GimpGradientSegment *range_l,
GimpGradientSegment *range_r,
gdouble new_l,
gdouble new_r);
void gimp_gradient_segments_blend_endpoints (GimpGradientSegment *lseg,
void gimp_gradient_segment_range_blend (GimpGradient *gradient,
GimpGradientSegment *lseg,
GimpGradientSegment *rseg,
GimpRGB *rgb1,
GimpRGB *rgb2,
const GimpRGB *rgb1,
const GimpRGB *rgb2,
gboolean blend_colors,
gboolean blend_opacity);
void gimp_gradient_segment_range_set_blending_function
(GimpGradient *gradient,
GimpGradientSegment *start_seg,
GimpGradientSegment *end_seg,
GimpGradientSegmentType new_type);
void gimp_gradient_segment_range_set_coloring_type
(GimpGradient *gradient,
GimpGradientSegment *start_seg,
GimpGradientSegment *end_seg,
GimpGradientSegmentColor new_color);
void gimp_gradient_segment_range_flip (GimpGradient *gradient,
GimpGradientSegment *start_seg,
GimpGradientSegment *end_seg,
GimpGradientSegment **final_start_seg,
GimpGradientSegment **final_end_seg);
void gimp_gradient_segment_range_replicate (GimpGradient *gradient,
GimpGradientSegment *start_seg,
GimpGradientSegment *end_seg,
gint replicate_times,
GimpGradientSegment **final_start_seg,
GimpGradientSegment **final_end_seg);
void gimp_gradient_segment_range_split_midpoint
(GimpGradient *gradient,
GimpGradientSegment *start_seg,
GimpGradientSegment *end_seg,
GimpGradientSegment **final_start_seg,
GimpGradientSegment **final_end_seg);
void gimp_gradient_segment_range_split_uniform
(GimpGradient *gradient,
GimpGradientSegment *start_seg,
GimpGradientSegment *end_seg,
gint parts,
GimpGradientSegment **final_start_seg,
GimpGradientSegment **final_end_seg);
void gimp_gradient_segment_range_delete (GimpGradient *gradient,
GimpGradientSegment *start_seg,
GimpGradientSegment *end_seg,
GimpGradientSegment **final_start_seg,
GimpGradientSegment **final_end_seg);
void gimp_gradient_segment_range_recenter_handles
(GimpGradient *gradient,
GimpGradientSegment *start_seg,
GimpGradientSegment *end_seg);
void gimp_gradient_segment_range_redistribute_handles
(GimpGradient *gradient,
GimpGradientSegment *start_seg,
GimpGradientSegment *end_seg);
gdouble gimp_gradient_segment_range_move (GimpGradient *gradient,
GimpGradientSegment *range_l,
GimpGradientSegment *range_r,
gdouble delta,
gboolean control_compress);
#endif /* __GIMP_GRADIENT_H__ */

View File

@ -20,6 +20,7 @@ libapppdb_a_SOURCES = \
font_select_cmds.c \
fonts_cmds.c \
gimprc_cmds.c \
gradient_edit_cmds.c \
gradient_select_cmds.c \
gradients_cmds.c \
guides_cmds.c \

2645
app/pdb/gradient_edit_cmds.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -43,6 +43,7 @@ void register_floating_sel_procs (Gimp *gimp);
void register_font_select_procs (Gimp *gimp);
void register_fonts_procs (Gimp *gimp);
void register_gimprc_procs (Gimp *gimp);
void register_gradient_edit_procs (Gimp *gimp);
void register_gradient_select_procs (Gimp *gimp);
void register_gradients_procs (Gimp *gimp);
void register_guides_procs (Gimp *gimp);
@ -68,7 +69,7 @@ void register_transform_tools_procs (Gimp *gimp);
void register_undo_procs (Gimp *gimp);
void register_unit_procs (Gimp *gimp);
/* 350 procedures registered total */
/* 373 procedures registered total */
void
internal_procs_init (Gimp *gimp,
@ -80,112 +81,115 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (_("Internal Procedures"), _("Brush UI"), 0.0);
register_brush_select_procs (gimp);
(* status_callback) (NULL, _("Brushes"), 0.009);
(* status_callback) (NULL, _("Brushes"), 0.008);
register_brushes_procs (gimp);
(* status_callback) (NULL, _("Channel"), 0.04);
(* status_callback) (NULL, _("Channel"), 0.038);
register_channel_procs (gimp);
(* status_callback) (NULL, _("Color"), 0.066);
(* status_callback) (NULL, _("Color"), 0.062);
register_color_procs (gimp);
(* status_callback) (NULL, _("Convert"), 0.103);
(* status_callback) (NULL, _("Convert"), 0.097);
register_convert_procs (gimp);
(* status_callback) (NULL, _("Display procedures"), 0.111);
(* status_callback) (NULL, _("Display procedures"), 0.105);
register_display_procs (gimp);
(* status_callback) (NULL, _("Drawable procedures"), 0.123);
(* status_callback) (NULL, _("Drawable procedures"), 0.115);
register_drawable_procs (gimp);
(* status_callback) (NULL, _("Edit procedures"), 0.214);
(* status_callback) (NULL, _("Edit procedures"), 0.201);
register_edit_procs (gimp);
(* status_callback) (NULL, _("File Operations"), 0.237);
(* status_callback) (NULL, _("File Operations"), 0.223);
register_fileops_procs (gimp);
(* status_callback) (NULL, _("Floating selections"), 0.263);
(* status_callback) (NULL, _("Floating selections"), 0.247);
register_floating_sel_procs (gimp);
(* status_callback) (NULL, _("Font UI"), 0.28);
(* status_callback) (NULL, _("Font UI"), 0.263);
register_font_select_procs (gimp);
(* status_callback) (NULL, _("Fonts"), 0.289);
(* status_callback) (NULL, _("Fonts"), 0.271);
register_fonts_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.294);
(* status_callback) (NULL, _("Gimprc procedures"), 0.276);
register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.311);
(* status_callback) (NULL, _("Gradient"), 0.292);
register_gradient_edit_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.354);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.32);
(* status_callback) (NULL, _("Gradients"), 0.362);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.34);
(* status_callback) (NULL, _("Guide procedures"), 0.381);
register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.357);
(* status_callback) (NULL, _("Help procedures"), 0.397);
register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.36);
(* status_callback) (NULL, _("Image"), 0.399);
register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.534);
(* status_callback) (NULL, _("Layer"), 0.563);
register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.609);
(* status_callback) (NULL, _("Message procedures"), 0.633);
register_message_procs (gimp);
(* status_callback) (NULL, _("Miscellaneous"), 0.617);
(* status_callback) (NULL, _("Miscellaneous"), 0.641);
register_misc_procs (gimp);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.623);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.646);
register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette"), 0.666);
(* status_callback) (NULL, _("Palette"), 0.686);
register_palette_procs (gimp);
(* status_callback) (NULL, _("Palette UI"), 0.683);
(* status_callback) (NULL, _("Palette UI"), 0.702);
register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.691);
(* status_callback) (NULL, _("Palettes"), 0.71);
register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.706);
(* status_callback) (NULL, _("Parasite procedures"), 0.724);
register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.74);
(* status_callback) (NULL, _("Paths"), 0.756);
register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.783);
(* status_callback) (NULL, _("Pattern UI"), 0.796);
register_pattern_select_procs (gimp);
(* status_callback) (NULL, _("Patterns"), 0.791);
(* status_callback) (NULL, _("Patterns"), 0.804);
register_patterns_procs (gimp);
(* status_callback) (NULL, _("Plug-in"), 0.806);
(* status_callback) (NULL, _("Plug-in"), 0.818);
register_plug_in_procs (gimp);
(* status_callback) (NULL, _("Procedural database"), 0.826);
(* status_callback) (NULL, _("Procedural database"), 0.836);
register_procedural_db_procs (gimp);
(* status_callback) (NULL, _("Image mask"), 0.851);
(* status_callback) (NULL, _("Image mask"), 0.861);
register_selection_procs (gimp);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.903);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.909);
register_selection_tools_procs (gimp);
(* status_callback) (NULL, _("Text procedures"), 0.917);
(* status_callback) (NULL, _("Text procedures"), 0.922);
register_text_tool_procs (gimp);
(* status_callback) (NULL, _("Transform Tool procedures"), 0.929);
(* status_callback) (NULL, _("Transform Tool procedures"), 0.933);
register_transform_tools_procs (gimp);
(* status_callback) (NULL, _("Undo"), 0.946);
(* status_callback) (NULL, _("Undo"), 0.949);
register_undo_procs (gimp);
(* status_callback) (NULL, _("Units"), 0.966);
(* status_callback) (NULL, _("Units"), 0.968);
register_unit_procs (gimp);
}

View File

@ -114,6 +114,8 @@ static void gimp_gradient_editor_init (GimpGradientEditor *editor);
static void gimp_gradient_editor_set_data (GimpDataEditor *editor,
GimpData *data);
static void gimp_gradient_editor_gradient_dirty (GimpGradientEditor *editor,
GimpGradient *gradient);
static void gradient_editor_drop_gradient (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
@ -175,14 +177,11 @@ static void control_motion (GimpGradientEditor *editor,
GimpGradient *gradient,
gint x);
static void control_compress_left (GimpGradientSegment *range_l,
static void control_compress_left (GimpGradient *gradient,
GimpGradientSegment *range_l,
GimpGradientSegment *range_r,
GimpGradientSegment *drag_seg,
gdouble pos);
static void control_compress_range (GimpGradientSegment *range_l,
GimpGradientSegment *range_r,
gdouble new_l,
gdouble new_r);
static double control_move (GimpGradientEditor *editor,
GimpGradientSegment *range_l,
@ -223,9 +222,9 @@ static gdouble control_calc_g_pos (GimpGradientEditor *editor,
/* Segment functions */
static void seg_get_closest_handle (GimpGradient *grad,
gdouble pos,
GimpGradientSegment **seg,
GradientEditorDragMode *handle);
gdouble pos,
GimpGradientSegment **seg,
GradientEditorDragMode *handle);
static GimpDataEditorClass *parent_class = NULL;
@ -436,9 +435,23 @@ gimp_gradient_editor_set_data (GimpDataEditor *editor,
GimpData *data)
{
GimpGradientEditor *gradient_editor = GIMP_GRADIENT_EDITOR (editor);
GimpData *old_data;
old_data = gimp_data_editor_get_data (editor);
if (old_data)
g_signal_handlers_disconnect_by_func (old_data,
gimp_gradient_editor_gradient_dirty,
gradient_editor);
GIMP_DATA_EDITOR_CLASS (parent_class)->set_data (editor, data);
if (data)
g_signal_connect_swapped (data, "dirty",
G_CALLBACK (gimp_gradient_editor_gradient_dirty),
gradient_editor);
gimp_preview_set_viewable (GIMP_PREVIEW (gradient_editor->preview),
(GimpViewable *) data);
@ -454,6 +467,38 @@ gimp_gradient_editor_set_data (GimpDataEditor *editor,
control_update (gradient_editor, (GimpGradient *) data, TRUE);
}
static void
gimp_gradient_editor_gradient_dirty (GimpGradientEditor *editor,
GimpGradient *gradient)
{
GimpGradientSegment *segment;
gboolean left_seen = FALSE;
gboolean right_seen = FALSE;
for (segment = gradient->segments; segment; segment = segment->next)
{
if (segment == editor->control_sel_l)
left_seen = TRUE;
if (segment == editor->control_sel_r)
right_seen = TRUE;
if (right_seen && ! left_seen)
{
GimpGradientSegment *tmp;
tmp = editor->control_sel_l;
editor->control_sel_l = editor->control_sel_r;
editor->control_sel_r = tmp;
right_seen = FALSE;
left_seen = TRUE;
}
}
control_update (editor, gradient, ! (left_seen && right_seen));
}
/* public functions */
@ -915,7 +960,17 @@ control_events (GtkWidget *widget,
x, y, bevent->button, bevent->state);
if (editor->control_drag_mode != GRAD_DRAG_NONE)
gtk_grab_add (widget);
{
gtk_grab_add (widget);
g_signal_handlers_block_by_func (gradient,
gimp_gradient_editor_gradient_dirty,
editor);
if (! editor->instant_update)
gimp_gradient_freeze (gradient);
}
}
break;
@ -948,6 +1003,13 @@ control_events (GtkWidget *widget,
if (editor->control_drag_mode != GRAD_DRAG_NONE)
{
if (! editor->instant_update)
gimp_gradient_thaw (gradient);
g_signal_handlers_unblock_by_func (gradient,
gimp_gradient_editor_gradient_dirty,
editor);
gtk_grab_remove (widget);
gtk_widget_get_pointer (editor->control, &x, &y);
@ -956,8 +1018,7 @@ control_events (GtkWidget *widget,
if ((time - editor->control_click_time) >= GRAD_MOVE_TIME)
{
if (! editor->instant_update)
gimp_data_dirty (GIMP_DATA (gradient));
/* stuff was done in motion */
}
else if ((editor->control_drag_mode == GRAD_DRAG_MIDDLE) ||
(editor->control_drag_mode == GRAD_DRAG_ALL))
@ -1332,13 +1393,13 @@ control_motion (GimpGradientEditor *editor,
seg->prev->middle + EPSILON,
seg->middle - EPSILON);
else
control_compress_left (editor->control_sel_l,
control_compress_left (gradient,
editor->control_sel_l,
editor->control_sel_r,
seg, pos);
str = g_strdup_printf (_("Handle position: %0.6f"), seg->left);
gradient_editor_set_hint (editor, str, "", "");
break;
case GRAD_DRAG_MIDDLE:
@ -1347,7 +1408,6 @@ control_motion (GimpGradientEditor *editor,
str = g_strdup_printf (_("Handle position: %0.6f"), seg->middle);
gradient_editor_set_hint (editor, str, "", "");
break;
case GRAD_DRAG_ALL:
@ -1380,14 +1440,12 @@ control_motion (GimpGradientEditor *editor,
if (str)
g_free (str);
if (editor->instant_update)
gimp_data_dirty (GIMP_DATA (gradient));
gimp_gradient_editor_update (editor);
}
static void
control_compress_left (GimpGradientSegment *range_l,
control_compress_left (GimpGradient *gradient,
GimpGradientSegment *range_l,
GimpGradientSegment *range_r,
GimpGradientSegment *drag_seg,
gdouble pos)
@ -1457,52 +1515,24 @@ control_compress_left (GimpGradientSegment *range_l,
/* Compress segments to the left of the handle */
if (drag_seg == range_l)
control_compress_range (range_l->prev, range_l->prev,
range_l->prev->left, pos);
gimp_gradient_segment_range_compress (gradient,
range_l->prev, range_l->prev,
range_l->prev->left, pos);
else
control_compress_range (range_l, drag_seg->prev, range_l->left, pos);
gimp_gradient_segment_range_compress (gradient,
range_l, drag_seg->prev,
range_l->left, pos);
/* Compress segments to the right of the handle */
if (drag_seg != range_r->next)
control_compress_range (drag_seg, range_r, pos, range_r->right);
gimp_gradient_segment_range_compress (gradient,
drag_seg, range_r,
pos, range_r->right);
else
control_compress_range (drag_seg, drag_seg, pos, drag_seg->right);
}
static void
control_compress_range (GimpGradientSegment *range_l,
GimpGradientSegment *range_r,
gdouble new_l,
gdouble new_r)
{
gdouble orig_l, orig_r;
gdouble scale;
GimpGradientSegment *seg, *aseg;
orig_l = range_l->left;
orig_r = range_r->right;
scale = (new_r - new_l) / (orig_r - orig_l);
seg = range_l;
do
{
if (seg->prev)
seg->left = new_l + (seg->left - orig_l) * scale;
seg->middle = new_l + (seg->middle - orig_l) * scale;
if (seg->next)
seg->right = new_l + (seg->right - orig_l) * scale;
/* Next */
aseg = seg;
seg = seg->next;
}
while (aseg != range_r);
gimp_gradient_segment_range_compress (gradient,
drag_seg, drag_seg,
pos, drag_seg->right);
}
/*****/
@ -1513,109 +1543,18 @@ control_move (GimpGradientEditor *editor,
GimpGradientSegment *range_r,
gdouble delta)
{
gdouble lbound, rbound;
gint is_first, is_last;
GimpGradientSegment *seg, *aseg;
GimpGradient *gradient;
gdouble ret;
/* First or last segments in gradient? */
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
is_first = (range_l->prev == NULL);
is_last = (range_r->next == NULL);
ret = gimp_gradient_segment_range_move (gradient,
range_l,
range_r,
delta,
editor->control_compress);
/* Calculate drag bounds */
if (! editor->control_compress)
{
if (!is_first)
lbound = range_l->prev->middle + EPSILON;
else
lbound = range_l->left + EPSILON;
if (!is_last)
rbound = range_r->next->middle - EPSILON;
else
rbound = range_r->right - EPSILON;
}
else
{
if (!is_first)
lbound = range_l->prev->left + 2.0 * EPSILON;
else
lbound = range_l->left + EPSILON;
if (!is_last)
rbound = range_r->next->right - 2.0 * EPSILON;
else
rbound = range_r->right - EPSILON;
}
/* Fix the delta if necessary */
if (delta < 0.0)
{
if (!is_first)
{
if (range_l->left + delta < lbound)
delta = lbound - range_l->left;
}
else
if (range_l->middle + delta < lbound)
delta = lbound - range_l->middle;
}
else
{
if (!is_last)
{
if (range_r->right + delta > rbound)
delta = rbound - range_r->right;
}
else
if (range_r->middle + delta > rbound)
delta = rbound - range_r->middle;
}
/* Move all the segments inside the range */
seg = range_l;
do
{
if (!((seg == range_l) && is_first))
seg->left += delta;
seg->middle += delta;
if (!((seg == range_r) && is_last))
seg->right += delta;
/* Next */
aseg = seg;
seg = seg->next;
}
while (aseg != range_r);
/* Fix the segments that surround the range */
if (!is_first)
{
if (! editor->control_compress)
range_l->prev->right = range_l->left;
else
control_compress_range (range_l->prev, range_l->prev,
range_l->prev->left, range_l->left);
}
if (!is_last)
{
if (! editor->control_compress)
range_r->next->left = range_r->right;
else
control_compress_range (range_r->next, range_r->next,
range_r->right, range_r->next->right);
}
return delta;
return ret;
}
/*****/
@ -1649,12 +1588,18 @@ control_update (GimpGradientEditor *editor,
editor->control_pixmap =
gdk_pixmap_new (editor->control->window, cwidth, cheight, -1);
reset_selection = TRUE;
}
if (reset_selection && gradient)
control_select_single_segment (editor, gradient->segments);
if (! editor->control_sel_l || ! editor->control_sel_r)
reset_selection = TRUE;
if (reset_selection)
{
if (gradient)
control_select_single_segment (editor, gradient->segments);
else
control_select_single_segment (editor, NULL);
}
/* Redraw pixmap */
adjustment = GTK_ADJUSTMENT (editor->scroll_data);
@ -1697,10 +1642,8 @@ control_draw (GimpGradientEditor *editor,
/* Draw selection */
sel_l = control_calc_p_pos (editor,
editor->control_sel_l->left);
sel_r = control_calc_p_pos (editor,
editor->control_sel_r->right);
sel_l = control_calc_p_pos (editor, editor->control_sel_l->left);
sel_r = control_calc_p_pos (editor, editor->control_sel_r->right);
gdk_draw_rectangle (pixmap,
editor->control->style->dark_gc[GTK_STATE_NORMAL],
@ -1708,21 +1651,14 @@ control_draw (GimpGradientEditor *editor,
/* Draw handles */
seg = gradient->segments;
while (seg)
for (seg = gradient->segments; seg; seg = seg->next)
{
control_draw_normal_handle (editor, pixmap, seg->left, height);
control_draw_middle_handle (editor, pixmap, seg->middle, height);
/* Draw right handle only if this is the last segment */
if (seg->next == NULL)
control_draw_normal_handle (editor, pixmap, seg->right, height);
/* Next! */
seg = seg->next;
}
/* Draw the handle which is closest to the mouse position */

View File

@ -87,6 +87,7 @@ PDB_WRAPPERS_C = \
gimpfonts_pdb.c \
gimpfontselect_pdb.c \
gimpgimprc_pdb.c \
gimpgradientedit_pdb.c \
gimpgradients_pdb.c \
gimpgradientselect_pdb.c \
gimpguides_pdb.c \
@ -127,6 +128,7 @@ PDB_WRAPPERS_H = \
gimpfonts_pdb.h \
gimpfontselect_pdb.h \
gimpgimprc_pdb.h \
gimpgradientedit_pdb.h \
gimpgradients_pdb.h \
gimpgradientselect_pdb.h \
gimpguides_pdb.h \

View File

@ -37,6 +37,7 @@
#include <libgimp/gimpfonts_pdb.h>
#include <libgimp/gimpfontselect_pdb.h>
#include <libgimp/gimpgimprc_pdb.h>
#include <libgimp/gimpgradientedit_pdb.h>
#include <libgimp/gimpgradients_pdb.h>
#include <libgimp/gimpgradientselect_pdb.h>
#include <libgimp/gimpguides_pdb.h>

View File

@ -124,6 +124,22 @@ typedef enum
GIMP_PATTERN_FILL
} GimpFillType;
typedef enum
{
GIMP_GRAD_RGB,
GIMP_GRAD_HSV_CCW,
GIMP_GRAD_HSV_CW
} GimpGradientSegmentColor;
typedef enum
{
GIMP_GRAD_LINEAR,
GIMP_GRAD_CURVED,
GIMP_GRAD_SINE,
GIMP_GRAD_SPHERE_INCREASING,
GIMP_GRAD_SPHERE_DECREASING
} GimpGradientSegmentType;
typedef enum
{
GIMP_GRADIENT_LINEAR,

View File

@ -0,0 +1,957 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimpgradientedit_pdb.c
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* NOTE: This file is autogenerated by pdbgen.pl */
#include "config.h"
#include "gimp.h"
/**
* gimp_gradient_segment_get_left_color:
* @name: The name of the gradient to operate on.
* @segment: The index of the segment within the gradient.
* @color: The return color.
* @opacity: The opacity of the endpoint.
*
* Retrieves the left endpoint color of the specified gradient and
* segment
*
* This procedure retrieves the left endpoint color of the specified
* segment of the specified gradient.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_get_left_color (const gchar *name,
gint segment,
GimpRGB *color,
gdouble *opacity)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_get_left_color",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, segment,
GIMP_PDB_END);
*opacity = 0.0;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
{
*color = return_vals[1].data.d_color;
*opacity = return_vals[2].data.d_float;
}
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_set_left_color:
* @name: The name of the gradient to operate on.
* @segment: The index of the segment within the gradient.
* @color: The color to set.
* @opacity: The opacity to set for the endpoint.
*
* Retrieves the left endpoint color of the specified gradient and
* segment
*
* This procedure retrieves the left endpoint color of the specified
* segment of the specified gradient.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_set_left_color (const gchar *name,
gint segment,
const GimpRGB *color,
gdouble opacity)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_set_left_color",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, segment,
GIMP_PDB_COLOR, color,
GIMP_PDB_FLOAT, opacity,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_get_right_color:
* @name: The name of the gradient to operate on.
* @segment: The index of the segment within the gradient.
* @color: The return color.
* @opacity: The opacity of the endpoint.
*
* Retrieves the right endpoint color of the specified gradient and
* segment
*
* This procedure retrieves the right endpoint color of the specified
* segment of the specified gradient.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_get_right_color (const gchar *name,
gint segment,
GimpRGB *color,
gdouble *opacity)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_get_right_color",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, segment,
GIMP_PDB_END);
*opacity = 0.0;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
{
*color = return_vals[1].data.d_color;
*opacity = return_vals[2].data.d_float;
}
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_set_right_color:
* @name: The name of the gradient to operate on.
* @segment: The index of the segment within the gradient.
* @color: The color to set.
* @opacity: The opacity to set for the endpoint.
*
* Retrieves the right endpoint color of the specified gradient and
* segment
*
* This procedure retrieves the right endpoint color of the specified
* segment of the specified gradient.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_set_right_color (const gchar *name,
gint segment,
const GimpRGB *color,
gdouble opacity)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_set_right_color",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, segment,
GIMP_PDB_COLOR, color,
GIMP_PDB_FLOAT, opacity,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_get_left_pos:
* @name: The name of the gradient to operate on.
* @segment: The index of the segment within the gradient.
* @pos: The return position.
*
* Retrieves the left endpoint position of the specified gradient and
* segment
*
* This procedure retrieves the left endpoint position of the specified
* segment of the specified gradient.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_get_left_pos (const gchar *name,
gint segment,
gdouble *pos)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_get_left_pos",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, segment,
GIMP_PDB_END);
*pos = 0.0;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
*pos = return_vals[1].data.d_float;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_set_left_pos:
* @name: The name of the gradient to operate on.
* @segment: The index of the segment within the gradient.
* @pos: The position to set the guidepoint in.
* @final_pos: The return position.
*
* Sets the left endpoint position of the specified gradient and
* segment
*
* This procedure sets the left endpoint position of the specified
* segment of the specified gradient. The final position will be
* between the position of the middle point to the left to the middle
* point of the current segement. This procedure returns the final
* position.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_set_left_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_set_left_pos",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, segment,
GIMP_PDB_FLOAT, pos,
GIMP_PDB_END);
*final_pos = 0.0;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
*final_pos = return_vals[1].data.d_float;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_get_middle_pos:
* @name: The name of the gradient to operate on.
* @segment: The index of the segment within the gradient.
* @pos: The return position.
*
* Retrieves the middle point position of the specified gradient and
* segment
*
* This procedure retrieves the middle point position of the specified
* segment of the specified gradient.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_get_middle_pos (const gchar *name,
gint segment,
gdouble *pos)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_get_middle_pos",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, segment,
GIMP_PDB_END);
*pos = 0.0;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
*pos = return_vals[1].data.d_float;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_set_middle_pos:
* @name: The name of the gradient to operate on.
* @segment: The index of the segment within the gradient.
* @pos: The position to set the guidepoint in.
* @final_pos: The return position.
*
* Sets the middle point position of the specified gradient and segment
*
* This procedure sets the middle point position of the specified
* segment of the specified gradient. The final position will be
* between the two endpoints of the segment. This procedure returns the
* final position.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_set_middle_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_set_middle_pos",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, segment,
GIMP_PDB_FLOAT, pos,
GIMP_PDB_END);
*final_pos = 0.0;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
*final_pos = return_vals[1].data.d_float;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_get_right_pos:
* @name: The name of the gradient to operate on.
* @segment: The index of the segment within the gradient.
* @pos: The return position.
*
* Retrieves the right endpoint position of the specified gradient and
* segment
*
* This procedure retrieves the right endpoint position of the
* specified segment of the specified gradient.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_get_right_pos (const gchar *name,
gint segment,
gdouble *pos)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_get_right_pos",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, segment,
GIMP_PDB_END);
*pos = 0.0;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
*pos = return_vals[1].data.d_float;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_set_right_pos:
* @name: The name of the gradient to operate on.
* @segment: The index of the segment within the gradient.
* @pos: The position to set the guidepoint in.
* @final_pos: The return position.
*
* Sets the right endpoint position of the specified gradient and
* segment
*
* This procedure sets the right endpoint position of the specified
* segment of the specified gradient. The final position will be
* between the position of the middle point of the current segment and
* the middle point of the segment to the right. This procedure returns
* the final position.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_set_right_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_set_right_pos",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, segment,
GIMP_PDB_FLOAT, pos,
GIMP_PDB_END);
*final_pos = 0.0;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
*final_pos = return_vals[1].data.d_float;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_get_blending_function:
* @name: The name of the gradient to operate on.
* @segment: The index of the segment within the gradient.
* @blend_func: The blending function of the segment.
*
* Retrieves the gradient segment's blending function
*
* This procedure retrieves the blending function of the segment at the
* specified gradient name and segment index.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_get_blending_function (const gchar *name,
gint segment,
gint *blend_func)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_get_blending_function",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, segment,
GIMP_PDB_END);
*blend_func = 0;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
*blend_func = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_set_blending_function:
* @name: The name of the gradient to operate on.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
* @blending_function: The Blending Function (GRAD-LINEAR, GRAD-CURVED, GRAD-SINE, GRAD-SPHERE-INCREASING, GRAD-SPHERE-DECREASING).
*
* Change the blending function of a segments range
*
* This function changes the blending function of a segment range to
* the specified blending function.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_set_blending_function (const gchar *name,
gint start_segment,
gint end_segment,
gint blending_function)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_set_blending_function",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, start_segment,
GIMP_PDB_INT32, end_segment,
GIMP_PDB_INT32, blending_function,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_get_coloring_type:
* @name: The name of the gradient to operate on.
* @segment: The index of the segment within the gradient.
* @coloring_type: The coloring type of the segment.
*
* Retrieves the gradient segment's coloring type
*
* This procedure retrieves the coloring type of the segment at the
* specified gradient name and segment index.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_get_coloring_type (const gchar *name,
gint segment,
gint *coloring_type)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_get_coloring_type",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, segment,
GIMP_PDB_END);
*coloring_type = 0;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
*coloring_type = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_set_coloring_type:
* @name: The name of the gradient to operate on.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
* @coloring_type: The Coloring Type (GRAD-RGB, GRAD-HSV-CCW, GRAD-HSV-CW).
*
* Change the coloring type of a segments range
*
* This function changes the coloring type of a segment range to the
* specified coloring type.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_set_coloring_type (const gchar *name,
gint start_segment,
gint end_segment,
gint coloring_type)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_set_coloring_type",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, start_segment,
GIMP_PDB_INT32, end_segment,
GIMP_PDB_INT32, coloring_type,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_range_flip:
* @name: The name of the gradient to operate on.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
*
* Flip the segment range
*
* This function flips a segment range.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_range_flip (const gchar *name,
gint start_segment,
gint end_segment)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_range_flip",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, start_segment,
GIMP_PDB_INT32, end_segment,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_range_replicate:
* @name: The name of the gradient to operate on.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
* @replicate_times: The number of times to replicate.
*
* Replicate the segment range
*
* This function replicates a segment range a given number of times.
* Instead of the original segment range, several smaller scaled copies
* of it will appear in equal widths.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_range_replicate (const gchar *name,
gint start_segment,
gint end_segment,
gint replicate_times)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_range_replicate",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, start_segment,
GIMP_PDB_INT32, end_segment,
GIMP_PDB_INT32, replicate_times,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_range_split_midpoint:
* @name: The name of the gradient to operate on.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
*
* Splits each segment in the segment range at midpoint
*
* This function splits each segment in the segment range at its
* midpoint.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_range_split_midpoint (const gchar *name,
gint start_segment,
gint end_segment)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_range_split_midpoint",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, start_segment,
GIMP_PDB_INT32, end_segment,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_range_split_uniform:
* @name: The name of the gradient to operate on.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
* @split_parts: The number of uniform divisions to split each segment to.
*
* Splits each segment in the segment range uniformly
*
* This function splits each segment in the segment range uniformly
* according to the number of times specified by the parameter.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_range_split_uniform (const gchar *name,
gint start_segment,
gint end_segment,
gint split_parts)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_range_split_uniform",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, start_segment,
GIMP_PDB_INT32, end_segment,
GIMP_PDB_INT32, split_parts,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_range_delete:
* @name: The name of the gradient to operate on.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
*
* Delete the segment range
*
* This function deletes a segment range.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_range_delete (const gchar *name,
gint start_segment,
gint end_segment)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_range_delete",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, start_segment,
GIMP_PDB_INT32, end_segment,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_range_redistribute_handles:
* @name: The name of the gradient to operate on.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
*
* Uniformly redistribute the segment range's handles
*
* This function redistributes the handles of the specified segment
* range of the specified gradient, so they'll be evenly spaced.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_range_redistribute_handles (const gchar *name,
gint start_segment,
gint end_segment)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_range_redistribute_handles",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, start_segment,
GIMP_PDB_INT32, end_segment,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_range_blend_colors:
* @name: The name of the gradient to operate on.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
*
* Blend the colors of the segment range.
*
* This function blends the colors (but not the opacity) of the
* segments' range of the gradient. Using it, the colors' transition
* will be uniform across the range.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_range_blend_colors (const gchar *name,
gint start_segment,
gint end_segment)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_range_blend_colors",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, start_segment,
GIMP_PDB_INT32, end_segment,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_range_blend_opacity:
* @name: The name of the gradient to operate on.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
*
* Blend the opacity of the segment range.
*
* This function blends the opacity (but not the colors) of the
* segments' range of the gradient. Using it, the opacity's transition
* will be uniform across the range.
*
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_range_blend_opacity (const gchar *name,
gint start_segment,
gint end_segment)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_gradient_segment_range_blend_opacity",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, start_segment,
GIMP_PDB_INT32, end_segment,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_gradient_segment_range_move:
* @name: The name of the gradient to operate on.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
* @delta: The delta to move the segment range.
* @control_compress: Whether or not to compress the neighboring segments.
*
* Move the position of an entire segment range by a delta.
*
* This funtions moves the position of an entire segment range by a
* delta. The actual delta (which is returned) will be limited by the
* control points of the neighboring segments.
*
* Returns: The final delta by which the range moved.
*/
gdouble
gimp_gradient_segment_range_move (const gchar *name,
gint start_segment,
gint end_segment,
gdouble delta,
gboolean control_compress)
{
GimpParam *return_vals;
gint nreturn_vals;
gdouble final_delta = 0;
return_vals = gimp_run_procedure ("gimp_gradient_segment_range_move",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_INT32, start_segment,
GIMP_PDB_INT32, end_segment,
GIMP_PDB_FLOAT, delta,
GIMP_PDB_INT32, control_compress,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
final_delta = return_vals[1].data.d_float;
gimp_destroy_params (return_vals, nreturn_vals);
return final_delta;
}

View File

@ -0,0 +1,118 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimpgradientedit_pdb.h
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* NOTE: This file is autogenerated by pdbgen.pl */
#ifndef __GIMP_GRADIENT_EDIT_PDB_H__
#define __GIMP_GRADIENT_EDIT_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean gimp_gradient_segment_get_left_color (const gchar *name,
gint segment,
GimpRGB *color,
gdouble *opacity);
gboolean gimp_gradient_segment_set_left_color (const gchar *name,
gint segment,
const GimpRGB *color,
gdouble opacity);
gboolean gimp_gradient_segment_get_right_color (const gchar *name,
gint segment,
GimpRGB *color,
gdouble *opacity);
gboolean gimp_gradient_segment_set_right_color (const gchar *name,
gint segment,
const GimpRGB *color,
gdouble opacity);
gboolean gimp_gradient_segment_get_left_pos (const gchar *name,
gint segment,
gdouble *pos);
gboolean gimp_gradient_segment_set_left_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean gimp_gradient_segment_get_middle_pos (const gchar *name,
gint segment,
gdouble *pos);
gboolean gimp_gradient_segment_set_middle_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean gimp_gradient_segment_get_right_pos (const gchar *name,
gint segment,
gdouble *pos);
gboolean gimp_gradient_segment_set_right_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean gimp_gradient_segment_get_blending_function (const gchar *name,
gint segment,
gint *blend_func);
gboolean gimp_gradient_segment_set_blending_function (const gchar *name,
gint start_segment,
gint end_segment,
gint blending_function);
gboolean gimp_gradient_segment_get_coloring_type (const gchar *name,
gint segment,
gint *coloring_type);
gboolean gimp_gradient_segment_set_coloring_type (const gchar *name,
gint start_segment,
gint end_segment,
gint coloring_type);
gboolean gimp_gradient_segment_range_flip (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_replicate (const gchar *name,
gint start_segment,
gint end_segment,
gint replicate_times);
gboolean gimp_gradient_segment_range_split_midpoint (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_split_uniform (const gchar *name,
gint start_segment,
gint end_segment,
gint split_parts);
gboolean gimp_gradient_segment_range_delete (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_redistribute_handles (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_blend_colors (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_blend_opacity (const gchar *name,
gint start_segment,
gint end_segment);
gdouble gimp_gradient_segment_range_move (const gchar *name,
gint start_segment,
gint end_segment,
gdouble delta,
gboolean control_compress);
G_END_DECLS
#endif /* __GIMP_GRADIENT_EDIT_PDB_H__ */

View File

@ -107,6 +107,18 @@ WHITE_FILL = 2
TRANSPARENT_FILL = 3
PATTERN_FILL = 4
# GimpGradientSegmentColor
GRAD_RGB = 0
GRAD_HSV_CCW = 1
GRAD_HSV_CW = 2
# GimpGradientSegmentType
GRAD_LINEAR = 0
GRAD_CURVED = 1
GRAD_SINE = 2
GRAD_SPHERE_INCREASING = 3
GRAD_SPHERE_DECREASING = 4
# GimpGradientType
GRADIENT_LINEAR = 0
GRADIENT_BILINEAR = 1

View File

@ -84,6 +84,16 @@ init_generated_constants (void)
setvar (cintern ("TRANSPARENT-FILL"), flocons (3), NIL);
setvar (cintern ("PATTERN-FILL"), flocons (4), NIL);
setvar (cintern ("GRAD-RGB"), flocons (0), NIL);
setvar (cintern ("GRAD-HSV-CCW"), flocons (1), NIL);
setvar (cintern ("GRAD-HSV-CW"), flocons (2), NIL);
setvar (cintern ("GRAD-LINEAR"), flocons (0), NIL);
setvar (cintern ("GRAD-CURVED"), flocons (1), NIL);
setvar (cintern ("GRAD-SINE"), flocons (2), NIL);
setvar (cintern ("GRAD-SPHERE-INCREASING"), flocons (3), NIL);
setvar (cintern ("GRAD-SPHERE-DECREASING"), flocons (4), NIL);
setvar (cintern ("GRADIENT-LINEAR"), flocons (0), NIL);
setvar (cintern ("GRADIENT-BILINEAR"), flocons (1), NIL);
setvar (cintern ("GRADIENT-RADIAL"), flocons (2), NIL);

View File

@ -15,6 +15,7 @@ pdb_sources = \
pdb/font_select.pdb \
pdb/fonts.pdb \
pdb/gimprc.pdb \
pdb/gradient_edit.pdb \
pdb/gradient_select.pdb \
pdb/gradients.pdb \
pdb/guides.pdb \

View File

@ -358,6 +358,26 @@ package Gimp::CodeGen::enums;
GIMP_MONO_PALETTE => '3',
GIMP_CUSTOM_PALETTE => '4' }
},
GimpGradientSegmentType =>
{ contig => 1,
header => 'core/core-enums.h',
symbols => [ qw(GIMP_GRAD_LINEAR GIMP_GRAD_CURVED GIMP_GRAD_SINE
GIMP_GRAD_SPHERE_INCREASING
GIMP_GRAD_SPHERE_DECREASING) ],
mapping => { GIMP_GRAD_LINEAR => '0',
GIMP_GRAD_CURVED => '1',
GIMP_GRAD_SINE => '2',
GIMP_GRAD_SPHERE_INCREASING => '3',
GIMP_GRAD_SPHERE_DECREASING => '4' }
},
GimpGradientSegmentColor =>
{ contig => 1,
header => 'core/core-enums.h',
symbols => [ qw(GIMP_GRAD_RGB GIMP_GRAD_HSV_CCW GIMP_GRAD_HSV_CW) ],
mapping => { GIMP_GRAD_RGB => '0',
GIMP_GRAD_HSV_CCW => '1',
GIMP_GRAD_HSV_CW => '2' }
},
GimpMaskApplyMode =>
{ contig => 1,
header => 'core/core-enums.h',

View File

@ -13,6 +13,7 @@
font_select
fonts
gimprc
gradient_edit
gradient_select
gradients
guides

View File

@ -0,0 +1,750 @@
# The GIMP -- an image manipulation program
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
sub pdb_misc {
$author = $copyright = 'Shlomi Fish';
$date = '2003';
}
my $_get_gradient_from_name_code = <<'CODE';
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
CODE
sub _gen_gradient_search_for_segment_code
{
my $action_on_success = shift;
return <<"CODE";
{
$_get_gradient_from_name_code
if (gradient)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
if (seg)
{
/* Success */
$action_on_success
}
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
CODE
}
sub other_side
{
my $side = shift;
return ($side eq "left") ? "right" : "left";
}
sub _grad_and_seg_params
{
return
(
{
name => 'name',
type => 'string',
desc => 'The name of the gradient to operate on',
},
{
name => 'segment',
type => '0 <= int32',
desc => 'The index of the segment within the gradient',
},
);
}
sub _gen_gradient_set_side_color
{
my $side = shift;
my $other_side = other_side($side);
$blurb = "Retrieves the $side endpoint color of the specified gradient and segment";
$help = <<"HELP";
This procedure retrieves the $side endpoint color of the specified segment of
the specified gradient.
HELP
&pdb_misc;
@inargs = (
&_grad_and_seg_params,
{
name => 'color',
type => 'color',
desc => "The color to set",
},
{
name => "opacity",
type => '0 <= float <= 100.0',
desc => "The opacity to set for the endpoint",
},
);
@outargs = (
);
my @blend_params = ("&color","&(seg->${other_side}_color)");
if ($side eq "right")
{
@blend_params = reverse(@blend_params);
}
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => &_gen_gradient_search_for_segment_code(<<"CODE"),
color.a = opacity / 100.0;
gimp_gradient_segment_set_${side}_color (gradient, seg, &color);
CODE
);
}
sub _gen_gradient_get_side_color
{
my $side = shift;
$blurb = "Retrieves the $side endpoint color of the specified gradient and segment";
$help = <<"HELP";
This procedure retrieves the $side endpoint color of the specified segment of
the specified gradient.
HELP
&pdb_misc;
@inargs = (
&_grad_and_seg_params,
);
@outargs = (
{
name => 'color',
type => 'color',
desc => "The return color",
void_ret => 1,
init => 1,
},
{
name => "opacity",
type => 'float',
desc => "The opacity of the endpoint",
},
);
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => &_gen_gradient_search_for_segment_code(<<"CODE"),
gimp_gradient_segment_get_${side}_color (gradient, seg, &color);
opacity = color.a * 100.0;
CODE
);
}
sub _gen_gradient_get_pos
{
my $side = shift;
my $side_endpoint =
(($side eq "middle") ?
"middle point" :
"$side endpoint"
);
$blurb = "Retrieves the $side_endpoint position of the specified gradient and segment";
$help = <<"HELP";
This procedure retrieves the $side_endpoint position of the specified segment of
the specified gradient.
HELP
&pdb_misc;
@inargs = &_grad_and_seg_params;
@outargs = (
{
name => 'pos',
type => 'float',
desc => "The return position",
void_ret => 1,
init => 1,
},
);
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => &_gen_gradient_search_for_segment_code(<<"CODE"),
pos = gimp_gradient_segment_get_${side}_pos (gradient, seg);
CODE
);
}
sub _gen_gradient_set_pos
{
my $side = shift;
my $side_endpoint =
(($side eq "middle") ?
"middle point" :
"$side endpoint"
);
$blurb = "Sets the $side_endpoint position of the specified gradient and segment";
my %betweens =
(
'left' => ("the position of the middle point to the left to " .
"the middle point of the current segement"),
'right' => ("the position of the middle point of the current " .
"segment and the middle point of the segment to " .
"the right"),
'middle' => ("the two endpoints of the segment"),
);
$help = <<"HELP";
This procedure sets the $side_endpoint position of the specified segment of
the specified gradient. The final position will be between $betweens{$side}.
This procedure returns the final position.
HELP
&pdb_misc;
@inargs = (
&_grad_and_seg_params,
{
name => 'pos',
type => "0.0 <= float <= 1.0",
desc => "The position to set the guidepoint in."
},
);
@outargs = (
{
name => 'final_pos',
type => 'float',
desc => "The return position",
void_ret => 1,
init => 1,
},
);
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => &_gen_gradient_search_for_segment_code(<<"CODE"),
final_pos = gimp_gradient_segment_set_${side}_pos (gradient, seg, pos);
CODE
);
}
sub gradient_segment_get_left_color
{
&_gen_gradient_get_side_color("left");
}
sub gradient_segment_get_right_color
{
&_gen_gradient_get_side_color("right");
}
sub gradient_segment_set_left_color
{
&_gen_gradient_set_side_color("left");
}
sub gradient_segment_set_right_color
{
&_gen_gradient_set_side_color("right");
}
sub gradient_segment_get_left_pos
{
&_gen_gradient_get_pos("left");
}
sub gradient_segment_get_right_pos
{
&_gen_gradient_get_pos("right");
}
sub gradient_segment_get_middle_pos
{
&_gen_gradient_get_pos("middle");
}
sub gradient_segment_set_left_pos
{
&_gen_gradient_set_pos("left");
}
sub gradient_segment_set_right_pos
{
&_gen_gradient_set_pos("right");
}
sub gradient_segment_set_middle_pos
{
&_gen_gradient_set_pos("middle");
}
sub gradient_segment_get_blending_function
{
$blurb = "Retrieves the gradient segment's blending function";
$help = <<'HELP';
This procedure retrieves the blending function of the segment at the
specified gradient name and segment index.
HELP
&pdb_misc;
@inargs = &_grad_and_seg_params;
@outargs = (
{
name => 'blend_func',
type => "int32",
desc => "The blending function of the segment",
void_ret => 1,
init => 1,
}
);
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => &_gen_gradient_search_for_segment_code(<<"CODE"),
blend_func = gimp_gradient_segment_get_blending_function (gradient, seg);
CODE
);
}
sub gradient_segment_get_coloring_type
{
$blurb = "Retrieves the gradient segment's coloring type";
$help = <<'HELP';
This procedure retrieves the coloring type of the segment at the
specified gradient name and segment index.
HELP
&pdb_misc;
@inargs = &_grad_and_seg_params;
@outargs = (
{
name => 'coloring_type',
type => "int32",
desc => "The coloring type of the segment",
void_ret => 1,
init => 1,
}
);
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => &_gen_gradient_search_for_segment_code(<<"CODE"),
coloring_type = gimp_gradient_segment_get_coloring_type (gradient, seg);
CODE
);
}
sub _gen_gradient_operate_on_segments_range
{
my %args = (@_);
$blurb = $args{blurb};
$help = $args{help};
&pdb_misc;
@inargs =
(
{
name => 'name',
type => 'string',
desc => 'The name of the gradient to operate on.',
},
{
name => 'start_segment',
type => '0 <= int32',
desc => 'The index of the first segment to operate on',
},
{
name => 'end_segment',
type => 'int32',
desc => 'The index of the last segment to operate on. If negative, the selection will extend to the end of the string.',
},
@{$args{inargs}},
);
@outargs = @{$args{outargs}};
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => <<"CODE",
{
$_get_gradient_from_name_code
if (gradient)
{
GimpGradientSegment *start_seg, *end_seg;
start_seg = gimp_gradient_segment_get_nth (gradient->segments, start_segment);
if (start_seg)
{
if ((end_segment < start_segment) && (end_segment >= 0))
{
/* Do Nothing */
success = FALSE;
}
else
{
if (end_segment < 0)
{
end_seg = NULL;
}
else
{
end_seg = gimp_gradient_segment_get_nth (start_seg,
end_segment - start_segment);
}
/* Success */
$args{action_on_success}
}
}
else
{
success = FALSE;
}
}
}
CODE
);
}
sub gradient_segment_set_blending_function
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Change the blending function of a segments range",
'help' => <<'HELP',
This function changes the blending function of a segment range to the
specified blending function.
HELP
'inargs' =>
[
{
name => "blending_function",
type => "0 <= int32 <= 4",
desc => "The Blending Function (GRAD-LINEAR, GRAD-CURVED, GRAD-SINE, GRAD-SPHERE-INCREASING, GRAD-SPHERE-DECREASING)"
},
],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_set_blending_function (gradient,
start_seg,
end_seg,
blending_function);
CODE
);
}
sub gradient_segment_set_coloring_type
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Change the coloring type of a segments range",
'help' => <<'HELP',
This function changes the coloring type of a segment range to the
specified coloring type.
HELP
'inargs' =>
[
{
name => "coloring_type",
type => "0 <= int32 <= 2",
desc => "The Coloring Type (GRAD-RGB, GRAD-HSV-CCW, GRAD-HSV-CW)"
},
],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_set_coloring_type (gradient,
start_seg,
end_seg,
coloring_type);
CODE
);
}
sub gradient_segment_range_flip
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Flip the segment range",
'help' => <<'HELP',
This function flips a segment range.
HELP
'inargs' => [],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_flip (gradient,
start_seg,
end_seg,
NULL, NULL);
CODE
);
}
sub gradient_segment_range_replicate
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Replicate the segment range",
'help' => <<'HELP',
This function replicates a segment range a given number of times. Instead
of the original segment range, several smaller scaled copies of it
will appear in equal widths.
HELP
'inargs' =>
[
{
'name' => "replicate_times",
'type' => "2 <= int32 <= 20",
'desc' => "The number of times to replicate",
}
],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_replicate (gradient,
start_seg,
end_seg,
replicate_times,
NULL, NULL);
CODE
);
}
sub gradient_segment_range_split_midpoint
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Splits each segment in the segment range at midpoint",
'help' => <<'HELP',
This function splits each segment in the segment range at its midpoint.
HELP
'inargs' => [],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_split_midpoint (gradient,
start_seg,
end_seg,
NULL, NULL);
CODE
);
}
sub gradient_segment_range_split_uniform
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Splits each segment in the segment range uniformly",
'help' => <<'HELP',
This function splits each segment in the segment range uniformly according
to the number of times specified by the parameter.
HELP
'inargs' =>
[
{
'name' => "split_parts",
'type' => "2 <= int32 <= 20",
'desc' => "The number of uniform divisions to split each segment to",
}
],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_split_uniform (gradient,
start_seg,
end_seg,
split_parts,
NULL, NULL);
CODE
);
}
sub gradient_segment_range_delete
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Delete the segment range",
'help' => <<'HELP',
This function deletes a segment range.
HELP
'inargs' => [],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_delete (gradient,
start_seg,
end_seg,
NULL, NULL);
CODE
);
}
sub gradient_segment_range_redistribute_handles
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Uniformly redistribute the segment range's handles",
'help' => <<'HELP',
This function redistributes the handles of the specified segment range of the
specified gradient, so they'll be evenly spaced.
HELP
'inargs' => [],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_redistribute_handles (gradient,
start_seg,
end_seg);
CODE
);
}
sub gradient_segment_range_blend_colors
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Blend the colors of the segment range.",
'help' => <<'HELP',
This function blends the colors (but not the opacity) of the segments'
range of the gradient. Using it, the colors' transition will be uniform
across the range.
HELP
'inargs' => [],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_blend (gradient, start_seg, end_seg,
&start_seg->left_color,
&end_seg->right_color,
TRUE, FALSE);
CODE
);
}
sub gradient_segment_range_blend_opacity
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Blend the opacity of the segment range.",
'help' => <<'HELP',
This function blends the opacity (but not the colors) of the segments'
range of the gradient. Using it, the opacity's transition will be uniform
across the range.
HELP
'inargs' => [],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_blend (gradient, start_seg, end_seg,
&start_seg->left_color,
&end_seg->right_color,
FALSE, TRUE);
CODE
);
}
sub gradient_segment_range_move
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Move the position of an entire segment range by a delta.",
'help' => <<'HELP',
This funtions moves the position of an entire segment range by a delta. The
actual delta (which is returned) will be limited by the control points of the
neighboring segments.
HELP
'inargs' =>
[
{
'name' => "delta",
'type' => "-1.0 <= float <= 1.0",
'desc' => "The delta to move the segment range",
},
{
'name' => "control_compress",
'type' => "boolean",
'desc' => "Whether or not to compress the neighboring segments",
},
],
'outargs' =>
[
{
'name' => "final_delta",
'type' => "float",
'desc' => "The final delta by which the range moved",
},
],
'action_on_success' => <<'CODE',
final_delta = gimp_gradient_segment_range_move (gradient,
start_seg,
end_seg,
delta,
control_compress);
CODE
);
}
@headers = qw(<string.h> "core/gimp.h" "core/gimpcontext.h"
"core/gimpgradient.h" "core/gimpcontainer.h"
"core/gimpdatafactory.h" "core/gimplist.h");
@procs = qw(gradient_segment_get_left_color gradient_segment_set_left_color
gradient_segment_get_right_color gradient_segment_set_right_color
gradient_segment_get_left_pos gradient_segment_set_left_pos
gradient_segment_get_middle_pos gradient_segment_set_middle_pos
gradient_segment_get_right_pos gradient_segment_set_right_pos
gradient_segment_get_blending_function
gradient_segment_set_blending_function
gradient_segment_get_coloring_type
gradient_segment_set_coloring_type
gradient_segment_range_flip
gradient_segment_range_replicate
gradient_segment_range_split_midpoint
gradient_segment_range_split_uniform
gradient_segment_range_delete
gradient_segment_range_redistribute_handles
gradient_segment_range_blend_colors
gradient_segment_range_blend_opacity
gradient_segment_range_move);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Gradient';
1;

View File

@ -0,0 +1,750 @@
# The GIMP -- an image manipulation program
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
sub pdb_misc {
$author = $copyright = 'Shlomi Fish';
$date = '2003';
}
my $_get_gradient_from_name_code = <<'CODE';
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
CODE
sub _gen_gradient_search_for_segment_code
{
my $action_on_success = shift;
return <<"CODE";
{
$_get_gradient_from_name_code
if (gradient)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
if (seg)
{
/* Success */
$action_on_success
}
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
CODE
}
sub other_side
{
my $side = shift;
return ($side eq "left") ? "right" : "left";
}
sub _grad_and_seg_params
{
return
(
{
name => 'name',
type => 'string',
desc => 'The name of the gradient to operate on',
},
{
name => 'segment',
type => '0 <= int32',
desc => 'The index of the segment within the gradient',
},
);
}
sub _gen_gradient_set_side_color
{
my $side = shift;
my $other_side = other_side($side);
$blurb = "Retrieves the $side endpoint color of the specified gradient and segment";
$help = <<"HELP";
This procedure retrieves the $side endpoint color of the specified segment of
the specified gradient.
HELP
&pdb_misc;
@inargs = (
&_grad_and_seg_params,
{
name => 'color',
type => 'color',
desc => "The color to set",
},
{
name => "opacity",
type => '0 <= float <= 100.0',
desc => "The opacity to set for the endpoint",
},
);
@outargs = (
);
my @blend_params = ("&color","&(seg->${other_side}_color)");
if ($side eq "right")
{
@blend_params = reverse(@blend_params);
}
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => &_gen_gradient_search_for_segment_code(<<"CODE"),
color.a = opacity / 100.0;
gimp_gradient_segment_set_${side}_color (gradient, seg, &color);
CODE
);
}
sub _gen_gradient_get_side_color
{
my $side = shift;
$blurb = "Retrieves the $side endpoint color of the specified gradient and segment";
$help = <<"HELP";
This procedure retrieves the $side endpoint color of the specified segment of
the specified gradient.
HELP
&pdb_misc;
@inargs = (
&_grad_and_seg_params,
);
@outargs = (
{
name => 'color',
type => 'color',
desc => "The return color",
void_ret => 1,
init => 1,
},
{
name => "opacity",
type => 'float',
desc => "The opacity of the endpoint",
},
);
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => &_gen_gradient_search_for_segment_code(<<"CODE"),
gimp_gradient_segment_get_${side}_color (gradient, seg, &color);
opacity = color.a * 100.0;
CODE
);
}
sub _gen_gradient_get_pos
{
my $side = shift;
my $side_endpoint =
(($side eq "middle") ?
"middle point" :
"$side endpoint"
);
$blurb = "Retrieves the $side_endpoint position of the specified gradient and segment";
$help = <<"HELP";
This procedure retrieves the $side_endpoint position of the specified segment of
the specified gradient.
HELP
&pdb_misc;
@inargs = &_grad_and_seg_params;
@outargs = (
{
name => 'pos',
type => 'float',
desc => "The return position",
void_ret => 1,
init => 1,
},
);
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => &_gen_gradient_search_for_segment_code(<<"CODE"),
pos = gimp_gradient_segment_get_${side}_pos (gradient, seg);
CODE
);
}
sub _gen_gradient_set_pos
{
my $side = shift;
my $side_endpoint =
(($side eq "middle") ?
"middle point" :
"$side endpoint"
);
$blurb = "Sets the $side_endpoint position of the specified gradient and segment";
my %betweens =
(
'left' => ("the position of the middle point to the left to " .
"the middle point of the current segement"),
'right' => ("the position of the middle point of the current " .
"segment and the middle point of the segment to " .
"the right"),
'middle' => ("the two endpoints of the segment"),
);
$help = <<"HELP";
This procedure sets the $side_endpoint position of the specified segment of
the specified gradient. The final position will be between $betweens{$side}.
This procedure returns the final position.
HELP
&pdb_misc;
@inargs = (
&_grad_and_seg_params,
{
name => 'pos',
type => "0.0 <= float <= 1.0",
desc => "The position to set the guidepoint in."
},
);
@outargs = (
{
name => 'final_pos',
type => 'float',
desc => "The return position",
void_ret => 1,
init => 1,
},
);
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => &_gen_gradient_search_for_segment_code(<<"CODE"),
final_pos = gimp_gradient_segment_set_${side}_pos (gradient, seg, pos);
CODE
);
}
sub gradient_segment_get_left_color
{
&_gen_gradient_get_side_color("left");
}
sub gradient_segment_get_right_color
{
&_gen_gradient_get_side_color("right");
}
sub gradient_segment_set_left_color
{
&_gen_gradient_set_side_color("left");
}
sub gradient_segment_set_right_color
{
&_gen_gradient_set_side_color("right");
}
sub gradient_segment_get_left_pos
{
&_gen_gradient_get_pos("left");
}
sub gradient_segment_get_right_pos
{
&_gen_gradient_get_pos("right");
}
sub gradient_segment_get_middle_pos
{
&_gen_gradient_get_pos("middle");
}
sub gradient_segment_set_left_pos
{
&_gen_gradient_set_pos("left");
}
sub gradient_segment_set_right_pos
{
&_gen_gradient_set_pos("right");
}
sub gradient_segment_set_middle_pos
{
&_gen_gradient_set_pos("middle");
}
sub gradient_segment_get_blending_function
{
$blurb = "Retrieves the gradient segment's blending function";
$help = <<'HELP';
This procedure retrieves the blending function of the segment at the
specified gradient name and segment index.
HELP
&pdb_misc;
@inargs = &_grad_and_seg_params;
@outargs = (
{
name => 'blend_func',
type => "int32",
desc => "The blending function of the segment",
void_ret => 1,
init => 1,
}
);
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => &_gen_gradient_search_for_segment_code(<<"CODE"),
blend_func = gimp_gradient_segment_get_blending_function (gradient, seg);
CODE
);
}
sub gradient_segment_get_coloring_type
{
$blurb = "Retrieves the gradient segment's coloring type";
$help = <<'HELP';
This procedure retrieves the coloring type of the segment at the
specified gradient name and segment index.
HELP
&pdb_misc;
@inargs = &_grad_and_seg_params;
@outargs = (
{
name => 'coloring_type',
type => "int32",
desc => "The coloring type of the segment",
void_ret => 1,
init => 1,
}
);
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => &_gen_gradient_search_for_segment_code(<<"CODE"),
coloring_type = gimp_gradient_segment_get_coloring_type (gradient, seg);
CODE
);
}
sub _gen_gradient_operate_on_segments_range
{
my %args = (@_);
$blurb = $args{blurb};
$help = $args{help};
&pdb_misc;
@inargs =
(
{
name => 'name',
type => 'string',
desc => 'The name of the gradient to operate on.',
},
{
name => 'start_segment',
type => '0 <= int32',
desc => 'The index of the first segment to operate on',
},
{
name => 'end_segment',
type => 'int32',
desc => 'The index of the last segment to operate on. If negative, the selection will extend to the end of the string.',
},
@{$args{inargs}},
);
@outargs = @{$args{outargs}};
%invoke = (
vars => [ 'GimpGradient *gradient = NULL' ],
code => <<"CODE",
{
$_get_gradient_from_name_code
if (gradient)
{
GimpGradientSegment *start_seg, *end_seg;
start_seg = gimp_gradient_segment_get_nth (gradient->segments, start_segment);
if (start_seg)
{
if ((end_segment < start_segment) && (end_segment >= 0))
{
/* Do Nothing */
success = FALSE;
}
else
{
if (end_segment < 0)
{
end_seg = NULL;
}
else
{
end_seg = gimp_gradient_segment_get_nth (start_seg,
end_segment - start_segment);
}
/* Success */
$args{action_on_success}
}
}
else
{
success = FALSE;
}
}
}
CODE
);
}
sub gradient_segment_set_blending_function
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Change the blending function of a segments range",
'help' => <<'HELP',
This function changes the blending function of a segment range to the
specified blending function.
HELP
'inargs' =>
[
{
name => "blending_function",
type => "0 <= int32 <= 4",
desc => "The Blending Function (GRAD-LINEAR, GRAD-CURVED, GRAD-SINE, GRAD-SPHERE-INCREASING, GRAD-SPHERE-DECREASING)"
},
],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_set_blending_function (gradient,
start_seg,
end_seg,
blending_function);
CODE
);
}
sub gradient_segment_set_coloring_type
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Change the coloring type of a segments range",
'help' => <<'HELP',
This function changes the coloring type of a segment range to the
specified coloring type.
HELP
'inargs' =>
[
{
name => "coloring_type",
type => "0 <= int32 <= 2",
desc => "The Coloring Type (GRAD-RGB, GRAD-HSV-CCW, GRAD-HSV-CW)"
},
],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_set_coloring_type (gradient,
start_seg,
end_seg,
coloring_type);
CODE
);
}
sub gradient_segment_range_flip
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Flip the segment range",
'help' => <<'HELP',
This function flips a segment range.
HELP
'inargs' => [],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_flip (gradient,
start_seg,
end_seg,
NULL, NULL);
CODE
);
}
sub gradient_segment_range_replicate
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Replicate the segment range",
'help' => <<'HELP',
This function replicates a segment range a given number of times. Instead
of the original segment range, several smaller scaled copies of it
will appear in equal widths.
HELP
'inargs' =>
[
{
'name' => "replicate_times",
'type' => "2 <= int32 <= 20",
'desc' => "The number of times to replicate",
}
],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_replicate (gradient,
start_seg,
end_seg,
replicate_times,
NULL, NULL);
CODE
);
}
sub gradient_segment_range_split_midpoint
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Splits each segment in the segment range at midpoint",
'help' => <<'HELP',
This function splits each segment in the segment range at its midpoint.
HELP
'inargs' => [],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_split_midpoint (gradient,
start_seg,
end_seg,
NULL, NULL);
CODE
);
}
sub gradient_segment_range_split_uniform
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Splits each segment in the segment range uniformly",
'help' => <<'HELP',
This function splits each segment in the segment range uniformly according
to the number of times specified by the parameter.
HELP
'inargs' =>
[
{
'name' => "split_parts",
'type' => "2 <= int32 <= 20",
'desc' => "The number of uniform divisions to split each segment to",
}
],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_split_uniform (gradient,
start_seg,
end_seg,
split_parts,
NULL, NULL);
CODE
);
}
sub gradient_segment_range_delete
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Delete the segment range",
'help' => <<'HELP',
This function deletes a segment range.
HELP
'inargs' => [],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_delete (gradient,
start_seg,
end_seg,
NULL, NULL);
CODE
);
}
sub gradient_segment_range_redistribute_handles
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Uniformly redistribute the segment range's handles",
'help' => <<'HELP',
This function redistributes the handles of the specified segment range of the
specified gradient, so they'll be evenly spaced.
HELP
'inargs' => [],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_redistribute_handles (gradient,
start_seg,
end_seg);
CODE
);
}
sub gradient_segment_range_blend_colors
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Blend the colors of the segment range.",
'help' => <<'HELP',
This function blends the colors (but not the opacity) of the segments'
range of the gradient. Using it, the colors' transition will be uniform
across the range.
HELP
'inargs' => [],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_blend (gradient, start_seg, end_seg,
&start_seg->left_color,
&end_seg->right_color,
TRUE, FALSE);
CODE
);
}
sub gradient_segment_range_blend_opacity
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Blend the opacity of the segment range.",
'help' => <<'HELP',
This function blends the opacity (but not the colors) of the segments'
range of the gradient. Using it, the opacity's transition will be uniform
across the range.
HELP
'inargs' => [],
'outargs' => [],
'action_on_success' => <<'CODE',
gimp_gradient_segment_range_blend (gradient, start_seg, end_seg,
&start_seg->left_color,
&end_seg->right_color,
FALSE, TRUE);
CODE
);
}
sub gradient_segment_range_move
{
&_gen_gradient_operate_on_segments_range(
'blurb' => "Move the position of an entire segment range by a delta.",
'help' => <<'HELP',
This funtions moves the position of an entire segment range by a delta. The
actual delta (which is returned) will be limited by the control points of the
neighboring segments.
HELP
'inargs' =>
[
{
'name' => "delta",
'type' => "-1.0 <= float <= 1.0",
'desc' => "The delta to move the segment range",
},
{
'name' => "control_compress",
'type' => "boolean",
'desc' => "Whether or not to compress the neighboring segments",
},
],
'outargs' =>
[
{
'name' => "final_delta",
'type' => "float",
'desc' => "The final delta by which the range moved",
},
],
'action_on_success' => <<'CODE',
final_delta = gimp_gradient_segment_range_move (gradient,
start_seg,
end_seg,
delta,
control_compress);
CODE
);
}
@headers = qw(<string.h> "core/gimp.h" "core/gimpcontext.h"
"core/gimpgradient.h" "core/gimpcontainer.h"
"core/gimpdatafactory.h" "core/gimplist.h");
@procs = qw(gradient_segment_get_left_color gradient_segment_set_left_color
gradient_segment_get_right_color gradient_segment_set_right_color
gradient_segment_get_left_pos gradient_segment_set_left_pos
gradient_segment_get_middle_pos gradient_segment_set_middle_pos
gradient_segment_get_right_pos gradient_segment_set_right_pos
gradient_segment_get_blending_function
gradient_segment_set_blending_function
gradient_segment_get_coloring_type
gradient_segment_set_coloring_type
gradient_segment_range_flip
gradient_segment_range_replicate
gradient_segment_range_split_midpoint
gradient_segment_range_split_uniform
gradient_segment_range_delete
gradient_segment_range_redistribute_handles
gradient_segment_range_blend_colors
gradient_segment_range_blend_opacity
gradient_segment_range_move);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Gradient';
1;