diff options
Diffstat (limited to 'linden/indra/newview/lltoolbar.cpp')
-rw-r--r-- | linden/indra/newview/lltoolbar.cpp | 165 |
1 files changed, 57 insertions, 108 deletions
diff --git a/linden/indra/newview/lltoolbar.cpp b/linden/indra/newview/lltoolbar.cpp index 9edc469..8d103ce 100644 --- a/linden/indra/newview/lltoolbar.cpp +++ b/linden/indra/newview/lltoolbar.cpp | |||
@@ -57,7 +57,7 @@ | |||
57 | #include "llviewermenu.h" | 57 | #include "llviewermenu.h" |
58 | #include "llfirstuse.h" | 58 | #include "llfirstuse.h" |
59 | #include "llviewerparcelmgr.h" | 59 | #include "llviewerparcelmgr.h" |
60 | #include "llvieweruictrlfactory.h" | 60 | #include "lluictrlfactory.h" |
61 | #include "llviewerwindow.h" | 61 | #include "llviewerwindow.h" |
62 | #include "lltoolgrab.h" | 62 | #include "lltoolgrab.h" |
63 | #include "llcombobox.h" | 63 | #include "llcombobox.h" |
@@ -158,10 +158,10 @@ BOOL LLToolBar::postBuild() | |||
158 | child_iter != getChildList()->end(); ++child_iter) | 158 | child_iter != getChildList()->end(); ++child_iter) |
159 | { | 159 | { |
160 | LLView *view = *child_iter; | 160 | LLView *view = *child_iter; |
161 | if(view->getWidgetType() == WIDGET_TYPE_BUTTON) | 161 | LLButton* buttonp = dynamic_cast<LLButton*>(view); |
162 | if(buttonp) | ||
162 | { | 163 | { |
163 | LLButton* btn = (LLButton*)view; | 164 | buttonp->setSoundFlags(LLView::SILENT); |
164 | btn->setSoundFlags(LLView::SILENT); | ||
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
@@ -171,6 +171,8 @@ BOOL LLToolBar::postBuild() | |||
171 | LLRect rect(0, 0, RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT); | 171 | LLRect rect(0, 0, RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT); |
172 | mResizeHandle = new LLFakeResizeHandle(LLString(""), rect, RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT); | 172 | mResizeHandle = new LLFakeResizeHandle(LLString(""), rect, RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT); |
173 | this->addChildAtEnd(mResizeHandle); | 173 | this->addChildAtEnd(mResizeHandle); |
174 | LLLayoutStack* toolbar_stack = getChild<LLLayoutStack>("toolbar_stack"); | ||
175 | toolbar_stack->reshape(toolbar_stack->getRect().getWidth() - RESIZE_HANDLE_WIDTH, toolbar_stack->getRect().getHeight()); | ||
174 | } | 176 | } |
175 | #endif // LL_DARWIN | 177 | #endif // LL_DARWIN |
176 | 178 | ||
@@ -191,7 +193,7 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, | |||
191 | EAcceptance* accept, | 193 | EAcceptance* accept, |
192 | LLString& tooltip_msg) | 194 | LLString& tooltip_msg) |
193 | { | 195 | { |
194 | LLButton* inventory_btn = LLUICtrlFactory::getButtonByName(this, "inventory_btn"); | 196 | LLButton* inventory_btn = getChild<LLButton>("inventory_btn"); |
195 | if (!inventory_btn) return FALSE; | 197 | if (!inventory_btn) return FALSE; |
196 | 198 | ||
197 | LLInventoryView* active_inventory = LLInventoryView::getActiveInventory(); | 199 | LLInventoryView* active_inventory = LLInventoryView::getActiveInventory(); |
@@ -238,19 +240,14 @@ BOOL LLToolBar::visible(void*) | |||
238 | 240 | ||
239 | void LLToolBar::layoutButtons() | 241 | void LLToolBar::layoutButtons() |
240 | { | 242 | { |
241 | // Always spans whole window. JC | 243 | #if LL_DARWIN |
242 | const S32 FUDGE_WIDTH_OF_SCREEN = 4; | 244 | const S32 FUDGE_WIDTH_OF_SCREEN = 4; |
243 | S32 width = gViewerWindow->getWindowWidth() + FUDGE_WIDTH_OF_SCREEN; | 245 | S32 width = gViewerWindow->getWindowWidth() + FUDGE_WIDTH_OF_SCREEN; |
244 | S32 count = getChildCount(); | ||
245 | S32 pad = 2; | 246 | S32 pad = 2; |
246 | 247 | ||
247 | #if LL_DARWIN | ||
248 | // this function may be called before postBuild(), in which case mResizeHandle won't have been set up yet. | 248 | // this function may be called before postBuild(), in which case mResizeHandle won't have been set up yet. |
249 | if(mResizeHandle != NULL) | 249 | if(mResizeHandle != NULL) |
250 | { | 250 | { |
251 | // a resize handle has been added as a child, increasing the count by one. | ||
252 | count--; | ||
253 | |||
254 | if(!gViewerWindow->getWindow()->getFullscreen()) | 251 | if(!gViewerWindow->getWindow()->getFullscreen()) |
255 | { | 252 | { |
256 | // Only when running in windowed mode on the Mac, leave room for a resize widget on the right edge of the bar. | 253 | // Only when running in windowed mode on the Mac, leave room for a resize widget on the right edge of the bar. |
@@ -270,51 +267,6 @@ void LLToolBar::layoutButtons() | |||
270 | } | 267 | } |
271 | } | 268 | } |
272 | #endif // LL_DARWIN | 269 | #endif // LL_DARWIN |
273 | |||
274 | LLButton* chat_button = LLUICtrlFactory::getButtonByName(this, "chat_btn"); | ||
275 | if (chat_button) | ||
276 | { | ||
277 | width -= chat_button->getRect().getWidth() + pad; | ||
278 | } | ||
279 | |||
280 | // We actually want to extend "pad" pixels off the right edge of the | ||
281 | // screen, such that the rightmost button is aligned. | ||
282 | S32 segment_width = llround((F32)(width) / ((F32)count - 1.f)); // ignore chat button | ||
283 | S32 btn_width = segment_width - pad; | ||
284 | |||
285 | // Evenly space all views | ||
286 | S32 height = -1; | ||
287 | S32 i = count - 1; | ||
288 | S32 x = pad; | ||
289 | for (child_list_const_reverse_iter_t child_iter = getChildList()->rbegin(); | ||
290 | child_iter != getChildList()->rend(); ++child_iter) | ||
291 | { | ||
292 | LLView *btn_view = *child_iter; | ||
293 | if(btn_view->getWidgetType() == WIDGET_TYPE_BUTTON || btn_view->getWidgetType() == WIDGET_TYPE_FLYOUT_BUTTON) | ||
294 | { | ||
295 | if (height < 0) | ||
296 | { | ||
297 | height = btn_view->getRect().getHeight(); | ||
298 | } | ||
299 | |||
300 | LLRect r; | ||
301 | |||
302 | if (btn_view->getName() == "chat_btn") | ||
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()); | ||
315 | i--; | ||
316 | } | ||
317 | } | ||
318 | } | 270 | } |
319 | 271 | ||
320 | 272 | ||
@@ -338,13 +290,13 @@ void LLToolBar::refresh() | |||
338 | 290 | ||
339 | childSetEnabled("fly_btn", gAgent.canFly() || gAgent.getFlying() ); | 291 | childSetEnabled("fly_btn", gAgent.canFly() || gAgent.getFlying() ); |
340 | 292 | ||
341 | childSetEnabled("build_btn", gParcelMgr->agentCanBuild() ); | 293 | childSetEnabled("build_btn", LLViewerParcelMgr::getInstance()->agentCanBuild() ); |
342 | 294 | ||
343 | 295 | ||
344 | // Check to see if we're in build mode | 296 | // Check to see if we're in build mode |
345 | BOOL build_mode = gToolMgr->inEdit(); | 297 | BOOL build_mode = LLToolMgr::getInstance()->inEdit(); |
346 | // And not just clicking on a scripted object | 298 | // And not just clicking on a scripted object |
347 | if (gToolGrab->getHideBuildHighlight()) | 299 | if (LLToolGrab::getInstance()->getHideBuildHighlight()) |
348 | { | 300 | { |
349 | build_mode = FALSE; | 301 | build_mode = FALSE; |
350 | } | 302 | } |
@@ -355,69 +307,66 @@ void LLToolBar::refresh() | |||
355 | 307 | ||
356 | void LLToolBar::updateCommunicateList() | 308 | void LLToolBar::updateCommunicateList() |
357 | { | 309 | { |
358 | LLFlyoutButton* communicate_button = (LLFlyoutButton*)getChildByName("communicate_btn", TRUE); | 310 | LLFlyoutButton* communicate_button = getChild<LLFlyoutButton>("communicate_btn"); |
359 | if (communicate_button) | 311 | LLSD selected = communicate_button->getValue(); |
360 | { | ||
361 | LLSD selected = communicate_button->getValue(); | ||
362 | 312 | ||
363 | communicate_button->removeall(); | 313 | communicate_button->removeall(); |
364 | 314 | ||
365 | LLFloater* frontmost_floater = LLFloaterChatterBox::getInstance()->getActiveFloater(); | 315 | LLFloater* frontmost_floater = LLFloaterChatterBox::getInstance()->getActiveFloater(); |
366 | LLScrollListItem* itemp = NULL; | 316 | LLScrollListItem* itemp = NULL; |
367 | 317 | ||
368 | itemp = communicate_button->add(LLFloaterMyFriends::getInstance()->getShortTitle(), LLSD("contacts"), ADD_TOP); | 318 | itemp = communicate_button->add(LLFloaterMyFriends::getInstance()->getShortTitle(), LLSD("contacts"), ADD_TOP); |
369 | if (LLFloaterMyFriends::getInstance() == frontmost_floater) | 319 | if (LLFloaterMyFriends::getInstance() == frontmost_floater) |
320 | { | ||
321 | ((LLScrollListText*)itemp->getColumn(0))->setFontStyle(LLFontGL::BOLD); | ||
322 | // make sure current tab is selected in list | ||
323 | if (selected.isUndefined()) | ||
370 | { | 324 | { |
371 | ((LLScrollListText*)itemp->getColumn(0))->setFontStyle(LLFontGL::BOLD); | 325 | selected = itemp->getValue(); |
372 | // make sure current tab is selected in list | ||
373 | if (selected.isUndefined()) | ||
374 | { | ||
375 | selected = itemp->getValue(); | ||
376 | } | ||
377 | } | 326 | } |
378 | itemp = communicate_button->add(LLFloaterChat::getInstance()->getShortTitle(), LLSD("local chat"), ADD_TOP); | 327 | } |
379 | if (LLFloaterChat::getInstance() == frontmost_floater) | 328 | itemp = communicate_button->add(LLFloaterChat::getInstance()->getShortTitle(), LLSD("local chat"), ADD_TOP); |
329 | if (LLFloaterChat::getInstance() == frontmost_floater) | ||
330 | { | ||
331 | ((LLScrollListText*)itemp->getColumn(0))->setFontStyle(LLFontGL::BOLD); | ||
332 | if (selected.isUndefined()) | ||
380 | { | 333 | { |
381 | ((LLScrollListText*)itemp->getColumn(0))->setFontStyle(LLFontGL::BOLD); | 334 | selected = itemp->getValue(); |
382 | if (selected.isUndefined()) | ||
383 | { | ||
384 | selected = itemp->getValue(); | ||
385 | } | ||
386 | } | 335 | } |
387 | communicate_button->addSeparator(ADD_TOP); | 336 | } |
388 | communicate_button->add(getUIString("Redock Windows"), LLSD("redock"), ADD_TOP); | 337 | communicate_button->addSeparator(ADD_TOP); |
389 | communicate_button->addSeparator(ADD_TOP); | 338 | communicate_button->add(getUIString("Redock Windows"), LLSD("redock"), ADD_TOP); |
390 | communicate_button->add(LLFloaterMute::getInstance()->getShortTitle(), LLSD("mute list"), ADD_TOP); | 339 | communicate_button->addSeparator(ADD_TOP); |
391 | 340 | communicate_button->add(LLFloaterMute::getInstance()->getShortTitle(), LLSD("mute list"), ADD_TOP); | |
392 | std::set<LLHandle<LLFloater> >::const_iterator floater_handle_it; | 341 | |
342 | std::set<LLHandle<LLFloater> >::const_iterator floater_handle_it; | ||
393 | 343 | ||
394 | if (gIMMgr->getIMFloaterHandles().size() > 0) | 344 | if (gIMMgr->getIMFloaterHandles().size() > 0) |
395 | { | 345 | { |
396 | communicate_button->addSeparator(ADD_TOP); | 346 | communicate_button->addSeparator(ADD_TOP); |
397 | } | 347 | } |
398 | 348 | ||
399 | for(floater_handle_it = gIMMgr->getIMFloaterHandles().begin(); floater_handle_it != gIMMgr->getIMFloaterHandles().end(); ++floater_handle_it) | 349 | for(floater_handle_it = gIMMgr->getIMFloaterHandles().begin(); floater_handle_it != gIMMgr->getIMFloaterHandles().end(); ++floater_handle_it) |
350 | { | ||
351 | LLFloaterIMPanel* im_floaterp = (LLFloaterIMPanel*)floater_handle_it->get(); | ||
352 | if (im_floaterp) | ||
400 | { | 353 | { |
401 | LLFloaterIMPanel* im_floaterp = (LLFloaterIMPanel*)floater_handle_it->get(); | 354 | LLString floater_title = im_floaterp->getNumUnreadMessages() > 0 ? "*" : ""; |
402 | if (im_floaterp) | 355 | floater_title.append(im_floaterp->getShortTitle()); |
356 | itemp = communicate_button->add(floater_title, im_floaterp->getSessionID(), ADD_TOP); | ||
357 | if (im_floaterp == frontmost_floater) | ||
403 | { | 358 | { |
404 | LLString floater_title = im_floaterp->getNumUnreadMessages() > 0 ? "*" : ""; | 359 | ((LLScrollListText*)itemp->getColumn(0))->setFontStyle(LLFontGL::BOLD); |
405 | floater_title.append(im_floaterp->getShortTitle()); | 360 | if (selected.isUndefined()) |
406 | itemp = communicate_button->add(floater_title, im_floaterp->getSessionID(), ADD_TOP); | ||
407 | if (im_floaterp == frontmost_floater) | ||
408 | { | 361 | { |
409 | ((LLScrollListText*)itemp->getColumn(0))->setFontStyle(LLFontGL::BOLD); | 362 | selected = itemp->getValue(); |
410 | if (selected.isUndefined()) | ||
411 | { | ||
412 | selected = itemp->getValue(); | ||
413 | } | ||
414 | } | 363 | } |
415 | } | 364 | } |
416 | } | 365 | } |
417 | |||
418 | communicate_button->setToggleState(gSavedSettings.getBOOL("ShowCommunicate")); | ||
419 | communicate_button->setValue(selected); | ||
420 | } | 366 | } |
367 | |||
368 | communicate_button->setToggleState(gSavedSettings.getBOOL("ShowCommunicate")); | ||
369 | communicate_button->setValue(selected); | ||
421 | } | 370 | } |
422 | 371 | ||
423 | 372 | ||
@@ -425,7 +374,7 @@ void LLToolBar::updateCommunicateList() | |||
425 | void LLToolBar::onClickCommunicate(LLUICtrl* ctrl, void* user_data) | 374 | void LLToolBar::onClickCommunicate(LLUICtrl* ctrl, void* user_data) |
426 | { | 375 | { |
427 | LLToolBar* toolbar = (LLToolBar*)user_data; | 376 | LLToolBar* toolbar = (LLToolBar*)user_data; |
428 | LLFlyoutButton* communicate_button = (LLFlyoutButton*)toolbar->getChildByName("communicate_btn", TRUE); | 377 | LLFlyoutButton* communicate_button = toolbar->getChild<LLFlyoutButton>("communicate_btn"); |
429 | 378 | ||
430 | LLSD selected_option = communicate_button->getValue(); | 379 | LLSD selected_option = communicate_button->getValue(); |
431 | 380 | ||