Reduce flicker on some SDL platforms
[clav.git] / ui.h
blobc4acb6ec5a9033a8c7cba960f1254241edd7e98b
1 /*
2 * Copyright (c) 2016-2019, 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_fast32_t a;
44 uint_fast32_t b;
45 char *str;
48 /* Initialize whatever UI is present */
49 int ui_init(struct quiver *q);
51 /* Tear down whatever UI was made */
52 int ui_teardown(void);
54 /* Deal with the fact that the quiver was changed */
55 int ui_respond_quiver_change(void);
57 /* Acknowledge a successful load */
58 int ui_respond_successful_load(const char *filename);
60 /* Acknowledge a successful save */
61 int ui_respond_successful_save(const char *filename);
63 /* Record that a frame has been started */
64 int ui_start_frame(void);
66 /* Draw a frame, sleep to framelimit */
67 int ui_finish_frame(void);
69 /* Get some kind of ui-agnostic event (like `quit' or `mutate' */
70 int ui_get_event(struct ui_event *e, uint_fast8_t *more);