10 static int in_range_func (VisParamValue *value, VisParamInRangeArgs *data);
11 static void in_range_args_free (VisParamInRangeArgs *args);
13 VisClosure *visual_param_in_range (VisParamType type,
void *lower,
void *upper)
16 visual_param_value_set (&args->lower, type, lower);
17 visual_param_value_set (&args->upper, type, upper);
19 return visual_closure_new (in_range_func, args, (VisDestroyFunc) in_range_args_free);
22 int in_range_func (VisParamValue *value, VisParamInRangeArgs *data)
24 visual_return_val_if_fail (value != NULL, FALSE);
25 visual_return_val_if_fail (data != NULL, FALSE);
27 switch (value->type) {
28 case VISUAL_PARAM_TYPE_INTEGER: {
29 int v = visual_param_value_get_integer (value);
30 int a = visual_param_value_get_integer (&data->lower);
31 int b = visual_param_value_get_integer (&data->upper);
32 return (v >= a && v <= b);
34 case VISUAL_PARAM_TYPE_FLOAT: {
35 float v = visual_param_value_get_float (value);
36 float a = visual_param_value_get_float (&data->lower);
37 float b = visual_param_value_get_float (&data->upper);
38 return (v >= a && v <= b);
40 case VISUAL_PARAM_TYPE_DOUBLE: {
41 double v = visual_param_value_get_double (value);
42 double a = visual_param_value_get_double (&data->lower);
43 double b = visual_param_value_get_double (&data->upper);
44 return (v >= a && v <= b);
52 void in_range_args_free (VisParamInRangeArgs *args)
54 visual_param_value_free_value (&args->lower);
55 visual_param_value_free_value (&args->upper);