Mercurial > mplayer.hg
annotate sub/eosd.c @ 34346:3d0c795524b0
Fix bug with wrong focus in file selector.
The focus can only be set to fsFNameList after it's realized and mapped.
This also removes the irritating selection of the fsPathCombo.
author | ib |
---|---|
date | Sun, 11 Dec 2011 16:02:02 +0000 |
parents | fbe5c829c69b |
children | 7dbe7168cf49 |
rev | line source |
---|---|
32460 | 1 /* |
2 * Extended On Screen Display | |
3 * Copyright (C) 2010 Nicolas George | |
4 * | |
5 * This file is part of MPlayer. | |
6 * | |
7 * MPlayer is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * MPlayer is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License along | |
18 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
20 */ | |
21 | |
22 #include "mpcommon.h" | |
23 #include "libmpcodecs/vf.h" | |
24 #include "libvo/video_out.h" | |
32467 | 25 #include "sub.h" |
32464
22888a8cb312
Do not use a path for including files in the same directory.
reimar
parents:
32461
diff
changeset
|
26 #include "ass_mp.h" |
22888a8cb312
Do not use a path for including files in the same directory.
reimar
parents:
32461
diff
changeset
|
27 #include "eosd.h" |
32460 | 28 |
29 static struct mp_eosd_source *sources; | |
30 static struct mp_eosd_settings settings; | |
31 static struct mp_eosd_image *image_pool; | |
32 | |
33 void eosd_init(vf_instance_t *vf) | |
34 { | |
35 vf->control(vf, VFCTRL_INIT_EOSD, NULL); | |
36 } | |
37 | |
38 void eosd_register(struct mp_eosd_source *src) | |
39 { | |
40 struct mp_eosd_source *p, **prev = &sources; | |
41 for (p = sources; p && p->z_index < src->z_index; p = p->priv_next) | |
42 prev = &p->priv_next; | |
43 src->priv_next = p; | |
44 *prev = src; | |
45 src->initialized = 0; | |
46 } | |
47 | |
48 int eosd_registered(struct mp_eosd_source *source) | |
49 { | |
50 struct mp_eosd_source *p; | |
51 for (p = sources; p; p = p->priv_next) | |
52 if (p == source) | |
53 return 1; | |
54 return 0; | |
55 } | |
56 | |
57 void eosd_configure(struct mp_eosd_settings *res) | |
58 { | |
59 if (res->w != settings.w || | |
60 res->h != settings.h || | |
61 res->srcw != settings.srcw || | |
62 res->srch != settings.srch || | |
63 res->mt != settings.mt || | |
64 res->mt != settings.mb || | |
65 res->mt != settings.ml || | |
66 res->mt != settings.mr || | |
67 res->unscaled != settings.unscaled) { | |
68 settings = *res; | |
69 settings.changed = 1; | |
70 } | |
71 } | |
72 | |
73 void eosd_render_frame(double ts, struct mp_eosd_image_list *images) | |
74 { | |
75 struct mp_eosd_source *src; | |
76 int changed = 0; | |
77 for (src = sources; src; src = src->priv_next) { | |
78 if (src->update) | |
79 src->update(src, &settings, ts); | |
80 changed |= src->changed; | |
81 src->changed = 0; | |
82 } | |
83 settings.changed = 0; | |
84 images->first_source = sources; | |
85 images->changed = changed; | |
86 } | |
87 | |
88 void eosd_uninit(void) | |
89 { | |
90 struct mp_eosd_source *src; | |
91 for (src = sources; src; src = src->priv_next) { | |
92 // TODO: maybe only call if src->initialized is set. | |
93 if (src->uninit) | |
94 src->uninit(src); | |
95 src->initialized = 0; | |
96 } | |
97 } | |
98 | |
99 struct mp_eosd_image *eosd_image_alloc(void) | |
100 { | |
101 struct mp_eosd_image *r; | |
102 if (!image_pool) { | |
103 const unsigned n_alloc = 127; /* arbitrary */ | |
104 unsigned i; | |
105 image_pool = calloc(n_alloc, sizeof(*image_pool)); | |
106 for (i = 0; i < n_alloc - 1; i++) | |
107 image_pool[i].next = image_pool + i + 1; | |
108 image_pool[i].next = NULL; | |
109 } | |
110 r = image_pool; | |
111 image_pool = image_pool->next; | |
112 return r; | |
113 } | |
114 | |
115 void eosd_image_free(struct mp_eosd_image *image) | |
116 { | |
117 image->next = image_pool; | |
118 image_pool = image; | |
119 } | |
120 | |
121 void eosd_image_append(struct mp_eosd_source *source, | |
122 struct mp_eosd_image *image) | |
123 { | |
124 image->next = NULL; | |
125 *source->images_tail = image; | |
126 source->images_tail = &image->next; | |
127 } | |
128 | |
129 void eosd_image_remove(struct mp_eosd_source *source, | |
130 struct mp_eosd_image *image, | |
131 struct mp_eosd_image **prev) | |
132 { | |
133 *prev = image->next; | |
134 if (!*prev) | |
135 source->images_tail = prev; | |
136 eosd_image_free(image); | |
137 } | |
138 | |
139 void eosd_image_remove_all(struct mp_eosd_source *source) | |
140 { | |
141 struct mp_eosd_image *image; | |
142 | |
143 while (source->images) { | |
144 image = source->images; | |
145 source->images = source->images->next; | |
146 eosd_image_free(image); | |
147 } | |
148 source->images_tail = &source->images; | |
149 } | |
150 | |
151 static void next_image_in_sources(struct mp_eosd_image_list *images, | |
152 struct mp_eosd_source *src) | |
153 { | |
154 images->source = src; | |
155 while (images->source && !images->source->images) | |
156 images->source = images->source->priv_next; | |
157 images->image = images->source ? images->source->images : NULL; | |
158 } | |
159 | |
160 struct mp_eosd_image *eosd_image_first(struct mp_eosd_image_list *images) | |
161 { | |
162 next_image_in_sources(images, images->first_source); | |
163 return images->image; | |
164 } | |
165 | |
166 struct mp_eosd_image *eosd_image_next(struct mp_eosd_image_list *images) | |
167 { | |
168 images->image = images->image->next; | |
169 if (!images->image) | |
170 next_image_in_sources(images, images->source->priv_next); | |
171 return images->image; | |
172 } |