7 #include "../graphics.h"
10 #include "../utility.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
)
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
,
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,
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
) {
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);
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
);
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
);