Qt: playlist menu strings and icons
[vlc.git] / src / video_output / event.h
blob948d317fd14f2902d8356425fa5021773339621b
1 /*****************************************************************************
2 * event.h: vout event
3 *****************************************************************************
4 * Copyright (C) 2009 Laurent Aimar
5 * $Id$
7 * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #if defined(__PLUGIN__) || defined(__BUILTIN__) || !defined(__LIBVLC__)
25 # error This header file can only be included from LibVLC.
26 #endif
28 #include <vlc_common.h>
29 #include <vlc_playlist.h>
30 #include <math.h>
32 #include "vout_control.h"
34 /* TODO/FIXME
36 * It should be converted to something like input_thread_t:
37 * one intf-event can be grabbed by a callback, all others
38 * variable only var_Change
40 * Maybe a intf-mouse can be used too (don't like it).
42 * (Some case may infinite loop otherwise here)
45 static inline void vout_SendEventClose(vout_thread_t *vout)
47 /* Ask to stop
48 * FIXME works only for input handled by the playlist
50 playlist_t *playlist = pl_Get(vout);
51 playlist_Stop(playlist);
53 static inline void vout_SendEventKey(vout_thread_t *vout, int key)
55 var_SetInteger(vout->p_libvlc, "key-pressed", key);
57 static inline void vout_SendEventMouseMoved(vout_thread_t *vout, int x, int y)
59 var_SetCoords(vout, "mouse-moved", x, y);
61 static inline void vout_SendEventMousePressed(vout_thread_t *vout, int button)
63 var_OrInteger(vout, "mouse-button-down", 1 << button);
65 switch (button)
67 case MOUSE_BUTTON_LEFT:
69 /* FIXME? */
70 int x, y;
71 var_GetCoords(vout, "mouse-moved", &x, &y);
72 var_SetCoords(vout, "mouse-clicked", x, y);
73 var_SetBool(vout->p_libvlc, "intf-popupmenu", false);
74 break;
76 case MOUSE_BUTTON_CENTER:
77 var_ToggleBool(vout->p_libvlc, "intf-show");
78 break;
79 case MOUSE_BUTTON_RIGHT:
80 var_SetBool(vout->p_libvlc, "intf-popupmenu", true);
81 break;
84 static inline void vout_SendEventMouseReleased(vout_thread_t *vout, int button)
86 var_NAndInteger(vout, "mouse-button-down", 1 << button);
88 static inline void vout_SendEventMouseDoubleClick(vout_thread_t *vout)
90 //vout_ControlSetFullscreen(vout, !var_GetBool(vout, "fullscreen"));
91 //var_ToggleBool(vout, "fullscreen");
92 var_SetInteger(vout->p_libvlc, "key-action", ACTIONID_TOGGLE_FULLSCREEN);
94 static inline void vout_SendEventMouseVisible(vout_thread_t *vout)
96 /* TODO */
97 VLC_UNUSED(vout);
99 static inline void vout_SendEventMouseHidden(vout_thread_t *vout)
101 /* TODO */
102 VLC_UNUSED(vout);
105 static inline void vout_SendEventFullscreen(vout_thread_t *vout, bool is_fullscreen)
107 var_SetBool(vout, "fullscreen", is_fullscreen);
110 static inline void vout_SendEventDisplayFilled(vout_thread_t *vout, bool is_display_filled)
112 if (!var_GetBool(vout, "autoscale") != !is_display_filled)
113 var_SetBool(vout, "autoscale", is_display_filled);
116 static inline void vout_SendEventZoom(vout_thread_t *vout, int num, int den)
118 VLC_UNUSED(vout);
119 VLC_UNUSED(num);
120 VLC_UNUSED(den);
121 /* FIXME deadlock problems with current vout */
122 #if 0
123 const float zoom = (float)num / (float)den;
125 /* XXX 0.1% is arbitrary */
126 if (fabs(zoom - var_GetFloat(vout, "scale")) > 0.001)
127 var_SetFloat(vout, "scale", zoom);
128 #endif
131 static inline void vout_SendEventOnTop(vout_thread_t *vout, bool is_on_top)
133 VLC_UNUSED(vout);
134 VLC_UNUSED(is_on_top);
135 /* FIXME deadlock problems with current vout */
136 #if 0
138 if (!var_GetBool(vout, "video-on-top") != !is_on_top)
139 var_SetBool(vout, "video-on-top", is_on_top);
140 #endif
144 * It must be called on source aspect ratio changes, with the new DAR (Display
145 * Aspect Ratio) value.
147 static inline void vout_SendEventSourceAspect(vout_thread_t *vout,
148 unsigned num, unsigned den)
150 VLC_UNUSED(vout);
151 VLC_UNUSED(num);
152 VLC_UNUSED(den);
153 /* FIXME the value stored in "aspect-ratio" are not reduced
154 * creating a lot of problems here */
155 #if 0
156 char *ar;
157 if (num > 0 && den > 0) {
158 if (asprintf(&ar, "%u:%u", num, den) < 0)
159 return;
160 } else {
161 ar = strdup("");
164 char *current = var_GetString(vout, "aspect-ratio");
165 msg_Err(vout, "vout_SendEventSourceAspect %s -> %s", current, ar);
166 if (ar && current && strcmp(ar, current))
167 var_SetString(vout, "aspect-ratio", ar);
169 free(current);
170 free(ar);
171 #endif
173 static inline void vout_SendEventSourceCrop(vout_thread_t *vout,
174 unsigned num, unsigned den,
175 unsigned left, unsigned top,
176 unsigned right, unsigned bottom)
178 VLC_UNUSED(num);
179 VLC_UNUSED(den);
181 vlc_value_t val;
183 /* I cannot use var_Set here, infinite loop otherwise */
185 /* */
186 val.i_int = left;
187 var_Change(vout, "crop-left", VLC_VAR_SETVALUE, &val, NULL);
188 val.i_int = top;
189 var_Change(vout, "crop-top", VLC_VAR_SETVALUE, &val, NULL);
190 val.i_int = right;
191 var_Change(vout, "crop-right", VLC_VAR_SETVALUE, &val, NULL);
192 val.i_int = bottom;
193 var_Change(vout, "crop-bottom", VLC_VAR_SETVALUE, &val, NULL);
195 /* FIXME the value stored in "crop" are not reduced
196 * creating a lot of problems here */
197 #if 0
198 char *crop;
199 if (num > 0 && den > 0) {
200 if (asprintf(&crop, "%u:%u", num, den) < 0)
201 crop = NULL;
202 } else if (left > 0 || top > 0 || right > 0 || bottom > 0) {
203 if (asprintf(&crop, "%u+%u+%u+%u", left, top, right, bottom) < 0)
204 crop = NULL;
205 } else {
206 crop = strdup("");
208 if (crop) {
209 val.psz_string = crop;
210 var_Change(vout, "crop", VLC_VAR_SETVALUE, &val, NULL);
211 free(crop);
213 #endif
215 #if 0
216 static inline void vout_SendEventSnapshot(vout_thread_t *vout, const char *filename)
218 /* signal creation of a new snapshot file */
219 var_SetString(vout->p_libvlc, "snapshot-file", filename);
222 #warning "FIXME clean up postproc event"
224 extern void vout_InstallDeprecatedPostProcessing(vout_thread_t *);
225 extern void vout_UninstallDeprecatedPostProcessing(vout_thread_t *);
227 static inline void vout_SendEventPostProcessing(vout_thread_t *vout, bool is_available)
229 if (is_available)
230 vout_InstallDeprecatedPostProcessing(vout);
231 else
232 vout_UninstallDeprecatedPostProcessing(vout);
235 static inline void vout_SendEventFilters(vout_thread_t *vout)
237 vout_filter_t **filter;
238 int filter_count;
240 vout_ControlGetFilters(vout, &filter, &filter_count);
242 char *list = strdup("");
243 for (int i = 0; i < filter_count; i++) {
244 char *psz;
246 if (asprintf(&psz, "%s%s%s",
247 list, i > 0 ? ":" : "", filter[i]->name) < 0) {
248 free(list);
249 list = NULL;
250 break;
252 free(list);
253 list = psz;
256 if (list) {
257 vlc_value_t val;
258 val.psz_string = list;
259 var_Change(vout, "video-filter", VLC_VAR_SETVALUE, &val, NULL);
260 free(list);
263 for (int i = 0; i < filter_count; i++)
264 vout_filter_Delete(filter[i]);
265 free(filter);
267 #endif