Updated the contacts list BMenuItem with a complete redesign of the item, added an experimental version of the Search BTextControl showing a text that disappear when the user click on it, updated the Nickname text control to be a BTextView, other minor updates already WIP like more organization of statuses.

This commit is contained in:
barrett 2012-05-15 16:48:53 +00:00
parent de33c1be80
commit 710a3c6526
20 changed files with 128 additions and 98 deletions

View File

@ -13,7 +13,7 @@ resource app_version {
internal = 0,
short_info = "Caya",
long_info = "©2009-2011 Andrea Anzani, Pier Luigi Fiorini"
long_info = "©2009-2012 Andrea Anzani, Pier Luigi Fiorini, Dario Casalinuovo"
};
resource app_flags B_SINGLE_LAUNCH;
@ -115,7 +115,7 @@ resource(kSearchIcon) #'VICN' array {
*/
// Connecting Green
resource(kConnectingReplicant) #'VICN' array {
resource(kOnlineReplicant) #'VICN' array {
$"6E636966070501040156020106023DB0753A5ED7B9F9EE3D18204A5B813F873F"
$"C376A70251C9FF89020106023DE0000000000000003D40004A200049A0005376"
$"A702CBC9FF89020106023F5C743B37D1BAB2F23ED1AC471CEC4937F8BF77A703"
@ -264,6 +264,24 @@ resource(kExitMenuReplicant) #'VICN' array {
$"00003FBBBB40CC7F4022220A05020203100117842004"
};
// Replicant message received
resource(kReplicantMessageReceived) #'VICN' array {
$"6E636966050500020106033D835C3C19B2BA8B0B3C20794769624A510E00FFCE"
$"CEB4FF0404FFC10505020106023D835C3C19B2BA8B0B3C20794769624A510E00"
$"FF0404FFC10505020106033D429E3C5148BB5ADA3C5C1B4A23AA46EC1800AAE4"
$"F3B40392B6FF03627A05FF0502093F404644383C273F2E3A244122482245224D"
$"2755245126572256245725582A5828592C5A315C2F5B345D3C5E385E425E4957"
$"475C4D4E02043F4044433D3FBC95BE953B3D333D3D493844424E4A5148534A4A"
$"04032E264DB84FC80CB673C6C93258385902085645C8FEC3AFCA30C0E55E3A5E"
$"405EBA4D5227592B4A2237263E21BA16B6DF33353130363E4A4641444D475346"
$"C657C27B554BCB01C635584F5A4F04032E36353F3DBD0FBD2D44404C42090A00"
$"01001001178400040A010100000A020101000A0401021001178210040A040102"
$"123FFD6238491FB8085D3F8C5843A1A3BE897201178210040A00010310011784"
$"00040A030103000A0401041001178210040A040104123FC0CBB65EEB3639DA3F"
$"FF4C40FECDC3C0A80117821004"
};
// Person icon
resource(kPersonIcon) #'VICN' array {

View File

@ -30,9 +30,9 @@ const rgb_color CAYA_SELEND_COLOR = {230, 113, 9};
enum CayaStatus {
CAYA_ONLINE = 1,
CAYA_AWAY = 2,
CAYA_EXTENDED_AWAY = 3,
CAYA_DO_NOT_DISTURB = 4,
CAYA_OFFLINE = 5,
CAYA_DO_NOT_DISTURB = 3,
CAYA_OFFLINE = 4,
CAYA_EXTENDED_AWAY = 5,
CAYA_STATUSES = 6
};

View File

@ -16,12 +16,13 @@ enum {
kProtocolSettingsTemplate = 1000,
kConnectingReplicant = 1200,
kOnlineReplicant = 1200,
kCayaIconReplicant = 1220,
kOfflineReplicant = 1300,
kBusyReplicant = 1333,
kAwayReplicant = 1400,
kExitMenuReplicant = 1401,
kReplicantMessageReceived = 1402,
kPersonIcon = 1500
};

View File

@ -29,7 +29,7 @@ CayaStatusToString(CayaStatus status)
case CAYA_AWAY:
return "Away";
case CAYA_EXTENDED_AWAY:
return "Extended Away";
return "Custom Status";
case CAYA_DO_NOT_DISTURB:
return "Busy";
default:

View File

@ -36,7 +36,7 @@
ChatWindow::ChatWindow(ContactLinker* cl)
:
BWindow(BRect(200, 200, 500, 500),
cl->GetName().String(), B_DOCUMENT_WINDOW, 0),
cl->GetName().String(), B_TITLED_WINDOW, 0),
fContactLinker(cl)
{
fReceiveView = new CayaRenderView("fReceiveView");
@ -53,7 +53,9 @@ ChatWindow::ChatWindow(ContactLinker* cl)
fPersonalMessage = new BTextView("personalMessage", B_WILL_DRAW);
fPersonalMessage->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
fPersonalMessage->SetExplicitAlignment(
BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
fPersonalMessage->SetText(fContactLinker->GetNotifyPersonalStatus());
fPersonalMessage->SetExplicitMaxSize(BSize(400, 200));
fPersonalMessage->MakeEditable(false);
@ -83,8 +85,8 @@ ChatWindow::ChatWindow(ContactLinker* cl)
.Add(fAvatar)
.End()
.Add(scrollViewReceive, 2)
.Add(scrollViewSend)
.Add(fStatus, 3)
.Add(scrollViewSend, 3)
.Add(fStatus, 4)
.SetInsets(5, 5, 5, 5)
);

View File

@ -16,7 +16,7 @@ class BitmapView;
class ContactLinker;
class CayaRenderView;
class ChatWindow: public BWindow, public Observer {
class ChatWindow : public BWindow, public Observer {
public:
ChatWindow(ContactLinker* cl);

View File

@ -7,12 +7,15 @@
* Andrea Anzani, andrea.anzani@gmail.com
* Dario Casalinuovo
*/
#include "ContactLinker.h"
#include <libinterface/BitmapUtils.h>
#include "CayaUtils.h"
#include "CayaPreferences.h"
#include "CayaProtocolAddOn.h"
#include "CayaResources.h"
#include "ChatWindow.h"
#include "ContactLinker.h"
#include "ContactPopUp.h"
#include "NotifyMessage.h"
#include "ProtocolLooper.h"
@ -20,10 +23,6 @@
#include "RosterItem.h"
#include "WindowsManager.h"
#include "CayaUtils.h"
#include "CayaResources.h"
#include "CayaPreferences.h"
#include <stdio.h>

View File

@ -49,6 +49,7 @@ Application Caya :
# views
ContactPopUp.cpp
SearchBarTextControl.cpp
NicknameTextControl.cpp
RosterItem.cpp
RosterListView.cpp

View File

@ -45,6 +45,7 @@
#include "ReplicantStatusView.h"
#include "RosterItem.h"
#include "RosterListView.h"
#include "SearchBarTextControl.h"
#include "Server.h"
#include "StatusView.h"
@ -54,12 +55,12 @@ const uint32 kSearchContact = 'SRCH';
MainWindow::MainWindow()
:
BWindow(BRect(0, 0, 300, 400), "Caya", B_DOCUMENT_WINDOW, 0),
BWindow(BRect(0, 0, 300, 400), "Caya", B_TITLED_WINDOW, 0),
fWorkspaceChanged(false)
{
fStatusView = new StatusView("statusView");
BTextControl* searchBox = new BTextControl("searchBox", NULL, NULL,
SearchBarTextControl* searchBox = new SearchBarTextControl(
new BMessage(kSearchContact));
fListView = new RosterListView("buddyView");
@ -89,8 +90,8 @@ MainWindow::MainWindow()
wrench->SetBitmap(toolIcon);
wrench->SetMenu(wrenchMenu);
SetLayout(new BGridLayout(5, 5));
AddChild(BGridLayoutBuilder(5, 5)
SetLayout(new BGridLayout(1, 2));
AddChild(BGridLayoutBuilder(1, 2)
.Add(searchBox, 0, 0)
.Add(wrench, 1, 0)
.Add(scrollView, 0, 1, 2)
@ -141,7 +142,8 @@ MainWindow::MessageReceived(BMessage* message)
if (message->FindPointer("source", &control) != B_OK)
return;
BTextControl* searchBox = static_cast<BTextControl*>(control);
SearchBarTextControl* searchBox
= static_cast<SearchBarTextControl*>(control);
if (searchBox == NULL)
return;

View File

@ -91,7 +91,7 @@ TheApp::AboutRequested()
const char* holders[] = {
"2009-2010 Andrea Anzani",
"2009-2010 Pier Luigi Fiorini",
"2011-2012 Casalinuovo Dario",
"2010-2012 Casalinuovo Dario",
NULL
};
@ -109,7 +109,7 @@ TheApp::AboutRequested()
AboutWindow* about = new AboutWindow("Caya", holders,
authors, extraInfo.String());
about->Show();
delete about;
//delete about;
}

View File

@ -6,20 +6,24 @@
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
*/
#include "CayaConstants.h"
#include "NicknameTextControl.h"
#include <Font.h>
NicknameTextControl::NicknameTextControl(const char* name, BMessage* message)
: BTextControl(name, NULL, NULL, message)
: BTextView(name, B_WILL_DRAW)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
}
/*
void
NicknameTextControl::Draw(BRect updateRect)
{
BRect rect(Bounds());
// BRect rect(Bounds());
SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
FillRect(rect);
// FillRect(rect);
}
*/

View File

@ -5,13 +5,13 @@
#ifndef _NICKNAME_TEXT_CONTROL_H
#define _NICKNAME_TEXT_CONTROL_H
#include <TextControl.h>
#include <TextView.h>
class NicknameTextControl : public BTextControl {
class NicknameTextControl : public BTextView {
public:
NicknameTextControl(const char* name, BMessage* message);
virtual void Draw(BRect updateRect);
// virtual void Draw(BRect updateRect);
};
#endif // _NICKNAME_TEXT_CONTROL_H

View File

@ -65,9 +65,11 @@ ReplicantMenuItem::SetIcon()
switch (fStatus) {
case CAYA_ONLINE:
num = kConnectingReplicant;
num = kOnlineReplicant;
break;
case CAYA_EXTENDED_AWAY:
num = kCayaIconReplicant;
break;
case CAYA_AWAY:
num = kAwayReplicant;
break;

View File

@ -151,9 +151,11 @@ ReplicantStatusView::SetStatus(CayaStatus status)
switch (status) {
case CAYA_AWAY:
case CAYA_EXTENDED_AWAY:
fIcon = fAwayIcon;
break;
case CAYA_EXTENDED_AWAY:
fIcon = fCayaIcon;
break;
case CAYA_DO_NOT_DISTURB:
fIcon = fBusyIcon;
break;
@ -273,7 +275,7 @@ ReplicantStatusView::_Init()
fResources = CayaResources();
//Get icons from resources
fConnectingIcon = _GetIcon(kConnectingReplicant);
fConnectingIcon = _GetIcon(kOnlineReplicant);
fCayaIcon = _GetIcon(kCayaIconReplicant);
fOfflineIcon = _GetIcon(kOfflineReplicant);
fIcon = fOfflineIcon;
@ -299,15 +301,11 @@ void
ReplicantStatusView::_BuildMenu()
{
// Status menu
//fStatusMenu = new BPopUpMenu("Status", false, false);
fReplicantMenu = new BPopUpMenu(" - ", false, false);
// Add status menu items
int32 s = CAYA_ONLINE;
while (s >= CAYA_ONLINE && s < CAYA_STATUSES) {
if (s == CAYA_EXTENDED_AWAY) {
s++;
continue;
}
BMessage* msg = new BMessage(CAYA_REPLICANT_STATUS_SET);
msg->AddInt32("status", s);
@ -315,20 +313,12 @@ ReplicantStatusView::_BuildMenu()
CayaStatusToString((CayaStatus)s), (CayaStatus)s);
fReplicantMenu->AddItem(item);
// Add items for custom messages
if (s == CAYA_ONLINE/* || s == CAYA_DO_NOT_DISTURB*/) {
item = new ReplicantMenuItem("Custom...", (CayaStatus) s, true);
fReplicantMenu->AddItem(item);
fReplicantMenu->AddItem(new BSeparatorItem());
}
// Mark offline status by default
if (s == CAYA_OFFLINE)
item->SetMarked(true);
s++;
}
//fReplicantMenu->AddItem(fStatusMenu);
fReplicantMenu->AddItem(new BSeparatorItem());
fReplicantMenu->AddItem(new BitmapMenuItem("Preferences ",
@ -337,7 +327,6 @@ ReplicantStatusView::_BuildMenu()
fReplicantMenu->AddItem(new BitmapMenuItem("Exit",
new BMessage(CAYA_REPLICANT_EXIT), fExitMenuIcon));
//fStatusMenu->SetTargetForItems(fReplicantMenu);
fReplicantMenu->SetTargetForItems(this);
}

View File

@ -99,6 +99,7 @@ void RosterItem::DrawItem(BView* owner, BRect frame, bool complete)
rgb_color highlightColor = ui_color(B_CONTROL_HIGHLIGHT_COLOR);
rgb_color highColor = owner->HighColor();
rgb_color lowColor = owner->LowColor();
float h = frame.Height();
// Draw selection
if (IsSelected()) {
@ -111,31 +112,33 @@ void RosterItem::DrawItem(BView* owner, BRect frame, bool complete)
owner->FillRect(frame);
}
BResources* res = CayaResources();
/*BResources* res = CayaResources();
if (res) {
int32 num = 0;
switch (fStatus) {
case CAYA_ONLINE:
num = kOnlineIcon;
num = kOnlineReplicant;
break;
case CAYA_EXTENDED_AWAY:
num = kCayaIconReplicant;
break;
case CAYA_AWAY:
num = kAwayIcon;
num = kAwayReplicant;
break;
case CAYA_DO_NOT_DISTURB:
num = kBusyIcon;
num = kBusyReplicant;
break;
case CAYA_OFFLINE:
num = kOfflineIcon;
num = kOfflineReplicant;
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);
BRect bitmapRect(frame.left + 40, frame.top + fBaselineOffset - 10,
frame.left + 55, frame.top + 18);
owner->SetDrawingMode(B_OP_ALPHA);
owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
@ -143,7 +146,7 @@ void RosterItem::DrawItem(BView* owner, BRect frame, bool complete)
bitmapRect, B_FILTER_BITMAP_BILINEAR);
delete res;
} else {
} else {*/
// Draw contact status
switch (fStatus) {
case CAYA_ONLINE:
@ -162,19 +165,31 @@ void RosterItem::DrawItem(BView* owner, BRect frame, bool complete)
break;
}
owner->FillEllipse(BRect(frame.left + 4, frame.top + 4,
frame.left + 4 + 10 , frame.top + 4 + 10));
owner->FillRect(BRect(frame.left,
frame.top,
frame.left + 5, frame.top + h - 1
));
//}
// Draw avatar icon
if (fBitmap != NULL) {
BRect rect(frame.left + 6, frame.top,
frame.left + 42, frame.top + h);
owner->SetDrawingMode(B_OP_ALPHA);
owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
owner->DrawBitmap(fBitmap, fBitmap->Bounds(),
rect, B_FILTER_BITMAP_BILINEAR);
}
// Draw contact name
owner->MovePenTo(frame.left + 20, frame.top + fBaselineOffset);
owner->MovePenTo(frame.left + 48, frame.top + fBaselineOffset);
owner->SetHighColor(ui_color(B_CONTROL_TEXT_COLOR));
owner->DrawString(Text());
// Draw contact status string
owner->MovePenTo(frame.left + 20, frame.top + fBaselineOffset +
fBaselineOffset + 2);
owner->SetHighColor(tint_color(lowColor, B_DARKEN_1_TINT));
owner->MovePenTo(frame.left + 48, frame.top + fBaselineOffset +
fBaselineOffset + 3);
owner->SetHighColor(tint_color(lowColor, B_DARKEN_2_TINT));
if (fPersonalStatus.Length() == 0)
owner->DrawString(CayaStatusToString(fStatus));
else
@ -184,21 +199,11 @@ void RosterItem::DrawItem(BView* owner, BRect frame, bool complete)
owner->StrokeLine(BPoint(frame.left, frame.bottom),
BPoint(frame.right, frame.bottom));
// Draw avatar icon
if (fBitmap != NULL) {
float h = frame.Height() - 4;
BRect rect(frame.right - h - 2, frame.top + 2,
frame.right - 2, frame.top + h );
owner->SetDrawingMode(B_OP_ALPHA);
owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
owner->DrawBitmap(fBitmap, fBitmap->Bounds(),
rect, B_FILTER_BITMAP_BILINEAR);
}
// Draw protocol bitmpap
BBitmap* protocolBitmap = contactLinker->ProtocolBitmap();
float h = frame.Height();
BRect rect(frame.right - h - 20, frame.top + 2,
frame.right - 40, frame.top + h - 20);
BRect rect(frame.right - 19, frame.top + 2,
frame.right - 2, frame.top + 19 );;
owner->SetDrawingMode(B_OP_ALPHA);
owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
owner->DrawBitmap(protocolBitmap, protocolBitmap->Bounds(),

View File

@ -50,7 +50,8 @@ compare_by_status(const void* _item1, const void* _item2)
RosterListView::RosterListView(const char* name)
: BListView(name, B_SINGLE_SELECTION_LIST, B_WILL_DRAW | B_FRAME_EVENTS |
: BOutlineListView(name, B_SINGLE_SELECTION_LIST,
B_WILL_DRAW | B_FRAME_EVENTS |
B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE),
fPrevItem(NULL)
{

View File

@ -5,14 +5,14 @@
#ifndef _ROSTER_LIST_VIEW_H
#define _ROSTER_LIST_VIEW_H
#include <ListView.h>
#include <OutlineListView.h>
class BPopUpMenu;
class ContactLinker;
class RosterItem;
class RosterListView : public BListView
class RosterListView : public BOutlineListView
{
public:
RosterListView(const char* name);

View File

@ -62,17 +62,19 @@ StatusMenuItem::SetIcon()
switch (fStatus) {
case CAYA_ONLINE:
num = kOnlineIcon;
num = kOnlineReplicant;
break;
case CAYA_EXTENDED_AWAY:
num = kCayaIconReplicant;
break;
case CAYA_AWAY:
num = kAwayIcon;
num = kAwayReplicant;
break;
case CAYA_DO_NOT_DISTURB:
num = kBusyIcon;
num = kBusyReplicant;
break;
case CAYA_OFFLINE:
num = kOfflineIcon;
num = kOfflineReplicant;
break;
default:
break;

View File

@ -13,6 +13,7 @@
#include <MenuField.h>
#include <MenuItem.h>
#include <PopUpMenu.h>
#include <StringView.h>
#include <libinterface/BitmapMenuItem.h>
#include <libinterface/BitmapUtils.h>
@ -32,8 +33,10 @@ StatusView::StatusView(const char* name)
BView(name, B_WILL_DRAW)
{
// Nick name
fNickname = new NicknameTextControl("Nickname", new BMessage(kSetNickname));
fPersonalMessage = new NicknameTextControl("Nickname",
new BMessage(kSetNickname));
BStringView* personalMessageLabel = new BStringView("Nickname","Nickname:", B_WILL_DRAW);
// Status menu
fStatusMenu = new BPopUpMenu("-");
@ -44,12 +47,12 @@ StatusView::StatusView(const char* name)
(CayaStatus)s), (CayaStatus)s);
fStatusMenu->AddItem(item);
// Add items for custom messages
/*// Add items for custom messages
if (s == CAYA_ONLINE || s == CAYA_DO_NOT_DISTURB) {
item = new StatusMenuItem("Custom...", (CayaStatus)s, true);
fStatusMenu->AddItem(item);
fStatusMenu->AddItem(new BSeparatorItem());
}
}*/
// Mark offline status by default
if (s == CAYA_OFFLINE)
@ -71,12 +74,14 @@ StatusView::StatusView(const char* name)
SetLayout(new BGroupLayout(B_VERTICAL));
AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 5)
.AddGroup(B_VERTICAL)
.Add(fNickname)
.Add(statusField)
.AddGlue()
.AddGroup(B_HORIZONTAL)
.Add(personalMessageLabel)
.Add(fPersonalMessage)
.End()
.End()
.Add(fAvatar)
.TopView()
// .TopView()
);
}
@ -84,8 +89,7 @@ StatusView::StatusView(const char* name)
void
StatusView::AttachedToWindow()
{
fNickname->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fNickname->SetTarget(this);
//fNickname->SetTarget(this);
fStatusMenu->SetTargetForItems(this);
}
@ -94,12 +98,12 @@ void
StatusView::MessageReceived(BMessage* msg)
{
switch (msg->what) {
case kSetNickname:
/*case kSetNickname:
{
AccountManager* accountManager = AccountManager::Get();
accountManager->SetNickname(fNickname->Text());
break;
}
}*/
case kSetStatus:
{
int32 status;
@ -120,7 +124,7 @@ StatusView::MessageReceived(BMessage* msg)
void
StatusView::SetName(BString name)
{
fNickname->SetText(name.String());
fPersonalMessage->SetText(name.String());
}

View File

@ -27,7 +27,7 @@ public:
private:
BPopUpMenu* fStatusMenu;
NicknameTextControl* fNickname;
NicknameTextControl* fPersonalMessage;
BitmapView* fAvatar;
};