forked from libretro/RetroArch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgfx_widgets.h
213 lines (172 loc) · 6.54 KB
/
gfx_widgets.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/* RetroArch - A frontend for libretro.
* Copyright (C) 2018 - natinusala
*
* RetroArch 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 Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch 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 RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _GFX_WIDGETS_H
#define _GFX_WIDGETS_H
#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
#include <formats/image.h>
#include <queues/task_queue.h>
#include <queues/message_queue.h>
#include "gfx_animation.h"
#define DEFAULT_BACKDROP 0.75f
#define MSG_QUEUE_PENDING_MAX 32
#define MSG_QUEUE_ONSCREEN_MAX 4
#define MSG_QUEUE_ANIMATION_DURATION 330
#define CHEEVO_NOTIFICATION_DURATION 4000
#define TASK_FINISHED_DURATION 3000
#define HOURGLASS_INTERVAL 5000
#define HOURGLASS_DURATION 1000
#define GENERIC_MESSAGE_DURATION 3000
/* TODO: Colors for warning, error and success */
#define TEXT_COLOR_INFO 0xD8EEFFFF
#if 0
#define TEXT_COLOR_SUCCESS 0x22B14CFF
#define TEXT_COLOR_ERROR 0xC23B22FF
#endif
#define TEXT_COLOR_FAINT 0x878787FF
/* A widget */
/* TODO: cleanup all unused parameters */
struct gfx_widget
{
/* called when the widgets system is initialized
* -> initialize the widget here */
bool (*init)(bool video_is_threaded, bool fullscreen);
/* called when the widgets system is freed
* -> free the widget here */
void (*free)(void);
/* called when the graphics context is reset
* -> (re)load the textures here */
void (*context_reset)(bool is_threaded,
unsigned width, unsigned height, bool fullscreen,
const char *dir_assets, char *font_path,
char* menu_png_path,
char* widgets_png_path);
/* called when the graphics context is destroyed
* -> release the textures here */
void (*context_destroy)(void);
/* called when the window resolution changes
* -> (re)layout the widget here */
void (*layout)(bool is_threaded, const char *dir_assets, char *font_path);
/* called every frame on the main thread
* -> update the widget logic here */
void (*iterate)(
unsigned width, unsigned height, bool fullscreen,
const char *dir_assets, char *font_path,
bool is_threaded);
/* called every frame
* (on the video thread if threaded video is on)
* -> draw the widget here */
void (*frame)(void* data);
};
/* This structure holds all objects + metadata
* corresponding to a particular font */
typedef struct
{
font_data_t *font;
video_font_raster_block_t raster_block;
unsigned glyph_width;
float line_height;
float line_ascender;
float line_descender;
float line_centre_offset;
size_t usage_count;
} gfx_widget_font_data_t;
gfx_animation_ctx_tag gfx_widgets_get_generic_tag(void);
float* gfx_widgets_get_pure_white(void);
unsigned gfx_widgets_get_padding(void);
unsigned gfx_widgets_get_height(void);
gfx_widget_font_data_t* gfx_widgets_get_font_regular(void);
gfx_widget_font_data_t* gfx_widgets_get_font_bold(void);
gfx_widget_font_data_t* gfx_widgets_get_font_msg_queue(void);
float* gfx_widgets_get_backdrop_orig(void);
unsigned gfx_widgets_get_last_video_width(void);
unsigned gfx_widgets_get_last_video_height(void);
unsigned gfx_widgets_get_generic_message_height(void);
float gfx_widgets_get_thumbnail_scale_factor(
const float dst_width, const float dst_height,
const float image_width, const float image_height);
void gfx_widgets_draw_icon(
void *userdata,
unsigned video_width,
unsigned video_height,
unsigned icon_width,
unsigned icon_height,
uintptr_t texture,
float x, float y,
unsigned width, unsigned height,
float rotation, float scale_factor,
float *color);
void gfx_widgets_draw_text(
gfx_widget_font_data_t* font_data,
const char *text,
float x, float y,
int width, int height,
uint32_t color,
enum text_alignment text_align,
bool draw_outside);
void gfx_widgets_flush_text(
unsigned video_width, unsigned video_height,
gfx_widget_font_data_t* font_data);
typedef struct gfx_widget gfx_widget_t;
extern const gfx_widget_t gfx_widget_screenshot;
extern const gfx_widget_t gfx_widget_volume;
extern const gfx_widget_t gfx_widget_generic_message;
extern const gfx_widget_t gfx_widget_libretro_message;
bool gfx_widgets_active(void);
void gfx_widgets_set_persistence(bool persist);
bool gfx_widgets_init(
bool video_is_threaded,
unsigned width, unsigned height, bool fullscreen,
const char *dir_assets, char *font_path);
void gfx_widgets_deinit(void);
void gfx_widgets_msg_queue_push(
retro_task_t *task, const char *msg,
unsigned duration,
char *title,
enum message_queue_icon icon,
enum message_queue_category category,
unsigned prio, bool flush,
bool menu_is_alive);
void gfx_widget_volume_update_and_show(float new_volume,
bool mute);
void gfx_widgets_iterate(
unsigned width, unsigned height, bool fullscreen,
const char *dir_assets, char *font_path,
bool is_threaded);
void gfx_widget_screenshot_taken(const char *shotname, const char *filename);
/* AI Service functions */
#ifdef HAVE_TRANSLATE
int gfx_widgets_ai_service_overlay_get_state(void);
bool gfx_widgets_ai_service_overlay_set_state(int state);
bool gfx_widgets_ai_service_overlay_load(
char* buffer, unsigned buffer_len,
enum image_type_enum image_type);
void gfx_widgets_ai_service_overlay_unload(void);
#endif
void gfx_widgets_start_load_content_animation(
const char *content_name, bool remove_extension);
void gfx_widgets_cleanup_load_content_animation(void);
void gfx_widgets_push_achievement(const char *title, const char *badge);
/* Warning: not thread safe! */
void gfx_widget_set_message(char *message);
/* Warning: not thread safe! */
void gfx_widget_set_libretro_message(const char *message, unsigned duration);
/* All the functions below should be called in
* the video driver - once they are all added, set
* enable_menu_widgets to true for that driver */
void gfx_widgets_frame(void *data);
bool gfx_widgets_set_fps_text(const char *new_fps_text);
#endif