23 #include "lv_param_value.h"
24 #include "lv_common.h"
28 VisParamValue *visual_param_value_new (VisParamType type,
void *value)
31 visual_param_value_init (
self, type, value);
35 void visual_param_value_init (VisParamValue *
self, VisParamType type,
void *value)
37 self->type = VISUAL_PARAM_TYPE_NONE;
38 visual_param_value_set (
self, type, value);
41 void visual_param_value_copy (VisParamValue *
self, VisParamValue *src)
43 visual_return_if_fail (
self != NULL);
45 visual_param_value_free_value (
self);
47 self->type = src->type;
51 case VISUAL_PARAM_TYPE_NONE:
53 case VISUAL_PARAM_TYPE_BOOL:
54 case VISUAL_PARAM_TYPE_INTEGER:
55 case VISUAL_PARAM_TYPE_FLOAT:
56 case VISUAL_PARAM_TYPE_DOUBLE:
57 self->value =
self->value;
59 case VISUAL_PARAM_TYPE_COLOR:
60 self->value.color = visual_color_clone (src->value.color);
62 case VISUAL_PARAM_TYPE_STRING:
63 self->value.string = visual_strdup (src->value.string);
65 case VISUAL_PARAM_TYPE_PALETTE:
66 self->value.palette = visual_palette_clone (src->value.palette);
73 void visual_param_value_set (VisParamValue *
self, VisParamType type,
void *value)
75 visual_return_if_fail (
self != NULL);
76 visual_return_if_fail (type != VISUAL_PARAM_TYPE_NONE);
78 visual_param_value_free_value (
self);
84 case VISUAL_PARAM_TYPE_NONE:
86 case VISUAL_PARAM_TYPE_BOOL:
87 case VISUAL_PARAM_TYPE_INTEGER:
88 self->value.integer = (intptr_t) value;
90 case VISUAL_PARAM_TYPE_FLOAT: {
91 self->value.single_float = *(
float *) value;
94 case VISUAL_PARAM_TYPE_DOUBLE:
95 self->value.double_float = *(
double *) value;
97 case VISUAL_PARAM_TYPE_STRING:
98 self->value.string = visual_strdup ((
const char *) value);
100 case VISUAL_PARAM_TYPE_COLOR:
101 self->value.color = visual_color_clone (value);
103 case VISUAL_PARAM_TYPE_PALETTE:
104 self->value.palette = visual_palette_clone (value);
111 void visual_param_value_free_value (VisParamValue *
self)
113 visual_return_if_fail (
self != NULL);
117 case VISUAL_PARAM_TYPE_STRING:
120 case VISUAL_PARAM_TYPE_COLOR:
121 visual_color_free (self->value.color);
123 case VISUAL_PARAM_TYPE_PALETTE:
124 visual_palette_free (self->value.palette);
130 self->type = VISUAL_PARAM_TYPE_NONE;
133 void visual_param_value_free (VisParamValue *
self)
135 visual_return_if_fail (
self != NULL);
137 visual_param_value_free_value (
self);
141 int visual_param_value_compare (VisParamValue *lhs, VisParamValue *rhs)
143 visual_return_val_if_fail (lhs != NULL, FALSE);
144 visual_return_val_if_fail (rhs != NULL, FALSE);
146 if (lhs->type != rhs->type)
150 case VISUAL_PARAM_TYPE_NONE:
152 case VISUAL_PARAM_TYPE_BOOL:
153 case VISUAL_PARAM_TYPE_INTEGER:
154 return lhs->value.integer == rhs->value.integer;
155 case VISUAL_PARAM_TYPE_FLOAT:
156 return lhs->value.single_float == rhs->value.single_float;
157 case VISUAL_PARAM_TYPE_DOUBLE:
158 return lhs->value.double_float == rhs->value.double_float;
159 case VISUAL_PARAM_TYPE_STRING:
160 return strcmp (lhs->value.string, rhs->value.string) == 0;
161 case VISUAL_PARAM_TYPE_COLOR:
162 return visual_color_compare (lhs->value.color, rhs->value.color);
163 case VISUAL_PARAM_TYPE_PALETTE: