2019-04-01 20:44:11 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2020-03-05 11:19:44 +01:00
|
|
|
|
|
|
|
#include <string/stdstring.h>
|
|
|
|
|
2019-05-13 01:57:26 +02:00
|
|
|
#include "component.h"
|
2019-04-01 20:44:11 +01:00
|
|
|
|
|
|
|
void component_init(component_t *comp, comp_type_t type)
|
|
|
|
{
|
2020-03-05 11:19:44 +01:00
|
|
|
comp->type = type;
|
|
|
|
comp->bounds = make_bounds();
|
2019-04-01 20:44:11 +01:00
|
|
|
comp->render_bounds = make_bounds_unit();
|
2020-03-05 11:19:44 +01:00
|
|
|
comp->orientation = VIDEO_LAYOUT_ROT0;
|
|
|
|
comp->color = make_color_white();
|
2019-04-01 20:44:11 +01:00
|
|
|
comp->enabled_state = -1;
|
|
|
|
|
|
|
|
switch (comp->type)
|
|
|
|
{
|
2019-10-14 00:31:44 +02:00
|
|
|
case VIDEO_LAYOUT_C_UNKNOWN:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_SCREEN:
|
|
|
|
comp->attr.screen.index = 0;
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_RECT:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_DISK:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_IMAGE:
|
2020-03-05 11:19:44 +01:00
|
|
|
comp->attr.image.file = NULL;
|
|
|
|
comp->attr.image.alpha_file = NULL;
|
|
|
|
comp->attr.image.image_idx = 0;
|
|
|
|
comp->attr.image.alpha_idx = 0;
|
|
|
|
comp->attr.image.loaded = false;
|
2019-10-14 00:31:44 +02:00
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_TEXT:
|
2020-03-05 11:19:44 +01:00
|
|
|
comp->attr.text.string = NULL;
|
|
|
|
comp->attr.text.align = VIDEO_LAYOUT_TEXT_ALIGN_CENTER;
|
2019-10-14 00:31:44 +02:00
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_COUNTER:
|
2020-03-05 11:19:44 +01:00
|
|
|
comp->attr.counter.digits = 2;
|
2019-10-14 00:31:44 +02:00
|
|
|
comp->attr.counter.max_state = 999;
|
2020-03-05 11:19:44 +01:00
|
|
|
comp->attr.counter.align = VIDEO_LAYOUT_TEXT_ALIGN_CENTER;
|
2019-10-14 00:31:44 +02:00
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_DOTMATRIX_X1:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_DOTMATRIX_H5:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_DOTMATRIX_H8:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_7:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_8_GTS1:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_14:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_14_SC:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_16:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_16_SC:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_REEL:
|
|
|
|
break;
|
2019-04-01 20:44:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void component_copy(component_t *comp, const component_t *src)
|
|
|
|
{
|
2020-03-05 11:19:44 +01:00
|
|
|
comp->type = src->type;
|
|
|
|
comp->bounds = src->bounds;
|
2019-04-01 20:44:11 +01:00
|
|
|
comp->render_bounds = src->render_bounds;
|
2020-03-05 11:19:44 +01:00
|
|
|
comp->orientation = src->orientation;
|
|
|
|
comp->color = src->color;
|
2019-04-01 20:44:11 +01:00
|
|
|
comp->enabled_state = src->enabled_state;
|
|
|
|
|
|
|
|
switch (comp->type)
|
|
|
|
{
|
2019-10-14 00:31:44 +02:00
|
|
|
case VIDEO_LAYOUT_C_UNKNOWN:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_SCREEN:
|
2020-03-05 11:19:44 +01:00
|
|
|
comp->attr.screen.index = src->attr.screen.index;
|
2019-10-14 00:31:44 +02:00
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_RECT:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_DISK:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_IMAGE:
|
2020-03-05 11:19:44 +01:00
|
|
|
comp->attr.image.file = string_init(src->attr.image.file);
|
|
|
|
comp->attr.image.alpha_file = string_init(src->attr.image.alpha_file);
|
|
|
|
comp->attr.image.image_idx = src->attr.image.image_idx;
|
|
|
|
comp->attr.image.alpha_idx = src->attr.image.alpha_idx;
|
|
|
|
comp->attr.image.loaded = src->attr.image.loaded;
|
2019-10-14 00:31:44 +02:00
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_TEXT:
|
2020-03-05 11:19:44 +01:00
|
|
|
comp->attr.text.string = string_init(src->attr.text.string);
|
|
|
|
comp->attr.text.align = src->attr.text.align;
|
2019-10-14 00:31:44 +02:00
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_COUNTER:
|
2020-03-05 11:19:44 +01:00
|
|
|
comp->attr.counter.digits = src->attr.counter.digits;
|
2019-10-14 00:31:44 +02:00
|
|
|
comp->attr.counter.max_state = src->attr.counter.max_state;
|
|
|
|
comp->attr.counter.align = src->attr.counter.align;
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_DOTMATRIX_X1:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_DOTMATRIX_H5:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_DOTMATRIX_H8:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_7:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_8_GTS1:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_14:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_14_SC:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_16:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_16_SC:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_REEL:
|
|
|
|
break;
|
2019-04-01 20:44:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void component_deinit(component_t *comp)
|
|
|
|
{
|
|
|
|
switch (comp->type)
|
|
|
|
{
|
2019-10-14 00:31:44 +02:00
|
|
|
case VIDEO_LAYOUT_C_UNKNOWN:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_SCREEN:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_RECT:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_DISK:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_IMAGE:
|
|
|
|
free(comp->attr.image.file);
|
|
|
|
free(comp->attr.image.alpha_file);
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_TEXT:
|
|
|
|
free(comp->attr.text.string);
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_COUNTER:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_DOTMATRIX_X1:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_DOTMATRIX_H5:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_DOTMATRIX_H8:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_7:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_8_GTS1:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_14:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_14_SC:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_16:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_LED_16_SC:
|
|
|
|
break;
|
|
|
|
case VIDEO_LAYOUT_C_REEL:
|
|
|
|
break;
|
2019-04-01 20:44:11 +01:00
|
|
|
}
|
|
|
|
}
|