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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#ifndef __LAYER_TEXT_H
#define __LAYER_TEXT_H
#include <string.h>
#include <stdlib.h>
#include <SDL.h>
#include <SDL_ttf.h>
#include "osc_graphics.h"
#include "osc_server.h"
#include "layer.h"
class LayerText : public Layer {
TTF_Font *ttf_font;
SDL_Surface *surf_alpha; /* with per-surface alpha */
SDL_Surface *surf; /* original text (possibly scaled) */
char *textv;
char *filev;
SDL_Color colorv;
SDL_Rect geov;
float alphav;
public:
LayerText(const char *name, SDL_Rect geo, float opacity,
SDL_Color color, const char *text, const char *file);
static CtorInfo ctor_info;
static Layer *
ctor_osc(const char *name, SDL_Rect geo, float opacity, lo_arg **argv)
{
SDL_Color color = {
(Uint8)argv[0]->i, (Uint8)argv[1]->i, (Uint8)argv[2]->i
};
return new LayerText(name, geo, opacity, color,
&argv[3]->s, &argv[4]->s);
}
~LayerText();
void frame(SDL_Surface *target);
private:
void geo(SDL_Rect geo);
void alpha(float opacity);
void color(SDL_Color color);
OSCServer::MethodHandlerId *color_osc_id;
static void
color_osc(LayerText *obj, lo_arg **argv)
{
SDL_Color color = {
(Uint8)argv[0]->i, (Uint8)argv[1]->i, (Uint8)argv[2]->i
};
obj->color(color);
}
inline void
text(const char *text)
{
free(textv);
textv = strdup(text);
color(colorv);
}
OSCServer::MethodHandlerId *text_osc_id;
static void
text_osc(LayerText *obj, lo_arg **argv)
{
obj->text(&argv[0]->s);
}
inline void
font(const char *file)
{
free(filev);
filev = strdup(file);
geo(geov);
}
OSCServer::MethodHandlerId *font_osc_id;
static void
font_osc(LayerText *obj, lo_arg **argv)
{
obj->font(&argv[0]->s);
}
inline void
style(int style)
{
TTF_SetFontStyle(ttf_font, style);
color(colorv);
}
OSCServer::MethodHandlerId *style_osc_id;
static void style_osc(LayerText *obj, lo_arg **argv);
};
#endif
|