Skip to content

Commit d1ade35

Browse files
committed
rg_gui+rg_surface: Added rg_margins_t
1 parent be325c7 commit d1ade35

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

components/retro-go/rg_display.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,15 @@ typedef struct
7474
// bool (*write)(int left, int top, int width, int height, int pitch, const uint16_t data);
7575
} rg_display_driver_t;
7676

77+
#include "rg_surface.h"
78+
7779
typedef struct
7880
{
7981
struct
8082
{
8183
int real_width, real_height; // Real physical resolution
8284
int width, height; // Visible resolution (minus margins)
83-
struct {int left, top, right, bottom;} margins;
85+
rg_margins_t margins;
8486
int format;
8587
} screen;
8688
struct
@@ -97,8 +99,6 @@ typedef struct
9799
bool changed;
98100
} rg_display_t;
99101

100-
#include "rg_surface.h"
101-
102102
void rg_display_init(void);
103103
void rg_display_deinit(void);
104104
void rg_display_write_rect(int left, int top, int width, int height, int stride, const uint16_t *buffer, uint32_t flags);

components/retro-go/rg_gui.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static struct
1616
uint16_t *screen_buffer, *draw_buffer;
1717
size_t draw_buffer_size;
1818
int screen_width, screen_height;
19-
struct {int left, top, right, bottom;} margins;
19+
rg_margins_t margins;
2020
struct
2121
{
2222
rg_color_t box_background;
@@ -106,7 +106,7 @@ void rg_gui_init(void)
106106
gui.screen_height = rg_display_get_height();
107107
// FIXME: RG_SCREEN_SAFE_AREA being added on top of RG_SCREEN_VISIBLE_AREA might not be super intuitive
108108
// because of how this is defined in config.h. It should be documented somewhere...
109-
gui.margins = (__typeof__(gui.margins))RG_SCREEN_SAFE_AREA;
109+
gui.margins = (rg_margins_t)RG_SCREEN_SAFE_AREA;
110110
gui.draw_buffer = get_draw_buffer(gui.screen_width, 18, C_BLACK);
111111
gui.show_clock = rg_settings_get_boolean(NS_GLOBAL, SETTING_CLOCK, false);
112112
if (!rg_gui_set_language_id(rg_settings_get_number(NS_GLOBAL, SETTING_LANGUAGE, RG_LANG_DEFAULT)))
@@ -239,6 +239,11 @@ void rg_gui_set_surface(rg_surface_t *surface)
239239
gui.screen_buffer = surface ? surface->data : NULL;
240240
}
241241

242+
rg_margins_t rg_gui_get_safe_area(void)
243+
{
244+
return gui.margins;
245+
}
246+
242247
void rg_gui_copy_buffer(int left, int top, int width, int height, int stride, const uint16_t *buffer, bool transparency)
243248
{
244249
left = get_horizontal_position(left, width);

components/retro-go/rg_gui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ bool rg_gui_set_theme(const char *name);
119119
const char *rg_gui_get_theme_name(void);
120120
rg_image_t *rg_gui_get_theme_image(const char *name);
121121
rg_color_t rg_gui_get_theme_color(const char *section, const char *key, rg_color_t default_value);
122+
rg_margins_t rg_gui_get_safe_area(void);
122123
void rg_gui_copy_buffer(int left, int top, int width, int height, int stride, const uint16_t *buffer, bool transparency);
123124

124125
rg_rect_t rg_gui_draw_text(int x_pos, int y_pos, int width, const char *text, // const rg_font_t *font,

components/retro-go/rg_surface.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ typedef struct
3030
int width, height;
3131
} rg_rect_t;
3232

33+
typedef struct
34+
{
35+
int left, top;
36+
int right, bottom;
37+
} rg_margins_t;
38+
3339
typedef struct
3440
{
3541
int width, height;

0 commit comments

Comments
 (0)