Skip to content

Commit b989bce

Browse files
committed
Lecture 118 - Building the Window header files
1 parent 15d8c27 commit b989bce

2 files changed

Lines changed: 104 additions & 0 deletions

File tree

PeachOS64Bit/src/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@
6161

6262
#define PEACHOS_KEYBOARD_BUFFER_SIZE 1024
6363

64+
#define WINDOW_MAX_TITLE 128
6465
#endif

PeachOS64Bit/src/graphics/window.h

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#ifndef GRAPHICS_WINDOW_H
2+
#define GRAPHICS_WINDOW_H
3+
#include "graphics/terminal.h"
4+
#include "graphics/graphics.h"
5+
#include "config.h"
6+
#include <stddef.h>
7+
#include <stdint.h>
8+
9+
enum
10+
{
11+
WINDOW_EVENT_TYPE_NULL,
12+
WINDOW_EVENT_TYPE_FOCUS,
13+
WINDOW_EVENT_TYPE_LOST_FOCUS,
14+
WINDOW_EVENT_TYPE_MOUSE_MOVE,
15+
WINDOW_EVENT_TYPE_MOUSE_CLICK,
16+
WINDOW_EVENT_TYPE_WINDOW_CLOSE,
17+
WINDOW_EVENT_TYPE_KEY_PRESS
18+
};
19+
20+
struct window_event
21+
{
22+
int type;
23+
int win_id;
24+
struct window* window;
25+
union
26+
{
27+
struct
28+
{
29+
// no extra data for focus event
30+
} focus;
31+
32+
struct
33+
{
34+
int x;
35+
int y;
36+
} move;
37+
38+
struct
39+
{
40+
int x;
41+
int y;
42+
} click;
43+
44+
struct
45+
{
46+
int key;
47+
} keypress;
48+
} data;
49+
};
50+
typedef int (*WINDOW_EVENT_HANDLER)(struct window* window, struct window_event* event);
51+
52+
enum
53+
{
54+
WINDOW_FLAG_BORDERLESS = 0b00000001,
55+
WINDOW_FLAG_CLICK_THROUGH = 0b00000010,
56+
WINDOW_FLAG_BACKGROUND_TRANSPARENT = 0b00000100
57+
};
58+
struct window
59+
{
60+
int id;
61+
struct terminal* title_bar_terminal;
62+
// Terminal for the body of the window
63+
struct terminal* terminal;
64+
65+
// Contains subgraphics for titlebar window and borders
66+
struct graphics_info* root_graphics;
67+
68+
struct graphics_info* title_bar_graphics;
69+
70+
struct graphics_info* graphics;
71+
72+
struct
73+
{
74+
struct
75+
{
76+
size_t x;
77+
size_t y ;
78+
size_t width;
79+
size_t height;
80+
} close_btn;
81+
} title_bar_components;
82+
83+
struct
84+
{
85+
// vector of WINDOW_EVENT_HANDLER*
86+
struct vector* handlers;
87+
} event_handlers;
88+
89+
size_t width;
90+
size_t height;
91+
92+
size_t x;
93+
size_t y;
94+
95+
// Determines which window is drawn first
96+
size_t zindex;
97+
98+
// Window title
99+
char title[WINDOW_MAX_TITLE];
100+
int flags;
101+
102+
};
103+
#endif

0 commit comments

Comments
 (0)