Commit 7166f7ac authored by Michael Natterer's avatar Michael Natterer Committed by Michael Natterer

app/actions/context-actions.c added tons of new actions to modify the

2004-06-18  Michael Natterer  <mitch@gimp.org>

	* app/actions/context-actions.c
	* app/actions/context-commands.[ch]: added tons of new actions to
	modify the current FG/BG color's RGB components.

	Added new enum value GIMP_CONTEXT_SELECT_SET which allows to set
	values, not only increase/decrease them.

	Changed context_select_value() utility function to interpret
	GimpEnumAction::value being >= GIMP_CONTEXT_SELECT_SET as settings
	in a range from 0 to 1000. Yes, that's a hack...
parent 31fd8787
2004-06-18 Michael Natterer <mitch@gimp.org>
* app/actions/context-actions.c
* app/actions/context-commands.[ch]: added tons of new actions to
modify the current FG/BG color's RGB components.
Added new enum value GIMP_CONTEXT_SELECT_SET which allows to set
values, not only increase/decrease them.
Changed context_select_value() utility function to interpret
GimpEnumAction::value being >= GIMP_CONTEXT_SELECT_SET as settings
in a range from 0 to 1000. Yes, that's a hack...
2004-06-18 Philip Lafleur <plafleur@cvs.gnome.org>
* app/tools/gimptransformtool.c: reverted my fix to bug #144570.
......
......@@ -63,8 +63,204 @@ static GimpActionEntry context_actions[] =
GIMP_HELP_TOOLBOX_SWAP_COLORS }
};
static GimpEnumActionEntry context_foreground_red_actions[] =
{
{ "context-foreground-red-set", NULL,
"Set Foreground Red", NULL, NULL,
GIMP_CONTEXT_SELECT_SET,
NULL },
{ "context-foreground-red-minimum", GTK_STOCK_GOTO_FIRST,
"Foreground Red Minimum", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-foreground-red-maximum", GTK_STOCK_GOTO_LAST,
"Foreground Red Maximum", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-foreground-red-decrease", GTK_STOCK_REMOVE,
"Foreground Red Decrease", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-foreground-red-increase", GTK_STOCK_ADD,
"Foreground Red Increase", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL },
{ "context-foreground-red-decrease-skip", GTK_STOCK_REMOVE,
"Foreground Red Decrease 10%", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_PREVIOUS,
NULL },
{ "context-foreground-red-increase-skip", GTK_STOCK_ADD,
"Foreground Red Increase 10%", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_NEXT,
NULL }
};
static GimpEnumActionEntry context_foreground_green_actions[] =
{
{ "context-foreground-green-set", NULL,
"Set Foreground Green", NULL, NULL,
GIMP_CONTEXT_SELECT_SET,
NULL },
{ "context-foreground-green-minimum", GTK_STOCK_GOTO_FIRST,
"Foreground Green Minimum", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-foreground-green-maximum", GTK_STOCK_GOTO_LAST,
"Foreground Green Maximum", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-foreground-green-decrease", GTK_STOCK_REMOVE,
"Foreground Green Decrease", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-foreground-green-increase", GTK_STOCK_ADD,
"Foreground Green Increase", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL },
{ "context-foreground-green-decrease-skip", GTK_STOCK_REMOVE,
"Foreground Green Decrease 10%", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_PREVIOUS,
NULL },
{ "context-foreground-green-increase-skip", GTK_STOCK_ADD,
"Foreground Green Increase 10%", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_NEXT,
NULL }
};
static GimpEnumActionEntry context_foreground_blue_actions[] =
{
{ "context-foreground-blue-set", NULL,
"Set Foreground Blue", NULL, NULL,
GIMP_CONTEXT_SELECT_SET,
NULL },
{ "context-foreground-blue-minimum", GTK_STOCK_GOTO_FIRST,
"Foreground Blue Minimum", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-foreground-blue-maximum", GTK_STOCK_GOTO_LAST,
"Foreground Blue Maximum", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-foreground-blue-decrease", GTK_STOCK_REMOVE,
"Foreground Blue Decrease", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-foreground-blue-increase", GTK_STOCK_ADD,
"Foreground Blue Increase", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL },
{ "context-foreground-blue-decrease-skip", GTK_STOCK_REMOVE,
"Foreground Blue Decrease 10%", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_PREVIOUS,
NULL },
{ "context-foreground-blue-increase-skip", GTK_STOCK_ADD,
"Foreground Blue Increase 10%", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_NEXT,
NULL }
};
static GimpEnumActionEntry context_background_red_actions[] =
{
{ "context-background-red-set", NULL,
"Set Background Red", NULL, NULL,
GIMP_CONTEXT_SELECT_SET,
NULL },
{ "context-background-red-minimum", GTK_STOCK_GOTO_FIRST,
"Background Red Minimum", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-background-red-maximum", GTK_STOCK_GOTO_LAST,
"Background Red Maximum", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-background-red-decrease", GTK_STOCK_REMOVE,
"Background Red Decrease", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-background-red-increase", GTK_STOCK_ADD,
"Background Red Increase", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL },
{ "context-background-red-decrease-skip", GTK_STOCK_REMOVE,
"Background Red Decrease 10%", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_PREVIOUS,
NULL },
{ "context-background-red-increase-skip", GTK_STOCK_ADD,
"Background Red Increase 10%", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_NEXT,
NULL }
};
static GimpEnumActionEntry context_background_green_actions[] =
{
{ "context-background-green-set", NULL,
"Set Background Green", NULL, NULL,
GIMP_CONTEXT_SELECT_SET,
NULL },
{ "context-background-green-minimum", GTK_STOCK_GOTO_FIRST,
"Background Green Minimum", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-background-green-maximum", GTK_STOCK_GOTO_LAST,
"Background Green Maximum", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-background-green-decrease", GTK_STOCK_REMOVE,
"Background Green Decrease", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-background-green-increase", GTK_STOCK_ADD,
"Background Green Increase", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL },
{ "context-background-green-decrease-skip", GTK_STOCK_REMOVE,
"Background Green Decrease 10%", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_PREVIOUS,
NULL },
{ "context-background-green-increase-skip", GTK_STOCK_ADD,
"Background Green Increase 10%", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_NEXT,
NULL }
};
static GimpEnumActionEntry context_background_blue_actions[] =
{
{ "context-background-blue-set", NULL,
"Set Background Blue", NULL, NULL,
GIMP_CONTEXT_SELECT_SET,
NULL },
{ "context-background-blue-minimum", GTK_STOCK_GOTO_FIRST,
"Background Blue Minimum", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
NULL },
{ "context-background-blue-maximum", GTK_STOCK_GOTO_LAST,
"Background Blue Maximum", NULL, NULL,
GIMP_CONTEXT_SELECT_LAST,
NULL },
{ "context-background-blue-decrease", GTK_STOCK_REMOVE,
"Background Blue Decrease", NULL, NULL,
GIMP_CONTEXT_SELECT_PREVIOUS,
NULL },
{ "context-background-blue-increase", GTK_STOCK_ADD,
"Background Blue Increase", NULL, NULL,
GIMP_CONTEXT_SELECT_NEXT,
NULL },
{ "context-background-blue-decrease-skip", GTK_STOCK_REMOVE,
"Background Blue Decrease 10%", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_PREVIOUS,
NULL },
{ "context-background-blue-increase-skip", GTK_STOCK_ADD,
"Background Blue Increase 10%", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_NEXT,
NULL }
};
static GimpEnumActionEntry context_opacity_actions[] =
{
{ "context-opacity-set", NULL,
"Set Transparency", NULL, NULL,
GIMP_CONTEXT_SELECT_SET,
NULL },
{ "context-opacity-transparent", GTK_STOCK_GOTO_FIRST,
"Completely Transparent", NULL, NULL,
GIMP_CONTEXT_SELECT_FIRST,
......@@ -82,11 +278,11 @@ static GimpEnumActionEntry context_opacity_actions[] =
GIMP_CONTEXT_SELECT_NEXT,
NULL },
{ "context-opacity-decrease-skip", GTK_STOCK_REMOVE,
"Much More Transparent", NULL, NULL,
"10% More Transparent", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_PREVIOUS,
NULL },
{ "context-opacity-increase-skip", GTK_STOCK_ADD,
"Much More Opaque", NULL, NULL,
"10% More Opaque", NULL, NULL,
GIMP_CONTEXT_SELECT_SKIP_NEXT,
NULL }
};
......@@ -331,6 +527,32 @@ context_actions_setup (GimpActionGroup *group)
context_actions,
G_N_ELEMENTS (context_actions));
gimp_action_group_add_enum_actions (group,
context_foreground_red_actions,
G_N_ELEMENTS (context_foreground_red_actions),
G_CALLBACK (context_foreground_red_cmd_callback));
gimp_action_group_add_enum_actions (group,
context_foreground_green_actions,
G_N_ELEMENTS (context_foreground_green_actions),
G_CALLBACK (context_foreground_green_cmd_callback));
gimp_action_group_add_enum_actions (group,
context_foreground_blue_actions,
G_N_ELEMENTS (context_foreground_blue_actions),
G_CALLBACK (context_foreground_blue_cmd_callback));
gimp_action_group_add_enum_actions (group,
context_background_red_actions,
G_N_ELEMENTS (context_background_red_actions),
G_CALLBACK (context_background_red_cmd_callback));
gimp_action_group_add_enum_actions (group,
context_background_green_actions,
G_N_ELEMENTS (context_background_green_actions),
G_CALLBACK (context_background_green_cmd_callback));
gimp_action_group_add_enum_actions (group,
context_background_blue_actions,
G_N_ELEMENTS (context_background_blue_actions),
G_CALLBACK (context_background_blue_cmd_callback));
gimp_action_group_add_enum_actions (group,
context_opacity_actions,
G_N_ELEMENTS (context_opacity_actions),
......
......@@ -72,6 +72,108 @@ context_colors_swap_cmd_callback (GtkAction *action,
gimp_context_swap_colors (context);
}
void
context_foreground_red_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpRGB color;
return_if_no_context (context, data);
gimp_context_get_foreground (context, &color);
color.r = context_select_value ((GimpContextSelectType) value,
color.r,
0.0, 1.0,
0.01, 0.1, FALSE);
gimp_context_set_foreground (context, &color);
}
void
context_foreground_green_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpRGB color;
return_if_no_context (context, data);
gimp_context_get_foreground (context, &color);
color.g = context_select_value ((GimpContextSelectType) value,
color.g,
0.0, 1.0,
0.01, 0.1, FALSE);
gimp_context_set_foreground (context, &color);
}
void
context_foreground_blue_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpRGB color;
return_if_no_context (context, data);
gimp_context_get_foreground (context, &color);
color.b = context_select_value ((GimpContextSelectType) value,
color.b,
0.0, 1.0,
0.01, 0.1, FALSE);
gimp_context_set_foreground (context, &color);
}
void
context_background_red_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpRGB color;
return_if_no_context (context, data);
gimp_context_get_background (context, &color);
color.r = context_select_value ((GimpContextSelectType) value,
color.r,
0.0, 1.0,
0.01, 0.1, FALSE);
gimp_context_set_background (context, &color);
}
void
context_background_green_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpRGB color;
return_if_no_context (context, data);
gimp_context_get_background (context, &color);
color.g = context_select_value ((GimpContextSelectType) value,
color.g,
0.0, 1.0,
0.01, 0.1, FALSE);
gimp_context_set_background (context, &color);
}
void
context_background_blue_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpContext *context;
GimpRGB color;
return_if_no_context (context, data);
gimp_context_get_background (context, &color);
color.b = context_select_value ((GimpContextSelectType) value,
color.b,
0.0, 1.0,
0.01, 0.1, FALSE);
gimp_context_set_background (context, &color);
}
void
context_opacity_cmd_callback (GtkAction *action,
gint value,
......@@ -368,17 +470,25 @@ context_select_value (GimpContextSelectType select_type,
break;
default:
g_return_val_if_reached (min);
if (value >= 0)
value = (gdouble) select_type * (max - min) / 1000.0 + min;
else
g_return_val_if_reached (FALSE);
break;
}
if (! wrap)
return CLAMP (value, min, max);
if (wrap)
{
while (value < min)
value = max - (min - value);
if (value < min)
return max - (min - value);
else if (value > max)
return min + (max - value);
while (value > max)
value = min + (max - value);
}
else
{
value = CLAMP (value, min, max);
}
return value;
}
......@@ -22,6 +22,7 @@
typedef enum
{
GIMP_CONTEXT_SELECT_SET = 0,
GIMP_CONTEXT_SELECT_FIRST = -1,
GIMP_CONTEXT_SELECT_LAST = -2,
GIMP_CONTEXT_SELECT_PREVIOUS = -3,
......@@ -36,6 +37,26 @@ void context_colors_default_cmd_callback (GtkAction *action,
void context_colors_swap_cmd_callback (GtkAction *action,
gpointer data);
void context_foreground_red_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void context_foreground_green_cmd_callback(GtkAction *action,
gint value,
gpointer data);
void context_foreground_blue_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void context_background_red_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void context_background_green_cmd_callback(GtkAction *action,
gint value,
gpointer data);
void context_background_blue_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void context_opacity_cmd_callback (GtkAction *action,
gint value,
gpointer data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment