X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FBasemenu.cc;h=90d5e458ebcdc8e21b56fd0e47ff1e0c9f2eb037;hb=5033ce0a24336668f4705a17063f27d842da461b;hp=fcd6931e6eba5dff03dbd4012468d59f131b2b3a;hpb=0a9da781402101b450b575c9ce0b20e651aa27a3;p=chaz%2Fopenbox diff --git a/src/Basemenu.cc b/src/Basemenu.cc index fcd6931e..90d5e458 100644 --- a/src/Basemenu.cc +++ b/src/Basemenu.cc @@ -151,7 +151,7 @@ Basemenu::~Basemenu(void) { MenuItems::const_iterator it = menuitems.begin(); while (it != menuitems.end()) { BasemenuItem *item = *it; - if ((! internal_menu)) { + if (! internal_menu) { Basemenu *tmp = (Basemenu *) item->submenu(); if (tmp) { if (! tmp->internal_menu) { @@ -224,7 +224,7 @@ int Basemenu::remove(int index) { BasemenuItem *item = find(index); if (! item) return -1; - if ((! internal_menu)) { + if (! internal_menu) { Basemenu *tmp = (Basemenu *) item->submenu(); if (tmp) { if (! tmp->internal_menu) { @@ -250,7 +250,8 @@ int Basemenu::remove(int index) { void Basemenu::update(void) { MenuStyle *style = screen->getMenuStyle(); - menu.item_h = style->f_font->height() + menu.bevel_w; + menu.item_h = (style->f_font->height() < 9 ? 9 : style->f_font->height()) + + menu.bevel_w; // 9 for the menu pixmaps (checkmarks) menu.title_h = style->t_font->height() + menu.bevel_w * 2; if (title_vis) { @@ -385,10 +386,10 @@ void Basemenu::show(void) { void Basemenu::hide(void) { - if ((! torn) && hide_tree && parent && parent->isVisible()) { + if (! torn && hide_tree && parent && parent->isVisible()) { Basemenu *p = parent; - while (p->isVisible() && (! p->torn) && p->parent) p = p->parent; + while (p->isVisible() && ! p->torn && p->parent) p = p->parent; p->internal_hide(); } else { internal_hide(); @@ -401,7 +402,7 @@ void Basemenu::internal_hide(void) { if (tmp) tmp->submenu()->internal_hide(); - if (parent && (! torn)) { + if (parent && ! torn) { parent->drawItem(parent->which_sub, False, True); parent->which_sub = -1; @@ -525,12 +526,12 @@ void Basemenu::drawItem(int index, bool highlight, bool clear, BasemenuItem *item = find(index); if (! item) return; - bool dotext = True, dohilite = True, dosel = True; + bool dotext = True, dohilite = True, dosel = True, dooppsel = True; const char *text = item->label(); int sbl = index / menu.persub, i = index - (sbl * menu.persub); int item_x = (sbl * menu.item_w), item_y = (i * menu.item_h); int hilite_x = item_x, hilite_y = item_y, hoff_x = 0, hoff_y = 0; - int text_x = 0, text_y = 0, sel_x = 0, sel_y = 0; + int text_x = 0, text_y = 0, sel_x = 0, oppsel_x = 0, sel_y = 0; unsigned int hilite_w = menu.item_w, hilite_h = menu.item_h, text_w = 0, text_h = 0; unsigned int half_w = menu.item_h / 2, quarter_w = menu.item_h / 4; @@ -557,14 +558,22 @@ void Basemenu::drawItem(int index, bool highlight, bool clear, } MenuStyle *style = screen->getMenuStyle(); - BPen pen((highlight || item->isSelected()) ? style->h_text : style->f_text), - hipen(style->hilite.color()); + BPen hipen(style->hilite.color()); + // match the text color + BPen pen((highlight ? style->h_text : + (item->isEnabled() ? style->f_text : + style->d_text))); sel_x = item_x; if (screen->getMenuStyle()->bullet_pos == Right) sel_x += (menu.item_w - menu.item_h - menu.bevel_w); sel_x += quarter_w; + oppsel_x = sel_x; + if (screen->getMenuStyle()->bullet_pos == Right) + oppsel_x -= (menu.item_w - menu.item_h - menu.bevel_w); + else + oppsel_x += (menu.item_w - menu.item_h - menu.bevel_w); sel_y = item_y + quarter_w; if (clear) { @@ -594,6 +603,12 @@ void Basemenu::drawItem(int index, bool highlight, bool clear, if (! (max(sel_x, x) <= min(sel_x + half_w, x + w) && max(sel_y, y) <= min(sel_y + half_w, y + h))) dosel = False; + + // check if we need to redraw the select pixmap/menu bullet + // on the opposite side of the menu + if (! (max(oppsel_x, x) <= min(oppsel_x + half_w, x + w) && + max(sel_y, y) <= min(sel_y + half_w, y + h))) + dooppsel = False; } if (dohilite && highlight && (menu.hilite_pixmap != ParentRelative)) { @@ -606,15 +621,10 @@ void Basemenu::drawItem(int index, bool highlight, bool clear, hilite_x, hilite_y, hilite_w, hilite_h); } - if (dosel && item->isSelected()) { - // match the text color - BPen pen((highlight ? style->h_text : - (item->isEnabled() ? style->f_text : - style->d_text))); - + if (dooppsel && item->isSelected()) { XPoint pts[6]; - pts[0].x = sel_x + 0; + pts[0].x = oppsel_x + 0; pts[0].y = sel_y + 2; pts[1].x = 0; @@ -808,7 +818,7 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) { if (me->window == menu.title && (me->state & Button1Mask)) { if (movable) { if (! moving) { - if (parent && (! torn)) { + if (parent && ! torn) { parent->drawItem(parent->which_sub, False, True); parent->which_sub = -1; } @@ -827,7 +837,7 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) { drawSubmenu(which_sub); } } - } else if ((! (me->state & Button1Mask)) && me->window == menu.frame && + } else if (! (me->state & Button1Mask) && me->window == menu.frame && me->x >= 0 && me->x < static_cast(menu.width) && me->y >= 0 && me->y < static_cast(menu.frame_h)) { int sbl = (me->x / menu.item_w), i = (me->y / menu.item_h), @@ -842,7 +852,7 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) { drawItem(p, False, True); if (item->submenu()) if (item->submenu()->isVisible() && - (! item->submenu()->isTorn())) { + ! item->submenu()->isTorn()) { item->submenu()->internal_hide(); which_sub = -1; } @@ -926,7 +936,7 @@ void Basemenu::enterNotifyEvent(XCrossingEvent *ce) { int sbl = (ce->x / menu.item_w), i = (ce->y / menu.item_h), w = (sbl * menu.persub) + i; - if (w != which_sub && (! tmp->submenu()->isTorn())) { + if (w != which_sub && ! tmp->submenu()->isTorn()) { tmp->submenu()->internal_hide(); drawItem(which_sub, False, True); @@ -972,6 +982,6 @@ void Basemenu::reconfigure(void) { void Basemenu::changeItemLabel(unsigned int index, const string& label) { BasemenuItem *item = find(index); - assert(item); - item->newLabel(label); + if (item) + item->newLabel(label); }