Code

screen: moved code to title_bar.c
[ncmpc.git] / src / screen.h
1 /* ncmpc (Ncurses MPD Client)
2  * (c) 2004-2009 The Music Player Daemon Project
3  * Project homepage: http://musicpd.org
4  
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
20 #ifndef SCREEN_H
21 #define SCREEN_H
23 #include "config.h"
24 #include "command.h"
25 #include "window.h"
26 #include "title_bar.h"
27 #include "progress_bar.h"
29 #include <mpd/client.h>
31 #include <glib.h>
33 #ifdef HAVE_NCURSESW_NCURSES_H
34 #include <ncursesw/ncurses.h>
35 #else
36 #include <ncurses.h>
37 #endif
39 #define IS_PLAYING(s) (s==MPD_STATE_PLAY)
40 #define IS_PAUSED(s) (s==MPD_STATE_PAUSE)
41 #define IS_STOPPED(s) (!(IS_PLAYING(s) | IS_PAUSED(s)))
43 #define MAX_SONGNAME_LENGTH   512
45 struct mpdclient;
47 struct screen {
48         struct title_bar title_bar;
49         struct window main_window;
50         struct progress_bar progress_bar;
51         struct window status_window;
53         /* GTime is equivalent to time_t */
54         GTime start_timestamp;
55         GTime status_timestamp;
57         unsigned cols, rows;
59         char *buf;
60         size_t buf_size;
62         char *findbuf;
63         GList *find_history;
64 };
66 extern struct screen screen;
68 extern const struct screen_functions screen_playlist;
69 extern const struct screen_functions screen_browse;
70 #ifdef ENABLE_ARTIST_SCREEN
71 extern const struct screen_functions screen_artist;
72 #endif
73 extern const struct screen_functions screen_help;
74 #ifdef ENABLE_SEARCH_SCREEN
75 extern const struct screen_functions screen_search;
76 #endif
77 #ifdef ENABLE_SONG_SCREEN
78 extern const struct screen_functions screen_song;
79 #endif
80 #ifdef ENABLE_KEYDEF_SCREEN
81 extern const struct screen_functions screen_keydef;
82 #endif
83 #ifdef ENABLE_LYRICS_SCREEN
84 extern const struct screen_functions screen_lyrics;
85 #endif
86 #ifdef ENABLE_OUTPUTS_SCREEN
87 extern const struct screen_functions screen_outputs;
88 #endif
91 typedef struct screen_functions {
92         void (*init)(WINDOW *w, int cols, int rows);
93         void (*exit)(void);
94         void (*open)(struct mpdclient *c);
95         void (*close)(void);
96         void (*resize)(int cols, int rows);
97         void (*paint)(void);
98         void (*update)(struct mpdclient *c);
99         bool (*cmd)(struct mpdclient *c, command_t cmd);
100         const char *(*get_title)(char *s, size_t size);
101 } screen_functions_t;
103 void screen_init(struct mpdclient *c);
104 void screen_exit(void);
105 void screen_resize(struct mpdclient *c);
106 void screen_status_message(const char *msg);
107 void screen_status_printf(const char *format, ...);
108 char *screen_error(void);
109 void screen_paint(struct mpdclient *c);
110 void screen_update(struct mpdclient *c);
111 void screen_cmd(struct mpdclient *c, command_t cmd);
112 gint screen_get_id(const char *name);
114 void
115 screen_switch(const struct screen_functions *sf, struct mpdclient *c);
116 void 
117 screen_swap(struct mpdclient *c, const struct mpd_song *song);
119 gboolean
120 screen_is_visible(const struct screen_functions *sf);
122 int
123 screen_get_mouse_event(struct mpdclient *c, unsigned long *bstate, int *row);
125 bool
126 screen_file_goto_song(struct mpdclient *c, const struct mpd_song *song);
128 #ifdef ENABLE_SONG_SCREEN
129 void
130 screen_song_switch(struct mpdclient *c, const struct mpd_song *song);
131 #endif
133 #ifdef ENABLE_LYRICS_SCREEN
134 void
135 screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song, bool follow);
136 #endif
138 #endif