1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
|
/**
* @file llavatarlistitem.cpp
* @brief avatar list item source file
*
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llavataractions.h"
#include "llavatarlistitem.h"
#include "llbutton.h"
#include "llclipboard.h"
#include "llfloaterreg.h"
#include "lltextutil.h"
#include "llagent.h"
#include "llavatarnamecache.h"
#include "llavatariconctrl.h"
#include "lloutputmonitorctrl.h"
#include "lltooldraganddrop.h"
bool LLAvatarListItem::sStaticInitialized = false;
S32 LLAvatarListItem::sLeftPadding = 0;
S32 LLAvatarListItem::sNameRightPadding = 0;
S32 LLAvatarListItem::sChildrenWidths[LLAvatarListItem::ALIC_COUNT];
static LLWidgetNameRegistry::StaticRegistrar sRegisterAvatarListItemParams(&typeid(LLAvatarListItem::Params), "avatar_list_item");
LLAvatarListItem::Params::Params()
: default_style("default_style"),
voice_call_invited_style("voice_call_invited_style"),
voice_call_joined_style("voice_call_joined_style"),
voice_call_left_style("voice_call_left_style"),
online_style("online_style"),
offline_style("offline_style"),
name_right_pad("name_right_pad", 0)
{};
LLAvatarListItem::LLAvatarListItem(bool not_from_ui_factory/* = true*/)
: LLPanel(),
mAvatarIcon(NULL),
mAvatarName(NULL),
mLastInteractionTime(NULL),
mIconPermissionOnline(NULL),
mIconPermissionMap(NULL),
mIconPermissionEditMine(NULL),
mIconPermissionEditTheirs(NULL),
mSpeakingIndicator(NULL),
mInfoBtn(NULL),
mProfileBtn(NULL),
mOnlineStatus(E_UNKNOWN),
mShowInfoBtn(true),
mShowProfileBtn(true),
mShowPermissions(false),
mHovered(false)
{
if (not_from_ui_factory)
{
buildFromFile("panel_avatar_list_item.xml");
}
// *NOTE: mantipov: do not use any member here. They can be uninitialized here in case instance
// is created from the UICtrlFactory
}
LLAvatarListItem::~LLAvatarListItem()
{
if (mAvatarId.notNull())
LLAvatarTracker::instance().removeParticularFriendObserver(mAvatarId, this);
}
BOOL LLAvatarListItem::postBuild()
{
mAvatarIcon = getChild<LLAvatarIconCtrl>("avatar_icon");
mAvatarName = getChild<LLTextBox>("avatar_name");
mLastInteractionTime = getChild<LLTextBox>("last_interaction");
mIconPermissionOnline = getChild<LLIconCtrl>("permission_online_icon");
mIconPermissionMap = getChild<LLIconCtrl>("permission_map_icon");
mIconPermissionEditMine = getChild<LLIconCtrl>("permission_edit_mine_icon");
mIconPermissionEditTheirs = getChild<LLIconCtrl>("permission_edit_theirs_icon");
mIconPermissionOnline->setVisible(false);
mIconPermissionMap->setVisible(false);
mIconPermissionEditMine->setVisible(false);
mIconPermissionEditTheirs->setVisible(false);
mSpeakingIndicator = getChild<LLOutputMonitorCtrl>("speaking_indicator");
mInfoBtn = getChild<LLButton>("info_btn");
mProfileBtn = getChild<LLButton>("profile_btn");
mInfoBtn->setVisible(false);
mInfoBtn->setClickedCallback(boost::bind(&LLAvatarListItem::onInfoBtnClick, this));
mProfileBtn->setVisible(false);
mProfileBtn->setClickedCallback(boost::bind(&LLAvatarListItem::onProfileBtnClick, this));
if (!sStaticInitialized)
{
// Remember children widths including their padding from the next sibling,
// so that we can hide and show them again later.
initChildrenWidths(this);
// Right padding between avatar name text box and nearest visible child.
sNameRightPadding = LLUICtrlFactory::getDefaultParams<LLAvatarListItem>().name_right_pad;
sStaticInitialized = true;
}
return TRUE;
}
S32 LLAvatarListItem::notifyParent(const LLSD& info)
{
if (info.has("visibility_changed"))
{
updateChildren();
return 1;
}
return LLPanel::notifyParent(info);
}
void LLAvatarListItem::onMouseEnter(S32 x, S32 y, MASK mask)
{
getChildView("hovered_icon")->setVisible( true);
mInfoBtn->setVisible(mShowInfoBtn);
mProfileBtn->setVisible(mShowProfileBtn);
mHovered = true;
LLPanel::onMouseEnter(x, y, mask);
showPermissions(mShowPermissions);
updateChildren();
}
void LLAvatarListItem::onMouseLeave(S32 x, S32 y, MASK mask)
{
getChildView("hovered_icon")->setVisible( false);
mInfoBtn->setVisible(false);
mProfileBtn->setVisible(false);
mHovered = false;
LLPanel::onMouseLeave(x, y, mask);
showPermissions(false);
updateChildren();
}
// virtual, called by LLAvatarTracker
void LLAvatarListItem::changed(U32 mask)
{
// no need to check mAvatarId for null in this case
setOnline(LLAvatarTracker::instance().isBuddyOnline(mAvatarId));
if (mask & LLFriendObserver::POWERS)
{
showPermissions(mShowPermissions && mHovered);
updateChildren();
}
}
void LLAvatarListItem::setOnline(bool online)
{
// *FIX: setName() overrides font style set by setOnline(). Not an issue ATM.
if (mOnlineStatus != E_UNKNOWN && (bool) mOnlineStatus == online)
return;
mOnlineStatus = (EOnlineStatus) online;
// Change avatar name font style depending on the new online status.
setState(online ? IS_ONLINE : IS_OFFLINE);
}
void LLAvatarListItem::setAvatarName(const std::string& name)
{
setNameInternal(name, mHighlihtSubstring);
}
void LLAvatarListItem::setAvatarToolTip(const std::string& tooltip)
{
mAvatarName->setToolTip(tooltip);
}
void LLAvatarListItem::setHighlight(const std::string& highlight)
{
setNameInternal(mAvatarName->getText(), mHighlihtSubstring = highlight);
}
void LLAvatarListItem::setState(EItemState item_style)
{
const LLAvatarListItem::Params& params = LLUICtrlFactory::getDefaultParams<LLAvatarListItem>();
switch(item_style)
{
default:
case IS_DEFAULT:
mAvatarNameStyle = params.default_style();
break;
case IS_VOICE_INVITED:
mAvatarNameStyle = params.voice_call_invited_style();
break;
case IS_VOICE_JOINED:
mAvatarNameStyle = params.voice_call_joined_style();
break;
case IS_VOICE_LEFT:
mAvatarNameStyle = params.voice_call_left_style();
break;
case IS_ONLINE:
mAvatarNameStyle = params.online_style();
break;
case IS_OFFLINE:
mAvatarNameStyle = params.offline_style();
break;
}
// *NOTE: You cannot set the style on a text box anymore, you must
// rebuild the text. This will cause problems if the text contains
// hyperlinks, as their styles will be wrong.
setNameInternal(mAvatarName->getText(), mHighlihtSubstring);
icon_color_map_t& item_icon_color_map = getItemIconColorMap();
mAvatarIcon->setColor(item_icon_color_map[item_style]);
}
void LLAvatarListItem::setAvatarId(const LLUUID& id, const LLUUID& session_id, bool ignore_status_changes/* = false*/, bool is_resident/* = true*/)
{
if (mAvatarId.notNull())
LLAvatarTracker::instance().removeParticularFriendObserver(mAvatarId, this);
mAvatarId = id;
mSpeakingIndicator->setSpeakerId(id, session_id);
// We'll be notified on avatar online status changes
if (!ignore_status_changes && mAvatarId.notNull())
LLAvatarTracker::instance().addParticularFriendObserver(mAvatarId, this);
if (is_resident)
{
mAvatarIcon->setValue(id);
// Set avatar name.
LLAvatarNameCache::get(id,
boost::bind(&LLAvatarListItem::onAvatarNameCache, this, _2));
}
}
void LLAvatarListItem::showLastInteractionTime(bool show)
{
mLastInteractionTime->setVisible(show);
updateChildren();
}
void LLAvatarListItem::setLastInteractionTime(U32 secs_since)
{
mLastInteractionTime->setValue(formatSeconds(secs_since));
}
void LLAvatarListItem::setShowInfoBtn(bool show)
{
mShowInfoBtn = show;
}
void LLAvatarListItem::setShowProfileBtn(bool show)
{
mShowProfileBtn = show;
}
void LLAvatarListItem::showSpeakingIndicator(bool visible)
{
// Already done? Then do nothing.
if (mSpeakingIndicator->getVisible() == (BOOL)visible)
return;
// Disabled to not contradict with SpeakingIndicatorManager functionality. EXT-3976
// probably this method should be totally removed.
// mSpeakingIndicator->setVisible(visible);
// updateChildren();
}
void LLAvatarListItem::setAvatarIconVisible(bool visible)
{
// Already done? Then do nothing.
if (mAvatarIcon->getVisible() == (BOOL)visible)
{
return;
}
// Show/hide avatar icon.
mAvatarIcon->setVisible(visible);
updateChildren();
}
void LLAvatarListItem::onInfoBtnClick()
{
LLFloaterReg::showInstance("inspect_avatar", LLSD().with("avatar_id", mAvatarId));
}
void LLAvatarListItem::onProfileBtnClick()
{
LLAvatarActions::showProfile(mAvatarId);
}
BOOL LLAvatarListItem::handleDoubleClick(S32 x, S32 y, MASK mask)
{
if(mInfoBtn->getRect().pointInRect(x, y))
{
onInfoBtnClick();
return TRUE;
}
if(mProfileBtn->getRect().pointInRect(x, y))
{
onProfileBtnClick();
return TRUE;
}
return LLPanel::handleDoubleClick(x, y, mask);
}
BOOL LLAvatarListItem::handleMouseDown(S32 x, S32 y, MASK mask)
{
if (LLUICtrl::handleMouseDown(x, y, mask))
{
return TRUE;
}
gFocusMgr.setMouseCapture(this);
S32 screen_x;
S32 screen_y;
localPointToScreen(x, y, &screen_x, &screen_y);
LLToolDragAndDrop::getInstance()->setDragStart(screen_x, screen_y);
return TRUE;
}
BOOL LLAvatarListItem::handleMouseUp( S32 x, S32 y, MASK mask )
{
if (LLUICtrl::childrenHandleMouseUp(x, y, mask))
{
return TRUE;
}
if(hasMouseCapture())
{
gFocusMgr.setMouseCapture(NULL);
}
return TRUE;
}
BOOL LLAvatarListItem::handleHover(S32 x, S32 y, MASK mask)
{
bool handled = hasMouseCapture();
if(handled)
{
S32 screen_x;
S32 screen_y;
localPointToScreen(x, y, &screen_x, &screen_y);
if(LLToolDragAndDrop::getInstance()->isOverThreshold(screen_x, screen_y))
{
// First, create the global drag and drop object
std::vector<EDragAndDropType> types;
uuid_vec_t cargo_ids;
types.push_back(DAD_PERSON);
cargo_ids.push_back(mAvatarId);
gClipboard.setSourceObject(mAvatarId, LLAssetType::AT_PERSON);
LLToolDragAndDrop::ESource src = LLToolDragAndDrop::SOURCE_PEOPLE;
LLToolDragAndDrop::getInstance()->beginMultiDrag(types, cargo_ids, src);
}
}
return handled;
}
void LLAvatarListItem::setValue( const LLSD& value )
{
if (!value.isMap()) return;;
if (!value.has("selected")) return;
getChildView("selected_icon")->setVisible( value["selected"]);
}
const LLUUID& LLAvatarListItem::getAvatarId() const
{
return mAvatarId;
}
std::string LLAvatarListItem::getAvatarName() const
{
return mAvatarName->getValue();
}
std::string LLAvatarListItem::getAvatarToolTip() const
{
return mAvatarName->getToolTip();
}
void LLAvatarListItem::updateAvatarName()
{
LLAvatarNameCache::get(getAvatarId(),
boost::bind(&LLAvatarListItem::onAvatarNameCache, this, _2));
}
//== PRIVATE SECITON ==========================================================
void LLAvatarListItem::setNameInternal(const std::string& name, const std::string& highlight)
{
LLTextUtil::textboxSetHighlightedVal(mAvatarName, mAvatarNameStyle, name, highlight);
}
void LLAvatarListItem::onAvatarNameCache(const LLAvatarName& av_name)
{
setAvatarName(av_name.mDisplayName);
setAvatarToolTip(av_name.mUsername);
//requesting the list to resort
notifyParent(LLSD().with("sort", LLSD()));
}
// Convert given number of seconds to a string like "23 minutes", "15 hours" or "3 years",
// taking i18n into account. The format string to use is taken from the panel XML.
std::string LLAvatarListItem::formatSeconds(U32 secs)
{
static const U32 LL_ALI_MIN = 60;
static const U32 LL_ALI_HOUR = LL_ALI_MIN * 60;
static const U32 LL_ALI_DAY = LL_ALI_HOUR * 24;
static const U32 LL_ALI_WEEK = LL_ALI_DAY * 7;
static const U32 LL_ALI_MONTH = LL_ALI_DAY * 30;
static const U32 LL_ALI_YEAR = LL_ALI_DAY * 365;
std::string fmt;
U32 count = 0;
if (secs >= LL_ALI_YEAR)
{
fmt = "FormatYears"; count = secs / LL_ALI_YEAR;
}
else if (secs >= LL_ALI_MONTH)
{
fmt = "FormatMonths"; count = secs / LL_ALI_MONTH;
}
else if (secs >= LL_ALI_WEEK)
{
fmt = "FormatWeeks"; count = secs / LL_ALI_WEEK;
}
else if (secs >= LL_ALI_DAY)
{
fmt = "FormatDays"; count = secs / LL_ALI_DAY;
}
else if (secs >= LL_ALI_HOUR)
{
fmt = "FormatHours"; count = secs / LL_ALI_HOUR;
}
else if (secs >= LL_ALI_MIN)
{
fmt = "FormatMinutes"; count = secs / LL_ALI_MIN;
}
else
{
fmt = "FormatSeconds"; count = secs;
}
LLStringUtil::format_map_t args;
args["[COUNT]"] = llformat("%u", count);
return getString(fmt, args);
}
// static
LLAvatarListItem::icon_color_map_t& LLAvatarListItem::getItemIconColorMap()
{
static icon_color_map_t item_icon_color_map;
if (!item_icon_color_map.empty()) return item_icon_color_map;
item_icon_color_map.insert(
std::make_pair(IS_DEFAULT,
LLUIColorTable::instance().getColor("AvatarListItemIconDefaultColor", LLColor4::white)));
item_icon_color_map.insert(
std::make_pair(IS_VOICE_INVITED,
LLUIColorTable::instance().getColor("AvatarListItemIconVoiceInvitedColor", LLColor4::white)));
item_icon_color_map.insert(
std::make_pair(IS_VOICE_JOINED,
LLUIColorTable::instance().getColor("AvatarListItemIconVoiceJoinedColor", LLColor4::white)));
item_icon_color_map.insert(
std::make_pair(IS_VOICE_LEFT,
LLUIColorTable::instance().getColor("AvatarListItemIconVoiceLeftColor", LLColor4::white)));
item_icon_color_map.insert(
std::make_pair(IS_ONLINE,
LLUIColorTable::instance().getColor("AvatarListItemIconOnlineColor", LLColor4::white)));
item_icon_color_map.insert(
std::make_pair(IS_OFFLINE,
LLUIColorTable::instance().getColor("AvatarListItemIconOfflineColor", LLColor4::white)));
return item_icon_color_map;
}
// static
void LLAvatarListItem::initChildrenWidths(LLAvatarListItem* avatar_item)
{
//speaking indicator width + padding
S32 speaking_indicator_width = avatar_item->getRect().getWidth() - avatar_item->mSpeakingIndicator->getRect().mLeft;
//profile btn width + padding
S32 profile_btn_width = avatar_item->mSpeakingIndicator->getRect().mLeft - avatar_item->mProfileBtn->getRect().mLeft;
//info btn width + padding
S32 info_btn_width = avatar_item->mProfileBtn->getRect().mLeft - avatar_item->mInfoBtn->getRect().mLeft;
// online permission icon width + padding
S32 permission_online_width = avatar_item->mInfoBtn->getRect().mLeft - avatar_item->mIconPermissionOnline->getRect().mLeft;
// map permission icon width + padding
S32 permission_map_width = avatar_item->mIconPermissionOnline->getRect().mLeft - avatar_item->mIconPermissionMap->getRect().mLeft;
// edit my objects permission icon width + padding
S32 permission_edit_mine_width = avatar_item->mIconPermissionMap->getRect().mLeft - avatar_item->mIconPermissionEditMine->getRect().mLeft;
// edit their objects permission icon width + padding
S32 permission_edit_theirs_width = avatar_item->mIconPermissionEditMine->getRect().mLeft - avatar_item->mIconPermissionEditTheirs->getRect().mLeft;
// last interaction time textbox width + padding
S32 last_interaction_time_width = avatar_item->mIconPermissionEditTheirs->getRect().mLeft - avatar_item->mLastInteractionTime->getRect().mLeft;
// avatar icon width + padding
S32 icon_width = avatar_item->mAvatarName->getRect().mLeft - avatar_item->mAvatarIcon->getRect().mLeft;
sLeftPadding = avatar_item->mAvatarIcon->getRect().mLeft;
S32 index = ALIC_COUNT;
sChildrenWidths[--index] = icon_width;
sChildrenWidths[--index] = 0; // for avatar name we don't need its width, it will be calculated as "left available space"
sChildrenWidths[--index] = last_interaction_time_width;
sChildrenWidths[--index] = permission_edit_theirs_width;
sChildrenWidths[--index] = permission_edit_mine_width;
sChildrenWidths[--index] = permission_map_width;
sChildrenWidths[--index] = permission_online_width;
sChildrenWidths[--index] = info_btn_width;
sChildrenWidths[--index] = profile_btn_width;
sChildrenWidths[--index] = speaking_indicator_width;
llassert(index == 0);
}
void LLAvatarListItem::updateChildren()
{
LL_DEBUGS("AvatarItemReshape") << LL_ENDL;
LL_DEBUGS("AvatarItemReshape") << "Updating for: " << getAvatarName() << LL_ENDL;
S32 name_new_width = getRect().getWidth();
S32 ctrl_new_left = name_new_width;
S32 name_new_left = sLeftPadding;
// iterate through all children and set them into correct position depend on each child visibility
// assume that child indexes are in back order: the first in Enum is the last (right) in the item
// iterate & set child views starting from right to left
for (S32 i = 0; i < ALIC_COUNT; ++i)
{
// skip "name" textbox, it will be processed out of loop later
if (ALIC_NAME == i) continue;
LLView* control = getItemChildView((EAvatarListItemChildIndex)i);
LL_DEBUGS("AvatarItemReshape") << "Processing control: " << control->getName() << LL_ENDL;
// skip invisible views
if (!control->getVisible()) continue;
S32 ctrl_width = sChildrenWidths[i]; // including space between current & left controls
// decrease available for
name_new_width -= ctrl_width;
LL_DEBUGS("AvatarItemReshape") << "width: " << ctrl_width << ", name_new_width: " << name_new_width << LL_ENDL;
LLRect control_rect = control->getRect();
LL_DEBUGS("AvatarItemReshape") << "rect before: " << control_rect << LL_ENDL;
if (ALIC_ICON == i)
{
// assume that this is the last iteration,
// so it is not necessary to save "ctrl_new_left" value calculated on previous iterations
ctrl_new_left = sLeftPadding;
name_new_left = ctrl_new_left + ctrl_width;
}
else
{
ctrl_new_left -= ctrl_width;
}
LL_DEBUGS("AvatarItemReshape") << "ctrl_new_left: " << ctrl_new_left << LL_ENDL;
control_rect.setLeftTopAndSize(
ctrl_new_left,
control_rect.mTop,
control_rect.getWidth(),
control_rect.getHeight());
LL_DEBUGS("AvatarItemReshape") << "rect after: " << control_rect << LL_ENDL;
control->setShape(control_rect);
}
// set size and position of the "name" child
LLView* name_view = getItemChildView(ALIC_NAME);
LLRect name_view_rect = name_view->getRect();
LL_DEBUGS("AvatarItemReshape") << "name rect before: " << name_view_rect << LL_ENDL;
// apply paddings
name_new_width -= sLeftPadding;
name_new_width -= sNameRightPadding;
name_view_rect.setLeftTopAndSize(
name_new_left,
name_view_rect.mTop,
name_new_width,
name_view_rect.getHeight());
name_view->setShape(name_view_rect);
LL_DEBUGS("AvatarItemReshape") << "name rect after: " << name_view_rect << LL_ENDL;
}
bool LLAvatarListItem::showPermissions(bool visible)
{
const LLRelationship* relation = LLAvatarTracker::instance().getBuddyInfo(getAvatarId());
if(relation && visible)
{
mIconPermissionOnline->setVisible(relation->isRightGrantedTo(LLRelationship::GRANT_ONLINE_STATUS));
mIconPermissionMap->setVisible(relation->isRightGrantedTo(LLRelationship::GRANT_MAP_LOCATION));
mIconPermissionEditMine->setVisible(relation->isRightGrantedTo(LLRelationship::GRANT_MODIFY_OBJECTS));
mIconPermissionEditTheirs->setVisible(relation->isRightGrantedFrom(LLRelationship::GRANT_MODIFY_OBJECTS));
}
else
{
mIconPermissionOnline->setVisible(false);
mIconPermissionMap->setVisible(false);
mIconPermissionEditMine->setVisible(false);
mIconPermissionEditTheirs->setVisible(false);
}
return NULL != relation;
}
LLView* LLAvatarListItem::getItemChildView(EAvatarListItemChildIndex child_view_index)
{
LLView* child_view = mAvatarName;
switch (child_view_index)
{
case ALIC_ICON:
child_view = mAvatarIcon;
break;
case ALIC_NAME:
child_view = mAvatarName;
break;
case ALIC_INTERACTION_TIME:
child_view = mLastInteractionTime;
break;
case ALIC_SPEAKER_INDICATOR:
child_view = mSpeakingIndicator;
break;
case ALIC_PERMISSION_ONLINE:
child_view = mIconPermissionOnline;
break;
case ALIC_PERMISSION_MAP:
child_view = mIconPermissionMap;
break;
case ALIC_PERMISSION_EDIT_MINE:
child_view = mIconPermissionEditMine;
break;
case ALIC_PERMISSION_EDIT_THEIRS:
child_view = mIconPermissionEditTheirs;
break;
case ALIC_INFO_BUTTON:
child_view = mInfoBtn;
break;
case ALIC_PROFILE_BUTTON:
child_view = mProfileBtn;
break;
default:
LL_WARNS("AvatarItemReshape") << "Unexpected child view index is passed: " << child_view_index << LL_ENDL;
// leave child_view untouched
}
return child_view;
}
// EOF
|