From 7b4d57f275fb7fbc7521fd3efad57f6fd07bb248 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Tue, 3 Aug 2004 21:25:51 +0000 Subject: fixed menu move bug and made separator not selectable, patch from Mathias Gumz --- src/FbTk/Menu.cc | 29 +++++++++++++++++++++++++++-- src/FbTk/Menu.hh | 3 ++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 7b18520..8c09c7f 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.71 2004/07/14 18:30:37 fluxgen Exp $ +// $Id: Menu.cc,v 1.72 2004/08/03 21:25:51 fluxgen Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -36,6 +36,7 @@ #endif //HAVE_CONFIG_H #include "MenuItem.hh" +#include "MenuSeparator.hh" #include "ImageControl.hh" #include "MenuTheme.hh" #include "App.hh" @@ -51,6 +52,7 @@ #include #include #include +#include using namespace std; @@ -309,6 +311,11 @@ void Menu::nextItem() { return; } + if (!isItemSelectable(which_press)) { + nextItem(); + return; + } + m_active_index = which_press; drawItem(which_press, @@ -344,6 +351,11 @@ void Menu::prevItem() { return; } + if (!isItemSelectable(which_press)) { + prevItem(); + return; + } + m_active_index = which_press; drawItem(which_press, @@ -1038,6 +1050,18 @@ bool Menu::isItemEnabled(unsigned int index) const { return item->isEnabled(); } +bool Menu::isItemSelectable(unsigned int index) const { + + if (index >= menuitems.size()) return false; + + const MenuItem *item = find(index); + if (!item) + return false; + + return (typeid(*item) != typeid(FbTk::MenuSeparator)); +} + + void Menu::handleEvent(XEvent &event) { if (event.type == FocusOut) { if (s_focused == this) @@ -1189,6 +1213,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { !item->submenu()->isTorn()) { // setup hide timer for submenu item->submenu()->startHide(); + which_sub = -1; } } @@ -1231,7 +1256,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { } - } else { + } else if (isItemSelectable(w)){ // else normal menu item // draw highlighted m_submenu_timer.stop(); diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 8c6c738..57894b8 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.37 2004/06/27 13:51:24 fluxgen Exp $ +// $Id: Menu.hh,v 1.38 2004/08/03 21:25:51 fluxgen Exp $ #ifndef FBTK_MENU_HH #define FBTK_MENU_HH @@ -151,6 +151,7 @@ public: bool hasSubmenu(unsigned int index) const; bool isItemSelected(unsigned int index) const; bool isItemEnabled(unsigned int index) const; + bool isItemSelectable(unsigned int index) const; inline const MenuTheme &theme() const { return m_theme; } inline unsigned char alpha() const { return theme().alpha(); } inline static Menu *focused() { return s_focused; } -- cgit v0.11.2