2019-01-13 01:59:38 +01:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-19 23:22:46 +01:00
|
|
|
#include <SharedGraphics/Color.h>
|
|
|
|
#include <SharedGraphics/Rect.h>
|
2019-01-13 01:59:38 +01:00
|
|
|
|
2019-01-13 05:08:26 +01:00
|
|
|
// GUI system call API types.
|
2019-01-13 01:59:38 +01:00
|
|
|
|
|
|
|
struct GUI_WindowFlags { enum {
|
|
|
|
Visible = 1 << 0,
|
|
|
|
}; };
|
|
|
|
|
|
|
|
typedef unsigned GUI_Color;
|
|
|
|
|
2019-01-14 14:21:51 +01:00
|
|
|
struct GUI_Point {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GUI_Size {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GUI_Rect {
|
|
|
|
GUI_Point location;
|
|
|
|
GUI_Size size;
|
|
|
|
};
|
|
|
|
|
2019-01-20 06:02:09 +01:00
|
|
|
struct GUI_WindowParameters {
|
2019-01-14 14:21:51 +01:00
|
|
|
GUI_Rect rect;
|
2019-01-13 05:08:26 +01:00
|
|
|
Color background_color;
|
|
|
|
unsigned flags { 0 };
|
2019-01-13 01:59:38 +01:00
|
|
|
char title[128];
|
|
|
|
};
|
2019-01-13 05:03:17 +01:00
|
|
|
|
2019-01-14 15:25:34 +01:00
|
|
|
struct GUI_WindowBackingStoreInfo {
|
2019-01-24 23:40:12 +01:00
|
|
|
void* backing_store_id;
|
2019-01-14 15:25:34 +01:00
|
|
|
GUI_Size size;
|
|
|
|
size_t bpp;
|
|
|
|
size_t pitch;
|
|
|
|
RGBA32* pixels;
|
|
|
|
};
|
|
|
|
|
2019-01-14 14:21:51 +01:00
|
|
|
enum class GUI_MouseButton : unsigned char {
|
|
|
|
NoButton = 0,
|
2019-01-15 06:49:52 +01:00
|
|
|
Left = 1,
|
|
|
|
Right = 2,
|
|
|
|
Middle = 4,
|
2019-01-13 05:03:17 +01:00
|
|
|
};
|
|
|
|
|
2019-01-15 06:49:52 +01:00
|
|
|
struct GUI_KeyModifiers { enum {
|
|
|
|
Shift = 1 << 0,
|
|
|
|
Alt = 1 << 1,
|
|
|
|
Ctrl = 1 << 2,
|
|
|
|
}; };
|
|
|
|
|
|
|
|
|
2019-01-14 14:21:51 +01:00
|
|
|
struct GUI_Event {
|
|
|
|
enum Type : unsigned {
|
|
|
|
Invalid,
|
|
|
|
Paint,
|
|
|
|
MouseMove,
|
|
|
|
MouseDown,
|
|
|
|
MouseUp,
|
2019-01-15 06:49:52 +01:00
|
|
|
KeyDown,
|
|
|
|
KeyUp,
|
2019-01-17 17:38:04 +01:00
|
|
|
WindowActivated,
|
|
|
|
WindowDeactivated,
|
2019-02-05 10:31:37 +01:00
|
|
|
WindowCloseRequest,
|
2019-01-14 14:21:51 +01:00
|
|
|
};
|
|
|
|
Type type { Invalid };
|
|
|
|
int window_id { -1 };
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
GUI_Rect rect;
|
|
|
|
} paint;
|
|
|
|
struct {
|
|
|
|
GUI_Point position;
|
|
|
|
GUI_MouseButton button;
|
2019-01-20 07:03:38 +01:00
|
|
|
unsigned buttons;
|
2019-01-14 14:21:51 +01:00
|
|
|
} mouse;
|
2019-01-15 06:49:52 +01:00
|
|
|
struct {
|
|
|
|
char character;
|
2019-01-21 07:28:04 +01:00
|
|
|
byte key;
|
|
|
|
byte modifiers;
|
|
|
|
bool ctrl : 1;
|
|
|
|
bool alt : 1;
|
|
|
|
bool shift : 1;
|
2019-01-15 06:49:52 +01:00
|
|
|
} key;
|
2019-01-14 14:21:51 +01:00
|
|
|
};
|
2019-01-13 05:03:17 +01:00
|
|
|
};
|
2019-01-14 14:21:51 +01:00
|
|
|
|
|
|
|
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 }; }
|