-
Notifications
You must be signed in to change notification settings - Fork 50
/
uidialog.h
70 lines (54 loc) · 1.21 KB
/
uidialog.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// uidialog.h
//
// Copyright (c) 2019-2023 Kristofer Berggren
// All rights reserved.
//
// nchat is distributed under the MIT license, see LICENSE for details.
#pragma once
#include <string>
#include <ncurses.h>
class UiModel;
class UiView;
struct UiDialogParams
{
// Requested geometry (WReq/HReq) may be specified as 0.0-1.0 fraction of screen size, or as
// integer number (> 1) of columns and rows.
UiDialogParams(UiView* p_View, UiModel* p_Model, std::string p_Title, float p_WReq, float p_HReq)
: view(p_View)
, model(p_Model)
, title(p_Title)
, wReq(p_WReq)
, hReq(p_HReq)
{
}
UiView* view = nullptr;
UiModel* model = nullptr;
std::string title;
float wReq = 0;
float hReq = 0;
};
class UiDialog
{
public:
UiDialog(const UiDialogParams& p_Params);
virtual ~UiDialog();
void Init();
void Cleanup();
void SetFooter(const std::string& p_Footer);
private:
void DrawBorder();
protected:
UiView* m_View = nullptr;
UiModel* m_Model = nullptr;
int m_X = 0;
int m_Y = 0;
int m_W = 0;
int m_H = 0;
WINDOW* m_Win = nullptr;
private:
std::string m_Title;
float m_WReq = 0;
float m_HReq = 0;
std::string m_Footer;
WINDOW* m_BorderWin = nullptr;
};