2012-03-11 10:11:29 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2012, Casalinuovo Dario. All rights reserved.
|
2021-07-07 22:35:44 -05:00
|
|
|
* Copyright 2021, Jaidyn Levesque. All rights reserved.
|
2012-03-11 10:11:29 -05:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Casalinuovo Dario
|
2021-07-07 22:35:44 -05:00
|
|
|
* Jaidyn Levesque <jadedctrl@teknik.io>
|
2012-03-11 10:11:29 -05:00
|
|
|
*/
|
|
|
|
|
2021-05-23 15:10:14 -05:00
|
|
|
#include "UserInfoWindow.h"
|
2021-05-19 16:12:19 -05:00
|
|
|
|
2012-03-11 10:11:29 -05:00
|
|
|
#include <Alert.h>
|
2021-07-24 20:54:46 -05:00
|
|
|
#include <Catalog.h>
|
2021-07-07 22:35:44 -05:00
|
|
|
#include <LayoutBuilder.h>
|
2012-03-11 10:11:29 -05:00
|
|
|
#include <Message.h>
|
|
|
|
|
2021-05-19 16:12:19 -05:00
|
|
|
#include <libinterface/BitmapView.h>
|
|
|
|
|
2021-07-24 20:54:46 -05:00
|
|
|
#include "ImageCache.h"
|
2021-05-23 15:10:14 -05:00
|
|
|
#include "User.h"
|
2021-07-24 20:54:46 -05:00
|
|
|
#include "Utils.h"
|
|
|
|
|
|
|
|
|
|
|
|
#undef B_TRANSLATION_CONTEXT
|
|
|
|
#define B_TRANSLATION_CONTEXT "UserInfoWindow"
|
2012-03-11 10:11:29 -05:00
|
|
|
|
|
|
|
|
2021-05-23 15:10:14 -05:00
|
|
|
UserInfoWindow::UserInfoWindow(User* user)
|
2012-03-11 10:11:29 -05:00
|
|
|
:
|
2021-07-24 20:54:46 -05:00
|
|
|
BWindow(BRect(200, 200, 300, 400),
|
|
|
|
B_TRANSLATE("User information"), B_FLOATING_WINDOW,
|
2021-07-07 22:35:44 -05:00
|
|
|
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
|
2021-05-23 15:10:14 -05:00
|
|
|
fUser(user)
|
2012-03-11 10:11:29 -05:00
|
|
|
{
|
2021-07-07 22:35:44 -05:00
|
|
|
_InitInterface();
|
|
|
|
MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2));
|
|
|
|
}
|
2012-03-11 19:40:37 -05:00
|
|
|
|
2012-03-11 10:11:29 -05:00
|
|
|
|
2021-07-07 22:35:44 -05:00
|
|
|
void
|
|
|
|
UserInfoWindow::MessageReceived(BMessage* message)
|
|
|
|
{
|
|
|
|
switch (message->what) {
|
|
|
|
default:
|
|
|
|
BWindow::MessageReceived(message);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-11 10:11:29 -05:00
|
|
|
|
|
|
|
|
2021-07-07 22:35:44 -05:00
|
|
|
void
|
|
|
|
UserInfoWindow::_InitInterface()
|
|
|
|
{
|
|
|
|
fNameLabel = new BStringView("nameLabel", fUser->GetName().String());
|
2021-07-24 20:54:46 -05:00
|
|
|
fNameLabel->SetFont(be_bold_font);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2021-07-07 22:35:44 -05:00
|
|
|
fTextStatusLabel = new BStringView("statusMessageLabel",
|
|
|
|
fUser->GetNotifyPersonalStatus());
|
2012-03-11 10:11:29 -05:00
|
|
|
|
2021-07-24 20:54:46 -05:00
|
|
|
const char* userId = fUser->GetId().String();
|
|
|
|
fIdLabel = new BTextView("idLabel");
|
|
|
|
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));
|
2012-03-11 10:11:29 -05:00
|
|
|
|
2021-07-24 20:54:46 -05:00
|
|
|
fAvatar = new BitmapView("userIcon");
|
2012-03-11 10:11:29 -05:00
|
|
|
fAvatar->SetExplicitMaxSize(BSize(70, 70));
|
|
|
|
fAvatar->SetExplicitMinSize(BSize(50, 50));
|
|
|
|
fAvatar->SetExplicitPreferredSize(BSize(50, 50));
|
2021-05-23 15:10:14 -05:00
|
|
|
fAvatar->SetBitmap(fUser->AvatarBitmap());
|
2012-03-11 10:11:29 -05:00
|
|
|
|
2021-07-07 22:35:44 -05:00
|
|
|
// Centering is lyfeee
|
|
|
|
fNameLabel->SetExplicitAlignment(BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP));
|
|
|
|
fIdLabel->SetExplicitAlignment(BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP));
|
2021-07-24 20:54:46 -05:00
|
|
|
fStatusIcon->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_TOP));
|
|
|
|
fStatusLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
|
|
|
|
fAvatar->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_TOP));
|
2021-07-07 22:35:44 -05:00
|
|
|
|
|
|
|
BLayoutBuilder::Group<>(this, B_HORIZONTAL, 10)
|
|
|
|
.SetInsets(B_USE_DEFAULT_SPACING)
|
|
|
|
.AddGroup(B_VERTICAL)
|
|
|
|
.Add(fNameLabel)
|
|
|
|
.Add(fIdLabel)
|
|
|
|
.Add(fTextStatusLabel)
|
|
|
|
.AddGlue()
|
2012-03-11 10:11:29 -05:00
|
|
|
.End()
|
2021-07-07 22:35:44 -05:00
|
|
|
.AddGroup(B_VERTICAL)
|
|
|
|
.AddGroup(B_VERTICAL)
|
|
|
|
.Add(fAvatar)
|
2021-07-24 20:54:46 -05:00
|
|
|
.AddGroup(B_HORIZONTAL)
|
|
|
|
.Add(fStatusIcon)
|
|
|
|
.Add(fStatusLabel)
|
|
|
|
.End()
|
2012-03-11 10:11:29 -05:00
|
|
|
.End()
|
2021-07-07 22:35:44 -05:00
|
|
|
.End();
|
2012-03-11 10:11:29 -05:00
|
|
|
}
|