void feh_draw_errstr(winwidget w) { static Imlib_Font fn = NULL; int tw = 0, th = 0; Imlib_Image im = NULL; if (!w->im) return; fn = feh_load_font(NULL); /* Work out how high the font is */ gib_imlib_get_text_size(fn, w->errstr, NULL, &tw, &th, IMLIB_TEXT_TO_RIGHT); tw += 3; th += 3; im = imlib_create_image(tw, th); if (!im) eprintf("Couldn't create errstr image. Out of memory?"); feh_imlib_image_fill_text_bg(im, tw, th); gib_imlib_text_draw(im, fn, NULL, 2, 2, w->errstr, IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255); gib_imlib_text_draw(im, fn, NULL, 1, 1, w->errstr, IMLIB_TEXT_TO_RIGHT, 255, 0, 0, 255); free(w->errstr); w->errstr = NULL; gib_imlib_render_image_on_drawable(w->bg_pmap, im, 0, w->h - th, 1, 1, 0); gib_imlib_free_image_and_decache(im); }
void feh_draw_zoom(winwidget w) { static Imlib_Font fn = NULL; int tw = 0, th = 0; Imlib_Image im = NULL; char buf[100]; if (!w->im) return; fn = feh_load_font(w); snprintf(buf, sizeof(buf), "%.0f%%, %dx%d", w->zoom * 100, (int) (w->im_w * w->zoom), (int) (w->im_h * w->zoom)); /* Work out how high the font is */ gib_imlib_get_text_size(fn, buf, NULL, &tw, &th, IMLIB_TEXT_TO_RIGHT); tw += 3; th += 3; im = imlib_create_image(tw, th); if (!im) eprintf("Couldn't create image. Out of memory?"); feh_imlib_image_fill_text_bg(im, tw, th); gib_imlib_text_draw(im, fn, NULL, 2, 2, buf, IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255); gib_imlib_text_draw(im, fn, NULL, 1, 1, buf, IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255); gib_imlib_render_image_on_drawable(w->bg_pmap, im, 0, w->h - th, 1, 1, 0); gib_imlib_free_image_and_decache(im); return; }
void feh_draw_filename(winwidget w) { static Imlib_Font fn = NULL; int tw = 0, th = 0, nw = 0; Imlib_Image im = NULL; char *s = NULL; int len = 0; if ((!w->file) || (!FEH_FILE(w->file->data)) || (!FEH_FILE(w->file->data)->filename)) return; fn = feh_load_font(w); /* Work out how high the font is */ gib_imlib_get_text_size(fn, FEH_FILE(w->file->data)->filename, NULL, &tw, &th, IMLIB_TEXT_TO_RIGHT); if (gib_list_length(filelist) > 1) { len = snprintf(NULL, 0, "%d of %d", gib_list_length(filelist), gib_list_length(filelist)) + 1; s = emalloc(len); if (w->file) snprintf(s, len, "%d of %d", gib_list_num(filelist, w->file) + 1, gib_list_length(filelist)); else snprintf(s, len, "%d of %d", gib_list_num(filelist, current_file) + 1, gib_list_length(filelist)); gib_imlib_get_text_size(fn, s, NULL, &nw, NULL, IMLIB_TEXT_TO_RIGHT); if (nw > tw) tw = nw; } tw += 3; th += 3; im = imlib_create_image(tw, 2 * th); if (!im) eprintf("Couldn't create image. Out of memory?"); feh_imlib_image_fill_text_bg(im, tw, 2 * th); gib_imlib_text_draw(im, fn, NULL, 2, 2, FEH_FILE(w->file->data)->filename, IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255); gib_imlib_text_draw(im, fn, NULL, 1, 1, FEH_FILE(w->file->data)->filename, IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255); if (s) { gib_imlib_text_draw(im, fn, NULL, 2, th + 1, s, IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255); gib_imlib_text_draw(im, fn, NULL, 1, th, s, IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255); free(s); } gib_imlib_render_image_on_drawable(w->bg_pmap, im, 0, 0, 1, 1, 0); gib_imlib_free_image_and_decache(im); return; }
void feh_menu_draw_item(feh_menu_item * i, Imlib_Image im, int ox, int oy) { D(("drawing item %p (text %s)\n", i, i->text)); if (i->text) { D(("text item\n")); if (MENU_ITEM_IS_SELECTED(i)) { D(("selected item\n")); /* draw selected image */ feh_menu_item_draw_at(i->x, i->y, i->w, i->h, im, ox, oy, 1); } else { D(("unselected item\n")); /* draw unselected image */ feh_menu_item_draw_at(i->x, i->y, i->w, i->h, im, ox, oy, 0); } /* draw text */ gib_imlib_text_draw(im, opt.menu_fn, NULL, i->x - ox + i->text_x, i->y - oy + FEH_MENUITEM_PAD_TOP, i->text, IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255); if (i->submenu) { D(("submenu item\n")); feh_menu_draw_submenu_at(i->x + i->sub_x, i->y + FEH_MENUITEM_PAD_TOP + ((i->h - FEH_MENUITEM_PAD_TOP - FEH_MENUITEM_PAD_BOTTOM - FEH_MENU_SUBMENU_H) / 2), im, ox, oy); } if (i->is_toggle) { D(("toggleable item\n")); feh_menu_draw_toggle_at(i->x + i->toggle_x, i->y + FEH_MENUITEM_PAD_TOP + ((i->h - FEH_MENUITEM_PAD_TOP - FEH_MENUITEM_PAD_BOTTOM - FEH_MENU_TOGGLE_H) / 2), FEH_MENU_TOGGLE_W, FEH_MENU_TOGGLE_H, im, ox, oy, MENU_ITEM_IS_ON(i)); } } else { D(("separator item\n")); feh_menu_draw_separator_at(i->x, i->y, i->w, i->h, im, ox, oy); } return; }
/* TODO s/bit/lot */ void init_thumbnail_mode(void) { /* moved to thumbnail_data: Imlib_Image im_main; Imlib_Image bg_im = NULL; Imlib_Font fn = NULL; Imlib_Font title_fn = NULL; int w = 800, h = 600; int bg_w = 0, bg_h = 0; int text_area_w, text_area_h; int max_column_w = 0; */ Imlib_Image im_temp; int ww = 0, hh = 0, www, hhh, xxx, yyy; int x = 0, y = 0; winwidget winwid = NULL; Imlib_Image im_thumb = NULL; unsigned char trans_bg = 0; int title_area_h = 0; int tw = 0, th = 0; int fw_name, fw_size, fw_dim, fh; int thumbnailcount = 0; feh_file *file = NULL; gib_list *l, *last = NULL; int lines; int index_image_width, index_image_height; int x_offset_name = 0, x_offset_dim = 0, x_offset_size = 0; char *s; unsigned int thumb_counter = 0; /* initialize thumbnail mode data */ td.im_main = NULL; td.im_bg = NULL; td.font_main = NULL; td.font_title = NULL; td.w = 640; td.h = 480; td.bg_w = 0; td.bg_h = 0; td.thumb_tot_h = 0; td.text_area_w = 0; td.text_area_h = 0; td.vertical = 0; td.max_column_w = 0; mode = "thumbnail"; if (opt.font) td.font_main = gib_imlib_load_font(opt.font); if (!td.font_main) td.font_main = gib_imlib_load_font(DEFAULT_FONT); if (opt.title_font) { int fh, fw; td.font_title = gib_imlib_load_font(opt.title_font); gib_imlib_get_text_size(td.font_title, "W", NULL, &fw, &fh, IMLIB_TEXT_TO_RIGHT); title_area_h = fh + 4; } else td.font_title = imlib_load_font(DEFAULT_FONT_TITLE); if ((!td.font_main) || (!td.font_title)) eprintf("Error loading fonts"); /* Work out how tall the font is */ gib_imlib_get_text_size(td.font_main, "W", NULL, &tw, &th, IMLIB_TEXT_TO_RIGHT); /* For now, allow room for the right number of lines with small gaps */ td.text_area_h = ((th + 2) * (opt.index_show_name + opt.index_show_size + opt.index_show_dim)) + 5; /* This includes the text area for index data */ td.thumb_tot_h = opt.thumb_h + td.text_area_h; /* Use bg image dimensions for default size */ if (opt.bg && opt.bg_file) { if (!strcmp(opt.bg_file, "trans")) trans_bg = 1; else { D(3, ("Time to apply a background to blend onto\n")); if (feh_load_image_char(&td.im_bg, opt.bg_file) != 0) { td.bg_w = gib_imlib_image_get_width(td.im_bg); td.bg_h = gib_imlib_image_get_height(td.im_bg); } } } /* figure out geometry for the main window and entries */ feh_thumbnail_calculate_geometry(); index_image_width = td.w; index_image_height = td.h + title_area_h; td.im_main = imlib_create_image(index_image_width, index_image_height); gib_imlib_image_set_has_alpha(td.im_main, 1); if (!td.im_main) eprintf("Imlib error creating index image, are you low on RAM?"); if (td.im_bg) gib_imlib_blend_image_onto_image(td.im_main, td.im_bg, gib_imlib_image_has_alpha (td.im_bg), 0, 0, td.bg_w, td.bg_h, 0, 0, td.w, td.h, 1, 0, 0); else if (trans_bg) { gib_imlib_image_fill_rectangle(td.im_main, 0, 0, td.w, td.h + title_area_h, 0, 0, 0, 0); gib_imlib_image_set_has_alpha(td.im_main, 1); } else { /* Colour the background */ gib_imlib_image_fill_rectangle(td.im_main, 0, 0, td.w, td.h + title_area_h, 0, 0, 0, 255); } /* Create title now */ if (!opt.title) s = estrdup(PACKAGE " [thumbnail mode]"); else s = estrdup(feh_printf(opt.title, NULL)); if (opt.display) { winwid = winwidget_create_from_image(td.im_main, s, WIN_TYPE_THUMBNAIL); winwidget_show(winwid); } /* make sure we have an ~/.thumbnails/normal directory for storing permanent thumbnails */ td.cache_thumbnails = opt.cache_thumbnails; if (td.cache_thumbnails) { if (opt.thumb_w > opt.thumb_h) td.cache_dim = opt.thumb_w; else td.cache_dim = opt.thumb_h; if (td.cache_dim > 256) { /* No caching as specified by standard. Sort of. */ td.cache_thumbnails = 0; } else if (td.cache_dim > 128) { td.cache_dim = 256; td.cache_dir = estrdup("large"); } else { td.cache_dim = 128; td.cache_dir = estrdup("normal"); } feh_thumbnail_setup_thumbnail_dir(); } for (l = filelist; l; l = l->next) { file = FEH_FILE(l->data); if (last) { filelist = feh_file_remove_from_list(filelist, last); last = NULL; } D(4, ("About to load image %s\n", file->filename)); /* if (feh_load_image(&im_temp, file) != 0) */ if (feh_thumbnail_get_thumbnail(&im_temp, file) != 0) { if (opt.verbose) feh_display_status('.'); D(4, ("Successfully loaded %s\n", file->filename)); www = opt.thumb_w; hhh = opt.thumb_h; ww = gib_imlib_image_get_width(im_temp); hh = gib_imlib_image_get_height(im_temp); thumbnailcount++; if (gib_imlib_image_has_alpha(im_temp)) imlib_context_set_blend(1); else imlib_context_set_blend(0); if (opt.aspect) { double ratio = 0.0; /* Keep the aspect ratio for the thumbnail */ ratio = ((double) ww / hh) / ((double) www / hhh); if (ratio > 1.0) hhh = opt.thumb_h / ratio; else if (ratio != 1.0) www = opt.thumb_w * ratio; } if ((!opt.stretch) && ((www > ww) || (hhh > hh))) { /* Don't make the image larger unless stretch is specified */ www = ww; hhh = hh; } im_thumb = gib_imlib_create_cropped_scaled_image(im_temp, 0, 0, ww, hh, www, hhh, 1); gib_imlib_free_image_and_decache(im_temp); if (opt.alpha) { DATA8 atab[256]; D(3, ("Applying alpha options\n")); gib_imlib_image_set_has_alpha(im_thumb, 1); memset(atab, opt.alpha_level, sizeof(atab)); gib_imlib_apply_color_modifier_to_rectangle (im_thumb, 0, 0, www, hhh, NULL, NULL, NULL, atab); } td.text_area_w = opt.thumb_w; /* Now draw on the info text */ if (opt.index_show_name) { gib_imlib_get_text_size(td.font_main, file->name, NULL, &fw_name, &fh, IMLIB_TEXT_TO_RIGHT); if (fw_name > td.text_area_w) td.text_area_w = fw_name; } if (opt.index_show_dim) { gib_imlib_get_text_size(td.font_main, create_index_dimension_string(ww, hh), NULL, &fw_dim, &fh, IMLIB_TEXT_TO_RIGHT); if (fw_dim > td.text_area_w) td.text_area_w = fw_dim; } if (opt.index_show_size) { gib_imlib_get_text_size(td.font_main, create_index_size_string(file->filename), NULL, &fw_size, &fh, IMLIB_TEXT_TO_RIGHT); if (fw_size > td.text_area_w) td.text_area_w = fw_size; } if (td.text_area_w > opt.thumb_w) td.text_area_w += 5; /* offsets for centering text */ x_offset_name = (td.text_area_w - fw_name) / 2; x_offset_dim = (td.text_area_w - fw_dim) / 2; x_offset_size = (td.text_area_w - fw_size) / 2; if (td.vertical) { if (td.text_area_w > td.max_column_w) td.max_column_w = td.text_area_w; if (y > td.h - td.thumb_tot_h) { y = 0; x += td.max_column_w; td.max_column_w = 0; } if (x > td.w - td.text_area_w) break; } else { if (x > td.w - td.text_area_w) { x = 0; y += td.thumb_tot_h; } if (y > td.h - td.thumb_tot_h) break; } /* center image relative to the text below it (if any) */ xxx = x + ((td.text_area_w - www) / 2); yyy = y; if (opt.aspect) yyy += (opt.thumb_h - hhh) / 2; /* Draw now */ gib_imlib_blend_image_onto_image(td.im_main, im_thumb, gib_imlib_image_has_alpha (im_thumb), 0, 0, www, hhh, xxx, yyy, www, hhh, 1, gib_imlib_image_has_alpha(im_thumb), 0); thumbnails = gib_list_add_front(thumbnails, feh_thumbnail_new(file, xxx, yyy, www, hhh)); gib_imlib_free_image_and_decache(im_thumb); lines = 0; if (opt.index_show_name) gib_imlib_text_draw(td.im_main, td.font_main, NULL, x + x_offset_name, y + opt.thumb_h + (lines++ * (th + 2)) + 2, file->name, IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255); if (opt.index_show_dim) gib_imlib_text_draw(td.im_main, td.font_main, NULL, x + x_offset_dim, y + opt.thumb_h + (lines++ * (th + 2)) + 2, create_index_dimension_string(ww, hh), IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255); if (opt.index_show_size) gib_imlib_text_draw(td.im_main, td.font_main, NULL, x + x_offset_size, y + opt.thumb_h + (lines++ * (th + 2)) + 2, create_index_size_string(file->filename), IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255); if (td.vertical) y += td.thumb_tot_h; else x += td.text_area_w; } else { if (opt.verbose) feh_display_status('x'); last = l; } if (opt.display) { /* thumb_counter is unsigned, so no need to catch overflows */ if (++thumb_counter == opt.thumb_redraw) { winwidget_render_image(winwid, 0, 0); thumb_counter = 0; } if (!feh_main_iteration(0)) exit(0); } } if (thumb_counter != 0) winwidget_render_image(winwid, 0, 0); if (opt.verbose) fprintf(stdout, "\n"); if (opt.title_font) { int fw, fh, fx, fy; char *s; s = create_index_title_string(thumbnailcount, td.w, td.h); gib_imlib_get_text_size(td.font_title, s, NULL, &fw, &fh, IMLIB_TEXT_TO_RIGHT); fx = (index_image_width - fw) >> 1; fy = index_image_height - fh - 2; gib_imlib_text_draw(td.im_main, td.font_title, NULL, fx, fy, s, IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255); }
void feh_draw_caption(winwidget w) { static Imlib_Font fn = NULL; int tw = 0, th = 0, ww, hh; int x, y; Imlib_Image im = NULL; char *p; gib_list *lines, *l; static gib_style *caption_style = NULL; feh_file *file; if (!w->file) { return; } file = FEH_FILE(w->file->data); if (!file->filename) { return; } if (!file->caption) { char *caption_filename; caption_filename = build_caption_filename(file, 0); if (caption_filename) /* read caption from file */ file->caption = ereadfile(caption_filename); else file->caption = estrdup(""); free(caption_filename); } if (file->caption == NULL) { /* caption file is not there, we want to cache that, otherwise we'll stat * the damn file every time we render the image. Reloading an image will * always cause the caption to be reread though so we're safe to do so. * (Before this bit was added, when zooming a captionless image with * captions enabled, the captions file would be stat()d like 30 times a * second) - don't forget this function is called from * winwidget_render_image(). */ file->caption = estrdup(""); } if (*(file->caption) == '\0' && !w->caption_entry) return; caption_style = gib_style_new("caption"); caption_style->bits = gib_list_add_front(caption_style->bits, gib_style_bit_new(0, 0, 0, 0, 0, 0)); caption_style->bits = gib_list_add_front(caption_style->bits, gib_style_bit_new(1, 1, 0, 0, 0, 255)); fn = feh_load_font(w); if (*(file->caption) == '\0') { p = estrdup("Caption entry mode - Hit ESC to cancel"); lines = feh_wrap_string(p, w->w, fn, NULL); free(p); } else lines = feh_wrap_string(file->caption, w->w, fn, NULL); if (!lines) return; /* Work out how high/wide the caption is */ l = lines; while (l) { p = (char *) l->data; gib_imlib_get_text_size(fn, p, caption_style, &ww, &hh, IMLIB_TEXT_TO_RIGHT); if (ww > tw) tw = ww; th += hh; if (l->next) th += 1; /* line spacing */ l = l->next; } /* we don't want the caption overlay larger than our window */ if (th > w->h) th = w->h; if (tw > w->w) tw = w->w; im = imlib_create_image(tw, th); if (!im) eprintf("Couldn't create image. Out of memory?"); feh_imlib_image_fill_text_bg(im, tw, th); l = lines; x = 0; y = 0; while (l) { p = (char *) l->data; gib_imlib_get_text_size(fn, p, caption_style, &ww, &hh, IMLIB_TEXT_TO_RIGHT); x = (tw - ww) / 2; if (w->caption_entry && (*(file->caption) == '\0')) gib_imlib_text_draw(im, fn, caption_style, x, y, p, IMLIB_TEXT_TO_RIGHT, 255, 255, 127, 255); else if (w->caption_entry) gib_imlib_text_draw(im, fn, caption_style, x, y, p, IMLIB_TEXT_TO_RIGHT, 255, 255, 0, 255); else gib_imlib_text_draw(im, fn, caption_style, x, y, p, IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255); y += hh + 1; /* line spacing */ l = l->next; } gib_imlib_render_image_on_drawable(w->bg_pmap, im, (w->w - tw) / 2, w->h - th, 1, 1, 0); gib_imlib_free_image_and_decache(im); gib_list_free_and_data(lines); return; }
void feh_draw_info(winwidget w) { static Imlib_Font fn = NULL; int width = 0, height = 0, line_width = 0, line_height = 0; Imlib_Image im = NULL; int no_lines = 0, i; char *info_cmd; char info_line[256]; char *info_buf[128]; FILE *info_pipe; if ((!w->file) || (!FEH_FILE(w->file->data)) || (!FEH_FILE(w->file->data)->filename)) return; fn = feh_load_font(w); info_cmd = feh_printf(opt.info_cmd, FEH_FILE(w->file->data), w); info_pipe = popen(info_cmd, "r"); if (!info_pipe) { info_buf[0] = estrdup("Failed to run info command"); gib_imlib_get_text_size(fn, info_buf[0], NULL, &width, &height, IMLIB_TEXT_TO_RIGHT); no_lines = 1; } else { while ((no_lines < 128) && fgets(info_line, 256, info_pipe)) { if (info_line[strlen(info_line)-1] == '\n') info_line[strlen(info_line)-1] = '\0'; gib_imlib_get_text_size(fn, info_line, NULL, &line_width, &line_height, IMLIB_TEXT_TO_RIGHT); if (line_height > height) height = line_height; if (line_width > width) width = line_width; info_buf[no_lines] = estrdup(info_line); no_lines++; } pclose(info_pipe); } if (no_lines == 0) return; height *= no_lines; width += 4; im = imlib_create_image(width, height); if (!im) eprintf("Couldn't create image. Out of memory?"); feh_imlib_image_fill_text_bg(im, width, height); for (i = 0; i < no_lines; i++) { gib_imlib_text_draw(im, fn, NULL, 2, (i * line_height) + 2, info_buf[i], IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255); gib_imlib_text_draw(im, fn, NULL, 1, (i * line_height) + 1, info_buf[i], IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255); free(info_buf[i]); } gib_imlib_render_image_on_drawable(w->bg_pmap, im, 0, w->h - height, 1, 1, 0); gib_imlib_free_image_and_decache(im); return; }
void feh_draw_exif(winwidget w) { static Imlib_Font fn = NULL; int width = 0, height = 0, line_width = 0, line_height = 0; Imlib_Image im = NULL; int no_lines = 0, i; int pos = 0; int pos2 = 0; char info_line[256]; char *info_buf[128]; char buffer[EXIF_MAX_DATA]; if ( (!w->file) || (!FEH_FILE(w->file->data)) || (!FEH_FILE(w->file->data)->filename) ) { return; } buffer[0] = '\0'; exif_get_info(FEH_FILE(w->file->data)->ed, buffer, EXIF_MAX_DATA); fn = feh_load_font(w); if (buffer == NULL) { snprintf(buffer, EXIF_MAX_DATA, "%s", estrdup("Failed to run exif command")); gib_imlib_get_text_size(fn, &buffer[0], NULL, &width, &height, IMLIB_TEXT_TO_RIGHT); no_lines = 1; } else { while ( (no_lines < 128) && (pos < EXIF_MAX_DATA) ) { /* max 128 lines */ pos2 = 0; while ( pos2 < 256 ) /* max 256 chars per line */ { if ( (buffer[pos] != '\n') && (buffer[pos] != '\0') ) { info_line[pos2] = buffer[pos]; } else if ( buffer[pos] == '\0' ) { pos = EXIF_MAX_DATA; /* all data seen */ info_line[pos2] = '\0'; } else { info_line[pos2] = '\0'; /* line finished, continue with next line*/ pos++; break; } pos++; pos2++; } gib_imlib_get_text_size(fn, info_line, NULL, &line_width, &line_height, IMLIB_TEXT_TO_RIGHT); if (line_height > height) height = line_height; if (line_width > width) width = line_width; info_buf[no_lines] = estrdup(info_line); no_lines++; } } if (no_lines == 0) return; height *= no_lines; width += 4; im = imlib_create_image(width, height); if (!im) { eprintf("Couldn't create image. Out of memory?"); } feh_imlib_image_fill_text_bg(im, width, height); for (i = 0; i < no_lines; i++) { gib_imlib_text_draw(im, fn, NULL, 2, (i * line_height) + 2, info_buf[i], IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255); gib_imlib_text_draw(im, fn, NULL, 1, (i * line_height) + 1, info_buf[i], IMLIB_TEXT_TO_RIGHT, 255, 255, 255, 255); } gib_imlib_render_image_on_drawable(w->bg_pmap, im, 0, w->h - height, 1, 1, 0); gib_imlib_free_image_and_decache(im); return; }
void feh_menu_draw_item(feh_menu_item * i, Imlib_Image im, int ox, int oy) { D(("drawing item %p (text %s)\n", i, i->text)); if (i->text) { D(("text item\n")); if (MENU_ITEM_IS_SELECTED(i)) { D(("selected item\n")); /* draw selected image */ feh_menu_item_draw_at(i->x, i->y, i->w, i->h, im, ox, oy, 1); } else { D(("unselected item\n")); /* draw unselected image */ feh_menu_item_draw_at(i->x, i->y, i->w, i->h, im, ox, oy, 0); } /* draw text */ gib_imlib_text_draw(im, opt.menu_fn, opt.menu_style_l, i->x - ox + i->text_x, i->y - oy + FEH_MENUITEM_PAD_TOP, i->text, IMLIB_TEXT_TO_RIGHT, 0, 0, 0, 255); if (i->icon) { Imlib_Image im2; D(("icon item\n")); im2 = i->icon; if (im2) { int iw, ih, ow, oh; iw = gib_imlib_image_get_width(im2); ih = gib_imlib_image_get_height(im2); if (ih <= (i->h - FEH_MENUITEM_PAD_TOP - FEH_MENUITEM_PAD_BOTTOM)) { ow = iw; oh = ih; } else { ow = (iw * (i->h - FEH_MENUITEM_PAD_TOP - FEH_MENUITEM_PAD_BOTTOM)) / ih; oh = i->h - FEH_MENUITEM_PAD_TOP - FEH_MENUITEM_PAD_BOTTOM; } gib_imlib_blend_image_onto_image(im, im2, 0, 0, 0, iw, ih, i->x + i->icon_x - ox, i->y + FEH_MENUITEM_PAD_TOP + (((i->h - FEH_MENUITEM_PAD_TOP - FEH_MENUITEM_PAD_BOTTOM) - oh) / 2) - oy, ow, oh, 1, 1, 1); gib_imlib_free_image(im2); } } if (i->submenu) { D(("submenu item\n")); feh_menu_draw_submenu_at(i->x + i->sub_x, i->y + FEH_MENUITEM_PAD_TOP + ((i->h - FEH_MENUITEM_PAD_TOP - FEH_MENUITEM_PAD_BOTTOM - FEH_MENU_SUBMENU_H) / 2), im, ox, oy); } if (i->is_toggle) { D(("toggleable item\n")); feh_menu_draw_toggle_at(i->x + i->toggle_x, i->y + FEH_MENUITEM_PAD_TOP + ((i->h - FEH_MENUITEM_PAD_TOP - FEH_MENUITEM_PAD_BOTTOM - FEH_MENU_TOGGLE_H) / 2), FEH_MENU_TOGGLE_W, FEH_MENU_TOGGLE_H, im, ox, oy, MENU_ITEM_IS_ON(i)); } } else { D(("separator item\n")); feh_menu_draw_separator_at(i->x, i->y, i->w, i->h, im, ox, oy); } return; }