home · contact · privacy
5c9c4b57d7b4ff52ec6448a8723a04f0a124a3be
[plomrogue] / src / wincontrol.h
1 /* wincontrol.h
2  *
3  * Routines that build on top of the windows library to provide a simple window
4  * management API to the game.
5  */
6
7 #ifndef WINCONTROL_H
8 #define WINCONTROL_H
9
10
11
12 #include <stdint.h> /* for uint8_t */
13 struct Win;
14 struct WinMeta;
15 struct World;
16
17
18
19 /* Puts an identifier on each window, interfaces to its config file data. */
20 struct WinConf
21 {
22     char id;
23     struct Win * win;
24     char * title;
25     int16_t height;
26     int16_t width;
27     void (* draw) (struct Win *);
28 };
29
30
31
32 /* Create/initialize (from config files)/free Winconf / Win structs. */
33 extern void create_winconfs(struct World * world);
34 extern void init_winconfs(struct World * world);
35 extern void free_winconfs(struct World * world);
36 extern void init_wins(struct World * world);
37 extern void free_wins(struct World * world);
38
39
40
41 /* Reload windows in order and sizes defined in win config. */
42 extern void reload_win_config(struct World * world);
43
44
45
46 /* Get WinConf identified by winconf->id == "id", or that winconf's ->win. */
47 extern struct WinConf * get_winconf_by_id(struct World * world, char id);
48 extern struct Win * get_win_by_id(struct World * world, char id);
49
50
51
52 /* Toggle windows in world->wins in the order desribed by the first line of
53  * config/windows/toggled_win_order, wherein each character may correspond to
54  * one hardcoded window.
55  */
56 extern void sorted_wintoggle(struct World * world);
57
58
59
60 /* Toggle display of a window "win".
61  *
62  * Return 0 on success, 1 on (ncurses pad/window memory allocation) error.
63  */
64 extern uint8_t toggle_window(struct WinMeta * win_meta, struct Win * win);
65
66
67
68 /* Try to scroll virtual screen left ("dir" = "-") or right ("dir" = "+"),
69  * subject to the limitations provided by the window manager via
70  * reset_pad_offset().
71  */
72 extern void scroll_pad(struct WinMeta * win_meta, char dir);
73
74
75
76 /* Try to grow or shrink the active window horizontally ("change" = "*"/"_") or
77  * vertically ("change = "+"/"-") by one cell size, subject to the limitations
78  * provided by the window manager via resize_active_win().
79  *
80  * Return 0 on success, 1 on (ncurses pad/window memory allocation) error.
81  */
82 extern uint8_t growshrink_active_window(struct WinMeta * win_meta, char change);
83
84
85
86 #endif