feh_menu_item *feh_menu_find_selected_r(feh_menu * m, feh_menu ** parent) { feh_menu_item *i, *ii; feh_menu *mm; D(("menu %p\n", m)); for (i = m->items; i; i = i->next) { if (MENU_ITEM_IS_SELECTED(i)) { if (parent) *parent = m; return(i); } else if (i->submenu) { mm = feh_menu_find(i->submenu); if (mm) { ii = feh_menu_find_selected_r(mm, parent); if (ii) return(ii); } } } if (parent) *parent = m; return(NULL); }
feh_menu_item *feh_menu_find_selected(feh_menu * m) { feh_menu_item *i; D(("menu %p\n", m)); for (i = m->items; i; i = i->next) { if (MENU_ITEM_IS_SELECTED(i)) return(i); } return(NULL); }
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; }
static void feh_event_handle_LeaveNotify(XEvent * ev) { if ((menu_root) && (ev->xcrossing.window == menu_root->win)) { feh_menu_item *ii; D(("It is for a menu\n")); for (ii = menu_root->items; ii; ii = ii->next) { if (MENU_ITEM_IS_SELECTED(ii)) { D(("Unselecting menu\n")); MENU_ITEM_SET_NORMAL(ii); menu_root->updates = imlib_update_append_rect(menu_root->updates, ii->x, ii->y, ii->w, ii->h); menu_root->needs_redraw = 1; } } feh_raise_all_menus(); } 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; }