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/llcombobox.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/llcombobox.cpp')
-rw-r--r-- | linden/indra/llui/llcombobox.cpp | 75 |
1 files changed, 32 insertions, 43 deletions
diff --git a/linden/indra/llui/llcombobox.cpp b/linden/indra/llui/llcombobox.cpp index c486042..0523a11 100644 --- a/linden/indra/llui/llcombobox.cpp +++ b/linden/indra/llui/llcombobox.cpp | |||
@@ -57,6 +57,8 @@ S32 LLCOMBOBOX_HEIGHT = 0; | |||
57 | S32 LLCOMBOBOX_WIDTH = 0; | 57 | S32 LLCOMBOBOX_WIDTH = 0; |
58 | S32 MAX_COMBO_WIDTH = 500; | 58 | S32 MAX_COMBO_WIDTH = 500; |
59 | 59 | ||
60 | static LLRegisterWidget<LLComboBox> r1("combo_box"); | ||
61 | |||
60 | LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString& label, | 62 | LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString& label, |
61 | void (*commit_callback)(LLUICtrl*,void*), | 63 | void (*commit_callback)(LLUICtrl*,void*), |
62 | void *callback_userdata | 64 | void *callback_userdata |
@@ -74,9 +76,10 @@ LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString | |||
74 | { | 76 | { |
75 | // Always use text box | 77 | // Always use text box |
76 | // Text label button | 78 | // Text label button |
77 | mButton = new LLButton("comboxbox button", | 79 | mButton = new LLButton(label, |
78 | LLRect(), label, NULL, LLString::null, | 80 | LLRect(), |
79 | NULL, this); | 81 | LLString::null, |
82 | NULL, this); | ||
80 | mButton->setImageUnselected("square_btn_32x128.tga"); | 83 | mButton->setImageUnselected("square_btn_32x128.tga"); |
81 | mButton->setImageSelected("square_btn_selected_32x128.tga"); | 84 | mButton->setImageSelected("square_btn_selected_32x128.tga"); |
82 | mButton->setImageDisabled("square_btn_32x128.tga"); | 85 | mButton->setImageDisabled("square_btn_32x128.tga"); |
@@ -99,13 +102,7 @@ LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString | |||
99 | mList->setCommitOnKeyboardMovement(FALSE); | 102 | mList->setCommitOnKeyboardMovement(FALSE); |
100 | addChild(mList); | 103 | addChild(mList); |
101 | 104 | ||
102 | LLRect border_rect(0, getRect().getHeight(), getRect().getWidth(), 0); | 105 | mArrowImage = LLUI::sImageProvider->getUIImage("combobox_arrow.tga"); |
103 | mBorder = new LLViewBorder( "combo border", border_rect ); | ||
104 | addChild( mBorder ); | ||
105 | mBorder->setFollowsAll(); | ||
106 | |||
107 | LLUUID arrow_image_id( LLUI::sAssetsGroup->getString("combobox_arrow.tga") ); | ||
108 | mArrowImage = LLUI::sImageProvider->getImageByID(arrow_image_id); | ||
109 | mButton->setImageOverlay("combobox_arrow.tga", LLFontGL::RIGHT); | 106 | mButton->setImageOverlay("combobox_arrow.tga", LLFontGL::RIGHT); |
110 | 107 | ||
111 | updateLayout(); | 108 | updateLayout(); |
@@ -447,7 +444,7 @@ void LLComboBox::setButtonVisible(BOOL visible) | |||
447 | LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0); | 444 | LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0); |
448 | if (visible) | 445 | if (visible) |
449 | { | 446 | { |
450 | text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth(0)) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton"); | 447 | text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth()) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton"); |
451 | } | 448 | } |
452 | //mTextEntry->setRect(text_entry_rect); | 449 | //mTextEntry->setRect(text_entry_rect); |
453 | mTextEntry->reshape(text_entry_rect.getWidth(), text_entry_rect.getHeight(), TRUE); | 450 | mTextEntry->reshape(text_entry_rect.getWidth(), text_entry_rect.getHeight(), TRUE); |
@@ -456,15 +453,10 @@ void LLComboBox::setButtonVisible(BOOL visible) | |||
456 | 453 | ||
457 | void LLComboBox::draw() | 454 | void LLComboBox::draw() |
458 | { | 455 | { |
459 | if( getVisible() ) | 456 | mButton->setEnabled(getEnabled() /*&& !mList->isEmpty()*/); |
460 | { | ||
461 | mBorder->setKeyboardFocusHighlight(hasFocus()); | ||
462 | |||
463 | mButton->setEnabled(getEnabled() /*&& !mList->isEmpty()*/); | ||
464 | 457 | ||
465 | // Draw children normally | 458 | // Draw children normally |
466 | LLUICtrl::draw(); | 459 | LLUICtrl::draw(); |
467 | } | ||
468 | } | 460 | } |
469 | 461 | ||
470 | BOOL LLComboBox::setCurrentByIndex( S32 index ) | 462 | BOOL LLComboBox::setCurrentByIndex( S32 index ) |
@@ -494,14 +486,14 @@ void LLComboBox::updateLayout() | |||
494 | if (mAllowTextEntry) | 486 | if (mAllowTextEntry) |
495 | { | 487 | { |
496 | S32 shadow_size = LLUI::sConfigGroup->getS32("DropShadowButton"); | 488 | S32 shadow_size = LLUI::sConfigGroup->getS32("DropShadowButton"); |
497 | mButton->setRect(LLRect( getRect().getWidth() - llmax(8,mArrowImage->getWidth(0)) - 2 * shadow_size, | 489 | mButton->setRect(LLRect( getRect().getWidth() - llmax(8,mArrowImage->getWidth()) - 2 * shadow_size, |
498 | rect.mTop, rect.mRight, rect.mBottom)); | 490 | rect.mTop, rect.mRight, rect.mBottom)); |
499 | mButton->setTabStop(FALSE); | 491 | mButton->setTabStop(FALSE); |
500 | 492 | ||
501 | if (!mTextEntry) | 493 | if (!mTextEntry) |
502 | { | 494 | { |
503 | LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0); | 495 | LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0); |
504 | text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth(0)) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton"); | 496 | text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth()) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton"); |
505 | // clear label on button | 497 | // clear label on button |
506 | LLString cur_label = mButton->getLabelSelected(); | 498 | LLString cur_label = mButton->getLabelSelected(); |
507 | mTextEntry = new LLLineEditor("combo_text_entry", | 499 | mTextEntry = new LLLineEditor("combo_text_entry", |
@@ -512,11 +504,7 @@ void LLComboBox::updateLayout() | |||
512 | onTextCommit, | 504 | onTextCommit, |
513 | onTextEntry, | 505 | onTextEntry, |
514 | NULL, | 506 | NULL, |
515 | this, | 507 | this); |
516 | NULL, // prevalidate func | ||
517 | LLViewBorder::BEVEL_NONE, | ||
518 | LLViewBorder::STYLE_LINE, | ||
519 | 0); // no border | ||
520 | mTextEntry->setSelectAllonFocusReceived(TRUE); | 508 | mTextEntry->setSelectAllonFocusReceived(TRUE); |
521 | mTextEntry->setHandleEditKeysDirectly(TRUE); | 509 | mTextEntry->setHandleEditKeysDirectly(TRUE); |
522 | mTextEntry->setCommitOnFocusLost(FALSE); | 510 | mTextEntry->setCommitOnFocusLost(FALSE); |
@@ -761,7 +749,7 @@ BOOL LLComboBox::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_ | |||
761 | tool_tip = getToolTip(); | 749 | tool_tip = getToolTip(); |
762 | if (tool_tip.empty()) | 750 | if (tool_tip.empty()) |
763 | { | 751 | { |
764 | tool_tip = getValue().asString(); | 752 | tool_tip = getSelectedItemLabel(); |
765 | } | 753 | } |
766 | } | 754 | } |
767 | 755 | ||
@@ -780,10 +768,10 @@ BOOL LLComboBox::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_ | |||
780 | return TRUE; | 768 | return TRUE; |
781 | } | 769 | } |
782 | 770 | ||
783 | BOOL LLComboBox::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent) | 771 | BOOL LLComboBox::handleKeyHere(KEY key, MASK mask) |
784 | { | 772 | { |
785 | BOOL result = FALSE; | 773 | BOOL result = FALSE; |
786 | if (gFocusMgr.childHasKeyboardFocus(this)) | 774 | if (hasFocus()) |
787 | { | 775 | { |
788 | //give list a chance to pop up and handle key | 776 | //give list a chance to pop up and handle key |
789 | LLScrollListItem* last_selected_item = mList->getLastSelectedItem(); | 777 | LLScrollListItem* last_selected_item = mList->getLastSelectedItem(); |
@@ -792,7 +780,7 @@ BOOL LLComboBox::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent) | |||
792 | // highlight the original selection before potentially selecting a new item | 780 | // highlight the original selection before potentially selecting a new item |
793 | mList->highlightNthItem(mList->getItemIndex(last_selected_item)); | 781 | mList->highlightNthItem(mList->getItemIndex(last_selected_item)); |
794 | } | 782 | } |
795 | result = mList->handleKeyHere(key, mask, FALSE); | 783 | result = mList->handleKeyHere(key, mask); |
796 | // if selection has changed, pop open list | 784 | // if selection has changed, pop open list |
797 | if (mList->getLastSelectedItem() != last_selected_item) | 785 | if (mList->getLastSelectedItem() != last_selected_item) |
798 | { | 786 | { |
@@ -802,7 +790,7 @@ BOOL LLComboBox::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent) | |||
802 | return result; | 790 | return result; |
803 | } | 791 | } |
804 | 792 | ||
805 | BOOL LLComboBox::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent) | 793 | BOOL LLComboBox::handleUnicodeCharHere(llwchar uni_char) |
806 | { | 794 | { |
807 | BOOL result = FALSE; | 795 | BOOL result = FALSE; |
808 | if (gFocusMgr.childHasKeyboardFocus(this)) | 796 | if (gFocusMgr.childHasKeyboardFocus(this)) |
@@ -816,7 +804,7 @@ BOOL LLComboBox::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent | |||
816 | // highlight the original selection before potentially selecting a new item | 804 | // highlight the original selection before potentially selecting a new item |
817 | mList->highlightNthItem(mList->getItemIndex(last_selected_item)); | 805 | mList->highlightNthItem(mList->getItemIndex(last_selected_item)); |
818 | } | 806 | } |
819 | result = mList->handleUnicodeCharHere(uni_char, called_from_parent); | 807 | result = mList->handleUnicodeCharHere(uni_char); |
820 | if (mList->getLastSelectedItem() != last_selected_item) | 808 | if (mList->getLastSelectedItem() != last_selected_item) |
821 | { | 809 | { |
822 | showList(); | 810 | showList(); |
@@ -1095,6 +1083,8 @@ BOOL LLComboBox::selectItemRange( S32 first, S32 last ) | |||
1095 | // LLFlyoutButton | 1083 | // LLFlyoutButton |
1096 | // | 1084 | // |
1097 | 1085 | ||
1086 | static LLRegisterWidget<LLFlyoutButton> r2("flyout_button"); | ||
1087 | |||
1098 | const S32 FLYOUT_BUTTON_ARROW_WIDTH = 24; | 1088 | const S32 FLYOUT_BUTTON_ARROW_WIDTH = 24; |
1099 | 1089 | ||
1100 | LLFlyoutButton::LLFlyoutButton( | 1090 | LLFlyoutButton::LLFlyoutButton( |
@@ -1109,9 +1099,8 @@ LLFlyoutButton::LLFlyoutButton( | |||
1109 | { | 1099 | { |
1110 | // Always use text box | 1100 | // Always use text box |
1111 | // Text label button | 1101 | // Text label button |
1112 | mActionButton = new LLButton("flyout_button_main", | 1102 | mActionButton = new LLButton(label, |
1113 | LLRect(), label, NULL, LLString::null, | 1103 | LLRect(), LLString::null, NULL, this); |
1114 | NULL, this); | ||
1115 | mActionButton->setScaleImage(TRUE); | 1104 | mActionButton->setScaleImage(TRUE); |
1116 | 1105 | ||
1117 | mActionButton->setClickedCallback(onActionButtonClick); | 1106 | mActionButton->setClickedCallback(onActionButtonClick); |
@@ -1120,24 +1109,24 @@ LLFlyoutButton::LLFlyoutButton( | |||
1120 | mActionButton->setLabel(label); | 1109 | mActionButton->setLabel(label); |
1121 | addChild(mActionButton); | 1110 | addChild(mActionButton); |
1122 | 1111 | ||
1123 | mActionButtonImage = LLUI::getUIImageByName("flyout_btn_left.tga"); | 1112 | mActionButtonImage = LLUI::getUIImage("flyout_btn_left.tga"); |
1124 | mExpanderButtonImage = LLUI::getUIImageByName("flyout_btn_right.tga"); | 1113 | mExpanderButtonImage = LLUI::getUIImage("flyout_btn_right.tga"); |
1125 | mActionButtonImageSelected = LLUI::getUIImageByName("flyout_btn_left_selected.tga"); | 1114 | mActionButtonImageSelected = LLUI::getUIImage("flyout_btn_left_selected.tga"); |
1126 | mExpanderButtonImageSelected = LLUI::getUIImageByName("flyout_btn_right_selected.tga"); | 1115 | mExpanderButtonImageSelected = LLUI::getUIImage("flyout_btn_right_selected.tga"); |
1116 | mActionButtonImageDisabled = LLUI::getUIImage("flyout_btn_left_disabled.tga"); | ||
1117 | mExpanderButtonImageDisabled = LLUI::getUIImage("flyout_btn_right_disabled.tga"); | ||
1127 | 1118 | ||
1128 | mActionButton->setImageSelected(mActionButtonImageSelected); | 1119 | mActionButton->setImageSelected(mActionButtonImageSelected); |
1129 | mActionButton->setImageUnselected(mActionButtonImage); | 1120 | mActionButton->setImageUnselected(mActionButtonImage); |
1130 | mActionButton->setImageDisabled(LLPointer<LLUIImage>(NULL)); | 1121 | mActionButton->setImageDisabled(mActionButtonImageDisabled); |
1131 | mActionButton->setImageDisabledSelected(LLPointer<LLUIImage>(NULL)); | 1122 | mActionButton->setImageDisabledSelected(LLPointer<LLUIImage>(NULL)); |
1132 | 1123 | ||
1133 | mButton->setImageSelected(mExpanderButtonImageSelected); | 1124 | mButton->setImageSelected(mExpanderButtonImageSelected); |
1134 | mButton->setImageUnselected(mExpanderButtonImage); | 1125 | mButton->setImageUnselected(mExpanderButtonImage); |
1135 | mButton->setImageDisabled(LLPointer<LLUIImage>(NULL)); | 1126 | mButton->setImageDisabled(mExpanderButtonImageDisabled); |
1136 | mButton->setImageDisabledSelected(LLPointer<LLUIImage>(NULL)); | 1127 | mButton->setImageDisabledSelected(LLPointer<LLUIImage>(NULL)); |
1137 | mButton->setRightHPad(6); | 1128 | mButton->setRightHPad(6); |
1138 | 1129 | ||
1139 | mBorder->setVisible(FALSE); | ||
1140 | |||
1141 | updateLayout(); | 1130 | updateLayout(); |
1142 | } | 1131 | } |
1143 | 1132 | ||