mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 17:59:37 +00:00
app: peek/poke much less in GimpGradientEditor internals
Add gimp_gradient_editor_get_selection() and set_selection() and use them in gradient-editor-commands.c
This commit is contained in:
parent
acd3a6f169
commit
025a13b519
3 changed files with 214 additions and 159 deletions
|
@ -64,36 +64,32 @@ gradient_editor_left_color_type_cmd_callback (GtkAction *action,
|
||||||
GtkAction *current,
|
GtkAction *current,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
GimpGradientColor color_type;
|
GimpGradientSegment *left;
|
||||||
|
GimpGradientColor color_type;
|
||||||
|
|
||||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
gimp_gradient_editor_get_selection (editor, &gradient, &left, NULL);
|
||||||
|
|
||||||
color_type = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
|
color_type = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
|
||||||
|
|
||||||
if (gradient &&
|
if (gradient &&
|
||||||
color_type >= 0 &&
|
color_type >= 0 &&
|
||||||
color_type !=
|
color_type !=
|
||||||
gimp_gradient_segment_get_left_color_type (gradient,
|
gimp_gradient_segment_get_left_color_type (gradient, left))
|
||||||
editor->control_sel_l))
|
|
||||||
{
|
{
|
||||||
GimpRGB color;
|
GimpRGB color;
|
||||||
|
|
||||||
gimp_gradient_segment_get_left_flat_color (
|
gimp_gradient_segment_get_left_flat_color (gradient,
|
||||||
gradient, GIMP_DATA_EDITOR (editor)->context, editor->control_sel_l,
|
GIMP_DATA_EDITOR (editor)->context,
|
||||||
&color);
|
left, &color);
|
||||||
|
|
||||||
gimp_data_freeze (GIMP_DATA (gradient));
|
gimp_data_freeze (GIMP_DATA (gradient));
|
||||||
|
|
||||||
gimp_gradient_segment_set_left_color_type (gradient,
|
gimp_gradient_segment_set_left_color_type (gradient, left, color_type);
|
||||||
editor->control_sel_l,
|
|
||||||
color_type);
|
|
||||||
|
|
||||||
if (color_type == GIMP_GRADIENT_COLOR_FIXED)
|
if (color_type == GIMP_GRADIENT_COLOR_FIXED)
|
||||||
gimp_gradient_segment_set_left_color (gradient,
|
gimp_gradient_segment_set_left_color (gradient, left, &color);
|
||||||
editor->control_sel_l,
|
|
||||||
&color);
|
|
||||||
|
|
||||||
gimp_data_thaw (GIMP_DATA (gradient));
|
gimp_data_thaw (GIMP_DATA (gradient));
|
||||||
}
|
}
|
||||||
|
@ -107,27 +103,29 @@ gradient_editor_load_left_cmd_callback (GtkAction *action,
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data);
|
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data);
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
|
GimpGradientSegment *left;
|
||||||
|
GimpGradientSegment *right;
|
||||||
GimpGradientSegment *seg;
|
GimpGradientSegment *seg;
|
||||||
GimpRGB color;
|
GimpRGB color;
|
||||||
GimpGradientColor color_type = GIMP_GRADIENT_COLOR_FIXED;
|
GimpGradientColor color_type = GIMP_GRADIENT_COLOR_FIXED;
|
||||||
|
|
||||||
gradient = GIMP_GRADIENT (data_editor->data);
|
gimp_gradient_editor_get_selection (editor, &gradient, &left, &right);
|
||||||
|
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
case GRADIENT_EDITOR_COLOR_NEIGHBOR_ENDPOINT:
|
case GRADIENT_EDITOR_COLOR_NEIGHBOR_ENDPOINT:
|
||||||
if (editor->control_sel_l->prev != NULL)
|
if (left->prev != NULL)
|
||||||
seg = editor->control_sel_l->prev;
|
seg = left->prev;
|
||||||
else
|
else
|
||||||
seg = gimp_gradient_segment_get_last (editor->control_sel_l);
|
seg = gimp_gradient_segment_get_last (left);
|
||||||
|
|
||||||
color = seg->right_color;
|
color = seg->right_color;
|
||||||
color_type = seg->right_color_type;
|
color_type = seg->right_color_type;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GRADIENT_EDITOR_COLOR_OTHER_ENDPOINT:
|
case GRADIENT_EDITOR_COLOR_OTHER_ENDPOINT:
|
||||||
color = editor->control_sel_r->right_color;
|
color = right->right_color;
|
||||||
color_type = editor->control_sel_l->right_color_type;
|
color_type = right->right_color_type;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GRADIENT_EDITOR_COLOR_FOREGROUND:
|
case GRADIENT_EDITOR_COLOR_FOREGROUND:
|
||||||
|
@ -145,15 +143,11 @@ gradient_editor_load_left_cmd_callback (GtkAction *action,
|
||||||
|
|
||||||
gimp_data_freeze (GIMP_DATA (gradient));
|
gimp_data_freeze (GIMP_DATA (gradient));
|
||||||
|
|
||||||
gimp_gradient_segment_range_blend (gradient,
|
gimp_gradient_segment_range_blend (gradient, left, right,
|
||||||
editor->control_sel_l,
|
|
||||||
editor->control_sel_r,
|
|
||||||
&color,
|
&color,
|
||||||
&editor->control_sel_r->right_color,
|
&right->right_color,
|
||||||
TRUE, TRUE);
|
TRUE, TRUE);
|
||||||
gimp_gradient_segment_set_left_color_type (gradient,
|
gimp_gradient_segment_set_left_color_type (gradient, left, color_type);
|
||||||
editor->control_sel_l,
|
|
||||||
color_type);
|
|
||||||
|
|
||||||
gimp_data_thaw (GIMP_DATA (gradient));
|
gimp_data_thaw (GIMP_DATA (gradient));
|
||||||
}
|
}
|
||||||
|
@ -163,12 +157,13 @@ gradient_editor_save_left_cmd_callback (GtkAction *action,
|
||||||
gint value,
|
gint value,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
|
GimpGradientSegment *left;
|
||||||
|
|
||||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
gimp_gradient_editor_get_selection (editor, &gradient, &left, NULL);
|
||||||
|
|
||||||
gimp_gradient_segment_get_left_color (gradient, editor->control_sel_l,
|
gimp_gradient_segment_get_left_color (gradient, left,
|
||||||
&editor->saved_colors[value]);
|
&editor->saved_colors[value]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,36 +181,32 @@ gradient_editor_right_color_type_cmd_callback (GtkAction *action,
|
||||||
GtkAction *current,
|
GtkAction *current,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
GimpGradientColor color_type;
|
GimpGradientSegment *right;
|
||||||
|
GimpGradientColor color_type;
|
||||||
|
|
||||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
gimp_gradient_editor_get_selection (editor, &gradient, NULL, &right);
|
||||||
|
|
||||||
color_type = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
|
color_type = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
|
||||||
|
|
||||||
if (gradient &&
|
if (gradient &&
|
||||||
color_type >= 0 &&
|
color_type >= 0 &&
|
||||||
color_type !=
|
color_type !=
|
||||||
gimp_gradient_segment_get_right_color_type (gradient,
|
gimp_gradient_segment_get_right_color_type (gradient, right))
|
||||||
editor->control_sel_r))
|
|
||||||
{
|
{
|
||||||
GimpRGB color;
|
GimpRGB color;
|
||||||
|
|
||||||
gimp_gradient_segment_get_right_flat_color (
|
gimp_gradient_segment_get_right_flat_color (gradient,
|
||||||
gradient, GIMP_DATA_EDITOR (editor)->context, editor->control_sel_r,
|
GIMP_DATA_EDITOR (editor)->context,
|
||||||
&color);
|
right, &color);
|
||||||
|
|
||||||
gimp_data_freeze (GIMP_DATA (gradient));
|
gimp_data_freeze (GIMP_DATA (gradient));
|
||||||
|
|
||||||
gimp_gradient_segment_set_right_color_type (gradient,
|
gimp_gradient_segment_set_right_color_type (gradient, right, color_type);
|
||||||
editor->control_sel_r,
|
|
||||||
color_type);
|
|
||||||
|
|
||||||
if (color_type == GIMP_GRADIENT_COLOR_FIXED)
|
if (color_type == GIMP_GRADIENT_COLOR_FIXED)
|
||||||
gimp_gradient_segment_set_right_color (gradient,
|
gimp_gradient_segment_set_right_color (gradient, right, &color);
|
||||||
editor->control_sel_r,
|
|
||||||
&color);
|
|
||||||
|
|
||||||
gimp_data_thaw (GIMP_DATA (gradient));
|
gimp_data_thaw (GIMP_DATA (gradient));
|
||||||
}
|
}
|
||||||
|
@ -229,27 +220,29 @@ gradient_editor_load_right_cmd_callback (GtkAction *action,
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data);
|
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data);
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
|
GimpGradientSegment *left;
|
||||||
|
GimpGradientSegment *right;
|
||||||
GimpGradientSegment *seg;
|
GimpGradientSegment *seg;
|
||||||
GimpRGB color;
|
GimpRGB color;
|
||||||
GimpGradientColor color_type = GIMP_GRADIENT_COLOR_FIXED;
|
GimpGradientColor color_type = GIMP_GRADIENT_COLOR_FIXED;
|
||||||
|
|
||||||
gradient = GIMP_GRADIENT (data_editor->data);
|
gimp_gradient_editor_get_selection (editor, &gradient, &left, &right);
|
||||||
|
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
case GRADIENT_EDITOR_COLOR_NEIGHBOR_ENDPOINT:
|
case GRADIENT_EDITOR_COLOR_NEIGHBOR_ENDPOINT:
|
||||||
if (editor->control_sel_r->next != NULL)
|
if (right->next != NULL)
|
||||||
seg = editor->control_sel_r->next;
|
seg = right->next;
|
||||||
else
|
else
|
||||||
seg = gimp_gradient_segment_get_first (editor->control_sel_r);
|
seg = gimp_gradient_segment_get_first (right);
|
||||||
|
|
||||||
color = seg->left_color;
|
color = seg->left_color;
|
||||||
color_type = seg->left_color_type;
|
color_type = seg->left_color_type;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GRADIENT_EDITOR_COLOR_OTHER_ENDPOINT:
|
case GRADIENT_EDITOR_COLOR_OTHER_ENDPOINT:
|
||||||
color = editor->control_sel_l->left_color;
|
color = left->left_color;
|
||||||
color_type = editor->control_sel_l->left_color_type;
|
color_type = left->left_color_type;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GRADIENT_EDITOR_COLOR_FOREGROUND:
|
case GRADIENT_EDITOR_COLOR_FOREGROUND:
|
||||||
|
@ -267,15 +260,11 @@ gradient_editor_load_right_cmd_callback (GtkAction *action,
|
||||||
|
|
||||||
gimp_data_freeze (GIMP_DATA (gradient));
|
gimp_data_freeze (GIMP_DATA (gradient));
|
||||||
|
|
||||||
gimp_gradient_segment_range_blend (gradient,
|
gimp_gradient_segment_range_blend (gradient, left, right,
|
||||||
editor->control_sel_l,
|
&left->left_color,
|
||||||
editor->control_sel_r,
|
|
||||||
&editor->control_sel_l->left_color,
|
|
||||||
&color,
|
&color,
|
||||||
TRUE, TRUE);
|
TRUE, TRUE);
|
||||||
gimp_gradient_segment_set_right_color_type (gradient,
|
gimp_gradient_segment_set_right_color_type (gradient, left, color_type);
|
||||||
editor->control_sel_l,
|
|
||||||
color_type);
|
|
||||||
|
|
||||||
gimp_data_thaw (GIMP_DATA (gradient));
|
gimp_data_thaw (GIMP_DATA (gradient));
|
||||||
}
|
}
|
||||||
|
@ -285,12 +274,13 @@ gradient_editor_save_right_cmd_callback (GtkAction *action,
|
||||||
gint value,
|
gint value,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
|
GimpGradientSegment *right;
|
||||||
|
|
||||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
gimp_gradient_editor_get_selection (editor, &gradient, NULL, &right);
|
||||||
|
|
||||||
gimp_gradient_segment_get_right_color (gradient, editor->control_sel_r,
|
gimp_gradient_segment_get_right_color (gradient, right,
|
||||||
&editor->saved_colors[value]);
|
&editor->saved_colors[value]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,10 +291,12 @@ gradient_editor_blending_func_cmd_callback (GtkAction *action,
|
||||||
{
|
{
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
|
GimpGradientSegment *left;
|
||||||
|
GimpGradientSegment *right;
|
||||||
GEnumClass *enum_class = NULL;
|
GEnumClass *enum_class = NULL;
|
||||||
GimpGradientSegmentType type;
|
GimpGradientSegmentType type;
|
||||||
|
|
||||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
gimp_gradient_editor_get_selection (editor, &gradient, &left, &right);
|
||||||
|
|
||||||
type = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
|
type = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
|
||||||
|
|
||||||
|
@ -313,8 +305,7 @@ gradient_editor_blending_func_cmd_callback (GtkAction *action,
|
||||||
if (gradient && g_enum_get_value (enum_class, type))
|
if (gradient && g_enum_get_value (enum_class, type))
|
||||||
{
|
{
|
||||||
gimp_gradient_segment_range_set_blending_function (gradient,
|
gimp_gradient_segment_range_set_blending_function (gradient,
|
||||||
editor->control_sel_l,
|
left, right,
|
||||||
editor->control_sel_r,
|
|
||||||
type);
|
type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,10 +319,12 @@ gradient_editor_coloring_type_cmd_callback (GtkAction *action,
|
||||||
{
|
{
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
|
GimpGradientSegment *left;
|
||||||
|
GimpGradientSegment *right;
|
||||||
GEnumClass *enum_class = NULL;
|
GEnumClass *enum_class = NULL;
|
||||||
GimpGradientSegmentColor color;
|
GimpGradientSegmentColor color;
|
||||||
|
|
||||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
gimp_gradient_editor_get_selection (editor, &gradient, &left, &right);
|
||||||
|
|
||||||
color = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
|
color = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
|
||||||
|
|
||||||
|
@ -340,8 +333,7 @@ gradient_editor_coloring_type_cmd_callback (GtkAction *action,
|
||||||
if (gradient && g_enum_get_value (enum_class, color))
|
if (gradient && g_enum_get_value (enum_class, color))
|
||||||
{
|
{
|
||||||
gimp_gradient_segment_range_set_coloring_type (gradient,
|
gimp_gradient_segment_range_set_coloring_type (gradient,
|
||||||
editor->control_sel_l,
|
left, right,
|
||||||
editor->control_sel_r,
|
|
||||||
color);
|
color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,33 +344,39 @@ void
|
||||||
gradient_editor_flip_cmd_callback (GtkAction *action,
|
gradient_editor_flip_cmd_callback (GtkAction *action,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
|
GimpGradientSegment *left;
|
||||||
|
GimpGradientSegment *right;
|
||||||
|
|
||||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
gimp_gradient_editor_get_selection (editor, &gradient, &left, &right);
|
||||||
|
|
||||||
gimp_gradient_segment_range_flip (gradient,
|
gimp_gradient_segment_range_flip (gradient,
|
||||||
editor->control_sel_l,
|
left, right,
|
||||||
editor->control_sel_r,
|
&left, &right);
|
||||||
&editor->control_sel_l,
|
|
||||||
&editor->control_sel_r);
|
gimp_gradient_editor_set_selection (editor, left, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gradient_editor_replicate_cmd_callback (GtkAction *action,
|
gradient_editor_replicate_cmd_callback (GtkAction *action,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data);
|
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data);
|
||||||
GtkWidget *dialog;
|
GimpGradientSegment *left;
|
||||||
GtkWidget *vbox;
|
GimpGradientSegment *right;
|
||||||
GtkWidget *label;
|
GtkWidget *dialog;
|
||||||
GtkWidget *scale;
|
GtkWidget *vbox;
|
||||||
GtkAdjustment *scale_data;
|
GtkWidget *label;
|
||||||
const gchar *title;
|
GtkWidget *scale;
|
||||||
const gchar *desc;
|
GtkAdjustment *scale_data;
|
||||||
|
const gchar *title;
|
||||||
|
const gchar *desc;
|
||||||
|
|
||||||
if (editor->control_sel_l == editor->control_sel_r)
|
gimp_gradient_editor_get_selection (editor, NULL, &left, &right);
|
||||||
|
|
||||||
|
if (left == right)
|
||||||
{
|
{
|
||||||
title = _("Replicate Segment");
|
title = _("Replicate Segment");
|
||||||
desc = _("Replicate Gradient Segment");
|
desc = _("Replicate Gradient Segment");
|
||||||
|
@ -419,7 +417,7 @@ gradient_editor_replicate_cmd_callback (GtkAction *action,
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
|
||||||
/* Instructions */
|
/* Instructions */
|
||||||
if (editor->control_sel_l == editor->control_sel_r)
|
if (left == right)
|
||||||
label = gtk_label_new (_("Select the number of times\n"
|
label = gtk_label_new (_("Select the number of times\n"
|
||||||
"to replicate the selected segment."));
|
"to replicate the selected segment."));
|
||||||
else
|
else
|
||||||
|
@ -454,34 +452,42 @@ void
|
||||||
gradient_editor_split_midpoint_cmd_callback (GtkAction *action,
|
gradient_editor_split_midpoint_cmd_callback (GtkAction *action,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data);
|
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data);
|
||||||
GimpGradient *gradient = GIMP_GRADIENT (data_editor->data);
|
GimpGradient *gradient;
|
||||||
|
GimpGradientSegment *left;
|
||||||
|
GimpGradientSegment *right;
|
||||||
|
|
||||||
|
gimp_gradient_editor_get_selection (editor, &gradient, &left, &right);
|
||||||
|
|
||||||
gimp_gradient_segment_range_split_midpoint (gradient,
|
gimp_gradient_segment_range_split_midpoint (gradient,
|
||||||
data_editor->context,
|
data_editor->context,
|
||||||
editor->control_sel_l,
|
left, right,
|
||||||
editor->control_sel_r,
|
|
||||||
editor->blend_color_space,
|
editor->blend_color_space,
|
||||||
&editor->control_sel_l,
|
&left, &right);
|
||||||
&editor->control_sel_r);
|
|
||||||
|
gimp_gradient_editor_set_selection (editor, left, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gradient_editor_split_uniformly_cmd_callback (GtkAction *action,
|
gradient_editor_split_uniformly_cmd_callback (GtkAction *action,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data);
|
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data);
|
||||||
GtkWidget *dialog;
|
GimpGradientSegment *left;
|
||||||
GtkWidget *vbox;
|
GimpGradientSegment *right;
|
||||||
GtkWidget *label;
|
GtkWidget *dialog;
|
||||||
GtkWidget *scale;
|
GtkWidget *vbox;
|
||||||
GtkAdjustment *scale_data;
|
GtkWidget *label;
|
||||||
const gchar *title;
|
GtkWidget *scale;
|
||||||
const gchar *desc;
|
GtkAdjustment *scale_data;
|
||||||
|
const gchar *title;
|
||||||
|
const gchar *desc;
|
||||||
|
|
||||||
if (editor->control_sel_l == editor->control_sel_r)
|
gimp_gradient_editor_get_selection (editor, NULL, &left, &right);
|
||||||
|
|
||||||
|
if (left == right)
|
||||||
{
|
{
|
||||||
title = _("Split Segment Uniformly");
|
title = _("Split Segment Uniformly");
|
||||||
desc = _("Split Gradient Segment Uniformly");
|
desc = _("Split Gradient Segment Uniformly");
|
||||||
|
@ -523,7 +529,7 @@ gradient_editor_split_uniformly_cmd_callback (GtkAction *action,
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
|
||||||
/* Instructions */
|
/* Instructions */
|
||||||
if (editor->control_sel_l == editor->control_sel_r)
|
if (left == right)
|
||||||
label = gtk_label_new (_("Select the number of uniform parts\n"
|
label = gtk_label_new (_("Select the number of uniform parts\n"
|
||||||
"in which to split the selected segment."));
|
"in which to split the selected segment."));
|
||||||
else
|
else
|
||||||
|
@ -558,60 +564,62 @@ void
|
||||||
gradient_editor_delete_cmd_callback (GtkAction *action,
|
gradient_editor_delete_cmd_callback (GtkAction *action,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
|
GimpGradientSegment *left;
|
||||||
|
GimpGradientSegment *right;
|
||||||
|
|
||||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
gimp_gradient_editor_get_selection (editor, &gradient, &left, &right);
|
||||||
|
|
||||||
gimp_gradient_segment_range_delete (gradient,
|
gimp_gradient_segment_range_delete (gradient,
|
||||||
editor->control_sel_l,
|
left, right,
|
||||||
editor->control_sel_r,
|
&left, &right);
|
||||||
&editor->control_sel_l,
|
|
||||||
&editor->control_sel_r);
|
gimp_gradient_editor_set_selection (editor, left, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gradient_editor_recenter_cmd_callback (GtkAction *action,
|
gradient_editor_recenter_cmd_callback (GtkAction *action,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
|
GimpGradientSegment *left;
|
||||||
|
GimpGradientSegment *right;
|
||||||
|
|
||||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
gimp_gradient_editor_get_selection (editor, &gradient, &left, &right);
|
||||||
|
|
||||||
gimp_gradient_segment_range_recenter_handles (gradient,
|
gimp_gradient_segment_range_recenter_handles (gradient, left, right);
|
||||||
editor->control_sel_l,
|
|
||||||
editor->control_sel_r);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gradient_editor_redistribute_cmd_callback (GtkAction *action,
|
gradient_editor_redistribute_cmd_callback (GtkAction *action,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
|
GimpGradientSegment *left;
|
||||||
|
GimpGradientSegment *right;
|
||||||
|
|
||||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
gimp_gradient_editor_get_selection (editor, &gradient, &left, &right);
|
||||||
|
|
||||||
gimp_gradient_segment_range_redistribute_handles (gradient,
|
gimp_gradient_segment_range_redistribute_handles (gradient, left, right);
|
||||||
editor->control_sel_l,
|
|
||||||
editor->control_sel_r);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gradient_editor_blend_color_cmd_callback (GtkAction *action,
|
gradient_editor_blend_color_cmd_callback (GtkAction *action,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
|
GimpGradientSegment *left;
|
||||||
|
GimpGradientSegment *right;
|
||||||
|
|
||||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
gimp_gradient_editor_get_selection (editor, &gradient, &left, &right);
|
||||||
|
|
||||||
gimp_gradient_segment_range_blend (gradient,
|
gimp_gradient_segment_range_blend (gradient, left, right,
|
||||||
editor->control_sel_l,
|
&left->left_color,
|
||||||
editor->control_sel_r,
|
&right->right_color,
|
||||||
&editor->control_sel_l->left_color,
|
|
||||||
&editor->control_sel_r->right_color,
|
|
||||||
TRUE, FALSE);
|
TRUE, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,16 +627,16 @@ void
|
||||||
gradient_editor_blend_opacity_cmd_callback (GtkAction *action,
|
gradient_editor_blend_opacity_cmd_callback (GtkAction *action,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
|
||||||
GimpGradient *gradient;
|
GimpGradient *gradient;
|
||||||
|
GimpGradientSegment *left;
|
||||||
|
GimpGradientSegment *right;
|
||||||
|
|
||||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
gimp_gradient_editor_get_selection (editor, &gradient, &left, &right);
|
||||||
|
|
||||||
gimp_gradient_segment_range_blend (gradient,
|
gimp_gradient_segment_range_blend (gradient, left, right,
|
||||||
editor->control_sel_l,
|
&left->left_color,
|
||||||
editor->control_sel_r,
|
&right->right_color,
|
||||||
&editor->control_sel_l->left_color,
|
|
||||||
&editor->control_sel_r->right_color,
|
|
||||||
FALSE, TRUE);
|
FALSE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,17 +665,21 @@ gradient_editor_split_uniform_response (GtkWidget *widget,
|
||||||
|
|
||||||
if (response_id == GTK_RESPONSE_OK)
|
if (response_id == GTK_RESPONSE_OK)
|
||||||
{
|
{
|
||||||
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor);
|
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor);
|
||||||
GimpGradient *gradient = GIMP_GRADIENT (data_editor->data);
|
GimpGradient *gradient;
|
||||||
|
GimpGradientSegment *left;
|
||||||
|
GimpGradientSegment *right;
|
||||||
|
|
||||||
|
gimp_gradient_editor_get_selection (editor, &gradient, &left, &right);
|
||||||
|
|
||||||
gimp_gradient_segment_range_split_uniform (gradient,
|
gimp_gradient_segment_range_split_uniform (gradient,
|
||||||
data_editor->context,
|
data_editor->context,
|
||||||
editor->control_sel_l,
|
left, right,
|
||||||
editor->control_sel_r,
|
|
||||||
editor->split_parts,
|
editor->split_parts,
|
||||||
editor->blend_color_space,
|
editor->blend_color_space,
|
||||||
&editor->control_sel_l,
|
&left, &right);
|
||||||
&editor->control_sel_r);
|
|
||||||
|
gimp_gradient_editor_set_selection (editor, left, right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -683,13 +695,17 @@ gradient_editor_replicate_response (GtkWidget *widget,
|
||||||
|
|
||||||
if (response_id == GTK_RESPONSE_OK)
|
if (response_id == GTK_RESPONSE_OK)
|
||||||
{
|
{
|
||||||
GimpGradient *gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
GimpGradient *gradient;
|
||||||
|
GimpGradientSegment *left;
|
||||||
|
GimpGradientSegment *right;
|
||||||
|
|
||||||
|
gimp_gradient_editor_get_selection (editor, &gradient, &left, &right);
|
||||||
|
|
||||||
gimp_gradient_segment_range_replicate (gradient,
|
gimp_gradient_segment_range_replicate (gradient,
|
||||||
editor->control_sel_l,
|
left, right,
|
||||||
editor->control_sel_r,
|
|
||||||
editor->replicate_times,
|
editor->replicate_times,
|
||||||
&editor->control_sel_l,
|
&left, &right);
|
||||||
&editor->control_sel_r);
|
|
||||||
|
gimp_gradient_editor_set_selection (editor, left, right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,6 +551,37 @@ gimp_gradient_editor_new (GimpContext *context,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_gradient_editor_get_selection (GimpGradientEditor *editor,
|
||||||
|
GimpGradient **gradient,
|
||||||
|
GimpGradientSegment **left,
|
||||||
|
GimpGradientSegment **right)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_GRADIENT_EDITOR (editor));
|
||||||
|
|
||||||
|
if (gradient)
|
||||||
|
*gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
||||||
|
|
||||||
|
if (left)
|
||||||
|
*left = editor->control_sel_l;
|
||||||
|
|
||||||
|
if (right)
|
||||||
|
*right = editor->control_sel_r;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_gradient_editor_set_selection (GimpGradientEditor *editor,
|
||||||
|
GimpGradientSegment *left,
|
||||||
|
GimpGradientSegment *right)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_GRADIENT_EDITOR (editor));
|
||||||
|
g_return_if_fail (left != NULL);
|
||||||
|
g_return_if_fail (right != NULL);
|
||||||
|
|
||||||
|
editor->control_sel_l = left;
|
||||||
|
editor->control_sel_r = right;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_gradient_editor_edit_left_color (GimpGradientEditor *editor)
|
gimp_gradient_editor_edit_left_color (GimpGradientEditor *editor)
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,15 +108,23 @@ struct _GimpGradientEditorClass
|
||||||
|
|
||||||
GType gimp_gradient_editor_get_type (void) G_GNUC_CONST;
|
GType gimp_gradient_editor_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GtkWidget * gimp_gradient_editor_new (GimpContext *context,
|
GtkWidget * gimp_gradient_editor_new (GimpContext *context,
|
||||||
GimpMenuFactory *menu_factory);
|
GimpMenuFactory *menu_factory);
|
||||||
|
|
||||||
void gimp_gradient_editor_edit_left_color (GimpGradientEditor *editor);
|
void gimp_gradient_editor_get_selection (GimpGradientEditor *editor,
|
||||||
void gimp_gradient_editor_edit_right_color (GimpGradientEditor *editor);
|
GimpGradient **gradient,
|
||||||
|
GimpGradientSegment **left,
|
||||||
|
GimpGradientSegment **right);
|
||||||
|
void gimp_gradient_editor_set_selection (GimpGradientEditor *editor,
|
||||||
|
GimpGradientSegment *left,
|
||||||
|
GimpGradientSegment *right);
|
||||||
|
|
||||||
void gimp_gradient_editor_zoom (GimpGradientEditor *editor,
|
void gimp_gradient_editor_edit_left_color (GimpGradientEditor *editor);
|
||||||
GimpZoomType zoom_type,
|
void gimp_gradient_editor_edit_right_color (GimpGradientEditor *editor);
|
||||||
gdouble delta);
|
|
||||||
|
void gimp_gradient_editor_zoom (GimpGradientEditor *editor,
|
||||||
|
GimpZoomType zoom_type,
|
||||||
|
gdouble delta);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_GRADIENT_EDITOR_H__ */
|
#endif /* __GIMP_GRADIENT_EDITOR_H__ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue