Chat-O-Matic/application/windows/UserInfoWindow.cpp

87 lines
2.1 KiB
C++
Raw Normal View History

/*
* Copyright 2012, Casalinuovo Dario. All rights reserved.
2021-07-07 22:35:44 -05:00
* Copyright 2021, Jaidyn Levesque. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Casalinuovo Dario
2021-07-07 22:35:44 -05:00
* Jaidyn Levesque <jadedctrl@teknik.io>
*/
#include "UserInfoWindow.h"
2021-05-19 16:12:19 -05:00
#include <Alert.h>
2021-07-07 22:35:44 -05:00
#include <LayoutBuilder.h>
#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"
#include "User.h"
UserInfoWindow::UserInfoWindow(User* user)
:
BWindow(BRect(200, 200, 500, 400),
"User information", B_FLOATING_WINDOW,
2021-07-07 22:35:44 -05:00
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
fUser(user)
{
2021-07-07 22:35:44 -05:00
_InitInterface();
MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2));
}
2021-07-07 22:35:44 -05:00
void
UserInfoWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
default:
BWindow::MessageReceived(message);
break;
}
}
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());
2021-07-07 22:35:44 -05:00
BString idText("[");
idText << fUser->GetId().String() << "]";
fIdLabel = new BStringView("idLabel", idText.String());
fAvatar = new BitmapView("UserIcon");
fAvatar->SetExplicitMaxSize(BSize(70, 70));
fAvatar->SetExplicitMinSize(BSize(50, 50));
fAvatar->SetExplicitPreferredSize(BSize(50, 50));
fAvatar->SetBitmap(fUser->AvatarBitmap());
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()
.End()
2021-07-07 22:35:44 -05:00
.AddGroup(B_VERTICAL)
.AddGroup(B_VERTICAL)
.Add(fAvatar)
.Add(fStatusLabel)
.AddGlue()
.End()
2021-07-07 22:35:44 -05:00
.End();
}