Esempio n. 1
0
static void draw_next_button(int is_exit) {
	if (button_focused == 1) {
		/* hover */
		_ttk_draw_button_hover(cr_win, center_win_x(button_width), 400, button_width, button_height, is_exit ? "Exit" : "Next");
	} else if (button_focused == 2) {
		/* Down */
		_ttk_draw_button_select(cr_win, center_win_x(button_width), 400, button_width, button_height, is_exit ? "Exit" : "Next");
	} else {
		/* Something else? */
		_ttk_draw_button(cr_win, center_win_x(button_width), 400, button_width, button_height, is_exit ? "Exit" : "Next");
	}
}
Esempio n. 2
0
void ttk_window_draw(ttk_window_t * window) {
	draw_fill(window->core_context, rgb(TTK_BACKGROUND_DEFAULT));
	ttk_redraw_borders(window);

	/* TODO actual drawing */
	{
		/* TODO move these surfaces into the ttk_window_t object */
		int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, window->core_window->width);
		cairo_surface_t * core_surface = cairo_image_surface_create_for_data(window->core_context->backbuffer, CAIRO_FORMAT_ARGB32, window->core_window->width, window->core_window->height, stride);
		cairo_t * cr_main = cairo_create(core_surface);

		/* TODO move this surface to a ttk_frame_t or something; GUIs man, go look at some Qt or GTK APIs! */
		cairo_surface_t * internal_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, window->width, window->height);
		cairo_t * cr = cairo_create(internal_surface);

		_ttk_draw_menu(cr, 0, 0, window->width);

		_ttk_draw_button(cr, 4, TTK_MENU_HEIGHT + 4, window->width - 8, 40, "Regular Button");

		_ttk_draw_button(cr, 4, TTK_MENU_HEIGHT + 48 + 4, (window->width / 2) - 8, 40, "Regular Button");
		_ttk_draw_button_hover(cr, 4 + (window->width / 2), TTK_MENU_HEIGHT + 48 + 4, (window->width / 2) - 8, 40, "Hover Button");

		_ttk_draw_button_select(cr, 4, TTK_MENU_HEIGHT + 2 * 48 + 4, (window->width / 2) - 8, 40, "Selected");
		_ttk_draw_button_disabled(cr, 4 + (window->width / 2), TTK_MENU_HEIGHT + 2 * 48 + 4, (window->width / 2) - 8, 40, "Disabled Button");

		_ttk_draw_button(cr, 4, TTK_MENU_HEIGHT + 3 * 48 + 4, window->width - 8, window->height - (3 * 48) - TTK_MENU_HEIGHT - 8, "Regular Button");

		/* Paint the window's internal surface onto the backbuffer */
		cairo_set_source_surface(cr_main, internal_surface, (double)window->off_x, (double)window->off_y);
		cairo_paint(cr_main);
		cairo_surface_flush(internal_surface);
		cairo_destroy(cr);
		cairo_surface_destroy(internal_surface);

		/* In theory, we don't actually want to destroy much of any of this; maybe the cairo_t */
		cairo_surface_flush(core_surface);
		cairo_destroy(cr_main);
		cairo_surface_destroy(core_surface);
	}

	flip(window->core_context);
	yutani_flip(yctx, window->core_window);
}