diff options
author | Josh Bell <josh@lindenlab.com> | 2007-02-20 22:02:36 +0000 |
---|---|---|
committer | Josh Bell <josh@lindenlab.com> | 2007-02-20 22:02:36 +0000 |
commit | 7dada07dbaae3dfb9b1319453e51019bfff2717f (patch) | |
tree | a7f2b84ea65c39cee31474640dd5f265c0b2f432 /indra/llui | |
parent | 73bc0fb42b5bcd80030d9f30d5cb57ec2397ba08 (diff) |
svn merge -r 57620:58007 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llfloater.cpp | 34 | ||||
-rw-r--r-- | indra/llui/llfloater.h | 3 | ||||
-rw-r--r-- | indra/llui/llmenugl.cpp | 64 | ||||
-rw-r--r-- | indra/llui/llmenugl.h | 69 | ||||
-rw-r--r-- | indra/llui/llpanel.cpp | 20 | ||||
-rw-r--r-- | indra/llui/llscrolllistctrl.cpp | 67 | ||||
-rw-r--r-- | indra/llui/llscrolllistctrl.h | 41 |
7 files changed, 173 insertions, 125 deletions
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 22d898c5ce..b56ae5167b 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -1218,24 +1218,36 @@ void LLFloater::onClickEdit(void *userdata) } // static -void LLFloater::closeByMenu( void* userdata ) +void LLFloater::closeFocusedFloater() { - LLFloater* self = (LLFloater*) userdata; - if (!self || self->getHost()) return; + LLFloater* focused_floater = NULL; + + std::map<LLViewHandle, LLFloater*>::iterator iter; + for(iter = sFloaterMap.begin(); iter != sFloaterMap.end(); ++iter) + { + focused_floater = iter->second; + if (focused_floater->hasFocus()) + { + break; + } + } - LLFloaterView* parent = (LLFloaterView*) self->getParent(); + if (iter == sFloaterMap.end()) + { + // nothing found, return + return; + } - // grab focus status before close just in case floater is deleted - BOOL has_focus = gFocusMgr.childHasKeyboardFocus(self); - self->close(); + focused_floater->close(); - // if this floater used to have focus and now nothing took focus + // if nothing took focus after closing focused floater // give it to next floater (to allow closing multiple windows via keyboard in rapid succession) - if (has_focus && gFocusMgr.getKeyboardFocus() == NULL) + if (gFocusMgr.getKeyboardFocus() == NULL) { - parent->focusFrontFloater(); + // HACK: use gFloaterView directly in case we are using Ctrl-W to close snapshot window + // which sits in gSnapshotFloaterView, and needs to pass focus on to normal floater view + gFloaterView->focusFrontFloater(); } - } diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index a743081335..05e513ed1d 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -183,7 +183,8 @@ public: /*virtual*/ LLView* getRootMostFastFrameView(); - static void closeByMenu(void *userdata); + static void closeFocusedFloater(); + static void onClickClose(void *userdata); static void onClickMinimize(void *userdata); static void onClickTearOff(void *userdata); diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 7aaa306f05..9161ecb19f 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -1155,70 +1155,6 @@ void LLMenuItemToggleGL::doIt( void ) } -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Class LLMenuItemBranchGL -// -// The LLMenuItemBranchGL represents a menu item that has a -// sub-menu. This is used to make cascading menus. -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -class LLMenuItemBranchGL : public LLMenuItemGL -{ -protected: - LLMenuGL* mBranch; - -public: - LLMenuItemBranchGL( const LLString& name, const LLString& label, LLMenuGL* branch, - KEY key = KEY_NONE, MASK mask = MASK_NONE ); - virtual LLXMLNodePtr getXML(bool save_children = true) const; - - virtual LLView* getChildByName(const LLString& name, BOOL recurse) const; - - virtual LLString getType() const { return "menu"; } - - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; - - virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); - - virtual BOOL handleAcceleratorKey(KEY key, MASK mask); - - // check if we've used these accelerators already - virtual BOOL addToAcceleratorList(std::list <LLKeyBinding*> *listp); - - // called to rebuild the draw label - virtual void buildDrawLabel( void ); - - // doIt() - do the primary funcationality of the menu item. - virtual void doIt( void ); - - virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent); - virtual BOOL handleUnicodeChar(llwchar uni_char, BOOL called_from_parent); - - // set the hover status (called by it's menu) and if the object is - // active. This is used for behavior transfer. - virtual void setHighlight( BOOL highlight ); - - virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); - - virtual BOOL isActive() const; - - virtual BOOL isOpen() const; - - LLMenuGL *getBranch() const { return mBranch; } - - virtual void updateBranchParent( LLView* parentp ); - - // LLView Functionality - virtual void onVisibilityChange( BOOL curVisibilityIn ); - - virtual void draw(); - - virtual void setEnabledSubMenus(BOOL enabled); - - virtual void openMenu(); -}; - LLMenuItemBranchGL::LLMenuItemBranchGL( const LLString& name, const LLString& label, LLMenuGL* branch, KEY key, MASK mask ) : LLMenuItemGL( name, label, key, mask ), diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index d43b4553c3..1b0b844bdc 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -542,6 +542,75 @@ protected: KEY mJumpKey; }; + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLMenuItemBranchGL +// +// The LLMenuItemBranchGL represents a menu item that has a +// sub-menu. This is used to make cascading menus. +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +class LLMenuItemBranchGL : public LLMenuItemGL +{ +protected: + LLMenuGL* mBranch; + +public: + LLMenuItemBranchGL( const LLString& name, const LLString& label, LLMenuGL* branch, + KEY key = KEY_NONE, MASK mask = MASK_NONE ); + virtual LLXMLNodePtr getXML(bool save_children = true) const; + + virtual LLView* getChildByName(const LLString& name, BOOL recurse) const; + + virtual LLString getType() const { return "menu"; } + + virtual EWidgetType getWidgetType() const; + virtual LLString getWidgetTag() const; + + virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); + + virtual BOOL handleAcceleratorKey(KEY key, MASK mask); + + // check if we've used these accelerators already + virtual BOOL addToAcceleratorList(std::list <LLKeyBinding*> *listp); + + // called to rebuild the draw label + virtual void buildDrawLabel( void ); + + // doIt() - do the primary funcationality of the menu item. + virtual void doIt( void ); + + virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent); + virtual BOOL handleUnicodeChar(llwchar uni_char, BOOL called_from_parent); + + // set the hover status (called by it's menu) and if the object is + // active. This is used for behavior transfer. + virtual void setHighlight( BOOL highlight ); + + virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); + + virtual BOOL isActive() const; + + virtual BOOL isOpen() const; + + LLMenuGL *getBranch() const { return mBranch; } + + virtual void updateBranchParent( LLView* parentp ); + + // LLView Functionality + virtual void onVisibilityChange( BOOL curVisibilityIn ); + + virtual void draw(); + + virtual void setEnabledSubMenus(BOOL enabled); + + virtual void openMenu(); +}; + + + + //----------------------------------------------------------------------------- // class LLPieMenu // A circular menu of items, icons, etc. diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 91bf6befe7..de65ce14f6 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -338,16 +338,6 @@ BOOL LLPanel::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ) gFocusMgr.childHasKeyboardFocus(this) && !called_from_parent ) { LLUICtrl* cur_focus = gFocusMgr.getKeyboardFocus(); - if (key == KEY_RETURN && mask == MASK_NONE) - { - // set keyboard focus to self to trigger commitOnFocusLost behavior on current ctrl - if (cur_focus && cur_focus->acceptsTextInput()) - { - cur_focus->onCommit(); - handled = TRUE; - } - } - // If we have a default button, click it when // return is pressed, unless current focus is a return-capturing button // in which case *that* button will handle the return key @@ -363,6 +353,16 @@ BOOL LLPanel::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ) handled = TRUE; } } + + if (key == KEY_RETURN && mask == MASK_NONE) + { + // set keyboard focus to self to trigger commitOnFocusLost behavior on current ctrl + if (cur_focus && cur_focus->acceptsTextInput()) + { + cur_focus->onCommit(); + handled = TRUE; + } + } } return handled; diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 2b7cbe5cef..c168bbe5a8 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -137,10 +137,11 @@ BOOL LLScrollListCheck::handleClick() // U32 LLScrollListText::sCount = 0; -LLScrollListText::LLScrollListText( const LLString& text, const LLFontGL* font, S32 width, U8 font_style, LLColor4& color, BOOL use_color, BOOL visible) +LLScrollListText::LLScrollListText( const LLString& text, const LLFontGL* font, S32 width, U8 font_style, LLFontGL::HAlign font_alignment, LLColor4& color, BOOL use_color, BOOL visible) : mText( text ), mFont( font ), mFontStyle( font_style ), + mFontAlignment( font_alignment ), mWidth( width ), mVisible( visible ), mHighlightCount( 0 ), @@ -163,10 +164,6 @@ LLScrollListText::LLScrollListText( const LLString& text, const LLFontGL* font, { mRoundedRectImage = LLUI::sImageProvider->getUIImageByID(LLUUID(LLUI::sAssetsGroup->getString("rounded_square.tga"))); } - - // Yes, that's four dots, because we want it to have a little - // padding, in proportion to the font size. - mEllipsisWidth = (S32)mFont->getWidth("...."); } LLScrollListText::~LLScrollListText() @@ -202,7 +199,19 @@ void LLScrollListText::drawToWidth(S32 width, const LLColor4& color, const LLCol { mRoundedRectImage->bind(); glColor4fv(highlight_color.mV); - S32 left = mFont->getWidth(mText.getString(), 0, mHighlightOffset); + S32 left = 0; + switch(mFontAlignment) + { + case LLFontGL::LEFT: + left = mFont->getWidth(mText.getString(), 0, mHighlightOffset); + break; + case LLFontGL::RIGHT: + left = width - mFont->getWidth(mText.getString(), mHighlightOffset, S32_MAX); + break; + case LLFontGL::HCENTER: + left = (width - mFont->getWidth(mText.getString())) / 2; + break; + } gl_segmented_rect_2d_tex(left - 2, llround(mFont->getLineHeight()) + 1, left + mFont->getWidth(mText.getString(), mHighlightOffset, mHighlightCount) + 1, @@ -215,21 +224,28 @@ void LLScrollListText::drawToWidth(S32 width, const LLColor4& color, const LLCol // Try to draw the entire string F32 right_x; U32 string_chars = mText.length(); - U32 drawn_chars = mFont->render(mText.getWString(), 0, 0, 2, - *display_color, - LLFontGL::LEFT, - LLFontGL::BOTTOM, - mFontStyle, - string_chars, - width - mEllipsisWidth, - &right_x, FALSE); - - // If we didn't get the whole string, abbreviate - if (drawn_chars < string_chars && drawn_chars) - { - mFont->renderUTF8("...", 0, right_x, 0.f, color, LLFontGL::LEFT, LLFontGL::BOTTOM, mFontStyle, - S32_MAX, S32_MAX, NULL, FALSE); - } + F32 start_x = 0.f; + switch(mFontAlignment) + { + case LLFontGL::LEFT: + start_x = 0.f; + break; + case LLFontGL::RIGHT: + start_x = (F32)width; + break; + case LLFontGL::HCENTER: + start_x = (F32)width * 0.5f; + break; + } + mFont->render(mText.getWString(), 0, + start_x, 2.f, + *display_color, + mFontAlignment, + LLFontGL::BOTTOM, + mFontStyle, + string_chars, + width, + &right_x, FALSE, TRUE); } @@ -2171,7 +2187,7 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac NULL, multi_select, draw_border); - + scroll_list->setDisplayHeading(draw_heading); if (node->hasAttribute("heading_height")) { @@ -2226,6 +2242,8 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac F32 columnrelwidth = 0.f; child->getAttributeF32("relwidth", columnrelwidth); + LLFontGL::HAlign h_align = LLFontGL::LEFT; + h_align = LLView::selectFontHAlign(child); columns[index]["name"] = columnname; columns[index]["sort"] = sortname; @@ -2234,6 +2252,7 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac columns[index]["width"] = columnwidth; columns[index]["relwidth"] = columnrelwidth; columns[index]["dynamicwidth"] = columndynamicwidth; + columns[index]["halign"] = (S32)h_align; index++; } } @@ -2580,6 +2599,7 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p S32 index = column_itor->second.mIndex; S32 width = column_itor->second.mWidth; + LLFontGL::HAlign font_alignment = column_itor->second.mFontAlignment; LLSD value = (*itor)["value"]; LLString fontname = (*itor)["font"].asString(); @@ -2607,7 +2627,7 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p } else { - new_item->setColumn(index, new LLScrollListText(value.asString(), font, width, font_style)); + new_item->setColumn(index, new LLScrollListText(value.asString(), font, width, font_style, font_alignment)); } } @@ -2715,3 +2735,4 @@ void LLScrollListCtrl::onFocusLost() } } } + diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h index 985ccc12a5..9c16e4dff9 100644 --- a/indra/llui/llscrolllistctrl.h +++ b/indra/llui/llscrolllistctrl.h @@ -46,9 +46,8 @@ public: class LLScrollListText : public LLScrollListCell { - static U32 sCount; public: - LLScrollListText( const LLString& text, const LLFontGL* font, S32 width = 0, U8 font_style = LLFontGL::NORMAL, LLColor4& color = LLColor4::black, BOOL use_color = FALSE, BOOL visible = TRUE); + LLScrollListText( const LLString& text, const LLFontGL* font, S32 width = 0, U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, LLColor4& color = LLColor4::black, BOOL use_color = FALSE, BOOL visible = TRUE); /*virtual*/ ~LLScrollListText(); virtual void drawToWidth(S32 width, const LLColor4& color, const LLColor4& highlight_color) const; @@ -65,13 +64,15 @@ private: const LLFontGL* mFont; LLColor4* mColor; const U8 mFontStyle; + LLFontGL::HAlign mFontAlignment; S32 mWidth; - S32 mEllipsisWidth; // in pixels, of "..." BOOL mVisible; S32 mHighlightCount; S32 mHighlightOffset; LLPointer<LLImageGL> mRoundedRectImage; + + static U32 sCount; }; class LLScrollListIcon : public LLScrollListCell @@ -116,9 +117,10 @@ class LLScrollListColumn { public: // Default constructor - LLScrollListColumn() : mName(""), mSortingColumn(""), mLabel(""), mWidth(-1), mRelWidth(-1.0), mDynamicWidth(FALSE), mIndex(-1), mParentCtrl(NULL), mButton(NULL) { } + LLScrollListColumn() : mName(""), mSortingColumn(""), mLabel(""), mWidth(-1), mRelWidth(-1.0), mDynamicWidth(FALSE), mIndex(-1), mParentCtrl(NULL), mButton(NULL), mFontAlignment(LLFontGL::LEFT) + { } - LLScrollListColumn(LLString name, LLString label, S32 width, F32 relwidth) + LLScrollListColumn(LLString name, LLString label, S32 width, F32 relwidth) : mName(name), mSortingColumn(name), mLabel(label), mWidth(width), mRelWidth(relwidth), mDynamicWidth(FALSE), mIndex(-1), mParentCtrl(NULL), mButton(NULL) { } LLScrollListColumn(const LLSD &sd) @@ -150,20 +152,27 @@ public: mDynamicWidth = FALSE; mRelWidth = -1; } + + if (sd.has("halign")) + { + mFontAlignment = (LLFontGL::HAlign)llclamp(sd.get("halign").asInteger(), (S32)LLFontGL::LEFT, (S32)LLFontGL::HCENTER); + } + mIndex = -1; mParentCtrl = NULL; mButton = NULL; } - LLString mName; - LLString mSortingColumn; - LLString mLabel; - S32 mWidth; - F32 mRelWidth; - BOOL mDynamicWidth; - S32 mIndex; - LLScrollListCtrl *mParentCtrl; - LLButton *mButton; + LLString mName; + LLString mSortingColumn; + LLString mLabel; + S32 mWidth; + F32 mRelWidth; + BOOL mDynamicWidth; + S32 mIndex; + LLScrollListCtrl* mParentCtrl; + LLButton* mButton; + LLFontGL::HAlign mFontAlignment; }; class LLScrollListItem @@ -190,8 +199,8 @@ public: // If width = 0, just use the width of the text. Otherwise override with // specified width in pixels. - void addColumn( const LLString& text, const LLFontGL* font, S32 width = 0 , U8 font_style = LLFontGL::NORMAL, BOOL visible = TRUE) - { mColumns.push_back( new LLScrollListText(text, font, width, font_style, LLColor4::black, FALSE, visible) ); } + void addColumn( const LLString& text, const LLFontGL* font, S32 width = 0 , U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, BOOL visible = TRUE) + { mColumns.push_back( new LLScrollListText(text, font, width, font_style, font_alignment, LLColor4::black, FALSE, visible) ); } void addColumn( LLImageGL* icon, S32 width = 0 ) { mColumns.push_back( new LLScrollListIcon(icon, width) ); } |