Create menu_display_set_alpha

This commit is contained in:
twinaphex 2016-04-21 04:34:02 +02:00
parent 02776fed31
commit c9ed624078
4 changed files with 28 additions and 41 deletions

View File

@ -659,14 +659,6 @@ static size_t mui_list_get_size(void *data, enum menu_list_type type)
return 0;
}
static void bgcolor_setalpha(float *bg, float alpha)
{
bg[3] = alpha;
bg[7] = alpha;
bg[11] = alpha;
bg[15] = alpha;
}
static int mui_get_core_title(char *s, size_t len)
{
struct retro_system_info *system = NULL;
@ -836,8 +828,7 @@ static void mui_frame(void *data)
{
background_rendered = true;
/* Set new opacity for transposed white background */
bgcolor_setalpha(white_transp_bg, 0.30);
menu_display_set_alpha(white_transp_bg, 0.30);
memset(&draw, 0, sizeof(menu_display_ctx_draw_t));
@ -863,7 +854,7 @@ static void mui_frame(void *data)
mui_draw_bg(&draw);
/* Restore opacity of transposed white background */
bgcolor_setalpha(white_transp_bg, 0.90);
menu_display_set_alpha(white_transp_bg, 0.90);
}
}
@ -873,9 +864,9 @@ static void mui_frame(void *data)
return;
if (background_rendered || libretro_running)
bgcolor_setalpha(lightblue_bg, 0.75);
menu_display_set_alpha(lightblue_bg, 0.75);
else
bgcolor_setalpha(lightblue_bg, 1.0);
menu_display_set_alpha(lightblue_bg, 1.0);
/* highlighted entry */
mui_render_quad(mui, 0,

View File

@ -407,7 +407,8 @@ static void xmb_draw_icon_predone(xmb_handle_t *xmb,
{
for (i = 0; i < 16; i++)
shadow[i] = 0;
shadow[3] = shadow[7] = shadow[11] = shadow[15] = color[3]/4;
menu_display_set_alpha(shadow, color[3] / 4);
coords.color = shadow;
draw.x = x + 2;
@ -1701,19 +1702,15 @@ static void xmb_draw_items(xmb_handle_t *xmb,
menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL);
/* set alpha components of color */
color[3] = color[7] = color[11] = color[15] =
(node->alpha > xmb->alpha)
? xmb->alpha : node->alpha;
menu_display_set_alpha(color, node->alpha > xmb->alpha
? xmb->alpha : node->alpha);
if (color[3] != 0)
xmb_draw_icon(xmb, icon, icon_x, icon_y, width, height,
0, node->zoom, &color[0]);
/* set alpha components of color */
color[3] = color[7] = color[11] = color[15] =
(node->alpha > xmb->alpha)
? xmb->alpha : node->alpha;
menu_display_set_alpha(color, node->alpha > xmb->alpha
? xmb->alpha : node->alpha);
if (texture_switch != 0 && color[3] != 0)
xmb_draw_icon_predone(xmb, &mymat,
@ -1855,12 +1852,9 @@ static void xmb_frame(void *data)
item_color[i] = 1.0f;
}
/* set alpha components of colors */
coord_color[3] = coord_color[7] = coord_color[11] = coord_color[15] =
((float)settings->menu.xmb_alpha_factor/100 > xmb->alpha) ?
xmb->alpha : (float)settings->menu.xmb_alpha_factor/100;
coord_color2[3] = coord_color2[7] = coord_color2[11] = coord_color2[15] =
xmb->alpha;
menu_display_set_alpha(coord_color, ((float)settings->menu.xmb_alpha_factor/100 > xmb->alpha) ?
xmb->alpha : (float)settings->menu.xmb_alpha_factor/100);
menu_display_set_alpha(coord_color2, xmb->alpha);
memset(&draw, 0, sizeof(menu_display_ctx_draw_t));
@ -1946,9 +1940,7 @@ static void xmb_frame(void *data)
if (strcmp(xmb_thumbnails_ident(), "OFF") && xmb->thumbnail)
xmb_draw_thumbnail(xmb, &coord_color2[0], width, height);
/* set alpha components of colors */
coord_color2[3] = coord_color2[7] = coord_color2[11] =
coord_color2[15] = (1.00f > xmb->alpha) ? xmb->alpha : 1.00f;
menu_display_set_alpha(coord_color2, 1.00f > xmb->alpha ? xmb->alpha : 1.00f);
if (settings->menu.timedate_enable && coord_color2[3] != 0)
xmb_draw_icon_predone(xmb, &mymat,
@ -1956,10 +1948,8 @@ static void xmb_frame(void *data)
width - xmb->icon.size, xmb->icon.size,width,
height, 1, 0, 1, &coord_color2[0]);
/* set alpha components of colors */
coord_color2[3] = coord_color2[7] = coord_color2[11] =
coord_color2[15] = (xmb->textures.arrow.alpha > xmb->alpha)
? xmb->alpha : xmb->textures.arrow.alpha;
menu_display_set_alpha(coord_color2, xmb->textures.arrow.alpha > xmb->alpha
? xmb->alpha : xmb->textures.arrow.alpha);
if (coord_color2[3] != 0)
xmb_draw_icon_predone(
@ -1987,9 +1977,8 @@ static void xmb_frame(void *data)
menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL);
/* set alpha components of color */
item_color[3] = item_color[7] = item_color[11] = item_color[15] = (node->alpha > xmb->alpha)
? xmb->alpha : node->alpha;
menu_display_set_alpha(item_color, node->alpha > xmb->alpha
? xmb->alpha : node->alpha);
if (item_color[3] != 0)
xmb_draw_icon(xmb, node->icon,
@ -2055,9 +2044,7 @@ static void xmb_frame(void *data)
xmb_render_messagebox_internal(xmb, msg);
}
/* set alpha components of colors */
coord_color2[3] = coord_color2[7] = coord_color2[11] =
coord_color2[15] = (1.00f > xmb->alpha) ? xmb->alpha : 1.00f;
menu_display_set_alpha(coord_color2, 1.00f > xmb->alpha ? xmb->alpha : 1.00f);
if ( settings->menu.mouse.enable && (settings->video.fullscreen
|| !video_driver_ctl(RARCH_DISPLAY_CTL_HAS_WINDOWED, NULL)))

View File

@ -835,3 +835,10 @@ void menu_display_draw_text(const char *msg,
video_driver_set_osd_msg(msg, params, fb_buf);
}
void menu_display_set_alpha(float *color, float alpha_value)
{
if (!color)
return;
color[3] = color[7] = color[11] = color[15] = alpha_value;
}

View File

@ -194,6 +194,8 @@ void menu_display_draw_cursor(
void menu_display_draw_text(const char *msg, int width, int height,
struct font_params *params);
void menu_display_set_alpha(float *color, float alpha_value);
extern uintptr_t menu_display_white_texture;
extern menu_display_ctx_driver_t menu_display_ctx_gl;