-
Notifications
You must be signed in to change notification settings - Fork 50
/
uiviewbase.h
60 lines (50 loc) · 964 Bytes
/
uiviewbase.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
// uiviewbase.h
//
// Copyright (c) 2019-2021 Kristofer Berggren
// All rights reserved.
//
// nchat is distributed under the MIT license, see LICENSE for details.
#pragma once
#include <mutex>
#include <ncurses.h>
class UiModel;
struct UiViewParams
{
UiViewParams(int p_X, int p_Y, int p_W, int p_H, bool p_Enabled, UiModel* p_Model)
: x(p_X)
, y(p_Y)
, w(p_W)
, h(p_H)
, enabled(p_Enabled)
, model(p_Model)
{
}
int x = 0;
int y = 0;
int w = 0;
int h = 0;
bool enabled = false;
UiModel* model = nullptr;
};
class UiViewBase
{
public:
UiViewBase(const UiViewParams& p_Params);
virtual ~UiViewBase();
virtual void Draw() = 0;
int W();
int H();
int X();
int Y();
void SetDirty(bool p_Dirty);
protected:
int m_X = 0;
int m_Y = 0;
int m_W = 0;
int m_H = 0;
bool m_Enabled = false;
UiModel* m_Model = nullptr;
bool m_Dirty = true;
std::mutex m_ViewMutex;
WINDOW* m_Win = nullptr;
};