Minor syntactical changes for readability.
[xuni.git] / src / widget / image_tile.c
blob3b92b66f42d3bc210860ecf17b280463f34f316d
1 /*! \file image_tile.c
3 */
5 #include <stdlib.h>
7 #include "../graphics.h"
8 #include "../memory.h"
9 #include "../error.h"
10 #include "../utility.h"
11 #include "widgets.h"
12 #include "image_tile.h"
14 static void free_image_tile(struct xuni_t *xuni, struct widget_t *widget);
15 static void paint_image_tile(struct xuni_t *xuni, struct widget_t *widget);
17 void image_tile_widget_event(struct xuni_t *xuni, struct widget_t *widget,
18 enum widget_event_t event) {
20 static void (*function[])(struct xuni_t *xuni, struct widget_t *widget)
21 = {
23 free_image_tile,
25 paint_image_tile,
30 call_widget_event_func(xuni, widget, event, function,
31 sizeof(function) / sizeof(*function));
34 void init_image_tile(struct widget_t *widget, const char *filename,
35 int xinc, int yinc) {
37 widget->type = WIDGET_IMAGE_TILE;
38 widget->p.image_tile = xuni_memory_allocate(sizeof(*widget->p.image));
40 widget->p.image_tile->xinc = xinc;
41 widget->p.image_tile->yinc = yinc;
42 widget->p.image_tile->xpos = 0;
43 widget->p.image_tile->ypos = 0;
45 add_allocate_widget_compose(widget, "image");
47 init_widget_pos(last_compose_widget(widget), 0, 0, 100.0, 100.0,
48 POS_PACK_NONE);
49 init_image(last_compose_widget(widget), filename, 0.0,
50 IMAGE_LOAD_FREE, IMAGE_RESCALE_LAZY);
51 last_compose_widget(widget)->visibility &= ~WIDGET_VISIBILITY_INDEPENDENT;
53 widget->visibility &= ~WIDGET_VISIBILITY_NOT_COMPOSE;
56 static void free_image_tile(struct xuni_t *xuni, struct widget_t *widget) {
57 xuni_memory_free(widget->p.image_tile);
60 static void paint_image_tile(struct xuni_t *xuni, struct widget_t *widget) {
61 #if !1
62 clear_widget_clip(xuni, widget->compose->widget[WID_IMAGE_TILE_IMAGE]);
64 add_widget_clip(xuni, widget->compose->widget[WID_IMAGE_TILE_IMAGE],
65 widget->p.image_tile->xpos, widget->p.image_tile->ypos, 0, 0, 0, 0);
66 #else
67 prepare_paint_image(xuni, widget->compose->widget[WID_IMAGE_TILE_IMAGE]);
69 blit_surface_fill_from(xuni->smode->screen,
70 widget->compose->widget[WID_IMAGE_TILE_IMAGE]->p.image->image,
71 widget->pos->real.x, widget->pos->real.y,
72 widget->pos->real.w, widget->pos->real.h,
73 widget->p.image_tile->xpos, widget->p.image_tile->ypos);
74 #endif
76 widget->p.image_tile->xpos += widget->p.image_tile->xinc;
77 wrap_int(&widget->p.image_tile->xpos, widget->pos->real.w);
79 widget->p.image_tile->ypos += widget->p.image_tile->yinc;
80 wrap_int(&widget->p.image_tile->ypos, widget->pos->real.h);