summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2004-08-03 21:25:51 (GMT)
committerfluxgen <fluxgen>2004-08-03 21:25:51 (GMT)
commit7b4d57f275fb7fbc7521fd3efad57f6fd07bb248 (patch)
tree9c91f7ef3475446493dce579ccfe47c0f488c633 /src
parent582fe36cea0d20298d67222a720fe8be014a78bf (diff)
downloadfluxbox_lack-7b4d57f275fb7fbc7521fd3efad57f6fd07bb248.zip
fluxbox_lack-7b4d57f275fb7fbc7521fd3efad57f6fd07bb248.tar.bz2
fixed menu move bug and made separator not selectable, patch from Mathias Gumz
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/Menu.cc29
-rw-r--r--src/FbTk/Menu.hh3
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 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Menu.cc,v 1.71 2004/07/14 18:30:37 fluxgen Exp $ 25// $Id: Menu.cc,v 1.72 2004/08/03 21:25:51 fluxgen Exp $
26 26
27//use GNU extensions 27//use GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -36,6 +36,7 @@
36#endif //HAVE_CONFIG_H 36#endif //HAVE_CONFIG_H
37 37
38#include "MenuItem.hh" 38#include "MenuItem.hh"
39#include "MenuSeparator.hh"
39#include "ImageControl.hh" 40#include "ImageControl.hh"
40#include "MenuTheme.hh" 41#include "MenuTheme.hh"
41#include "App.hh" 42#include "App.hh"
@@ -51,6 +52,7 @@
51#include <cstdlib> 52#include <cstdlib>
52#include <cstring> 53#include <cstring>
53#include <iostream> 54#include <iostream>
55#include <typeinfo>
54 56
55using namespace std; 57using namespace std;
56 58
@@ -309,6 +311,11 @@ void Menu::nextItem() {
309 return; 311 return;
310 } 312 }
311 313
314 if (!isItemSelectable(which_press)) {
315 nextItem();
316 return;
317 }
318
312 m_active_index = which_press; 319 m_active_index = which_press;
313 320
314 drawItem(which_press, 321 drawItem(which_press,
@@ -344,6 +351,11 @@ void Menu::prevItem() {
344 return; 351 return;
345 } 352 }
346 353
354 if (!isItemSelectable(which_press)) {
355 prevItem();
356 return;
357 }
358
347 m_active_index = which_press; 359 m_active_index = which_press;
348 360
349 drawItem(which_press, 361 drawItem(which_press,
@@ -1038,6 +1050,18 @@ bool Menu::isItemEnabled(unsigned int index) const {
1038 return item->isEnabled(); 1050 return item->isEnabled();
1039} 1051}
1040 1052
1053bool Menu::isItemSelectable(unsigned int index) const {
1054
1055 if (index >= menuitems.size()) return false;
1056
1057 const MenuItem *item = find(index);
1058 if (!item)
1059 return false;
1060
1061 return (typeid(*item) != typeid(FbTk::MenuSeparator));
1062}
1063
1064
1041void Menu::handleEvent(XEvent &event) { 1065void Menu::handleEvent(XEvent &event) {
1042 if (event.type == FocusOut) { 1066 if (event.type == FocusOut) {
1043 if (s_focused == this) 1067 if (s_focused == this)
@@ -1189,6 +1213,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) {
1189 !item->submenu()->isTorn()) { 1213 !item->submenu()->isTorn()) {
1190 // setup hide timer for submenu 1214 // setup hide timer for submenu
1191 item->submenu()->startHide(); 1215 item->submenu()->startHide();
1216 which_sub = -1;
1192 } 1217 }
1193 } 1218 }
1194 1219
@@ -1231,7 +1256,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) {
1231 1256
1232 } 1257 }
1233 1258
1234 } else { 1259 } else if (isItemSelectable(w)){
1235 // else normal menu item 1260 // else normal menu item
1236 // draw highlighted 1261 // draw highlighted
1237 m_submenu_timer.stop(); 1262 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 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Menu.hh,v 1.37 2004/06/27 13:51:24 fluxgen Exp $ 25// $Id: Menu.hh,v 1.38 2004/08/03 21:25:51 fluxgen Exp $
26 26
27#ifndef FBTK_MENU_HH 27#ifndef FBTK_MENU_HH
28#define FBTK_MENU_HH 28#define FBTK_MENU_HH
@@ -151,6 +151,7 @@ public:
151 bool hasSubmenu(unsigned int index) const; 151 bool hasSubmenu(unsigned int index) const;
152 bool isItemSelected(unsigned int index) const; 152 bool isItemSelected(unsigned int index) const;
153 bool isItemEnabled(unsigned int index) const; 153 bool isItemEnabled(unsigned int index) const;
154 bool isItemSelectable(unsigned int index) const;
154 inline const MenuTheme &theme() const { return m_theme; } 155 inline const MenuTheme &theme() const { return m_theme; }
155 inline unsigned char alpha() const { return theme().alpha(); } 156 inline unsigned char alpha() const { return theme().alpha(); }
156 inline static Menu *focused() { return s_focused; } 157 inline static Menu *focused() { return s_focused; }