示例#1
0
void skin_draw_header_text(Skin *skin, char *text, SDL_Surface *target)
{
	lcd_draw_string(&skin->font1, text, target, 
	                gmu_widget_get_pos_x(&skin->header, 1),
			                             gmu_widget_get_pos_y(&skin->header, 0) +
			                             (gmu_widget_get_height(&skin->header, 0) -
			                              skin->font1_char_height) / 2);
}
示例#2
0
void skin_draw_footer_text(Skin *skin, char *text, SDL_Surface *target)
{
	int len = skin_textarea_get_characters_per_line(skin);
	lcd_draw_string_with_highlight(&skin->font1, &skin->font2, text, 0, target,
			                       gmu_widget_get_pos_x(&skin->footer, 1),
			                       gmu_widget_get_pos_y(&skin->footer, 0) +
			                       (gmu_widget_get_height(&skin->footer, 0) -
			                        skin->font1_char_height) / 2,
			                       len, RENDER_CROP);
}
示例#3
0
static void skin_update_widget(Skin *skin, GmuWidget *gw, SDL_Surface *display, SDL_Surface *buffer)
{
	SDL_Rect srect, drect;

	srect.x = gmu_widget_get_pos_x(gw, 0);
	srect.y = gmu_widget_get_pos_y(gw, 0);
	srect.w = gmu_widget_get_width(gw, 0);
	srect.h = gmu_widget_get_height(gw, 0);
	drect.x = srect.x;
	drect.y = srect.y;
	SDL_BlitSurface(buffer, &srect, display, &drect);
	SDL_UpdateRects(display, 1, &drect);
}
示例#4
0
void skin_draw_scroll_arrow_down(Skin *skin, SDL_Surface *target)
{
	SDL_Rect srect, drect;
	int ox = gmu_widget_get_pos_x(&skin->lv, 1);
	int oy = gmu_widget_get_pos_y(&skin->lv, 1);

	srect.w = skin->arrow_down->w;
	srect.h = skin->arrow_down->h;
	srect.x = 0;
	srect.y = 0;
	drect.x = ox + gmu_widget_get_width(&skin->lv, 1) - skin->arrow_down->w;
	drect.y = oy + gmu_widget_get_height(&skin->lv, 1) - skin->arrow_down->h;
	drect.w = 1;
	drect.h = 1;
	if (skin->arrow_down)
		SDL_BlitSurface(skin->arrow_down, &srect, target, &drect);
}
示例#5
0
static void skin_draw_widget(Skin *skin, GmuWidget *gw, SDL_Surface *buffer)
{
	SDL_Rect srect, drect;

	/* if necessary, draw the widget to the offscreen */
	if (skin_init_offscreen(skin, buffer)) {
		gmu_widget_draw(&skin->display, skin->buffer);
		gmu_widget_draw(&skin->header, skin->buffer);
		gmu_widget_draw(&skin->lv, skin->buffer);
		gmu_widget_draw(&skin->footer, skin->buffer);
	}
	srect.x = gmu_widget_get_pos_x(gw, 0);
	srect.y = gmu_widget_get_pos_y(gw, 0);
	srect.w = gmu_widget_get_width(gw, 0);
	srect.h = gmu_widget_get_height(gw, 0);
	drect.x = srect.x;
	drect.y = srect.y;
	SDL_BlitSurface(skin->buffer, &srect, buffer, &drect);
}
示例#6
0
void skin_draw_display_symbol(Skin *skin, SDL_Surface *target, SkinDisplaySymbol symbol)
{
	SDL_Rect srect, drect;
	int ox = gmu_widget_get_pos_x(&skin->display, 0);
	int oy = gmu_widget_get_pos_y(&skin->display, 0);

	srect.w = skin->symbols_width;
	srect.h = skin->symbols_height;
	srect.y = 0;
	switch (symbol) {
		default:
		case SYMBOL_PLAY:
			srect.x = 0;
			drect.x = ox + skin->symbol_play_offset_x;
			drect.y = oy + skin->symbol_play_offset_y;
			drect.w = 1;
			drect.h = 1;
			break;
		case SYMBOL_PAUSE:
			srect.x = 1 * skin->symbols_width;
			drect.x = ox + skin->symbol_pause_offset_x;
			drect.y = oy + skin->symbol_pause_offset_y;
			drect.w = 1;
			drect.h = 1;
			break;
		case SYMBOL_STEREO:
			srect.x = 2 * skin->symbols_width;
			drect.x = ox + skin->symbol_stereo_offset_x;
			drect.y = oy + skin->symbol_stereo_offset_y;
			drect.w = 1;
			drect.h = 1;
			break;
	}
	if (skin->display_symbols && drect.x - ox >= 0 && drect.y - oy >= 0)
		SDL_BlitSurface(skin->display_symbols, &srect, target, &drect);
}
示例#7
0
void cover_viewer_show(CoverViewer *cv, SDL_Surface *target, TrackInfo *ti)
{
	SDL_Rect     srect, drect;
	int          text_x_offset = 5;
	int          chars_per_line = (skin_textarea_get_characters_per_line((Skin *)cv->skin) < 256 ? 
	                               skin_textarea_get_characters_per_line((Skin *)cv->skin) : 255);
	SDL_Surface *cover = cover_image_get_image(&cv->ci);
	int          ax = gmu_widget_get_pos_x((GmuWidget *)&cv->skin->lv, 1);
	int          ay = gmu_widget_get_pos_y((GmuWidget *)&cv->skin->lv, 1);
	int          aw = gmu_widget_get_width((GmuWidget *)&cv->skin->lv, 1);
	int          ah = gmu_widget_get_height((GmuWidget *)&cv->skin->lv, 1);

	if (cover != NULL && !cv->hide_cover && trackinfo_has_cover_artwork(ti)) {
		if (!cv->large) {
			if (cv->small_cover_align == ALIGN_LEFT) {
				text_browser_set_pos_x(&cv->tb, ax + aw / 2);
			} else {
				text_browser_set_pos_x(&cv->tb, ax);
			}
			if (!cv->hide_text) {
				chars_per_line = chars_per_line / 2 - 1;
				text_browser_set_chars_per_line(&cv->tb, chars_per_line);
				switch (cv->small_cover_align) {
					case ALIGN_LEFT:
						drect.x = ax;
						drect.y = ay + ah / 2 - cover->h / 2;
						text_x_offset = cover->w + 5;
						break;
					case ALIGN_RIGHT:
						drect.x = ax + aw - cover->w;
						drect.y = ay + ah / 2 - cover->h / 2;
						text_x_offset = 0;
						break;
				}
				text_browser_set_pos_x(&cv->tb, ax + text_x_offset);
				text_browser_draw(&cv->tb, target);
			} else {
				drect.x = ax + aw / 2 - cover->w / 2;
				drect.y = ay + ah / 2 - cover->h / 2;
			}
			if (cover->w <= aw && cover->h <= ah)
				SDL_BlitSurface(cover, NULL, target, &drect);
		} else {
			text_browser_set_pos_x(&cv->tb, ax);
			text_browser_set_chars_per_line(&cv->tb, chars_per_line);
			drect.x = ax;
			drect.y = ay;
			srect.x = 0;
			srect.y = cv->y_offset;
			srect.w = aw;
			srect.h = ah;
			text_x_offset = 5;
			SDL_BlitSurface(cover, &srect, target, &drect);
			if (!cv->hide_text)	text_browser_draw(&cv->tb, target);
		}
	} else {
		text_browser_set_pos_x(&cv->tb, ax);
		text_browser_set_chars_per_line(&cv->tb, chars_per_line);
		if (!cv->hide_text) text_browser_draw(&cv->tb, target);
	}
	
	/* Draw spectrum analyzer */
	if (cv->spectrum_analyzer) {
		Uint32   color = SDL_MapRGB(target->format, 0, 70, 255);
		int      i, barwidth = aw / 20;
		int16_t *amplitudes;
		static int16_t amplitudes_smoothed[8];
		SDL_Rect dstrect;

		dstrect.w = barwidth;
		dstrect.h = 20;
		dstrect.x = cv->hide_text ? ax + aw / 2 - aw / 4 : ax + aw / 2;
		if (audio_spectrum_read_lock()) {
			amplitudes = audio_spectrum_get_current_amplitudes();
			for (i = 0; i < 8; i++) {
				int16_t a = amplitudes[i] / 327 + 2;
				dstrect.x += barwidth+1;
				if (amplitudes_smoothed[i] < a) amplitudes_smoothed[i] = a;
				amplitudes_smoothed[i] = amplitudes_smoothed[i] > 70 ? 70 : amplitudes_smoothed[i];
				dstrect.h = amplitudes_smoothed[i];
				dstrect.y = ay + ah / 2 + 25 - amplitudes_smoothed[i];
				SDL_FillRect(target, &dstrect, color);
				amplitudes_smoothed[i] -= (15-i);
				if (amplitudes_smoothed[i] < 2) amplitudes_smoothed[i] = 2;
			}
			audio_spectrum_read_unlock();
		}
	}

	if (cv->hide_text && !cv->hide_cover &&  !cv->spectrum_analyzer)
		skin_draw_header_text((Skin *)cv->skin, "Track info (Cover only)", target);
	else if (cv->hide_cover && !cv->hide_text && !cv->spectrum_analyzer)
		skin_draw_header_text((Skin *)cv->skin, "Track info (Text only)", target);
	else if (cv->hide_cover && cv->hide_text && cv->spectrum_analyzer)
		skin_draw_header_text((Skin *)cv->skin, "Track info (Spectrum analyzer only)", target);
	else if (cv->hide_text && cv->hide_cover && !cv->spectrum_analyzer)
		skin_draw_header_text((Skin *)cv->skin, "Track info (showing nothing)", target);
	else if (cv->hide_text && !cv->hide_cover && cv->spectrum_analyzer)
		skin_draw_header_text((Skin *)cv->skin, "Track info (Cover + Spectrum analyzer)", target);
	else if (!cv->hide_text && cv->hide_cover && cv->spectrum_analyzer)
		skin_draw_header_text((Skin *)cv->skin, "Track info (Text + Spectrum analyzer)", target);
	else if (!cv->hide_text && !cv->hide_cover && !cv->spectrum_analyzer)
		skin_draw_header_text((Skin *)cv->skin, "Track info (Text + Cover)", target);
}
void pl_browser_draw(PlaylistBrowser *pb, SDL_Surface *sdl_target)
{
	int    i = 0;
	char   buf[64];
	Entry *pl_entry;
	int    number_of_visible_lines = skin_textarea_get_number_of_lines((Skin *)pb->skin);
	int    len = (skin_textarea_get_characters_per_line((Skin *)pb->skin) > 63 ? 
	              63 : skin_textarea_get_characters_per_line((Skin *)pb->skin));
	int    selected_entry_drawn = 0;

	snprintf(buf, 63, "Playlist (%d %s)", gmu_core_playlist_get_length(),
	         gmu_core_playlist_get_length() != 1 ? "entries" : "entry");
	skin_draw_header_text((Skin *)pb->skin, buf, sdl_target);

	if (pb->first_visible_entry == NULL || pb->offset == 0) {
		pb->first_visible_entry = gmu_core_playlist_get_first();
	}

	pb->longest_line_so_far = 0;
	pl_entry = pb->first_visible_entry;
	for (i = pb->offset; 
	     i < pb->offset + number_of_visible_lines && 
	     i < gmu_core_playlist_get_length() && pl_entry != NULL;
	     i++) {
		char  c = (playlist_get_played(pl_entry) ? 'o' : ' ');
		char *entry_name = gmu_core_playlist_get_entry_name(pl_entry);
		char *format = "%c%3d";
		int   l = gmu_core_playlist_get_length();
		int   line_length = strlen(entry_name);
		LCD  *font, *font_inverted;

		if (line_length > pb->longest_line_so_far)
			pb->longest_line_so_far = line_length;

		if (l > 999 && l <= 9999) format = "%c%4d";
		if (l > 9999) format = "%c%5d";

		if (playlist_entry_get_queue_pos(pl_entry) == 0)
			snprintf(buf, len, format, (pl_entry == gmu_core_playlist_get_current() ? '*' : c), i + 1);
		else
			snprintf(buf, len, "%cQ:%d", (pl_entry == gmu_core_playlist_get_current() ? '*' : c),
			         playlist_entry_get_queue_pos(pl_entry));

		if (i == pb->offset + number_of_visible_lines - 1 && !selected_entry_drawn)
			pb->selection = i;

		font =          (LCD *)(i == pb->selection ? &pb->skin->font2 : &pb->skin->font1);
		font_inverted = (LCD *)(i == pb->selection ? &pb->skin->font1 : &pb->skin->font2);

		if (i == pb->selection) selected_entry_drawn = 1;
		lcd_draw_string(font, buf, sdl_target, gmu_widget_get_pos_x((GmuWidget *)&pb->skin->lv, 1),
						gmu_widget_get_pos_y((GmuWidget *)&pb->skin->lv, 1) + 1
						+ (i-pb->offset) * (pb->skin->font2_char_height + 1));
		lcd_draw_string_with_highlight(font, font_inverted, entry_name, pb->horiz_offset, sdl_target, 
									   gmu_widget_get_pos_x((GmuWidget *)&pb->skin->lv, 1)
									   + pb->skin->font1_char_width * 7,
									   gmu_widget_get_pos_y((GmuWidget *)&pb->skin->lv, 1) + 1
									   + (i-pb->offset)*(pb->skin->font2_char_height+1),
									   skin_textarea_get_characters_per_line((Skin *)pb->skin)-6, RENDER_ARROW);
		pl_entry = playlist_get_next(pl_entry);
	}
}