Use status icons instead of simple circles.
This commit is contained in:
parent
2f6f458fe0
commit
7d4a7d1c24
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2009, Andrea Anzani. All rights reserved.
|
* Copyright 2009-2010, Andrea Anzani. All rights reserved.
|
||||||
|
* Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _THE_APP_H
|
#ifndef _THE_APP_H
|
||||||
|
@ -13,7 +14,8 @@ class TheApp : public BApplication {
|
||||||
public:
|
public:
|
||||||
TheApp();
|
TheApp();
|
||||||
|
|
||||||
void ReadyToRun();
|
virtual void ReadyToRun();
|
||||||
|
virtual void AboutRequested();
|
||||||
|
|
||||||
MainWindow* GetMainWindow() const;
|
MainWindow* GetMainWindow() const;
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
|
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <ListView.h>
|
#include <ListView.h>
|
||||||
|
|
||||||
|
#include <libinterface/BitmapUtils.h>
|
||||||
|
|
||||||
#include "CayaUtils.h"
|
#include "CayaUtils.h"
|
||||||
|
#include "CayaResources.h"
|
||||||
#include "ContactLinker.h"
|
#include "ContactLinker.h"
|
||||||
#include "NotifyMessage.h"
|
#include "NotifyMessage.h"
|
||||||
#include "RosterItem.h"
|
#include "RosterItem.h"
|
||||||
|
@ -110,6 +111,39 @@ void RosterItem::DrawItem(BView* owner, BRect frame, bool complete)
|
||||||
owner->FillRect(frame);
|
owner->FillRect(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BResources* res = CayaResources();
|
||||||
|
if (res) {
|
||||||
|
int32 num = 0;
|
||||||
|
|
||||||
|
switch (fStatus) {
|
||||||
|
case CAYA_ONLINE:
|
||||||
|
num = kOnlineIcon;
|
||||||
|
break;
|
||||||
|
case CAYA_EXTENDED_AWAY:
|
||||||
|
case CAYA_AWAY:
|
||||||
|
num = kAwayIcon;
|
||||||
|
break;
|
||||||
|
case CAYA_DO_NOT_DISTURB:
|
||||||
|
num = kBusyIcon;
|
||||||
|
break;
|
||||||
|
case CAYA_OFFLINE:
|
||||||
|
num = kOfflineIcon;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
BBitmap* bitmap = IconFromResources(res, num, B_MINI_ICON);
|
||||||
|
BRect bitmapRect(frame.left + 2, frame.top + 2,
|
||||||
|
frame.left + 2 + 14, frame.top + 2 + 14);
|
||||||
|
|
||||||
|
owner->SetDrawingMode(B_OP_ALPHA);
|
||||||
|
owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
||||||
|
owner->DrawBitmap(bitmap, bitmap->Bounds(),
|
||||||
|
bitmapRect, B_FILTER_BITMAP_BILINEAR);
|
||||||
|
|
||||||
|
delete res;
|
||||||
|
} else {
|
||||||
// Draw contact status
|
// Draw contact status
|
||||||
switch (fStatus) {
|
switch (fStatus) {
|
||||||
case CAYA_ONLINE:
|
case CAYA_ONLINE:
|
||||||
|
@ -127,17 +161,19 @@ void RosterItem::DrawItem(BView* owner, BRect frame, bool complete)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
owner->FillEllipse(BRect(frame.left + 6, frame.top + 6,
|
|
||||||
frame.left + 6 + 7 , frame.top + 6 + 7));
|
owner->FillEllipse(BRect(frame.left + 4, frame.top + 4,
|
||||||
|
frame.left + 4 + 10 , frame.top + 4 + 10));
|
||||||
|
}
|
||||||
|
|
||||||
// Draw contact name
|
// Draw contact name
|
||||||
owner->MovePenTo(frame.left + 20, frame.top + myfBaselineOffset);
|
owner->MovePenTo(frame.left + 20, frame.top + fBaselineOffset);
|
||||||
owner->SetHighColor(ui_color(B_CONTROL_TEXT_COLOR));
|
owner->SetHighColor(ui_color(B_CONTROL_TEXT_COLOR));
|
||||||
owner->DrawString(Text());
|
owner->DrawString(Text());
|
||||||
|
|
||||||
// Draw contact status string
|
// Draw contact status string
|
||||||
owner->MovePenTo(frame.left + 20, frame.top + myfBaselineOffset +
|
owner->MovePenTo(frame.left + 20, frame.top + fBaselineOffset +
|
||||||
myfBaselineOffset + 2);
|
fBaselineOffset + 2);
|
||||||
owner->SetHighColor(tint_color(lowColor, B_DARKEN_1_TINT));
|
owner->SetHighColor(tint_color(lowColor, B_DARKEN_1_TINT));
|
||||||
if (fPersonalStatus.Length() == 0)
|
if (fPersonalStatus.Length() == 0)
|
||||||
owner->DrawString(CayaStatusToString(fStatus));
|
owner->DrawString(CayaStatusToString(fStatus));
|
||||||
|
@ -145,12 +181,14 @@ void RosterItem::DrawItem(BView* owner, BRect frame, bool complete)
|
||||||
owner->DrawString(fPersonalStatus);
|
owner->DrawString(fPersonalStatus);
|
||||||
|
|
||||||
// Draw separator between items
|
// Draw separator between items
|
||||||
owner->StrokeLine(BPoint(frame.left, frame.bottom), BPoint(frame.right, frame.bottom));
|
owner->StrokeLine(BPoint(frame.left, frame.bottom),
|
||||||
|
BPoint(frame.right, frame.bottom));
|
||||||
|
|
||||||
// Draw avatar icon
|
// Draw avatar icon
|
||||||
if (fBitmap != NULL) {
|
if (fBitmap != NULL) {
|
||||||
float h = frame.Height() - 4;
|
float h = frame.Height() - 4;
|
||||||
BRect rect(frame.right - h - 2, frame.top + 2, frame.right - 2, frame.top + h );
|
BRect rect(frame.right - h - 2, frame.top + 2,
|
||||||
|
frame.right - 2, frame.top + h );
|
||||||
owner->SetDrawingMode(B_OP_ALPHA);
|
owner->SetDrawingMode(B_OP_ALPHA);
|
||||||
owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
|
||||||
owner->DrawBitmap(fBitmap, fBitmap->Bounds(),
|
owner->DrawBitmap(fBitmap, fBitmap->Bounds(),
|
||||||
|
@ -168,7 +206,7 @@ RosterItem::Update(BView* owner, const BFont* font)
|
||||||
font_height fheight;
|
font_height fheight;
|
||||||
font->GetHeight(&fheight);
|
font->GetHeight(&fheight);
|
||||||
|
|
||||||
myfBaselineOffset = 2 + ceilf(fheight.ascent + fheight.leading / 2);
|
fBaselineOffset = 2 + ceilf(fheight.ascent + fheight.leading / 2);
|
||||||
|
|
||||||
SetHeight((ceilf(fheight.ascent) + ceilf(fheight.descent) +
|
SetHeight((ceilf(fheight.ascent) + ceilf(fheight.descent) +
|
||||||
ceilf(fheight.leading) + 4 ) * 2);
|
ceilf(fheight.leading) + 4 ) * 2);
|
||||||
|
|
|
@ -46,7 +46,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ContactLinker* contactLinker;
|
ContactLinker* contactLinker;
|
||||||
float myfBaselineOffset;
|
float fBaselineOffset;
|
||||||
BString fPersonalStatus;
|
BString fPersonalStatus;
|
||||||
CayaStatus fStatus;
|
CayaStatus fStatus;
|
||||||
BBitmap* fBitmap;
|
BBitmap* fBitmap;
|
||||||
|
|
Ŝarĝante…
Reference in New Issue