1 /*  RetroArch - A frontend for libretro.
2  *  Copyright (C) 2010-2014 - Hans-Kristian Arntzen
3  *  Copyright (C) 2011-2017 - Daniel De Matteis
4  *
5  *  RetroArch is free software: you can redistribute it and/or modify it under the terms
6  *  of the GNU General Public License as published by the Free Software Found-
7  *  ation, either version 3 of the License, or (at your option) any later version.
8  *
9  *  RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10  *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  *  PURPOSE.  See the GNU General Public License for more details.
12  *
13  *  You should have received a copy of the GNU General Public License along with RetroArch.
14  *  If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef __UI_COMPANION_DRIVER_H
18 #define __UI_COMPANION_DRIVER_H
19 
20 #include <stddef.h>
21 
22 #include <boolean.h>
23 #include <retro_common_api.h>
24 #include <lists/file_list.h>
25 
26 #ifdef HAVE_CONFIG_H
27 #include "../config.h"
28 #endif
29 
30 #include "../command.h"
31 
32 RETRO_BEGIN_DECLS
33 
34 enum ui_msg_window_buttons
35 {
36    UI_MSG_WINDOW_OK = 0,
37    UI_MSG_WINDOW_OKCANCEL,
38    UI_MSG_WINDOW_YESNO,
39    UI_MSG_WINDOW_YESNOCANCEL
40 };
41 
42 enum ui_msg_window_response
43 {
44    UI_MSG_RESPONSE_NA = 0,
45    UI_MSG_RESPONSE_OK,
46    UI_MSG_RESPONSE_CANCEL,
47    UI_MSG_RESPONSE_YES,
48    UI_MSG_RESPONSE_NO
49 };
50 
51 enum ui_msg_window_type
52 {
53     UI_MSG_WINDOW_TYPE_ERROR = 0,
54     UI_MSG_WINDOW_TYPE_INFORMATION,
55     UI_MSG_WINDOW_TYPE_QUESTION,
56     UI_MSG_WINDOW_TYPE_WARNING
57 };
58 
59 typedef struct ui_msg_window_state
60 {
61    enum ui_msg_window_buttons buttons;
62    char *text;
63    char *title;
64    void *window;
65 } ui_msg_window_state;
66 
67 typedef struct ui_browser_window_state
68 {
69    struct
70    {
71       bool can_choose_directories;
72       bool can_choose_directories_val;
73       bool can_choose_files;
74       bool can_choose_files_val;
75       bool allows_multiple_selection;
76       bool allows_multiple_selection_val;
77       bool treat_file_packages_as_directories;
78       bool treat_file_packages_as_directories_val;
79    } capabilities;
80    void *window;
81    char *filters;
82    char *filters_title;
83    char *startdir;
84    char *path;
85    char *title;
86    char *result;
87 } ui_browser_window_state_t;
88 
89 typedef struct ui_browser_window
90 {
91    bool (*open)(ui_browser_window_state_t *state);
92    bool (*save)(ui_browser_window_state_t *state);
93    const char *ident;
94 } ui_browser_window_t;
95 
96 typedef struct ui_msg_window
97 {
98    enum ui_msg_window_response (*error      )(ui_msg_window_state *state);
99    enum ui_msg_window_response (*information)(ui_msg_window_state *state);
100    enum ui_msg_window_response (*question   )(ui_msg_window_state *state);
101    enum ui_msg_window_response (*warning    )(ui_msg_window_state *state);
102    const char *ident;
103 } ui_msg_window_t;
104 
105 typedef struct ui_application
106 {
107    void* (*initialize)(void);
108    void (*process_events)(void);
109    void (*quit)(void);
110    bool exiting;
111    const char *ident;
112 } ui_application_t;
113 
114 typedef struct ui_window
115 {
116    void* (*init)(void);
117    void (*destroy)(void *data);
118    void (*set_focused)(void *data);
119    void (*set_visible)(void *data, bool visible);
120    void (*set_title)(void *data, char *buf);
121    void (*set_droppable)(void *data, bool droppable);
122    bool (*focused)(void *data);
123    const char *ident;
124 } ui_window_t;
125 
126 typedef struct ui_companion_driver
127 {
128    void *(*init)(void);
129    void (*deinit)(void *data);
130    void (*toggle)(void *data, bool force);
131    void (*event_command)(void *data, enum event_command action);
132    void (*notify_content_loaded)(void *data);
133    void (*notify_list_loaded)(void *data, file_list_t *list, file_list_t *menu_list);
134    void (*notify_refresh)(void *data);
135    void (*msg_queue_push)(void *data, const char *msg, unsigned priority, unsigned duration, bool flush);
136    void (*render_messagebox)(const char *msg);
137    void *(*get_main_window)(void *data);
138    void (*log_msg)(void *data, const char *msg);
139    bool (*is_active)(void *data);
140    ui_browser_window_t *browser_window;
141    ui_msg_window_t     *msg_window;
142    ui_window_t         *window;
143    ui_application_t    *application;
144    const char        *ident;
145 } ui_companion_driver_t;
146 
147 extern ui_companion_driver_t ui_companion_cocoa;
148 extern ui_companion_driver_t ui_companion_cocoatouch;
149 extern ui_companion_driver_t ui_companion_qt;
150 extern ui_companion_driver_t ui_companion_win32;
151 
152 bool ui_companion_is_on_foreground(void);
153 
154 void ui_companion_set_foreground(unsigned enable);
155 
156 void ui_companion_event_command(enum event_command action);
157 
158 void ui_companion_driver_notify_refresh(void);
159 
160 void ui_companion_driver_notify_list_loaded(file_list_t *list, file_list_t *menu_list);
161 
162 void ui_companion_driver_notify_content_loaded(void);
163 
164 void ui_companion_driver_free(void);
165 
166 const ui_msg_window_t *ui_companion_driver_get_msg_window_ptr(void);
167 
168 const ui_browser_window_t *ui_companion_driver_get_browser_window_ptr(void);
169 
170 const ui_window_t *ui_companion_driver_get_window_ptr(void);
171 
172 void ui_companion_driver_log_msg(const char *msg);
173 
174 void *ui_companion_driver_get_main_window(void);
175 
176 const char *ui_companion_driver_get_ident(void);
177 
178 RETRO_END_DECLS
179 
180 #endif
181