Add clav-bfzIII
[clav.git] / ui.h
blob3f634854bf37c3ddfdd528681b79ffa29ec4fe5b
1 /*
2 * Copyright (c) 2018, S. Gilles <sgilles@math.umd.edu>
4 * Permission to use, copy, modify, and/or distribute this software
5 * for any purpose with or without fee is hereby granted, provided
6 * that the above copyright notice and this permission notice appear
7 * in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
13 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
14 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 enum event_type {
19 ET_NONE = 0,
20 ET_CHANGE_FATNESS,
21 ET_CHANGE_COLOR,
22 ET_DELETE_EDGE,
23 ET_DELETE_VERTEX,
24 ET_LOAD,
25 ET_MUTATE,
26 ET_NEW_EDGE,
27 ET_NEW_VERTEX,
28 ET_QUIT,
29 ET_RENAME,
30 ET_SAVE,
33 struct ui_event {
34 /* What event this is */
35 enum event_type type;
37 /* Event-specific data */
38 size_t idx_1;
39 size_t idx_2;
40 int int_1;
41 int int_2;
42 uint32_t z;
43 int_fast8_t a;
44 uint_fast8_t b;
45 char *str;
48 /* Initialize whatever UI is present */
49 int
50 ui_init(struct quiver *q);
52 /* Tear down whatever UI was made */
53 int
54 ui_teardown(void);
56 /* Deal with the fact that the quiver was changed */
57 int
58 ui_respond_quiver_change(void);
60 /* Acknowledge a successful load */
61 int
62 ui_respond_successful_load(const char *filename);
64 /* Acknowledge a successful save */
65 int
66 ui_respond_successful_save(const char *filename);
68 /* Record that a frame has been started */
69 int
70 ui_start_frame(void);
72 /* Draw a frame, sleep to framelimit */
73 int
74 ui_finish_frame(void);
76 /* Get some kind of ui-agnostic event (like `quit' or `mutate' */
77 int
78 ui_get_event(struct ui_event *e, uint_fast8_t *more);