diff --git a/application/windows/UserInfoWindow.cpp b/application/windows/UserInfoWindow.cpp index 91a2d4a..5996672 100644 --- a/application/windows/UserInfoWindow.cpp +++ b/application/windows/UserInfoWindow.cpp @@ -1,33 +1,22 @@ /* * Copyright 2012, Casalinuovo Dario. All rights reserved. + * Copyright 2021, Jaidyn Levesque. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Casalinuovo Dario + * Jaidyn Levesque */ #include "UserInfoWindow.h" #include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include -#include #include -#include "AppMessages.h" -#include "ChatProtocolMessages.h" -#include "AppConstants.h" -#include "RenderView.h" #include "Utils.h" -#include "NotifyMessage.h" #include "User.h" @@ -35,49 +24,10 @@ UserInfoWindow::UserInfoWindow(User* user) : BWindow(BRect(200, 200, 500, 400), "User information", B_FLOATING_WINDOW, - B_NOT_ZOOMABLE | B_NOT_RESIZABLE), + B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS), fUser(user) { - fPersonalMessage = new BTextView("personalMessage", B_WILL_DRAW); - fPersonalMessage->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, - B_ALIGN_MIDDLE)); - - fPersonalMessage->SetText(fUser->GetNotifyPersonalStatus()); - fPersonalMessage->SetExplicitMaxSize(BSize(200, 200)); - fPersonalMessage->MakeEditable(false); - fPersonalMessage->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - - BString status(fUser->GetName()); - status << UserStatusToString(fUser->GetNotifyStatus()); - - status << "\n\n ID : "; - status << fUser->GetId(); - - fStatus = new BTextView("status", B_WILL_DRAW); - fStatus->SetText(status); - fStatus->MakeEditable(false); - fStatus->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - - SetLayout(new BGroupLayout(B_HORIZONTAL)); - - fAvatar = new BitmapView("UserIcon"); - fAvatar->SetExplicitMaxSize(BSize(70, 70)); - fAvatar->SetExplicitMinSize(BSize(50, 50)); - fAvatar->SetExplicitPreferredSize(BSize(50, 50)); - fAvatar->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_MIDDLE)); - fAvatar->SetBitmap(fUser->AvatarBitmap()); - - AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) - .AddGroup(B_HORIZONTAL) - .Add(fStatus) - .Add(fAvatar) - .End() - .AddGroup(B_HORIZONTAL) - .Add(fPersonalMessage) - .End() - .SetInsets(5, 5, 5, 5) - ); - + _InitInterface(); MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2)); } @@ -91,3 +41,46 @@ UserInfoWindow::MessageReceived(BMessage* message) break; } } + + +void +UserInfoWindow::_InitInterface() +{ + fNameLabel = new BStringView("nameLabel", fUser->GetName().String()); + fStatusLabel = new BStringView("statusLabel", + UserStatusToString(fUser->GetNotifyStatus())); + fTextStatusLabel = new BStringView("statusMessageLabel", + fUser->GetNotifyPersonalStatus()); + + 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()); + + // 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() + .AddGroup(B_VERTICAL) + .AddGroup(B_VERTICAL) + .Add(fAvatar) + .Add(fStatusLabel) + .AddGlue() + .End() + .End(); +} diff --git a/application/windows/UserInfoWindow.h b/application/windows/UserInfoWindow.h index d8f9d9c..354660d 100644 --- a/application/windows/UserInfoWindow.h +++ b/application/windows/UserInfoWindow.h @@ -1,9 +1,11 @@ /* * Copyright 2012, Casalinuovo Dario. All rights reserved. + * Copyright 2021, Jaidyn Levesque. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Casalinuovo Dario + * Jaidyn Levesque */ #ifndef _USER_INFO_WINDOW_H #define _USER_INFO_WINDOW_H @@ -13,8 +15,6 @@ #include #include "Observer.h" -#include "AppConstants.h" - class BitmapView; class User; @@ -26,12 +26,15 @@ public: virtual void MessageReceived(BMessage* message); private: - BTextView* fStatus; + void _InitInterface(); + User* fUser; - BTextView* fPersonalMessage; + BitmapView* fAvatar; + BStringView* fNameLabel; + BStringView* fIdLabel; + BStringView* fStatusLabel; + BStringView* fTextStatusLabel; }; - #endif // _USER_INFO_WINDOW_H -