Fixup scroll list column header resizing.

This commit is contained in:
Shyotl
2012-12-18 18:27:59 -06:00
parent 184882e916
commit d3939c785d
3 changed files with 21 additions and 2 deletions

View File

@@ -54,6 +54,7 @@ LLResizeBar::LLResizeBar( const std::string& name, LLView* resizing_view, const
mAllowDoubleClickSnapping(TRUE), mAllowDoubleClickSnapping(TRUE),
mResizingView(resizing_view) mResizingView(resizing_view)
{ {
setFollowsNone();
// set up some generically good follow code. // set up some generically good follow code.
switch( side ) switch( side )
{ {
@@ -87,6 +88,8 @@ LLResizeBar::LLResizeBar( const std::string& name, LLView* resizing_view, const
BOOL LLResizeBar::handleMouseDown(S32 x, S32 y, MASK mask) BOOL LLResizeBar::handleMouseDown(S32 x, S32 y, MASK mask)
{ {
if (!canResize()) return FALSE;
// Route future Mouse messages here preemptively. (Release on mouse up.) // Route future Mouse messages here preemptively. (Release on mouse up.)
// No handler needed for focus lost since this clas has no state that depends on it. // No handler needed for focus lost since this clas has no state that depends on it.
gFocusMgr.setMouseCapture( this ); gFocusMgr.setMouseCapture( this );
@@ -240,7 +243,7 @@ BOOL LLResizeBar::handleHover(S32 x, S32 y, MASK mask)
handled = TRUE; handled = TRUE;
} }
if( handled ) if( handled && canResize() )
{ {
switch( mSide ) switch( mSide )
{ {

View File

@@ -52,6 +52,7 @@ public:
void setResizeLimits( S32 min_size, S32 max_size ) { mMinSize = min_size; mMaxSize = max_size; } void setResizeLimits( S32 min_size, S32 max_size ) { mMinSize = min_size; mMaxSize = max_size; }
void setEnableSnapping(BOOL enable) { mSnappingEnabled = enable; } void setEnableSnapping(BOOL enable) { mSnappingEnabled = enable; }
void setAllowDoubleClickSnapping(BOOL allow) { mAllowDoubleClickSnapping = allow; } void setAllowDoubleClickSnapping(BOOL allow) { mAllowDoubleClickSnapping = allow; }
bool canResize() { return getEnabled() && mMaxSize > mMinSize; }
private: private:
S32 mDragLastScreenX; S32 mDragLastScreenX;

View File

@@ -1093,6 +1093,15 @@ BOOL LLScrollListCtrl::addItem( LLScrollListItem* item, EAddPosition pos, BOOL r
addColumn(new_column); addColumn(new_column);
} }
S32 num_cols = item->getNumColumns();
S32 i = 0;
for (LLScrollListCell* cell = item->getColumn(i); i < num_cols; cell = item->getColumn(++i))
{
if (i >= (S32)mColumnsIndexed.size()) break;
cell->setWidth(mColumnsIndexed[i]->getWidth());
}
updateLineHeightInsert(item); updateLineHeightInsert(item);
updateLayout(); updateLayout();
@@ -3898,7 +3907,11 @@ LLScrollColumnHeader::~LLScrollColumnHeader()
void LLScrollColumnHeader::draw() void LLScrollColumnHeader::draw()
{ {
BOOL draw_arrow = !mColumn->mLabel.empty() && mColumn->mParentCtrl->isSorted() && mColumn->mParentCtrl->getSortColumnName() == mColumn->mSortingColumn; std::string sort_column = mColumn->mParentCtrl->getSortColumnName();
BOOL draw_arrow = !mColumn->mLabel.empty()
&& mColumn->mParentCtrl->isSorted()
// check for indirect sorting column as well as column's sorting name
&& (sort_column == mColumn->mSortingColumn || sort_column == mColumn->mName);
BOOL is_ascending = mColumn->mParentCtrl->getSortAscending(); BOOL is_ascending = mColumn->mParentCtrl->getSortAscending();
mButton->setImageOverlay(is_ascending ? "up_arrow.tga" : "down_arrow.tga", LLFontGL::RIGHT, draw_arrow ? LLColor4::white : LLColor4::transparent); mButton->setImageOverlay(is_ascending ? "up_arrow.tga" : "down_arrow.tga", LLFontGL::RIGHT, draw_arrow ? LLColor4::white : LLColor4::transparent);
@@ -4014,6 +4027,7 @@ BOOL LLScrollColumnHeader::handleDoubleClick(S32 x, S32 y, MASK mask)
if (canResize() && mResizeBar->getRect().pointInRect(x, y)) if (canResize() && mResizeBar->getRect().pointInRect(x, y))
{ {
// reshape column to max content width // reshape column to max content width
mColumn->mParentCtrl->calcMaxContentWidth();
LLRect column_rect = getRect(); LLRect column_rect = getRect();
column_rect.mRight = column_rect.mLeft + mColumn->mMaxContentWidth; column_rect.mRight = column_rect.mLeft + mColumn->mMaxContentWidth;
setShape(column_rect,true); setShape(column_rect,true);
@@ -4308,6 +4322,7 @@ void LLScrollColumnHeader::handleReshape(const LLRect& new_rect, bool by_user)
// tell scroll list to layout columns again // tell scroll list to layout columns again
// do immediate update to get proper feedback to resize handle // do immediate update to get proper feedback to resize handle
// which needs to know how far the resize actually went // which needs to know how far the resize actually went
mColumn->mParentCtrl->dirtyColumns(); //Must flag as dirty, else updateColumns will probably be a noop.
mColumn->mParentCtrl->updateColumns(); mColumn->mParentCtrl->updateColumns();
} }
} }