aboutsummaryrefslogtreecommitdiff
path: root/src/layer_image.h
blob: 1674348b221191e19c0140df3b1a07268f684d6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef __LAYER_IMAGE_H
#define __LAYER_IMAGE_H

#include <stdlib.h>
#include <stdio.h>

#include <SDL.h>

#include "osc_graphics.h"
#include "layer.h"

class LayerImage : public Layer {
	SDL_Surface	*surf_alpha;	/* with per-surface alpha */
	SDL_Surface	*surf_scaled;	/* scaled image */
	SDL_Surface	*surf;		/* original image */

	SDL_Rect	geov;
	float		alphav;

public:
	LayerImage(const char *name,
		   SDL_Rect geo = (SDL_Rect){0, 0, 0, 0},
		   float opacity = 1.,
		   const char *file = NULL);

	static CtorInfo ctor_info;
	static Layer *
	ctor_osc(const char *name, SDL_Rect geo, float opacity, lo_arg **argv)
	{
		return new LayerImage(name, geo, opacity, &argv[0]->s);
	}

	~LayerImage();

	void frame(SDL_Surface *target);

private:
	void geo(SDL_Rect geo);
	void alpha(float opacity);

	void file(const char *file = NULL);
	OSCServer::MethodHandlerId *file_osc_id;
	static void
	file_osc(LayerImage *obj, lo_arg **argv)
	{
		obj->file(&argv[0]->s);
	}
};

#endif