mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
FS#13537: format_sound_value alignment issue in themes
Positive values included a leading space, which meant they weren't displayed center-aligned in themes anymore. Change-Id: Ibe75e9b81a2989c87630dd3ea78e4b90c6c74502
This commit is contained in:
parent
af7ed73f31
commit
384c35418a
3 changed files with 28 additions and 18 deletions
|
@ -988,7 +988,6 @@ const char *get_token_value(struct gui_wps *gwps,
|
||||||
{
|
{
|
||||||
int numeric_ret = -1;
|
int numeric_ret = -1;
|
||||||
const char *numeric_buf = "?";
|
const char *numeric_buf = "?";
|
||||||
int fmt_size;
|
|
||||||
|
|
||||||
if (!gwps)
|
if (!gwps)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1173,17 +1172,8 @@ const char *get_token_value(struct gui_wps *gwps,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SKIN_TOKEN_VOLUME:
|
case SKIN_TOKEN_VOLUME:
|
||||||
fmt_size = format_sound_value(buf, buf_size, SOUND_VOLUME,
|
format_sound_value_ex(buf, buf_size, SOUND_VOLUME,
|
||||||
global_settings.volume);
|
global_settings.volume, true);
|
||||||
/* FIXME: this is a cheap hack to avoid breaking existing themes.
|
|
||||||
* The new formatting includes a unit based on the AUDIOHW_SETTING
|
|
||||||
* definition -- on all targets, it's defined to be "dB". But the
|
|
||||||
* old formatting was just an integer value, and many themes append
|
|
||||||
* "dB" manually. So we need to strip the unit to unbreak all those
|
|
||||||
* existing themes.
|
|
||||||
*/
|
|
||||||
if(fmt_size >= 3 && !strcmp(&buf[fmt_size - 3], " dB"))
|
|
||||||
buf[fmt_size - 3] = 0;
|
|
||||||
|
|
||||||
if (intval)
|
if (intval)
|
||||||
{
|
{
|
||||||
|
|
14
apps/misc.c
14
apps/misc.c
|
@ -1167,8 +1167,7 @@ void replaygain_update(void)
|
||||||
dsp_replaygain_set_settings(&settings);
|
dsp_replaygain_set_settings(&settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* format a sound value like: -1.05 dB */
|
void format_sound_value_ex(char *buf, size_t buf_sz, int snd, int val, bool skin_token)
|
||||||
int format_sound_value(char *buf, size_t size, int snd, int val)
|
|
||||||
{
|
{
|
||||||
int numdec = sound_numdecimals(snd);
|
int numdec = sound_numdecimals(snd);
|
||||||
const char *unit = sound_unit(snd);
|
const char *unit = sound_unit(snd);
|
||||||
|
@ -1183,8 +1182,15 @@ int format_sound_value(char *buf, size_t size, int snd, int val)
|
||||||
unsigned int av = abs(physval);
|
unsigned int av = abs(physval);
|
||||||
unsigned int i = av / factor;
|
unsigned int i = av / factor;
|
||||||
unsigned int d = av - i*factor;
|
unsigned int d = av - i*factor;
|
||||||
return snprintf(buf, size, "%c%u%.*s%.*u %s", " -"[physval < 0],
|
|
||||||
i, numdec, ".", numdec, d, unit);
|
snprintf(buf, buf_sz, "%s%u%.*s%.*u%s%s", physval < 0 ? "-" : &" "[skin_token],
|
||||||
|
i, numdec, ".", numdec, d, &" "[skin_token], skin_token ? "" : unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* format a sound value as "-1.05 dB", or " 1.05 dB" */
|
||||||
|
void format_sound_value(char *buf, size_t buf_sz, int snd, int val)
|
||||||
|
{
|
||||||
|
format_sound_value_ex(buf, buf_sz, snd, val, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !defined(__PCTOOL__) */
|
#endif /* !defined(__PCTOOL__) */
|
||||||
|
|
18
apps/misc.h
18
apps/misc.h
|
@ -256,8 +256,22 @@ void pop_current_activity(void);
|
||||||
void pop_current_activity_without_refresh(void);
|
void pop_current_activity_without_refresh(void);
|
||||||
enum current_activity get_current_activity(void);
|
enum current_activity get_current_activity(void);
|
||||||
|
|
||||||
/* format a sound value like: -1.05 dB */
|
/* Format a sound value like: "-1.05 dB" (negative values)
|
||||||
int format_sound_value(char *buf, size_t len, int snd, int val);
|
* " 1.05 dB" (positive values include leading space)
|
||||||
|
*/
|
||||||
|
void format_sound_value(char *buf, size_t buf_sz, int snd, int val);
|
||||||
|
|
||||||
|
/* Set skin_token parameter to true to format a sound value for
|
||||||
|
* display in themes, like: "-1.05" (negative values)
|
||||||
|
* "1.05" (positive values without leading space)
|
||||||
|
*
|
||||||
|
* (The new formatting includes a unit based on the AUDIOHW_SETTING
|
||||||
|
* definition -- on all targets, it's defined to be "dB". But the
|
||||||
|
* old formatting was just an integer value, and many themes append
|
||||||
|
* "dB" manually. So we need to strip the unit to unbreak all those
|
||||||
|
* existing themes.)
|
||||||
|
*/
|
||||||
|
void format_sound_value_ex(char *buf, size_t buf_sz, int snd, int val, bool skin_token);
|
||||||
|
|
||||||
#ifndef PLUGIN
|
#ifndef PLUGIN
|
||||||
enum core_load_bmp_error
|
enum core_load_bmp_error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue