diff options
author | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
commit | ce28e056c20bf2723f565bbf464b87781ec248a2 (patch) | |
tree | ef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/llui/llmenugl.cpp | |
parent | Second Life viewer sources 1.19.1.4b (diff) | |
download | meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2 meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz |
Second Life viewer sources 1.20.2
Diffstat (limited to 'linden/indra/llui/llmenugl.cpp')
-rw-r--r-- | linden/indra/llui/llmenugl.cpp | 279 |
1 files changed, 88 insertions, 191 deletions
diff --git a/linden/indra/llui/llmenugl.cpp b/linden/indra/llui/llmenugl.cpp index cb54476..f2486f1 100644 --- a/linden/indra/llui/llmenugl.cpp +++ b/linden/indra/llui/llmenugl.cpp | |||
@@ -188,31 +188,6 @@ LLXMLNodePtr LLMenuItemGL::getXML(bool save_children) const | |||
188 | return node; | 188 | return node; |
189 | } | 189 | } |
190 | 190 | ||
191 | BOOL LLMenuItemGL::handleKey(KEY key, MASK mask, BOOL called_from_parent) | ||
192 | { | ||
193 | // modified from LLView::handleKey | ||
194 | // ignore visibility, as keyboard accelerators should still trigger menu items | ||
195 | // even when they are not visible | ||
196 | // also, ignore enabled flag for self, as that can change based on menu callbacks | ||
197 | BOOL handled = FALSE; | ||
198 | |||
199 | if( called_from_parent ) | ||
200 | { | ||
201 | // Downward traversal | ||
202 | if (getEnabled()) | ||
203 | { | ||
204 | handled = childrenHandleKey( key, mask ) != NULL; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | if( !handled ) | ||
209 | { | ||
210 | handled = handleKeyHere( key, mask, called_from_parent ); | ||
211 | } | ||
212 | |||
213 | return handled; | ||
214 | } | ||
215 | |||
216 | BOOL LLMenuItemGL::handleAcceleratorKey(KEY key, MASK mask) | 191 | BOOL LLMenuItemGL::handleAcceleratorKey(KEY key, MASK mask) |
217 | { | 192 | { |
218 | if( getEnabled() && (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == (mAcceleratorMask & MASK_NORMALKEYS)) ) | 193 | if( getEnabled() && (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == (mAcceleratorMask & MASK_NORMALKEYS)) ) |
@@ -400,7 +375,7 @@ void LLMenuItemGL::doIt( void ) | |||
400 | } | 375 | } |
401 | 376 | ||
402 | 377 | ||
403 | BOOL LLMenuItemGL::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ) | 378 | BOOL LLMenuItemGL::handleKeyHere( KEY key, MASK mask ) |
404 | { | 379 | { |
405 | if (getHighlight() && | 380 | if (getHighlight() && |
406 | getMenu()->isOpen()) | 381 | getMenu()->isOpen()) |
@@ -436,29 +411,21 @@ BOOL LLMenuItemGL::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ) | |||
436 | 411 | ||
437 | BOOL LLMenuItemGL::handleMouseUp( S32 x, S32 y, MASK ) | 412 | BOOL LLMenuItemGL::handleMouseUp( S32 x, S32 y, MASK ) |
438 | { | 413 | { |
439 | if (getEnabled()) | 414 | // switch to mouse navigation mode |
440 | { | 415 | LLMenuGL::setKeyboardMode(FALSE); |
441 | // switch to mouse navigation mode | ||
442 | LLMenuGL::setKeyboardMode(FALSE); | ||
443 | 416 | ||
444 | doIt(); | 417 | doIt(); |
445 | make_ui_sound("UISndClickRelease"); | 418 | make_ui_sound("UISndClickRelease"); |
446 | return TRUE; | 419 | return TRUE; |
447 | } | ||
448 | return FALSE; | ||
449 | } | 420 | } |
450 | 421 | ||
451 | BOOL LLMenuItemGL::handleMouseDown( S32 x, S32 y, MASK ) | 422 | BOOL LLMenuItemGL::handleMouseDown( S32 x, S32 y, MASK ) |
452 | { | 423 | { |
453 | if (getEnabled()) | 424 | // switch to mouse navigation mode |
454 | { | 425 | LLMenuGL::setKeyboardMode(FALSE); |
455 | // switch to mouse navigation mode | ||
456 | LLMenuGL::setKeyboardMode(FALSE); | ||
457 | 426 | ||
458 | setHighlight(TRUE); | 427 | setHighlight(TRUE); |
459 | return TRUE; | 428 | return TRUE; |
460 | } | ||
461 | return FALSE; | ||
462 | } | 429 | } |
463 | 430 | ||
464 | 431 | ||
@@ -560,9 +527,6 @@ public: | |||
560 | 527 | ||
561 | virtual LLString getType() const { return "separator"; } | 528 | virtual LLString getType() const { return "separator"; } |
562 | 529 | ||
563 | virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM_SEPARATOR; } | ||
564 | virtual LLString getWidgetTag() const { return LL_MENU_ITEM_SEPARATOR_GL_TAG; } | ||
565 | |||
566 | // doIt() - do the primary funcationality of the menu item. | 530 | // doIt() - do the primary funcationality of the menu item. |
567 | virtual void doIt( void ) {} | 531 | virtual void doIt( void ) {} |
568 | 532 | ||
@@ -641,9 +605,6 @@ class LLMenuItemVerticalSeparatorGL | |||
641 | public: | 605 | public: |
642 | LLMenuItemVerticalSeparatorGL( void ); | 606 | LLMenuItemVerticalSeparatorGL( void ); |
643 | 607 | ||
644 | virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_SEPARATOR_VERTICAL; } | ||
645 | virtual LLString getWidgetTag() const { return LL_MENU_ITEM_VERTICAL_SEPARATOR_GL_TAG; } | ||
646 | |||
647 | virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask) { return FALSE; } | 608 | virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask) { return FALSE; } |
648 | }; | 609 | }; |
649 | 610 | ||
@@ -739,8 +700,6 @@ public: | |||
739 | { | 700 | { |
740 | setEnabled(FALSE); | 701 | setEnabled(FALSE); |
741 | } | 702 | } |
742 | virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM_BLANK; } | ||
743 | virtual LLString getWidgetTag() const { return LL_MENU_ITEM_BLANK_GL_TAG; } | ||
744 | virtual void doIt( void ) {} | 703 | virtual void doIt( void ) {} |
745 | virtual void draw( void ) {} | 704 | virtual void draw( void ) {} |
746 | }; | 705 | }; |
@@ -827,57 +786,33 @@ void LLMenuItemCallGL::setEnabledControl(LLString enabled_control, LLView *conte | |||
827 | // Register new listener | 786 | // Register new listener |
828 | if (!enabled_control.empty()) | 787 | if (!enabled_control.empty()) |
829 | { | 788 | { |
830 | LLControlBase *control = context->findControl(enabled_control); | 789 | LLControlVariable *control = context->findControl(enabled_control); |
831 | if (control) | 790 | if (!control) |
832 | { | ||
833 | LLSD state = control->registerListener(this, "ENABLED"); | ||
834 | setEnabled(state); | ||
835 | } | ||
836 | else | ||
837 | { | 791 | { |
838 | context->addBoolControl(enabled_control, getEnabled()); | 792 | context->addBoolControl(enabled_control, getEnabled()); |
839 | control = context->findControl(enabled_control); | 793 | control = context->findControl(enabled_control); |
840 | control->registerListener(this, "ENABLED"); | 794 | llassert_always(control); |
841 | } | 795 | } |
796 | control->getSignal()->connect(boost::bind(&LLView::controlListener, _1, getHandle(), std::string("enabled"))); | ||
797 | setEnabled(control->getValue()); | ||
842 | } | 798 | } |
843 | } | 799 | } |
844 | 800 | ||
845 | void LLMenuItemCallGL::setVisibleControl(LLString enabled_control, LLView *context) | 801 | void LLMenuItemCallGL::setVisibleControl(LLString visible_control, LLView *context) |
846 | { | 802 | { |
847 | // Register new listener | 803 | // Register new listener |
848 | if (!enabled_control.empty()) | 804 | if (!visible_control.empty()) |
849 | { | 805 | { |
850 | LLControlBase *control = context->findControl(enabled_control); | 806 | LLControlVariable *control = context->findControl(visible_control); |
851 | if (control) | 807 | if (!control) |
852 | { | 808 | { |
853 | LLSD state = control->registerListener(this, "VISIBLE"); | 809 | context->addBoolControl(visible_control, getVisible()); |
854 | setVisible(state); | 810 | control = context->findControl(visible_control); |
811 | llassert_always(control); | ||
855 | } | 812 | } |
856 | else | 813 | control->getSignal()->connect(boost::bind(&LLView::controlListener, _1, getHandle(), std::string("visible"))); |
857 | { | 814 | setVisible(control->getValue()); |
858 | context->addBoolControl(enabled_control, getEnabled()); | ||
859 | control = context->findControl(enabled_control); | ||
860 | control->registerListener(this, "VISIBLE"); | ||
861 | } | ||
862 | } | ||
863 | } | ||
864 | |||
865 | // virtual | ||
866 | bool LLMenuItemCallGL::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
867 | { | ||
868 | if (userdata.asString() == "ENABLED" && event->desc() == "value_changed") | ||
869 | { | ||
870 | LLSD state = event->getValue(); | ||
871 | setEnabled(state); | ||
872 | return TRUE; | ||
873 | } | 815 | } |
874 | if (userdata.asString() == "VISIBLE" && event->desc() == "value_changed") | ||
875 | { | ||
876 | LLSD state = event->getValue(); | ||
877 | setVisible(state); | ||
878 | return TRUE; | ||
879 | } | ||
880 | return LLMenuItemGL::handleEvent(event, userdata); | ||
881 | } | 816 | } |
882 | 817 | ||
883 | // virtual | 818 | // virtual |
@@ -1000,44 +935,35 @@ LLMenuItemCheckGL::LLMenuItemCheckGL ( const LLString& name, | |||
1000 | setControlName(control_name, context); | 935 | setControlName(control_name, context); |
1001 | } | 936 | } |
1002 | 937 | ||
1003 | void LLMenuItemCheckGL::setCheckedControl(LLString checked_control, LLView *context) | 938 | //virtual |
939 | void LLMenuItemCheckGL::setValue(const LLSD& value) | ||
1004 | { | 940 | { |
1005 | // Register new listener | 941 | mChecked = value.asBoolean(); |
1006 | if (!checked_control.empty()) | 942 | if(mChecked) |
1007 | { | 943 | { |
1008 | LLControlBase *control = context->findControl(checked_control); | 944 | mDrawBoolLabel = BOOLEAN_TRUE_PREFIX; |
1009 | if (control) | 945 | } |
1010 | { | 946 | else |
1011 | LLSD state = control->registerListener(this, "CHECKED"); | 947 | { |
1012 | mChecked = state; | 948 | mDrawBoolLabel.clear(); |
1013 | } | ||
1014 | else | ||
1015 | { | ||
1016 | context->addBoolControl(checked_control, mChecked); | ||
1017 | control = context->findControl(checked_control); | ||
1018 | control->registerListener(this, "CHECKED"); | ||
1019 | } | ||
1020 | } | 949 | } |
1021 | } | 950 | } |
1022 | 951 | ||
1023 | // virtual | 952 | void LLMenuItemCheckGL::setCheckedControl(LLString checked_control, LLView *context) |
1024 | bool LLMenuItemCheckGL::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
1025 | { | 953 | { |
1026 | if (userdata.asString() == "CHECKED" && event->desc() == "value_changed") | 954 | // Register new listener |
955 | if (!checked_control.empty()) | ||
1027 | { | 956 | { |
1028 | LLSD state = event->getValue(); | 957 | LLControlVariable *control = context->findControl(checked_control); |
1029 | mChecked = state; | 958 | if (!control) |
1030 | if(mChecked) | ||
1031 | { | ||
1032 | mDrawBoolLabel = BOOLEAN_TRUE_PREFIX; | ||
1033 | } | ||
1034 | else | ||
1035 | { | 959 | { |
1036 | mDrawBoolLabel.clear(); | 960 | context->addBoolControl(checked_control, mChecked); |
961 | control = context->findControl(checked_control); | ||
962 | llassert_always(control); | ||
1037 | } | 963 | } |
1038 | return TRUE; | 964 | control->getSignal()->connect(boost::bind(&LLView::controlListener, _1, getHandle(), std::string("value"))); |
965 | mChecked = control->getValue(); | ||
1039 | } | 966 | } |
1040 | return LLMenuItemCallGL::handleEvent(event, userdata); | ||
1041 | } | 967 | } |
1042 | 968 | ||
1043 | // virtual | 969 | // virtual |
@@ -1119,29 +1045,31 @@ LLMenuItemBranchGL::LLMenuItemBranchGL( const LLString& name, const LLString& la | |||
1119 | } | 1045 | } |
1120 | 1046 | ||
1121 | // virtual | 1047 | // virtual |
1122 | LLView* LLMenuItemBranchGL::getChildByName(const LLString& name, BOOL recurse) const | 1048 | LLView* LLMenuItemBranchGL::getChildView(const LLString& name, BOOL recurse, BOOL create_if_missing) const |
1123 | { | 1049 | { |
1050 | // richard: this is redundant with parent, remove | ||
1124 | if (mBranch->getName() == name) | 1051 | if (mBranch->getName() == name) |
1125 | { | 1052 | { |
1126 | return mBranch; | 1053 | return mBranch; |
1127 | } | 1054 | } |
1128 | // Always recurse on branches | 1055 | // Always recurse on branches |
1129 | return mBranch->getChild<LLView>(name, recurse); | 1056 | LLView* child = mBranch->getChildView(name, recurse, FALSE); |
1057 | if (!child) | ||
1058 | { | ||
1059 | child = LLView::getChildView(name, recurse, create_if_missing); | ||
1060 | } | ||
1061 | return child; | ||
1130 | } | 1062 | } |
1131 | 1063 | ||
1132 | // virtual | 1064 | // virtual |
1133 | BOOL LLMenuItemBranchGL::handleMouseUp(S32 x, S32 y, MASK mask) | 1065 | BOOL LLMenuItemBranchGL::handleMouseUp(S32 x, S32 y, MASK mask) |
1134 | { | 1066 | { |
1135 | if (getEnabled()) | 1067 | // switch to mouse navigation mode |
1136 | { | 1068 | LLMenuGL::setKeyboardMode(FALSE); |
1137 | // switch to mouse navigation mode | ||
1138 | LLMenuGL::setKeyboardMode(FALSE); | ||
1139 | 1069 | ||
1140 | doIt(); | 1070 | doIt(); |
1141 | make_ui_sound("UISndClickRelease"); | 1071 | make_ui_sound("UISndClickRelease"); |
1142 | return TRUE; | 1072 | return TRUE; |
1143 | } | ||
1144 | return FALSE; | ||
1145 | } | 1073 | } |
1146 | 1074 | ||
1147 | BOOL LLMenuItemBranchGL::handleAcceleratorKey(KEY key, MASK mask) | 1075 | BOOL LLMenuItemBranchGL::handleAcceleratorKey(KEY key, MASK mask) |
@@ -1299,7 +1227,7 @@ void LLMenuItemBranchGL::onVisibilityChange( BOOL new_visibility ) | |||
1299 | LLMenuItemGL::onVisibilityChange(new_visibility); | 1227 | LLMenuItemGL::onVisibilityChange(new_visibility); |
1300 | } | 1228 | } |
1301 | 1229 | ||
1302 | BOOL LLMenuItemBranchGL::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ) | 1230 | BOOL LLMenuItemBranchGL::handleKeyHere( KEY key, MASK mask ) |
1303 | { | 1231 | { |
1304 | if (getMenu()->getVisible() && mBranch->getVisible() && key == KEY_LEFT) | 1232 | if (getMenu()->getVisible() && mBranch->getVisible() && key == KEY_LEFT) |
1305 | { | 1233 | { |
@@ -1318,8 +1246,7 @@ BOOL LLMenuItemBranchGL::handleKeyHere( KEY key, MASK mask, BOOL called_from_par | |||
1318 | return handled; | 1246 | return handled; |
1319 | } | 1247 | } |
1320 | 1248 | ||
1321 | if (getEnabled() && | 1249 | if (getHighlight() && |
1322 | getHighlight() && | ||
1323 | getMenu()->isOpen() && | 1250 | getMenu()->isOpen() && |
1324 | key == KEY_RIGHT && !mBranch->getHighlightedItem()) | 1251 | key == KEY_RIGHT && !mBranch->getHighlightedItem()) |
1325 | { | 1252 | { |
@@ -1333,7 +1260,7 @@ BOOL LLMenuItemBranchGL::handleKeyHere( KEY key, MASK mask, BOOL called_from_par | |||
1333 | } | 1260 | } |
1334 | } | 1261 | } |
1335 | 1262 | ||
1336 | return LLMenuItemGL::handleKeyHere(key, mask, called_from_parent); | 1263 | return LLMenuItemGL::handleKeyHere(key, mask); |
1337 | } | 1264 | } |
1338 | 1265 | ||
1339 | void LLMenuItemBranchGL::openMenu() | 1266 | void LLMenuItemBranchGL::openMenu() |
@@ -1403,9 +1330,6 @@ public: | |||
1403 | LLMenuItemBranchDownGL( const LLString& name, const LLString& label, LLMenuGL* branch, | 1330 | LLMenuItemBranchDownGL( const LLString& name, const LLString& label, LLMenuGL* branch, |
1404 | KEY key = KEY_NONE, MASK mask = MASK_NONE ); | 1331 | KEY key = KEY_NONE, MASK mask = MASK_NONE ); |
1405 | 1332 | ||
1406 | virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM_BRANCH_DOWN; } | ||
1407 | virtual LLString getWidgetTag() const { return LL_MENU_ITEM_BRANCH_DOWN_GL_TAG; } | ||
1408 | |||
1409 | virtual LLString getType() const { return "menu"; } | 1333 | virtual LLString getType() const { return "menu"; } |
1410 | 1334 | ||
1411 | // returns the normal width of this control in pixels - this is | 1335 | // returns the normal width of this control in pixels - this is |
@@ -1429,7 +1353,7 @@ public: | |||
1429 | virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask ); | 1353 | virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask ); |
1430 | virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask ); | 1354 | virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask ); |
1431 | virtual void draw( void ); | 1355 | virtual void draw( void ); |
1432 | virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); | 1356 | virtual BOOL handleKeyHere(KEY key, MASK mask); |
1433 | 1357 | ||
1434 | virtual BOOL handleAcceleratorKey(KEY key, MASK mask); | 1358 | virtual BOOL handleAcceleratorKey(KEY key, MASK mask); |
1435 | }; | 1359 | }; |
@@ -1566,7 +1490,7 @@ BOOL LLMenuItemBranchDownGL::handleAcceleratorKey(KEY key, MASK mask) | |||
1566 | return handled; | 1490 | return handled; |
1567 | } | 1491 | } |
1568 | 1492 | ||
1569 | BOOL LLMenuItemBranchDownGL::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent) | 1493 | BOOL LLMenuItemBranchDownGL::handleKeyHere(KEY key, MASK mask) |
1570 | { | 1494 | { |
1571 | BOOL menu_open = getBranch()->getVisible(); | 1495 | BOOL menu_open = getBranch()->getVisible(); |
1572 | // don't do keyboard navigation of top-level menus unless in keyboard mode, or menu expanded | 1496 | // don't do keyboard navigation of top-level menus unless in keyboard mode, or menu expanded |
@@ -1605,7 +1529,7 @@ BOOL LLMenuItemBranchDownGL::handleKeyHere(KEY key, MASK mask, BOOL called_from_ | |||
1605 | // switch to keyboard navigation mode | 1529 | // switch to keyboard navigation mode |
1606 | LLMenuGL::setKeyboardMode(TRUE); | 1530 | LLMenuGL::setKeyboardMode(TRUE); |
1607 | 1531 | ||
1608 | if (getEnabled() && !isActive()) | 1532 | if (!isActive()) |
1609 | { | 1533 | { |
1610 | doIt(); | 1534 | doIt(); |
1611 | } | 1535 | } |
@@ -1617,7 +1541,7 @@ BOOL LLMenuItemBranchDownGL::handleKeyHere(KEY key, MASK mask, BOOL called_from_ | |||
1617 | // switch to keyboard navigation mode | 1541 | // switch to keyboard navigation mode |
1618 | LLMenuGL::setKeyboardMode(TRUE); | 1542 | LLMenuGL::setKeyboardMode(TRUE); |
1619 | 1543 | ||
1620 | if (getEnabled() && !isActive()) | 1544 | if (!isActive()) |
1621 | { | 1545 | { |
1622 | doIt(); | 1546 | doIt(); |
1623 | } | 1547 | } |
@@ -1690,6 +1614,8 @@ void LLMenuItemBranchDownGL::draw( void ) | |||
1690 | /// Class LLMenuGL | 1614 | /// Class LLMenuGL |
1691 | ///============================================================================ | 1615 | ///============================================================================ |
1692 | 1616 | ||
1617 | static LLRegisterWidget<LLMenuGL> r1("menu"); | ||
1618 | |||
1693 | // Default constructor | 1619 | // Default constructor |
1694 | LLMenuGL::LLMenuGL( const LLString& name, const LLString& label, LLHandle<LLFloater> parent_floater_handle ) | 1620 | LLMenuGL::LLMenuGL( const LLString& name, const LLString& label, LLHandle<LLFloater> parent_floater_handle ) |
1695 | : LLUICtrl( name, LLRect(), FALSE, NULL, NULL ), | 1621 | : LLUICtrl( name, LLRect(), FALSE, NULL, NULL ), |
@@ -1946,7 +1872,7 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory | |||
1946 | { | 1872 | { |
1947 | continue; | 1873 | continue; |
1948 | } | 1874 | } |
1949 | LLControlBase *control = parent->findControl(control_name); | 1875 | LLControlVariable *control = parent->findControl(control_name); |
1950 | if (!control) | 1876 | if (!control) |
1951 | { | 1877 | { |
1952 | parent->addBoolControl(control_name, FALSE); | 1878 | parent->addBoolControl(control_name, FALSE); |
@@ -2685,8 +2611,8 @@ LLMenuItemGL* LLMenuGL::highlightNextItem(LLMenuItemGL* cur_item, BOOL skip_disa | |||
2685 | 2611 | ||
2686 | while(1) | 2612 | while(1) |
2687 | { | 2613 | { |
2688 | // skip separators and disabled items | 2614 | // skip separators and disabled/invisible items |
2689 | if ((*next_item_iter)->getEnabled() && (*next_item_iter)->getType() != SEPARATOR_NAME) | 2615 | if ((*next_item_iter)->getEnabled() && (*next_item_iter)->getVisible() && (*next_item_iter)->getType() != SEPARATOR_NAME) |
2690 | { | 2616 | { |
2691 | if (cur_item) | 2617 | if (cur_item) |
2692 | { | 2618 | { |
@@ -2751,8 +2677,8 @@ LLMenuItemGL* LLMenuGL::highlightPrevItem(LLMenuItemGL* cur_item, BOOL skip_disa | |||
2751 | 2677 | ||
2752 | while(1) | 2678 | while(1) |
2753 | { | 2679 | { |
2754 | // skip separators and disabled items | 2680 | // skip separators and disabled/invisible items |
2755 | if ((*prev_item_iter)->getEnabled() && (*prev_item_iter)->getName() != SEPARATOR_NAME) | 2681 | if ((*prev_item_iter)->getEnabled() && (*prev_item_iter)->getVisible() && (*prev_item_iter)->getName() != SEPARATOR_NAME) |
2756 | { | 2682 | { |
2757 | (*prev_item_iter)->setHighlight(TRUE); | 2683 | (*prev_item_iter)->setHighlight(TRUE); |
2758 | return (*prev_item_iter); | 2684 | return (*prev_item_iter); |
@@ -2801,37 +2727,6 @@ void LLMenuGL::updateParent(LLView* parentp) | |||
2801 | } | 2727 | } |
2802 | } | 2728 | } |
2803 | 2729 | ||
2804 | // LLView functionality | ||
2805 | BOOL LLMenuGL::handleKey( KEY key, MASK mask, BOOL called_from_parent ) | ||
2806 | { | ||
2807 | BOOL handled = FALSE; | ||
2808 | |||
2809 | // Pass down even if not visible | ||
2810 | if( getEnabled() && called_from_parent ) | ||
2811 | { | ||
2812 | for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) | ||
2813 | { | ||
2814 | LLView* viewp = *child_it; | ||
2815 | if (viewp->handleKey(key, mask, TRUE)) | ||
2816 | { | ||
2817 | handled = TRUE; | ||
2818 | break; | ||
2819 | } | ||
2820 | } | ||
2821 | } | ||
2822 | |||
2823 | if( !handled ) | ||
2824 | { | ||
2825 | handled = handleKeyHere( key, mask, called_from_parent ); | ||
2826 | if (handled && LLView::sDebugKeys) | ||
2827 | { | ||
2828 | llinfos << "Key handled by " << getName() << llendl; | ||
2829 | } | ||
2830 | } | ||
2831 | |||
2832 | return handled; | ||
2833 | } | ||
2834 | |||
2835 | BOOL LLMenuGL::handleAcceleratorKey(KEY key, MASK mask) | 2730 | BOOL LLMenuGL::handleAcceleratorKey(KEY key, MASK mask) |
2836 | { | 2731 | { |
2837 | // don't handle if not enabled | 2732 | // don't handle if not enabled |
@@ -2854,7 +2749,7 @@ BOOL LLMenuGL::handleAcceleratorKey(KEY key, MASK mask) | |||
2854 | return FALSE; | 2749 | return FALSE; |
2855 | } | 2750 | } |
2856 | 2751 | ||
2857 | BOOL LLMenuGL::handleUnicodeCharHere( llwchar uni_char, BOOL called_from_parent ) | 2752 | BOOL LLMenuGL::handleUnicodeCharHere( llwchar uni_char ) |
2858 | { | 2753 | { |
2859 | if (jumpKeysActive()) | 2754 | if (jumpKeysActive()) |
2860 | { | 2755 | { |
@@ -2980,17 +2875,19 @@ void LLMenuGL::setVisible(BOOL visible) | |||
2980 | 2875 | ||
2981 | LLMenuGL* LLMenuGL::getChildMenuByName(const LLString& name, BOOL recurse) const | 2876 | LLMenuGL* LLMenuGL::getChildMenuByName(const LLString& name, BOOL recurse) const |
2982 | { | 2877 | { |
2983 | LLView* view = getChildByName(name, recurse); | 2878 | LLView* view = getChildView(name, recurse, FALSE); |
2984 | if (view) | 2879 | if (view) |
2985 | { | 2880 | { |
2986 | if (view->getWidgetType() == WIDGET_TYPE_MENU_ITEM_BRANCH) | 2881 | LLMenuItemBranchGL* branch = dynamic_cast<LLMenuItemBranchGL*>(view); |
2882 | if (branch) | ||
2987 | { | 2883 | { |
2988 | LLMenuItemBranchGL *branch = (LLMenuItemBranchGL *)view; | ||
2989 | return branch->getBranch(); | 2884 | return branch->getBranch(); |
2990 | } | 2885 | } |
2991 | if (view->getWidgetType() == WIDGET_TYPE_MENU || view->getWidgetType() == WIDGET_TYPE_PIE_MENU) | 2886 | |
2887 | LLMenuGL* menup = dynamic_cast<LLMenuGL*>(view); | ||
2888 | if (menup) | ||
2992 | { | 2889 | { |
2993 | return (LLMenuGL*)view; | 2890 | return menup; |
2994 | } | 2891 | } |
2995 | } | 2892 | } |
2996 | llwarns << "Child Menu " << name << " not found in menu " << getName() << llendl; | 2893 | llwarns << "Child Menu " << name << " not found in menu " << getName() << llendl; |
@@ -3070,9 +2967,6 @@ class LLPieMenuBranch : public LLMenuItemGL | |||
3070 | public: | 2967 | public: |
3071 | LLPieMenuBranch(const LLString& name, const LLString& label, LLPieMenu* branch); | 2968 | LLPieMenuBranch(const LLString& name, const LLString& label, LLPieMenu* branch); |
3072 | 2969 | ||
3073 | virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_PIE_MENU_BRANCH; } | ||
3074 | virtual LLString getWidgetTag() const { return LL_PIE_MENU_BRANCH_TAG; } | ||
3075 | |||
3076 | // called to rebuild the draw label | 2970 | // called to rebuild the draw label |
3077 | virtual void buildDrawLabel( void ); | 2971 | virtual void buildDrawLabel( void ); |
3078 | 2972 | ||
@@ -3842,6 +3736,8 @@ void LLPieMenu::hide(BOOL item_selected) | |||
3842 | /// Class LLMenuBarGL | 3736 | /// Class LLMenuBarGL |
3843 | ///============================================================================ | 3737 | ///============================================================================ |
3844 | 3738 | ||
3739 | static LLRegisterWidget<LLMenuBarGL> r2("menu_bar"); | ||
3740 | |||
3845 | // Default constructor | 3741 | // Default constructor |
3846 | LLMenuBarGL::LLMenuBarGL( const LLString& name ) : LLMenuGL ( name, name ) | 3742 | LLMenuBarGL::LLMenuBarGL( const LLString& name ) : LLMenuGL ( name, name ) |
3847 | { | 3743 | { |
@@ -3897,9 +3793,10 @@ LLView* LLMenuBarGL::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory | |||
3897 | LLMenuBarGL *menubar = new LLMenuBarGL(name); | 3793 | LLMenuBarGL *menubar = new LLMenuBarGL(name); |
3898 | 3794 | ||
3899 | LLHandle<LLFloater> parent_handle; | 3795 | LLHandle<LLFloater> parent_handle; |
3900 | if (parent->getWidgetType() == WIDGET_TYPE_FLOATER) | 3796 | LLFloater* parent_floater = dynamic_cast<LLFloater*>(parent); |
3797 | if (parent_floater) | ||
3901 | { | 3798 | { |
3902 | parent_handle = ((LLFloater*)parent)->getHandle(); | 3799 | parent_handle = parent_floater->getHandle(); |
3903 | } | 3800 | } |
3904 | 3801 | ||
3905 | // We need to have the rect early so that it's around when building | 3802 | // We need to have the rect early so that it's around when building |
@@ -3991,7 +3888,7 @@ BOOL LLMenuBarGL::handleAcceleratorKey(KEY key, MASK mask) | |||
3991 | return result; | 3888 | return result; |
3992 | } | 3889 | } |
3993 | 3890 | ||
3994 | BOOL LLMenuBarGL::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent) | 3891 | BOOL LLMenuBarGL::handleKeyHere(KEY key, MASK mask) |
3995 | { | 3892 | { |
3996 | if(key == KEY_ALT && !gKeyboard->getKeyRepeated(key) && LLUI::sConfigGroup->getBOOL("UseAltKeyForMenus")) | 3893 | if(key == KEY_ALT && !gKeyboard->getKeyRepeated(key) && LLUI::sConfigGroup->getBOOL("UseAltKeyForMenus")) |
3997 | { | 3894 | { |
@@ -4005,7 +3902,7 @@ BOOL LLMenuBarGL::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent) | |||
4005 | // before processing any other key, check to see if ALT key has triggered menu access | 3902 | // before processing any other key, check to see if ALT key has triggered menu access |
4006 | checkMenuTrigger(); | 3903 | checkMenuTrigger(); |
4007 | 3904 | ||
4008 | return LLMenuGL::handleKeyHere(key, mask, called_from_parent); | 3905 | return LLMenuGL::handleKeyHere(key, mask); |
4009 | } | 3906 | } |
4010 | 3907 | ||
4011 | BOOL LLMenuBarGL::handleJumpKey(KEY key) | 3908 | BOOL LLMenuBarGL::handleJumpKey(KEY key) |
@@ -4295,7 +4192,7 @@ BOOL LLMenuHolderGL::hasVisibleMenu() const | |||
4295 | for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) | 4192 | for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) |
4296 | { | 4193 | { |
4297 | LLView* viewp = *child_it; | 4194 | LLView* viewp = *child_it; |
4298 | if (viewp->getVisible() && viewp->getWidgetType() != WIDGET_TYPE_MENU_BAR) | 4195 | if (viewp->getVisible() && dynamic_cast<LLMenuBarGL*>(viewp) == NULL) |
4299 | { | 4196 | { |
4300 | return TRUE; | 4197 | return TRUE; |
4301 | } | 4198 | } |
@@ -4319,7 +4216,7 @@ BOOL LLMenuHolderGL::hideMenus() | |||
4319 | { | 4216 | { |
4320 | LLView* viewp = *child_it; | 4217 | LLView* viewp = *child_it; |
4321 | // clicks off of menu do not hide menu bar | 4218 | // clicks off of menu do not hide menu bar |
4322 | if (viewp->getWidgetType() != WIDGET_TYPE_MENU_BAR && viewp->getVisible()) | 4219 | if (dynamic_cast<LLMenuBarGL*>(viewp) == NULL && viewp->getVisible()) |
4323 | { | 4220 | { |
4324 | viewp->setVisible(FALSE); | 4221 | viewp->setVisible(FALSE); |
4325 | } | 4222 | } |
@@ -4429,7 +4326,7 @@ BOOL LLTearOffMenu::handleUnicodeChar(llwchar uni_char, BOOL called_from_parent) | |||
4429 | return mMenu->handleUnicodeChar(uni_char, TRUE); | 4326 | return mMenu->handleUnicodeChar(uni_char, TRUE); |
4430 | } | 4327 | } |
4431 | 4328 | ||
4432 | BOOL LLTearOffMenu::handleKey(KEY key, MASK mask, BOOL called_from_parent) | 4329 | BOOL LLTearOffMenu::handleKeyHere(KEY key, MASK mask) |
4433 | { | 4330 | { |
4434 | if (!mMenu->getHighlightedItem()) | 4331 | if (!mMenu->getHighlightedItem()) |
4435 | { | 4332 | { |