/** * Render a button. * @param button * Button to render. * @param text * Optional text to render. */ void button_show(button_struct *button, const char *text) { SDL_Surface *texture; (void) button_need_redraw(button); if (button->pressed_forced) { button->pressed = 1; } texture = texture_surface(button_determine_texture(button)); surface_show(button->surface, button->x, button->y, NULL, texture); if (text) { const char *color, *color_shadow; int x, y; if (button->disabled) { color = COLOR_GRAY; color_shadow = COLOR_BLACK; } else if (button->mouse_over) { color = button->color_over; color_shadow = button->color_over_shadow; } else { color = button->color; color_shadow = button->color_shadow; } x = button->x; y = button->y; if (button->center) { x += texture->w / 2 - text_get_width(button->font, text, button->flags) / 2; y += texture->h / 2 - FONT_HEIGHT(button->font) / 2; } if (!color_shadow) { text_show(button->surface, button->font, text, x, y, color, button->flags, NULL); } else { text_show_shadow(button->surface, button->font, text, x, y - 2, color, color_shadow, button->flags, NULL); } } if (button->repeat_func && button->pressed && SDL_GetTicks() - button->pressed_ticks > button->pressed_repeat_ticks) { button->repeat_func(button); button->pressed_ticks = SDL_GetTicks(); button->pressed_repeat_ticks = 150; } button->redraw = 0; }
/** @copydoc widgetdata::background_func */ static void widget_background(widgetdata *widget, int draw) { if (!widget->redraw) { widget->redraw = list_need_redraw(list_skills); } if (!widget->redraw) { size_t i; for (i = 0; i < BUTTON_NUM; i++) { if (button_need_redraw(&buttons[i])) { widget->redraw = 1; break; } } } }
/** @copydoc widgetdata::background_func */ static void widget_background(widgetdata *widget, int draw) { size_t i; /* Create the party list. */ if (!list_party) { list_party = list_create(12, 2, 8); list_party->handle_enter_func = list_handle_enter; list_party->text_flags = TEXT_MARKUP; list_party->row_highlight_func = list_row_highlight; list_party->row_selected_func = list_row_selected; list_scrollbar_enable(list_party); list_set_column(list_party, 0, 130, 7, NULL, -1); list_set_column(list_party, 1, 60, 7, NULL, -1); list_party->header_height = 6; for (i = 0; i < BUTTON_NUM; i++) { button_create(&buttons[i]); if (i == BUTTON_CLOSE || i == BUTTON_HELP) { buttons[i].texture = texture_get(TEXTURE_TYPE_CLIENT, "button_round"); buttons[i].texture_pressed = texture_get(TEXTURE_TYPE_CLIENT, "button_round_down"); buttons[i].texture_over = texture_get(TEXTURE_TYPE_CLIENT, "button_round_over"); } else if (i == BUTTON_PARTIES || i == BUTTON_MEMBERS) { buttons[i].flags = TEXT_MARKUP; } } widget->redraw = 1; list_contents = -1; } if (!widget->redraw) { widget->redraw = list_need_redraw(list_party); } if (!widget->redraw) { for (i = 0; i < BUTTON_NUM; i++) { if (button_need_redraw(&buttons[i])) { widget->redraw = 1; break; } } } }
/** @copydoc widgetdata::background_func */ static void widget_background(widgetdata *widget, int draw) { uint32_t duration, num_lines; /* If shuffle is enabled, check whether we need to start playing * another song. */ if (shuffle) { mplayer_check_shuffle(); } duration = sound_music_get_duration(); num_lines = duration + MAX(1, duration / 10); if (num_lines != scrollbar_progress_info.num_lines) { scrollbar_progress_info.num_lines = num_lines; scrollbar_progress.max_lines = MAX(1, duration / 10); widget->redraw = 1; } if (list_mplayer) { if (scrollbar_progress_info.redraw && sound_music_can_seek()) { sound_music_seek(scrollbar_progress_info.scroll_offset + 1); scrollbar_progress_info.redraw = 0; widget->redraw = 1; } else { uint32_t offset; offset = scrollbar_progress_info.scroll_offset; scrollbar_progress.redraw = NULL; scrollbar_scroll_to(&scrollbar_progress, sound_music_get_offset()); scrollbar_progress.redraw = &scrollbar_progress_info.redraw; if (offset != scrollbar_progress_info.scroll_offset) { widget->redraw = 1; } } } /* Do mass blacklist status change if the button has been held for * some time. */ if (buttons[BUTTON_BLACKLIST].pressed && SDL_GetTicks() - buttons[BUTTON_BLACKLIST].pressed_ticks > BLACKLIST_ALL_DELAY) { mplayer_blacklist_mass_toggle(list_mplayer, mplayer_blacklisted(list_mplayer)); mplayer_blacklist_save(list_mplayer); buttons[BUTTON_BLACKLIST].pressed_ticks = SDL_GetTicks(); } if (!widget->redraw) { widget->redraw = list_need_redraw(list_mplayer); } if (!widget->redraw) { size_t i; for (i = 0; i < BUTTON_NUM; i++) { if (button_need_redraw(&buttons[i])) { widget->redraw = 1; break; } } } }