removed enum GimpContextSelectType.
2004-06-23 Michael Natterer <mitch@gimp.org> * app/actions/context-commands.h: removed enum GimpContextSelectType. * app/actions/actions-types.h: added enum GimpActionSelectType. * app/actions/actions.[ch]: added utility functions action_select_value() and action_select_object(). * app/actions/context-actions.c * app/actions/context-commands.c: changed accordingly. * app/actions/layers-actions.c * app/actions/layers-commands.[ch]: merged the layer select callbacks into one using the GimpActionSelectType functions. Added actions and callbacks for modifying the active layer's opacity. * app/menus/menus-types.h: #incude "actions/action-types.h". * app/gui/gui-types.h: #incude "menus/menus-types.h". * app/gui/preferences-dialog.c: allow to enable/disable input controllers.
This commit is contained in:

committed by
Michael Natterer

parent
546359f914
commit
d88f23ddba
@ -38,16 +38,9 @@
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void context_select_object (GimpContext *context,
|
||||
GimpContainer *container,
|
||||
GimpContextSelectType select_type);
|
||||
static gdouble context_select_value (GimpContextSelectType select_type,
|
||||
gdouble value,
|
||||
gdouble min,
|
||||
gdouble max,
|
||||
gdouble inc,
|
||||
gdouble skip_inc,
|
||||
gboolean wrap);
|
||||
static void context_select_object (GimpActionSelectType select_type,
|
||||
GimpContext *context,
|
||||
GimpContainer *container);
|
||||
|
||||
|
||||
/* public functions */
|
||||
@ -82,10 +75,10 @@ context_foreground_red_cmd_callback (GtkAction *action,
|
||||
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);
|
||||
color.r = action_select_value ((GimpActionSelectType) value,
|
||||
color.r,
|
||||
0.0, 1.0,
|
||||
0.01, 0.1, FALSE);
|
||||
gimp_context_set_foreground (context, &color);
|
||||
}
|
||||
|
||||
@ -99,10 +92,10 @@ context_foreground_green_cmd_callback (GtkAction *action,
|
||||
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);
|
||||
color.g = action_select_value ((GimpActionSelectType) value,
|
||||
color.g,
|
||||
0.0, 1.0,
|
||||
0.01, 0.1, FALSE);
|
||||
gimp_context_set_foreground (context, &color);
|
||||
}
|
||||
|
||||
@ -116,10 +109,10 @@ context_foreground_blue_cmd_callback (GtkAction *action,
|
||||
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);
|
||||
color.b = action_select_value ((GimpActionSelectType) value,
|
||||
color.b,
|
||||
0.0, 1.0,
|
||||
0.01, 0.1, FALSE);
|
||||
gimp_context_set_foreground (context, &color);
|
||||
}
|
||||
|
||||
@ -133,10 +126,10 @@ context_background_red_cmd_callback (GtkAction *action,
|
||||
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);
|
||||
color.r = action_select_value ((GimpActionSelectType) value,
|
||||
color.r,
|
||||
0.0, 1.0,
|
||||
0.01, 0.1, FALSE);
|
||||
gimp_context_set_background (context, &color);
|
||||
}
|
||||
|
||||
@ -150,10 +143,10 @@ context_background_green_cmd_callback (GtkAction *action,
|
||||
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);
|
||||
color.g = action_select_value ((GimpActionSelectType) value,
|
||||
color.g,
|
||||
0.0, 1.0,
|
||||
0.01, 0.1, FALSE);
|
||||
gimp_context_set_background (context, &color);
|
||||
}
|
||||
|
||||
@ -167,10 +160,10 @@ context_background_blue_cmd_callback (GtkAction *action,
|
||||
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);
|
||||
color.b = action_select_value ((GimpActionSelectType) value,
|
||||
color.b,
|
||||
0.0, 1.0,
|
||||
0.01, 0.1, FALSE);
|
||||
gimp_context_set_background (context, &color);
|
||||
}
|
||||
|
||||
@ -183,11 +176,11 @@ context_opacity_cmd_callback (GtkAction *action,
|
||||
gdouble opacity;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
opacity = context_select_value ((GimpContextSelectType) value,
|
||||
gimp_context_get_opacity (context),
|
||||
GIMP_OPACITY_TRANSPARENT,
|
||||
GIMP_OPACITY_OPAQUE,
|
||||
0.01, 0.1, FALSE);
|
||||
opacity = action_select_value ((GimpActionSelectType) value,
|
||||
gimp_context_get_opacity (context),
|
||||
GIMP_OPACITY_TRANSPARENT,
|
||||
GIMP_OPACITY_OPAQUE,
|
||||
0.01, 0.1, FALSE);
|
||||
gimp_context_set_opacity (context, opacity);
|
||||
}
|
||||
|
||||
@ -199,8 +192,8 @@ context_tool_select_cmd_callback (GtkAction *action,
|
||||
GimpContext *context;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
context_select_object (context, context->gimp->tool_info_list,
|
||||
(GimpContextSelectType) value);
|
||||
context_select_object ((GimpActionSelectType) value,
|
||||
context, context->gimp->tool_info_list);
|
||||
}
|
||||
|
||||
void
|
||||
@ -211,8 +204,8 @@ context_brush_select_cmd_callback (GtkAction *action,
|
||||
GimpContext *context;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
context_select_object (context, context->gimp->brush_factory->container,
|
||||
(GimpContextSelectType) value);
|
||||
context_select_object ((GimpActionSelectType) value,
|
||||
context, context->gimp->brush_factory->container);
|
||||
}
|
||||
|
||||
void
|
||||
@ -223,8 +216,8 @@ context_pattern_select_cmd_callback (GtkAction *action,
|
||||
GimpContext *context;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
context_select_object (context, context->gimp->pattern_factory->container,
|
||||
(GimpContextSelectType) value);
|
||||
context_select_object ((GimpActionSelectType) value,
|
||||
context, context->gimp->pattern_factory->container);
|
||||
}
|
||||
|
||||
void
|
||||
@ -235,8 +228,8 @@ context_palette_select_cmd_callback (GtkAction *action,
|
||||
GimpContext *context;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
context_select_object (context, context->gimp->palette_factory->container,
|
||||
(GimpContextSelectType) value);
|
||||
context_select_object ((GimpActionSelectType) value,
|
||||
context, context->gimp->palette_factory->container);
|
||||
}
|
||||
|
||||
void
|
||||
@ -247,8 +240,8 @@ context_gradient_select_cmd_callback (GtkAction *action,
|
||||
GimpContext *context;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
context_select_object (context, context->gimp->gradient_factory->container,
|
||||
(GimpContextSelectType) value);
|
||||
context_select_object ((GimpActionSelectType) value,
|
||||
context, context->gimp->gradient_factory->container);
|
||||
}
|
||||
|
||||
void
|
||||
@ -259,8 +252,8 @@ context_font_select_cmd_callback (GtkAction *action,
|
||||
GimpContext *context;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
context_select_object (context, context->gimp->fonts,
|
||||
(GimpContextSelectType) value);
|
||||
context_select_object ((GimpActionSelectType) value,
|
||||
context, context->gimp->fonts);
|
||||
}
|
||||
|
||||
void
|
||||
@ -281,10 +274,10 @@ context_brush_radius_cmd_callback (GtkAction *action,
|
||||
|
||||
radius = gimp_brush_generated_get_radius (generated);
|
||||
|
||||
radius = context_select_value ((GimpContextSelectType) value,
|
||||
radius,
|
||||
1.0, 4096.0,
|
||||
1.0, 10.0, FALSE);
|
||||
radius = action_select_value ((GimpActionSelectType) value,
|
||||
radius,
|
||||
1.0, 4096.0,
|
||||
1.0, 10.0, FALSE);
|
||||
gimp_brush_generated_set_radius (generated, radius);
|
||||
}
|
||||
}
|
||||
@ -307,10 +300,10 @@ context_brush_hardness_cmd_callback (GtkAction *action,
|
||||
|
||||
hardness = gimp_brush_generated_get_hardness (generated);
|
||||
|
||||
hardness = context_select_value ((GimpContextSelectType) value,
|
||||
hardness,
|
||||
0.0, 1.0,
|
||||
0.01, 0.1, FALSE);
|
||||
hardness = action_select_value ((GimpActionSelectType) value,
|
||||
hardness,
|
||||
0.0, 1.0,
|
||||
0.01, 0.1, FALSE);
|
||||
gimp_brush_generated_set_hardness (generated, hardness);
|
||||
}
|
||||
}
|
||||
@ -333,10 +326,10 @@ context_brush_aspect_cmd_callback (GtkAction *action,
|
||||
|
||||
aspect = gimp_brush_generated_get_aspect_ratio (generated);
|
||||
|
||||
aspect = context_select_value ((GimpContextSelectType) value,
|
||||
aspect,
|
||||
1.0, 1000.0,
|
||||
1.0, 4.0, FALSE);
|
||||
aspect = action_select_value ((GimpActionSelectType) value,
|
||||
aspect,
|
||||
1.0, 1000.0,
|
||||
1.0, 4.0, FALSE);
|
||||
gimp_brush_generated_set_aspect_ratio (generated, aspect);
|
||||
}
|
||||
}
|
||||
@ -359,15 +352,15 @@ context_brush_angle_cmd_callback (GtkAction *action,
|
||||
|
||||
angle = gimp_brush_generated_get_angle (generated);
|
||||
|
||||
if (value == GIMP_CONTEXT_SELECT_FIRST)
|
||||
if (value == GIMP_ACTION_SELECT_FIRST)
|
||||
angle = 0.0;
|
||||
else if (value == GIMP_CONTEXT_SELECT_LAST)
|
||||
else if (value == GIMP_ACTION_SELECT_LAST)
|
||||
angle = 90.0;
|
||||
else
|
||||
angle = context_select_value ((GimpContextSelectType) value,
|
||||
angle,
|
||||
0.0, 180.0,
|
||||
1.0, 15.0, TRUE);
|
||||
angle = action_select_value ((GimpActionSelectType) value,
|
||||
angle,
|
||||
0.0, 180.0,
|
||||
1.0, 15.0, TRUE);
|
||||
|
||||
gimp_brush_generated_set_angle (generated, angle);
|
||||
}
|
||||
@ -377,118 +370,16 @@ context_brush_angle_cmd_callback (GtkAction *action,
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
context_select_object (GimpContext *context,
|
||||
GimpContainer *container,
|
||||
GimpContextSelectType select_type)
|
||||
context_select_object (GimpActionSelectType select_type,
|
||||
GimpContext *context,
|
||||
GimpContainer *container)
|
||||
{
|
||||
GimpObject *current;
|
||||
gint select_index;
|
||||
gint n_children;
|
||||
|
||||
current = gimp_context_get_by_type (context, container->children_type);
|
||||
|
||||
if (! current)
|
||||
return;
|
||||
|
||||
n_children = gimp_container_num_children (container);
|
||||
|
||||
if (n_children == 0)
|
||||
return;
|
||||
|
||||
switch (select_type)
|
||||
{
|
||||
case GIMP_CONTEXT_SELECT_FIRST:
|
||||
select_index = 0;
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_SELECT_LAST:
|
||||
select_index = n_children - 1;
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_SELECT_PREVIOUS:
|
||||
select_index = gimp_container_get_child_index (container, current) - 1;
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_SELECT_NEXT:
|
||||
select_index = gimp_container_get_child_index (container, current) + 1;
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_SELECT_SKIP_PREVIOUS:
|
||||
select_index = gimp_container_get_child_index (container, current) - 10;
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_SELECT_SKIP_NEXT:
|
||||
select_index = gimp_container_get_child_index (container, current) + 10;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_return_if_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
select_index = CLAMP (select_index, 0, n_children - 1);
|
||||
|
||||
current = gimp_container_get_child_by_index (container, select_index);
|
||||
current = action_select_object (select_type, container, current);
|
||||
|
||||
if (current)
|
||||
gimp_context_set_by_type (context, container->children_type, current);
|
||||
}
|
||||
|
||||
static gdouble
|
||||
context_select_value (GimpContextSelectType select_type,
|
||||
gdouble value,
|
||||
gdouble min,
|
||||
gdouble max,
|
||||
gdouble inc,
|
||||
gdouble skip_inc,
|
||||
gboolean wrap)
|
||||
{
|
||||
switch (select_type)
|
||||
{
|
||||
case GIMP_CONTEXT_SELECT_FIRST:
|
||||
value = min;
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_SELECT_LAST:
|
||||
value = max;
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_SELECT_PREVIOUS:
|
||||
value -= inc;
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_SELECT_NEXT:
|
||||
value += inc;
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_SELECT_SKIP_PREVIOUS:
|
||||
value -= skip_inc;
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_SELECT_SKIP_NEXT:
|
||||
value += skip_inc;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (value >= 0)
|
||||
value = (gdouble) select_type * (max - min) / 1000.0 + min;
|
||||
else
|
||||
g_return_val_if_reached (FALSE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (wrap)
|
||||
{
|
||||
while (value < min)
|
||||
value = max - (min - value);
|
||||
|
||||
while (value > max)
|
||||
value = min + (max - value);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = CLAMP (value, min, max);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
Reference in New Issue
Block a user