diff options
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/skin_engine/skin_tokens.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index c599adf833..6eb1759b91 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c | |||
@@ -107,6 +107,42 @@ static char* get_dir(char* buf, int buf_size, const char* path, int level) | |||
107 | return buf; | 107 | return buf; |
108 | } | 108 | } |
109 | 109 | ||
110 | /* A helper to determine the enum value for pitch/speed. | ||
111 | |||
112 | When there are two choices (i.e. boolean), return 1 if the value is | ||
113 | different from normal value and 2 if the value is the same as the | ||
114 | normal value. E.g. "%?Sp<%Sp>" would show the pitch only when | ||
115 | playing at a modified pitch. | ||
116 | |||
117 | When there are more than two choices (i.e. enum), the left half of | ||
118 | the choices are to show 0..normal range, and the right half of the | ||
119 | choices are to show values over that. The last entry is used when | ||
120 | it is set to the normal setting, following the rockbox convention | ||
121 | to use the last entry for special values. | ||
122 | |||
123 | E.g. | ||
124 | |||
125 | 2 items: %?Sp<0..99 or 101..infinity|100> | ||
126 | 3 items: %?Sp<0..99|101..infinity|100> | ||
127 | 4 items: %?Sp<0..49|50..99|101..infinity|100> | ||
128 | 5 items: %?Sp<0..49|50..99|101..149|150..infinity|100> | ||
129 | 6 items: %?Sp<0..33|34..66|67..99|101..133|134..infinity|100> | ||
130 | 7 items: %?Sp<0..33|34..66|67..99|101..133|134..167|167..infinity|100> | ||
131 | */ | ||
132 | static int pitch_speed_enum(int range, int32_t val, int32_t normval) | ||
133 | { | ||
134 | int center; | ||
135 | int n; | ||
136 | |||
137 | if (range < 3) | ||
138 | return (val == normval) + 1; | ||
139 | if (val == normval) | ||
140 | return range; | ||
141 | center = range / 2; | ||
142 | n = (center * val) / normval + 1; | ||
143 | return (range <= n) ? (range - 1) : n; | ||
144 | } | ||
145 | |||
110 | /* Return the tag found at index i and write its value in buf. | 146 | /* Return the tag found at index i and write its value in buf. |
111 | The return value is buf if the tag had a value, or NULL if not. | 147 | The return value is buf if the tag had a value, or NULL if not. |
112 | 148 | ||
@@ -786,6 +822,10 @@ const char *get_token_value(struct gui_wps *gwps, | |||
786 | snprintf(buf, buf_size, "%ld.%ld", | 822 | snprintf(buf, buf_size, "%ld.%ld", |
787 | pitch / PITCH_SPEED_PRECISION, | 823 | pitch / PITCH_SPEED_PRECISION, |
788 | (pitch % PITCH_SPEED_PRECISION) / (PITCH_SPEED_PRECISION / 10)); | 824 | (pitch % PITCH_SPEED_PRECISION) / (PITCH_SPEED_PRECISION / 10)); |
825 | |||
826 | if (intval) | ||
827 | *intval = pitch_speed_enum(limit, pitch, | ||
828 | PITCH_SPEED_PRECISION * 100); | ||
789 | return buf; | 829 | return buf; |
790 | } | 830 | } |
791 | #endif | 831 | #endif |