diff --git a/application/views/RosterItem.cpp b/application/views/RosterItem.cpp index 1afb7fb..8679f08 100644 --- a/application/views/RosterItem.cpp +++ b/application/views/RosterItem.cpp @@ -5,6 +5,7 @@ * Authors: * Andrea Anzani, andrea.anzani@gmail.com * Pier Luigi Fiorini, pierluigi.fiorini@gmail.com + * Jaidyn Levesque, jadedctrl@teknik.io */ #include @@ -21,11 +22,11 @@ RosterItem::RosterItem(const char* name, Contact* contact) : BStringItem(name), fBitmap(contact->AvatarBitmap()), - fStatus(STATUS_OFFLINE), - contactLinker(contact), + fStatus(contact->GetNotifyStatus()), + fContact(contact), fVisible(true) { - rgb_color highlightColor = ui_color(B_CONTROL_HIGHLIGHT_COLOR); + rgb_color highlightColor = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR); rgb_color darkenHighlightColor = tint_color(highlightColor, B_DARKEN_1_TINT); fGradient.AddColor(highlightColor, 0); @@ -154,18 +155,19 @@ RosterItem::DrawItem(BView* owner, BRect frame, bool complete) // Draw contact status string owner->MovePenTo(frame.left + 48, frame.top + fBaselineOffset + fBaselineOffset + 3); - owner->SetHighColor(tint_color(lowColor, B_DARKEN_2_TINT)); + owner->SetHighColor(TintColor(owner->HighColor(), 2)); if (fPersonalStatus.Length() == 0) owner->DrawString(UserStatusToString(fStatus)); else owner->DrawString(fPersonalStatus); // Draw separator between items + owner->SetHighColor(tint_color(lowColor, B_DARKEN_2_TINT)); owner->StrokeLine(BPoint(frame.left, frame.bottom), BPoint(frame.right, frame.bottom)); // Draw protocol bitmpap - BBitmap* protocolBitmap = contactLinker->ProtocolBitmap(); + BBitmap* protocolBitmap = fContact->ProtocolBitmap(); if (protocolBitmap != NULL) { BRect rect(frame.right - 19, frame.top + 2, @@ -175,7 +177,6 @@ RosterItem::DrawItem(BView* owner, BRect frame, bool complete) owner->DrawBitmap(protocolBitmap, protocolBitmap->Bounds(), rect, B_FILTER_BITMAP_BILINEAR); } - owner->SetHighColor(highColor); owner->SetLowColor(lowColor); } diff --git a/application/views/RosterItem.h b/application/views/RosterItem.h index a279c05..ffba25b 100644 --- a/application/views/RosterItem.h +++ b/application/views/RosterItem.h @@ -28,7 +28,7 @@ public: void Update(BView *owner, const BFont *font); - Contact* GetContact() { return contactLinker;} + Contact* GetContact() { return fContact;} UserStatus Status() const { return fStatus; } void SetStatus(UserStatus status); @@ -45,7 +45,7 @@ protected: void ObserveInteger(int32 what, int32 val); private: - Contact* contactLinker; + Contact* fContact; float fBaselineOffset; BString fPersonalStatus; UserStatus fStatus; diff --git a/application/views/RosterListView.cpp b/application/views/RosterListView.cpp index 8e4adb1..7bb797c 100644 --- a/application/views/RosterListView.cpp +++ b/application/views/RosterListView.cpp @@ -224,16 +224,25 @@ RosterListView::Draw(BRect updateRect) bool -RosterListView::AddRosterItem(RosterItem* item) +RosterListView::AddItem(RosterItem* item) { + item->Deselect(); bool ret = false; if (HasItem(item) == false) - ret = AddItem(item); + ret = BListView::AddItem(item); Sort(); return ret; } +void +RosterListView::RemoveItem(RosterItem* item) +{ + item->Deselect(); + BListView::RemoveItem(item); +} + + RosterItem* RosterListView::RosterItemAt(int32 index) { diff --git a/application/views/RosterListView.h b/application/views/RosterListView.h index 47cbf17..233eeab 100644 --- a/application/views/RosterListView.h +++ b/application/views/RosterListView.h @@ -23,7 +23,8 @@ public: virtual void Draw(BRect updateRect); virtual void AttachedToWindow(); - bool AddRosterItem(RosterItem* item); + bool AddItem(RosterItem* item); + void RemoveItem(RosterItem* item); RosterItem* RosterItemAt(int32 index); void Sort(); diff --git a/application/views/RosterView.cpp b/application/views/RosterView.cpp index ccaca32..0a2f46a 100644 --- a/application/views/RosterView.cpp +++ b/application/views/RosterView.cpp @@ -42,7 +42,6 @@ RosterView::RosterView(const char* title, Server* server, bigtime_t account) new BMessage(kSearchContact)); fSearchBox->SetModificationMessage(new BMessage(kSearchContact)); - fListView = new RosterListView("buddyView"); BScrollView* scrollView = new BScrollView("scrollview", fListView, B_WILL_DRAW, false, true); @@ -74,11 +73,11 @@ RosterView::MessageReceived(BMessage* message) // otherwise remove the item in order to show only items // that matches the search criteria if (strcmp(fSearchBox->Text(), "") == 0) - fListView->AddRosterItem(item); + fListView->AddItem(item); else if (linker->GetName().IFindFirst(fSearchBox->Text()) == B_ERROR) fListView->RemoveItem(item); else - fListView->AddRosterItem(item); + fListView->AddItem(item); UpdateListItem(item); } break; @@ -128,7 +127,7 @@ RosterView::ImMessage(BMessage* msg) return;*/ default: // Add item because it has a non-offline status - fListView->AddRosterItem(rosterItem); + fListView->AddItem(rosterItem); break; } @@ -233,7 +232,7 @@ RosterView::SetAccount(bigtime_t instance_id) fListView->MakeEmpty(); for (int i = 0; i < contacts.CountItems(); i++) - fListView->AddRosterItem(contacts.ValueAt(i)->GetRosterItem()); + fListView->AddItem(contacts.ValueAt(i)->GetRosterItem()); }