EFI_STATUS ui_textarea_draw_scale(ui_textarea_t *textarea, UINTN x, UINTN *y,
				  UINTN width, UINTN height)
{
	UINTN new_width, new_height;
	EFI_GRAPHICS_OUTPUT_BLT_PIXEL *scaled_blt = NULL;
	EFI_STATUS ret;

	ui_textarea_refresh_blt(textarea);

	ui_get_scaled_dimension(textarea->width, textarea->height,
				width, height, &new_width, &new_height);
	scaled_blt = AllocatePool(ui_get_blt_size(new_width, new_height));
	if (!scaled_blt)
		return EFI_OUT_OF_RESOURCES;

	ui_bilinear_scale((unsigned char *)textarea->blt,
			  (unsigned char *)scaled_blt,
			  textarea->width, textarea->height,
			  new_width, new_height,
			  sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
	ret = ui_draw_blt(scaled_blt, x, *y, new_width, new_height);
	FreePool(scaled_blt);
	*y += new_height;

	return ret;
}
Ejemplo n.º 2
0
BOOLEAN ui_confirm(const ui_textline_t *text, UINTN width, UINTN height,
		   UINTN x, UINTN y)
{
	ui_events_t event;

#ifdef USE_POWER_BUTTON
	UINTN line_nb, len, row_nb = 0;
	EFI_STATUS ret;
	ui_font_t *font;
	UINTN text_height, scaled_text_height, scaled_text_width, line_height;

	font = ui_font_get_default();
	if (!font) {
		error(L"Default font not available");
		return FALSE;
	}

	for (line_nb = 0; text[line_nb].str; line_nb++) {
		len = strlen((CHAR8 *)text[line_nb].str);
		row_nb = row_nb < len ? len : row_nb;
	}

	if (!line_nb || !row_nb) {
		error(L"Invalid text for ui_confirm");
		return FALSE;
	}

	text_height = line_nb * height / (line_nb + ARRAY_SIZE(yes_no_menu));
	ret = ui_textarea_display_text(text, font, x, &y, width, text_height, NULL);
	if (EFI_ERROR(ret))
		return FALSE;

	ui_get_scaled_dimension((row_nb * font->cwidth), (line_nb * font->cheight),
				width, text_height, &scaled_text_width, &scaled_text_height);
	line_height = scaled_text_height / line_nb;

	ret = ui_confirm_draw_menu(font, x, y, scaled_text_width, line_height);
	if (EFI_ERROR(ret))
		return FALSE;
	for (;;) {
		event = ui_wait_for_input(TIMEOUT_SECS);
		switch (event) {
		case EV_UP:
		case EV_DOWN:
			current = (current + 1) % ARRAY_SIZE(yes_no_menu);
			ret = ui_confirm_draw_menu(font, x, y, scaled_text_width, line_height);
			if (EFI_ERROR(ret))
				return FALSE;
			break;
		case EV_POWER:
			ui_wait_for_key_release();
			return !current;
		default:
			break;
		}
	}
#else
	const ui_textline_t *texts[] = {text, yes_no_text, NULL};
	ui_display_texts(texts, x, y, width, height);
	event = ui_wait_for_input(TIMEOUT_SECS);
	return event == EV_UP ? TRUE : FALSE;
#endif
}