19 #include "os_helpers.h"
37 #define LINE_FONT BAGL_FONT_OPEN_SANS_REGULAR_11px
39 #if (BAGL_WIDTH == 128 && BAGL_HEIGHT == 64)
43 {{BAGL_RECTANGLE , 0x00, 0, 0, 128, 64, 0, 0, BAGL_FILL, 0x000000, 0xFFFFFF, 0, 0}, .
text=NULL},
45 {{BAGL_ICON , 0x01, 2, 28, 4, 7, 0, 0, 0 , 0xFFFFFF, 0x000000, 0, 0 }, .text=(
const char*)&C_icon_left},
46 {{BAGL_ICON , 0x02, 122, 28, 4, 7, 0, 0, 0 , 0xFFFFFF, 0x000000, 0, 0 }, .text=(
const char*)&C_icon_right},
48 {{BAGL_LABELINE , 0x10, 0, 15, 128, 12, 0, 0, 0 , 0xFFFFFF, 0x000000, BAGL_FONT_OPEN_SANS_EXTRABOLD_11px|BAGL_FONT_ALIGNMENT_CENTER, 0 }, .text=NULL},
49 {{BAGL_LABELINE , 0x11, (128-PIXEL_PER_LINE)/2, 29, PIXEL_PER_LINE, 12, 0, 0, 0 , 0xFFFFFF, 0x000000, LINE_FONT|BAGL_FONT_ALIGNMENT_CENTER, 0 }, .text=NULL},
50 {{BAGL_LABELINE , 0x12, (128-PIXEL_PER_LINE)/2, 43, PIXEL_PER_LINE, 12, 0, 0, 0 , 0xFFFFFF, 0x000000, LINE_FONT|BAGL_FONT_ALIGNMENT_CENTER, 0 }, .text=NULL},
51 {{BAGL_LABELINE , 0x13, (128-PIXEL_PER_LINE)/2, 57, PIXEL_PER_LINE, 12, 0, 0, 0 , 0xFFFFFF, 0x000000, LINE_FONT|BAGL_FONT_ALIGNMENT_CENTER, 0 }, .text=NULL},
81 SPRINTF(
G_ux.string_buffer,
82 (
G_ux.layout_paging.count > 1) ?
"%s (%d/%d)" :
"%s",
84 G_ux.layout_paging.current + 1,
85 G_ux.layout_paging.count);
88 SPRINTF(
G_ux.string_buffer,
90 G_ux.layout_paging.current + 1,
91 G_ux.layout_paging.count);
94 G_ux.tmp_element.component.font_id
95 = ((
G_ux.layout_paging.format & PAGING_FORMAT_BN) == PAGING_FORMAT_BN)
96 ? (BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER)
97 : (BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER);
98 G_ux.tmp_element.text =
G_ux.string_buffer;
104 unsigned int lineidx = (element->
component.userid & 0xF) - 1;
105 if (lineidx < UX_LAYOUT_PAGING_LINE_COUNT &&
G_ux.layout_paging.lengths[lineidx]) {
106 SPRINTF(
G_ux.string_buffer,
109 MIN(
sizeof(
G_ux.string_buffer) - 1,
G_ux.layout_paging.lengths[lineidx]),
111 +
G_ux.layout_paging.offsets[lineidx]);
112 G_ux.tmp_element.text =
G_ux.string_buffer;
114 G_ux.tmp_element.component.font_id
115 = ((
G_ux.layout_paging.format & PAGING_FORMAT_NB) == PAGING_FORMAT_NB)
116 ? (BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER)
117 : (BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER);
122 return &
G_ux.tmp_element;
129 if (NULL == params) {
135 #if defined(HAVE_INDEXED_STRINGS)
140 title = ((
const ux_layout_paging_params_t *) params)->title;
141 text = ((
const ux_layout_paging_params_t *) params)->text;
143 return ux_layout_paging_prepro_common(element, title, text);
147 void ux_layout_paging_redisplay_common(
unsigned int stack_slot,
152 bagl_font_id_e font_id;
154 #if (BAGL_WIDTH == 128 && BAGL_HEIGHT == 64)
159 ux_layout_bb_init_common(stack_slot);
163 if (
G_ux.layout_paging.format & PAGING_FORMAT_NB) {
164 font_id = BAGL_FONT_OPEN_SANS_EXTRABOLD_11px;
167 font_id = BAGL_FONT_OPEN_SANS_REGULAR_11px;
170 ux_layout_paging_compute(text,
G_ux.layout_paging.current, &
G_ux.layout_paging, font_id);
178 unsigned int button_mask,
179 unsigned int button_mask_counter);
181 void ux_layout_paging_redisplay_by_addr(
unsigned int stack_slot)
185 if (NULL == params) {
188 #if defined(HAVE_INDEXED_STRINGS)
191 text = ((
const ux_layout_paging_params_t *) params)->text;
193 ux_layout_paging_redisplay_common(stack_slot,
195 ux_layout_paging_button_callback_by_addr,
196 ux_layout_paging_prepro_by_addr);
199 static void ux_layout_paging_next(ux_layout_paging_redisplay_t redisplay)
201 if (
G_ux.layout_paging.current ==
G_ux.layout_paging.count - 1) {
206 G_ux.layout_paging.current++;
207 redisplay(
G_ux.stack_count - 1);
211 static void ux_layout_paging_prev(ux_layout_paging_redisplay_t redisplay)
213 if (
G_ux.layout_paging.current == 0) {
218 G_ux.layout_paging.current--;
219 redisplay(
G_ux.stack_count - 1);
224 unsigned int button_mask,
225 unsigned int button_mask_counter,
226 ux_layout_paging_redisplay_t redisplay)
228 UNUSED(button_mask_counter);
229 switch (button_mask) {
231 ux_layout_paging_prev(redisplay);
234 ux_layout_paging_next(redisplay);
237 if (
G_ux.layout_paging.count == 0
238 ||
G_ux.layout_paging.count - 1 ==
G_ux.layout_paging.current) {
247 unsigned int button_mask,
248 unsigned int button_mask_counter)
250 return ux_layout_paging_button_callback_common(
251 button_mask, button_mask_counter, ux_layout_paging_redisplay_by_addr);
254 void ux_layout_paging_init_common(
unsigned int stack_slot,
256 ux_layout_paging_redisplay_t redisplay)
258 bagl_font_id_e font_id;
262 unsigned int backup_format =
G_ux.layout_paging.format;
267 ux_layout_paging_reset();
271 G_ux.layout_paging.current = -1UL;
275 ux_layout_paging_reset();
282 G_ux.layout_paging.format = backup_format;
288 if ((text == NULL) && (
G_ux.externalText == NULL)) {
293 if (
G_ux.layout_paging.format & PAGING_FORMAT_NB) {
294 font_id = BAGL_FONT_OPEN_SANS_EXTRABOLD_11px;
297 font_id = BAGL_FONT_OPEN_SANS_REGULAR_11px;
301 G_ux.layout_paging.count
302 = ux_layout_paging_compute(text, -1UL, &
G_ux.layout_paging, font_id);
304 if (
G_ux.layout_paging.count == 0) {
305 ux_layout_paging_reset();
313 if (
G_ux.layout_paging.count &&
G_ux.layout_paging.current >
G_ux.layout_paging.count - 1UL) {
314 G_ux.layout_paging.current =
G_ux.layout_paging.count - 1;
317 redisplay(stack_slot);
320 void ux_layout_paging_init(
unsigned int stack_slot)
322 const ux_layout_paging_params_t *params
324 ux_layout_paging_init_common(stack_slot, params->text, ux_layout_paging_redisplay_by_addr);
327 void ux_layout_xx_paging_init(
unsigned int stack_slot,
unsigned int format)
329 G_ux.layout_paging.format = format;
330 ux_layout_paging_init(stack_slot);
333 void ux_layout_nn_paging_init(
unsigned int stack_slot)
335 ux_layout_xx_paging_init(stack_slot, PAGING_FORMAT_NN);
338 void ux_layout_nb_paging_init(
unsigned int stack_slot)
340 ux_layout_xx_paging_init(stack_slot, PAGING_FORMAT_NB);
343 void ux_layout_bn_paging_init(
unsigned int stack_slot)
345 ux_layout_xx_paging_init(stack_slot, PAGING_FORMAT_BN);
348 void ux_layout_bb_paging_init(
unsigned int stack_slot)
350 ux_layout_xx_paging_init(stack_slot, PAGING_FORMAT_BB);
355 void ux_layout_paging_reset(
void)
357 memset(&
G_ux.layout_paging, 0,
sizeof(
G_ux.layout_paging));
const char * get_ux_loc_string(uint32_t index)
bagl_component_t component
unsigned char element_arrays_count
button_push_callback_t button_push_callback
struct ux_stack_slot_s::@44 element_arrays[UX_STACK_SLOT_ARRAY_COUNT]
bagl_element_callback_t screen_before_element_display_callback
const bagl_element_t * element_array
unsigned char element_array_count
#define STATIC_IF_NOT_INDEXED
#define BUTTON_EVT_RELEASED
const bagl_element_t *(* bagl_element_callback_t)(const bagl_element_t *element)
void ux_stack_display(unsigned int stack_slot)
void ux_stack_init(unsigned int stack_slot)
unsigned int(* button_push_callback_t)(unsigned int button_mask, unsigned int button_mask_counter)
@ FLOW_DIRECTION_BACKWARD
ux_flow_direction_t ux_flow_direction(void)
unsigned int ux_flow_is_first(void)
const void * ux_stack_get_step_params(unsigned int stack_slot)
const void * ux_stack_get_current_step_params(void)
unsigned int ux_flow_is_last(void)
void ux_flow_validate(void)
BOLOS_UX_LOC_STRINGS UX_LOC_STRINGS_INDEX