ladybird/Kernel/GUITypes.h
Andreas Kling 78696236d3 Add very basic KeyDown events to the GUI event stream.
The Terminal program now hosts an interactive shell. :^)
2019-01-15 06:51:00 +01:00

90 lines
1.7 KiB
C

#pragma once
#include <Widgets/Color.h>
#include <Widgets/Rect.h>
// GUI system call API types.
struct GUI_WindowFlags { enum {
Visible = 1 << 0,
}; };
typedef unsigned GUI_Color;
struct GUI_Point {
int x;
int y;
};
struct GUI_Size {
int width;
int height;
};
struct GUI_Rect {
GUI_Point location;
GUI_Size size;
};
struct GUI_CreateWindowParameters {
GUI_Rect rect;
Color background_color;
unsigned flags { 0 };
char title[128];
};
struct GUI_WindowBackingStoreInfo {
GUI_Size size;
size_t bpp;
size_t pitch;
RGBA32* pixels;
};
enum class GUI_MouseButton : unsigned char {
NoButton = 0,
Left = 1,
Right = 2,
Middle = 4,
};
struct GUI_KeyModifiers { enum {
Shift = 1 << 0,
Alt = 1 << 1,
Ctrl = 1 << 2,
}; };
struct GUI_Event {
enum Type : unsigned {
Invalid,
Paint,
MouseMove,
MouseDown,
MouseUp,
KeyDown,
KeyUp,
};
Type type { Invalid };
int window_id { -1 };
union {
struct {
GUI_Rect rect;
} paint;
struct {
GUI_Point position;
GUI_MouseButton button;
} mouse;
struct {
char character;
unsigned modifiers;
} key;
};
};
inline Rect::Rect(const GUI_Rect& r) : Rect(r.location, r.size) { }
inline Point::Point(const GUI_Point& p) : Point(p.x, p.y) { }
inline Size::Size(const GUI_Size& s) : Size(s.width, s.height) { }
inline Rect::operator GUI_Rect() const { return { m_location, m_size }; }
inline Point::operator GUI_Point() const { return { m_x, m_y }; }
inline Size::operator GUI_Size() const { return { m_width, m_height }; }