X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fscreen.h;h=7c2d2140da2c26c1e58953f57fdfb7426680b7a5;hb=655cd7831d0226c2e223280c61228be26f1bb8f8;hp=75852d36e738da2994e571002ccce437599b1afa;hpb=ddd95cfda00af6e9093b8958af5679cf9b9cc54f;p=ncmpc.git diff --git a/src/screen.h b/src/screen.h index 75852d3..7c2d214 100644 --- a/src/screen.h +++ b/src/screen.h @@ -1,100 +1,89 @@ +/* ncmpc (Ncurses MPD Client) + * (c) 2004-2017 The Music Player Daemon Project + * Project homepage: http://musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + #ifndef SCREEN_H #define SCREEN_H -#include -#include "list_window.h" - -/* minumum window size */ -#define SCREEN_MIN_COLS 14 -#define SCREEN_MIN_ROWS 5 - -#define IS_PLAYING(s) (s==MPD_STATUS_STATE_PLAY) -#define IS_PAUSED(s) (s==MPD_STATUS_STATE_PAUSE) -#define IS_STOPPED(s) (!(IS_PLAYING(s) | IS_PAUSED(s))) +#include "config.h" +#include "command.h" +#include "window.h" +#include "title_bar.h" +#include "progress_bar.h" +#include "status_bar.h" +#include "ncmpc_curses.h" -typedef enum -{ - SCREEN_PLAY_WINDOW = 0, - SCREEN_FILE_WINDOW, - SCREEN_HELP_WINDOW, - SCREEN_KEYDEF_WINDOW, - SCREEN_SEARCH_WINDOW +#include -} screen_mode_t; +#include -typedef struct -{ - WINDOW *w; - int rows, cols; +#include -} window_t; +struct mpdclient; +struct screen_functions; +struct screen { + struct title_bar title_bar; + struct window main_window; + struct progress_bar progress_bar; + struct status_bar status_bar; + const struct screen_functions *current_page; -typedef struct -{ - window_t top_window; - window_t main_window; - window_t progress_window; - window_t status_window; + char *buf; + size_t buf_size; - GList *screen_list; + char *findbuf; + GList *find_history; - time_t start_timestamp; - time_t status_timestamp; - time_t input_timestamp; - command_t last_cmd; - - int cols, rows; - - screen_mode_t mode; - - char *buf; - size_t buf_size; +#ifndef NCMPC_MINI + /** + * Non-zero when the welcome message is currently being + * displayed. The associated timer will disable it. + */ + guint welcome_source_id; +#endif +}; - char *findbuf; +extern struct screen screen; - int painted; +void screen_init(struct mpdclient *c); +void screen_exit(void); +void screen_resize(struct mpdclient *c); -} screen_t; +void +screen_paint(struct mpdclient *c, bool main_dirty); +void screen_update(struct mpdclient *c); +void screen_cmd(struct mpdclient *c, command_t cmd); -typedef void (*screen_init_fn_t) (WINDOW *w, int cols, int rows); -typedef void (*screen_exit_fn_t) (void); -typedef void (*screen_open_fn_t) (screen_t *screen, mpd_client_t *c); -typedef void (*screen_close_fn_t) (void); -typedef void (*screen_resize_fn_t) (int cols, int rows); -typedef void (*screen_paint_fn_t) (screen_t *screen, mpd_client_t *c); -typedef void (*screen_update_fn_t) (screen_t *screen, mpd_client_t *c); -typedef int (*screen_cmd_fn_t) (screen_t *scr, mpd_client_t *c, command_t cmd); -typedef char * (*screen_title_fn_t) (void); -typedef list_window_t * (*screen_get_lw_fn_t) (void); +void +screen_switch(const struct screen_functions *sf, struct mpdclient *c); +void +screen_swap(struct mpdclient *c, const struct mpd_song *song); -typedef struct +static inline bool +screen_is_visible(const struct screen_functions *sf) { - screen_init_fn_t init; - screen_exit_fn_t exit; - screen_open_fn_t open; - screen_close_fn_t close; - screen_resize_fn_t resize; - screen_paint_fn_t paint; - screen_update_fn_t update; - screen_cmd_fn_t cmd; - screen_title_fn_t get_title; - screen_get_lw_fn_t get_lw; - -} screen_functions_t; - - -int screen_init(void); -int screen_exit(void); -void screen_resize(void); -void screen_status_message(char *msg); -void screen_status_printf(char *format, ...); -char *screen_error(void); -void screen_paint(mpd_client_t *c); -void screen_update(mpd_client_t *c); -void screen_idle(mpd_client_t *c); -void screen_cmd(mpd_client_t *c, command_t cmd); + return sf == screen.current_page; +} + +int +screen_get_mouse_event(struct mpdclient *c, unsigned long *bstate, int *row); #endif