Create menu_animation_ticker

This commit is contained in:
twinaphex 2017-01-17 16:29:23 +01:00
parent 2849e2aa79
commit bfb124a60e
6 changed files with 51 additions and 50 deletions

View File

@ -692,13 +692,13 @@ static void mui_render_label_value(mui_handle_t *mui, mui_node_t *node,
ticker.str = label; ticker.str = label;
ticker.selected = selected; ticker.selected = selected;
menu_animation_ctl(MENU_ANIMATION_CTL_TICKER, &ticker); menu_animation_ticker(&ticker);
ticker.s = value_str; ticker.s = value_str;
ticker.len = value_len; ticker.len = value_len;
ticker.str = value; ticker.str = value;
menu_animation_ctl(MENU_ANIMATION_CTL_TICKER, &ticker); menu_animation_ticker(&ticker);
if (menu_entry_get_sublabel(i, sublabel_str, sizeof(sublabel_str))) if (menu_entry_get_sublabel(i, sublabel_str, sizeof(sublabel_str)))
{ {
@ -1360,7 +1360,7 @@ static void mui_frame(void *data)
ticker.str = title; ticker.str = title;
ticker.selected = true; ticker.selected = true;
menu_animation_ctl(MENU_ANIMATION_CTL_TICKER, &ticker); menu_animation_ticker(&ticker);
/* Title */ /* Title */
if (mui_get_core_title(title_msg, sizeof(title_msg)) == 0) if (mui_get_core_title(title_msg, sizeof(title_msg)) == 0)
@ -1383,7 +1383,7 @@ static void mui_frame(void *data)
ticker.str = title_buf_msg; ticker.str = title_buf_msg;
ticker.selected = true; ticker.selected = true;
menu_animation_ctl(MENU_ANIMATION_CTL_TICKER, &ticker); menu_animation_ticker(&ticker);
strlcpy(title_buf, title_buf_msg_tmp, sizeof(title_buf)); strlcpy(title_buf, title_buf_msg_tmp, sizeof(title_buf));
} }

View File

@ -507,7 +507,7 @@ static void rgui_render(void *data)
ticker.str = title; ticker.str = title;
ticker.selected = true; ticker.selected = true;
menu_animation_ctl(MENU_ANIMATION_CTL_TICKER, &ticker); menu_animation_ticker(&ticker);
hover_color = HOVER_COLOR(settings); hover_color = HOVER_COLOR(settings);
normal_color = NORMAL_COLOR(settings); normal_color = NORMAL_COLOR(settings);
@ -599,13 +599,13 @@ static void rgui_render(void *data)
ticker.str = entry_path; ticker.str = entry_path;
ticker.selected = entry_selected; ticker.selected = entry_selected;
menu_animation_ctl(MENU_ANIMATION_CTL_TICKER, &ticker); menu_animation_ticker(&ticker);
ticker.s = type_str_buf; ticker.s = type_str_buf;
ticker.len = entry_spacing; ticker.len = entry_spacing;
ticker.str = entry_value; ticker.str = entry_value;
menu_animation_ctl(MENU_ANIMATION_CTL_TICKER, &ticker); menu_animation_ticker(&ticker);
snprintf(message, sizeof(message), "%c %-*.*s %-*s", snprintf(message, sizeof(message), "%c %-*.*s %-*s",
entry_selected ? '>' : ' ', entry_selected ? '>' : ' ',

View File

@ -2213,7 +2213,7 @@ static void xmb_draw_items(
ticker.str = ticker_str; ticker.str = ticker_str;
ticker.selected = (i == current); ticker.selected = (i == current);
menu_animation_ctl(MENU_ANIMATION_CTL_TICKER, &ticker); menu_animation_ticker(&ticker);
label_offset = xmb->margins.label.top; label_offset = xmb->margins.label.top;
if (i == current && width > 320 && height > 240 if (i == current && width > 320 && height > 240
@ -2244,7 +2244,7 @@ static void xmb_draw_items(
ticker.str = entry_value; ticker.str = entry_value;
ticker.selected = (i == current); ticker.selected = (i == current);
menu_animation_ctl(MENU_ANIMATION_CTL_TICKER, &ticker); menu_animation_ticker(&ticker);
if (do_draw_text) if (do_draw_text)
xmb_draw_text(menu_disp_info, xmb, value, xmb_draw_text(menu_disp_info, xmb, value,

View File

@ -350,7 +350,7 @@ static bool zarch_zui_list_item(zui_t *zui, struct zui_tabbed *tab, int x1, int
ticker.str = label; ticker.str = label;
ticker.selected = (bg == zui_bg_hilite || bg == zui_bg_pad_hilite); ticker.selected = (bg == zui_bg_hilite || bg == zui_bg_pad_hilite);
menu_animation_ctl(MENU_ANIMATION_CTL_TICKER, &ticker); menu_animation_ticker(&ticker);
menu_display_push_quad(zui->width, zui->height, bg, x1, y1, x2, y2); menu_display_push_quad(zui->width, zui->height, bg, x1, y1, x2, y2);
zarch_zui_draw_text(zui, ZUI_FG_NORMAL, 12, y1 + 35, title_buf); zarch_zui_draw_text(zui, ZUI_FG_NORMAL, 12, y1 + 35, title_buf);

View File

@ -519,6 +519,45 @@ bool menu_animation_update(float delta_time)
return true; return true;
} }
bool menu_animation_ticker(const menu_animation_ctx_ticker_t *ticker)
{
size_t str_len = utf8len(ticker->str);
size_t offset = 0;
if ((size_t)str_len <= ticker->len)
{
utf8cpy(ticker->s,
PATH_MAX_LENGTH,
ticker->str,
ticker->len);
return true;
}
if (!ticker->selected)
{
utf8cpy(ticker->s, PATH_MAX_LENGTH, ticker->str, ticker->len - 3);
strlcat(ticker->s, "...", PATH_MAX_LENGTH);
return true;
}
if (str_len > ticker->len)
menu_animation_ticker_generic(
ticker->idx,
ticker->len,
&offset,
&str_len);
utf8cpy(
ticker->s,
PATH_MAX_LENGTH,
utf8skip(ticker->str, offset),
str_len);
animation_is_active = true;
return true;
}
bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data) bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data)
{ {
switch (state) switch (state)
@ -629,45 +668,6 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data)
} }
} }
break; break;
case MENU_ANIMATION_CTL_TICKER:
{
menu_animation_ctx_ticker_t
*ticker = (menu_animation_ctx_ticker_t*)data;
size_t str_len = ticker ? utf8len(ticker->str) : 0;
size_t offset = 0;
if ((size_t)str_len <= ticker->len)
{
utf8cpy(ticker->s,
PATH_MAX_LENGTH,
ticker->str,
ticker->len);
return true;
}
if (!ticker->selected)
{
utf8cpy(ticker->s, PATH_MAX_LENGTH, ticker->str, ticker->len - 3);
strlcat(ticker->s, "...", PATH_MAX_LENGTH);
return true;
}
if (str_len > ticker->len)
menu_animation_ticker_generic(
ticker->idx,
ticker->len,
&offset,
&str_len);
utf8cpy(
ticker->s,
PATH_MAX_LENGTH,
utf8skip(ticker->str, offset),
str_len);
animation_is_active = true;
}
break;
case MENU_ANIMATION_CTL_IDEAL_DELTA_TIME_GET: case MENU_ANIMATION_CTL_IDEAL_DELTA_TIME_GET:
{ {
menu_animation_ctx_delta_t *delta = menu_animation_ctx_delta_t *delta =

View File

@ -39,7 +39,6 @@ enum menu_animation_ctl_state
MENU_ANIMATION_CTL_UPDATE_TIME, MENU_ANIMATION_CTL_UPDATE_TIME,
MENU_ANIMATION_CTL_KILL_BY_TAG, MENU_ANIMATION_CTL_KILL_BY_TAG,
MENU_ANIMATION_CTL_KILL_BY_SUBJECT, MENU_ANIMATION_CTL_KILL_BY_SUBJECT,
MENU_ANIMATION_CTL_TICKER,
MENU_ANIMATION_CTL_PUSH, MENU_ANIMATION_CTL_PUSH,
MENU_ANIMATION_CTL_IDEAL_DELTA_TIME_GET MENU_ANIMATION_CTL_IDEAL_DELTA_TIME_GET
}; };
@ -128,6 +127,8 @@ typedef struct menu_animation_ctx_ticker
bool menu_animation_update(float delta_time); bool menu_animation_update(float delta_time);
bool menu_animation_ticker(const menu_animation_ctx_ticker_t *ticker);
bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data); bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data);
RETRO_END_DECLS RETRO_END_DECLS