Added anchor, so actual song does not run away from window during playback.
[herrie-working.git] / herrie / src / gui_internal.h
blob0dfa4edd0977b9271aaaee54d5ef1ade17a7593e
1 /*
2 * Copyright (c) 2006-2011 Ed Schouten <ed@80386.nl>
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
26 /**
27 * @file gui_internal.h
28 * @brief Internal textual user interface routines.
31 #include CURSES_HEADER
33 struct vfsref;
34 struct vfsmatch;
36 /**
37 * @brief Determine whether our terminal is black or white or color.
39 extern int gui_draw_colors;
40 /**
41 * @brief Height percentage of the playlist.
43 extern int gui_draw_ratio;
44 /**
45 * @brief Refresh the curses GUI after a terminal resize.
47 void gui_draw_resize(void);
48 /**
49 * @brief Write all altered data back to the physical terminal.
51 void gui_draw_done(void);
52 /**
53 * @brief The mutex that locks the GUI down.
55 extern GMutex *gui_mtx;
57 /**
58 * @brief Acquire a lock on the GUI.
60 static inline void
61 gui_lock(void)
63 g_mutex_lock(gui_mtx);
66 /**
67 * @brief Release a lock on the GUI.
69 static inline void
70 gui_unlock(void)
72 g_mutex_unlock(gui_mtx);
75 /* Display size ratios */
76 /**
77 * @brief Height of playlist window.
79 #define GUI_SIZE_PLAYQ_HEIGHT (((LINES * gui_draw_ratio) / 100) - 1)
80 /**
81 * @brief Offset of the window containing the filebrowser's directory
82 * name.
84 #define GUI_SIZE_BROWSER_DIRNAME_TOP (GUI_SIZE_PLAYQ_HEIGHT + 1)
85 /**
86 * @brief Offset of the filebrowser window.
88 #define GUI_SIZE_BROWSER_TOP (GUI_SIZE_BROWSER_DIRNAME_TOP + 1)
89 /**
90 * @brief Height of the filebrowser window.
92 #define GUI_SIZE_BROWSER_HEIGHT (LINES - GUI_SIZE_BROWSER_TOP - 1)
93 /**
94 * @brief Offset of the message bar window.
96 #define GUI_SIZE_MSGBAR_TOP (LINES - 1)
98 /**
99 * @brief Curses colour code used to draw bars (status, dirname).
101 #define GUI_COLOR_BAR 2
103 * @brief Curses colour code used to draw blocks (playlist, browser).
105 #define GUI_COLOR_BLOCK 3
107 * @brief Curses colour code used to draw focused selections.
109 #define GUI_COLOR_SELECT 4
111 * @brief Curses colour code used to draw unfocused selections.
113 #define GUI_COLOR_DESELECT 5
115 * @brief Curses colour code used to draw marked items (song currenty
116 * played).
118 #define GUI_COLOR_MARKED 6
121 * @brief Display a standard Yes/No question at the bottom of the screen
122 * and return the user response.
124 int gui_input_askyesno(const char *question);
126 * @brief Display a string input question at the bottom of the screen
127 * and return the user response.
129 char *gui_input_askstring(const char *question, const char *defstr,
130 int (*validator)(const char *str, char c));
133 * gui_msgbar
136 * @brief Create a bar at the bottom of the terminal displaying
137 * messages and questions.
139 void gui_msgbar_init(void);
141 * @brief Destroy the message bar at the bottom of the screen.
143 void gui_msgbar_destroy(void);
145 * @brief Set the proper size of the message bar after a terminal
146 * resize.
148 void gui_msgbar_resize(void);
150 * @brief Redraw the message bar after its contents have been altered.
152 void gui_msgbar_refresh(void);
154 * @brief Flush the text in the message bar.
156 void gui_msgbar_flush(void);
158 * @brief Show a message in the message bar that will only be
159 * overwritten by other messages with this priority. This
160 * routine will also unhide the cursor and show it right after
161 * the message.
163 void gui_msgbar_ask(const char *msg);
166 * gui_playq
169 * @brief Initialize the playlist window.
171 void gui_playq_init(void);
173 * @brief Destroy the playlist window.
175 void gui_playq_destroy(void);
177 * @brief Redraw the playlist window, because of a terminal resize.
179 void gui_playq_resize(void);
182 * @brief Move the cursor of the playlist one item up.
184 void gui_playq_cursor_up(void);
186 * @brief Move the cursor of the playlist one item down.
188 void gui_playq_cursor_down(void);
190 * @brief Move the cursor of the playlist on the actually played song.
192 void gui_playq_cursor_actual(void);
194 * @brief Move the cursor and the viewport of the playlist one page up.
196 void gui_playq_cursor_pageup(void);
198 * @brief Move the cursor and the viewport of the playlist one page down.
200 void gui_playq_cursor_pagedown(void);
202 * @brief Move the cursor and the viewport of the playlist to the top of
203 * the playlist.
205 void gui_playq_cursor_head(void);
207 * @brief Move the cursor and the viewport of the playlist to the bottom
208 * of the playlist.
210 void gui_playq_cursor_tail(void);
212 * @brief Remove the currently selected song from the playlist.
214 void gui_playq_song_remove(void);
216 * @brief Remove all songs from the playlist after presenting the user
217 * with a question.
219 void gui_playq_song_remove_all(void);
221 * @brief Randomize all songs in the playlist after presenting the user
222 * with a question.
224 void gui_playq_song_randomize(void);
227 * @brief Add a song before the selected item in the playlist.
229 void gui_playq_song_add_before(struct vfsref *ve);
231 * @brief Add a song after the selected item in the playlist.
233 void gui_playq_song_add_after(struct vfsref *ve);
235 * @brief Move the currently selected song one up.
237 void gui_playq_song_move_up(void);
239 * @brief Move the currently selected song one down.
241 void gui_playq_song_move_down(void);
243 * @brief Move the currently selected song to the top of the playlist.
245 void gui_playq_song_move_head(void);
247 * @brief Move the currently selected song to the bottom of the
248 * playlist.
250 void gui_playq_song_move_tail(void);
252 * @brief Start playback on the currently selected song.
254 void gui_playq_song_select(void);
256 * @brief Search for the next item matching gui_input_cursearch in the
257 * playlist.
259 int gui_playq_searchnext(const struct vfsmatch *vm);
261 * @brief Focus or unfocus the playlist.
263 void gui_playq_setfocus(int focus);
265 * @brief Write the full pathname of the selected item in the message
266 * bar.
268 void gui_playq_fullpath(void);
269 #ifdef BUILD_VOLUME
271 * @brief Increment the volume and display the new value.
273 void gui_playq_volume_up(void);
275 * @brief Decrement the volume and display the new value.
277 void gui_playq_volume_down(void);
278 #endif /* BUILD_VOLUME */
280 * @brief Go to the directory containing the selected item.
282 void gui_playq_gotofolder(void);
284 * @brief Go to the current user's home directory.
286 void gui_browser_gotohome(void);
288 * @brief Go to the parent directory of the VFS reference and select the
289 * item which shares the same filename.
291 void gui_browser_gotofile(struct vfsref *vr);
294 * gui_browser
297 * @brief Initialize the filebrowser window.
299 void gui_browser_init(void);
301 * @brief Destroy the filebrowser window.
303 void gui_browser_destroy(void);
305 * @brief Redraw the filebrowser, because of a terminal resize.
307 void gui_browser_resize(void);
310 * @brief Move the cursor of the filebrowser one position up.
312 void gui_browser_cursor_up(void);
314 * @brief Move the cursor of the filebrowser one position down.
316 void gui_browser_cursor_down(void);
318 * @brief Move the cursor and the viewport of the filebrowser one page
319 * up.
321 void gui_browser_cursor_pageup(void);
323 * @brief Move the cursor and the viewport of the filebrowser one page
324 * down.
326 void gui_browser_cursor_pagedown(void);
328 * @brief Move the cursor and the viewport of the filebrowser to the top
329 * of the current directory.
331 void gui_browser_cursor_head(void);
333 * @brief Move the cursor and the viewport of the filebrowser to the
334 * bottom of the current directory.
336 void gui_browser_cursor_tail(void);
338 * @brief Change the current working directory of the filebrowser to the
339 * parent directory.
341 void gui_browser_dir_parent(void);
343 * @brief Change the current working directory of the filebrowser to the
344 * currently selected item.
346 void gui_browser_dir_enter(void);
348 * @brief Add the current selection to the tail of the playlist.
350 void gui_browser_playq_add_tail(void);
352 * @brief Add the current selection to the head of the playlist.
354 void gui_browser_playq_add_head(void);
356 * @brief Add the current selection after the selected item in the
357 * playlist.
359 void gui_browser_playq_add_after(void);
361 * @brief Add the current selection before the selected item in the
362 * playlist.
364 void gui_browser_playq_add_before(void);
366 * @brief Search for the next item matching gui_input_cursearch in the
367 * file browser.
369 int gui_browser_searchnext(const struct vfsmatch *vm);
371 * @brief Change to a directory, filled in by the user.
373 void gui_browser_chdir(void);
375 * @brief Focus or unfocus the filebrowser.
377 void gui_browser_setfocus(int focus);
379 * @brief Write the playlist to a file.
381 void gui_browser_write_playlist(void);
383 * @brief Write the full pathname of the selected item in the message
384 * bar.
386 void gui_browser_fullpath(void);
388 * @brief Apply a recursive search filter on the current directory.
390 int gui_browser_locate(const struct vfsmatch *vm);
392 * @brief Go to the directory containing the selected item.
394 void gui_browser_gotofolder(void);