Compare commits
2 Commits
8e5972cec8
...
fd48860131
Author | SHA1 | Date |
---|---|---|
Pascal Abresch | fd48860131 | |
Pascal Abresch | 97d639c4bf |
|
@ -22,14 +22,6 @@ RosterItem::RosterItem(const UserID *userid)
|
|||
{
|
||||
_userid = userid;
|
||||
_is_stale_pointer = false;
|
||||
|
||||
// intitialize static members
|
||||
if (_offline_icon == NULL) {
|
||||
_kinda_online_icon = LoadIconFromResource("away-online");
|
||||
_online_icon = LoadIconFromResource("online");
|
||||
_offline_icon = LoadIconFromResource("offline");
|
||||
_unknown_icon = LoadIconFromResource("unknown");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,6 +44,21 @@ void RosterItem::DrawItem(BView *owner, BRect frame, __attribute__((unused)) boo
|
|||
return;
|
||||
}
|
||||
|
||||
font_height fh;
|
||||
owner->GetFontHeight(&fh);
|
||||
|
||||
float iconSize = fh.ascent + fh.descent;
|
||||
iconSize = floorf(fh.ascent + fh.descent);
|
||||
|
||||
// intitialize static members
|
||||
if (_offline_icon == NULL) {
|
||||
iconSize = iconSize * 16 / 11;
|
||||
_kinda_online_icon = LoadIconFromResource("away-online", iconSize);
|
||||
_online_icon = LoadIconFromResource("online", iconSize);
|
||||
_offline_icon = LoadIconFromResource("offline", iconSize);
|
||||
_unknown_icon = LoadIconFromResource("unknown", iconSize);
|
||||
}
|
||||
|
||||
// get online status
|
||||
UserID::online_status status = _userid->OnlineStatus();
|
||||
std::string exact_status = _userid->ExactOnlineStatus();
|
||||
|
@ -61,23 +68,7 @@ void RosterItem::DrawItem(BView *owner, BRect frame, __attribute__((unused)) boo
|
|||
|
||||
// clear rectangle
|
||||
if (IsSelected()) {
|
||||
if (status == UserID::ONLINE) {
|
||||
if(exact_status == "xa" || exact_status == "away")
|
||||
{
|
||||
owner->SetHighColor(255, 179, 0, 255);
|
||||
}
|
||||
else if(exact_status == "dnd")
|
||||
{
|
||||
owner->SetHighColor(213, 158, 158, 255);
|
||||
}
|
||||
else {
|
||||
owner->SetHighColor(158, 213, 158, 255);
|
||||
}
|
||||
} else if (status == UserID::OFFLINE) {
|
||||
owner->SetHighColor(213, 213, 213, 255);
|
||||
} else {
|
||||
owner->SetHighColor(200, 200, 255, 255);
|
||||
}
|
||||
owner->SetHighUIColor(B_LIST_SELECTED_BACKGROUND_COLOR);
|
||||
} else {
|
||||
owner->SetHighColor(owner->ViewColor());
|
||||
}
|
||||
|
@ -91,7 +82,7 @@ void RosterItem::DrawItem(BView *owner, BRect frame, __attribute__((unused)) boo
|
|||
owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
||||
|
||||
int height = frame.bottom - frame.top;
|
||||
frame.left = height - 4; // have the status badge right over the edge of the avatar
|
||||
frame.left = height - (iconSize / 2); // have the status badge right over the edge of the avatar
|
||||
if (fAvatar) {
|
||||
owner->DrawBitmapAsync(fAvatar, fAvatar->Bounds(),
|
||||
BRect(0, frame.top, height - 1, frame.bottom - 1), B_FILTER_BITMAP_BILINEAR);
|
||||
|
@ -155,17 +146,17 @@ void RosterItem::DrawItem(BView *owner, BRect frame, __attribute__((unused)) boo
|
|||
owner->SetHighColor(0, 0, 255, 255); //blue
|
||||
}
|
||||
|
||||
// construct text positioning
|
||||
font_height fh;
|
||||
owner->GetFontHeight(&fh);
|
||||
|
||||
// draw name
|
||||
BPoint textPosition(frame.left + 13, frame.top + fh.ascent + 1);
|
||||
BPoint textPosition(frame.left + iconSize, frame.top + fh.ascent + 1);
|
||||
owner->DrawString(name.c_str(), textPosition);
|
||||
|
||||
// draw show
|
||||
if (!GetUserID()->MoreExactOnlineStatus().empty()) {
|
||||
owner->SetHighColor(0, 0, 0, 255);
|
||||
if (IsSelected()) {
|
||||
owner->SetHighUIColor(B_LIST_SELECTED_ITEM_TEXT_COLOR);
|
||||
} else {
|
||||
owner->SetHighUIColor(B_LIST_ITEM_TEXT_COLOR);
|
||||
}
|
||||
textPosition.y += frame.Height() / 2;
|
||||
|
||||
owner->DrawString(GetUserID()->MoreExactOnlineStatus().c_str(), textPosition);
|
||||
|
|
Loading…
Reference in New Issue