diff options
author | Jacek Antonelli | 2009-04-30 13:04:20 -0500 |
---|---|---|
committer | Jacek Antonelli | 2009-04-30 13:07:16 -0500 |
commit | ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch) | |
tree | 8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/llui/llpanel.cpp | |
parent | Second Life viewer sources 1.22.11 (diff) | |
download | meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2 meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz |
Second Life viewer sources 1.23.0-RC
Diffstat (limited to 'linden/indra/llui/llpanel.cpp')
-rw-r--r-- | linden/indra/llui/llpanel.cpp | 142 |
1 files changed, 84 insertions, 58 deletions
diff --git a/linden/indra/llui/llpanel.cpp b/linden/indra/llui/llpanel.cpp index d37517f..92d045d 100644 --- a/linden/indra/llui/llpanel.cpp +++ b/linden/indra/llui/llpanel.cpp | |||
@@ -17,7 +17,8 @@ | |||
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://secondlifegrid.net/programs/open_source/licensing/flossexception | 20 | * online at |
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | 22 | * |
22 | * By copying, modifying or distributing this software, you acknowledge | 23 | * By copying, modifying or distributing this software, you acknowledge |
23 | * that you have read and understood your obligations described above, | 24 | * that you have read and understood your obligations described above, |
@@ -58,8 +59,6 @@ | |||
58 | #include "llresizebar.h" | 59 | #include "llresizebar.h" |
59 | #include "llcriticaldamp.h" | 60 | #include "llcriticaldamp.h" |
60 | 61 | ||
61 | LLPanel::alert_queue_t LLPanel::sAlertQueue; | ||
62 | |||
63 | const S32 RESIZE_BAR_OVERLAP = 1; | 62 | const S32 RESIZE_BAR_OVERLAP = 1; |
64 | const S32 RESIZE_BAR_HEIGHT = 3; | 63 | const S32 RESIZE_BAR_HEIGHT = 3; |
65 | 64 | ||
@@ -344,14 +343,14 @@ BOOL LLPanel::checkRequirements() | |||
344 | { | 343 | { |
345 | if (!mRequirementsError.empty()) | 344 | if (!mRequirementsError.empty()) |
346 | { | 345 | { |
347 | LLStringUtil::format_map_t args; | 346 | LLSD args; |
348 | args["[COMPONENTS]"] = mRequirementsError; | 347 | args["COMPONENTS"] = mRequirementsError; |
349 | args["[FLOATER]"] = getName(); | 348 | args["FLOATER"] = getName(); |
350 | 349 | ||
351 | llwarns << getName() << " failed requirements check on: \n" | 350 | llwarns << getName() << " failed requirements check on: \n" |
352 | << mRequirementsError << llendl; | 351 | << mRequirementsError << llendl; |
353 | 352 | ||
354 | alertXml(std::string("FailedRequirementsCheck"), args); | 353 | LLNotifications::instance().add(LLNotification::Params("FailedRequirementsCheck").payload(args)); |
355 | mRequirementsError.clear(); | 354 | mRequirementsError.clear(); |
356 | return FALSE; | 355 | return FALSE; |
357 | } | 356 | } |
@@ -359,25 +358,6 @@ BOOL LLPanel::checkRequirements() | |||
359 | return TRUE; | 358 | return TRUE; |
360 | } | 359 | } |
361 | 360 | ||
362 | //static | ||
363 | void LLPanel::alertXml(const std::string& label, LLStringUtil::format_map_t args) | ||
364 | { | ||
365 | sAlertQueue.push(LLAlertInfo(label,args)); | ||
366 | } | ||
367 | |||
368 | //static | ||
369 | BOOL LLPanel::nextAlert(LLAlertInfo &alert) | ||
370 | { | ||
371 | if (!sAlertQueue.empty()) | ||
372 | { | ||
373 | alert = sAlertQueue.front(); | ||
374 | sAlertQueue.pop(); | ||
375 | return TRUE; | ||
376 | } | ||
377 | |||
378 | return FALSE; | ||
379 | } | ||
380 | |||
381 | void LLPanel::setFocus(BOOL b) | 361 | void LLPanel::setFocus(BOOL b) |
382 | { | 362 | { |
383 | if( b ) | 363 | if( b ) |
@@ -927,7 +907,7 @@ LLPanel *LLPanel::childGetVisibleTab(const std::string& id) const | |||
927 | return NULL; | 907 | return NULL; |
928 | } | 908 | } |
929 | 909 | ||
930 | void LLPanel::childSetTabChangeCallback(const std::string& id, const std::string& tabname, void (*on_tab_clicked)(void*, bool), void *userdata) | 910 | void LLPanel::childSetTabChangeCallback(const std::string& id, const std::string& tabname, void (*on_tab_clicked)(void*, bool), void *userdata, void (*on_precommit)(void*,bool)) |
931 | { | 911 | { |
932 | LLTabContainer* child = getChild<LLTabContainer>(id); | 912 | LLTabContainer* child = getChild<LLTabContainer>(id); |
933 | if (child) | 913 | if (child) |
@@ -937,6 +917,10 @@ void LLPanel::childSetTabChangeCallback(const std::string& id, const std::string | |||
937 | { | 917 | { |
938 | child->setTabChangeCallback(panel, on_tab_clicked); | 918 | child->setTabChangeCallback(panel, on_tab_clicked); |
939 | child->setTabUserData(panel, userdata); | 919 | child->setTabUserData(panel, userdata); |
920 | if (on_precommit) | ||
921 | { | ||
922 | child->setTabPrecommitChangeCallback(panel, on_precommit); | ||
923 | } | ||
940 | } | 924 | } |
941 | } | 925 | } |
942 | } | 926 | } |
@@ -982,12 +966,12 @@ void LLPanel::childSetAction(const std::string& id, void(*function)(void*), void | |||
982 | } | 966 | } |
983 | } | 967 | } |
984 | 968 | ||
985 | void LLPanel::childSetActionTextbox(const std::string& id, void(*function)(void*)) | 969 | void LLPanel::childSetActionTextbox(const std::string& id, void(*function)(void*), void* value) |
986 | { | 970 | { |
987 | LLTextBox* textbox = getChild<LLTextBox>(id); | 971 | LLTextBox* textbox = getChild<LLTextBox>(id); |
988 | if (textbox) | 972 | if (textbox) |
989 | { | 973 | { |
990 | textbox->setClickedCallback(function); | 974 | textbox->setClickedCallback(function, value); |
991 | } | 975 | } |
992 | } | 976 | } |
993 | 977 | ||
@@ -1039,9 +1023,9 @@ void LLPanel::childDisplayNotFound() | |||
1039 | mExpectedMembers.insert(*itor); | 1023 | mExpectedMembers.insert(*itor); |
1040 | } | 1024 | } |
1041 | mNewExpectedMembers.clear(); | 1025 | mNewExpectedMembers.clear(); |
1042 | LLStringUtil::format_map_t args; | 1026 | LLSD args; |
1043 | args["[CONTROLS]"] = msg; | 1027 | args["CONTROLS"] = msg; |
1044 | LLAlertDialog::showXml("FloaterNotFound", args); | 1028 | LLNotifications::instance().add("FloaterNotFound", args); |
1045 | } | 1029 | } |
1046 | 1030 | ||
1047 | void LLPanel::storeRectControl() | 1031 | void LLPanel::storeRectControl() |
@@ -1065,6 +1049,8 @@ struct LLLayoutStack::LLEmbeddedPanel | |||
1065 | mAutoResize(auto_resize), | 1049 | mAutoResize(auto_resize), |
1066 | mUserResize(user_resize), | 1050 | mUserResize(user_resize), |
1067 | mOrientation(orientation), | 1051 | mOrientation(orientation), |
1052 | mCollapsed(FALSE), | ||
1053 | mCollapseAmt(0.f), | ||
1068 | mVisibleAmt(1.f) // default to fully visible | 1054 | mVisibleAmt(1.f) // default to fully visible |
1069 | { | 1055 | { |
1070 | LLResizeBar::Side side = (orientation == HORIZONTAL) ? LLResizeBar::RIGHT : LLResizeBar::BOTTOM; | 1056 | LLResizeBar::Side side = (orientation == HORIZONTAL) ? LLResizeBar::RIGHT : LLResizeBar::BOTTOM; |
@@ -1095,14 +1081,28 @@ struct LLLayoutStack::LLEmbeddedPanel | |||
1095 | mResizeBar = NULL; | 1081 | mResizeBar = NULL; |
1096 | } | 1082 | } |
1097 | 1083 | ||
1084 | F32 getCollapseFactor() | ||
1085 | { | ||
1086 | if (mOrientation == HORIZONTAL) | ||
1087 | { | ||
1088 | return mVisibleAmt * clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, (F32)mMinWidth / (F32)mPanel->getRect().getWidth()); | ||
1089 | } | ||
1090 | else | ||
1091 | { | ||
1092 | return mVisibleAmt * clamp_rescale(mCollapseAmt, 0.f, 1.f, 1.f, (F32)mMinHeight / (F32)mPanel->getRect().getHeight()); | ||
1093 | } | ||
1094 | } | ||
1095 | |||
1098 | LLPanel* mPanel; | 1096 | LLPanel* mPanel; |
1099 | S32 mMinWidth; | 1097 | S32 mMinWidth; |
1100 | S32 mMinHeight; | 1098 | S32 mMinHeight; |
1101 | BOOL mAutoResize; | 1099 | BOOL mAutoResize; |
1102 | BOOL mUserResize; | 1100 | BOOL mUserResize; |
1101 | BOOL mCollapsed; | ||
1103 | LLResizeBar* mResizeBar; | 1102 | LLResizeBar* mResizeBar; |
1104 | eLayoutOrientation mOrientation; | 1103 | eLayoutOrientation mOrientation; |
1105 | F32 mVisibleAmt; | 1104 | F32 mVisibleAmt; |
1105 | F32 mCollapseAmt; | ||
1106 | }; | 1106 | }; |
1107 | 1107 | ||
1108 | static LLRegisterWidget<LLLayoutStack> r2("layout_stack"); | 1108 | static LLRegisterWidget<LLLayoutStack> r2("layout_stack"); |
@@ -1123,28 +1123,27 @@ LLLayoutStack::~LLLayoutStack() | |||
1123 | void LLLayoutStack::draw() | 1123 | void LLLayoutStack::draw() |
1124 | { | 1124 | { |
1125 | updateLayout(); | 1125 | updateLayout(); |
1126 | |||
1127 | e_panel_list_t::iterator panel_it; | ||
1128 | for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) | ||
1126 | { | 1129 | { |
1127 | e_panel_list_t::iterator panel_it; | 1130 | // clip to layout rectangle, not bounding rectangle |
1128 | for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) | 1131 | LLRect clip_rect = (*panel_it)->mPanel->getRect(); |
1132 | // scale clipping rectangle by visible amount | ||
1133 | if (mOrientation == HORIZONTAL) | ||
1129 | { | 1134 | { |
1130 | // clip to layout rectangle, not bounding rectangle | 1135 | clip_rect.mRight = clip_rect.mLeft + llround((F32)clip_rect.getWidth() * (*panel_it)->getCollapseFactor()); |
1131 | LLRect clip_rect = (*panel_it)->mPanel->getRect(); | 1136 | } |
1132 | // scale clipping rectangle by visible amount | 1137 | else |
1133 | if (mOrientation == HORIZONTAL) | 1138 | { |
1134 | { | 1139 | clip_rect.mBottom = clip_rect.mTop - llround((F32)clip_rect.getHeight() * (*panel_it)->getCollapseFactor()); |
1135 | clip_rect.mRight = clip_rect.mLeft + llround((F32)clip_rect.getWidth() * (*panel_it)->mVisibleAmt); | 1140 | } |
1136 | } | ||
1137 | else | ||
1138 | { | ||
1139 | clip_rect.mBottom = clip_rect.mTop - llround((F32)clip_rect.getHeight() * (*panel_it)->mVisibleAmt); | ||
1140 | } | ||
1141 | 1141 | ||
1142 | LLPanel* panelp = (*panel_it)->mPanel; | 1142 | LLPanel* panelp = (*panel_it)->mPanel; |
1143 | 1143 | ||
1144 | LLLocalClipRect clip(clip_rect); | 1144 | LLLocalClipRect clip(clip_rect); |
1145 | // only force drawing invisible children if visible amount is non-zero | 1145 | // only force drawing invisible children if visible amount is non-zero |
1146 | drawChild(panelp, 0, 0, !clip_rect.isNull()); | 1146 | drawChild(panelp, 0, 0, !clip_rect.isNull()); |
1147 | } | ||
1148 | } | 1147 | } |
1149 | } | 1148 | } |
1150 | 1149 | ||
@@ -1276,8 +1275,13 @@ S32 LLLayoutStack::getDefaultWidth(S32 cur_width) | |||
1276 | return cur_width; | 1275 | return cur_width; |
1277 | } | 1276 | } |
1278 | 1277 | ||
1279 | void LLLayoutStack::addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL auto_resize, BOOL user_resize, S32 index) | 1278 | void LLLayoutStack::addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL auto_resize, BOOL user_resize, EAnimate animate, S32 index) |
1280 | { | 1279 | { |
1280 | // panel starts off invisible (collapsed) | ||
1281 | if (animate == ANIMATE) | ||
1282 | { | ||
1283 | panel->setVisible(FALSE); | ||
1284 | } | ||
1281 | LLEmbeddedPanel* embedded_panel = new LLEmbeddedPanel(panel, mOrientation, min_width, min_height, auto_resize, user_resize); | 1285 | LLEmbeddedPanel* embedded_panel = new LLEmbeddedPanel(panel, mOrientation, min_width, min_height, auto_resize, user_resize); |
1282 | 1286 | ||
1283 | mPanels.insert(mPanels.begin() + llclamp(index, 0, (S32)mPanels.size()), embedded_panel); | 1287 | mPanels.insert(mPanels.begin() + llclamp(index, 0, (S32)mPanels.size()), embedded_panel); |
@@ -1293,6 +1297,11 @@ void LLLayoutStack::addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL | |||
1293 | sendChildToFront(resize_barp); | 1297 | sendChildToFront(resize_barp); |
1294 | } | 1298 | } |
1295 | 1299 | ||
1300 | // start expanding panel animation | ||
1301 | if (animate == ANIMATE) | ||
1302 | { | ||
1303 | panel->setVisible(TRUE); | ||
1304 | } | ||
1296 | } | 1305 | } |
1297 | 1306 | ||
1298 | void LLLayoutStack::removePanel(LLPanel* panel) | 1307 | void LLLayoutStack::removePanel(LLPanel* panel) |
@@ -1300,6 +1309,14 @@ void LLLayoutStack::removePanel(LLPanel* panel) | |||
1300 | removeChild(panel); | 1309 | removeChild(panel); |
1301 | } | 1310 | } |
1302 | 1311 | ||
1312 | void LLLayoutStack::collapsePanel(LLPanel* panel, BOOL collapsed) | ||
1313 | { | ||
1314 | LLEmbeddedPanel* panel_container = findEmbeddedPanel(panel); | ||
1315 | if (!panel_container) return; | ||
1316 | |||
1317 | panel_container->mCollapsed = collapsed; | ||
1318 | } | ||
1319 | |||
1303 | void LLLayoutStack::updateLayout(BOOL force_resize) | 1320 | void LLLayoutStack::updateLayout(BOOL force_resize) |
1304 | { | 1321 | { |
1305 | calcMinExtents(); | 1322 | calcMinExtents(); |
@@ -1332,6 +1349,15 @@ void LLLayoutStack::updateLayout(BOOL force_resize) | |||
1332 | } | 1349 | } |
1333 | } | 1350 | } |
1334 | 1351 | ||
1352 | if ((*panel_it)->mCollapsed) | ||
1353 | { | ||
1354 | (*panel_it)->mCollapseAmt = lerp((*panel_it)->mCollapseAmt, 1.f, LLCriticalDamp::getInterpolant(ANIM_CLOSE_TIME)); | ||
1355 | } | ||
1356 | else | ||
1357 | { | ||
1358 | (*panel_it)->mCollapseAmt = lerp((*panel_it)->mCollapseAmt, 0.f, LLCriticalDamp::getInterpolant(ANIM_CLOSE_TIME)); | ||
1359 | } | ||
1360 | |||
1335 | if (mOrientation == HORIZONTAL) | 1361 | if (mOrientation == HORIZONTAL) |
1336 | { | 1362 | { |
1337 | // enforce minimize size constraint by default | 1363 | // enforce minimize size constraint by default |
@@ -1339,7 +1365,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) | |||
1339 | { | 1365 | { |
1340 | panelp->reshape((*panel_it)->mMinWidth, panelp->getRect().getHeight()); | 1366 | panelp->reshape((*panel_it)->mMinWidth, panelp->getRect().getHeight()); |
1341 | } | 1367 | } |
1342 | total_width += llround(panelp->getRect().getWidth() * (*panel_it)->mVisibleAmt); | 1368 | total_width += llround(panelp->getRect().getWidth() * (*panel_it)->getCollapseFactor()); |
1343 | // want n-1 panel gaps for n panels | 1369 | // want n-1 panel gaps for n panels |
1344 | if (panel_it != mPanels.begin()) | 1370 | if (panel_it != mPanels.begin()) |
1345 | { | 1371 | { |
@@ -1353,7 +1379,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) | |||
1353 | { | 1379 | { |
1354 | panelp->reshape(panelp->getRect().getWidth(), (*panel_it)->mMinHeight); | 1380 | panelp->reshape(panelp->getRect().getWidth(), (*panel_it)->mMinHeight); |
1355 | } | 1381 | } |
1356 | total_height += llround(panelp->getRect().getHeight() * (*panel_it)->mVisibleAmt); | 1382 | total_height += llround(panelp->getRect().getHeight() * (*panel_it)->getCollapseFactor()); |
1357 | if (panel_it != mPanels.begin()) | 1383 | if (panel_it != mPanels.begin()) |
1358 | { | 1384 | { |
1359 | total_height += mPanelSpacing; | 1385 | total_height += mPanelSpacing; |
@@ -1367,7 +1393,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) | |||
1367 | for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) | 1393 | for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) |
1368 | { | 1394 | { |
1369 | // panels that are not fully visible do not count towards shrink headroom | 1395 | // panels that are not fully visible do not count towards shrink headroom |
1370 | if ((*panel_it)->mVisibleAmt < 1.f) | 1396 | if ((*panel_it)->getCollapseFactor() < 1.f) |
1371 | { | 1397 | { |
1372 | continue; | 1398 | continue; |
1373 | } | 1399 | } |
@@ -1431,7 +1457,7 @@ void LLLayoutStack::updateLayout(BOOL force_resize) | |||
1431 | S32 delta_size = 0; | 1457 | S32 delta_size = 0; |
1432 | 1458 | ||
1433 | // if panel can automatically resize (not animating, and resize flag set)... | 1459 | // if panel can automatically resize (not animating, and resize flag set)... |
1434 | if ((*panel_it)->mVisibleAmt == 1.f | 1460 | if ((*panel_it)->getCollapseFactor() == 1.f |
1435 | && (force_resize || (*panel_it)->mAutoResize) | 1461 | && (force_resize || (*panel_it)->mAutoResize) |
1436 | && !(*panel_it)->mResizeBar->hasMouseCapture()) | 1462 | && !(*panel_it)->mResizeBar->hasMouseCapture()) |
1437 | { | 1463 | { |
@@ -1515,11 +1541,11 @@ void LLLayoutStack::updateLayout(BOOL force_resize) | |||
1515 | 1541 | ||
1516 | if (mOrientation == HORIZONTAL) | 1542 | if (mOrientation == HORIZONTAL) |
1517 | { | 1543 | { |
1518 | cur_x += llround(new_width * (*panel_it)->mVisibleAmt) + mPanelSpacing; | 1544 | cur_x += llround(new_width * (*panel_it)->getCollapseFactor()) + mPanelSpacing; |
1519 | } | 1545 | } |
1520 | else //VERTICAL | 1546 | else //VERTICAL |
1521 | { | 1547 | { |
1522 | cur_y -= llround(new_height * (*panel_it)->mVisibleAmt) + mPanelSpacing; | 1548 | cur_y -= llround(new_height * (*panel_it)->getCollapseFactor()) + mPanelSpacing; |
1523 | } | 1549 | } |
1524 | } | 1550 | } |
1525 | 1551 | ||