diff options
Diffstat (limited to 'indra/llui/llfloater.cpp')
-rwxr-xr-x | indra/llui/llfloater.cpp | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 6550eceaa2..770400802c 100755 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -1144,7 +1144,11 @@ void LLFloater::handleReshape(const LLRect& new_rect, bool by_user) if (by_user && !getHost()) { - static_cast<LLFloaterView*>(getParent())->adjustToFitScreen(this, !isMinimized()); + LLFloaterView * floaterVp = dynamic_cast<LLFloaterView*>(getParent()); + if (floaterVp) + { + floaterVp->adjustToFitScreen(this, !isMinimized()); + } } // if not minimized, adjust all snapped dependents to new shape @@ -1355,7 +1359,8 @@ void LLFloater::setFocus( BOOL b ) if (b) { // only push focused floaters to front of stack if not in midst of ctrl-tab cycle - if (!getHost() && !((LLFloaterView*)getParent())->getCycleMode()) + LLFloaterView * parent = dynamic_cast<LLFloaterView *>(getParent()); + if (!getHost() && parent && !parent->getCycleMode()) { if (!isFrontmost()) { @@ -1625,7 +1630,7 @@ void LLFloater::bringToFront( S32 x, S32 y ) } else { - LLFloaterView* parent = (LLFloaterView*) getParent(); + LLFloaterView* parent = dynamic_cast<LLFloaterView*>( getParent() ); if (parent) { parent->bringToFront( this ); @@ -1664,7 +1669,11 @@ void LLFloater::setFrontmost(BOOL take_focus) { // there are more than one floater view // so we need to query our parent directly - ((LLFloaterView*)getParent())->bringToFront(this, take_focus); + LLFloaterView * parent = dynamic_cast<LLFloaterView*>( getParent() ); + if (parent) + { + parent->bringToFront(this, take_focus); + } // Make sure to set the appropriate transparency type (STORM-732). updateTransparency(hasFocus() || getIsChrome() ? TT_ACTIVE : TT_INACTIVE); @@ -2394,6 +2403,9 @@ LLRect LLFloaterView::findNeighboringPosition( LLFloater* reference_floater, LLF void LLFloaterView::bringToFront(LLFloater* child, BOOL give_focus) { + if (!child) + return; + if (mFrontChild == child) { if (give_focus && !gFocusMgr.childHasKeyboardFocus(child)) @@ -2801,29 +2813,26 @@ void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_out } } - const LLRect& left_toolbar_rect = mToolbarRects[LLToolBarEnums::TOOLBAR_LEFT]; - const LLRect& bottom_toolbar_rect = mToolbarRects[LLToolBarEnums::TOOLBAR_BOTTOM]; - const LLRect& right_toolbar_rect = mToolbarRects[LLToolBarEnums::TOOLBAR_RIGHT]; const LLRect& floater_rect = floater->getRect(); - S32 delta_left = left_toolbar_rect.notEmpty() ? left_toolbar_rect.mRight - floater_rect.mRight : 0; - S32 delta_bottom = bottom_toolbar_rect.notEmpty() ? bottom_toolbar_rect.mTop - floater_rect.mTop : 0; - S32 delta_right = right_toolbar_rect.notEmpty() ? right_toolbar_rect.mLeft - floater_rect.mLeft : 0; + S32 delta_left = mToolbarLeftRect.notEmpty() ? mToolbarLeftRect.mRight - floater_rect.mRight : 0; + S32 delta_bottom = mToolbarBottomRect.notEmpty() ? mToolbarBottomRect.mTop - floater_rect.mTop : 0; + S32 delta_right = mToolbarRightRect.notEmpty() ? mToolbarRightRect.mLeft - floater_rect.mLeft : 0; // move window fully onscreen if (floater->translateIntoRect( snap_in_toolbars ? getSnapRect() : gFloaterView->getRect(), allow_partial_outside ? FLOATER_MIN_VISIBLE_PIXELS : S32_MAX )) { floater->clearSnapTarget(); } - else if (delta_left > 0 && floater_rect.mTop < left_toolbar_rect.mTop && floater_rect.mBottom > left_toolbar_rect.mBottom) + else if (delta_left > 0 && floater_rect.mTop < mToolbarLeftRect.mTop && floater_rect.mBottom > mToolbarLeftRect.mBottom) { floater->translate(delta_left, 0); } - else if (delta_bottom > 0 && floater_rect.mLeft > bottom_toolbar_rect.mLeft && floater_rect.mRight < bottom_toolbar_rect.mRight) + else if (delta_bottom > 0 && floater_rect.mLeft > mToolbarBottomRect.mLeft && floater_rect.mRight < mToolbarBottomRect.mRight) { floater->translate(0, delta_bottom); } - else if (delta_right < 0 && floater_rect.mTop < right_toolbar_rect.mTop && floater_rect.mBottom > right_toolbar_rect.mBottom) + else if (delta_right < 0 && floater_rect.mTop < mToolbarRightRect.mTop && floater_rect.mBottom > mToolbarRightRect.mBottom) { floater->translate(delta_right, 0); } @@ -2872,10 +2881,13 @@ LLFloater *LLFloaterView::getFocusedFloater() const { for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) { - LLUICtrl* ctrlp = (*child_it)->isCtrl() ? static_cast<LLUICtrl*>(*child_it) : NULL; - if ( ctrlp && ctrlp->hasFocus() ) + if ((*child_it)->isCtrl()) { - return static_cast<LLFloater *>(ctrlp); + LLFloater* ctrlp = dynamic_cast<LLFloater*>(*child_it); + if ( ctrlp && ctrlp->hasFocus() ) + { + return ctrlp; + } } } return NULL; @@ -3028,9 +3040,20 @@ void LLFloaterView::popVisibleAll(const skip_list_t& skip_list) void LLFloaterView::setToolbarRect(LLToolBarEnums::EToolBarLocation tb, const LLRect& toolbar_rect) { - if (tb < LLToolBarEnums::TOOLBAR_COUNT) + switch (tb) { - mToolbarRects[tb] = toolbar_rect; + case LLToolBarEnums::TOOLBAR_LEFT: + mToolbarLeftRect = toolbar_rect; + break; + case LLToolBarEnums::TOOLBAR_BOTTOM: + mToolbarBottomRect = toolbar_rect; + break; + case LLToolBarEnums::TOOLBAR_RIGHT: + mToolbarRightRect = toolbar_rect; + break; + default: + llwarns << "setToolbarRect() passed odd toolbar number " << (S32) tb << llendl; + break; } } |