diff options
author | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
commit | cd17687f01420952712a500107e0f93e7ab8d5f8 (patch) | |
tree | ce48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/llui/llcombobox.cpp | |
parent | Second Life viewer sources 1.19.0.5 (diff) | |
download | meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2 meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz |
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/llui/llcombobox.cpp')
-rw-r--r-- | linden/indra/llui/llcombobox.cpp | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/linden/indra/llui/llcombobox.cpp b/linden/indra/llui/llcombobox.cpp index 0e0f5f2..c486042 100644 --- a/linden/indra/llui/llcombobox.cpp +++ b/linden/indra/llui/llcombobox.cpp | |||
@@ -99,7 +99,7 @@ LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString | |||
99 | mList->setCommitOnKeyboardMovement(FALSE); | 99 | mList->setCommitOnKeyboardMovement(FALSE); |
100 | addChild(mList); | 100 | addChild(mList); |
101 | 101 | ||
102 | LLRect border_rect(0, mRect.getHeight(), mRect.getWidth(), 0); | 102 | LLRect border_rect(0, getRect().getHeight(), getRect().getWidth(), 0); |
103 | mBorder = new LLViewBorder( "combo border", border_rect ); | 103 | mBorder = new LLViewBorder( "combo border", border_rect ); |
104 | addChild( mBorder ); | 104 | addChild( mBorder ); |
105 | mBorder->setFollowsAll(); | 105 | mBorder->setFollowsAll(); |
@@ -444,7 +444,7 @@ void LLComboBox::setButtonVisible(BOOL visible) | |||
444 | mButton->setVisible(visible); | 444 | mButton->setVisible(visible); |
445 | if (mTextEntry) | 445 | if (mTextEntry) |
446 | { | 446 | { |
447 | LLRect text_entry_rect(0, mRect.getHeight(), mRect.getWidth(), 0); | 447 | LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0); |
448 | if (visible) | 448 | if (visible) |
449 | { | 449 | { |
450 | text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth(0)) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton"); | 450 | text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth(0)) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton"); |
@@ -460,7 +460,7 @@ void LLComboBox::draw() | |||
460 | { | 460 | { |
461 | mBorder->setKeyboardFocusHighlight(hasFocus()); | 461 | mBorder->setKeyboardFocusHighlight(hasFocus()); |
462 | 462 | ||
463 | mButton->setEnabled(mEnabled /*&& !mList->isEmpty()*/); | 463 | mButton->setEnabled(getEnabled() /*&& !mList->isEmpty()*/); |
464 | 464 | ||
465 | // Draw children normally | 465 | // Draw children normally |
466 | LLUICtrl::draw(); | 466 | LLUICtrl::draw(); |
@@ -494,13 +494,13 @@ void LLComboBox::updateLayout() | |||
494 | if (mAllowTextEntry) | 494 | if (mAllowTextEntry) |
495 | { | 495 | { |
496 | S32 shadow_size = LLUI::sConfigGroup->getS32("DropShadowButton"); | 496 | S32 shadow_size = LLUI::sConfigGroup->getS32("DropShadowButton"); |
497 | mButton->setRect(LLRect( mRect.getWidth() - llmax(8,mArrowImage->getWidth(0)) - 2 * shadow_size, | 497 | mButton->setRect(LLRect( getRect().getWidth() - llmax(8,mArrowImage->getWidth(0)) - 2 * shadow_size, |
498 | rect.mTop, rect.mRight, rect.mBottom)); | 498 | rect.mTop, rect.mRight, rect.mBottom)); |
499 | mButton->setTabStop(FALSE); | 499 | mButton->setTabStop(FALSE); |
500 | 500 | ||
501 | if (!mTextEntry) | 501 | if (!mTextEntry) |
502 | { | 502 | { |
503 | LLRect text_entry_rect(0, mRect.getHeight(), mRect.getWidth(), 0); | 503 | 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"); | 504 | text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth(0)) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton"); |
505 | // clear label on button | 505 | // clear label on button |
506 | LLString cur_label = mButton->getLabelSelected(); | 506 | LLString cur_label = mButton->getLabelSelected(); |
@@ -575,7 +575,7 @@ void LLComboBox::showList() | |||
575 | 575 | ||
576 | LLRect rect = mList->getRect(); | 576 | LLRect rect = mList->getRect(); |
577 | 577 | ||
578 | S32 min_width = mRect.getWidth(); | 578 | S32 min_width = getRect().getWidth(); |
579 | S32 max_width = llmax(min_width, MAX_COMBO_WIDTH); | 579 | S32 max_width = llmax(min_width, MAX_COMBO_WIDTH); |
580 | S32 list_width = llclamp(mList->getMaxContentWidth(), min_width, max_width); | 580 | S32 list_width = llclamp(mList->getMaxContentWidth(), min_width, max_width); |
581 | 581 | ||
@@ -589,7 +589,7 @@ void LLComboBox::showList() | |||
589 | else | 589 | else |
590 | { | 590 | { |
591 | // stack on top or bottom, depending on which has more room | 591 | // stack on top or bottom, depending on which has more room |
592 | if (-root_view_local.mBottom > root_view_local.mTop - mRect.getHeight()) | 592 | if (-root_view_local.mBottom > root_view_local.mTop - getRect().getHeight()) |
593 | { | 593 | { |
594 | // Move rect so it hangs off the bottom of this view | 594 | // Move rect so it hangs off the bottom of this view |
595 | rect.setLeftTopAndSize(0, 0, list_width, llmin(-root_view_local.mBottom, rect.getHeight())); | 595 | rect.setLeftTopAndSize(0, 0, list_width, llmin(-root_view_local.mBottom, rect.getHeight())); |
@@ -597,21 +597,21 @@ void LLComboBox::showList() | |||
597 | else | 597 | else |
598 | { | 598 | { |
599 | // move rect so it stacks on top of this view (clipped to size of screen) | 599 | // move rect so it stacks on top of this view (clipped to size of screen) |
600 | rect.setOriginAndSize(0, mRect.getHeight(), list_width, llmin(root_view_local.mTop - mRect.getHeight(), rect.getHeight())); | 600 | rect.setOriginAndSize(0, getRect().getHeight(), list_width, llmin(root_view_local.mTop - getRect().getHeight(), rect.getHeight())); |
601 | } | 601 | } |
602 | } | 602 | } |
603 | } | 603 | } |
604 | else // ABOVE | 604 | else // ABOVE |
605 | { | 605 | { |
606 | if (rect.getHeight() <= root_view_local.mTop - mRect.getHeight()) | 606 | if (rect.getHeight() <= root_view_local.mTop - getRect().getHeight()) |
607 | { | 607 | { |
608 | // move rect so it stacks on top of this view (clipped to size of screen) | 608 | // move rect so it stacks on top of this view (clipped to size of screen) |
609 | rect.setOriginAndSize(0, mRect.getHeight(), list_width, llmin(root_view_local.mTop - mRect.getHeight(), rect.getHeight())); | 609 | rect.setOriginAndSize(0, getRect().getHeight(), list_width, llmin(root_view_local.mTop - getRect().getHeight(), rect.getHeight())); |
610 | } | 610 | } |
611 | else | 611 | else |
612 | { | 612 | { |
613 | // stack on top or bottom, depending on which has more room | 613 | // stack on top or bottom, depending on which has more room |
614 | if (-root_view_local.mBottom > root_view_local.mTop - mRect.getHeight()) | 614 | if (-root_view_local.mBottom > root_view_local.mTop - getRect().getHeight()) |
615 | { | 615 | { |
616 | // Move rect so it hangs off the bottom of this view | 616 | // Move rect so it hangs off the bottom of this view |
617 | rect.setLeftTopAndSize(0, 0, list_width, llmin(-root_view_local.mBottom, rect.getHeight())); | 617 | rect.setLeftTopAndSize(0, 0, list_width, llmin(-root_view_local.mBottom, rect.getHeight())); |
@@ -619,7 +619,7 @@ void LLComboBox::showList() | |||
619 | else | 619 | else |
620 | { | 620 | { |
621 | // move rect so it stacks on top of this view (clipped to size of screen) | 621 | // move rect so it stacks on top of this view (clipped to size of screen) |
622 | rect.setOriginAndSize(0, mRect.getHeight(), list_width, llmin(root_view_local.mTop - mRect.getHeight(), rect.getHeight())); | 622 | rect.setOriginAndSize(0, getRect().getHeight(), list_width, llmin(root_view_local.mTop - getRect().getHeight(), rect.getHeight())); |
623 | } | 623 | } |
624 | } | 624 | } |
625 | 625 | ||
@@ -640,12 +640,6 @@ void LLComboBox::showList() | |||
640 | // NB: this call will trigger the focuslost callback which will hide the list, so do it first | 640 | // NB: this call will trigger the focuslost callback which will hide the list, so do it first |
641 | // before finally showing the list | 641 | // before finally showing the list |
642 | 642 | ||
643 | if (!mList->getFirstSelected()) | ||
644 | { | ||
645 | // if nothing is selected, select the first item | ||
646 | // so that the callback is not immediately triggered on setFocus() | ||
647 | mList->selectFirstItem(); | ||
648 | } | ||
649 | mList->setFocus(TRUE); | 643 | mList->setFocus(TRUE); |
650 | 644 | ||
651 | // register ourselves as a "top" control | 645 | // register ourselves as a "top" control |
@@ -718,7 +712,7 @@ void LLComboBox::onButtonDown(void *userdata) | |||
718 | else | 712 | else |
719 | { | 713 | { |
720 | self->hideList(); | 714 | self->hideList(); |
721 | } | 715 | } |
722 | 716 | ||
723 | } | 717 | } |
724 | 718 | ||
@@ -741,31 +735,36 @@ void LLComboBox::onItemSelected(LLUICtrl* item, void *userdata) | |||
741 | self->mTextEntry->selectAll(); | 735 | self->mTextEntry->selectAll(); |
742 | } | 736 | } |
743 | } | 737 | } |
744 | else | ||
745 | { | ||
746 | // invalid selection, just restore existing value | ||
747 | LLString orig_selection = self->mAllowTextEntry ? self->mTextEntry->getText() : self->mButton->getLabelSelected(); | ||
748 | |||
749 | self->mList->selectItemByLabel(orig_selection); | ||
750 | } | ||
751 | self->onCommit(); | ||
752 | 738 | ||
739 | // hiding the list reasserts the old value stored in the text editor/dropdown button | ||
753 | self->hideList(); | 740 | self->hideList(); |
741 | |||
742 | // commit does the reverse, asserting the value in the list | ||
743 | self->onCommit(); | ||
754 | } | 744 | } |
755 | 745 | ||
756 | BOOL LLComboBox::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen) | 746 | BOOL LLComboBox::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen) |
757 | { | 747 | { |
758 | LLString tool_tip; | 748 | LLString tool_tip; |
759 | 749 | ||
750 | if(LLUICtrl::handleToolTip(x, y, msg, sticky_rect_screen)) | ||
751 | { | ||
752 | return TRUE; | ||
753 | } | ||
754 | |||
760 | if (LLUI::sShowXUINames) | 755 | if (LLUI::sShowXUINames) |
761 | { | 756 | { |
762 | tool_tip = getShowNamesToolTip(); | 757 | tool_tip = getShowNamesToolTip(); |
763 | } | 758 | } |
764 | else | 759 | else |
765 | { | 760 | { |
766 | tool_tip = mToolTipMsg; | 761 | tool_tip = getToolTip(); |
762 | if (tool_tip.empty()) | ||
763 | { | ||
764 | tool_tip = getValue().asString(); | ||
765 | } | ||
767 | } | 766 | } |
768 | 767 | ||
769 | if( !tool_tip.empty() ) | 768 | if( !tool_tip.empty() ) |
770 | { | 769 | { |
771 | msg = tool_tip; | 770 | msg = tool_tip; |
@@ -775,7 +774,7 @@ BOOL LLComboBox::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_ | |||
775 | 0, 0, | 774 | 0, 0, |
776 | &(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) ); | 775 | &(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) ); |
777 | localPointToScreen( | 776 | localPointToScreen( |
778 | mRect.getWidth(), mRect.getHeight(), | 777 | getRect().getWidth(), getRect().getHeight(), |
779 | &(sticky_rect_screen->mRight), &(sticky_rect_screen->mTop) ); | 778 | &(sticky_rect_screen->mRight), &(sticky_rect_screen->mTop) ); |
780 | } | 779 | } |
781 | return TRUE; | 780 | return TRUE; |
@@ -1042,11 +1041,11 @@ BOOL LLComboBox::setCurrentByID(const LLUUID& id) | |||
1042 | return found; | 1041 | return found; |
1043 | } | 1042 | } |
1044 | 1043 | ||
1045 | LLUUID LLComboBox::getCurrentID() | 1044 | LLUUID LLComboBox::getCurrentID() const |
1046 | { | 1045 | { |
1047 | return mList->getStringUUIDSelectedItem(); | 1046 | return mList->getStringUUIDSelectedItem(); |
1048 | } | 1047 | } |
1049 | BOOL LLComboBox::setSelectedByValue(LLSD value, BOOL selected) | 1048 | BOOL LLComboBox::setSelectedByValue(const LLSD& value, BOOL selected) |
1050 | { | 1049 | { |
1051 | BOOL found = mList->setSelectedByValue(value, selected); | 1050 | BOOL found = mList->setSelectedByValue(value, selected); |
1052 | if (found) | 1051 | if (found) |
@@ -1061,7 +1060,7 @@ LLSD LLComboBox::getSelectedValue() | |||
1061 | return mList->getSelectedValue(); | 1060 | return mList->getSelectedValue(); |
1062 | } | 1061 | } |
1063 | 1062 | ||
1064 | BOOL LLComboBox::isSelected(LLSD value) | 1063 | BOOL LLComboBox::isSelected(const LLSD& value) const |
1065 | { | 1064 | { |
1066 | return mList->isSelected(value); | 1065 | return mList->isSelected(value); |
1067 | } | 1066 | } |
@@ -1199,14 +1198,14 @@ void LLFlyoutButton::updateLayout() | |||
1199 | { | 1198 | { |
1200 | LLComboBox::updateLayout(); | 1199 | LLComboBox::updateLayout(); |
1201 | 1200 | ||
1202 | mButton->setOrigin(mRect.getWidth() - FLYOUT_BUTTON_ARROW_WIDTH, 0); | 1201 | mButton->setOrigin(getRect().getWidth() - FLYOUT_BUTTON_ARROW_WIDTH, 0); |
1203 | mButton->reshape(FLYOUT_BUTTON_ARROW_WIDTH, mRect.getHeight()); | 1202 | mButton->reshape(FLYOUT_BUTTON_ARROW_WIDTH, getRect().getHeight()); |
1204 | mButton->setFollows(FOLLOWS_RIGHT | FOLLOWS_TOP | FOLLOWS_BOTTOM); | 1203 | mButton->setFollows(FOLLOWS_RIGHT | FOLLOWS_TOP | FOLLOWS_BOTTOM); |
1205 | mButton->setTabStop(FALSE); | 1204 | mButton->setTabStop(FALSE); |
1206 | mButton->setImageOverlay(mListPosition == BELOW ? "down_arrow.tga" : "up_arrow.tga", LLFontGL::RIGHT); | 1205 | mButton->setImageOverlay(mListPosition == BELOW ? "down_arrow.tga" : "up_arrow.tga", LLFontGL::RIGHT); |
1207 | 1206 | ||
1208 | mActionButton->setOrigin(0, 0); | 1207 | mActionButton->setOrigin(0, 0); |
1209 | mActionButton->reshape(mRect.getWidth() - FLYOUT_BUTTON_ARROW_WIDTH, mRect.getHeight()); | 1208 | mActionButton->reshape(getRect().getWidth() - FLYOUT_BUTTON_ARROW_WIDTH, getRect().getHeight()); |
1210 | } | 1209 | } |
1211 | 1210 | ||
1212 | //static | 1211 | //static |