diff options
-rw-r--r-- | apps/gui/skin_engine/skin_display.c | 17 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_render.c | 83 |
2 files changed, 68 insertions, 32 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index 8e08343d82..d76b57976d 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c | |||
@@ -503,12 +503,7 @@ int evaluate_conditional(struct gui_wps *gwps, int offset, | |||
503 | char result[128]; | 503 | char result[128]; |
504 | const char *value; | 504 | const char *value; |
505 | 505 | ||
506 | /* treat ?xx<true> constructs as if they had 2 options. | 506 | int intval = num_options < 2 ? 2 : num_options; |
507 | * (i.e ?xx<true|false>) */ | ||
508 | if (num_options < 2) | ||
509 | num_options = 2; | ||
510 | |||
511 | int intval = num_options; | ||
512 | /* get_token_value needs to know the number of options in the enum */ | 507 | /* get_token_value needs to know the number of options in the enum */ |
513 | value = get_token_value(gwps, conditional->token, offset, | 508 | value = get_token_value(gwps, conditional->token, offset, |
514 | result, sizeof(result), &intval); | 509 | result, sizeof(result), &intval); |
@@ -516,11 +511,15 @@ int evaluate_conditional(struct gui_wps *gwps, int offset, | |||
516 | /* intval is now the number of the enum option we want to read, | 511 | /* intval is now the number of the enum option we want to read, |
517 | starting from 1. If intval is -1, we check if value is empty. */ | 512 | starting from 1. If intval is -1, we check if value is empty. */ |
518 | if (intval == -1) | 513 | if (intval == -1) |
519 | intval = (value && *value) ? 1 : num_options; | 514 | { |
515 | if (num_options == 1) /* so %?AA<true> */ | ||
516 | intval = (value && *value) ? 1 : 0; /* returned as 0 for true, -1 for false */ | ||
517 | else | ||
518 | intval = (value && *value) ? 1 : num_options; | ||
519 | } | ||
520 | else if (intval > num_options || intval < 1) | 520 | else if (intval > num_options || intval < 1) |
521 | intval = num_options; | 521 | intval = num_options; |
522 | 522 | ||
523 | conditional->last_value = intval -1; | ||
524 | return intval -1; | 523 | return intval -1; |
525 | } | 524 | } |
526 | 525 | ||
diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c index 46ae16b1ab..9f392f144f 100644 --- a/apps/gui/skin_engine/skin_render.c +++ b/apps/gui/skin_engine/skin_render.c | |||
@@ -394,22 +394,19 @@ static bool skin_render_line(struct skin_element* line, struct skin_draw_info *i | |||
394 | last_value = conditional->last_value; | 394 | last_value = conditional->last_value; |
395 | value = evaluate_conditional(info->gwps, info->offset, | 395 | value = evaluate_conditional(info->gwps, info->offset, |
396 | conditional, child->children_count); | 396 | conditional, child->children_count); |
397 | 397 | conditional->last_value = value; | |
398 | if (value != 1 && value >= child->children_count) | ||
399 | value = child->children_count-1; | ||
400 | if (child->children_count == 1) | 398 | if (child->children_count == 1) |
401 | { | 399 | { |
402 | /* special handling so | 400 | /* special handling so |
403 | * %?aa<true> and %?<true|false> need special handlng here */ | 401 | * %?aa<true> and %?<true|false> need special handlng here */ |
404 | 402 | ||
405 | if (value == 1) /* tag is false */ | 403 | if (value == -1) /* tag is false */ |
406 | { | 404 | { |
407 | /* we are in a false branch of a %?aa<true> conditional */ | 405 | /* we are in a false branch of a %?aa<true> conditional */ |
408 | if (last_value == 0) | 406 | if (last_value == 0) |
409 | do_tags_in_hidden_conditional(child->children[0], info); | 407 | do_tags_in_hidden_conditional(child->children[0], info); |
410 | break; | 408 | break; |
411 | } | 409 | } |
412 | value = 0; | ||
413 | } | 410 | } |
414 | else | 411 | else |
415 | { | 412 | { |
@@ -482,6 +479,38 @@ static bool skin_render_line(struct skin_element* line, struct skin_draw_info *i | |||
482 | return needs_update; | 479 | return needs_update; |
483 | } | 480 | } |
484 | 481 | ||
482 | static int get_subline_timeout(struct gui_wps *gwps, struct skin_element* line) | ||
483 | { | ||
484 | struct skin_element *element=line; | ||
485 | struct wps_token *token; | ||
486 | int retval = -1; | ||
487 | if (element->type == LINE) | ||
488 | element = element->children[0]; | ||
489 | while (element) | ||
490 | { | ||
491 | if (element->type == TAG && | ||
492 | element->tag->type == SKIN_TOKEN_SUBLINE_TIMEOUT ) | ||
493 | { | ||
494 | token = element->data; | ||
495 | return token->value.i; | ||
496 | } | ||
497 | else if (element->type == CONDITIONAL) | ||
498 | { | ||
499 | struct conditional *conditional = element->data; | ||
500 | int val = evaluate_conditional(gwps, 0, conditional, | ||
501 | element->children_count); | ||
502 | if (val >= 0) | ||
503 | { | ||
504 | retval = get_subline_timeout(gwps, element->children[val]); | ||
505 | if (retval >= 0) | ||
506 | return retval; | ||
507 | } | ||
508 | } | ||
509 | element = element->next; | ||
510 | } | ||
511 | return retval; | ||
512 | } | ||
513 | |||
485 | bool skin_render_alternator(struct skin_element* element, struct skin_draw_info *info) | 514 | bool skin_render_alternator(struct skin_element* element, struct skin_draw_info *info) |
486 | { | 515 | { |
487 | bool changed_lines = false; | 516 | bool changed_lines = false; |
@@ -500,30 +529,38 @@ bool skin_render_alternator(struct skin_element* element, struct skin_draw_info | |||
500 | int next_change = alternator->last_change_tick + line->timeout; | 529 | int next_change = alternator->last_change_tick + line->timeout; |
501 | if (TIME_AFTER(current_tick, next_change)) | 530 | if (TIME_AFTER(current_tick, next_change)) |
502 | { | 531 | { |
503 | alternator->current_line++; | ||
504 | if (alternator->current_line >= element->children_count) | ||
505 | alternator->current_line = 0; | ||
506 | alternator->last_change_tick = current_tick; | 532 | alternator->last_change_tick = current_tick; |
507 | changed_lines = true; | 533 | changed_lines = true; |
508 | } | 534 | } |
509 | } | 535 | } |
510 | if (element->children[alternator->current_line]->children_count == 0) | ||
511 | { | ||
512 | int old_line = alternator->current_line; | ||
513 | int line = alternator->current_line+1; | ||
514 | /* skip empty sublines */ | ||
515 | while (line!=old_line && element->children[line]->children_count == 0) | ||
516 | { | ||
517 | line++; | ||
518 | if (line >= element->children_count) | ||
519 | line = 0; | ||
520 | } | ||
521 | alternator->current_line = line; | ||
522 | changed_lines = true; | ||
523 | } | ||
524 | |||
525 | if (changed_lines) | 536 | if (changed_lines) |
526 | { | 537 | { |
538 | struct skin_element *current_line = element->children[alternator->current_line]; | ||
539 | int start = alternator->current_line; | ||
540 | int try_line = start; | ||
541 | bool suitable = false; | ||
542 | |||
543 | /* find a subline which has at least one token in it, | ||
544 | * and that line doesnt have a timeout set to 0 through conditionals */ | ||
545 | do { | ||
546 | try_line++; | ||
547 | if (try_line >= element->children_count) | ||
548 | try_line = 0; | ||
549 | if (element->children[try_line]->children_count != 0) | ||
550 | { | ||
551 | current_line = element->children[try_line]; | ||
552 | if ((current_line->children[0]->type != CONDITIONAL) || | ||
553 | get_subline_timeout(info->gwps, current_line->children[0]) > 0) | ||
554 | { | ||
555 | suitable = true; | ||
556 | } | ||
557 | } | ||
558 | } | ||
559 | while (try_line != start && !suitable); | ||
560 | |||
561 | if (suitable) | ||
562 | alternator->current_line = try_line; | ||
563 | |||
527 | info->refresh_type = SKIN_REFRESH_ALL; | 564 | info->refresh_type = SKIN_REFRESH_ALL; |
528 | info->force_redraw = true; | 565 | info->force_redraw = true; |
529 | } | 566 | } |