Skip to content

Commit

Permalink
Merge pull request libretro#8285 from jdgleaver/text-ticker-loop
Browse files Browse the repository at this point in the history
Add optional 'looping' menu text ticker
  • Loading branch information
inactive123 authored Feb 14, 2019
2 parents 1daaf73 + 27694b6 commit feb6b19
Show file tree
Hide file tree
Showing 19 changed files with 272 additions and 16 deletions.
3 changes: 3 additions & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ static const float default_input_overlay_opacity = 0.7f;

#ifdef HAVE_MENU
#include "menu/menu_driver.h"
#include "menu/menu_animation.h"

static bool default_block_config_read = true;

Expand Down Expand Up @@ -323,6 +324,8 @@ static bool menu_show_core_updater = true;
#endif
static bool menu_show_sublabels = false;

static unsigned menu_ticker_type = TICKER_TYPE_BOUNCE;

static bool content_show_settings = true;
static bool content_show_favorites = true;
#ifdef HAVE_IMAGEVIEWER
Expand Down
1 change: 1 addition & 0 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,7 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings,
SETTING_UINT("dpi_override_value", &settings->uints.menu_dpi_override_value, true, menu_dpi_override_value, false);
SETTING_UINT("menu_thumbnails", &settings->uints.menu_thumbnails, true, menu_thumbnails_default, false);
SETTING_UINT("menu_timedate_style", &settings->uints.menu_timedate_style, true, menu_timedate_style, false);
SETTING_UINT("menu_ticker_type", &settings->uints.menu_ticker_type, true, menu_ticker_type, false);
#ifdef HAVE_RGUI
SETTING_UINT("rgui_menu_color_theme", &settings->uints.menu_rgui_color_theme, true, rgui_color_theme, false);
SETTING_UINT("rgui_thumbnail_downscaler", &settings->uints.menu_rgui_thumbnail_downscaler, true, rgui_thumbnail_downscaler, false);
Expand Down
1 change: 1 addition & 0 deletions configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ typedef struct settings
unsigned menu_font_color_green;
unsigned menu_font_color_blue;
unsigned menu_rgui_internal_upscale_level;
unsigned menu_ticker_type;

unsigned camera_width;
unsigned camera_height;
Expand Down
2 changes: 2 additions & 0 deletions intl/msg_hash_lbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,8 @@ MSG_HASH(MENU_ENUM_LABEL_TIMEDATE_ENABLE,
"menu_timedate_enable")
MSG_HASH(MENU_ENUM_LABEL_TIMEDATE_STYLE,
"menu_timedate_style")
MSG_HASH(MENU_ENUM_LABEL_MENU_TICKER_TYPE,
"menu_ticker_type")
MSG_HASH(MENU_ENUM_LABEL_UI_COMPANION_ENABLE,
"ui_companion_enable")
MSG_HASH(MENU_ENUM_LABEL_UI_COMPANION_START_ON_BOOT,
Expand Down
16 changes: 16 additions & 0 deletions intl/msg_hash_us.h
Original file line number Diff line number Diff line change
Expand Up @@ -3074,6 +3074,22 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM,
"HH:MM:SS (AM/PM)"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_MENU_TICKER_TYPE,
"Ticker Text Animation"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_MENU_TICKER_TYPE,
"Select horizontal scrolling method used to display long menu text strings."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_MENU_TICKER_TYPE_BOUNCE,
"Bounce Left/Right"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_MENU_TICKER_TYPE_LOOP,
"Scroll Left"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_RGUI_MENU_COLOR_THEME,
"Menu Color Theme"
Expand Down
4 changes: 4 additions & 0 deletions menu/cbs/menu_cbs_sublabel.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ default_sublabel_macro(action_bind_sublabel_rgui_menu_theme_preset,
default_sublabel_macro(action_bind_sublabel_menu_rgui_thumbnail_downscaler, MENU_ENUM_SUBLABEL_MENU_RGUI_THUMBNAIL_DOWNSCALER)
default_sublabel_macro(action_bind_sublabel_content_runtime_log, MENU_ENUM_SUBLABEL_CONTENT_RUNTIME_LOG)
default_sublabel_macro(action_bind_sublabel_menu_rgui_internal_upscale_level, MENU_ENUM_SUBLABEL_MENU_RGUI_INTERNAL_UPSCALE_LEVEL)
default_sublabel_macro(action_bind_sublabel_menu_ticker_type, MENU_ENUM_SUBLABEL_MENU_TICKER_TYPE)

static int action_bind_sublabel_systeminfo_controller_entry(
file_list_t *list,
Expand Down Expand Up @@ -2256,6 +2257,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_MENU_RGUI_INTERNAL_UPSCALE_LEVEL:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_rgui_internal_upscale_level);
break;
case MENU_ENUM_LABEL_MENU_TICKER_TYPE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_ticker_type);
break;
default:
case MSG_UNKNOWN:
return -1;
Expand Down
12 changes: 12 additions & 0 deletions menu/drivers/materialui.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ static void materialui_render_label_value(
{
menu_entry_t entry;
menu_animation_ctx_ticker_t ticker;
static const char ticker_spacer[] = " | ";
char label_str[255];
char value_str[255];
char *sublabel_str = NULL;
Expand All @@ -752,6 +753,11 @@ static void materialui_render_label_value(
int icon_margin = 0;
enum msg_file_type hash_type = msg_hash_to_file_type(msg_hash_calculate(value));
float scale_factor = menu_display_get_dpi();
settings_t *settings = config_get_ptr();

/* Initial ticker configuration */
ticker.type_enum = settings->uints.menu_ticker_type;
ticker.spacer = ticker_spacer;

label_str[0] = value_str[0] = '\0';

Expand Down Expand Up @@ -1063,6 +1069,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
menu_display_ctx_clearcolor_t clearcolor;

menu_animation_ctx_ticker_t ticker;
static const char ticker_spacer[] = " | ";
menu_display_ctx_draw_t draw;
char msg[255];
char title_buf[255];
Expand Down Expand Up @@ -1160,11 +1167,16 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
bool background_rendered = false;
bool libretro_running = video_info->libretro_running;

settings_t *settings = config_get_ptr();
materialui_handle_t *mui = (materialui_handle_t*)data;

if (!mui)
return;

/* Initial ticker configuration */
ticker.type_enum = settings->uints.menu_ticker_type;
ticker.spacer = ticker_spacer;

usable_width = width - (mui->margin * 2);

mui->frame_count++;
Expand Down
5 changes: 5 additions & 0 deletions menu/drivers/ozone/ozone.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,9 +848,14 @@ static void ozone_draw_header(ozone_handle_t *ozone, video_frame_info_t *video_i
{
char title[255];
menu_animation_ctx_ticker_t ticker;
static const char ticker_spacer[] = " | ";
settings_t *settings = config_get_ptr();
unsigned timedate_offset = 0;

/* Initial ticker configuration */
ticker.type_enum = settings->uints.menu_ticker_type;
ticker.spacer = ticker_spacer;

/* Separator */
menu_display_draw_quad(video_info, 30, ozone->dimensions.header_height, video_info->width - 60, 1, video_info->width, video_info->height, ozone->theme->header_footer_separator);

Expand Down
5 changes: 5 additions & 0 deletions menu/drivers/ozone/ozone_entries.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info,
menu_texture_item tex;
menu_entry_t entry;
menu_animation_ctx_ticker_t ticker;
static const char ticker_spacer[] = " | ";
char entry_value[255];
char rich_label[255];
char entry_value_ticker[255];
Expand All @@ -418,6 +419,10 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info,
int text_offset = -ozone->dimensions.entry_icon_padding - ozone->dimensions.entry_icon_size;
float *icon_color = NULL;

/* Initial ticker configuration */
ticker.type_enum = settings->uints.menu_ticker_type;
ticker.spacer = ticker_spacer;

entry_value[0] = '\0';
entry_selected = selection == i;
node = (ozone_node_t*) file_list_get_userdata_at_offset(selection_buf, i);
Expand Down
6 changes: 6 additions & 0 deletions menu/drivers/ozone/ozone_sidebar.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info)
unsigned i, sidebar_height;
char console_title[255];
menu_animation_ctx_ticker_t ticker;
static const char ticker_spacer[] = " | ";
settings_t *settings = config_get_ptr();

/* Initial ticker configuration */
ticker.type_enum = settings->uints.menu_ticker_type;
ticker.spacer = ticker_spacer;

unsigned selection_y = 0;
unsigned selection_old_y = 0;
Expand Down
8 changes: 5 additions & 3 deletions menu/drivers/rgui.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,7 @@ static void rgui_frame(void *data, video_frame_info_t *video_info)
static void rgui_render(void *data, bool is_idle)
{
menu_animation_ctx_ticker_t ticker;
static const char ticker_spacer[] = " | ";
unsigned x, y;
size_t i, end, fb_pitch, old_start;
unsigned fb_width, fb_height;
Expand Down Expand Up @@ -1586,10 +1587,11 @@ static void rgui_render(void *data, bool is_idle)
rgui_render_background(rgui);
}

/* We use a single ticker for all text animations.
* The same 'idx' is used in all cases, so set it
* once at the beginning. */
/* We use a single ticker for all text animations,
* with the following configuration: */
ticker.idx = frame_count / RGUI_TERM_START_X(fb_width);
ticker.type_enum = settings->uints.menu_ticker_type;
ticker.spacer = ticker_spacer;

/* If thumbnails are enabled and we are viewing a playlist,
* switch to thumbnail view mode if either current thumbnail
Expand Down
5 changes: 5 additions & 0 deletions menu/drivers/stripes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2332,6 +2332,7 @@ static int stripes_draw_item(
{
float icon_x, icon_y, label_offset;
menu_animation_ctx_ticker_t ticker;
static const char ticker_spacer[] = " | ";
char tmp[255];
char *ticker_str = NULL;
unsigned entry_type = 0;
Expand All @@ -2343,6 +2344,10 @@ static int stripes_draw_item(
file_list_get_userdata_at_offset(list, i);
settings_t *settings = config_get_ptr();

/* Initial ticker configuration */
ticker.type_enum = settings->uints.menu_ticker_type;
ticker.spacer = ticker_spacer;

if (!node)
goto iterate;

Expand Down
5 changes: 5 additions & 0 deletions menu/drivers/xmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2806,6 +2806,7 @@ static int xmb_draw_item(
float icon_x, icon_y, label_offset;
menu_animation_ctx_ticker_t ticker;
char tmp[255];
static const char ticker_spacer[] = " | ";
char *ticker_str = NULL;
unsigned entry_type = 0;
const float half_size = xmb->icon_size / 2.0f;
Expand All @@ -2816,6 +2817,10 @@ static int xmb_draw_item(
file_list_get_userdata_at_offset(list, i);
settings_t *settings = config_get_ptr();

/* Initial ticker configuration */
ticker.type_enum = settings->uints.menu_ticker_type;
ticker.spacer = ticker_spacer;

if (!node)
goto iterate;

Expand Down
6 changes: 6 additions & 0 deletions menu/drivers/xui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ static void xui_render(void *data, bool is_idle)
unsigned menu_type = 0;
uint64_t frame_count = xui_frame_count;
bool msg_force = menu_display_get_msg_force();
settings_t *settings = config_get_ptr();

menu_display_get_fb_size(&fb_width, &fb_height,
&fb_pitch);
Expand All @@ -565,10 +566,15 @@ static void xui_render(void *data, bool is_idle)
if (XuiHandleIsValid(m_menutitle))
{
menu_animation_ctx_ticker_t ticker;
static const char ticker_spacer[] = " | ";
menu_entries_get_title(title, sizeof(title));
mbstowcs(strw_buffer, title, sizeof(strw_buffer) / sizeof(wchar_t));
XuiTextElementSetText(m_menutitle, strw_buffer);

/* Initial ticker configuration */
ticker.type_enum = settings->uints.menu_ticker_type;
ticker.spacer = ticker_spacer;

ticker.s = title;
ticker.len = RXUI_TERM_WIDTH(fb_width) - 3;
ticker.idx = (unsigned int)frame_count / 15;
Expand Down
Loading

0 comments on commit feb6b19

Please sign in to comment.