Exemplo n.º 1
0
int render_clock()
{
	static char buflasttime[128];
	char buftime[128];
	time_t current_time;
	current_time = time(0);
	strftime(buftime, sizeof(buftime), theme->clock.format, localtime(&current_time));
	if (!strcmp(buflasttime, buftime))
		return 0;
	strcpy(buflasttime, buftime);
	
	tile_image(theme->tile_img, clock_pos, clock_width);
	int ox = clock_pos;
	draw_clock_background(ox, clock_width);
	int gap = theme->clock.space_gap;
	int lgap = get_image_width(theme->clock.left_img);
	int rgap = get_image_width(theme->clock.right_img);
	int x = ox + gap + lgap;
	int w = clock_width - ((gap * 2) + lgap + rgap);

	imlib_context_set_cliprect(x, 0, w, bbheight);
	draw_text(theme->clock.font, theme->clock.text_align, x, w,
			theme->clock.text_offset_x, theme->clock.text_offset_y,
			buftime, &theme->clock.text_color);
	imlib_context_set_cliprect(0, 0, bbwidth, bbheight);
	return 1;
}
Exemplo n.º 2
0
void render_taskbar(struct task *tasks, struct desktop *desktops)
{
	tile_image(theme->tile_img, taskbar_pos, taskbar_width);
	int activedesktop = 0;
	struct desktop *iter = desktops;
	while (iter) {
		if (iter->focused)
			break;
		activedesktop++;
		iter = iter->next;
	}
	
	struct task *t = tasks;
	uint state;
	int gap = theme->taskbar.space_gap;

	while (t) {
		if (t->desktop == activedesktop || t->desktop == -1) {
			state = t->focused ? BSTATE_PRESSED : BSTATE_IDLE;
			/* draw bg */
			draw_taskbar_button(state, t->posx, t->width);
			int lgap = get_image_width(theme->taskbar.left_img[state]);
			int rgap = get_image_width(theme->taskbar.right_img[state]);
			int x = t->posx + gap + lgap;
			int w = t->width - ((gap * 2) + lgap + rgap);

			/* draw icon */
			if (theme->taskbar.icon_h && theme->taskbar.icon_w) {
				int srcw, srch;
				int y = (theme->height - theme->taskbar.icon_h) / 2;
				imlib_context_set_image(t->icon);
				srcw = imlib_image_get_width();
				srch = imlib_image_get_height();
				y += theme->taskbar.icon_offset_y;
				x += theme->taskbar.icon_offset_x;
				w -= theme->taskbar.icon_offset_x;
				imlib_context_set_image(bb);
				imlib_context_set_blend(1);
				imlib_blend_image_onto_image(t->icon, 1, 0, 0, srcw, srch,
						x, y, theme->taskbar.icon_w, theme->taskbar.icon_h);
				imlib_context_set_blend(0);
				x += theme->taskbar.icon_w;
				w -= theme->taskbar.icon_w;
			}

			/* draw text */
			imlib_context_set_cliprect(x, 0, w, bbheight);
			draw_text(theme->taskbar.font, theme->taskbar.text_align, x, w,
				theme->taskbar.text_offset_x, theme->taskbar.text_offset_y,
				t->name, &theme->taskbar.text_color[state]);
			imlib_context_set_cliprect(0, 0, bbwidth, bbheight);

			/* draw separator if exists */
			if (t->next && t->next->desktop == activedesktop)
				draw_image(theme->taskbar.separator_img, x+w+gap+rgap);
		}
		t = t->next;
	}
}
Exemplo n.º 3
0
void
gib_imlib_line_clip_and_draw(Imlib_Image dest, int x0, int y0, int x1, int y1,
                             int cx, int cy, int cw, int ch, int r, int g,
                             int b, int a)
{
   imlib_context_set_cliprect(cx, cy, cw, ch);
   gib_imlib_image_draw_line(dest, x0, y0, x1, y1, 0, r, g, b, a);
   imlib_context_set_cliprect(0, 0, 0, 0);
}
Exemplo n.º 4
0
void
gib_imlib_image_fill_polygon(Imlib_Image im, ImlibPolygon poly, int r, int g,
                             int b, int a, unsigned char alias, int cx,
                             int cy, int cw, int ch)
{
   imlib_context_set_image(im);
   imlib_context_set_color(r, g, b, a);
   imlib_context_set_anti_alias(alias);
   imlib_context_set_cliprect(cx, cy, cw, ch);
   imlib_image_fill_polygon(poly);
   imlib_context_set_cliprect(0, 0, 0, 0);
}