Redesign/scalability of UserInfoWindow
This commit is contained in:
parent
dfa92a8d9e
commit
4934660da3
|
@ -27,6 +27,11 @@ ImageCache* ImageCache::fInstance = NULL;
|
||||||
ImageCache::ImageCache()
|
ImageCache::ImageCache()
|
||||||
{
|
{
|
||||||
_LoadResource(kPersonIcon, "kPersonIcon");
|
_LoadResource(kPersonIcon, "kPersonIcon");
|
||||||
|
|
||||||
|
_LoadResource(kAwayReplicant, "kAwayReplicant");
|
||||||
|
_LoadResource(kBusyReplicant, "kBusyReplicant");
|
||||||
|
_LoadResource(kOfflineReplicant, "kOfflineReplicant");
|
||||||
|
_LoadResource(kOnlineReplicant, "kOnlineReplicant");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,5 +103,3 @@ ImageCache::_LoadResource(int identifier, const char* key)
|
||||||
if (bitmap != NULL && bitmap->IsValid() == true)
|
if (bitmap != NULL && bitmap->IsValid() == true)
|
||||||
fBitmaps.AddItem(BString(key), bitmap);
|
fBitmaps.AddItem(BString(key), bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,22 @@ UserStatusToString(UserStatus status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char*
|
||||||
|
UserStatusToImageKey(UserStatus status)
|
||||||
|
{
|
||||||
|
switch (status) {
|
||||||
|
case STATUS_ONLINE:
|
||||||
|
return "kOnlineReplicant";
|
||||||
|
case STATUS_AWAY:
|
||||||
|
return "kAwayReplicant";
|
||||||
|
case STATUS_OFFLINE:
|
||||||
|
return "kOfflineReplicant";
|
||||||
|
default:
|
||||||
|
return "kBusyReplicant";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IsCommand(BString line)
|
IsCommand(BString line)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,8 +19,12 @@
|
||||||
class BMenu;
|
class BMenu;
|
||||||
|
|
||||||
|
|
||||||
|
// For display purposes
|
||||||
const char* UserStatusToString(UserStatus status);
|
const char* UserStatusToString(UserStatus status);
|
||||||
|
|
||||||
|
// For use with the ImageCache
|
||||||
|
const char* UserStatusToImageKey(UserStatus status);
|
||||||
|
|
||||||
bool IsCommand(BString line);
|
bool IsCommand(BString line);
|
||||||
BString CommandName(BString line);
|
BString CommandName(BString line);
|
||||||
BString CommandArgs(BString line);
|
BString CommandArgs(BString line);
|
||||||
|
|
|
@ -11,19 +11,25 @@
|
||||||
#include "UserInfoWindow.h"
|
#include "UserInfoWindow.h"
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
|
#include <Catalog.h>
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
|
||||||
#include <libinterface/BitmapView.h>
|
#include <libinterface/BitmapView.h>
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "ImageCache.h"
|
||||||
#include "User.h"
|
#include "User.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
|
|
||||||
|
#undef B_TRANSLATION_CONTEXT
|
||||||
|
#define B_TRANSLATION_CONTEXT "UserInfoWindow"
|
||||||
|
|
||||||
|
|
||||||
UserInfoWindow::UserInfoWindow(User* user)
|
UserInfoWindow::UserInfoWindow(User* user)
|
||||||
:
|
:
|
||||||
BWindow(BRect(200, 200, 500, 400),
|
BWindow(BRect(200, 200, 300, 400),
|
||||||
"User information", B_FLOATING_WINDOW,
|
B_TRANSLATE("User information"), B_FLOATING_WINDOW,
|
||||||
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
|
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
|
||||||
fUser(user)
|
fUser(user)
|
||||||
{
|
{
|
||||||
|
@ -47,16 +53,32 @@ void
|
||||||
UserInfoWindow::_InitInterface()
|
UserInfoWindow::_InitInterface()
|
||||||
{
|
{
|
||||||
fNameLabel = new BStringView("nameLabel", fUser->GetName().String());
|
fNameLabel = new BStringView("nameLabel", fUser->GetName().String());
|
||||||
fStatusLabel = new BStringView("statusLabel",
|
fNameLabel->SetFont(be_bold_font);
|
||||||
UserStatusToString(fUser->GetNotifyStatus()));
|
|
||||||
|
UserStatus status = fUser->GetNotifyStatus();
|
||||||
|
fStatusLabel = new BStringView("statusLabel", UserStatusToString(status));
|
||||||
|
|
||||||
|
float iconSize = be_plain_font->Size() + 5;
|
||||||
|
BBitmap* statusBitmap =
|
||||||
|
ImageCache::Get()->GetImage(UserStatusToImageKey(status));
|
||||||
|
fStatusIcon = new BitmapView("statusIcon");
|
||||||
|
fStatusIcon->SetExplicitMaxSize(BSize(iconSize, iconSize));
|
||||||
|
fStatusIcon->SetBitmap(statusBitmap);
|
||||||
|
|
||||||
fTextStatusLabel = new BStringView("statusMessageLabel",
|
fTextStatusLabel = new BStringView("statusMessageLabel",
|
||||||
fUser->GetNotifyPersonalStatus());
|
fUser->GetNotifyPersonalStatus());
|
||||||
|
|
||||||
BString idText("[");
|
const char* userId = fUser->GetId().String();
|
||||||
idText << fUser->GetId().String() << "]";
|
fIdLabel = new BTextView("idLabel");
|
||||||
fIdLabel = new BStringView("idLabel", idText.String());
|
fIdLabel->SetText(userId);
|
||||||
|
fIdLabel->SetFont(be_fixed_font);
|
||||||
|
fIdLabel->SetWordWrap(false);
|
||||||
|
fIdLabel->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
fIdLabel->MakeEditable(false);
|
||||||
|
fIdLabel->SetExplicitMinSize(
|
||||||
|
BSize(be_fixed_font->StringWidth(userId), B_SIZE_UNSET));
|
||||||
|
|
||||||
fAvatar = new BitmapView("UserIcon");
|
fAvatar = new BitmapView("userIcon");
|
||||||
fAvatar->SetExplicitMaxSize(BSize(70, 70));
|
fAvatar->SetExplicitMaxSize(BSize(70, 70));
|
||||||
fAvatar->SetExplicitMinSize(BSize(50, 50));
|
fAvatar->SetExplicitMinSize(BSize(50, 50));
|
||||||
fAvatar->SetExplicitPreferredSize(BSize(50, 50));
|
fAvatar->SetExplicitPreferredSize(BSize(50, 50));
|
||||||
|
@ -65,8 +87,9 @@ UserInfoWindow::_InitInterface()
|
||||||
// Centering is lyfeee
|
// Centering is lyfeee
|
||||||
fNameLabel->SetExplicitAlignment(BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP));
|
fNameLabel->SetExplicitAlignment(BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP));
|
||||||
fIdLabel->SetExplicitAlignment(BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP));
|
fIdLabel->SetExplicitAlignment(BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP));
|
||||||
fStatusLabel->SetExplicitAlignment(BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP));
|
fStatusIcon->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_TOP));
|
||||||
fAvatar->SetExplicitAlignment(BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP));
|
fStatusLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
|
||||||
|
fAvatar->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_TOP));
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this, B_HORIZONTAL, 10)
|
BLayoutBuilder::Group<>(this, B_HORIZONTAL, 10)
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING)
|
.SetInsets(B_USE_DEFAULT_SPACING)
|
||||||
|
@ -79,8 +102,10 @@ UserInfoWindow::_InitInterface()
|
||||||
.AddGroup(B_VERTICAL)
|
.AddGroup(B_VERTICAL)
|
||||||
.AddGroup(B_VERTICAL)
|
.AddGroup(B_VERTICAL)
|
||||||
.Add(fAvatar)
|
.Add(fAvatar)
|
||||||
|
.AddGroup(B_HORIZONTAL)
|
||||||
|
.Add(fStatusIcon)
|
||||||
.Add(fStatusLabel)
|
.Add(fStatusLabel)
|
||||||
.AddGlue()
|
.End()
|
||||||
.End()
|
.End()
|
||||||
.End();
|
.End();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,8 @@ private:
|
||||||
|
|
||||||
BitmapView* fAvatar;
|
BitmapView* fAvatar;
|
||||||
BStringView* fNameLabel;
|
BStringView* fNameLabel;
|
||||||
BStringView* fIdLabel;
|
BTextView* fIdLabel;
|
||||||
|
BitmapView* fStatusIcon;
|
||||||
BStringView* fStatusLabel;
|
BStringView* fStatusLabel;
|
||||||
BStringView* fTextStatusLabel;
|
BStringView* fTextStatusLabel;
|
||||||
};
|
};
|
||||||
|
|
Ŝarĝante…
Reference in New Issue