From 734b99611b0937a94407df0536fcdcd7cad45d13 Mon Sep 17 00:00:00 2001 From: rathnor Date: Sun, 20 Jul 2003 10:41:56 +0000 Subject: fix menu redrawing, particularly so that selecting an option will update properly upon selection, rather than subsequent movement --- BUGS | 7 ++++--- ChangeLog | 2 ++ src/FbTk/Menu.cc | 36 ++++++++++++++++++++---------------- src/FbTk/Menu.hh | 4 ++-- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/BUGS b/BUGS index 186a7c0..0ceb3ac 100644 --- a/BUGS +++ b/BUGS @@ -35,9 +35,6 @@ BUGS: turn off remember functionality when restarting (only use it for first instance). - * If you toggle a setting in the configuration-menu the notch does not - indicate the change until you point to another option. - Other TODO: FAQ items for: @@ -77,6 +74,10 @@ Fixed bugs (or not-our-fault bugs): => Fixed, added "ExtraMenus" for windows that get added whenever it is rebuilt. + * If you toggle a setting in the configuration-menu the notch does not + indicate the change until you point to another option. + => Fixed + ------------------------------ Core dumps and notes diff --git a/ChangeLog b/ChangeLog index f3218d6..50bebe3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ (Format: Year/Month/Day) Changes for 0.9.5: *03/07/20: + * Fix menu [re]drawing, particularly when selecting options (Simon) + Menu.hh/cc * Fix disappearing Remember menu, plus titles of sub-window menus -> can now use addExtraMenus for windows in extensions (Simon) Menu.hh/cc Window.hh/cc Screen.hh/cc Remember.cc diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 9dccb6f..ee7c231 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.cc,v 1.30 2003/07/20 08:12:36 rathnor Exp $ +// $Id: Menu.cc,v 1.31 2003/07/20 10:41:56 rathnor Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -384,7 +384,7 @@ void Menu::enableTitle() { setTitleVisibility(true); } -void Menu::update() { +void Menu::update(int active_index) { if (menu.bevel_w > 10) // clamp to "normal" size menu.bevel_w = 10; @@ -539,10 +539,10 @@ void Menu::update() { if (m_need_update) { for (unsigned int i = 0; visible && i < menuitems.size(); i++) { if (i == (unsigned int)which_sub) { - drawItem(i, true, false, false); + drawItem(i, true, true, false); drawSubmenu(i); } else - drawItem(i, false, false, false); + drawItem(i, (i == active_index), true, false); } if (m_parent && visible) @@ -978,7 +978,6 @@ void Menu::drawItem(unsigned int index, bool highlight, bool clear, bool render_ } - void Menu::setLabel(const char *labelstr) { //make sure we don't send 0 to std::string menu.label = (labelstr ? labelstr : ""); @@ -1095,16 +1094,16 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) { p = (which_sbl * menu.persub) + which_press; if (w < static_cast(menuitems.size()) && w >= 0) { - drawItem(p, (p == which_sub), true, true); - if (p == w && isItemEnabled(w)) { if (re.x > ix && re.x < (signed) (ix + menu.item_w) && re.y > iy && re.y < (signed) (iy + menu.item_h)) { menuitems[w]->click(re.button, re.time); itemSelected(re.button, w); - - update(); // update any changed item + m_need_update = true; + update(w); // update any changed item } + } else { + drawItem(p, isItemEnabled(p) && (p == which_sub), true, true); } } else drawItem(p, false, true, true); @@ -1147,12 +1146,15 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { int p = which_sbl * menu.persub + which_press; MenuItem *item = menuitems[p]; - drawItem(p, false, true, true); - if (item->submenu()) { - if (item->submenu()->isVisible() && - (! item->submenu()->isTorn())) { - item->submenu()->internal_hide(); - which_sub = -1; + // don't redraw disabled items on enter/leave + if (item->isEnabled()) { + drawItem(p, false, true, true); + if (item->submenu()) { + if (item->submenu()->isVisible() && + (! item->submenu()->isTorn())) { + item->submenu()->internal_hide(); + which_sub = -1; + } } } } @@ -1165,7 +1167,8 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { if (itmp->submenu()) drawSubmenu(w); else - drawItem(w, itmp->isEnabled(), true, true); + if (itmp->isEnabled()) + drawItem(w, true, true, true); } } } @@ -1305,6 +1308,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { if (which_press >= 0 && which_press < menuitems.size()) { menuitems[which_press]->click(1, event.time); itemSelected(1, which_press); + m_need_update = true; update(); } break; diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 2610ad9..9ab69b4 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.hh,v 1.20 2003/07/20 08:12:36 rathnor Exp $ +// $Id: Menu.hh,v 1.21 2003/07/20 10:41:56 rathnor Exp $ #ifndef FBTK_MENU_HH #define FBTK_MENU_HH @@ -115,7 +115,7 @@ public: void setLabel(const char *labelstr); /// move menu to x,y void move(int x, int y); - void update(); + void update(int active_index = -1); void setItemSelected(unsigned int index, bool val); void setItemEnabled(unsigned int index, bool val); inline void setMinimumSublevels(int m) { menu.minsub = m; } -- cgit v0.11.2