summaryrefslogtreecommitdiff
path: root/userland/libgui/libgui.h
blob: 07fd3db661904aa3b074cc7fac7ef99b0f1250c6 (plain)
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
#ifndef LIBGUI_H
#define LIBGUI_H
#include <stddef.h>
#include <stdint.h>

#define WINDOWSERVER_EVENT_KEYPRESS 0
#define WINDOWSERVER_EVENT_WINDOW_EXIT 1

typedef struct {
  int ws_socket;
  int bitmap_fd;
  uint32_t *bitmap_ptr;
  int x;
  int y;
  int sx;
  int sy;
} GUI_Window;

// Taken from drivers/keyboard.c
struct KEY_EVENT {
  char c;
  uint8_t mode;    // (shift (0 bit)) (alt (1 bit))
  uint8_t release; // 0 pressed, 1 released
};

typedef struct {
  int type;
  struct KEY_EVENT ev;
} WS_EVENT;

GUI_Window *GUI_CreateWindow(uint32_t x, uint32_t y, uint32_t sx, uint32_t sy);
void GUI_DrawFont(GUI_Window *w, uint32_t px, uint32_t py, const uint32_t c);
void GUI_UpdateWindow(GUI_Window *w);
void GUI_OverwriteFont(GUI_Window *w, uint32_t px, uint32_t py,
                       const uint32_t color);
void GUI_ClearScreen(GUI_Window *w, uint32_t color);
void GUI_EventLoop(GUI_Window *w, void (*event_handler)(WS_EVENT ev));
#endif