summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2007-02-05 20:20:42 +0000
committerSteven Bennetts <steve@lindenlab.com>2007-02-05 20:20:42 +0000
commitd1582a5105f01181535fb859c530e45c2efca071 (patch)
treef8c6939e2c67d64d7be0e2488af296b42f13800d /indra/llui
parent57be416ab7c9d93196231fb55de8ba563f3b29eb (diff)
merge -r 57111:57464 maintenance.
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llfloater.cpp12
-rw-r--r--indra/llui/llmenugl.cpp97
-rw-r--r--indra/llui/llmenugl.h9
-rw-r--r--indra/llui/llscrolllistctrl.cpp45
-rw-r--r--indra/llui/llscrolllistctrl.h7
5 files changed, 100 insertions, 70 deletions
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index b37602093f..8dc0ce5f66 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -506,7 +506,8 @@ void LLFloater::open() /* Flawfinder: ignore */
if (sHostp != NULL && hostp == NULL)
{
// needs a host
- sHostp->addFloater(this, TRUE);
+ // only select tabs if window they are hosted in is visible
+ sHostp->addFloater(this, sHostp->getVisible());
}
else if (hostp != NULL)
{
@@ -2578,8 +2579,6 @@ void LLMultiFloater::addFloater(LLFloater* floaterp, BOOL select_added_floater,
if ( select_added_floater )
{
mTabContainer->selectLastTab();
- // explicitly call tabopen to load preview assets, etc.
- tabOpen((LLFloater*)mTabContainer->getCurrentPanel(), true);
}
floaterp->setHost(this);
@@ -2702,6 +2701,13 @@ void LLMultiFloater::setVisible(BOOL visible)
{
cur_floaterp->setVisible(visible);
}
+
+ // if no tab selected, and we're being shown,
+ // select last tab to be added
+ if (visible && !cur_floaterp)
+ {
+ mTabContainer->selectLastTab();
+ }
}
}
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index b2225aa1a0..6ec0719ad5 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -43,7 +43,7 @@
#include <boost/tokenizer.hpp>
// static
-LLView *LLMenuGL::sDefaultMenuContainer = NULL;
+LLMenuHolderGL *LLMenuGL::sMenuContainer = NULL;
S32 MENU_BAR_HEIGHT = 0;
S32 MENU_BAR_WIDTH = 0;
@@ -392,7 +392,7 @@ void LLMenuItemGL::doIt( void )
&& !getMenu()->getTornOff()
&& getMenu()->getVisible())
{
- ((LLMenuHolderGL*)getMenu()->getParent())->hideMenus();
+ LLMenuGL::sMenuContainer->hideMenus();
}
}
@@ -454,18 +454,28 @@ BOOL LLMenuItemGL::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent )
BOOL LLMenuItemGL::handleMouseUp( S32 x, S32 y, MASK )
{
- //llinfos << mLabel.c_str() << " handleMouseUp " << x << "," << y
- // << llendl;
if (mEnabled)
{
// switch to mouse navigation mode
LLMenuGL::setKeyboardMode(FALSE);
doIt();
- setHighlight(FALSE);
make_ui_sound("UISndClickRelease");
return TRUE;
}
+ return FALSE;
+}
+
+BOOL LLMenuItemGL::handleMouseDown( S32 x, S32 y, MASK )
+{
+ if (mEnabled)
+ {
+ // switch to mouse navigation mode
+ LLMenuGL::setKeyboardMode(FALSE);
+
+ setHighlight(TRUE);
+ return TRUE;
+ }
else
{
return FALSE;
@@ -1483,6 +1493,9 @@ void LLMenuItemBranchGL::openMenu()
}
else if( !mBranch->getVisible() )
{
+ // get valid rectangle for menus
+ const LLRect menu_region_rect = LLMenuGL::sMenuContainer->getMenuRect();
+
mBranch->arrange();
LLRect rect = mBranch->getRect();
@@ -1505,13 +1518,13 @@ void LLMenuItemBranchGL::openMenu()
mBranch->localPointToOtherView( 0, 0, &x, &y, mBranch->getParent() );
S32 delta_x = 0;
S32 delta_y = 0;
- if( y < 0 )
+ if( y < menu_region_rect.mBottom )
{
- delta_y = -y;
+ delta_y = menu_region_rect.mBottom - y;
}
- S32 window_width = mBranch->getParent()->getRect().getWidth();
- if( x > window_width - rect.getWidth() )
+ S32 menu_region_width = menu_region_rect.getWidth();
+ if( x - menu_region_rect.mLeft > menu_region_width - rect.getWidth() )
{
// move sub-menu over to left side
delta_x = llmax(-x, (-1 * (rect.getWidth() + mRect.getWidth())));
@@ -1942,9 +1955,9 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory
// SUBMENU
LLMenuGL *submenu = (LLMenuGL*)LLMenuGL::fromXML(child, parent, factory);
appendMenu(submenu);
- if (LLMenuGL::sDefaultMenuContainer != NULL)
+ if (LLMenuGL::sMenuContainer != NULL)
{
- submenu->updateParent(LLMenuGL::sDefaultMenuContainer);
+ submenu->updateParent(LLMenuGL::sMenuContainer);
}
else
{
@@ -2331,8 +2344,10 @@ void LLMenuGL::arrange( void )
if( mItems.size() )
{
- U32 max_width = (getParent() != NULL) ? getParent()->getRect().getWidth() : U32_MAX;
- U32 max_height = (getParent() != NULL) ? getParent()->getRect().getHeight() : U32_MAX;
+ const LLRect menu_region_rect = LLMenuGL::sMenuContainer ? LLMenuGL::sMenuContainer->getMenuRect() : LLRect(0, S32_MAX, S32_MAX, 0);
+
+ U32 max_width = menu_region_rect.getWidth();
+ U32 max_height = menu_region_rect.getHeight();
// *FIX: create the item first and then ask for its dimensions?
S32 spillover_item_width = PLAIN_PAD_PIXELS + LLFontGL::sSansSerif->getWidth( "More" );
S32 spillover_item_height = llround(LLFontGL::sSansSerif->getLineHeight()) + MENU_ITEM_PADDING;
@@ -2453,7 +2468,7 @@ void LLMenuGL::createSpilloverBranch()
// technically, you can't tear off spillover menus, but we're passing the handle
// along just to be safe
mSpilloverMenu = new LLMenuGL("More", "More", mParentFloaterHandle);
- mSpilloverMenu->updateParent(getParent());
+ mSpilloverMenu->updateParent(LLMenuGL::sMenuContainer);
// Inherit colors
mSpilloverMenu->setBackgroundColor( mBackgroundColor );
mSpilloverMenu->setCanTearOff(FALSE);
@@ -3138,6 +3153,8 @@ void hide_top_view( LLView* view )
// static
void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y)
{
+ const LLRect menu_region_rect = LLMenuGL::sMenuContainer->getMenuRect();
+
const S32 HPAD = 2;
LLRect rect = menu->getRect();
//LLView* cur_view = spawning_view;
@@ -3158,13 +3175,15 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y)
// &left, &bottom );
S32 delta_x = 0;
S32 delta_y = 0;
- if( bottom < 0 )
+ if( bottom < menu_region_rect.mBottom )
{
- delta_y = -bottom;
+ // At this point, we need to move the context menu to the
+ // other side of the mouse.
+ //delta_y = menu_region_rect.mBottom - bottom;
+ delta_y = (rect.getHeight() + 2 * HPAD);
}
- S32 parent_width = menu->getParent()->getRect().getWidth();
- if( left > parent_width - rect.getWidth() )
+ if( left > menu_region_rect.mRight - rect.getWidth() )
{
// At this point, we need to move the context menu to the
// other side of the mouse.
@@ -3536,7 +3555,7 @@ BOOL LLPieMenu::handleMouseUp( S32 x, S32 y, MASK mask )
if (!handled && !mUseInfiniteRadius)
{
// call hidemenus to make sure transient selections get cleared
- ((LLMenuHolderGL*)getParent())->hideMenus();
+ sMenuContainer->hideMenus();
}
if (mFirstMouseDown)
@@ -3847,10 +3866,9 @@ void LLPieMenu::show(S32 x, S32 y, BOOL mouse_down)
S32 width = mRect.getWidth();
S32 height = mRect.getHeight();
- LLView* parent_view = getParent();
- S32 menu_region_width = parent_view->getRect().getWidth();
- S32 menu_region_height = parent_view->getRect().getHeight();
+ const LLRect menu_region_rect = LLMenuGL::sMenuContainer->getMenuRect();
+ LLView* parent_view = getParent();
BOOL moved = FALSE;
S32 local_x, local_y;
@@ -3860,36 +3878,36 @@ void LLPieMenu::show(S32 x, S32 y, BOOL mouse_down)
arrange();
// Adjust the pie rectangle to keep it on screen
- if (mRect.mLeft < 0)
+ if (mRect.mLeft < menu_region_rect.mLeft)
{
- //mShiftHoriz = 0 - mRect.mLeft;
+ //mShiftHoriz = menu_region_rect.mLeft - mRect.mLeft;
//mRect.translate( mShiftHoriz, 0 );
- mRect.translate( 0 - mRect.mLeft, 0 );
+ mRect.translate( menu_region_rect.mLeft - mRect.mLeft, 0 );
moved = TRUE;
}
- if (mRect.mRight > menu_region_width)
+ if (mRect.mRight > menu_region_rect.mRight)
{
- //mShiftHoriz = menu_region_width - mRect.mRight;
+ //mShiftHoriz = menu_region_rect.mRight - mRect.mRight;
//mRect.translate( mShiftHoriz, 0);
- mRect.translate( menu_region_width - mRect.mRight, 0 );
+ mRect.translate( menu_region_rect.mRight - mRect.mRight, 0 );
moved = TRUE;
}
- if (mRect.mBottom < 0)
+ if (mRect.mBottom < menu_region_rect.mBottom)
{
- //mShiftVert = -mRect.mBottom;
+ //mShiftVert = menu_region_rect.mBottom - mRect.mBottom;
//mRect.translate( 0, mShiftVert );
- mRect.translate( 0, 0 - mRect.mBottom );
+ mRect.translate( 0, menu_region_rect.mBottom - mRect.mBottom );
moved = TRUE;
}
- if (mRect.mTop > menu_region_height)
+ if (mRect.mTop > menu_region_rect.mTop)
{
- //mShiftVert = menu_region_height - mRect.mTop;
+ //mShiftVert = menu_region_rect.mTop - mRect.mTop;
//mRect.translate( 0, mShiftVert );
- mRect.translate( 0, menu_region_height - mRect.mTop );
+ mRect.translate( 0, menu_region_rect.mTop - mRect.mTop );
moved = TRUE;
}
@@ -4048,9 +4066,9 @@ LLView* LLMenuBarGL::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory
menu->setCanTearOff(TRUE, parent_handle);
}
menubar->appendMenu(menu);
- if (LLMenuGL::sDefaultMenuContainer != NULL)
+ if (LLMenuGL::sMenuContainer != NULL)
{
- menu->updateParent(LLMenuGL::sDefaultMenuContainer);
+ menu->updateParent(LLMenuGL::sMenuContainer);
}
else
{
@@ -4411,7 +4429,7 @@ void LLMenuHolderGL::reshape(S32 width, S32 height, BOOL called_from_parent)
LLView::reshape(width, height, called_from_parent);
}
-BOOL LLMenuHolderGL::hasVisibleMenu()
+BOOL LLMenuHolderGL::hasVisibleMenu() const
{
for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
{
@@ -4424,6 +4442,11 @@ BOOL LLMenuHolderGL::hasVisibleMenu()
return FALSE;
}
+const LLRect LLMenuHolderGL::getMenuRect() const
+{
+ return getLocalRect();
+}
+
BOOL LLMenuHolderGL::hideMenus()
{
if (!mCanHide)
diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h
index b9f7d033ac..d43b4553c3 100644
--- a/indra/llui/llmenugl.h
+++ b/indra/llui/llmenugl.h
@@ -22,6 +22,7 @@
#include "llview.h"
class LLMenuItemGL;
+class LLMenuHolderGL;
extern S32 MENU_BAR_HEIGHT;
extern S32 MENU_BAR_WIDTH;
@@ -144,6 +145,7 @@ public:
// LLView Functionality
virtual BOOL handleKeyHere( KEY key, MASK mask, BOOL called_from_parent );
+ virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask );
virtual void draw( void );
@@ -504,7 +506,8 @@ public:
static BOOL getKeyboardMode() { return sKeyboardMode; }
static void onFocusLost(LLView* old_focus);
- static LLView *sDefaultMenuContainer;
+
+ static LLMenuHolderGL* sMenuContainer;
protected:
void createSpilloverBranch();
@@ -679,8 +682,10 @@ public:
virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
+ virtual const LLRect getMenuRect() const;
+ virtual BOOL hasVisibleMenu() const;
+
static void setActivatedItem(LLMenuItemGL* item);
- BOOL hasVisibleMenu();
protected:
static LLViewHandle sItemLastSelectedHandle;
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp
index 95ea2cbc37..d263c25c72 100644
--- a/indra/llui/llscrolllistctrl.cpp
+++ b/indra/llui/llscrolllistctrl.cpp
@@ -143,7 +143,8 @@ LLScrollListText::LLScrollListText( const LLString& text, const LLFontGL* font,
mFontStyle( font_style ),
mWidth( width ),
mVisible( visible ),
- mHighlightChars( 0 )
+ mHighlightCount( 0 ),
+ mHighlightOffset( 0 )
{
if (use_color)
{
@@ -197,13 +198,14 @@ void LLScrollListText::drawToWidth(S32 width, const LLColor4& color, const LLCol
display_color = &color;
}
- if (mHighlightChars > 0)
+ if (mHighlightCount > 0)
{
mRoundedRectImage->bind();
glColor4fv(highlight_color.mV);
- gl_segmented_rect_2d_tex(-2,
+ S32 left = mFont->getWidth(mText.getString(), 0, mHighlightOffset);
+ gl_segmented_rect_2d_tex(left - 2,
llround(mFont->getLineHeight()) + 1,
- mFont->getWidth(mText.getString(), 0, mHighlightChars) + 1,
+ left + mFont->getWidth(mText.getString(), mHighlightOffset, mHighlightCount) + 1,
1,
mRoundedRectImage->getWidth(),
mRoundedRectImage->getHeight(),
@@ -1141,11 +1143,17 @@ BOOL LLScrollListCtrl::selectSimpleItemByPrefix(const LLWString& target, BOOL ca
{
LLWString::toLower(item_label);
}
+ // remove extraneous whitespace from searchable label
+ LLWString trimmed_label = item_label;
+ LLWString::trim(trimmed_label);
- BOOL select = item->getEnabled() && !item_label.compare(0, target_len, target_trimmed);
+ BOOL select = item->getEnabled() && trimmed_label.compare(0, target_trimmed.size(), target_trimmed) == 0;
if (select)
{
+ // find offset of matching text (might have leading whitespace)
+ S32 offset = item_label.find(target_trimmed);
+ cellp->highlightText(offset, target_trimmed.size());
selectItem(item);
found = TRUE;
break;
@@ -1447,6 +1455,9 @@ BOOL LLScrollListCtrl::handleMouseDown(S32 x, S32 y, MASK mask)
{
BOOL handled = LLView::childrenHandleMouseDown(x, y, mask) != NULL;
+ // set keyboard focus first, in case click action wants to move focus elsewhere
+ setFocus(TRUE);
+
if( !handled && mCanSelect)
{
LLScrollListItem* hit_item = hitItem(x, y);
@@ -1539,8 +1550,6 @@ BOOL LLScrollListCtrl::handleMouseDown(S32 x, S32 y, MASK mask)
}
}
- gFocusMgr.setKeyboardFocus(this, NULL);
-
return TRUE;
}
@@ -1739,7 +1748,7 @@ BOOL LLScrollListCtrl::handleKeyHere(KEY key,MASK mask, BOOL called_from_parent
LLScrollListCell* cellp = getFirstSelected()->getColumn(mSearchColumn);
if (cellp)
{
- cellp->highlightText(0);
+ cellp->highlightText(0, 0);
}
}
}
@@ -1748,13 +1757,6 @@ BOOL LLScrollListCtrl::handleKeyHere(KEY key,MASK mask, BOOL called_from_parent
// update search string only on successful match
mSearchTimer.reset();
- // highlight current search on matching item
- LLScrollListCell* cellp = getFirstSelected()->getColumn(mSearchColumn);
- if (cellp)
- {
- cellp->highlightText(mSearchString.size());
- }
-
if (mCommitOnKeyboardMovement
&& !mCommitOnSelectionChange)
{
@@ -1794,13 +1796,6 @@ BOOL LLScrollListCtrl::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_
mSearchString += uni_char;
mSearchTimer.reset();
- // highlight current search on matching item
- LLScrollListCell* cellp = getFirstSelected()->getColumn(mSearchColumn);
- if (cellp)
- {
- cellp->highlightText(mSearchString.size());
- }
-
if (mCommitOnKeyboardMovement
&& !mCommitOnSelectionChange)
{
@@ -1843,7 +1838,7 @@ BOOL LLScrollListCtrl::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_
if (item->getEnabled() && LLStringOps::toLower(item_label[0]) == uni_char)
{
selectItem(item);
- cellp->highlightText(1);
+ cellp->highlightText(0, 1);
mSearchTimer.reset();
if (mCommitOnKeyboardMovement
@@ -1906,7 +1901,7 @@ void LLScrollListCtrl::selectItem(LLScrollListItem* itemp, BOOL select_single_it
LLScrollListCell* cellp = mLastSelected->getColumn(mSearchColumn);
if (cellp)
{
- cellp->highlightText(0);
+ cellp->highlightText(0, 0);
}
}
if (select_single_item)
@@ -1934,7 +1929,7 @@ void LLScrollListCtrl::deselectItem(LLScrollListItem* itemp)
LLScrollListCell* cellp = itemp->getColumn(mSearchColumn);
if (cellp)
{
- cellp->highlightText(0);
+ cellp->highlightText(0, 0);
}
mSelectionChanged = TRUE;
}
diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h
index 805efe8679..985ccc12a5 100644
--- a/indra/llui/llscrolllistctrl.h
+++ b/indra/llui/llscrolllistctrl.h
@@ -38,7 +38,7 @@ public:
virtual const LLString& getTextLower() const { return LLString::null; }
virtual const BOOL getVisible() const { return TRUE; }
virtual void setWidth(S32 width) = 0;
- virtual void highlightText(S32 num_chars) {}
+ virtual void highlightText(S32 offset, S32 num_chars) {}
virtual BOOL handleClick() { return FALSE; }
virtual void setEnabled(BOOL enable) { }
@@ -57,7 +57,7 @@ public:
virtual S32 getHeight() const { return llround(mFont->getLineHeight()); }
virtual const LLString& getText() const { return mText.getString(); }
virtual const BOOL getVisible() const { return mVisible; }
- virtual void highlightText(S32 num_chars) {mHighlightChars = num_chars;}
+ virtual void highlightText(S32 offset, S32 num_chars) {mHighlightOffset = offset; mHighlightCount = num_chars;}
void setText(const LLString& text);
private:
@@ -68,7 +68,8 @@ private:
S32 mWidth;
S32 mEllipsisWidth; // in pixels, of "..."
BOOL mVisible;
- S32 mHighlightChars;
+ S32 mHighlightCount;
+ S32 mHighlightOffset;
LLPointer<LLImageGL> mRoundedRectImage;
};