Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
window.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <banjo/api.h>
13#include <banjo/bitmap.h>
14#include <banjo/input.h>
15#include <banjo/memory.h>
16
18typedef struct bj_window_t bj_window;
19
34
54 const char* p_title,
55 uint16_t x,
56 uint16_t y,
57 uint16_t width,
58 uint16_t height,
59 uint8_t flags
60);
61
67BANJO_EXPORT void bj_window_del(
68 bj_window* p_window
69);
70
89 bj_window* p_window
90);
91
102BANJO_EXPORT bj_bool bj_window_should_close(
103 bj_window* p_window
104);
105
116typedef void(* bj_window_enter_event_t)(bj_window* p_window, bj_bool enter, int x, int y);
117
127typedef void(* bj_window_cursor_event_t)(bj_window* p_window, int x, int y);
128
139typedef void(* bj_window_button_event_t)(bj_window* p_window, int, bj_event_action action, int x, int y);
140
153typedef void(* bj_window_key_event_t)(bj_window* p_window, bj_event_action action, bj_key key, int scancode);
154
170 bj_window* p_window,
171 bj_window_cursor_event_t p_callback
172);
173
174
191 bj_window* p_window,
192 bj_window_button_event_t p_callback
193);
194
195
221 bj_window* p_window,
222 bj_window_key_event_t p_callback
223);
224
238
255 bj_window* p_window,
256 bj_window_enter_event_t p_callback
257);
258
274BANJO_EXPORT uint8_t bj_window_get_flags(
275 bj_window* p_window,
276 uint8_t flags
277);
278
279
286BANJO_EXPORT void bj_poll_events(
287 void
288);
289
319 bj_window* p_window,
320 bj_error** p_error
321);
322
344BANJO_EXPORT int bj_window_get_size(
345 const bj_window* p_window,
346 int* width,
347 int* height
348);
349
366 bj_window* p_window
367);
368
General-purpose definitions for Banjo API.
Header file for Bitmap type.
struct bj_bitmap_t bj_bitmap
Typedef for the bj_bitmap struct.
Definition bitmap.h:22
Error structure.
Definition error.h:131
enum bj_event_action_t bj_event_action
Event action type enumeration.
enum bj_key_t bj_key
List of possible keys on a keyboard.
bj_window_button_event_t bj_window_set_button_event(bj_window *p_window, bj_window_button_event_t p_callback)
Set the callback for button events.
int bj_window_get_size(const bj_window *p_window, int *width, int *height)
Retrieve the size of the window.
bj_window_flag_t
A set of flags describing some properties of a bj_window.
Definition window.h:28
void(* bj_window_button_event_t)(bj_window *p_window, int, bj_event_action action, int x, int y)
Callback type for functions called when a mouse button is pressed or released.
Definition window.h:139
bj_window * bj_window_new(const char *p_title, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t flags)
Create a new bj_window with the specified attributes.
bj_bool bj_window_should_close(bj_window *p_window)
Get the close flag state of a window.
struct bj_window_t bj_window
Opaque typedef for the window type.
Definition window.h:18
void(* bj_window_enter_event_t)(bj_window *p_window, bj_bool enter, int x, int y)
Callback type for functions called when the mouse cursor enters a window.
Definition window.h:116
bj_window_cursor_event_t bj_window_set_cursor_event(bj_window *p_window, bj_window_cursor_event_t p_callback)
Set the callback for cursor events.
void(* bj_window_key_event_t)(bj_window *p_window, bj_event_action action, bj_key key, int scancode)
Callback type for functions called when a keyboard key is pressed or released.
Definition window.h:153
void(* bj_window_cursor_event_t)(bj_window *p_window, int x, int y)
Callback type for functions called when the mouse cursor position changes.
Definition window.h:127
enum bj_window_flag_t bj_window_flag
A set of flags describing some properties of a bj_window.
bj_bitmap * bj_window_get_framebuffer(bj_window *p_window, bj_error **p_error)
Return the framebuffer attached to the window.
void bj_close_on_escape(bj_window *, bj_event_action, bj_key, int)
An event call back for closing the window when escape key is pressed.
void bj_poll_events(void)
Polls all pending events and dispatch them to callbacks.
uint8_t bj_window_get_flags(bj_window *p_window, uint8_t flags)
Get window flags.
void bj_window_set_should_close(bj_window *p_window)
Flag a given window to be closed.
void bj_window_del(bj_window *p_window)
Deletes a bj_window object and releases associated memory.
void bj_window_update_framebuffer(bj_window *p_window)
Copy window's framebuffer onto screen.
bj_window_enter_event_t bj_window_set_enter_event(bj_window *p_window, bj_window_enter_event_t p_callback)
Set the callback for enter events.
bj_window_key_event_t bj_window_set_key_event(bj_window *p_window, bj_window_key_event_t p_callback)
Set the callback for key events.
@ BJ_WINDOW_FLAG_NONE
No Flag.
Definition window.h:29
@ BJ_WINDOW_FLAG_KEY_REPEAT
Key repeat event is enabled (see bj_window_set_key_event).
Definition window.h:31
@ BJ_WINDOW_FLAG_ALL
All flags set.
Definition window.h:32
@ BJ_WINDOW_FLAG_CLOSE
Window should be closed by the application.
Definition window.h:30
Header file for various event types.
All memory-related functions, including custom allocators.