From 13a73a78f604c2735089f98e2e89d097c2f324bc Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Mon, 1 Sep 2008 11:00:04 -0400 Subject: highlight the nearest menu item when the current one is disabled, and add separators to focus model menu --- ChangeLog | 4 ++++ src/FbTk/Menu.cc | 15 +++++++++++++++ src/Screen.cc | 3 +++ 3 files changed, 22 insertions(+) diff --git a/ChangeLog b/ChangeLog index 782b8f9..63aaf07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ (Format: Year/Month/Day) Changes for 1.1 +*08/09/01: + * When the current menu item gets disabled, highlight its nearest neighbor + and add separators to the focus model menu (Mark) + Screen.cc FbTk/Menu.cc *08/08/22: * Remove borders from maximized windows (Mark) FbWinFrame.cc diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index ce751d9..f4e8f3d 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -374,6 +374,21 @@ void Menu::updateMenu(int active_index) { } else menu.item_w = 1; + if (validIndex(m_active_index) && !menuitems[m_active_index]->isEnabled()) { + // find the nearest enabled menuitem and highlight it + for (size_t i = 1; i < menuitems.size(); i++) { + if (validIndex(m_active_index + i) && + menuitems[m_active_index + i]->isEnabled()) { + m_active_index += i; + break; + } else if (validIndex(m_active_index - i) && + menuitems[m_active_index - i]->isEnabled()) { + m_active_index -= i; + break; + } + } + } + unsigned int ii = 0; Menuitems::iterator it = menuitems.begin(); Menuitems::iterator it_end = menuitems.end(); diff --git a/src/Screen.cc b/src/Screen.cc index 4340ef1..23f85a5 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -37,6 +37,7 @@ // menu items #include "FbTk/BoolMenuItem.hh" #include "FbTk/IntMenuItem.hh" +#include "FbTk/MenuSeparator.hh" #include "FocusModelMenuItem.hh" #include "RadioMenuItem.hh" @@ -1619,12 +1620,14 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { FocusControl::MOUSEFOCUS); #undef _FOCUSITEM + focus_menu->insert(new FbTk::MenuSeparator()); focus_menu->insert(new TabFocusModelMenuItem(_FB_XTEXT(Configmenu, ClickTabFocus, "ClickTabFocus", "Click tab to focus windows"), focusControl(), FocusControl::CLICKTABFOCUS, save_and_reconfigure)); focus_menu->insert(new TabFocusModelMenuItem(_FB_XTEXT(Configmenu, MouseTabFocus, "MouseTabFocus", "Hover over tab to focus windows"), focusControl(), FocusControl::MOUSETABFOCUS, save_and_reconfigure)); + focus_menu->insert(new FbTk::MenuSeparator()); try { focus_menu->insert(new FbTk::BoolMenuItem(_FB_XTEXT(Configmenu, FocusNew, -- cgit v0.11.2