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-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-06-20 12:44:20 -05:00
|
|
|
#include "Utils.h"
|
2021-05-23 15:10:14 -05:00
|
|
|
#include "User.h"
|
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
|
|
|
:
|
|
|
|
BWindow(BRect(200, 200, 500, 400),
|
2021-05-23 15:10:14 -05:00
|
|
|
"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());
|
|
|
|
fStatusLabel = new BStringView("statusLabel",
|
|
|
|
UserStatusToString(fUser->GetNotifyStatus()));
|
|
|
|
fTextStatusLabel = new BStringView("statusMessageLabel",
|
|
|
|
fUser->GetNotifyPersonalStatus());
|
2012-03-11 10:11:29 -05:00
|
|
|
|
2021-07-07 22:35:44 -05:00
|
|
|
BString idText("[");
|
|
|
|
idText << fUser->GetId().String() << "]";
|
|
|
|
fIdLabel = new BStringView("idLabel", idText.String());
|
2012-03-11 10:11:29 -05:00
|
|
|
|
2021-05-23 15:10:14 -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));
|
|
|
|
fStatusLabel->SetExplicitAlignment(BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP));
|
|
|
|
fAvatar->SetExplicitAlignment(BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP));
|
|
|
|
|
|
|
|
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)
|
|
|
|
.Add(fStatusLabel)
|
|
|
|
.AddGlue()
|
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
|
|
|
}
|