From 0277259455c4354f81ea8a24c8ab93f27567bc6f Mon Sep 17 00:00:00 2001 From: Josh Bell Date: Wed, 11 Apr 2007 17:54:18 +0000 Subject: svn merge -r 59968:60342 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance --> release --- indra/llui/llbutton.cpp | 25 ++++++++ indra/llui/llbutton.h | 4 ++ indra/llui/lltabcontainer.cpp | 132 ++++++++++++++++++++++++++++++++++++++---- indra/llui/lltabcontainer.h | 4 ++ indra/llui/lltextbox.cpp | 2 +- indra/llui/llui.cpp | 15 +++-- indra/llui/llui.h | 3 + 7 files changed, 169 insertions(+), 16 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 8e81fec33b..9f66daf890 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -933,6 +933,19 @@ LLXMLNodePtr LLButton::getXML(bool save_children) const return node; } +void clicked_help(void* data) +{ + LLButton* self = (LLButton*)data; + if (!self) return; + + if (!LLUI::sHtmlHelp) + { + return; + } + + LLUI::sHtmlHelp->show(self->getHelpURL()); +} + // static LLView* LLButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { @@ -1009,9 +1022,21 @@ LLView* LLButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *fa { button->setLabelSelected(node->getTextContents()); } + + if (node->hasAttribute("help_url")) + { + LLString help_url; + node->getAttributeString("help_url",help_url); + button->setHelpURLCallback(help_url); + } button->initFromXML(node, parent); return button; } +void LLButton::setHelpURLCallback(std::string help_url) +{ + mHelpURL = help_url; + setClickedCallback(clicked_help,this); +} diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 3dea4434a9..9048358bd8 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -163,6 +163,8 @@ public: void setCommitOnReturn(BOOL commit) { mCommitOnReturn = commit; } BOOL getCommitOnReturn() { return mCommitOnReturn; } + void setHelpURLCallback(std::string help_url); + LLString getHelpURL() { return mHelpURL; } protected: virtual void drawBorder(const LLColor4& color, S32 size); @@ -243,6 +245,8 @@ protected: BOOL mNeedsHighlight; BOOL mCommitOnReturn; + LLString mHelpURL; + LLPointer mImagep; static LLFrameTimer sFlashingTimer; diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index c412d77922..a3353d2028 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -457,6 +457,24 @@ void LLTabContainerCommon::onPrevBtn( void* userdata ) self->mScrolled = FALSE; } + +void LLTabContainerCommon::onJumpFirstBtn( void* userdata ) +{ + LLTabContainer* self = (LLTabContainer*) userdata; + + self->mScrollPos = 0; + +} + + +void LLTabContainerCommon::onJumpLastBtn( void* userdata ) +{ + LLTabContainer* self = (LLTabContainer*) userdata; + + self->mScrollPos = self->mMaxScrollPos; +} + + // static void LLTabContainerCommon::onPrevBtnHeld( void* userdata ) { @@ -673,6 +691,8 @@ LLTabContainer::LLTabContainer( LLTabContainerCommon(name, rect, pos, close_callback, callback_userdata, bordered), mLeftArrowBtn(NULL), mRightArrowBtn(NULL), + mJumpLeftArrowBtn(NULL), + mJumpRightArrowBtn(NULL), mRightTabBtnOffset(0), mMinTabWidth(TABCNTR_TAB_MIN_WIDTH), mMaxTabWidth(TABCNTR_TAB_MAX_WIDTH), @@ -689,6 +709,8 @@ LLTabContainer::LLTabContainer( LLTabContainerCommon(name, rect_control, pos, close_callback, callback_userdata, bordered), mLeftArrowBtn(NULL), mRightArrowBtn(NULL), + mJumpLeftArrowBtn(NULL), + mJumpRightArrowBtn(NULL), mRightTabBtnOffset(0), mMinTabWidth(TABCNTR_TAB_MIN_WIDTH), mMaxTabWidth(TABCNTR_TAB_MAX_WIDTH), @@ -720,14 +742,35 @@ void LLTabContainer::initButtons() S32 btn_top = (mTabPosition == TOP ) ? mRect.getHeight() - mTopBorderHeight : TABCNTR_ARROW_BTN_SIZE + 1; LLRect left_arrow_btn_rect; - left_arrow_btn_rect.setLeftTopAndSize( LLPANEL_BORDER_WIDTH+1, btn_top + arrow_fudge, TABCNTR_ARROW_BTN_SIZE, TABCNTR_ARROW_BTN_SIZE ); + left_arrow_btn_rect.setLeftTopAndSize( LLPANEL_BORDER_WIDTH+1+TABCNTR_ARROW_BTN_SIZE, btn_top + arrow_fudge, TABCNTR_ARROW_BTN_SIZE, TABCNTR_ARROW_BTN_SIZE ); + + LLRect jump_left_arrow_btn_rect; + jump_left_arrow_btn_rect.setLeftTopAndSize( LLPANEL_BORDER_WIDTH+1, btn_top + arrow_fudge, TABCNTR_ARROW_BTN_SIZE, TABCNTR_ARROW_BTN_SIZE ); S32 right_pad = TABCNTR_ARROW_BTN_SIZE + LLPANEL_BORDER_WIDTH + 1; + LLRect right_arrow_btn_rect; - right_arrow_btn_rect.setLeftTopAndSize( mRect.getWidth() - mRightTabBtnOffset - right_pad, + right_arrow_btn_rect.setLeftTopAndSize( mRect.getWidth() - mRightTabBtnOffset - right_pad - TABCNTR_ARROW_BTN_SIZE, btn_top + arrow_fudge, TABCNTR_ARROW_BTN_SIZE, TABCNTR_ARROW_BTN_SIZE ); + + LLRect jump_right_arrow_btn_rect; + jump_right_arrow_btn_rect.setLeftTopAndSize( mRect.getWidth() - mRightTabBtnOffset - right_pad, + btn_top + arrow_fudge, + TABCNTR_ARROW_BTN_SIZE, TABCNTR_ARROW_BTN_SIZE ); + + out_id = "UIImgBtnJumpLeftOutUUID"; + in_id = "UIImgBtnJumpLeftInUUID"; + mJumpLeftArrowBtn = new LLButton( + "Jump Left Arrow", jump_left_arrow_btn_rect, + out_id, in_id, "", + &LLTabContainer::onJumpFirstBtn, this, LLFontGL::sSansSerif ); + mJumpLeftArrowBtn->setFollowsLeft(); + mJumpLeftArrowBtn->setSaveToXML(false); + mJumpLeftArrowBtn->setTabStop(FALSE); + addChild(mJumpLeftArrowBtn); + out_id = "UIImgBtnScrollLeftOutUUID"; in_id = "UIImgBtnScrollLeftInUUID"; mLeftArrowBtn = new LLButton( @@ -739,6 +782,18 @@ void LLTabContainer::initButtons() mLeftArrowBtn->setSaveToXML(false); mLeftArrowBtn->setTabStop(FALSE); addChild(mLeftArrowBtn); + + out_id = "UIImgBtnJumpRightOutUUID"; + in_id = "UIImgBtnJumpRightInUUID"; + mJumpRightArrowBtn = new LLButton( + "Jump Right Arrow", jump_right_arrow_btn_rect, + out_id, in_id, "", + &LLTabContainer::onJumpLastBtn, this, + LLFontGL::sSansSerif); + mJumpRightArrowBtn->setFollowsRight(); + mJumpRightArrowBtn->setSaveToXML(false); + mJumpRightArrowBtn->setTabStop(FALSE); + addChild(mJumpRightArrowBtn); out_id = "UIImgBtnScrollRightOutUUID"; in_id = "UIImgBtnScrollRightInUUID"; @@ -753,15 +808,20 @@ void LLTabContainer::initButtons() mRightArrowBtn->setTabStop(FALSE); addChild(mRightArrowBtn); + if( mTabPosition == TOP ) { mRightArrowBtn->setFollowsTop(); mLeftArrowBtn->setFollowsTop(); + mJumpLeftArrowBtn->setFollowsTop(); + mJumpRightArrowBtn->setFollowsTop(); } else { mRightArrowBtn->setFollowsBottom(); mLeftArrowBtn->setFollowsBottom(); + mJumpLeftArrowBtn->setFollowsBottom(); + mJumpRightArrowBtn->setFollowsBottom(); } // set default tab group to be panel contents @@ -952,7 +1012,7 @@ void LLTabContainer::updateMaxScrollPos() if( tab_space > available_space ) { - S32 available_width_with_arrows = mRect.getWidth() - mRightTabBtnOffset - 2 * (LLPANEL_BORDER_WIDTH + TABCNTR_ARROW_BTN_SIZE + 1); + S32 available_width_with_arrows = mRect.getWidth() - mRightTabBtnOffset - 2 * (LLPANEL_BORDER_WIDTH + TABCNTR_ARROW_BTN_SIZE + TABCNTR_ARROW_BTN_SIZE + 1); // subtract off reserved portion on left available_width_with_arrows -= TABCNTR_TAB_PARTIAL_WIDTH; @@ -1059,7 +1119,7 @@ BOOL LLTabContainer::selectTab(S32 which) } else { - S32 available_width_with_arrows = mRect.getWidth() - mRightTabBtnOffset - 2 * (LLPANEL_BORDER_WIDTH + TABCNTR_ARROW_BTN_SIZE + 1); + S32 available_width_with_arrows = mRect.getWidth() - mRightTabBtnOffset - 2 * (LLPANEL_BORDER_WIDTH + TABCNTR_ARROW_BTN_SIZE + TABCNTR_ARROW_BTN_SIZE + 1); S32 running_tab_width = tuple->mButton->getRect().getWidth(); S32 j = i - 1; S32 min_scroll_pos = i; @@ -1101,7 +1161,7 @@ void LLTabContainer::draw() S32 cur_scroll_pos = mScrollPos; if (cur_scroll_pos > 0) { - S32 available_width_with_arrows = mRect.getWidth() - mRightTabBtnOffset - 2 * (LLPANEL_BORDER_WIDTH + TABCNTR_ARROW_BTN_SIZE + 1); + S32 available_width_with_arrows = mRect.getWidth() - mRightTabBtnOffset - 2 * (LLPANEL_BORDER_WIDTH + TABCNTR_ARROW_BTN_SIZE + TABCNTR_ARROW_BTN_SIZE + 1); for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter) { if (cur_scroll_pos == 0) @@ -1122,11 +1182,13 @@ void LLTabContainer::draw() if( getVisible() ) { BOOL has_scroll_arrows = (mMaxScrollPos > 0) || (mScrollPosPixels > 0); + mJumpLeftArrowBtn->setVisible( has_scroll_arrows ); + mJumpRightArrowBtn->setVisible( has_scroll_arrows ); mLeftArrowBtn->setVisible( has_scroll_arrows ); mRightArrowBtn->setVisible( has_scroll_arrows ); // Set the leftmost position of the tab buttons. - S32 left = LLPANEL_BORDER_WIDTH + (has_scroll_arrows ? TABCNTR_ARROW_BTN_SIZE : TABCNTR_TAB_H_PAD); + S32 left = LLPANEL_BORDER_WIDTH + (has_scroll_arrows ? (TABCNTR_ARROW_BTN_SIZE * 2) : TABCNTR_TAB_H_PAD); left -= mScrollPosPixels; // Hide all the buttons @@ -1215,7 +1277,19 @@ BOOL LLTabContainer::handleMouseDown( S32 x, S32 y, MASK mask ) BOOL has_scroll_arrows = (mMaxScrollPos > 0); if (has_scroll_arrows) - { + { + if (mJumpLeftArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mJumpLeftArrowBtn->getRect().mLeft; + S32 local_y = y - mJumpLeftArrowBtn->getRect().mBottom; + handled = mJumpLeftArrowBtn->handleMouseDown(local_x, local_y, mask); + } + if (mJumpRightArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mJumpRightArrowBtn->getRect().mLeft; + S32 local_y = y - mJumpRightArrowBtn->getRect().mBottom; + handled = mJumpRightArrowBtn->handleMouseDown(local_x, local_y, mask); + } if (mLeftArrowBtn->getRect().pointInRect(x, y)) { S32 local_x = x - mLeftArrowBtn->getRect().mLeft; @@ -1237,9 +1311,9 @@ BOOL LLTabContainer::handleMouseDown( S32 x, S32 y, MASK mask ) if (mTabList.size() > 0) { LLTabTuple* firsttuple = mTabList[0]; - LLRect tab_rect(has_scroll_arrows ? mLeftArrowBtn->getRect().mRight : mLeftArrowBtn->getRect().mLeft, + LLRect tab_rect(has_scroll_arrows ? mLeftArrowBtn->getRect().mRight : mJumpLeftArrowBtn->getRect().mLeft, firsttuple->mButton->getRect().mTop, - has_scroll_arrows ? mRightArrowBtn->getRect().mLeft : mRightArrowBtn->getRect().mRight, + has_scroll_arrows ? mRightArrowBtn->getRect().mLeft : mJumpRightArrowBtn->getRect().mRight, firsttuple->mButton->getRect().mBottom ); if( tab_rect.pointInRect( x, y ) ) { @@ -1257,7 +1331,19 @@ BOOL LLTabContainer::handleHover( S32 x, S32 y, MASK mask ) BOOL has_scroll_arrows = (mMaxScrollPos > 0); if (has_scroll_arrows) - { + { + if (mJumpLeftArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mJumpLeftArrowBtn->getRect().mLeft; + S32 local_y = y - mJumpLeftArrowBtn->getRect().mBottom; + handled = mJumpLeftArrowBtn->handleHover(local_x, local_y, mask); + } + if (mJumpRightArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mJumpRightArrowBtn->getRect().mLeft; + S32 local_y = y - mJumpRightArrowBtn->getRect().mBottom; + handled = mJumpRightArrowBtn->handleHover(local_x, local_y, mask); + } if (mLeftArrowBtn->getRect().pointInRect(x, y)) { S32 local_x = x - mLeftArrowBtn->getRect().mLeft; @@ -1287,6 +1373,18 @@ BOOL LLTabContainer::handleMouseUp( S32 x, S32 y, MASK mask ) if (has_scroll_arrows) { + if (mJumpLeftArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mJumpLeftArrowBtn->getRect().mLeft; + S32 local_y = y - mJumpLeftArrowBtn->getRect().mBottom; + handled = mJumpLeftArrowBtn->handleMouseUp(local_x, local_y, mask); + } + if (mJumpRightArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mJumpRightArrowBtn->getRect().mLeft; + S32 local_y = y - mJumpRightArrowBtn->getRect().mBottom; + handled = mJumpRightArrowBtn->handleMouseUp(local_x, local_y, mask); + } if (mLeftArrowBtn->getRect().pointInRect(x, y)) { S32 local_x = x - mLeftArrowBtn->getRect().mLeft; @@ -1332,7 +1430,7 @@ BOOL LLTabContainer::handleToolTip( S32 x, S32 y, LLString& msg, LLRect* sticky_ BOOL has_scroll_arrows = (mMaxScrollPos > 0); LLRect clip( - has_scroll_arrows ? mLeftArrowBtn->getRect().mRight : mLeftArrowBtn->getRect().mLeft, + has_scroll_arrows ? mJumpLeftArrowBtn->getRect().mRight : mJumpLeftArrowBtn->getRect().mLeft, firsttuple->mButton->getRect().mTop, has_scroll_arrows ? mRightArrowBtn->getRect().mLeft : mRightArrowBtn->getRect().mRight, 0 ); @@ -1438,6 +1536,18 @@ BOOL LLTabContainer::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDrag if (has_scroll_arrows) { + if (mJumpLeftArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mJumpLeftArrowBtn->getRect().mLeft; + S32 local_y = y - mJumpLeftArrowBtn->getRect().mBottom; + mJumpLeftArrowBtn->handleHover(local_x, local_y, mask); + } + if (mJumpRightArrowBtn->getRect().pointInRect(x, y)) + { + S32 local_x = x - mJumpRightArrowBtn->getRect().mLeft; + S32 local_y = y - mJumpRightArrowBtn->getRect().mBottom; + mJumpRightArrowBtn->handleHover(local_x, local_y, mask); + } if (mLeftArrowBtn->getRect().pointInRect(x, y)) { S32 local_x = x - mLeftArrowBtn->getRect().mLeft; diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h index 41e602eaea..aa4c1c608a 100644 --- a/indra/llui/lltabcontainer.h +++ b/indra/llui/lltabcontainer.h @@ -109,6 +109,8 @@ public: static void onNextBtnHeld(void* userdata); static void onPrevBtn(void* userdata); static void onPrevBtnHeld(void* userdata); + static void onJumpFirstBtn( void* userdata ); + static void onJumpLastBtn( void* userdata ); virtual void setRightTabBtnOffset( S32 offset ) { } virtual void setPanelTitle(S32 index, const LLString& title) { } @@ -223,7 +225,9 @@ public: protected: LLButton* mLeftArrowBtn; + LLButton* mJumpLeftArrowBtn; LLButton* mRightArrowBtn; + LLButton* mJumpRightArrowBtn; S32 mRightTabBtnOffset; // Extra room to the right of the tab buttons. diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index f6f7067540..2afa32eccd 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -328,7 +328,7 @@ void LLTextBox::draw() void LLTextBox::reshape(S32 width, S32 height, BOOL called_from_parent) { // reparse line lengths - setText(mText); + setLineLengths(); LLView::reshape(width, height, called_from_parent); } diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index f32266faa8..c9a506756a 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -55,6 +55,7 @@ LLImageProviderInterface* LLUI::sImageProvider = NULL; LLUIAudioCallback LLUI::sAudioCallback = NULL; LLVector2 LLUI::sGLScaleFactor(1.f, 1.f); LLWindow* LLUI::sWindow = NULL; +LLHtmlHelp* LLUI::sHtmlHelp = NULL; BOOL LLUI::sShowXUINames = FALSE; // // Functions @@ -387,7 +388,7 @@ void gl_corners_2d(S32 left, S32 top, S32 right, S32 bottom, S32 length, F32 max void gl_draw_image( S32 x, S32 y, LLImageGL* image, const LLColor4& color ) { - gl_draw_scaled_rotated_image( x, y, image->getWidth(), image->getHeight(), 0.f, image, color ); + gl_draw_scaled_rotated_image( x, y, image->getWidth(0), image->getHeight(0), 0.f, image, color ); } void gl_draw_scaled_image(S32 x, S32 y, S32 width, S32 height, LLImageGL* image, const LLColor4& color) @@ -439,8 +440,8 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 border_width, S32 border glColor4fv(color.mV); - F32 border_width_fraction = (F32)border_width / (F32)image->getWidth(); - F32 border_height_fraction = (F32)border_height / (F32)image->getHeight(); + F32 border_width_fraction = (F32)border_width / (F32)image->getWidth(0); + F32 border_height_fraction = (F32)border_height / (F32)image->getHeight(0); glBegin(GL_QUADS); { @@ -573,7 +574,7 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 border_width, S32 border void gl_draw_rotated_image(S32 x, S32 y, F32 degrees, LLImageGL* image, const LLColor4& color) { - gl_draw_scaled_rotated_image( x, y, image->getWidth(), image->getHeight(), degrees, image, color ); + gl_draw_scaled_rotated_image( x, y, image->getWidth(0), image->getHeight(0), degrees, image, color ); } void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degrees, LLImageGL* image, const LLColor4& color) @@ -1766,3 +1767,9 @@ LLUUID LLUI::findAssetUUIDByName(const LLString &asset_name) } return LLUUID( foundValue ); } + +// static +void LLUI::setHtmlHelp(LLHtmlHelp* html_help) +{ + LLUI::sHtmlHelp = html_help; +} diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 282e41a113..c8c244072e 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -15,6 +15,7 @@ #include "llcontrol.h" #include "llrect.h" #include "llcoord.h" +#include "llhtmlhelp.h" class LLColor4; class LLVector3; @@ -151,6 +152,7 @@ public: static void setLineWidth(F32 width); static LLUUID findAssetUUIDByName(const LLString& name); static LLVector2 getWindowSize(); + static void setHtmlHelp(LLHtmlHelp* html_help); public: static LLControlGroup* sConfigGroup; static LLControlGroup* sColorsGroup; @@ -160,6 +162,7 @@ public: static LLVector2 sGLScaleFactor; static LLWindow* sWindow; static BOOL sShowXUINames; + static LLHtmlHelp* sHtmlHelp; }; // UI widgets -- cgit v1.2.3