2012-05-06 02:04:33 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2015-01-07 16:46:50 +00:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
|
|
* Copyright (C) 2012-2015 - Michael Lelli
|
2014-04-13 10:12:12 +00:00
|
|
|
*
|
2012-05-06 02:04:33 +00:00
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stddef.h>
|
2014-10-16 05:27:42 +00:00
|
|
|
#include <stdint.h>
|
2012-05-06 02:04:33 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
2015-06-17 17:45:57 +00:00
|
|
|
#include <string/string_list.h>
|
2014-10-21 05:58:58 +00:00
|
|
|
#include <compat/posix_string.h>
|
2014-10-21 22:23:06 +00:00
|
|
|
#include <file/file_path.h>
|
2015-03-29 14:43:02 +00:00
|
|
|
#include <retro_inline.h>
|
2013-03-09 14:33:44 +00:00
|
|
|
|
2015-09-13 22:13:36 +00:00
|
|
|
#include "../../general.h"
|
2015-06-05 16:22:15 +00:00
|
|
|
#include "../menu.h"
|
2015-07-09 16:39:40 +00:00
|
|
|
#include "../menu_hash.h"
|
|
|
|
#include "../menu_video.h"
|
2015-06-05 16:22:15 +00:00
|
|
|
|
2015-01-12 22:34:10 +00:00
|
|
|
#include "../../gfx/drivers_font_renderer/bitmap.h"
|
2013-01-09 16:49:43 +00:00
|
|
|
|
2015-09-25 18:28:56 +00:00
|
|
|
#define RGUI_TERM_START_X(width) (width / 21)
|
|
|
|
#define RGUI_TERM_START_Y(height) (height / 9)
|
|
|
|
#define RGUI_TERM_WIDTH(width) (((width - RGUI_TERM_START_X(width) - RGUI_TERM_START_X(width)) / (FONT_WIDTH_STRIDE)))
|
|
|
|
#define RGUI_TERM_HEIGHT(width, height) (((height - RGUI_TERM_START_Y(height) - RGUI_TERM_START_X(width)) / (FONT_HEIGHT_STRIDE)) - 1)
|
2013-05-04 14:56:02 +00:00
|
|
|
|
2015-03-14 22:44:27 +00:00
|
|
|
#if defined(GEKKO)|| defined(PSP)
|
2015-05-08 07:25:16 +00:00
|
|
|
#define HOVER_COLOR(settings) ((3 << 0) | (10 << 4) | (3 << 8) | (7 << 12))
|
|
|
|
#define NORMAL_COLOR(settings) 0x7FFF
|
|
|
|
#define TITLE_COLOR(settings) HOVER_COLOR(settings)
|
2015-03-14 22:44:27 +00:00
|
|
|
#else
|
2015-05-08 07:25:16 +00:00
|
|
|
#define HOVER_COLOR(settings) (argb32_to_rgba4444(settings->menu.entry_hover_color))
|
|
|
|
#define NORMAL_COLOR(settings) (argb32_to_rgba4444(settings->menu.entry_normal_color))
|
|
|
|
#define TITLE_COLOR(settings) (argb32_to_rgba4444(settings->menu.title_color))
|
2015-03-14 22:44:27 +00:00
|
|
|
#endif
|
2015-03-14 22:21:55 +00:00
|
|
|
|
2015-07-08 15:27:34 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2015-06-24 02:07:08 +00:00
|
|
|
bool force_redraw;
|
2015-06-24 01:22:53 +00:00
|
|
|
char msgbox[4096];
|
2015-06-25 04:19:28 +00:00
|
|
|
unsigned last_width;
|
|
|
|
unsigned last_height;
|
2015-06-24 01:22:53 +00:00
|
|
|
} rgui_t;
|
|
|
|
|
2015-03-29 14:43:02 +00:00
|
|
|
static INLINE uint16_t argb32_to_rgba4444(uint32_t col)
|
2015-03-14 22:21:55 +00:00
|
|
|
{
|
|
|
|
unsigned a = ((col >> 24) & 0xff) >> 4;
|
2015-03-15 15:51:55 +00:00
|
|
|
unsigned r = ((col >> 16) & 0xff) >> 4;
|
2015-05-08 07:25:16 +00:00
|
|
|
unsigned g = ((col >> 8) & 0xff) >> 4;
|
|
|
|
unsigned b = (col & 0xff) >> 4;
|
|
|
|
return (r << 12) | (g << 8) | (b << 4) | a;
|
2015-03-14 22:21:55 +00:00
|
|
|
}
|
|
|
|
|
2013-11-04 12:27:03 +00:00
|
|
|
static void rgui_copy_glyph(uint8_t *glyph, const uint8_t *buf)
|
|
|
|
{
|
2015-02-02 18:02:34 +00:00
|
|
|
int x, y;
|
2015-01-10 22:45:14 +00:00
|
|
|
|
|
|
|
if (!glyph)
|
|
|
|
return;
|
|
|
|
|
2013-11-04 12:27:03 +00:00
|
|
|
for (y = 0; y < FONT_HEIGHT; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < FONT_WIDTH; x++)
|
|
|
|
{
|
|
|
|
uint32_t col =
|
|
|
|
((uint32_t)buf[3 * (-y * 256 + x) + 0] << 0) |
|
|
|
|
((uint32_t)buf[3 * (-y * 256 + x) + 1] << 8) |
|
|
|
|
((uint32_t)buf[3 * (-y * 256 + x) + 2] << 16);
|
|
|
|
|
2015-02-11 04:16:19 +00:00
|
|
|
uint8_t rem = 1 << ((x + y * FONT_WIDTH) & 7);
|
2013-11-04 12:27:03 +00:00
|
|
|
unsigned offset = (x + y * FONT_WIDTH) >> 3;
|
|
|
|
|
|
|
|
if (col != 0xff)
|
|
|
|
glyph[offset] |= rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint16_t gray_filler(unsigned x, unsigned y)
|
|
|
|
{
|
2015-01-10 22:45:14 +00:00
|
|
|
unsigned col;
|
|
|
|
|
2013-11-04 12:27:03 +00:00
|
|
|
x >>= 1;
|
|
|
|
y >>= 1;
|
2015-01-10 22:45:14 +00:00
|
|
|
col = ((x + y) & 1) + 1;
|
|
|
|
|
2014-02-18 21:01:04 +00:00
|
|
|
#if defined(GEKKO) || defined(PSP)
|
2013-11-04 12:27:03 +00:00
|
|
|
return (6 << 12) | (col << 8) | (col << 4) | (col << 0);
|
|
|
|
#else
|
|
|
|
return (col << 13) | (col << 9) | (col << 5) | (12 << 0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint16_t green_filler(unsigned x, unsigned y)
|
|
|
|
{
|
2015-01-10 22:45:14 +00:00
|
|
|
unsigned col;
|
|
|
|
|
2013-11-04 12:27:03 +00:00
|
|
|
x >>= 1;
|
|
|
|
y >>= 1;
|
2015-01-10 22:45:14 +00:00
|
|
|
col = ((x + y) & 1) + 1;
|
2014-02-18 21:01:04 +00:00
|
|
|
#if defined(GEKKO) || defined(PSP)
|
2013-11-04 12:27:03 +00:00
|
|
|
return (6 << 12) | (col << 8) | (col << 5) | (col << 0);
|
|
|
|
#else
|
|
|
|
return (col << 13) | (col << 10) | (col << 5) | (12 << 0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-09-25 18:42:45 +00:00
|
|
|
static void fill_rect(uint16_t *data, size_t pitch,
|
2013-11-04 12:27:03 +00:00
|
|
|
unsigned x, unsigned y,
|
|
|
|
unsigned width, unsigned height,
|
|
|
|
uint16_t (*col)(unsigned x, unsigned y))
|
|
|
|
{
|
2015-02-02 18:02:34 +00:00
|
|
|
unsigned i, j;
|
2015-06-25 04:19:28 +00:00
|
|
|
|
2015-09-25 18:42:45 +00:00
|
|
|
if (!data || !col)
|
2015-01-01 17:47:39 +00:00
|
|
|
return;
|
2015-06-25 04:19:28 +00:00
|
|
|
|
2013-11-04 12:27:03 +00:00
|
|
|
for (j = y; j < y + height; j++)
|
|
|
|
for (i = x; i < x + width; i++)
|
2015-09-25 18:42:45 +00:00
|
|
|
data[j * (pitch >> 1) + i] = col(i, j);
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
2015-02-11 04:23:02 +00:00
|
|
|
|
2015-09-25 18:47:50 +00:00
|
|
|
static void color_rect(
|
|
|
|
uint16_t *data, size_t pitch,
|
|
|
|
unsigned fb_width, unsigned fb_height,
|
2014-10-25 21:21:28 +00:00
|
|
|
unsigned x, unsigned y,
|
|
|
|
unsigned width, unsigned height,
|
|
|
|
uint16_t color)
|
|
|
|
{
|
2015-02-02 18:02:34 +00:00
|
|
|
unsigned i, j;
|
2015-01-10 22:45:14 +00:00
|
|
|
|
2015-09-25 18:47:50 +00:00
|
|
|
if (!data)
|
2015-01-10 22:45:14 +00:00
|
|
|
return;
|
|
|
|
|
2014-10-25 21:21:28 +00:00
|
|
|
for (j = y; j < y + height; j++)
|
|
|
|
for (i = x; i < x + width; i++)
|
2015-09-25 18:28:56 +00:00
|
|
|
if (i < fb_width && j < fb_height)
|
2015-09-25 18:47:50 +00:00
|
|
|
data[j * (pitch >> 1) + i] = color;
|
2014-10-25 21:21:28 +00:00
|
|
|
}
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-09-10 21:08:39 +00:00
|
|
|
static uint8_t string_walkbyte(const char **string)
|
|
|
|
{
|
|
|
|
return *((*string)++);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_UTF8
|
|
|
|
/* Does not validate the input, returns garbage if it's not UTF-8. */
|
|
|
|
static uint32_t string_walk(const char **string)
|
|
|
|
{
|
|
|
|
uint8_t first = string_walkbyte(string);
|
|
|
|
uint32_t ret;
|
|
|
|
|
|
|
|
if (first<128) return first;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
ret = (ret<<6) | (string_walkbyte(string)&0x3F);
|
|
|
|
if (first >= 0xE0) ret = (ret<<6) | (string_walkbyte(string)&0x3F);
|
|
|
|
if (first >= 0xF0) ret = (ret<<6) | (string_walkbyte(string)&0x3F);
|
|
|
|
|
|
|
|
if (first >= 0xF0) return ret | (first&31)<<18;
|
|
|
|
if (first >= 0xE0) return ret | (first&15)<<12;
|
|
|
|
return ret | (first&7)<<6;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define string_walk string_walkbyte
|
|
|
|
#endif
|
|
|
|
|
2015-09-25 18:54:39 +00:00
|
|
|
static void blit_line(uint16_t *data,
|
|
|
|
size_t pitch, int x, int y,
|
2015-04-21 14:45:27 +00:00
|
|
|
const char *message, uint16_t color)
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
2015-02-02 18:02:34 +00:00
|
|
|
unsigned i, j;
|
2015-06-14 13:34:05 +00:00
|
|
|
menu_display_t *disp = menu_display_get_ptr();
|
2014-05-30 19:51:12 +00:00
|
|
|
|
2013-11-04 12:27:03 +00:00
|
|
|
while (*message)
|
|
|
|
{
|
2015-09-10 21:08:39 +00:00
|
|
|
uint32_t symbol = string_walk(&message);
|
|
|
|
|
2013-11-04 12:27:03 +00:00
|
|
|
for (j = 0; j < FONT_HEIGHT; j++)
|
|
|
|
{
|
|
|
|
for (i = 0; i < FONT_WIDTH; i++)
|
|
|
|
{
|
|
|
|
uint8_t rem = 1 << ((i + j * FONT_WIDTH) & 7);
|
2015-01-19 05:44:46 +00:00
|
|
|
int offset = (i + j * FONT_WIDTH) >> 3;
|
2015-09-10 21:08:39 +00:00
|
|
|
bool col = (disp->font.framebuf[FONT_OFFSET(symbol) + offset] & rem);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-01-19 05:44:46 +00:00
|
|
|
if (!col)
|
|
|
|
continue;
|
|
|
|
|
2015-09-25 18:54:39 +00:00
|
|
|
data[(y + j) * (pitch >> 1) + (x + i)] = color;
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
x += FONT_WIDTH_STRIDE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-12 04:30:53 +00:00
|
|
|
static bool init_font(menu_handle_t *menu, const uint8_t *font_bmp_buf)
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
uint8_t *font = (uint8_t *) calloc(1, FONT_OFFSET(256));
|
2014-09-12 04:30:53 +00:00
|
|
|
|
|
|
|
if (!font)
|
|
|
|
return false;
|
|
|
|
|
2015-06-14 13:34:05 +00:00
|
|
|
menu->display.font.alloc_framebuf = true;
|
2015-06-25 06:26:59 +00:00
|
|
|
|
2013-11-04 12:27:03 +00:00
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
{
|
|
|
|
unsigned y = i / 16;
|
|
|
|
unsigned x = i % 16;
|
|
|
|
rgui_copy_glyph(&font[FONT_OFFSET(i)],
|
|
|
|
font_bmp_buf + 54 + 3 * (256 * (255 - 16 * y) + 16 * x));
|
|
|
|
}
|
|
|
|
|
2015-06-14 13:34:05 +00:00
|
|
|
menu->display.font.framebuf = font;
|
2014-09-12 04:30:53 +00:00
|
|
|
return true;
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static bool rguidisp_init_font(menu_handle_t *menu)
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
|
|
|
const uint8_t *font_bmp_buf = NULL;
|
|
|
|
const uint8_t *font_bin_buf = bitmap_bin;
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
if (!menu)
|
|
|
|
return false;
|
|
|
|
|
2013-11-04 12:27:03 +00:00
|
|
|
if (font_bmp_buf)
|
2014-09-12 04:30:53 +00:00
|
|
|
return init_font(menu, font_bmp_buf);
|
2015-02-01 07:18:33 +00:00
|
|
|
|
|
|
|
if (!font_bin_buf)
|
2014-08-27 02:02:32 +00:00
|
|
|
return false;
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-06-14 13:34:05 +00:00
|
|
|
menu->display.font.framebuf = font_bin_buf;
|
2015-02-01 07:18:33 +00:00
|
|
|
|
2014-08-27 02:02:32 +00:00
|
|
|
return true;
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rgui_render_background(void)
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
2015-09-25 19:03:23 +00:00
|
|
|
size_t pitch_in_pixels, size, fb_pitch;
|
2015-09-25 18:28:56 +00:00
|
|
|
unsigned fb_width, fb_height;
|
2015-09-25 19:03:23 +00:00
|
|
|
uint16_t *fb_data = NULL;
|
2015-06-13 14:42:11 +00:00
|
|
|
uint16_t *src = NULL;
|
|
|
|
uint16_t *dst = NULL;
|
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-02-11 04:08:07 +00:00
|
|
|
if (!menu)
|
2015-01-10 22:45:14 +00:00
|
|
|
return;
|
|
|
|
|
2015-09-25 19:03:23 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width);
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &fb_height);
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_FB_DATA, &fb_data);
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_FB_PITCH, &fb_pitch);
|
2015-09-25 18:28:56 +00:00
|
|
|
|
2015-09-25 19:03:23 +00:00
|
|
|
pitch_in_pixels = fb_pitch >> 1;
|
|
|
|
size = fb_pitch * 4;
|
|
|
|
src = fb_data + pitch_in_pixels * fb_height;
|
|
|
|
dst = fb_data;
|
2015-03-08 12:18:32 +00:00
|
|
|
|
|
|
|
while (dst < src)
|
|
|
|
{
|
|
|
|
memcpy(dst, src, size);
|
|
|
|
dst += pitch_in_pixels * 4;
|
|
|
|
}
|
|
|
|
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-09-25 19:03:23 +00:00
|
|
|
fill_rect(fb_data, fb_pitch, 5, 5, fb_width - 10, 5, green_filler);
|
|
|
|
fill_rect(fb_data, fb_pitch, 5, fb_height - 10, fb_width - 10, 5, green_filler);
|
2015-09-25 18:28:56 +00:00
|
|
|
|
2015-09-25 19:03:23 +00:00
|
|
|
fill_rect(fb_data, fb_pitch, 5, 5, 5, fb_height - 10, green_filler);
|
|
|
|
fill_rect(fb_data, fb_pitch, fb_width - 10, 5, 5, fb_height - 10,
|
2014-09-02 14:03:17 +00:00
|
|
|
green_filler);
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
|
|
|
|
2015-06-24 01:22:53 +00:00
|
|
|
static void rgui_set_message(const char *message)
|
|
|
|
{
|
2015-06-24 02:07:08 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
|
|
|
rgui_t *rgui = NULL;
|
2015-06-24 01:22:53 +00:00
|
|
|
|
2015-09-06 00:41:36 +00:00
|
|
|
if (!menu || !menu->userdata || !message || !*message)
|
2015-06-24 01:22:53 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
rgui = (rgui_t*)menu->userdata;
|
|
|
|
strlcpy(rgui->msgbox, message, sizeof(rgui->msgbox));
|
2015-06-24 02:07:08 +00:00
|
|
|
rgui->force_redraw = true;
|
2015-06-24 01:22:53 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rgui_render_messagebox(const char *message)
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
2015-09-25 19:03:23 +00:00
|
|
|
size_t i, fb_pitch;
|
2015-01-04 14:22:49 +00:00
|
|
|
int x, y;
|
2015-09-25 18:28:56 +00:00
|
|
|
unsigned fb_width, fb_height;
|
2015-01-04 14:22:49 +00:00
|
|
|
unsigned width, glyphs_width, height;
|
2015-03-16 15:57:27 +00:00
|
|
|
uint16_t color;
|
2015-09-25 19:03:23 +00:00
|
|
|
uint16_t *fb_data = NULL;
|
2015-06-13 14:42:11 +00:00
|
|
|
struct string_list *list = NULL;
|
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
|
|
|
settings_t *settings = config_get_ptr();
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-09-25 18:28:56 +00:00
|
|
|
if (!menu || !message || !*message)
|
2013-11-04 12:27:03 +00:00
|
|
|
return;
|
|
|
|
|
2015-03-21 05:55:34 +00:00
|
|
|
(void)settings;
|
|
|
|
|
2015-01-04 14:22:49 +00:00
|
|
|
list = string_split(message, "\n");
|
2013-11-04 12:27:03 +00:00
|
|
|
if (!list)
|
|
|
|
return;
|
|
|
|
if (list->elems == 0)
|
2015-02-02 18:02:34 +00:00
|
|
|
goto end;
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-02-11 04:16:19 +00:00
|
|
|
width = 0;
|
2015-01-04 14:22:49 +00:00
|
|
|
glyphs_width = 0;
|
2015-02-11 04:16:19 +00:00
|
|
|
|
2015-09-25 18:28:56 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width);
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &fb_height);
|
2015-09-25 19:03:23 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_FB_DATA, &fb_data);
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_FB_PITCH, &fb_pitch);
|
2015-09-25 18:28:56 +00:00
|
|
|
|
2013-11-04 12:27:03 +00:00
|
|
|
for (i = 0; i < list->size; i++)
|
|
|
|
{
|
2015-01-04 14:22:49 +00:00
|
|
|
unsigned line_width;
|
2015-01-10 22:45:14 +00:00
|
|
|
char *msg = list->elems[i].data;
|
2013-11-04 12:27:03 +00:00
|
|
|
unsigned msglen = strlen(msg);
|
2015-01-04 14:22:49 +00:00
|
|
|
|
2015-09-25 18:28:56 +00:00
|
|
|
if (msglen > RGUI_TERM_WIDTH(fb_width))
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
2015-09-25 18:28:56 +00:00
|
|
|
msg[RGUI_TERM_WIDTH(fb_width) - 2] = '.';
|
|
|
|
msg[RGUI_TERM_WIDTH(fb_width) - 1] = '.';
|
|
|
|
msg[RGUI_TERM_WIDTH(fb_width) - 0] = '.';
|
|
|
|
msg[RGUI_TERM_WIDTH(fb_width) + 1] = '\0';
|
|
|
|
msglen = RGUI_TERM_WIDTH(fb_width);
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
|
|
|
|
2015-06-02 17:04:01 +00:00
|
|
|
line_width = msglen * FONT_WIDTH_STRIDE - 1 + 6 + 10;
|
|
|
|
width = max(width, line_width);
|
2013-11-04 12:27:03 +00:00
|
|
|
glyphs_width = max(glyphs_width, msglen);
|
|
|
|
}
|
|
|
|
|
2015-01-04 14:22:49 +00:00
|
|
|
height = FONT_HEIGHT_STRIDE * list->size + 6 + 10;
|
2015-09-25 18:28:56 +00:00
|
|
|
x = (fb_width - width) / 2;
|
|
|
|
y = (fb_height - height) / 2;
|
2014-04-13 10:12:12 +00:00
|
|
|
|
2015-09-25 19:03:23 +00:00
|
|
|
fill_rect(fb_data, fb_pitch, x + 5, y + 5, width - 10,
|
2015-04-21 14:45:27 +00:00
|
|
|
height - 10, gray_filler);
|
2015-09-25 19:03:23 +00:00
|
|
|
fill_rect(fb_data, fb_pitch, x, y, width - 5, 5, green_filler);
|
|
|
|
fill_rect(fb_data, fb_pitch, x + width - 5, y, 5,
|
2015-04-21 14:45:27 +00:00
|
|
|
height - 5, green_filler);
|
2015-09-25 19:03:23 +00:00
|
|
|
fill_rect(fb_data, fb_pitch, x + 5, y + height - 5,
|
2015-04-21 14:45:27 +00:00
|
|
|
width - 5, 5, green_filler);
|
2015-09-25 19:03:23 +00:00
|
|
|
fill_rect(fb_data, fb_pitch, x, y + 5, 5,
|
2015-04-21 14:45:27 +00:00
|
|
|
height - 5, green_filler);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-03-20 21:22:06 +00:00
|
|
|
color = NORMAL_COLOR(settings);
|
2015-03-14 22:44:27 +00:00
|
|
|
|
2013-11-04 12:27:03 +00:00
|
|
|
for (i = 0; i < list->size; i++)
|
|
|
|
{
|
|
|
|
const char *msg = list->elems[i].data;
|
2015-06-02 17:04:01 +00:00
|
|
|
int offset_x = FONT_WIDTH_STRIDE * (glyphs_width - strlen(msg)) / 2;
|
|
|
|
int offset_y = FONT_HEIGHT_STRIDE * i;
|
2015-09-25 19:03:23 +00:00
|
|
|
blit_line(fb_data, fb_pitch,
|
2015-09-25 18:54:39 +00:00
|
|
|
x + 8 + offset_x, y + 8 + offset_y, msg, color);
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
|
|
|
|
2015-02-02 18:02:34 +00:00
|
|
|
end:
|
2013-11-04 12:27:03 +00:00
|
|
|
string_list_free(list);
|
|
|
|
}
|
|
|
|
|
2015-02-11 04:08:07 +00:00
|
|
|
static void rgui_blit_cursor(menu_handle_t *menu)
|
2014-10-25 21:21:28 +00:00
|
|
|
{
|
2015-09-25 19:03:23 +00:00
|
|
|
size_t fb_pitch;
|
2015-09-25 18:47:50 +00:00
|
|
|
unsigned fb_width, fb_height;
|
2015-09-25 19:03:23 +00:00
|
|
|
uint16_t *fb_data = NULL;
|
|
|
|
int16_t x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
|
|
|
|
int16_t y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
2015-09-25 18:47:50 +00:00
|
|
|
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width);
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_height);
|
2015-09-25 19:03:23 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_FB_DATA, &fb_data);
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_FB_PITCH, &fb_pitch);
|
2014-10-25 21:21:28 +00:00
|
|
|
|
2015-09-25 19:03:23 +00:00
|
|
|
color_rect(fb_data, fb_pitch, fb_width, fb_height, x, y - 5, 1, 11, 0xFFFF);
|
|
|
|
color_rect(fb_data, fb_pitch, fb_width, fb_height, x - 5, y, 11, 1, 0xFFFF);
|
2014-10-25 21:21:28 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rgui_render(void)
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
2015-05-14 22:08:39 +00:00
|
|
|
unsigned x, y;
|
2015-09-24 18:08:11 +00:00
|
|
|
bool display_kb;
|
2015-03-16 15:57:27 +00:00
|
|
|
uint16_t hover_color, normal_color;
|
2015-09-25 19:03:23 +00:00
|
|
|
size_t i, end, fb_pitch;
|
2015-09-25 18:28:56 +00:00
|
|
|
unsigned fb_width, fb_height;
|
2015-06-12 22:09:09 +00:00
|
|
|
int bottom;
|
2015-09-25 18:28:56 +00:00
|
|
|
char title[256], title_buf[256], title_msg[64];
|
|
|
|
char msg[PATH_MAX_LENGTH], timedate[PATH_MAX_LENGTH];
|
2015-09-25 19:03:23 +00:00
|
|
|
uint16_t *fb_data = NULL;
|
2015-06-12 22:09:09 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-06-15 00:37:32 +00:00
|
|
|
menu_display_t *disp = menu_display_get_ptr();
|
2015-06-12 22:09:09 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
|
|
|
settings_t *settings = config_get_ptr();
|
2015-09-06 03:00:08 +00:00
|
|
|
menu_animation_t *anim = menu_animation_get_ptr();
|
2015-08-03 21:01:07 +00:00
|
|
|
uint64_t *frame_count = video_driver_get_frame_count();
|
2015-06-24 01:22:53 +00:00
|
|
|
rgui_t *rgui = NULL;
|
2015-03-18 19:31:01 +00:00
|
|
|
|
2015-09-24 18:08:11 +00:00
|
|
|
msg[0] = '\0';
|
2015-06-15 20:21:57 +00:00
|
|
|
title[0] = '\0';
|
|
|
|
title_buf[0] = '\0';
|
|
|
|
title_msg[0] = '\0';
|
|
|
|
timedate[0] = '\0';
|
|
|
|
|
2015-03-18 19:31:01 +00:00
|
|
|
(void)driver;
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-06-24 01:22:53 +00:00
|
|
|
if (!menu || !menu->userdata)
|
2015-02-13 18:00:34 +00:00
|
|
|
return;
|
2015-03-08 18:18:39 +00:00
|
|
|
|
2015-06-25 15:25:09 +00:00
|
|
|
rgui = (rgui_t*)menu->userdata;
|
2015-03-08 18:18:39 +00:00
|
|
|
|
2015-06-24 02:07:08 +00:00
|
|
|
if (!rgui->force_redraw)
|
|
|
|
{
|
|
|
|
if (menu_entries_needs_refresh() && menu_driver_alive() && !disp->msg_force)
|
|
|
|
return;
|
|
|
|
|
2015-08-05 10:40:47 +00:00
|
|
|
if (rarch_main_is_idle())
|
2015-06-24 02:07:08 +00:00
|
|
|
return;
|
|
|
|
|
2015-09-25 12:07:01 +00:00
|
|
|
if (!menu_display_ctl(MENU_DISPLAY_CTL_UPDATE_PENDING, NULL))
|
2015-06-24 02:07:08 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-09-25 18:28:56 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width);
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &fb_height);
|
2015-09-25 19:03:23 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_FB_DATA, &fb_data);
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_FB_PITCH, &fb_pitch);
|
2015-09-25 18:28:56 +00:00
|
|
|
|
2015-06-26 16:35:35 +00:00
|
|
|
/* if the framebuffer changed size, recache the background */
|
2015-09-25 18:28:56 +00:00
|
|
|
if (rgui->last_width != fb_width || rgui->last_height != fb_height)
|
2015-06-25 04:19:28 +00:00
|
|
|
{
|
2015-09-25 19:03:23 +00:00
|
|
|
fill_rect(fb_data, fb_pitch, 0, fb_height, fb_width, 4, gray_filler);
|
2015-09-25 18:28:56 +00:00
|
|
|
rgui->last_width = fb_width;
|
|
|
|
rgui->last_height = fb_height;
|
2015-06-25 04:19:28 +00:00
|
|
|
}
|
|
|
|
|
2015-09-25 11:27:15 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_SET_FRAMEBUFFER_DIRTY_FLAG, NULL);
|
|
|
|
|
2015-09-06 00:41:36 +00:00
|
|
|
menu_animation_clear_active(anim);
|
2015-06-24 02:07:08 +00:00
|
|
|
rgui->force_redraw = false;
|
2015-03-08 18:18:39 +00:00
|
|
|
|
2015-06-24 01:22:53 +00:00
|
|
|
|
2015-04-04 19:26:11 +00:00
|
|
|
if (settings->menu.pointer.enable)
|
|
|
|
{
|
2015-09-24 18:32:21 +00:00
|
|
|
bool pointer_dragged = false;
|
2015-09-24 18:23:18 +00:00
|
|
|
unsigned new_val = menu_input_pointer_state(MENU_POINTER_Y_AXIS) / 11 - 2 + menu_entries_get_start();
|
2015-09-24 18:08:11 +00:00
|
|
|
menu_input_ctl(MENU_CTL_POINTER_PTR, &new_val);
|
2015-09-24 18:32:21 +00:00
|
|
|
menu_input_ctl(MENU_CTL_POINTER_DRAGGING, &pointer_dragged);
|
2015-04-04 19:26:11 +00:00
|
|
|
|
2015-09-24 18:32:21 +00:00
|
|
|
if (pointer_dragged)
|
2015-04-04 19:26:11 +00:00
|
|
|
{
|
2015-09-24 18:32:21 +00:00
|
|
|
int16_t delta_y = menu_input_pointer_state(MENU_POINTER_DELTA_Y_AXIS);
|
|
|
|
menu->scroll_y += delta_y;
|
2015-06-15 23:59:26 +00:00
|
|
|
menu_entries_set_start(-menu->scroll_y / 11 + 2);
|
2015-04-04 19:26:11 +00:00
|
|
|
if (menu->scroll_y > 0)
|
|
|
|
menu->scroll_y = 0;
|
|
|
|
}
|
|
|
|
}
|
2015-06-25 04:19:28 +00:00
|
|
|
|
2015-04-04 19:26:11 +00:00
|
|
|
if (settings->menu.mouse.enable)
|
|
|
|
{
|
2015-09-24 17:51:55 +00:00
|
|
|
unsigned new_mouse_ptr;
|
2015-09-24 17:47:41 +00:00
|
|
|
bool mouse_scrolldown, mouse_scrollup;
|
2015-09-24 18:23:18 +00:00
|
|
|
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
2015-09-24 17:47:41 +00:00
|
|
|
|
|
|
|
menu_input_ctl(MENU_CTL_MOUSE_SCROLL_DOWN, &mouse_scrolldown);
|
|
|
|
menu_input_ctl(MENU_CTL_MOUSE_SCROLL_UP, &mouse_scrollup);
|
|
|
|
|
|
|
|
if (mouse_scrolldown
|
2015-09-25 18:28:56 +00:00
|
|
|
&& (menu_entries_get_start() < menu_entries_get_end() - RGUI_TERM_HEIGHT(fb_width, fb_height)))
|
2015-09-24 12:17:03 +00:00
|
|
|
menu_entries_set_start(menu_entries_get_start() + 1);
|
2014-10-26 23:55:14 +00:00
|
|
|
|
2015-09-24 17:47:41 +00:00
|
|
|
if (mouse_scrollup && (menu_entries_get_start() > 0))
|
2015-09-24 12:17:03 +00:00
|
|
|
menu_entries_set_start(menu_entries_get_start() - 1);
|
2014-10-26 21:31:53 +00:00
|
|
|
|
2015-09-24 18:23:18 +00:00
|
|
|
new_mouse_ptr = mouse_y / 11 - 2 + menu_entries_get_start();
|
2015-09-24 17:51:55 +00:00
|
|
|
|
|
|
|
menu_input_ctl(MENU_CTL_MOUSE_PTR, &new_mouse_ptr);
|
2015-04-04 19:26:11 +00:00
|
|
|
}
|
2014-04-13 10:12:12 +00:00
|
|
|
|
2014-09-02 14:03:17 +00:00
|
|
|
/* Do not scroll if all items are visible. */
|
2015-09-25 18:28:56 +00:00
|
|
|
if (menu_entries_get_end() <= RGUI_TERM_HEIGHT(fb_width, fb_height))
|
2015-06-15 23:59:26 +00:00
|
|
|
menu_entries_set_start(0);;
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-09-25 18:28:56 +00:00
|
|
|
bottom = menu_entries_get_end() - RGUI_TERM_HEIGHT(fb_width, fb_height);
|
2015-06-26 11:47:36 +00:00
|
|
|
if (menu_entries_get_start() > (unsigned)bottom)
|
2015-06-15 23:59:26 +00:00
|
|
|
menu_entries_set_start(bottom);
|
2015-04-04 19:26:11 +00:00
|
|
|
|
2015-09-25 18:28:56 +00:00
|
|
|
end = ((menu_entries_get_start() + RGUI_TERM_HEIGHT(fb_width, fb_height)) <= (menu_entries_get_end())) ?
|
|
|
|
menu_entries_get_start() + RGUI_TERM_HEIGHT(fb_width, fb_height) : menu_entries_get_end();
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
rgui_render_background();
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-08-31 17:47:45 +00:00
|
|
|
#if 0
|
2014-09-02 23:51:29 +00:00
|
|
|
RARCH_LOG("Dir is: %s\n", label);
|
2014-08-31 17:47:45 +00:00
|
|
|
#endif
|
|
|
|
|
2015-05-14 22:07:07 +00:00
|
|
|
menu_entries_get_title(title, sizeof(title));
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-09-25 18:28:56 +00:00
|
|
|
menu_animation_ticker_str(title_buf, RGUI_TERM_WIDTH(fb_width) - 10,
|
|
|
|
*frame_count / RGUI_TERM_START_X(fb_width), title, true);
|
2015-03-14 22:44:27 +00:00
|
|
|
|
2015-06-02 17:04:01 +00:00
|
|
|
hover_color = HOVER_COLOR(settings);
|
2015-03-20 21:22:06 +00:00
|
|
|
normal_color = NORMAL_COLOR(settings);
|
2015-03-14 22:44:27 +00:00
|
|
|
|
2015-05-14 22:16:39 +00:00
|
|
|
if (menu_entries_show_back())
|
2015-09-25 19:03:23 +00:00
|
|
|
blit_line(fb_data, fb_pitch,
|
2015-09-25 18:28:56 +00:00
|
|
|
RGUI_TERM_START_X(fb_width),
|
|
|
|
RGUI_TERM_START_X(fb_width),
|
2015-06-25 05:15:19 +00:00
|
|
|
menu_hash_to_str(MENU_VALUE_BACK),
|
|
|
|
TITLE_COLOR(settings));
|
2015-04-19 11:48:05 +00:00
|
|
|
|
2015-09-25 19:03:23 +00:00
|
|
|
blit_line(fb_data, fb_pitch,
|
2015-09-25 18:28:56 +00:00
|
|
|
RGUI_TERM_START_X(fb_width) + (RGUI_TERM_WIDTH(fb_width) - strlen(title_buf)) * FONT_WIDTH_STRIDE / 2,
|
|
|
|
RGUI_TERM_START_X(fb_width), title_buf, TITLE_COLOR(settings));
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-08-17 16:14:51 +00:00
|
|
|
if (menu_entries_get_core_title(title_msg, sizeof(title_msg)) == 0)
|
2015-09-25 19:03:23 +00:00
|
|
|
blit_line(fb_data, fb_pitch,
|
2015-09-25 18:28:56 +00:00
|
|
|
RGUI_TERM_START_X(fb_width),
|
|
|
|
(RGUI_TERM_HEIGHT(fb_width, fb_height) * FONT_HEIGHT_STRIDE) +
|
|
|
|
RGUI_TERM_START_Y(fb_height) + 2, title_msg, hover_color);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-03-20 21:22:06 +00:00
|
|
|
if (settings->menu.timedate_enable)
|
2015-02-12 18:35:24 +00:00
|
|
|
{
|
2015-06-08 12:57:46 +00:00
|
|
|
menu_display_timedate(timedate, sizeof(timedate), 3);
|
2015-02-12 18:35:24 +00:00
|
|
|
|
2015-09-25 19:03:23 +00:00
|
|
|
blit_line(fb_data, fb_pitch,
|
2015-09-25 18:28:56 +00:00
|
|
|
RGUI_TERM_WIDTH(fb_width) * FONT_WIDTH_STRIDE - RGUI_TERM_START_X(fb_width),
|
|
|
|
(RGUI_TERM_HEIGHT(fb_width, fb_height) * FONT_HEIGHT_STRIDE) +
|
|
|
|
RGUI_TERM_START_Y(fb_height) + 2, timedate, hover_color);
|
2015-02-12 18:35:24 +00:00
|
|
|
}
|
2015-01-17 03:50:46 +00:00
|
|
|
|
2015-09-25 18:28:56 +00:00
|
|
|
x = RGUI_TERM_START_X(fb_width);
|
|
|
|
y = RGUI_TERM_START_Y(fb_height);
|
2015-06-01 09:55:03 +00:00
|
|
|
i = menu_entries_get_start();
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-06-01 09:55:03 +00:00
|
|
|
for (; i < end; i++, y += FONT_HEIGHT_STRIDE)
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
2015-09-25 12:57:37 +00:00
|
|
|
size_t selection;
|
2015-06-15 20:21:57 +00:00
|
|
|
char entry_path[PATH_MAX_LENGTH];
|
|
|
|
char entry_value[PATH_MAX_LENGTH];
|
|
|
|
char message[PATH_MAX_LENGTH];
|
|
|
|
char entry_title_buf[PATH_MAX_LENGTH];
|
|
|
|
char type_str_buf[PATH_MAX_LENGTH];
|
2015-06-12 14:11:50 +00:00
|
|
|
unsigned entry_spacing = menu_entry_get_spacing(i);
|
|
|
|
bool entry_selected = menu_entry_is_currently_selected(i);
|
2015-09-25 12:57:37 +00:00
|
|
|
|
|
|
|
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
|
2015-09-25 13:02:19 +00:00
|
|
|
continue;
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-09-25 12:57:37 +00:00
|
|
|
if (i > (selection + 100))
|
2015-02-01 22:55:13 +00:00
|
|
|
continue;
|
|
|
|
|
2015-06-15 20:21:57 +00:00
|
|
|
entry_path[0] = '\0';
|
|
|
|
entry_value[0] = '\0';
|
|
|
|
message[0] = '\0';
|
|
|
|
entry_title_buf[0] = '\0';
|
|
|
|
type_str_buf[0] = '\0';
|
|
|
|
|
2015-06-01 12:59:15 +00:00
|
|
|
menu_entry_get_value(i, entry_value, sizeof(entry_value));
|
2015-06-01 13:16:54 +00:00
|
|
|
menu_entry_get_path(i, entry_path, sizeof(entry_path));
|
2015-06-01 12:59:15 +00:00
|
|
|
|
2015-09-25 18:28:56 +00:00
|
|
|
menu_animation_ticker_str(entry_title_buf, RGUI_TERM_WIDTH(fb_width) - (entry_spacing + 1 + 2),
|
|
|
|
*frame_count / RGUI_TERM_START_X(fb_width), entry_path, entry_selected);
|
2015-07-15 23:00:56 +00:00
|
|
|
menu_animation_ticker_str(type_str_buf, entry_spacing,
|
2015-09-25 18:28:56 +00:00
|
|
|
*frame_count / RGUI_TERM_START_X(fb_width),
|
2015-06-01 13:13:49 +00:00
|
|
|
entry_value, entry_selected);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
|
|
|
snprintf(message, sizeof(message), "%c %-*.*s %-*s",
|
2015-06-01 13:13:49 +00:00
|
|
|
entry_selected ? '>' : ' ',
|
2015-09-25 18:28:56 +00:00
|
|
|
RGUI_TERM_WIDTH(fb_width) - (entry_spacing + 1 + 2),
|
|
|
|
RGUI_TERM_WIDTH(fb_width) - (entry_spacing + 1 + 2),
|
2013-11-04 12:27:03 +00:00
|
|
|
entry_title_buf,
|
2015-06-01 13:13:49 +00:00
|
|
|
entry_spacing,
|
2013-11-04 12:27:03 +00:00
|
|
|
type_str_buf);
|
|
|
|
|
2015-09-25 19:03:23 +00:00
|
|
|
blit_line(fb_data, fb_pitch, x, y, message, entry_selected ? hover_color : normal_color);
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef GEKKO
|
|
|
|
const char *message_queue;
|
|
|
|
|
2015-06-15 00:37:32 +00:00
|
|
|
if (disp->msg_force)
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
2015-03-15 02:02:49 +00:00
|
|
|
message_queue = rarch_main_msg_queue_pull();
|
2015-06-15 00:37:32 +00:00
|
|
|
disp->msg_force = false;
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
|
|
|
else
|
2015-03-18 18:40:00 +00:00
|
|
|
message_queue = driver->current_msg;
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
rgui_render_messagebox( message_queue);
|
2013-11-04 12:27:03 +00:00
|
|
|
#endif
|
2013-12-09 15:18:58 +00:00
|
|
|
|
2015-09-24 18:08:11 +00:00
|
|
|
menu_input_ctl(MENU_CTL_KEYBOARD_DISPLAY, &display_kb);
|
|
|
|
|
|
|
|
if (display_kb)
|
2013-12-09 15:18:58 +00:00
|
|
|
{
|
2015-09-24 18:08:11 +00:00
|
|
|
const char *str = NULL, *label = NULL;
|
|
|
|
menu_input_ctl(MENU_CTL_KEYBOARD_BUFF_PTR, &str);
|
|
|
|
menu_input_ctl(MENU_CTL_KEYBOARD_LABEL, &label);
|
2015-06-12 22:09:09 +00:00
|
|
|
|
2013-12-10 18:39:09 +00:00
|
|
|
if (!str)
|
|
|
|
str = "";
|
2015-09-24 18:08:11 +00:00
|
|
|
snprintf(msg, sizeof(msg), "%s\n%s", label, str);
|
2015-02-13 18:00:34 +00:00
|
|
|
rgui_render_messagebox(msg);
|
2013-12-09 15:18:58 +00:00
|
|
|
}
|
2014-10-25 21:21:28 +00:00
|
|
|
|
2015-06-24 01:22:53 +00:00
|
|
|
if (rgui->msgbox[0] != '\0')
|
|
|
|
{
|
|
|
|
rgui_render_messagebox(rgui->msgbox);
|
|
|
|
rgui->msgbox[0] = '\0';
|
2015-06-24 02:07:08 +00:00
|
|
|
rgui->force_redraw = true;
|
2015-06-24 01:22:53 +00:00
|
|
|
}
|
|
|
|
|
2015-03-20 21:22:06 +00:00
|
|
|
if (settings->menu.mouse.enable)
|
2015-02-11 18:28:06 +00:00
|
|
|
rgui_blit_cursor(menu);
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
2013-09-28 02:45:44 +00:00
|
|
|
|
2014-03-25 09:19:02 +00:00
|
|
|
static void *rgui_init(void)
|
2012-05-06 02:04:33 +00:00
|
|
|
{
|
2015-06-13 14:51:16 +00:00
|
|
|
bool ret = false;
|
|
|
|
menu_framebuf_t *frame_buf = NULL;
|
|
|
|
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
2015-06-24 01:22:53 +00:00
|
|
|
rgui_t *rgui = NULL;
|
2012-05-06 02:04:33 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
if (!menu)
|
2014-05-30 18:41:31 +00:00
|
|
|
return NULL;
|
|
|
|
|
2015-06-24 01:22:53 +00:00
|
|
|
menu->userdata = rgui = (rgui_t*)calloc(1, sizeof(rgui_t));
|
|
|
|
|
|
|
|
if (!rgui)
|
|
|
|
goto error;
|
|
|
|
|
2015-09-25 19:25:37 +00:00
|
|
|
frame_buf = menu_display_fb_get_ptr();
|
2015-06-13 14:51:16 +00:00
|
|
|
|
2015-03-08 12:18:32 +00:00
|
|
|
/* 4 extra lines to cache the checked background */
|
2015-06-13 14:51:16 +00:00
|
|
|
frame_buf->data = (uint16_t*)calloc(400 * (240 + 4), sizeof(uint16_t));
|
2014-10-11 01:02:49 +00:00
|
|
|
|
2015-06-13 14:51:16 +00:00
|
|
|
if (!frame_buf->data)
|
2015-02-02 17:56:58 +00:00
|
|
|
goto error;
|
2014-10-11 01:02:49 +00:00
|
|
|
|
2015-06-14 13:34:05 +00:00
|
|
|
frame_buf->width = 320;
|
|
|
|
frame_buf->height = 240;
|
|
|
|
menu->display.header_height = FONT_HEIGHT_STRIDE * 2;
|
|
|
|
frame_buf->pitch = frame_buf->width * sizeof(uint16_t);
|
2012-05-06 02:04:33 +00:00
|
|
|
|
2015-06-15 23:59:26 +00:00
|
|
|
menu_entries_set_start(0);
|
|
|
|
|
2015-01-04 14:22:49 +00:00
|
|
|
ret = rguidisp_init_font(menu);
|
2013-09-28 02:45:44 +00:00
|
|
|
|
|
|
|
if (!ret)
|
2015-02-02 17:56:58 +00:00
|
|
|
goto error;
|
2012-05-06 02:04:33 +00:00
|
|
|
|
2015-09-25 18:42:45 +00:00
|
|
|
fill_rect(frame_buf->data, frame_buf->pitch, 0, frame_buf->height,
|
2015-06-13 14:51:16 +00:00
|
|
|
frame_buf->width, 4, gray_filler);
|
2015-03-08 12:18:32 +00:00
|
|
|
|
2015-09-25 19:20:26 +00:00
|
|
|
rgui->last_width = frame_buf->width;
|
2015-06-25 04:19:28 +00:00
|
|
|
rgui->last_height = frame_buf->height;
|
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
return menu;
|
2015-02-02 17:56:58 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
if (menu)
|
2015-02-11 04:08:07 +00:00
|
|
|
{
|
2015-06-13 14:51:16 +00:00
|
|
|
if (frame_buf->data)
|
|
|
|
free(frame_buf->data);
|
|
|
|
frame_buf->data = NULL;
|
2015-02-11 04:08:07 +00:00
|
|
|
if (menu->userdata)
|
|
|
|
free(menu->userdata);
|
2015-06-13 14:51:16 +00:00
|
|
|
menu->userdata = NULL;
|
2015-02-02 17:56:58 +00:00
|
|
|
free(menu);
|
2015-02-11 04:08:07 +00:00
|
|
|
}
|
2015-02-02 17:56:58 +00:00
|
|
|
return NULL;
|
2012-05-06 02:04:33 +00:00
|
|
|
}
|
|
|
|
|
2013-09-19 13:01:17 +00:00
|
|
|
static void rgui_free(void *data)
|
2012-05-06 02:04:33 +00:00
|
|
|
{
|
2015-06-14 13:34:05 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
|
|
|
menu_display_t *disp = menu ? &menu->display : NULL;
|
2014-05-30 18:41:31 +00:00
|
|
|
|
2015-06-14 13:34:05 +00:00
|
|
|
if (!menu || !disp)
|
2014-10-11 01:02:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (menu->userdata)
|
|
|
|
free(menu->userdata);
|
2015-02-11 20:15:39 +00:00
|
|
|
menu->userdata = NULL;
|
2014-10-11 01:02:49 +00:00
|
|
|
|
2015-06-14 13:34:05 +00:00
|
|
|
if (disp->font.alloc_framebuf)
|
|
|
|
free((uint8_t*)disp->font.framebuf);
|
2015-06-25 15:36:31 +00:00
|
|
|
disp->font.alloc_framebuf = false;
|
2012-05-06 02:04:33 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rgui_set_texture(void)
|
2013-11-04 15:23:37 +00:00
|
|
|
{
|
2015-09-25 18:37:04 +00:00
|
|
|
unsigned fb_width, fb_height;
|
2015-09-25 19:03:23 +00:00
|
|
|
uint16_t *fb_data = NULL;
|
2015-09-25 19:07:12 +00:00
|
|
|
bool fb_dirty = false;
|
2015-09-25 18:37:04 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-03-18 05:47:22 +00:00
|
|
|
|
2015-02-11 04:16:19 +00:00
|
|
|
if (!menu)
|
2015-02-01 07:18:33 +00:00
|
|
|
return;
|
2015-09-25 19:07:12 +00:00
|
|
|
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_GET_FRAMEBUFFER_DIRTY_FLAG, &fb_dirty);
|
|
|
|
|
|
|
|
if (!fb_dirty)
|
2015-06-24 01:01:09 +00:00
|
|
|
return;
|
|
|
|
|
2015-09-25 18:37:04 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width);
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &fb_height);
|
2015-09-25 19:03:23 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_FB_DATA, &fb_data);
|
2015-09-25 11:27:15 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_UNSET_FRAMEBUFFER_DIRTY_FLAG, NULL);
|
2015-02-01 07:18:33 +00:00
|
|
|
|
2015-03-22 18:15:34 +00:00
|
|
|
video_driver_set_texture_frame(
|
2015-09-25 19:03:23 +00:00
|
|
|
fb_data,
|
2015-06-13 14:42:11 +00:00
|
|
|
false,
|
2015-09-25 18:37:04 +00:00
|
|
|
fb_width,
|
|
|
|
fb_height,
|
2015-06-13 14:42:11 +00:00
|
|
|
1.0f);
|
2013-11-04 15:23:37 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rgui_navigation_clear(bool pending_push)
|
2014-10-26 21:31:53 +00:00
|
|
|
{
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-04-04 19:26:11 +00:00
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
2015-06-15 23:59:26 +00:00
|
|
|
menu_entries_set_start(0);
|
2015-04-04 19:26:11 +00:00
|
|
|
menu->scroll_y = 0;
|
2014-10-26 21:31:53 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rgui_navigation_set(bool scroll)
|
2014-10-26 21:31:53 +00:00
|
|
|
{
|
2015-09-25 18:28:56 +00:00
|
|
|
size_t selection, fb_width, fb_height;
|
2015-06-13 14:42:11 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-09-25 12:57:37 +00:00
|
|
|
size_t end = menu_entries_get_end();
|
|
|
|
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
|
2014-10-26 22:43:33 +00:00
|
|
|
return;
|
2015-09-25 12:57:37 +00:00
|
|
|
if (!menu || !scroll)
|
2014-10-26 21:31:53 +00:00
|
|
|
return;
|
|
|
|
|
2015-09-25 18:28:56 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width);
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &fb_height);
|
|
|
|
|
|
|
|
if (selection < RGUI_TERM_HEIGHT(fb_width, fb_height) /2)
|
2015-06-15 23:59:26 +00:00
|
|
|
menu_entries_set_start(0);
|
2015-09-25 18:28:56 +00:00
|
|
|
else if (selection >= (RGUI_TERM_HEIGHT(fb_width, fb_height) /2)
|
|
|
|
&& selection < (end - RGUI_TERM_HEIGHT(fb_width, fb_height) /2))
|
|
|
|
menu_entries_set_start(selection - RGUI_TERM_HEIGHT(fb_width, fb_height) /2);
|
|
|
|
else if (selection >= (end - RGUI_TERM_HEIGHT(fb_width, fb_height) /2))
|
|
|
|
menu_entries_set_start(end - RGUI_TERM_HEIGHT(fb_width, fb_height));
|
2014-10-26 21:31:53 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rgui_navigation_set_last(void)
|
2014-12-15 17:56:49 +00:00
|
|
|
{
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-02-13 18:00:34 +00:00
|
|
|
if (menu)
|
|
|
|
rgui_navigation_set(true);
|
2014-12-15 17:56:49 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rgui_navigation_descend_alphabet(size_t *unused)
|
2014-12-15 18:03:47 +00:00
|
|
|
{
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-02-13 18:00:34 +00:00
|
|
|
if (menu)
|
|
|
|
rgui_navigation_set(true);
|
2014-12-15 18:03:47 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rgui_navigation_ascend_alphabet(size_t *unused)
|
2014-12-15 18:03:47 +00:00
|
|
|
{
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-02-13 18:00:34 +00:00
|
|
|
if (menu)
|
|
|
|
rgui_navigation_set(true);
|
2014-12-15 18:03:47 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rgui_populate_entries(const char *path,
|
2015-09-21 19:32:31 +00:00
|
|
|
const char *label, unsigned k)
|
2015-01-04 14:52:46 +00:00
|
|
|
{
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-02-13 18:00:34 +00:00
|
|
|
if (menu)
|
|
|
|
rgui_navigation_set(true);
|
2015-01-04 14:52:46 +00:00
|
|
|
}
|
|
|
|
|
2015-07-07 23:01:41 +00:00
|
|
|
static int rgui_environ(menu_environ_cb_t type, void *data)
|
2015-07-07 22:37:44 +00:00
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
2015-07-08 22:24:10 +00:00
|
|
|
case 0:
|
2015-07-09 06:28:08 +00:00
|
|
|
break;
|
2015-07-07 22:37:44 +00:00
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-09-11 05:06:20 +00:00
|
|
|
menu_ctx_driver_t menu_ctx_rgui = {
|
2013-11-04 15:23:37 +00:00
|
|
|
rgui_set_texture,
|
2015-06-24 01:22:53 +00:00
|
|
|
rgui_set_message,
|
2013-11-04 15:23:37 +00:00
|
|
|
rgui_render,
|
2014-04-01 02:45:00 +00:00
|
|
|
NULL,
|
2013-09-19 12:49:07 +00:00
|
|
|
rgui_init,
|
|
|
|
rgui_free,
|
2013-11-08 14:13:14 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2015-01-04 14:52:46 +00:00
|
|
|
rgui_populate_entries,
|
2013-11-19 05:35:11 +00:00
|
|
|
NULL,
|
2014-10-26 21:31:53 +00:00
|
|
|
rgui_navigation_clear,
|
2014-04-13 21:41:47 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-10-26 21:31:53 +00:00
|
|
|
rgui_navigation_set,
|
2014-12-15 17:56:49 +00:00
|
|
|
rgui_navigation_set_last,
|
2014-12-15 18:03:47 +00:00
|
|
|
rgui_navigation_descend_alphabet,
|
|
|
|
rgui_navigation_ascend_alphabet,
|
2014-04-13 22:09:52 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-09-03 12:57:29 +00:00
|
|
|
NULL,
|
2015-02-12 23:12:15 +00:00
|
|
|
NULL,
|
2015-06-07 13:43:03 +00:00
|
|
|
NULL,
|
2015-06-08 14:01:57 +00:00
|
|
|
NULL,
|
2015-06-08 15:02:14 +00:00
|
|
|
NULL,
|
2015-06-15 17:00:52 +00:00
|
|
|
NULL,
|
2013-09-19 12:49:07 +00:00
|
|
|
"rgui",
|
2015-08-17 03:05:29 +00:00
|
|
|
MENU_VIDEO_DRIVER_GENERIC,
|
2015-07-07 22:37:44 +00:00
|
|
|
rgui_environ,
|
2013-09-19 12:49:07 +00:00
|
|
|
};
|