Slight UserInfoWindow redesign

This commit is contained in:
Jaidyn Ann 2021-07-07 22:35:44 -05:00
parent 988a4ebfb6
commit 352a6751da
2 changed files with 57 additions and 61 deletions

View File

@ -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 <jadedctrl@teknik.io>
*/
#include "UserInfoWindow.h"
#include <Alert.h>
#include <Application.h>
#include <Box.h>
#include <GridLayout.h>
#include <GridLayoutBuilder.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <Layout.h>
#include <LayoutBuilder.h>
#include <Message.h>
#include <SpaceLayoutItem.h>
#include <String.h>
#include <libinterface/BitmapView.h>
#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();
}

View File

@ -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 <jadedctrl@teknik.io>
*/
#ifndef _USER_INFO_WINDOW_H
#define _USER_INFO_WINDOW_H
@ -13,8 +15,6 @@
#include <StringView.h>
#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