blob: 7c53bd46353550de464c176643425c5c865c295d (
plain) (
blame)
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
71
72
73
74
75
76
77
78
79
80
81
|
#ifndef UMPS_UI_INTERNAL_H_INCLUDED
#define UMPS_UI_INTERNAL_H_INCLUDED
#include "../ui.h"
#include "config.h"
#include NCURSES_INCLUDE
#define UI__WINDOW_DOCK_TOP (0u)
#define UI__WINDOW_DOCK_BOTTOM (1u)
#define UI__WINDOW_DOCK_LEFT (2u)
#define UI__WINDOW_DOCK_RIGHT (3u)
#define UI__WINDOW_DOCK_CENTER (4u)
#define UI__WINDOW_FOCUS_NONE (999u)
#define UI__WINDOW_TYPE_BASE (0u)
#define UI__WINDOW_TYPE_DOCK (1u)
#define UI__WINDOW_TYPE_ROOT (2u)
#define UI__WINDOW_DOCK_MAX UI__WINDOW_DOCK_CENTER+1
/* concrete type definitions */
/* called to refresh the window (should refresh children as well) */
typedef void (ui__draw_proc)(struct ui_window_base *);
/* called to recalculate the layout of the window (for resize) */
typedef void (ui__layout_proc)(struct ui_window_base *);
struct ui_window_base {
unsigned type;
struct ui_window_base *parent; /* the parent of a window manages its memory */
WINDOW *cwindow; /* ncurses window */
ui__draw_proc *draw_proc;
ui__layout_proc *layout_proc;
};
struct ui_window_dock {
struct ui_window_base super;
struct ui_window_base *children[UI__WINDOW_DOCK_MAX];
float childsizes[UI__WINDOW_DOCK_MAX];
unsigned focus;
};
struct ui_window_root {
struct ui_window_dock super;
struct ui_window_base *floating;
};
/* internal utils */
/* in-place constructors */
void ui__init_window_base(struct ui_window_base *);
void ui__init_window_dock(struct ui_window_dock *);
void ui__init_window_root(struct ui_window_root *);
struct ui_window_base *ui__find_focused(void);
/* callback utils */
void ui__call_draw_proc(struct ui_window_base *);
void ui__call_layout_proc(struct ui_window_base *);
/* destructor */
void ui__destroy_window(struct ui_window_base *);
/* docked window utils */
void ui__dock_add_child(struct ui_window_dock *, struct ui_window_base *, unsigned position, float size);
void ui__dock_default_draw_proc(struct ui_window_base *base);
void ui__dock_default_layout_proc(struct ui_window_base *base);
/* root window hooks */
void ui__root_draw_proc(struct ui_window_base *);
void ui__root_layout_proc(struct ui_window_base *);
#endif /* include guard */
|