aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llpanel.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:27 -0500
committerJacek Antonelli2008-08-15 23:45:27 -0500
commita8a62201ba762e98dff92cf49033e577fc34d8d4 (patch)
tree11f8513c5cdc222f2fac0c93eb724c089803c200 /linden/indra/llui/llpanel.cpp
parentSecond Life viewer sources 1.18.6.4-RC (diff)
downloadmeta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.zip
meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.gz
meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.bz2
meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.xz
Second Life viewer sources 1.19.0.0
Diffstat (limited to '')
-rw-r--r--linden/indra/llui/llpanel.cpp236
1 files changed, 133 insertions, 103 deletions
diff --git a/linden/indra/llui/llpanel.cpp b/linden/indra/llui/llpanel.cpp
index 2c37dfd..af8aa21 100644
--- a/linden/indra/llui/llpanel.cpp
+++ b/linden/indra/llui/llpanel.cpp
@@ -12,12 +12,12 @@
12 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of 13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or 14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlife.com/developers/opensource/gplv2 15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 * 16 *
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlife.com/developers/opensource/flossexception 20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 21 *
22 * By copying, modifying or distributing this software, you acknowledge 22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 23 * that you have read and understood your obligations described above,
@@ -64,7 +64,6 @@ LLPanel::panel_map_t LLPanel::sPanelMap;
64LLPanel::alert_queue_t LLPanel::sAlertQueue; 64LLPanel::alert_queue_t LLPanel::sAlertQueue;
65 65
66const S32 RESIZE_BAR_OVERLAP = 1; 66const S32 RESIZE_BAR_OVERLAP = 1;
67const S32 PANEL_STACK_GAP = RESIZE_BAR_HEIGHT;
68 67
69void LLPanel::init() 68void LLPanel::init()
70{ 69{
@@ -88,6 +87,7 @@ LLPanel::LLPanel()
88: mRectControl() 87: mRectControl()
89{ 88{
90 init(); 89 init();
90 setName("panel");
91} 91}
92 92
93LLPanel::LLPanel(const LLString& name) 93LLPanel::LLPanel(const LLString& name)
@@ -124,6 +124,7 @@ LLPanel::LLPanel(const LLString& name, const LLString& rect_control, BOOL border
124void LLPanel::addBorder(LLViewBorder::EBevel border_bevel, 124void LLPanel::addBorder(LLViewBorder::EBevel border_bevel,
125 LLViewBorder::EStyle border_style, S32 border_thickness) 125 LLViewBorder::EStyle border_style, S32 border_thickness)
126{ 126{
127 removeBorder();
127 mBorder = new LLViewBorder( "panel border", 128 mBorder = new LLViewBorder( "panel border",
128 LLRect(0, mRect.getHeight(), mRect.getWidth(), 0), 129 LLRect(0, mRect.getHeight(), mRect.getWidth(), 0),
129 border_bevel, border_style, border_thickness ); 130 border_bevel, border_style, border_thickness );
@@ -339,11 +340,6 @@ void LLPanel::addCtrl( LLUICtrl* ctrl, S32 tab_group)
339 mLastTabGroup = tab_group; 340 mLastTabGroup = tab_group;
340 341
341 LLView::addCtrl(ctrl, tab_group); 342 LLView::addCtrl(ctrl, tab_group);
342 // propagate chrome to children only if they have not been flagged as chrome
343 if (!ctrl->getIsChrome())
344 {
345 ctrl->setIsChrome(getIsChrome());
346 }
347} 343}
348 344
349void LLPanel::addCtrlAtEnd( LLUICtrl* ctrl, S32 tab_group) 345void LLPanel::addCtrlAtEnd( LLUICtrl* ctrl, S32 tab_group)
@@ -351,22 +347,12 @@ void LLPanel::addCtrlAtEnd( LLUICtrl* ctrl, S32 tab_group)
351 mLastTabGroup = tab_group; 347 mLastTabGroup = tab_group;
352 348
353 LLView::addCtrlAtEnd(ctrl, tab_group); 349 LLView::addCtrlAtEnd(ctrl, tab_group);
354 if (!ctrl->getIsChrome())
355 {
356 ctrl->setIsChrome(getIsChrome());
357 }
358} 350}
359 351
360BOOL LLPanel::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ) 352BOOL LLPanel::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent )
361{ 353{
362 BOOL handled = FALSE; 354 BOOL handled = FALSE;
363 355
364 if( getVisible() && getEnabled() && gFocusMgr.childHasKeyboardFocus(this) && KEY_ESCAPE == key )
365 {
366 gFocusMgr.setKeyboardFocus(NULL, NULL);
367 return TRUE;
368 }
369
370 if( getVisible() && getEnabled() && 356 if( getVisible() && getEnabled() &&
371 gFocusMgr.childHasKeyboardFocus(this) && !called_from_parent ) 357 gFocusMgr.childHasKeyboardFocus(this) && !called_from_parent )
372 { 358 {
@@ -472,7 +458,7 @@ void LLPanel::setFocus(BOOL b)
472 { 458 {
473 if( this == gFocusMgr.getKeyboardFocus() ) 459 if( this == gFocusMgr.getKeyboardFocus() )
474 { 460 {
475 gFocusMgr.setKeyboardFocus( NULL, NULL ); 461 gFocusMgr.setKeyboardFocus( NULL );
476 } 462 }
477 else 463 else
478 { 464 {
@@ -595,7 +581,8 @@ LLView* LLPanel::fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory *fac
595 { 581 {
596 LLRect rect; 582 LLRect rect;
597 createRect(node, rect, parent, LLRect()); 583 createRect(node, rect, parent, LLRect());
598 panelp = new LLPanel(name, rect); 584 // create a new panel without a border, by default
585 panelp = new LLPanel(name, rect, FALSE);
599 panelp->initPanelXML(node, parent, factory); 586 panelp->initPanelXML(node, parent, factory);
600 // preserve panel's width and height, but override the location 587 // preserve panel's width and height, but override the location
601 const LLRect& panelrect = panelp->getRect(); 588 const LLRect& panelrect = panelp->getRect();
@@ -608,12 +595,13 @@ LLView* LLPanel::fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory *fac
608 { 595 {
609 panelp->initPanelXML(node, parent, factory); 596 panelp->initPanelXML(node, parent, factory);
610 } 597 }
598
611 return panelp; 599 return panelp;
612} 600}
613 601
614BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) 602BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
615{ 603{
616 LLString name("panel"); 604 LLString name = getName();
617 node->getAttributeString("name", name); 605 node->getAttributeString("name", name);
618 setName(name); 606 setName(name);
619 607
@@ -628,13 +616,15 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *f
628 616
629 if (!xml_filename.empty()) 617 if (!xml_filename.empty())
630 { 618 {
631 // Preserve postion of embedded panel but allow panel to dictate width/height
632 LLRect rect(getRect());
633 didPost = factory->buildPanel(this, xml_filename, NULL); 619 didPost = factory->buildPanel(this, xml_filename, NULL);
634 S32 w = getRect().getWidth(); 620
635 S32 h = getRect().getHeight(); 621 LLRect new_rect = getRect();
636 rect.setLeftTopAndSize(rect.mLeft, rect.mTop, w, h); 622 // override rectangle with embedding parameters as provided
637 setRect(rect); 623 createRect(node, new_rect, parent);
624 setOrigin(new_rect.mLeft, new_rect.mBottom);
625 reshape(new_rect.getWidth(), new_rect.getHeight());
626 // optionally override follows flags from including nodes
627 parseFollowsFlags(node);
638 } 628 }
639 else 629 else
640 { 630 {
@@ -678,7 +668,7 @@ void LLPanel::setPanelParameters(LLXMLNodePtr node, LLView* parent)
678 initFromXML(node, parent); 668 initFromXML(node, parent);
679 669
680 /////// Border attributes /////// 670 /////// Border attributes ///////
681 BOOL border = FALSE; 671 BOOL border = mBorder != NULL;
682 node->getAttributeBOOL("border", border); 672 node->getAttributeBOOL("border", border);
683 if (border) 673 if (border)
684 { 674 {
@@ -706,24 +696,24 @@ void LLPanel::setPanelParameters(LLXMLNodePtr node, LLView* parent)
706 } 696 }
707 697
708 /////// Background attributes /////// 698 /////// Background attributes ///////
709 BOOL background_visible = FALSE; 699 BOOL background_visible = mBgVisible;
710 node->getAttributeBOOL("background_visible", background_visible); 700 node->getAttributeBOOL("background_visible", background_visible);
711 setBackgroundVisible(background_visible); 701 setBackgroundVisible(background_visible);
712 702
713 BOOL background_opaque = FALSE; 703 BOOL background_opaque = mBgOpaque;
714 node->getAttributeBOOL("background_opaque", background_opaque); 704 node->getAttributeBOOL("background_opaque", background_opaque);
715 setBackgroundOpaque(background_opaque); 705 setBackgroundOpaque(background_opaque);
716 706
717 LLColor4 color; 707 LLColor4 color;
718 color = LLUI::sColorsGroup->getColor( "FocusBackgroundColor" ); 708 color = mBgColorOpaque;
719 LLUICtrlFactory::getAttributeColor(node,"bg_opaque_color", color); 709 LLUICtrlFactory::getAttributeColor(node,"bg_opaque_color", color);
720 setBackgroundColor(color); 710 setBackgroundColor(color);
721 711
722 color = LLUI::sColorsGroup->getColor( "DefaultBackgroundColor" ); 712 color = mBgColorAlpha;
723 LLUICtrlFactory::getAttributeColor(node,"bg_alpha_color", color); 713 LLUICtrlFactory::getAttributeColor(node,"bg_alpha_color", color);
724 setTransparentColor(color); 714 setTransparentColor(color);
725 715
726 LLString label; 716 LLString label = getLabel();
727 node->getAttributeString("label", label); 717 node->getAttributeString("label", label);
728 setLabel(label); 718 setLabel(label);
729} 719}
@@ -853,12 +843,12 @@ BOOL LLPanel::childHasFocus(const LLString& id)
853} 843}
854 844
855 845
856void LLPanel::childSetFocusChangedCallback(const LLString& id, void (*cb)(LLUICtrl*, void*)) 846void LLPanel::childSetFocusChangedCallback(const LLString& id, void (*cb)(LLFocusableElement*, void*), void* user_data)
857{ 847{
858 LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); 848 LLUICtrl* child = (LLUICtrl*)getChildByName(id, true);
859 if (child) 849 if (child)
860 { 850 {
861 child->setFocusChangedCallback(cb); 851 child->setFocusChangedCallback(cb, user_data);
862 } 852 }
863} 853}
864 854
@@ -1165,11 +1155,12 @@ void LLPanel::storeRectControl()
1165// 1155//
1166struct LLLayoutStack::LLEmbeddedPanel 1156struct LLLayoutStack::LLEmbeddedPanel
1167{ 1157{
1168 LLEmbeddedPanel(LLPanel* panelp, eLayoutOrientation orientation, S32 min_width, S32 min_height, BOOL auto_resize) : 1158 LLEmbeddedPanel(LLPanel* panelp, eLayoutOrientation orientation, S32 min_width, S32 min_height, BOOL auto_resize, BOOL user_resize) :
1169 mPanel(panelp), 1159 mPanel(panelp),
1170 mMinWidth(min_width), 1160 mMinWidth(min_width),
1171 mMinHeight(min_height), 1161 mMinHeight(min_height),
1172 mAutoResize(auto_resize), 1162 mAutoResize(auto_resize),
1163 mUserResize(user_resize),
1173 mOrientation(orientation), 1164 mOrientation(orientation),
1174 mVisibleAmt(1.f) // default to fully visible 1165 mVisibleAmt(1.f) // default to fully visible
1175 { 1166 {
@@ -1194,10 +1185,18 @@ struct LLLayoutStack::LLEmbeddedPanel
1194 } 1185 }
1195 } 1186 }
1196 1187
1188 ~LLEmbeddedPanel()
1189 {
1190 // probably not necessary, but...
1191 delete mResizeBar;
1192 mResizeBar = NULL;
1193 }
1194
1197 LLPanel* mPanel; 1195 LLPanel* mPanel;
1198 S32 mMinWidth; 1196 S32 mMinWidth;
1199 S32 mMinHeight; 1197 S32 mMinHeight;
1200 BOOL mAutoResize; 1198 BOOL mAutoResize;
1199 BOOL mUserResize;
1201 LLResizeBar* mResizeBar; 1200 LLResizeBar* mResizeBar;
1202 eLayoutOrientation mOrientation; 1201 eLayoutOrientation mOrientation;
1203 F32 mVisibleAmt; 1202 F32 mVisibleAmt;
@@ -1206,36 +1205,40 @@ struct LLLayoutStack::LLEmbeddedPanel
1206LLLayoutStack::LLLayoutStack(eLayoutOrientation orientation) : 1205LLLayoutStack::LLLayoutStack(eLayoutOrientation orientation) :
1207 mOrientation(orientation), 1206 mOrientation(orientation),
1208 mMinWidth(0), 1207 mMinWidth(0),
1209 mMinHeight(0) 1208 mMinHeight(0),
1209 mPanelSpacing(RESIZE_BAR_HEIGHT)
1210{ 1210{
1211} 1211}
1212 1212
1213LLLayoutStack::~LLLayoutStack() 1213LLLayoutStack::~LLLayoutStack()
1214{ 1214{
1215 std::for_each(mPanels.begin(), mPanels.end(), DeletePointer());
1215} 1216}
1216 1217
1217void LLLayoutStack::draw() 1218void LLLayoutStack::draw()
1218{ 1219{
1219 updateLayout(); 1220 updateLayout();
1220 { 1221 {
1221 // clip if outside nominal bounds
1222 LLLocalClipRect clip(getLocalRect(), mRect.getWidth() > mMinWidth || mRect.getHeight() > mMinHeight);
1223 e_panel_list_t::iterator panel_it; 1222 e_panel_list_t::iterator panel_it;
1224 for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) 1223 for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it)
1225 { 1224 {
1225 // clip to layout rectangle, not bounding rectangle
1226 LLRect clip_rect = (*panel_it)->mPanel->getRect(); 1226 LLRect clip_rect = (*panel_it)->mPanel->getRect();
1227 // scale clipping rectangle by visible amount 1227 // scale clipping rectangle by visible amount
1228 if (mOrientation == HORIZONTAL) 1228 if (mOrientation == HORIZONTAL)
1229 { 1229 {
1230 clip_rect.mRight = clip_rect.mLeft + llround(clip_rect.getWidth() * (*panel_it)->mVisibleAmt); 1230 clip_rect.mRight = clip_rect.mLeft + llround((F32)clip_rect.getWidth() * (*panel_it)->mVisibleAmt);
1231 } 1231 }
1232 else 1232 else
1233 { 1233 {
1234 clip_rect.mBottom = clip_rect.mTop - llround(clip_rect.getHeight() * (*panel_it)->mVisibleAmt); 1234 clip_rect.mBottom = clip_rect.mTop - llround((F32)clip_rect.getHeight() * (*panel_it)->mVisibleAmt);
1235 } 1235 }
1236 LLLocalClipRect clip(clip_rect, (*panel_it)->mVisibleAmt < 1.f); 1236
1237 LLPanel* panelp = (*panel_it)->mPanel;
1238
1239 LLLocalClipRect clip(clip_rect);
1237 // only force drawing invisible children if visible amount is non-zero 1240 // only force drawing invisible children if visible amount is non-zero
1238 drawChild((*panel_it)->mPanel, 0, 0, (*panel_it)->mVisibleAmt > 0.f); 1241 drawChild(panelp, 0, 0, !clip_rect.isNull());
1239 } 1242 }
1240 } 1243 }
1241} 1244}
@@ -1250,17 +1253,13 @@ void LLLayoutStack::removeCtrl(LLUICtrl* ctrl)
1250 delete embedded_panelp; 1253 delete embedded_panelp;
1251 } 1254 }
1252 1255
1256 // need to update resizebars
1257
1253 calcMinExtents(); 1258 calcMinExtents();
1254 1259
1255 LLView::removeCtrl(ctrl); 1260 LLView::removeCtrl(ctrl);
1256} 1261}
1257 1262
1258void LLLayoutStack::reshape(S32 width, S32 height, BOOL called_from_parent)
1259{
1260 LLView::reshape(width, height, called_from_parent);
1261 //updateLayout();
1262}
1263
1264LLXMLNodePtr LLLayoutStack::getXML(bool save_children) const 1263LLXMLNodePtr LLLayoutStack::getXML(bool save_children) const
1265{ 1264{
1266 LLXMLNodePtr node = LLView::getXML(); 1265 LLXMLNodePtr node = LLView::getXML();
@@ -1290,6 +1289,14 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactor
1290 1289
1291 LLLayoutStack* layout_stackp = new LLLayoutStack(orientation); 1290 LLLayoutStack* layout_stackp = new LLLayoutStack(orientation);
1292 1291
1292 node->getAttributeS32("border_size", layout_stackp->mPanelSpacing);
1293 // don't allow negative spacing values
1294 layout_stackp->mPanelSpacing = llmax(layout_stackp->mPanelSpacing, 0);
1295
1296 LLString name("stack");
1297 node->getAttributeString("name", name);
1298
1299 layout_stackp->setName(name);
1293 layout_stackp->initFromXML(node, parent); 1300 layout_stackp->initFromXML(node, parent);
1294 1301
1295 LLXMLNodePtr child; 1302 LLXMLNodePtr child;
@@ -1300,16 +1307,18 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactor
1300 S32 min_width = 0; 1307 S32 min_width = 0;
1301 S32 min_height = 0; 1308 S32 min_height = 0;
1302 BOOL auto_resize = TRUE; 1309 BOOL auto_resize = TRUE;
1310 BOOL user_resize = TRUE;
1303 1311
1304 child->getAttributeS32("min_width", min_width); 1312 child->getAttributeS32("min_width", min_width);
1305 child->getAttributeS32("min_height", min_height); 1313 child->getAttributeS32("min_height", min_height);
1306 child->getAttributeBOOL("auto_resize", auto_resize); 1314 child->getAttributeBOOL("auto_resize", auto_resize);
1315 child->getAttributeBOOL("user_resize", user_resize);
1307 1316
1308 LLPanel* panelp = (LLPanel*)LLPanel::fromXML(child, layout_stackp, factory); 1317 LLPanel* panelp = (LLPanel*)LLPanel::fromXML(child, layout_stackp, factory);
1309 if (panelp) 1318 if (panelp)
1310 { 1319 {
1311 panelp->setFollowsNone(); 1320 panelp->setFollowsNone();
1312 layout_stackp->addPanel(panelp, min_width, min_height, auto_resize); 1321 layout_stackp->addPanel(panelp, min_width, min_height, auto_resize, user_resize);
1313 } 1322 }
1314 } 1323 }
1315 } 1324 }
@@ -1327,11 +1336,36 @@ S32 LLLayoutStack::getMinHeight()
1327 return mMinHeight; 1336 return mMinHeight;
1328} 1337}
1329 1338
1330void LLLayoutStack::addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL auto_resize, S32 index) 1339S32 LLLayoutStack::getDefaultHeight(S32 cur_height)
1340{
1341 // if we are spanning our children (crude upward propagation of size)
1342 // then don't enforce our size on our children
1343 if (mOrientation == HORIZONTAL)
1344 {
1345 cur_height = llmax(mMinHeight, mRect.getHeight());
1346 }
1347
1348 return cur_height;
1349}
1350
1351S32 LLLayoutStack::getDefaultWidth(S32 cur_width)
1331{ 1352{
1332 LLEmbeddedPanel* embedded_panel = new LLEmbeddedPanel(panel, mOrientation, min_width, min_height, auto_resize); 1353 // if we are spanning our children (crude upward propagation of size)
1354 // then don't enforce our size on our children
1355 if (mOrientation == VERTICAL)
1356 {
1357 cur_width = llmax(mMinWidth, mRect.getWidth());
1358 }
1359
1360 return cur_width;
1361}
1362
1363void LLLayoutStack::addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL auto_resize, BOOL user_resize, S32 index)
1364{
1365 LLEmbeddedPanel* embedded_panel = new LLEmbeddedPanel(panel, mOrientation, min_width, min_height, auto_resize, user_resize);
1333 1366
1334 mPanels.insert(mPanels.begin() + llclamp(index, 0, (S32)mPanels.size()), embedded_panel); 1367 mPanels.insert(mPanels.begin() + llclamp(index, 0, (S32)mPanels.size()), embedded_panel);
1368
1335 addChild(panel); 1369 addChild(panel);
1336 addChild(embedded_panel->mResizeBar); 1370 addChild(embedded_panel->mResizeBar);
1337 1371
@@ -1339,29 +1373,15 @@ void LLLayoutStack::addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL
1339 // with a bit of overlap 1373 // with a bit of overlap
1340 for (e_panel_list_t::iterator panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) 1374 for (e_panel_list_t::iterator panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it)
1341 { 1375 {
1342 e_panel_list_t::iterator next_it = panel_it;
1343 ++next_it;
1344
1345 LLResizeBar* resize_barp = (*panel_it)->mResizeBar; 1376 LLResizeBar* resize_barp = (*panel_it)->mResizeBar;
1346 sendChildToFront(resize_barp); 1377 sendChildToFront(resize_barp);
1347 // last resize bar is disabled, since its not between any two panels
1348 if ( next_it == mPanels.end() )
1349 {
1350 resize_barp->setEnabled(FALSE);
1351 }
1352 else
1353 {
1354 resize_barp->setEnabled(TRUE);
1355 }
1356 } 1378 }
1357 1379
1358 //updateLayout();
1359} 1380}
1360 1381
1361void LLLayoutStack::removePanel(LLPanel* panel) 1382void LLLayoutStack::removePanel(LLPanel* panel)
1362{ 1383{
1363 removeChild(panel); 1384 removeChild(panel);
1364 //updateLayout();
1365} 1385}
1366 1386
1367void LLLayoutStack::updateLayout(BOOL force_resize) 1387void LLLayoutStack::updateLayout(BOOL force_resize)
@@ -1369,11 +1389,11 @@ void LLLayoutStack::updateLayout(BOOL force_resize)
1369 calcMinExtents(); 1389 calcMinExtents();
1370 1390
1371 // calculate current extents 1391 // calculate current extents
1372 S32 cur_width = 0; 1392 S32 total_width = 0;
1373 S32 cur_height = 0; 1393 S32 total_height = 0;
1374 1394
1375 const F32 ANIM_OPEN_TIME = 0.02f; 1395 const F32 ANIM_OPEN_TIME = 0.02f;
1376 const F32 ANIM_CLOSE_TIME = 0.02f; 1396 const F32 ANIM_CLOSE_TIME = 0.03f;
1377 1397
1378 e_panel_list_t::iterator panel_it; 1398 e_panel_list_t::iterator panel_it;
1379 for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) 1399 for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it)
@@ -1395,23 +1415,22 @@ void LLLayoutStack::updateLayout(BOOL force_resize)
1395 (*panel_it)->mVisibleAmt = 0.f; 1415 (*panel_it)->mVisibleAmt = 0.f;
1396 } 1416 }
1397 } 1417 }
1418
1398 if (mOrientation == HORIZONTAL) 1419 if (mOrientation == HORIZONTAL)
1399 { 1420 {
1400 // all panels get expanded to max of all the minimum dimensions 1421 total_width += llround(panelp->getRect().getWidth() * (*panel_it)->mVisibleAmt);
1401 cur_height = llmax(mMinHeight, panelp->getRect().getHeight()); 1422 // want n-1 panel gaps for n panels
1402 cur_width += llround(panelp->getRect().getWidth() * (*panel_it)->mVisibleAmt); 1423 if (panel_it != mPanels.begin())
1403 if (panel_it != mPanels.end())
1404 { 1424 {
1405 cur_width += PANEL_STACK_GAP; 1425 total_width += mPanelSpacing;
1406 } 1426 }
1407 } 1427 }
1408 else //VERTICAL 1428 else //VERTICAL
1409 { 1429 {
1410 cur_width = llmax(mMinWidth, panelp->getRect().getWidth()); 1430 total_height += llround(panelp->getRect().getHeight() * (*panel_it)->mVisibleAmt);
1411 cur_height += llround(panelp->getRect().getHeight() * (*panel_it)->mVisibleAmt); 1431 if (panel_it != mPanels.begin())
1412 if (panel_it != mPanels.end())
1413 { 1432 {
1414 cur_height += PANEL_STACK_GAP; 1433 total_height += mPanelSpacing;
1415 } 1434 }
1416 } 1435 }
1417 } 1436 }
@@ -1457,11 +1476,11 @@ void LLLayoutStack::updateLayout(BOOL force_resize)
1457 S32 pixels_to_distribute; 1476 S32 pixels_to_distribute;
1458 if (mOrientation == HORIZONTAL) 1477 if (mOrientation == HORIZONTAL)
1459 { 1478 {
1460 pixels_to_distribute = mRect.getWidth() - cur_width; 1479 pixels_to_distribute = mRect.getWidth() - total_width;
1461 } 1480 }
1462 else //VERTICAL 1481 else //VERTICAL
1463 { 1482 {
1464 pixels_to_distribute = mRect.getHeight() - cur_height; 1483 pixels_to_distribute = mRect.getHeight() - total_height;
1465 } 1484 }
1466 1485
1467 S32 cur_x = 0; 1486 S32 cur_x = 0;
@@ -1474,7 +1493,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize)
1474 S32 cur_width = panelp->getRect().getWidth(); 1493 S32 cur_width = panelp->getRect().getWidth();
1475 S32 cur_height = panelp->getRect().getHeight(); 1494 S32 cur_height = panelp->getRect().getHeight();
1476 S32 new_width = llmax((*panel_it)->mMinWidth, cur_width); 1495 S32 new_width = llmax((*panel_it)->mMinWidth, cur_width);
1477 S32 new_height = llmax((*panel_it)->mMinHeight, cur_height); 1496 S32 new_height = llmax((*panel_it)->mMinHeight, cur_height);
1478 1497
1479 S32 delta_size = 0; 1498 S32 delta_size = 0;
1480 1499
@@ -1494,11 +1513,11 @@ void LLLayoutStack::updateLayout(BOOL force_resize)
1494 // grow all elements equally 1513 // grow all elements equally
1495 delta_size = llround((F32)pixels_to_distribute / (F32)num_resizable_panels); 1514 delta_size = llround((F32)pixels_to_distribute / (F32)num_resizable_panels);
1496 } 1515 }
1497 new_width = llmax((*panel_it)->mMinWidth, panelp->getRect().getWidth() + delta_size); 1516 new_width = llmax((*panel_it)->mMinWidth, cur_width + delta_size);
1498 } 1517 }
1499 else 1518 else
1500 { 1519 {
1501 new_width = llmax(mMinWidth, mRect.getWidth()); 1520 new_width = getDefaultWidth(new_width);
1502 } 1521 }
1503 1522
1504 if (mOrientation == VERTICAL) 1523 if (mOrientation == VERTICAL)
@@ -1512,22 +1531,22 @@ void LLLayoutStack::updateLayout(BOOL force_resize)
1512 { 1531 {
1513 delta_size = llround((F32)pixels_to_distribute / (F32)num_resizable_panels); 1532 delta_size = llround((F32)pixels_to_distribute / (F32)num_resizable_panels);
1514 } 1533 }
1515 new_height = llmax((*panel_it)->mMinHeight, panelp->getRect().getHeight() + delta_size); 1534 new_height = llmax((*panel_it)->mMinHeight, cur_height + delta_size);
1516 } 1535 }
1517 else 1536 else
1518 { 1537 {
1519 new_height = llmax(mMinHeight, mRect.getHeight()); 1538 new_height = getDefaultHeight(new_height);
1520 } 1539 }
1521 } 1540 }
1522 else // don't resize 1541 else
1523 { 1542 {
1524 if (mOrientation == HORIZONTAL) 1543 if (mOrientation == HORIZONTAL)
1525 { 1544 {
1526 new_height = llmax(mMinHeight, mRect.getHeight()); 1545 new_height = getDefaultHeight(new_height);
1527 } 1546 }
1528 else // VERTICAL 1547 else // VERTICAL
1529 { 1548 {
1530 new_width = llmax(mMinWidth, mRect.getWidth()); 1549 new_width = getDefaultWidth(new_width);
1531 } 1550 }
1532 } 1551 }
1533 1552
@@ -1542,22 +1561,22 @@ void LLLayoutStack::updateLayout(BOOL force_resize)
1542 if (mOrientation == HORIZONTAL) 1561 if (mOrientation == HORIZONTAL)
1543 { 1562 {
1544 resize_bar_rect.mLeft = panel_rect.mRight - RESIZE_BAR_OVERLAP; 1563 resize_bar_rect.mLeft = panel_rect.mRight - RESIZE_BAR_OVERLAP;
1545 resize_bar_rect.mRight = panel_rect.mRight + PANEL_STACK_GAP + RESIZE_BAR_OVERLAP; 1564 resize_bar_rect.mRight = panel_rect.mRight + mPanelSpacing + RESIZE_BAR_OVERLAP;
1546 } 1565 }
1547 else 1566 else
1548 { 1567 {
1549 resize_bar_rect.mTop = panel_rect.mBottom + RESIZE_BAR_OVERLAP; 1568 resize_bar_rect.mTop = panel_rect.mBottom + RESIZE_BAR_OVERLAP;
1550 resize_bar_rect.mBottom = panel_rect.mBottom - PANEL_STACK_GAP - RESIZE_BAR_OVERLAP; 1569 resize_bar_rect.mBottom = panel_rect.mBottom - mPanelSpacing - RESIZE_BAR_OVERLAP;
1551 } 1570 }
1552 (*panel_it)->mResizeBar->setRect(resize_bar_rect); 1571 (*panel_it)->mResizeBar->setRect(resize_bar_rect);
1553 1572
1554 if (mOrientation == HORIZONTAL) 1573 if (mOrientation == HORIZONTAL)
1555 { 1574 {
1556 cur_x += llround(new_width * (*panel_it)->mVisibleAmt) + PANEL_STACK_GAP; 1575 cur_x += llround(new_width * (*panel_it)->mVisibleAmt) + mPanelSpacing;
1557 } 1576 }
1558 else //VERTICAL 1577 else //VERTICAL
1559 { 1578 {
1560 cur_y -= llround(new_height * (*panel_it)->mVisibleAmt) + PANEL_STACK_GAP; 1579 cur_y -= llround(new_height * (*panel_it)->mVisibleAmt) + mPanelSpacing;
1561 } 1580 }
1562 } 1581 }
1563 1582
@@ -1569,29 +1588,38 @@ void LLLayoutStack::updateLayout(BOOL force_resize)
1569 1588
1570 if (mOrientation == HORIZONTAL) 1589 if (mOrientation == HORIZONTAL)
1571 { 1590 {
1572 (*panel_it)->mResizeBar->setResizeLimits((*panel_it)->mMinWidth, (*panel_it)->mMinWidth + shrink_headroom_total); 1591 (*panel_it)->mResizeBar->setResizeLimits(
1592 (*panel_it)->mMinWidth,
1593 (*panel_it)->mMinWidth + shrink_headroom_total);
1573 } 1594 }
1574 else //VERTICAL 1595 else //VERTICAL
1575 { 1596 {
1576 (*panel_it)->mResizeBar->setResizeLimits((*panel_it)->mMinHeight, (*panel_it)->mMinHeight + shrink_headroom_total); 1597 (*panel_it)->mResizeBar->setResizeLimits(
1598 (*panel_it)->mMinHeight,
1599 (*panel_it)->mMinHeight + shrink_headroom_total);
1577 } 1600 }
1578 // hide resize bars for invisible panels 1601
1579 (*panel_it)->mResizeBar->setVisible(panelp->getVisible()); 1602 // toggle resize bars based on panel visibility, resizability, etc
1580 if (panelp->getVisible()) 1603 BOOL resize_bar_enabled = panelp->getVisible() && (*panel_it)->mUserResize;
1604 (*panel_it)->mResizeBar->setVisible(resize_bar_enabled);
1605
1606 if (resize_bar_enabled)
1581 { 1607 {
1582 last_resize_bar = (*panel_it)->mResizeBar; 1608 last_resize_bar = (*panel_it)->mResizeBar;
1583 } 1609 }
1584 } 1610 }
1585 1611
1586 // hide last resize bar as there is nothing past it 1612 // hide last resize bar as there is nothing past it
1613 // resize bars need to be in between two resizable panels
1587 if (last_resize_bar) 1614 if (last_resize_bar)
1588 { 1615 {
1589 last_resize_bar->setVisible(FALSE); 1616 last_resize_bar->setVisible(FALSE);
1590 } 1617 }
1591 1618
1592 // not enough room to fit existing contents 1619 // not enough room to fit existing contents
1593 if (!force_resize && 1620 if (!force_resize
1594 ((cur_y != -PANEL_STACK_GAP) || (cur_x != mRect.getWidth() + PANEL_STACK_GAP))) 1621 && ((cur_y != -mPanelSpacing)
1622 || (cur_x != mRect.getWidth() + mPanelSpacing)))
1595 { 1623 {
1596 // do another layout pass with all stacked elements contributing 1624 // do another layout pass with all stacked elements contributing
1597 // even those that don't usually resize 1625 // even those that don't usually resize
@@ -1623,20 +1651,22 @@ void LLLayoutStack::calcMinExtents()
1623 { 1651 {
1624 if (mOrientation == HORIZONTAL) 1652 if (mOrientation == HORIZONTAL)
1625 { 1653 {
1626 mMinHeight = llmax(mMinHeight, (*panel_it)->mMinHeight); 1654 mMinHeight = llmax( mMinHeight,
1655 (*panel_it)->mMinHeight);
1627 mMinWidth += (*panel_it)->mMinWidth; 1656 mMinWidth += (*panel_it)->mMinWidth;
1628 if (panel_it != mPanels.begin()) 1657 if (panel_it != mPanels.begin())
1629 { 1658 {
1630 mMinWidth += PANEL_STACK_GAP; 1659 mMinWidth += mPanelSpacing;
1631 } 1660 }
1632 } 1661 }
1633 else //VERTICAL 1662 else //VERTICAL
1634 { 1663 {
1635 mMinWidth = llmax(mMinWidth, (*panel_it)->mMinWidth); 1664 mMinWidth = llmax( mMinWidth,
1665 (*panel_it)->mMinWidth);
1636 mMinHeight += (*panel_it)->mMinHeight; 1666 mMinHeight += (*panel_it)->mMinHeight;
1637 if (panel_it != mPanels.begin()) 1667 if (panel_it != mPanels.begin())
1638 { 1668 {
1639 mMinHeight += PANEL_STACK_GAP; 1669 mMinHeight += mPanelSpacing;
1640 } 1670 }
1641 } 1671 }
1642 } 1672 }