aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltoolbar.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/newview/lltoolbar.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 'linden/indra/newview/lltoolbar.cpp')
-rw-r--r--linden/indra/newview/lltoolbar.cpp186
1 files changed, 164 insertions, 22 deletions
diff --git a/linden/indra/newview/lltoolbar.cpp b/linden/indra/newview/lltoolbar.cpp
index 5cddc59..e3aa9a3 100644
--- a/linden/indra/newview/lltoolbar.cpp
+++ b/linden/indra/newview/lltoolbar.cpp
@@ -13,12 +13,12 @@
13 * ("GPL"), unless you have obtained a separate licensing agreement 13 * ("GPL"), unless you have obtained a separate licensing agreement
14 * ("Other License"), formally executed by you and Linden Lab. Terms of 14 * ("Other License"), formally executed by you and Linden Lab. Terms of
15 * the GPL can be found in doc/GPL-license.txt in this distribution, or 15 * the GPL can be found in doc/GPL-license.txt in this distribution, or
16 * online at http://secondlife.com/developers/opensource/gplv2 16 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
17 * 17 *
18 * There are special exceptions to the terms and conditions of the GPL as 18 * There are special exceptions to the terms and conditions of the GPL as
19 * it is applied to this Source Code. View the full text of the exception 19 * it is applied to this Source Code. View the full text of the exception
20 * in the file doc/FLOSS-exception.txt in this software distribution, or 20 * in the file doc/FLOSS-exception.txt in this software distribution, or
21 * online at http://secondlife.com/developers/opensource/flossexception 21 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
22 * 22 *
23 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
24 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -60,6 +60,11 @@
60#include "llvieweruictrlfactory.h" 60#include "llvieweruictrlfactory.h"
61#include "llviewerwindow.h" 61#include "llviewerwindow.h"
62#include "lltoolgrab.h" 62#include "lltoolgrab.h"
63#include "llcombobox.h"
64#include "llfloaterchat.h"
65#include "llfloatermute.h"
66#include "llimpanel.h"
67#include "llscrolllistctrl.h"
63 68
64#if LL_DARWIN 69#if LL_DARWIN
65 70
@@ -100,24 +105,20 @@ F32 LLToolBar::sInventoryAutoOpenTime = 1.f;
100// Functions 105// Functions
101// 106//
102 107
103LLToolBar::LLToolBar(const std::string& name, const LLRect& r) 108LLToolBar::LLToolBar()
104: LLPanel(name, r, BORDER_NO) 109: LLPanel()
105#if LL_DARWIN 110#if LL_DARWIN
106 , mResizeHandle(NULL) 111 , mResizeHandle(NULL)
107#endif // LL_DARWIN 112#endif // LL_DARWIN
108{ 113{
109 setIsChrome(TRUE); 114 setIsChrome(TRUE);
110 setFollows( FOLLOWS_LEFT | FOLLOWS_RIGHT | FOLLOWS_BOTTOM ); 115 setFocusRoot(TRUE);
111
112 gUICtrlFactory->buildPanel(this, "panel_toolbar.xml");
113 mIsFocusRoot = TRUE;
114
115} 116}
116 117
117 118
118BOOL LLToolBar::postBuild() 119BOOL LLToolBar::postBuild()
119{ 120{
120 childSetAction("communicate_btn", onClickCommunicate, this); 121 childSetCommitCallback("communicate_btn", onClickCommunicate, this);
121 childSetControlName("communicate_btn", "ShowCommunicate"); 122 childSetControlName("communicate_btn", "ShowCommunicate");
122 123
123 childSetAction("chat_btn", onClickChat, this); 124 childSetAction("chat_btn", onClickChat, this);
@@ -270,29 +271,47 @@ void LLToolBar::layoutButtons()
270 } 271 }
271#endif // LL_DARWIN 272#endif // LL_DARWIN
272 273
274 LLButton* chat_button = LLUICtrlFactory::getButtonByName(this, "chat_btn");
275 if (chat_button)
276 {
277 width -= chat_button->getRect().getWidth() + pad;
278 }
279
273 // We actually want to extend "pad" pixels off the right edge of the 280 // We actually want to extend "pad" pixels off the right edge of the
274 // screen, such that the rightmost button is aligned. 281 // screen, such that the rightmost button is aligned.
275 F32 segment_width = (F32)(width + pad) / (F32)count; 282 S32 segment_width = llround((F32)(width) / ((F32)count - 1.f));
276 S32 btn_width = lltrunc(segment_width - pad); 283 S32 btn_width = segment_width - pad;
277 284
278 // Evenly space all views 285 // Evenly space all views
279 S32 height = -1; 286 S32 height = -1;
280 S32 i = count - 1; 287 S32 i = count - 1;
281 for (child_list_const_iter_t child_iter = getChildList()->begin(); 288 S32 x = pad;
282 child_iter != getChildList()->end(); ++child_iter) 289 for (child_list_const_reverse_iter_t child_iter = getChildList()->rbegin();
290 child_iter != getChildList()->rend(); ++child_iter)
283 { 291 {
284 LLView *btn_view = *child_iter; 292 LLView *btn_view = *child_iter;
285 if(btn_view->getWidgetType() == WIDGET_TYPE_BUTTON) 293 if(btn_view->getWidgetType() == WIDGET_TYPE_BUTTON || btn_view->getWidgetType() == WIDGET_TYPE_FLYOUT_BUTTON)
286 { 294 {
287 if (height < 0) 295 if (height < 0)
288 { 296 {
289 height = btn_view->getRect().getHeight(); 297 height = btn_view->getRect().getHeight();
290 } 298 }
291 S32 x = llround(i*segment_width); 299
292 S32 y = 0; 300 LLRect r;
293 LLRect r; 301
294 r.setOriginAndSize(x, y, btn_width, height); 302 if (btn_view->getName() == "chat_btn")
295 btn_view->setRect(r); 303 {
304 r.setOriginAndSize(x, 0, btn_view->getRect().getWidth(), height);
305 x += btn_view->getRect().getWidth() + pad;
306 }
307 else
308 {
309 r.setOriginAndSize(x, 0, btn_width, height);
310 x += segment_width;
311 }
312
313 btn_view->setOrigin(r.mLeft, r.mBottom);
314 btn_view->reshape(r.getWidth(), r.getHeight());
296 i--; 315 i--;
297 } 316 }
298 } 317 }
@@ -321,6 +340,7 @@ void LLToolBar::refresh()
321 340
322 childSetEnabled("build_btn", gParcelMgr->agentCanBuild() ); 341 childSetEnabled("build_btn", gParcelMgr->agentCanBuild() );
323 342
343
324 // Check to see if we're in build mode 344 // Check to see if we're in build mode
325 BOOL build_mode = gToolMgr->inEdit(); 345 BOOL build_mode = gToolMgr->inEdit();
326 // And not just clicking on a scripted object 346 // And not just clicking on a scripted object
@@ -329,13 +349,135 @@ void LLToolBar::refresh()
329 build_mode = FALSE; 349 build_mode = FALSE;
330 } 350 }
331 gSavedSettings.setBOOL("BuildBtnState", build_mode); 351 gSavedSettings.setBOOL("BuildBtnState", build_mode);
352
353 updateCommunicateList();
354}
355
356void LLToolBar::updateCommunicateList()
357{
358 LLFlyoutButton* communicate_button = (LLFlyoutButton*)getChildByName("communicate_btn", TRUE);
359 if (communicate_button)
360 {
361 LLSD selected = communicate_button->getValue();
362
363 communicate_button->removeall();
364
365 LLFloater* frontmost_floater = LLFloaterChatterBox::getInstance()->getActiveFloater();
366 LLScrollListItem* itemp = NULL;
367
368 itemp = communicate_button->add(LLFloaterMyFriends::getInstance()->getShortTitle(), LLSD("contacts"), ADD_TOP);
369 if (LLFloaterMyFriends::getInstance() == frontmost_floater)
370 {
371 ((LLScrollListText*)itemp->getColumn(0))->setFontStyle(LLFontGL::BOLD);
372 // make sure current tab is selected in list
373 if (selected.isUndefined())
374 {
375 selected = itemp->getValue();
376 }
377 }
378 itemp = communicate_button->add(LLFloaterChat::getInstance()->getShortTitle(), LLSD("local chat"), ADD_TOP);
379 if (LLFloaterChat::getInstance() == frontmost_floater)
380 {
381 ((LLScrollListText*)itemp->getColumn(0))->setFontStyle(LLFontGL::BOLD);
382 if (selected.isUndefined())
383 {
384 selected = itemp->getValue();
385 }
386 }
387 communicate_button->addSeparator(ADD_TOP);
388 communicate_button->add(getUIString("Redock Windows"), LLSD("redock"), ADD_TOP);
389 communicate_button->addSeparator(ADD_TOP);
390 communicate_button->add(LLFloaterMute::getInstance()->getShortTitle(), LLSD("mute list"), ADD_TOP);
391
392 std::set<LLViewHandle>::const_iterator floater_handle_it;
393
394 if (gIMMgr->getIMFloaterHandles().size() > 0)
395 {
396 communicate_button->addSeparator(ADD_TOP);
397 }
398
399 for(floater_handle_it = gIMMgr->getIMFloaterHandles().begin(); floater_handle_it != gIMMgr->getIMFloaterHandles().end(); ++floater_handle_it)
400 {
401 LLFloaterIMPanel* im_floaterp = (LLFloaterIMPanel*)LLFloater::getFloaterByHandle(*floater_handle_it);
402 if (im_floaterp)
403 {
404 LLString floater_title = im_floaterp->getNumUnreadMessages() > 0 ? "*" : "";
405 floater_title.append(im_floaterp->getShortTitle());
406 itemp = communicate_button->add(floater_title, im_floaterp->getSessionID(), ADD_TOP);
407 if (im_floaterp == frontmost_floater)
408 {
409 ((LLScrollListText*)itemp->getColumn(0))->setFontStyle(LLFontGL::BOLD);
410 if (selected.isUndefined())
411 {
412 selected = itemp->getValue();
413 }
414 }
415 }
416 }
417
418 communicate_button->setToggleState(gSavedSettings.getBOOL("ShowCommunicate"));
419 communicate_button->setValue(selected);
420 }
332} 421}
333 422
334 423
335// static 424// static
336void LLToolBar::onClickCommunicate(void* user_data) 425void LLToolBar::onClickCommunicate(LLUICtrl* ctrl, void* user_data)
337{ 426{
338 LLFloaterChatterBox::toggleInstance(LLSD()); 427 LLToolBar* toolbar = (LLToolBar*)user_data;
428 LLFlyoutButton* communicate_button = (LLFlyoutButton*)toolbar->getChildByName("communicate_btn", TRUE);
429
430 LLSD selected_option = communicate_button->getValue();
431
432 if (selected_option.asString() == "contacts")
433 {
434 LLFloaterMyFriends::showInstance();
435 }
436 else if (selected_option.asString() == "local chat")
437 {
438 LLFloaterChat::showInstance();
439 }
440 else if (selected_option.asString() == "redock")
441 {
442 LLFloaterChatterBox::getInstance()->addFloater(LLFloaterMyFriends::getInstance(), FALSE);
443 LLFloaterChatterBox::getInstance()->addFloater(LLFloaterChat::getInstance(), FALSE);
444 LLUUID session_to_show;
445
446 std::set<LLViewHandle>::const_iterator floater_handle_it;
447 for(floater_handle_it = gIMMgr->getIMFloaterHandles().begin(); floater_handle_it != gIMMgr->getIMFloaterHandles().end(); ++floater_handle_it)
448 {
449 LLFloater* im_floaterp = LLFloater::getFloaterByHandle(*floater_handle_it);
450 if (im_floaterp)
451 {
452 if (im_floaterp->isFrontmost())
453 {
454 session_to_show = ((LLFloaterIMPanel*)im_floaterp)->getSessionID();
455 }
456 LLFloaterChatterBox::getInstance()->addFloater(im_floaterp, FALSE);
457 }
458 }
459
460 LLFloaterChatterBox::showInstance(session_to_show);
461 }
462 else if (selected_option.asString() == "mute list")
463 {
464 LLFloaterMute::showInstance();
465 }
466 else if (selected_option.isUndefined()) // user just clicked the communicate button, treat as toggle
467 {
468 if (LLFloaterChatterBox::getInstance()->getFloaterCount() == 0)
469 {
470 LLFloaterMyFriends::toggleInstance();
471 }
472 else
473 {
474 LLFloaterChatterBox::toggleInstance();
475 }
476 }
477 else // otherwise selection_option is a specific IM session id
478 {
479 LLFloaterChatterBox::showInstance(selected_option);
480 }
339} 481}
340 482
341 483